Example usage for android.os Bundle putParcelableArrayList

List of usage examples for android.os Bundle putParcelableArrayList

Introduction

In this page you can find the example usage for android.os Bundle putParcelableArrayList.

Prototype

public void putParcelableArrayList(@Nullable String key, @Nullable ArrayList<? extends Parcelable> value) 

Source Link

Document

Inserts a List of Parcelable values into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.ultramegasoft.flavordex2.fragment.EditCatFragment.java

@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelableArrayList(STATE_EXTRA_FIELDS, mExtraFields);
    outState.putParcelableArrayList(STATE_FLAVOR_FIELDS, mFlavorFields);
}

From source file:com.brucetoo.imagebrowse.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    imgList.add(0, "http://cdn.at.cn/upload/146336617940.jpg");
    imgList.add(1, "http://cdn.at.cn/upload/146540079128.jpg");
    imgList.add(2, "http://cdn.at.cn/upload/146528287960.jpg");
    imgList.add(3, "http://cdn.at.cn/upload/146271377052.jpg");
    imgList.add(4, "http://cdn.at.cn/upload/146502027460.jpg");
    imgList.add(5, "http://cdn.at.cn/upload/146296005117.jpg");
    imgList.add(6, "http://cdn.at.cn/upload/146386101517.jpg");
    imgList.add(7, "http://cdn.at.cn/upload/146289180072.jpg");
    imgList.add(8, "http://cdn.at.cn/upload/146378563799.jpg");
    //        imgList.add(0, "http://img6.cache.netease.com/3g/2015/9/30/20150930091938133ad.jpg");
    //        imgList.add(1, "http://img2.cache.netease.com/3g/2015/9/30/2015093000515435aff.jpg");
    //        imgList.add(2, "http://img5.cache.netease.com/3g/2015/9/30/20150930075225737e5.jpg");
    //        imgList.add(3, "http://img5.cache.netease.com/3g/2015/9/29/20150929213007cd8cd.jpg");
    //        imgList.add(4, "http://img3.cache.netease.com/3g/2015/9/29/20150929162747a8bfa.jpg");
    //        imgList.add(5, "http://img2.cache.netease.com/3g/2015/9/30/20150930091208cf03c.jpg");
    //        imgList.add(6, "http://img2.cache.netease.com/3g/2015/9/30/2015093000515435aff.jpg");
    //        imgList.add(7, "http://img5.cache.netease.com/3g/2015/9/29/20150929213007cd8cd.jpg");
    //        imgList.add(8, "http://img3.cache.netease.com/3g/2015/9/29/20150929162747a8bfa.jpg");
    gridView = (GridView) findViewById(R.id.gridview);
    root = findViewById(R.id.layout_root);
    final ImageAdapter adapter = new ImageAdapter();
    gridView.setAdapter(adapter);/*from ww w.  ja  va 2 s.c  o m*/

    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> parent, final View view, final int position, long id) {
            if (view.isEnabled()) {
                //Use of ImageBrowseFragment
                Bundle bundle = new Bundle();
                bundle.putStringArrayList(ImageInfo.INTENT_IMAGE_URLS, imgList);
                bundle.putParcelable(ImageInfo.INTENT_CLICK_IMAGE_INFO, ((PhotoView) view).getInfo());
                bundle.putInt(ImageInfo.INTENT_CLICK_IMAGE_POSITION, position);
                imgImageInfos.clear();
                //NOTE:if imgList.size >= the visible count in single screen,i will cause NullPointException
                //because item out of screen have been replaced/reused
                for (int i = 0; i < imgList.size(); i++) {
                    imgImageInfos.add(((PhotoView) parent.getChildAt(i)).getInfo());
                }
                parent.getChildAt(position);
                bundle.putParcelableArrayList(ImageInfo.INTENT_IMAGE_INFOS, imgImageInfos);
                getSupportFragmentManager()
                        .beginTransaction().replace(Window.ID_ANDROID_CONTENT,
                                ImageBrowseFragment.newInstance(bundle), "ViewPagerFragment")
                        .addToBackStack(null).commit();

                //Use of ImageBrowseDialogFragment
                //                    root.post(new Runnable() { // in case root view not inflate complete
                //                        @Override
                //                        public void run() {
                //                            Bundle bundle = new Bundle();
                //                            bundle.putStringArrayList(ImageInfo.INTENT_IMAGE_URLS, imgList);
                //                            final ImageInfo preImgInfo = ((PhotoView) view).getInfo();
                //                            bundle.putParcelable(ImageInfo.INTENT_CLICK_IMAGE_INFO, preImgInfo);
                //                            bundle.putInt(ImageInfo.INTENT_CLICK_IMAGE_POSITION, position);
                //                            imgImageInfos.clear();
                //                            for (int i = 0; i < imgList.size(); i++) {
                //                                imgImageInfos.add(((PhotoView) parent.getChildAt(i)).getInfo());
                //                            }
                //                            bundle.putParcelableArrayList(ImageInfo.INTENT_IMAGE_INFOS, imgImageInfos);
                //                            int[] position = new int[2];
                //                            root.getLocationOnScreen(position);
                //                            //Must correct the ImageInfo in DialogFragment
                //                            preImgInfo.correct(position, getStatusBarHeight());
                //                            for (ImageInfo item : imgImageInfos) {
                //                                item.correct(position,getStatusBarHeight());
                //                            }
                //                            ImageBrowseDialogFragment.newInstance(bundle).show(getSupportFragmentManager(), ImageBrowseDialogFragment.class.getSimpleName());
                //                        }
                //                    });
            }
        }
    });
}

