List of usage examples for android.os Bundle putParcelable
public void putParcelable(@Nullable String key, @Nullable Parcelable value)
From source file:com.amaze.filemanager.fragments.Main.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); int index;/*ww w .j av a 2 s . co m*/ View vi; if (listView != null) { if (IS_LIST) { index = (mLayoutManager).findFirstVisibleItemPosition(); vi = listView.getChildAt(0); } else { index = (mLayoutManagerGrid).findFirstVisibleItemPosition(); vi = listView.getChildAt(0); } int top = (vi == null) ? 0 : vi.getTop(); outState.putInt("index", index); outState.putInt("top", top); outState.putBoolean("IS_LIST", IS_LIST); outState.putParcelableArrayList("list", LIST_ELEMENTS); outState.putString("CURRENT_PATH", CURRENT_PATH); outState.putBoolean("selection", selection); outState.putInt("openMode", openMode); outState.putInt("folder_count", folder_count); outState.putInt("file_count", file_count); if (selection) { outState.putIntegerArrayList("position", adapter.getCheckedItemPositions()); } outState.putBoolean("results", results); outState.putParcelable("adapter", adapter); if (openMode == 1) { outState.putString("SmbPath", smbPath); } } }
From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java
@Override protected void onSaveInstanceState(Bundle state) { super.onSaveInstanceState(state); state.putString(Constants.REPLY_TARGET_NAME_KEY, mReplyTargetName); state.putString(Constants.REPORT_TARGET_NAME_KEY, mReportTargetName); state.putString(Constants.EDIT_TARGET_BODY_KEY, mEditTargetBody); state.putString(Constants.DELETE_TARGET_KIND_KEY, mDeleteTargetKind); state.putString(Constants.SUBREDDIT_KEY, mSubreddit); state.putString(Constants.THREAD_ID_KEY, mThreadId); state.putString(Constants.THREAD_TITLE_KEY, mThreadTitle); state.putParcelable(Constants.VOTE_TARGET_THING_INFO_KEY, mVoteTargetThing); }
From source file:cn.edu.zafu.corepage.base.BaseActivity.java
/** * ??//from www. j a va 2s . c o m * * @param outState Bundle */ @Override protected void onSaveInstanceState(Bundle outState) { Field[] fields = this.getClass().getDeclaredFields(); Field.setAccessible(fields, true); Annotation[] ans; for (Field f : fields) { ans = f.getDeclaredAnnotations(); for (Annotation an : ans) { if (an instanceof SaveWithActivity) { try { Object o = f.get(this); if (o == null) { continue; } String fieldName = f.getName(); if (o instanceof Integer) { outState.putInt(fieldName, f.getInt(this)); } else if (o instanceof String) { outState.putString(fieldName, (String) f.get(this)); } else if (o instanceof Long) { outState.putLong(fieldName, f.getLong(this)); } else if (o instanceof Short) { outState.putShort(fieldName, f.getShort(this)); } else if (o instanceof Boolean) { outState.putBoolean(fieldName, f.getBoolean(this)); } else if (o instanceof Byte) { outState.putByte(fieldName, f.getByte(this)); } else if (o instanceof Character) { outState.putChar(fieldName, f.getChar(this)); } else if (o instanceof CharSequence) { outState.putCharSequence(fieldName, (CharSequence) f.get(this)); } else if (o instanceof Float) { outState.putFloat(fieldName, f.getFloat(this)); } else if (o instanceof Double) { outState.putDouble(fieldName, f.getDouble(this)); } else if (o instanceof String[]) { outState.putStringArray(fieldName, (String[]) f.get(this)); } else if (o instanceof Parcelable) { outState.putParcelable(fieldName, (Parcelable) f.get(this)); } else if (o instanceof Serializable) { outState.putSerializable(fieldName, (Serializable) f.get(this)); } else if (o instanceof Bundle) { outState.putBundle(fieldName, (Bundle) f.get(this)); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } super.onSaveInstanceState(outState); }
From source file:com.owncloud.android.authentication.AuthenticatorActivity.java
/** * Saves relevant state before {@link #onPause()} * /* w ww .j av a 2 s .c o m*/ * Do NOT save {@link #mNewCapturedUriFromOAuth2Redirection}; it keeps a * temporal flag, intended to defer the processing of the redirection caught * in {@link #onNewIntent(Intent)} until {@link #onResume()} * * See {@link #loadSavedInstanceState(Bundle)} */ @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // / connection state and info outState.putInt(KEY_AUTH_MESSAGE_VISIBILITY, mAuthMessage.getVisibility()); outState.putString(KEY_AUTH_MESSAGE_TEXT, mAuthMessage.getText().toString()); outState.putInt(KEY_SERVER_STATUS_TEXT, mServerStatusText); outState.putInt(KEY_SERVER_STATUS_ICON, mServerStatusIcon); outState.putBoolean(KEY_SERVER_VALID, mServerIsValid); outState.putBoolean(KEY_SERVER_CHECKED, mServerIsChecked); outState.putBoolean(KEY_SERVER_CHECK_IN_PROGRESS, (!mServerIsValid && mOcServerChkOperation != null)); outState.putBoolean(KEY_IS_SSL_CONN, mIsSslConn); outState.putBoolean(KEY_PASSWORD_VISIBLE, isPasswordVisible()); outState.putInt(KEY_AUTH_STATUS_ICON, mAuthStatusIcon); outState.putInt(KEY_AUTH_STATUS_TEXT, mAuthStatusText); // / server data if (mDiscoveredVersion != null) { outState.putString(KEY_OC_VERSION, mDiscoveredVersion.toString()); } outState.putString(KEY_HOST_URL_TEXT, mHostBaseUrl); // / account data, if updating if (mAccount != null) { outState.putParcelable(KEY_ACCOUNT, mAccount); } outState.putString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE, mAuthTokenType); // refresh button enabled outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE)); }
From source file:de.vanita5.twittnuker.util.Utils.java
public static void openStatus(final Activity activity, final ParcelableStatus status) { if (activity == null || status == null) return;/*from w w w . ja va2s .com*/ final long account_id = status.account_id, status_id = status.id; final Bundle extras = new Bundle(); extras.putParcelable(EXTRA_STATUS, status); final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_TWITTNUKER); builder.authority(AUTHORITY_STATUS); builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id)); builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(status_id)); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.setExtrasClassLoader(activity.getClassLoader()); intent.putExtras(extras); SwipebackActivityUtils.startSwipebackActivity(activity, intent); }
From source file:org.getlantern.firetweet.util.Utils.java
public static void openUserListDetails(final Activity activity, final ParcelableUserList userList) { if (activity == null || userList == null) return;/*from w ww .j a v a2s . c o m*/ final long accountId = userList.account_id, userId = userList.user_id; final long listId = userList.id; final Bundle extras = new Bundle(); extras.putParcelable(EXTRA_USER_LIST, userList); final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_FIRETWEET); builder.authority(AUTHORITY_USER_LIST); builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(accountId)); builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(userId)); builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(listId)); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.setExtrasClassLoader(activity.getClassLoader()); intent.putExtras(extras); activity.startActivity(intent); }
From source file:org.getlantern.firetweet.util.Utils.java
public static void openStatus(final Context context, final ParcelableStatus status, Bundle activityOptions) { if (context == null || status == null) return;/*from w w w.j av a 2s . co m*/ final long account_id = status.account_id, status_id = status.id; final Bundle extras = new Bundle(); extras.putParcelable(EXTRA_STATUS, status); final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_FIRETWEET); builder.authority(AUTHORITY_STATUS); builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id)); builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(status_id)); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.setExtrasClassLoader(context.getClassLoader()); intent.putExtras(extras); if (context instanceof Activity) { ActivityCompat.startActivity((Activity) context, intent, activityOptions); } else { context.startActivity(intent); } }
From source file:org.getlantern.firetweet.util.Utils.java
public static void openUserProfile(final Context context, final ParcelableUser user, final Bundle activityOptions) { if (context == null || user == null) return;//from ww w. java2s . c om final Bundle extras = new Bundle(); extras.putParcelable(EXTRA_USER, user); final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_FIRETWEET); builder.authority(AUTHORITY_USER); builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(user.account_id)); if (user.id > 0) { builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(user.id)); } if (user.screen_name != null) { builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, user.screen_name); } final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.setExtrasClassLoader(context.getClassLoader()); intent.putExtras(extras); if (context instanceof Activity) { ActivityCompat.startActivity((Activity) context, intent, activityOptions); } else { context.startActivity(intent); } }
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 w w w . j a v a2 s. com 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.android.leanlauncher.LauncherTransitionable.java
@Override protected void onSaveInstanceState(Bundle outState) { outState.putInt(RUNTIME_STATE, mState.ordinal()); if (mPendingAddInfo.container != ItemInfo.NO_ID && mWaitingForResult) { outState.putLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, mPendingAddInfo.container); outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_X, mPendingAddInfo.cellX); outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_Y, mPendingAddInfo.cellY); outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_X, mPendingAddInfo.spanX); outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y, mPendingAddInfo.spanY); outState.putParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO, mPendingAddWidgetInfo); outState.putInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID, mPendingAddWidgetId); }/* w ww.ja v a 2 s . com*/ // Save the current AppsCustomize tab if (mAppsCustomizeTabHost != null) { AppsCustomizePagedView.ContentType type = mAppsCustomizeContent.getContentType(); String currentTabTag = mAppsCustomizeTabHost.getTabTagForContentType(type); if (currentTabTag != null) { outState.putString("apps_customize_currentTab", currentTabTag); } int currentIndex = mAppsCustomizeContent.getSaveInstanceStateIndex(); outState.putInt("apps_customize_currentIndex", currentIndex); } outState.putSerializable(RUNTIME_STATE_VIEW_IDS, mItemIdToViewId); super.onSaveInstanceState(outState); }