江苏开放大学Android基础(专)第一次形成性考核作业

微信小程序
资源下载
下载价格10

作业说明:

1.做作业之前首先在封面填上自己的学号和姓名,做完作业后请写上作业完成时间。

2.学习完第1-4单元之后必须完成本次作业,并请在规定时间内通过学习平台提交Word文档形式的电子作业,本次作业占形成性考核总成绩的22%。

作业内容:

学习单元2、3、4中实验部分的项目源文件压缩包。请将源码贴在以下位置,格式为先写文件名后贴代码,如下:

1、

package uk.co.senab.photup.events;

import java.util.ArrayList;

import java.util.List;

import uk.co.senab.photup.model.PhotoUpload;

public class PhotoSelectionAddedEvent {

    private final List<PhotoUpload> mUploads;

    public PhotoSelectionAddedEvent(List<PhotoUpload> uploads) {

        mUploads = uploads;

    }

    public PhotoSelectionAddedEvent(PhotoUpload upload) {

        mUploads = new ArrayList<PhotoUpload>();

        mUploads.add(upload);

    }

    public List<PhotoUpload> getTargets() {

        return mUploads;

    }

    public PhotoUpload getTarget() {

        if (isSingleChange()) {

            return mUploads.get(0);

        } else {

            throw new IllegalStateException(“Can only call this when isSingleChange returns true”);

        }

    }

    public boolean isSingleChange() {

        return mUploads.size() == 1;

    }

}

2. 

package uk.co.senab.photup.events;

import java.util.ArrayList;

import java.util.List;

import uk.co.senab.photup.model.PhotoUpload;

public class PhotoSelectionRemovedEvent {

   private final List<PhotoUpload> mUploads;

   public PhotoSelectionRemovedEvent(List<PhotoUpload> uploads) {

        mUploads = uploads;

   }

    public PhotoSelectionRemovedEvent(PhotoUpload upload) {

        mUploads = new ArrayList<PhotoUpload>();

        mUploads.add(upload);

    }

   public List<PhotoUpload> getTargets() {

       return mUploads;

    }

  public PhotoUpload getTarget() {

      if (isSingleChange()) {

        return mUploads.get(0);

     } else {

        throw new IllegalStateException(“Can only call this when isSingleChange returns t

       }

   }

    public boolean isSingleChange() {

        return mUploads.size() == 1;

    }

}

3

package uk.co.senab.photup.facebook;

import com.facebook.android.Facebook;

import com.facebook.android.FacebookError;

import com.facebook.android.Util;

import org.json.JSONArray;

import org.json.JSONException;

import org.json.JSONObject;

import android.location.Location;

import android.os.Bundle;

import android.text.TextUtils;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Collections;

import java.util.List;

import uk.co.senab.photup.model.Account;

import uk.co.senab.photup.model.Album;

import uk.co.senab.photup.model.Event;

import uk.co.senab.photup.model.FbUser;

import uk.co.senab.photup.model.Group;

import uk.co.senab.photup.model.Place;

public class FacebookRequester {

    // private final Context mContext;

    private final Account mAccount;

    private final Facebook mFacebook;

    public FacebookRequester(Account account) {

        mAccount = account;

        mFacebook = mAccount.getFacebook();

    }

    public List<Place> getPlaces(Location location, String searchQuery)

            throws FacebookError, JSONException {

        Bundle b = new Bundle();

        b.putString(“date_format”, “U”);

        b.putString(“limit”, “75”);

        b.putString(“type”, “place”);

        if (null != location) {

            b.putString(“center”, location.getLatitude() + “,” + location.getLongitude());

        }

        if (TextUtils.isEmpty(searchQuery)) {

            b.putString(“distance”, “2000”);

        } else {

            b.putString(“q”, searchQuery);

        }

        String response = null;

        try {

            response = mFacebook.request(“search”, b);

        } catch (IOException e) {

            e.printStackTrace();

        }

        if (null == response) {

            return null;

        }

        JSONObject document = Util.parseJson(response);

        JSONArray data = document.getJSONArray(“data”);

        ArrayList<Place> places = new ArrayList<Place>(data.length());

        JSONObject object;

        for (int i = 0, z = data.length(); i < z; i++) {

            try {

                object = data.getJSONObject(i);

                places.add(new Place(object, mAccount));

            } catch (JSONException e) {

                e.printStackTrace();

            }

        }

        return places;

    }

    public List<FbUser> getFriends() throws FacebookError, JSONException {

        Bundle b = new Bundle();

        b.putString(“date_format”, “U”);

        b.putString(“limit”, “3000”);

        String response = null;

        try {

            response = mFacebook.request(“me/friends”, b);

        } catch (IOException e) {

            e.printStackTrace();

        }

        if (null == response) {

            return null;

        }

        JSONObject document = Util.parseJson(response);

        JSONArray data = document.getJSONArray(“data”);

        ArrayList<FbUser> friends = new ArrayList<FbUser>(data.length() * 2);

        friends.add(FbUser.getMeFromAccount(mAccount));

        JSONObject object;

        for (int i = 0, z = data.length(); i < z; i++) {

            try {

                object = data.getJSONObject(i);

                friends.add(new FbUser(object, mAccount));

            } catch (JSONException e) {

                e.printStackTrace();

            }

        }

        Collections.sort(friends, FbUser.getComparator());

        return friends;

    }