From source file:de.uni_koblenz_landau.apow.LoginActivity.java

@Override
protected void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putString(ARG_NFC, mNFCTag);
    savedInstanceState.putInt(ARG_NFC_STATE, mNFCTextDrawable);
    savedInstanceState.putBoolean(ARG_AUTO_SIGN_OFF_DISMISSED, mAutoSignOffDismissed);
    savedInstanceState.putBoolean(ARG_PROGRESS, mProgress);
    if (mFirstRun) {
        savedInstanceState.putParcelableArrayList(ARG_LOCATIONS, (ArrayList<ListViewItem>) mLocations);
        savedInstanceState.putInt(ARG_LOCATION_SELECTION, mSetupLocationView.getSelectedItemPosition());
    }//w  w  w. j  av a2s .  c o m
}

From source file:com.open.file.manager.MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    ArrayList<String> oldfrags = mAdapter.getFragments();
    outState.putStringArrayList("fragments", oldfrags);
    outState.putInt("operation", FileOperations.currentaction);
    if (FileOperations.currentpath != null) {
        outState.putString("currentpath", FileOperations.currentpath);
    }//from w  w w. jav  a2 s.  c  o m
    if (FileOperations.conflicts != null && FileOperations.conflicts.size() > 0) {
        outState.putParcelableArrayList("conflicts", FileOperations.conflicts);
    }
    if (!FileOperations.operationqueue.isEmpty()) {
        ArrayList<String> oldoperations = new ArrayList<String>();
        for (File current : FileOperations.operationqueue) {
            oldoperations.add(current.getAbsolutePath());
        }
        outState.putStringArrayList("oldqueue", oldoperations);
    }
    ArrayList<String> oldselected = new ArrayList<String>();
    for (File current : selectedfiles) {
        oldselected.add(current.getAbsolutePath());
    }
    outState.putStringArrayList("selectedfiles", oldselected);
}

From source file:com.android.messaging.datamodel.action.SyncMessagesAction.java

