android.os.Parcelable Java Examples
The following examples show how to use
android.os.Parcelable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomColorDialogPreferenceX.java From PhoneProfilesPlus with Apache License 2.0 | 6 votes |
@Override protected void onRestoreInstanceState(Parcelable state) { if (!state.getClass().equals(SavedState.class)) { // Didn't save state for us in onSaveInstanceState super.onRestoreInstanceState(state); int value = this.value; if (fragment != null) fragment.chromaColorView.setCurrentColor(value); setSummaryCCDP(value); return; } // restore instance state CustomColorDialogPreferenceX.SavedState myState = (CustomColorDialogPreferenceX.SavedState)state; super.onRestoreInstanceState(myState.getSuperState()); value = myState.value; defaultValue = myState.defaultValue; if (fragment != null) fragment.chromaColorView.setCurrentColor(value); setSummaryCCDP(value); }
Example #2
Source File: ReadBottomStatusBar.java From HaoReader with GNU General Public License v3.0 | 6 votes |
@Override protected void onRestoreInstanceState(Parcelable state) { Bundle bundle = (Bundle) state; showTimeBattery = bundle.getBoolean("showTimeBattery"); batteryLevel = bundle.getInt("batteryLevel", batteryLevel); durChapterName = bundle.getString("durChapterName"); durPage = bundle.getInt("durPage"); pageSize = bundle.getInt("pageSize"); durChapter = bundle.getInt("durChapter"); chapterSize = bundle.getInt("chapterSize"); super.onRestoreInstanceState(bundle.getParcelable("super_data")); updateTime(); setShowTimeBattery(showTimeBattery); updatePageIndex(durChapterName, durPage, pageSize); updateChapterIndex(durChapter, chapterSize); }
Example #3
Source File: NumberProgressBar.java From AppUpdate with Apache License 2.0 | 6 votes |
@Override protected Parcelable onSaveInstanceState() { final Bundle bundle = new Bundle(); bundle.putParcelable(INSTANCE_STATE, super.onSaveInstanceState()); bundle.putInt(INSTANCE_TEXT_COLOR, getTextColor()); bundle.putFloat(INSTANCE_TEXT_SIZE, getProgressTextSize()); bundle.putFloat(INSTANCE_REACHED_BAR_HEIGHT, getReachedBarHeight()); bundle.putFloat(INSTANCE_UNREACHED_BAR_HEIGHT, getUnreachedBarHeight()); bundle.putInt(INSTANCE_REACHED_BAR_COLOR, getReachedBarColor()); bundle.putInt(INSTANCE_UNREACHED_BAR_COLOR, getUnreachedBarColor()); bundle.putInt(INSTANCE_MAX, getMax()); bundle.putInt(INSTANCE_PROGRESS, getProgress()); bundle.putString(INSTANCE_SUFFIX, getSuffix()); bundle.putString(INSTANCE_PREFIX, getPrefix()); bundle.putBoolean(INSTANCE_TEXT_VISIBILITY, getProgressTextVisibility()); return bundle; }
Example #4
Source File: ViewUtils.java From VideoMeeting with Apache License 2.0 | 6 votes |
/** * 创建快捷方式 * * @param cxt * Context * @param icon * 快捷方式图标 * @param title * 快捷方式标题 * @param cls * 要启动的Activity类 */ public static void createDeskShortCut(Context cxt, int icon, String title, Class<?> cls) { // 创建快捷方式的Intent Intent shortcutIntent = new Intent( "com.android.launcher.action.INSTALL_SHORTCUT"); // 不允许重复创建 shortcutIntent.putExtra("duplicate", false); // 需要现实的名称 shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title); // 快捷图片 Parcelable ico = Intent.ShortcutIconResource.fromContext( cxt.getApplicationContext(), icon); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, ico); Intent intent = new Intent(cxt, cls); // 下面两个属性是为了当应用程序卸载时桌面上的快捷方式会删除 intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); // 点击快捷图片,运行的程序主入口 shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); // 发送广播。OK cxt.sendBroadcast(shortcutIntent); }
Example #5
Source File: MenuBuilder.java From android-apps with MIT License | 6 votes |
private void dispatchSaveInstanceState(Bundle outState) { if (mPresenters.isEmpty()) return; SparseArray<Parcelable> presenterStates = new SparseArray<Parcelable>(); for (WeakReference<MenuPresenter> ref : mPresenters) { final MenuPresenter presenter = ref.get(); if (presenter == null) { mPresenters.remove(ref); } else { final int id = presenter.getId(); if (id > 0) { final Parcelable state = presenter.onSaveInstanceState(); if (state != null) { presenterStates.put(id, state); } } } } outState.putSparseParcelableArray(PRESENTER_KEY, presenterStates); }
Example #6
Source File: FormulaResult.java From microMathematics with GNU General Public License v3.0 | 6 votes |
/** * Parcelable interface: procedure reads the formula state */ @Override public void onRestoreInstanceState(Parcelable state) { if (state == null) { return; } if (state instanceof Bundle) { Bundle bundle = (Bundle) state; properties.assign((ResultProperties) bundle.getParcelable(STATE_RESULT_PROPERTIES)); super.onRestoreInstanceState(bundle); updateResultView(false); } }
Example #7
Source File: GifTextView.java From sketch with Apache License 2.0 | 6 votes |
@Override public void onRestoreInstanceState(Parcelable state) { if (!(state instanceof GifViewSavedState)) { super.onRestoreInstanceState(state); return; } GifViewSavedState ss = (GifViewSavedState) state; super.onRestoreInstanceState(ss.getSuperState()); Drawable[] compoundDrawables = getCompoundDrawables(); ss.restoreState(compoundDrawables[0], 0); ss.restoreState(compoundDrawables[1], 1); ss.restoreState(compoundDrawables[2], 2); ss.restoreState(compoundDrawables[3], 3); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { Drawable[] compoundDrawablesRelative = getCompoundDrawablesRelative(); ss.restoreState(compoundDrawablesRelative[0], 4); ss.restoreState(compoundDrawablesRelative[2], 5); } ss.restoreState(getBackground(), 6); }
Example #8
Source File: WatchingView.java From cathode with Apache License 2.0 | 6 votes |
@Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState state = new SavedState(superState); state.type = type; state.showId = showId; state.showTitle = showTitle; state.episodeId = episodeId; state.episodeTitle = episodeTitle; state.movieId = movieId; state.movieTitle = movieTitle; state.movieOverview = movieOverview; state.poster = poster; state.startTime = startTime; state.endTime = endTime; state.startTime = startTime; state.endTime = endTime; state.isExpanded = isExpanded(); return state; }
Example #9
Source File: NumberProgressBar.java From FireFiles with Apache License 2.0 | 6 votes |
@Override protected void onRestoreInstanceState(Parcelable state) { if(state instanceof Bundle){ final Bundle bundle = (Bundle)state; mTextColor = bundle.getInt(INSTANCE_TEXT_COLOR); mTextSize = bundle.getFloat(INSTANCE_TEXT_SIZE); mReachedBarHeight = bundle.getFloat(INSTANCE_REACHED_BAR_HEIGHT); mUnreachedBarHeight = bundle.getFloat(INSTANCE_UNREACHED_BAR_HEIGHT); mReachedBarColor = bundle.getInt(INSTANCE_REACHED_BAR_COLOR); mUnreachedBarColor = bundle.getInt(INSTANCE_UNREACHED_BAR_COLOR); initializePainters(); setMax(bundle.getInt(INSTANCE_MAX)); setProgress(bundle.getInt(INSTANCE_PROGRESS)); setPrefix(bundle.getString(INSTANCE_PREFIX)); setSuffix(bundle.getString(INSTANCE_SUFFIX)); setProgressTextVisibility(bundle.getBoolean(INSTANCE_TEXT_VISBILITY) ? ProgressTextVisibility.Visible : ProgressTextVisibility.Invisible); super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE)); return; } super.onRestoreInstanceState(state); }
Example #10
Source File: AppBarLayout.java From material-components-android with Apache License 2.0 | 6 votes |
@Override public Parcelable onSaveInstanceState(@NonNull CoordinatorLayout parent, @NonNull T abl) { final Parcelable superState = super.onSaveInstanceState(parent, abl); final int offset = getTopAndBottomOffset(); // Try and find the first visible child... for (int i = 0, count = abl.getChildCount(); i < count; i++) { View child = abl.getChildAt(i); final int visBottom = child.getBottom() + offset; if (child.getTop() + offset <= 0 && visBottom >= 0) { final SavedState ss = new SavedState(superState); ss.firstVisibleChildIndex = i; ss.firstVisibleChildAtMinimumHeight = visBottom == (ViewCompat.getMinimumHeight(child) + abl.getTopInset()); ss.firstVisibleChildPercentageShown = visBottom / (float) child.getHeight(); return ss; } } // Else we'll just return the super state return superState; }
Example #11
Source File: MainActivity.java From arcgis-runtime-demos-android with Apache License 2.0 | 6 votes |
@Override public boolean dispatchTouchEvent(@NonNull MotionEvent event) { boolean wasLongPress = mGestureDetector.onTouchEvent(event); if(!wasLongPress) { Log.i("test", "not a long press"); if(!mDismissOverlayView.isShown()) { Parcel p = Parcel.obtain(); event.writeToParcel(p, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); sendEvent(p.marshall()); } else { return super.dispatchTouchEvent(event); } } else { Log.i("test", "long press"); } return true; }
Example #12
Source File: ParcelableModelsTest.java From spotify-web-api-android with MIT License | 6 votes |
@Test public void allParcelables() throws IllegalAccessException, InstantiationException, NoSuchFieldException { ModelPopulator populator = new ModelPopulator("CREATOR", "$jacocoData"); for (Class<? extends Parcelable> modelClass : getModelClasses()) { Parcelable instance = populator.populateWithRandomValues(modelClass); testSingleParcelable(instance); testParcelableArray(instance); /* Trick to increase code coverage */ instance.describeContents(); ((Parcelable.Creator<?>) modelClass.getField("CREATOR").get(null)).newArray(13); } }
Example #13
Source File: SwipeRevealLayout.java From SwipeRevealLayoutExample with MIT License | 5 votes |
@Nullable @Override protected Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); bundle.putParcelable(SUPER_INSTANCE_STATE, super.onSaveInstanceState()); return super.onSaveInstanceState(); }
Example #14
Source File: IcsProgressBar.java From Libraries-for-Android-Developers with MIT License | 5 votes |
@Override public Parcelable onSaveInstanceState() { // Force our ancestor class to save its state Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); ss.progress = mProgress; ss.secondaryProgress = mSecondaryProgress; return ss; }
Example #15
Source File: RefreshLayout.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
@Override protected void onRestoreInstanceState(Parcelable state) { SavedState savedState = (SavedState) state; super.onRestoreInstanceState(savedState.getSuperState()); //刷新状态 toggleStatus(savedState.status); }
Example #16
Source File: ReplaceState.java From microMathematics with GNU General Public License v3.0 | 5 votes |
public EntryState(int formulaId, FormulaBase.BaseType type, Parcelable data) { super(); this.formulaId = formulaId; this.type = type; this.data = data; }
Example #17
Source File: StateUtils.java From persistentsearchview with Apache License 2.0 | 5 votes |
public static Parcelable fetchParentState(Parcelable state) { if(state == null) { return null; } if(Utils.IS_AT_LEAST_MARSHMALLOW) { return state; } else { return View.BaseSavedState.EMPTY_STATE; } }
Example #18
Source File: ParcelableTester.java From mv2m with Apache License 2.0 | 5 votes |
private static void writeList(LinkedList<Object> parcelData, InvocationOnMock invocation, List<Parcelable> list) { if (list == null) { parcelData.add(-1); } else { parcelData.add(list.size()); for (Parcelable item : list) { writeParcelable(parcelData, item, (Parcel) invocation.getMock()); } } }
Example #19
Source File: LinePageIndicator.java From InfiniteViewPager with MIT License | 5 votes |
@Override public void onRestoreInstanceState(Parcelable state) { SavedState savedState = (SavedState)state; super.onRestoreInstanceState(savedState.getSuperState()); mCurrentPage = savedState.currentPage; requestLayout(); }
Example #20
Source File: UnderlinePageIndicator.java From monolog-android with MIT License | 5 votes |
@Override public Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState savedState = new SavedState(superState); savedState.currentPage = mCurrentPage; return savedState; }
Example #21
Source File: UnderlinePageIndicator.java From Klyph with MIT License | 5 votes |
@Override public void onRestoreInstanceState(Parcelable state) { SavedState savedState = (SavedState)state; super.onRestoreInstanceState(savedState.getSuperState()); mCurrentPage = savedState.currentPage; requestLayout(); }
Example #22
Source File: CheckTextView.java From EhViewer with Apache License 2.0 | 5 votes |
@Override public void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { final Bundle savedState = (Bundle) state; super.onRestoreInstanceState(savedState.getParcelable(STATE_KEY_SUPER)); setChecked(savedState.getBoolean(STATE_KEY_CHECKED), false); } }
Example #23
Source File: ColorPickerView.java From ColorPicker with Apache License 2.0 | 5 votes |
@Override protected Parcelable onSaveInstanceState() { Parcelable parcelable = super.onSaveInstanceState(); SavedState ss = new SavedState(parcelable); ss.selX = curX; ss.selY = curY; ss.color = bitmapForColor; if (mIndicatorEnable) { ss.indicator = bitmapForIndicator; } return ss; }
Example #24
Source File: FabSpeedDial.java From fab-speed-dial with Apache License 2.0 | 5 votes |
@Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); ss.isShowingMenu = isMenuOpen(); return ss; }
Example #25
Source File: FolderChooser.java From screenrecorder with GNU Affero General Public License v3.0 | 5 votes |
@Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); if (currentDir == null) return superState; Bundle dialogState = dialog == null ? null : dialog.onSaveInstanceState(); return new SavedStateHandler(superState, currentDir.getPath(), dialogState); }
Example #26
Source File: ScaleLayout.java From ScaleLayout with Apache License 2.0 | 5 votes |
/** * 存储当前状态 * @return */ @Override public Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); bundle.putParcelable("superState", super.onSaveInstanceState()); bundle.putSerializable(TAG, mState); return bundle; }
Example #27
Source File: BannerLayoutManager.java From RecyclerBanner with Apache License 2.0 | 5 votes |
@Override public Parcelable onSaveInstanceState() { if (mPendingSavedState != null) { return new SavedState(mPendingSavedState); } SavedState savedState = new SavedState(); savedState.position = mPendingScrollPosition; savedState.offset = mOffset; savedState.isReverseLayout = mShouldReverseLayout; return savedState; }
Example #28
Source File: SVBar.java From PhotoEdit with Apache License 2.0 | 5 votes |
@Override protected void onRestoreInstanceState(Parcelable state) { Bundle savedState = (Bundle) state; Parcelable superState = savedState.getParcelable(STATE_PARENT); super.onRestoreInstanceState(superState); setColor(Color.HSVToColor(savedState.getFloatArray(STATE_COLOR))); if (savedState.containsKey(STATE_SATURATION)) { setSaturation(savedState.getFloat(STATE_SATURATION)); } else { setValue(savedState.getFloat(STATE_VALUE)); } }
Example #29
Source File: EntityDetailFragment.java From commcare-android with Apache License 2.0 | 5 votes |
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (modifier instanceof Parcelable) { outState.putParcelable(MODIFIER_KEY, (Parcelable)modifier); } else { throw new IllegalArgumentException(modifier + " must implement Parcelable!"); } }
Example #30
Source File: ObservableGridView.java From moviedb-android with Apache License 2.0 | 5 votes |
@Override public Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); ss.prevFirstVisiblePosition = mPrevFirstVisiblePosition; ss.prevFirstVisibleChildHeight = mPrevFirstVisibleChildHeight; ss.prevScrolledChildrenHeight = mPrevScrolledChildrenHeight; ss.prevScrollY = mPrevScrollY; ss.scrollY = mScrollY; ss.childrenHeights = mChildrenHeights; return ss; }