    public List<Group> getGroups() throws FacebookError, JSONException {

        Bundle b = new Bundle();

        b.putString(“date_format”, “U”);

        b.putString(“limit”, “3000”);

        b.putString(“fields”, Group.GRAPH_FIELDS);

        String response = null;

        try {

            response = mFacebook.request(“me/groups”, b);

        } catch (IOException e) {

            e.printStackTrace();

        }

        if (null == response) {

            return null;

        }

        JSONObject document = Util.parseJson(response);

        JSONArray data = document.getJSONArray(“data”);

        ArrayList<Group> groups = new ArrayList<Group>(data.length() * 2);

        JSONObject object;

        for (int i = 0, z = data.length(); i < z; i++) {

            try {

                object = data.getJSONObject(i);

                groups.add(new Group(object, mAccount));

            } catch (JSONException e) {

                e.printStackTrace();

            }

        }

        return groups;

    }

    public List<Event> getEvents() throws FacebookError, JSONException {

        Bundle b = new Bundle();

        b.putString(“date_format”, “U”);

        b.putString(“limit”, “3000”);

        b.putString(“fields”, Event.GRAPH_FIELDS);

        String response = null;

        try {

            response = mFacebook.request(“me/events”, b);

        } catch (IOException e) {

            e.printStackTrace();

        }

        if (null == response) {

            return null;

        }

        JSONObject document = Util.parseJson(response);

        JSONArray data = document.getJSONArray(“data”);

        ArrayList<Event> events = new ArrayList<Event>(data.length() * 2);

        JSONObject object;

        for (int i = 0, z = data.length(); i < z; i++) {

            try {

                object = data.getJSONObject(i);

                events.add(new Event(object, mAccount));

            } catch (JSONException e) {

                e.printStackTrace();

            }

        }

        return events;

    }

    public List<Account> getAccounts() throws FacebookError, JSONException {

        Bundle b = new Bundle();

        b.putString(“date_format”, “U”);

        b.putString(“limit”, “3000”);

        String response = null;

        try {

            response = mFacebook.request(“me/accounts”, b);

        } catch (IOException e) {

            e.printStackTrace();

        }

        if (null == response) {

            return null;

        }

        JSONObject document = Util.parseJson(response);

        JSONArray data = document.getJSONArray(“data”);

        ArrayList<Account> accounts = new ArrayList<Account>(data.length() * 2);

        accounts.add(mAccount);

        JSONObject object;

        Account account;

        for (int i = 0, z = data.length(); i < z; i++) {

            try {

                object = data.getJSONObject(i);

                account = new Account(object);

                if (account.hasAccessToken()) {

                    accounts.add(account);

                }

            } catch (JSONException e) {

                e.printStackTrace();

            }

        }

        return accounts;

    }

    public List<Album> getUploadableAlbums() throws FacebookError, JSONException {

        Bundle b = new Bundle();

        b.putString(“date_format”, “U”);

        b.putString(“limit”, “3000”);

        String response = null;

        try {

            response = mFacebook.request(“me/albums”, b);

        } catch (IOException e) {

            e.printStackTrace();

        }

        if (null == response) {

            return null;

        }

        JSONObject document = Util.parseJson(response);

        JSONArray data = document.getJSONArray(“data”);

        ArrayList<Album> albums = new ArrayList<Album>(data.length());

        JSONObject object;

        for (int i = 0, z = data.length(); i < z; i++) {

            try {

                object = data.getJSONObject(i);

                Album album = new Album(object, mAccount);

                if (album.canUpload()) {

                    albums.add(album);

                }

            } catch (JSONException e) {

                e.printStackTrace();

            }

        }

        return albums;

    }

    public String createNewAlbum(String albumName, String description, String privacy) {

        Bundle b = new Bundle();

        b.putString(“name”, albumName);

        if (!TextUtils.isEmpty(description)) {

            b.putString(“message”, description);

        }

        if (!TextUtils.isEmpty(privacy)) {

            try {

                JSONObject object = new JSONObject();

                object.put(“value”, privacy);

                b.putString(“privacy”, object.toString());

            } catch (JSONException e) {

                e.printStackTrace();

            }

        }

        String response = null;

        try {

            response = mFacebook.request(“me/albums”, b, “POST”);

        } catch (IOException e) {

            e.printStackTrace();

        }

        if (null == response) {

            return null;

        }

        try {

            JSONObject document = Util.parseJson(response);

            return document.getString(“id”);

        } catch (FacebookError e) {

            e.printStackTrace();

        } catch (JSONException e) {

            e.printStackTrace();

        }

        return null;

    }

}

4

package uk.co.senab.photup.facebook;

import com.facebook.android.Facebook;

import android.content.Context;

import android.content.SharedPreferences;

import android.content.SharedPreferences.Editor;

import android.util.Log;

import uk.co.senab.photup.Constants;

import uk.co.senab.photup.Flags;

/**

 * A utility class for storing and retrieving Facebook session data.

 *

 * @author yariv

 */

public class Session {