@Override
protected Bundle doBackgroundWork() {
    final BugleGservices bugleGservices = BugleGservices.get();
    final DatabaseWrapper db = DataModel.get().getDatabase();

    final int maxMessagesToScan = bugleGservices.getInt(BugleGservicesKeys.SMS_SYNC_BATCH_MAX_MESSAGES_TO_SCAN,
            BugleGservicesKeys.SMS_SYNC_BATCH_MAX_MESSAGES_TO_SCAN_DEFAULT);

    final int initialMaxMessagesToUpdate = actionParameters.getInt(KEY_MAX_UPDATE);
    final int smsSyncSubsequentBatchSizeMin = bugleGservices.getInt(BugleGservicesKeys.SMS_SYNC_BATCH_SIZE_MIN,
            BugleGservicesKeys.SMS_SYNC_BATCH_SIZE_MIN_DEFAULT);
    final int smsSyncSubsequentBatchSizeMax = bugleGservices.getInt(BugleGservicesKeys.SMS_SYNC_BATCH_SIZE_MAX,
            BugleGservicesKeys.SMS_SYNC_BATCH_SIZE_MAX_DEFAULT);

    // Cap sync size to GServices limits
    final int maxMessagesToUpdate = Math.max(smsSyncSubsequentBatchSizeMin,
            Math.min(initialMaxMessagesToUpdate, smsSyncSubsequentBatchSizeMax));

    final long lowerBoundTimeMillis = actionParameters.getLong(KEY_LOWER_BOUND);
    final long upperBoundTimeMillis = actionParameters.getLong(KEY_UPPER_BOUND);

    LogUtil.i(TAG,//from   w w  w . j a  v  a  2s .  c om
            "SyncMessagesAction: Starting batch for messages from " + lowerBoundTimeMillis + " to "
                    + upperBoundTimeMillis + " (message update limit = " + maxMessagesToUpdate
                    + ", message scan limit = " + maxMessagesToScan + ")");

    // Clear last change time so that we can work out if this batch is dirty when it completes
    final SyncManager syncManager = DataModel.get().getSyncManager();

    // Clear the singleton cache that maps threads to recipients and to conversations.
    final SyncManager.ThreadInfoCache cache = syncManager.getThreadInfoCache();
    cache.clear();

    // Sms messages to store
    final ArrayList<SmsMessage> smsToAdd = new ArrayList<SmsMessage>();
    // Mms messages to store
    final LongSparseArray<MmsMessage> mmsToAdd = new LongSparseArray<MmsMessage>();
    // List of local SMS/MMS to remove
    final ArrayList<LocalDatabaseMessage> messagesToDelete = new ArrayList<LocalDatabaseMessage>();

    long lastTimestampMillis = SYNC_FAILED;
    if (syncManager.isSyncing(upperBoundTimeMillis)) {
        // Cursors
        final SyncCursorPair cursors = new SyncCursorPair(lowerBoundTimeMillis, upperBoundTimeMillis);

        // Actually compare the messages using cursor pair
        lastTimestampMillis = syncCursorPair(db, cursors, smsToAdd, mmsToAdd, messagesToDelete,
                maxMessagesToScan, maxMessagesToUpdate, cache);
    }
    final Bundle response = new Bundle();

    // If comparison succeeds bundle up the changes for processing in ActionService
    if (lastTimestampMillis > SYNC_FAILED) {
        final ArrayList<MmsMessage> mmsToAddList = new ArrayList<MmsMessage>();
        for (int i = 0; i < mmsToAdd.size(); i++) {
            final MmsMessage mms = mmsToAdd.valueAt(i);
            mmsToAddList.add(mms);
        }

        response.putParcelableArrayList(BUNDLE_KEY_SMS_MESSAGES, smsToAdd);
        response.putParcelableArrayList(BUNDLE_KEY_MMS_MESSAGES, mmsToAddList);
        response.putParcelableArrayList(BUNDLE_KEY_MESSAGES_TO_DELETE, messagesToDelete);
    }
    response.putLong(BUNDLE_KEY_LAST_TIMESTAMP, lastTimestampMillis);

    return response;
}

From source file:de.sourcestream.movieDB.controller.TVList.java

/**
 * Called to ask the fragment to save its current dynamic state,
 * so it can later be reconstructed in a new instance of its process is restarted.
 *
 * @param outState Bundle in which to place your saved state.
 *//*from   w  w w .j  av  a 2  s.c o  m*/
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    // Used to avoid bug where we add item in the back stack
    // and if we change orientation twice the item from the back stack has null values
    if (save != null)
        outState.putBundle("save", save);
    else {
        Bundle send = new Bundle();
        send.putInt("checkLoadMore", checkLoadMore);
        send.putInt("totalPages", totalPages);
        send.putString("currentListURL", getCurrentList());
        send.putString("title", getTitle());
        send.putBoolean("isLoading", isLoading);
        send.putInt("lastVisitedTV", lastVisitedTV);
        if (backState == 1) {
            send.putInt("backState", 1);
            send.putParcelableArrayList("listData", tvList);
            // used to restore the scroll listener variables
            send.putInt("currentPage", endlessScrollListener.getCurrentPage());
            send.putInt("oldCount", endlessScrollListener.getOldCount());
            send.putBoolean("loading", endlessScrollListener.getLoading());
            // Save scroll position
            if (listView != null) {
                Parcelable listState = listView.onSaveInstanceState();
                send.putParcelable("listViewScroll", listState);
            }
        } else
            send.putInt("backState", 0);

        outState.putBundle("save", send);
    }
}

From source file:com.fbartnitzek.tasteemall.MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    //        Log.v(LOG_TAG, "onSaveInstanceState, hashCode=" + this.hashCode() + ", " + "outState = [" + outState + "]");
    super.onSaveInstanceState(outState);
    outState.putString(STATE_SEARCH_PATTERN, mSearchPattern);
    outState.putParcelableArrayList(STATE_PRODUCERS_TO_GEOCODE, mProducerLocationUris);
    outState.putParcelableArrayList(STATE_REVIEW_LOCATIONS_TO_GEOCODE, mReviewLocationUris);
    outState.putInt(STATE_PAGER_POSITION, mPagerPosition);
}

