Example usage for android.os Bundle putParcelableArray

List of usage examples for android.os Bundle putParcelableArray

Introduction

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

Prototype

public void putParcelableArray(@Nullable String key, @Nullable Parcelable[] value) 

Source Link

Document

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

Usage

From source file:nu.yona.timepicker.time.TimePickerDialog.java

@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
    if (mTimePicker != null) {
        outState.putParcelable(KEY_INITIAL_TIME, mTimePicker.getTime());
        outState.putBoolean(KEY_IS_24_HOUR_VIEW, mIs24HourMode);
        outState.putInt(KEY_CURRENT_ITEM_SHOWING, mTimePicker.getCurrentItemShowing());
        outState.putBoolean(KEY_IN_KB_MODE, mInKbMode);
        if (mInKbMode) {
            outState.putIntegerArrayList(KEY_TYPED_TIMES, mTypedTimes);
        }/*from  w  w  w . j ava 2s . co  m*/
        outState.putString(KEY_TITLE, mTitle);
        outState.putBoolean(KEY_THEME_DARK, mThemeDark);
        outState.putBoolean(KEY_THEME_DARK_CHANGED, mThemeDarkChanged);
        outState.putInt(KEY_ACCENT, mAccentColor);
        outState.putBoolean(KEY_VIBRATE, mVibrate);
        outState.putBoolean(KEY_DISMISS, mDismissOnPause);
        outState.putParcelableArray(KEY_SELECTABLE_TIMES, mSelectableTimes);
        outState.putParcelable(KEY_MIN_TIME, mMinTime);
        outState.putParcelable(KEY_MAX_TIME, mMaxTime);
        outState.putBoolean(KEY_ENABLE_SECONDS, mEnableSeconds);
        outState.putInt(KEY_OK_RESID, mOkResid);
        outState.putString(KEY_OK_STRING, mOkString);
        outState.putInt(KEY_CANCEL_RESID, mCancelResid);
        outState.putString(KEY_CANCEL_STRING, mCancelString);
    }

    if (mTimePickerEnd != null) {
        //Todo for second time picker when needed
    }
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void openMedia(final Context context, final long accountId, final boolean isPossiblySensitive,
        final ParcelableStatus status, final ParcelableDirectMessage message, final ParcelableMedia current,
        final ParcelableMedia[] media) {
    if (context == null || media == null)
        return;/*from ww  w  .  j a v  a 2s  .  c o  m*/
    final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    if (context instanceof FragmentActivity && isPossiblySensitive
            && !prefs.getBoolean(KEY_DISPLAY_SENSITIVE_CONTENTS, false)) {
        final FragmentActivity activity = (FragmentActivity) context;
        final FragmentManager fm = activity.getSupportFragmentManager();
        final DialogFragment fragment = new SensitiveContentWarningDialogFragment();
        final Bundle args = new Bundle();
        args.putLong(EXTRA_ACCOUNT_ID, accountId);
        args.putParcelable(EXTRA_CURRENT_MEDIA, current);
        if (status != null) {
            args.putParcelable(EXTRA_STATUS, status);
        }
        if (message != null) {
            args.putParcelable(EXTRA_MESSAGE, message);
        }
        args.putParcelableArray(EXTRA_MEDIA, media);
        fragment.setArguments(args);
        fragment.show(fm, "sensitive_content_warning");
    } else {
        openMediaDirectly(context, accountId, status, message, current, media);
    }
}

From source file:com.hippo.ehviewer.ui.scene.GalleryDetailScene.java

