@Override public void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; normalizedScale = bundle.getFloat("saveScale"); m = bundle.getFloatArray("matrix"); prevMatrix.setValues(m); prevMatchViewHeight = bundle.getFloat("matchViewHeight"); prevMatchViewWidth = bundle.getFloat("matchViewWidth"); prevViewHeight = bundle.getInt("viewHeight"); prevViewWidth = bundle.getInt("viewWidth"); imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered"); super.onRestoreInstanceState(bundle.getParcelable("instanceState")); return; } super.onRestoreInstanceState(state); }
public static <ScreenT extends Screen> Function<DialogFragment, ScreenT> getDefaultScreenGettingFunction(final Class<ScreenT> screenClass) { return new Function<DialogFragment, ScreenT>() { @Override @SuppressWarnings("unchecked") public ScreenT call(DialogFragment dialogFragment) { if (dialogFragment.getArguments() == null) { throw new IllegalArgumentException("Dialog dialogFragment has no arguments."); } else if (Serializable.class.isAssignableFrom(screenClass)) { return (ScreenT) dialogFragment.getArguments().getSerializable(KEY_SCREEN); } else if (Parcelable.class.isAssignableFrom(screenClass)) { return (ScreenT) dialogFragment.getArguments().getParcelable(KEY_SCREEN); } else { throw new IllegalArgumentException("Screen " + screenClass.getSimpleName() + " should be Serializable or Parcelable."); } } }; }
@Override public void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; alpha = bundle.getInt("alpha"); hue = bundle.getFloat("hue"); sat = bundle.getFloat("sat"); val = bundle.getFloat("val"); showAlphaPanel = bundle.getBoolean("show_alpha"); alphaSliderText = bundle.getString("alpha_text"); state = bundle.getParcelable("instanceState"); } super.onRestoreInstanceState(state); }
public Builder addArg(String key, Object value) { if (value != null) { if (value instanceof Boolean) { bundle.putBoolean(key, (Boolean) value); } else if (value instanceof Integer) { bundle.putInt(key, (Integer) value); } else if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof Serializable) { bundle.putSerializable(key, (Serializable) value); } else if (value instanceof Bundle) { bundle.putBundle(key, (Bundle) value); } else if (value instanceof Parcelable) { bundle.putParcelable(key, (Parcelable) value); } else { throw new IllegalArgumentException("Unknown type " + value.getClass() + " in Bundle."); } } return this; }
/** * If the passed in state is a Bundle, an attempt is made to restore from it. * @param state a Parcelable containing the current state */ @Override protected void onRestoreInstanceState(Parcelable state) { if (state.getClass() != Bundle.class) { super.onRestoreInstanceState(state); } else { Bundle instanceState = (Bundle)state; super.onRestoreInstanceState(instanceState.getParcelable(SUPER_STATE_KEY)); profileId = instanceState.getString(PROFILE_ID_KEY); presetSizeType = instanceState.getInt(PRESET_SIZE_KEY); isCropped = instanceState.getBoolean(IS_CROPPED_KEY); queryWidth = instanceState.getInt(BITMAP_WIDTH_KEY); queryHeight = instanceState.getInt(BITMAP_HEIGHT_KEY); setImageBitmap((Bitmap)instanceState.getParcelable(BITMAP_KEY)); if (instanceState.getBoolean(PENDING_REFRESH_KEY)) { refreshImage(true); } } }
/** * {@inheritDoc} */ @Override public void onRestoreInstanceState(Parcelable state) { container = (ParcelableContainer) state; anchorView = container.getAnchorViewState(); if (orientation != container.getOrientation()) { //orientation have been changed, clear anchor rect int anchorPos = anchorView.getPosition(); anchorView = anchorFactory.createNotFound(); anchorView.setPosition(anchorPos); } viewPositionsStorage.onRestoreInstanceState(container.getPositionsCache(orientation)); cacheNormalizationPosition = container.getNormalizationPosition(orientation); Log.d(TAG, "RESTORE. last cache position before cleanup = " + viewPositionsStorage.getLastCachePosition()); if (cacheNormalizationPosition != null) { viewPositionsStorage.purgeCacheFromPosition(cacheNormalizationPosition); } viewPositionsStorage.purgeCacheFromPosition(anchorView.getPosition()); Log.d(TAG, "RESTORE. anchor position =" + anchorView.getPosition()); Log.d(TAG, "RESTORE. layoutOrientation = " + orientation + " normalizationPos = " + cacheNormalizationPosition); Log.d(TAG, "RESTORE. last cache position = " + viewPositionsStorage.getLastCachePosition()); }
@Override public void onRestoreInstanceState(Parcelable state) { if (!(state instanceof ProgressSavedState)) { super.onRestoreInstanceState(state); return; } ProgressSavedState ss = (ProgressSavedState) state; super.onRestoreInstanceState(ss.getSuperState()); this.mCurrentProgress = ss.mCurrentProgress; this.mTargetProgress = ss.mTargetProgress; this.mSpinSpeed = ss.mSpinSpeed; this.mProgressWidth = ss.mProgressWidth; this.mProgressColor = ss.mProgressColor; this.mProgressBackgroundColor = ss.mProgressBackgroundColor; this.mShouldProgressIndeterminate = ss.mShouldProgressIndeterminate; this.mShouldSetProgress = ss.mShouldSetProgress; this.mProgress = ss.mProgress; this.mAnimateProgress = ss.mAnimateProgress; this.mShowProgressBackground = ss.mShowProgressBackground; this.mLastTimeAnimated = SystemClock.uptimeMillis(); }
@Override public void onRestoreInstanceState(Parcelable state) { if (!(state instanceof SavedState)) { super.onRestoreInstanceState(state); return; } SavedState ss = (SavedState)state; super.onRestoreInstanceState(ss.getSuperState()); if (mAdapter != null) { mAdapter.restoreState(ss.adapterState, ss.loader); setCurrentItemInternal(ss.position, false, true); } else { mRestoredCurItem = ss.position; mRestoredAdapterState = ss.adapterState; mRestoredClassLoader = ss.loader; } }
@Override protected void onRestoreInstanceState(Parcelable state) { Bundle savedState = (Bundle) state; Parcelable superState = savedState.getParcelable("PARENT"); super.onRestoreInstanceState(superState); mMax = savedState.getInt("MAX"); mProgress = savedState.getInt("PROGRESS"); mCircleColor = savedState.getInt("mCircleColor"); mCircleProgressColor = savedState.getInt("mCircleProgressColor"); mPointerColor = savedState.getInt("mPointerColor"); mPointerHaloColor = savedState.getInt("mPointerHaloColor"); mPointerHaloColorOnTouch = savedState.getInt("mPointerHaloColorOnTouch"); mPointerAlpha = savedState.getInt("mPointerAlpha"); mPointerAlphaOnTouch = savedState.getInt("mPointerAlphaOnTouch"); lockEnabled = savedState.getBoolean("lockEnabled"); initPaints(); recalculateAll(); }
public void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; this.normalizedScale = bundle.getFloat("saveScale"); this.f3m = bundle.getFloatArray("matrix"); this.prevMatrix.setValues(this.f3m); this.prevMatchViewHeight = bundle.getFloat("matchViewHeight"); this.prevMatchViewWidth = bundle.getFloat("matchViewWidth"); this.prevViewHeight = bundle.getInt("viewHeight"); this.prevViewWidth = bundle.getInt("viewWidth"); this.imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered"); super.onRestoreInstanceState(bundle.getParcelable("instanceState")); return; } super.onRestoreInstanceState(state); }
@Override public Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); ss.mViewState = ViewState.ShowingRevealedLayout; ss.mAnimDuration = mAnimDuration; ss.mBordersSize = mBordersSize; ss.mExpandSize = mExpandSize; ss.mBoarderColor = mBoarderColor; ss.mRevealViewBackgroundColor = mRevealViewBackgroundColor; ss.mStartEditTintColor = mStartEditTintColor; ss.mEditViewBackgroundColor = mEditViewBackgroundColor; ss.mEditViewTextColor = mEditViewTextColor; ss.mDoneEditTintColor = mDoneEditTintColor; ss.mShowBorders = mShowBorders; ss.mKeepLastSearch = mKeepLastSearch; ss.mRevealEmptyText = mRevealEmptyText; ss.mSearchHintText = mSearchHintText; ss.mNoItemsFoundText = mNoItemsFoundText; ss.mSelectedViewPosition = mCurrSelectedView != null ? mCurrSelectedView.getPosition() : -1; return ss; }
@Override protected void onRestoreInstanceState(Parcelable state) { if (!(state instanceof SavedState)) { super.onRestoreInstanceState(state); return; } SavedState ss = (SavedState) state; super.onRestoreInstanceState(ss.getSuperState()); if (ss.isOpen) { openPane(); } else { closePane(); } mPreservedOpenState = ss.isOpen; }
@TargetApi(19) List<Uri> getUriArrayFromNotificationParcelableArray(android.app.Notification n, String extra) { Parcelable[] pa = n.extras.getParcelableArray(extra); if (pa == null) { try { return new ArrayList(); } catch (Exception e) { return new ArrayList(); } } List<Uri> uris = new ArrayList(pa.length); for (Parcelable p : pa) { uris.add((Uri) p); } return uris; }
@Override protected void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; mCurrentTab = bundle.getInt("mCurrentTab"); state = bundle.getParcelable("instanceState"); if (mCurrentTab != 0 && mTabsContainer.getChildCount() > 0) { updateTabSelection(mCurrentTab); scrollToCurrentTab(); } } super.onRestoreInstanceState(state); }
@Override protected Parcelable onSaveInstanceState() { Parcelable parentState = super.onSaveInstanceState(); SavedState savedState = new SavedState(parentState); savedState.currentState = currentState; savedState.previousState = previousState; return savedState; }
private void toMediaEdit (JournalEntry model, String key) { Intent toEdit = new Intent(this, JournalEditActivity.class); Parcelable parcel = Parcels.wrap(model); toEdit.putExtra ("JRNL_ENTRY", parcel); toEdit.putExtra ("JRNL_KEY", key); toEdit.putExtra ("DB_REF", entriesRef.getRef().getParent() .toString()); startActivity (toEdit); }
@Override public Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState savedState = new SavedState(superState); savedState.currentPage = mCurrentPage; return savedState; }
@Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); return new SavedState(superState, LockPatternUtils.patternToString(mPattern), mPatternDisplayMode.ordinal(), mInputEnabled, mInStealthMode, mEnableHapticFeedback); }
@Override public void onRestoreInstanceState(Parcelable state) { if (state instanceof SavedState) { SavedState savedState = (SavedState) state; expanded = savedState.expanded; touchDelegateGroup.setEnabled(expanded); if (rotatingDrawable != null) { rotatingDrawable.setRotation(expanded ? EXPANDED_PLUS_ROTATION : COLLAPSED_PLUS_ROTATION); } super.onRestoreInstanceState(savedState.getSuperState()); } else { super.onRestoreInstanceState(state); } }
@Override public Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); mSavedState = new SavedState(superState); mSavedState.query = mUserQuery != null ? mUserQuery.toString() : null; mSavedState.isSearchOpen = this.mIsSearchOpen; return mSavedState; }
@Override public Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); ss.position = mCurItem; if (mAdapter != null) { ss.adapterState = mAdapter.saveState(); } return ss; }
@Override public void onSaveInstanceState(Bundle outState) { outState.putParcelable(STATE_USER, user); if (firstPageFollowers.size() > 0) { outState.putParcelableArrayList(STATE_FIRST_PAGE_DATA, (ArrayList<? extends Parcelable>) firstPageFollowers); } outState.putString(STATE_NEXT_PAGE_URL, getNextPageUrl()); }
/** * Open a camera device and start showing camera preview. This is typically called from * {@link Activity#onResume()}. */ public void start() { if (!mImpl.start()) { //store the state ,and restore this state after fall back o Camera1 Parcelable state=onSaveInstanceState(); // Camera2 uses legacy hardware layer; fall back to Camera1 mImpl = new Camera1(mCallbacks, createPreviewImpl(getContext())); onRestoreInstanceState(state); mImpl.start(); } }
@Override public Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); ss.mSavedSlideState = mSlideState; return ss; }
@Override protected void onRestoreInstanceState(Parcelable state) { if (!(state instanceof SavedState)) { super.onRestoreInstanceState(state); return; } SavedState ss = (SavedState) state; super.onRestoreInstanceState(ss.getSuperState()); mIsBrightnessGradient = ss.isBrightnessGradient; setColor(ss.color, true); }
@Test public void onCreateChoosesInitialKeysIfRestoredHistoryIsEmpty() { BackstackDelegate backstackDelegate = new BackstackDelegate(null); TestKey testKey = new TestKey("hello"); ArrayList<Parcelable> restoredKeys = new ArrayList<>(); Mockito.when(savedInstanceState.getParcelableArrayList(backstackDelegate.getHistoryTag())).thenReturn(restoredKeys); backstackDelegate.onCreate(savedInstanceState, null, HistoryBuilder.single(testKey)); assertThat(backstackDelegate.getBackstack()).isNotNull(); backstackDelegate.setStateChanger(stateChanger); assertThat(backstackDelegate.getBackstack().getHistory()).containsExactly(testKey); }
public void restoreInstanceState(SparseArray<Parcelable> states) { try { dispatchRestoreInstanceState(states); } catch (IllegalArgumentException ex) { if (ProviderConfig.IS_DOGFOOD_BUILD) { throw ex; } // Mismatched viewId / viewType preventing restore. Skip restore on production builds. Log.e(TAG, "Ignoring an error while restoring a view instance state", ex); } }
@Override protected void onRestoreInstanceState(Parcelable state) { if (state == null || !state.getClass().equals(SavedState.class)) { // Didn't save state for us in onSaveInstanceState super.onRestoreInstanceState(state); return; } SavedState myState = (SavedState) state; super.onRestoreInstanceState(myState.getSuperState()); setValue(myState.value); }
@Override protected Parcelable onSaveInstanceState() { SavedState state = new SavedState(super.onSaveInstanceState()); state.facing = getFacing(); state.ratio = getAspectRatio(); state.autoFocus = getAutoFocus(); state.flash = getFlash(); return state; }
@Override protected Parcelable onSaveInstanceState() { final Parcelable superState = super.onSaveInstanceState(); if (mDialog == null || !mDialog.isShowing()) { return superState; } final SavedState myState = new SavedState(superState); myState.dialogBundle = mDialog.onSaveInstanceState(); return myState; }
@Override public void onRestoreInstanceState(Parcelable state) { if (state instanceof SavedState) { mPendingSavedState = (SavedState) state; requestLayout(); if (DEBUG) { Log.d(TAG, "loaded saved state"); } } else if (DEBUG) { Log.d(TAG, "invalid saved state class"); } }
protected void onRestoreInstanceState(Parcelable state) { SavedState ss = (SavedState) state; super.onRestoreInstanceState(ss.getSuperState()); Menu menu = this.mMenuView != null ? this.mMenuView.peekMenu() : null; if (!(ss.expandedMenuItemId == 0 || this.mExpandedMenuPresenter == null || menu == null)) { MenuItem item = menu.findItem(ss.expandedMenuItemId); if (item != null) { MenuItemCompat.expandActionView(item); } } if (ss.isOverflowOpen) { postShowOverflowMenu(); } }
public void onReceive(Context context, Intent intent) { Parcelable connectionResult = intent.getParcelableExtra(Constants.GOOGLE_API_CONNECTION_RESULT); Parcelable status = intent.getParcelableExtra(Constants.GOOGLE_API_LOCATION_RESULT); if (status != null) { handleLocationStatusResult((Status) status); } else if (connectionResult != null) { handleConnectionResult((ConnectionResult) connectionResult); } }
@Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); Bundle state = new Bundle(); state.putParcelable(STATE_KEY_SUPER, superState); state.putInt(STATE_KEY_SEEK_BAR_VALUE, mSeekBarValue); return state; }
protected Parcelable onSaveInstanceState() { SavedState ss = new SavedState(super.onSaveInstanceState()); int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { boolean isOpenedAndNotClosing; LayoutParams lp = (LayoutParams) getChildAt(i).getLayoutParams(); if (lp.openState == 1) { isOpenedAndNotClosing = true; } else { isOpenedAndNotClosing = false; } boolean isClosedAndOpening; if (lp.openState == 2) { isClosedAndOpening = true; } else { isClosedAndOpening = false; } if (isOpenedAndNotClosing || isClosedAndOpening) { ss.openDrawerGravity = lp.gravity; break; } } ss.lockModeLeft = this.mLockModeLeft; ss.lockModeRight = this.mLockModeRight; ss.lockModeStart = this.mLockModeStart; ss.lockModeEnd = this.mLockModeEnd; return ss; }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_main, container, false); recipeAdapter = new RecipeAdapter(getContext(), this); recipeDatabaseHelper = new RecipeDatabaseHelper(getContext()); recipeApiClient = new RecipeApiClient(); recipes = new ArrayList<>(); getIdlingResource(); mBinding.swiperefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener(){ @Override public void onRefresh() { updateRecipes(); } }); GridAutofitLayoutManager layoutManager = new GridAutofitLayoutManager(getContext(), 800); mBinding.rvRecipes.setLayoutManager(layoutManager); mBinding.rvRecipes.setAdapter(recipeAdapter); mBinding.rvRecipes.setHasFixedSize(false); if (savedInstanceState != null){ if (savedInstanceState.containsKey(SAVED_RECIPES_KEY)){ ArrayList<Parcelable> recipeParcelableArrayList = savedInstanceState.getParcelableArrayList(SAVED_RECIPES_KEY); for (Parcelable parcelable : recipeParcelableArrayList){ Recipe recipe = Parcels.unwrap(parcelable); recipes.add(recipe); recipeAdapter.addRecipe(recipe); } } if (savedInstanceState.containsKey(SCROLLBAR_POSITION_KEY)){ int position = savedInstanceState.getInt(SCROLLBAR_POSITION_KEY); mBinding.rvRecipes.getLayoutManager().scrollToPosition(position); } } else { mBinding.pbLoadingIndicator.setVisibility(View.VISIBLE); recipeDatabaseHelper.getAllRecipes(this); } return mBinding.getRoot(); }
@Override protected Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); bundle.putParcelable("instanceState", super.onSaveInstanceState()); bundle.putInt("mCurrentTab", mCurrentTab); return bundle; }
@Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); Bundle state = new Bundle(); state.putParcelable(STATE_PARENT, superState); state.putFloat(STATE_ANGLE, mAngle); state.putInt(STATE_OLD_COLOR, mCenterOldColor); state.putBoolean(STATE_SHOW_OLD_COLOR, mShowCenterOldColor); return state; }
private boolean internalDispatchEvent(Parcelable event) { List<String> t = types; if (t != null && t.contains(event.getClass().getCanonicalName())) { try { return sendEventToOtherProcess(new ParcelableEvent(event)); } catch (RemoteException e) { Log.e(e, "%s.failedToSendEventToOtherProcess", TAG); } } return false; }