From source file:de.sourcestream.movieDB.controller.MovieList.java

/**
 * Called to ask the fragment to save its current dynamic state,
 * so it can later be reconstructed in a new instance of its process is restarted.
 *
 * @param outState Bundle in which to place your saved state.
 *//*from   w w  w. ja  v a 2  s.com*/
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    // Used to avoid bug where we add item in the back stack
    // and if we change orientation twice the item from the back stack has null values
    if (save != null)
        outState.putBundle("save", save);
    else {
        Bundle send = new Bundle();
        send.putInt("checkLoadMore", checkLoadMore);
        send.putInt("totalPages", totalPages);
        send.putString("currentListURL", getCurrentList());
        send.putString("title", getTitle());
        send.putBoolean("isLoading", isLoading);
        send.putInt("lastVisitedMovie", lastVisitedMovie);
        if (backState == 1) {
            send.putInt("backState", 1);
            send.putParcelableArrayList("listData", moviesList);
            // used to restore the scroll listener variables
            send.putInt("currentPage", endlessScrollListener.getCurrentPage());
            send.putInt("oldCount", endlessScrollListener.getOldCount());
            send.putBoolean("loading", endlessScrollListener.getLoading());
            // Save scroll position
            if (listView != null) {
                Parcelable listState = listView.onSaveInstanceState();
                send.putParcelable("listViewScroll", listState);
            }
        } else
            send.putInt("backState", 0);

        outState.putBundle("save", send);
    }
}

From source file:app.hacked.MainActivity.java

@Override
public void onProjectItemSelected(Project project) {
    if (findViewById(R.id.ProjectDetails) != null) {
        mTwoPane = true;/*from ww w.j a v a  2s .c  om*/

        Bundle arguments = new Bundle();
        arguments.putInt(ProjectDetailsFragment.PROJECTID, project.ID);
        arguments.putString(ProjectDetailsFragment.NAME, project.Name);
        arguments.putString(ProjectDetailsFragment.SYNOPSIS, project.Synopsis);
        arguments.putString(ProjectDetailsFragment.DESCRIPTION, project.Description);
        arguments.putString(ProjectDetailsFragment.LOCATION, project.Location);
        arguments.putString(ProjectDetailsFragment.TECHNOLOGIES, project.Technologies);
        arguments.putInt(ProjectDetailsFragment.POPULARITY, project.Popularity);
        //arguments.putString(ProjectDetailsFragment.TEAMMEMBERS, project.getTeamMembers());
        arguments.putBoolean(ProjectDetailsFragment.ARG_2PANE, true);
        arguments.putParcelableArrayList(ProjectDetailsFragment.TEAMMEMBERS, project.TeamMembers);

        ProjectDetailsFragment fragment = new ProjectDetailsFragment();
        fragment.setArguments(arguments);
        fragment.setHasOptionsMenu(true);
        getSupportFragmentManager().beginTransaction().replace(R.id.ProjectDetails, fragment).commit();
    } else {
        mTwoPane = false;

        Intent detailIntent = new Intent(this, ProjectDetailsActivity.class);
        detailIntent.putExtra(ProjectDetailsFragment.PROJECTID, project.ID);
        detailIntent.putExtra(ProjectDetailsFragment.NAME, project.Name);
        detailIntent.putExtra(ProjectDetailsFragment.SYNOPSIS, project.Synopsis);
        detailIntent.putExtra(ProjectDetailsFragment.DESCRIPTION, project.Description);
        detailIntent.putExtra(ProjectDetailsFragment.LOCATION, project.Location);
        detailIntent.putExtra(ProjectDetailsFragment.TECHNOLOGIES, project.Technologies);
        detailIntent.putExtra(ProjectDetailsFragment.POPULARITY, project.Popularity);
        //detailIntent.putExtra(ProjectDetailsFragment.TEAMMEMBERS, project.getTeamMembers());
        detailIntent.putParcelableArrayListExtra(ProjectDetailsFragment.TEAMMEMBERS, project.TeamMembers);
        detailIntent.putExtra(ProjectDetailsFragment.ARG_2PANE, false);
        startActivity(detailIntent);
    }
}

From source file:com.krayzk9s.imgurholo.ui.SingleImageFragment.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putParcelable("imageData", imageData);
    savedInstanceState.putParcelableArrayList("commentData", commentArray);
    savedInstanceState.putBoolean("inGallery", inGallery);
    // Always call the superclass so it can save the view hierarchy state
    super.onSaveInstanceState(savedInstanceState);
}