@Override
public void onClick(View v) {
    Context context = getContext2();
    MainActivity activity = getActivity2();
    if (null == context || null == activity) {
        return;/* w ww  .j  a  v  a  2s  .co  m*/
    }

    if (mTip == v) {
        if (request()) {
            adjustViewVisibility(STATE_REFRESH, true);
        }
    } else if (mOtherActions == v) {
        ensurePopMenu();
        if (mPopupMenu != null) {
            mPopupMenu.show();
        }
    } else if (mUploader == v) {
        String uploader = getUploader();
        if (TextUtils.isEmpty(uploader)) {
            return;
        }
        ListUrlBuilder lub = new ListUrlBuilder();
        lub.setMode(ListUrlBuilder.MODE_UPLOADER);
        lub.setKeyword(uploader);
        GalleryListScene.startScene(this, lub);
    } else if (mCategory == v) {
        int category = getCategory();
        if (category == -1) {
            return;
        }
        ListUrlBuilder lub = new ListUrlBuilder();
        lub.setCategory(category);
        GalleryListScene.startScene(this, lub);
    } else if (mDownload == v) {
        GalleryInfo galleryInfo = getGalleryInfo();
        if (galleryInfo != null) {
            CommonOperations.startDownload(activity, galleryInfo, false);
        }
    } else if (mRead == v) {
        GalleryInfo galleryInfo = null;
        if (mGalleryInfo != null) {
            galleryInfo = mGalleryInfo;
        } else if (mGalleryDetail != null) {
            galleryInfo = mGalleryDetail;
        }
        if (galleryInfo != null) {
            Intent intent = new Intent(activity, GalleryActivity.class);
            intent.setAction(GalleryActivity.ACTION_EH);
            intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, galleryInfo);
            startActivity(intent);
        }
    } else if (mInfo == v) {
        Bundle args = new Bundle();
        args.putParcelable(GalleryInfoScene.KEY_GALLERY_DETAIL, mGalleryDetail);
        startScene(new Announcer(GalleryInfoScene.class).setArgs(args));
    } else if (mHeartGroup == v) {
        if (mGalleryDetail != null && !mModifingFavorites) {
            boolean remove = false;
            if (EhDB.containLocalFavorites(mGalleryDetail.gid)) {
                EhDB.removeLocalFavorites(mGalleryDetail.gid);
                remove = true;
            }
            if (mGalleryDetail.isFavorited) {
                mModifingFavorites = true;
                CommonOperations.removeFromFavorites(activity, mGalleryDetail,
                        new ModifyFavoritesListener(context, activity.getStageId(), getTag(), true));
                remove = true;
            }
            if (!remove) {
                mModifingFavorites = true;
                CommonOperations.addToFavorites(activity, mGalleryDetail,
                        new ModifyFavoritesListener(context, activity.getStageId(), getTag(), false));
            }
            // Update UI
            updateFavoriteDrawable();
        }
    } else if (mShare == v) {
        String url = getGalleryDetailUrl(false);
        if (url != null) {
            AppHelper.share(activity, url);
        }
    } else if (mTorrent == v) {
        if (mGalleryDetail != null) {
            TorrentListDialogHelper helper = new TorrentListDialogHelper();
            Dialog dialog = new AlertDialog.Builder(context).setTitle(R.string.torrents)
                    .setView(R.layout.dialog_torrent_list).setOnDismissListener(helper).show();
            helper.setDialog(dialog, mGalleryDetail.torrentUrl);
        }
    } else if (mRate == v) {
        if (mGalleryDetail == null) {
            return;
        }
        if (mGalleryDetail.apiUid < 0) {
            showTip(R.string.sign_in_first, LENGTH_SHORT);
            return;
        }
        RateDialogHelper helper = new RateDialogHelper();
        Dialog dialog = new AlertDialog.Builder(context).setTitle(R.string.rate).setView(R.layout.dialog_rate)
                .setNegativeButton(android.R.string.cancel, null).setPositiveButton(android.R.string.ok, helper)
                .show();
        helper.setDialog(dialog, mGalleryDetail.rating);
    } else if (mSimilar == v) {
        showSimilarGalleryList();
    } else if (mSearchCover == v) {
        showCoverGalleryList();
    } else if (mComments == v) {
        if (mGalleryDetail == null) {
            return;
        }
        Bundle args = new Bundle();
        args.putLong(GalleryCommentsScene.KEY_API_UID, mGalleryDetail.apiUid);
        args.putString(GalleryCommentsScene.KEY_API_KEY, mGalleryDetail.apiKey);
        args.putLong(GalleryCommentsScene.KEY_GID, mGalleryDetail.gid);
        args.putString(GalleryCommentsScene.KEY_TOKEN, mGalleryDetail.token);
        args.putParcelableArray(GalleryCommentsScene.KEY_COMMENTS, mGalleryDetail.comments);
        startScene(new Announcer(GalleryCommentsScene.class).setArgs(args).setRequestCode(this,
                REQUEST_CODE_COMMENT_GALLERY));
    } else if (mPreviews == v) {
        if (null != mGalleryDetail) {
            Bundle args = new Bundle();
            args.putParcelable(GalleryPreviewsScene.KEY_GALLERY_INFO, mGalleryDetail);
            startScene(new Announcer(GalleryPreviewsScene.class).setArgs(args));
        }
    } else {
        Object o = v.getTag(R.id.tag);
        if (o instanceof String) {
            String tag = (String) o;
            ListUrlBuilder lub = new ListUrlBuilder();
            lub.setMode(ListUrlBuilder.MODE_TAG);
            lub.setKeyword(tag);
            GalleryListScene.startScene(this, lub);
            return;
        }

        GalleryInfo galleryInfo = getGalleryInfo();
        o = v.getTag(R.id.index);
        if (null != galleryInfo && o instanceof Integer) {
            int index = (Integer) o;
            Intent intent = new Intent(context, GalleryActivity.class);
            intent.setAction(GalleryActivity.ACTION_EH);
            intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, galleryInfo);
            intent.putExtra(GalleryActivity.KEY_PAGE, index);
            startActivity(intent);
            return;
        }
    }
}