    static final String TOKEN = “access_token”;

    static final String EXPIRES = “expires_in”;

    static final String KEY = “facebook-session”;

    static final String UID = “uid”;

    static final String NAME = “name”;

    // The Facebook object

    private Facebook fb;

    // The user id of the logged in user

    private String uid;

    // The user name of the logged in user

    private String name;

    /**

     * Constructor

     */

    public Session(Facebook fb, String uid, String name) {

        this.fb = fb;

        this.uid = uid;

        this.name = name;

    }

    /**

     * Returns the Facebook object

     */

    public Facebook getFb() {

        return fb;

    }

    /**

     * Returns the session user’s id

     */

    public String getUid() {

        return uid;

    }

    /**

     * Returns the session user’s name

     */

    public String getName() {

        return name;

    }

    /**

     * Stores the session data on disk.

     */

    public void save(Context context) {

        if (Flags.DEBUG) {

            Log.d(getClass().getSimpleName(), “Saving Session! Expires: ” + fb.getAccessExpires());

        }

        Editor editor = context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();

        editor.putString(TOKEN, fb.getAccessToken());

        editor.putLong(EXPIRES, fb.getAccessExpires());

        editor.putString(UID, uid);

        editor.putString(NAME, name);

        editor.commit();

    }

    /**

     * Loads the session data from disk.

     */

    public static Session restore(Context context) {

        SharedPreferences prefs = context.getSharedPreferences(KEY, Context.MODE_PRIVATE);

        Facebook fb = new Facebook(Constants.FACEBOOK_APP_ID);

        fb.setAccessToken(prefs.getString(TOKEN, null));

        fb.setAccessExpires(prefs.getLong(EXPIRES, 0));

        String uid = prefs.getString(UID, null);

        String name = prefs.getString(NAME, null);

        if (fb.isSessionValid() && uid != null && name != null) {

            return new Session(fb, uid, name);

        }

        return null;

    }

    /**

     * Clears the saved session data.

     */

    public static void clearSavedSession(Context context) {

        Editor editor = context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();

        editor.clear().commit();

    }

}

点点赞赏,手留余香 给TA打赏

AI创作

2023年春江苏开放大学大学英语(B)(1)过程性考核作业4
2023年春江苏开放大学大学英语(B)(1)过程性考核作业4
7分钟前 有人购买 去瞅瞅看
材料分析题 中国作为文明古国,有很多诗人留下了关于“礼仪”的诗句,如先秦屈原在《九歌·礼魂》中写到:“成礼兮会鼓,传芭兮代舞;姱女倡兮容与;春兰兮秋菊,长无绝兮终古。”唐代李峤在《经》中写到:“五千道德阐,三百礼仪成。” 宋代吕希哲在《绝句》中写到:“礼仪三百复三千,酬酢天机理必然。”宋代林同在《贤者之孝二百四十首·张霸》写到“幼也知孝让,居然合礼仪。”由此可见,礼仪在中国具有重要的意义和作用,请结合实例,谈谈礼仪的功能。
材料分析题 中国作为文明古国,有很多诗人留下了关于“礼仪”的诗句,如先秦屈原在《九歌·礼魂》中写到:“成礼兮会鼓,传芭兮代舞;姱女倡兮容与;春兰兮秋菊,长无绝兮终古。”唐代李峤在《经》中写到:“五千道德阐,三百礼仪成。” 宋代吕希哲在《绝句》中写到:“礼仪三百复三千,酬酢天机理必然。”宋代林同在《贤者之孝二百四十首·张霸》写到“幼也知孝让,居然合礼仪。”由此可见,礼仪在中国具有重要的意义和作用,请结合实例,谈谈礼仪的功能。
5分钟前 有人购买 去瞅瞅看
结合文学文本概念及体裁形式知识分析,《罗刹海市》是否属于文学文本,属于哪一类文学文本?请说明理由。
结合文学文本概念及体裁形式知识分析,《罗刹海市》是否属于文学文本,属于哪一类文学文本?请说明理由。
刚刚 有人购买 去瞅瞅看
支持多种货币
支持多种货币付款,满足您的付款需求
7天无忧退换
安心无忧购物,售后有保障
专业客服服务
百名资深客服7*24h在线服务
发货超时赔付
交易成功极速发货,专业水准保证时效性

站点公告

答案整门打包购买,价格优惠,有需要加微信
显示验证码

社交账号快速登录