Search in sources :

Example 31 with Parcelable

use of android.os.Parcelable in project cameraview by google.

the class CameraView method start.

/**
     * 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();
    }
}
Also used : Parcelable(android.os.Parcelable)

Example 32 with Parcelable

use of android.os.Parcelable in project material-components-android by material-components.

the class CoordinatorLayout method onRestoreInstanceState.

@Override
protected void onRestoreInstanceState(Parcelable state) {
    if (!(state instanceof SavedState)) {
        super.onRestoreInstanceState(state);
        return;
    }
    final SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());
    final SparseArray<Parcelable> behaviorStates = ss.behaviorStates;
    for (int i = 0, count = getChildCount(); i < count; i++) {
        final View child = getChildAt(i);
        final int childId = child.getId();
        final LayoutParams lp = getResolvedLayoutParams(child);
        final Behavior b = lp.getBehavior();
        if (childId != NO_ID && b != null) {
            Parcelable savedState = behaviorStates.get(childId);
            if (savedState != null) {
                b.onRestoreInstanceState(this, child, savedState);
            }
        }
    }
}
Also used : AbsSavedState(android.support.v4.view.AbsSavedState) Parcelable(android.os.Parcelable) View(android.view.View) Paint(android.graphics.Paint)

Example 33 with Parcelable

use of android.os.Parcelable in project material-components-android by material-components.

the class BottomNavigationView method onSaveInstanceState.

@Override
protected Parcelable onSaveInstanceState() {
    Parcelable superState = super.onSaveInstanceState();
    SavedState savedState = new SavedState(superState);
    savedState.menuPresenterState = new Bundle();
    mMenu.savePresenterStates(savedState.menuPresenterState);
    return savedState;
}
Also used : AbsSavedState(android.support.v4.view.AbsSavedState) Bundle(android.os.Bundle) Parcelable(android.os.Parcelable)

Example 34 with Parcelable

use of android.os.Parcelable in project material-components-android by material-components.

the class NavigationMenuPresenter method onRestoreInstanceState.

@Override
public void onRestoreInstanceState(final Parcelable parcelable) {
    if (parcelable instanceof Bundle) {
        Bundle state = (Bundle) parcelable;
        SparseArray<Parcelable> hierarchy = state.getSparseParcelableArray(STATE_HIERARCHY);
        if (hierarchy != null) {
            mMenuView.restoreHierarchyState(hierarchy);
        }
        Bundle adapterState = state.getBundle(STATE_ADAPTER);
        if (adapterState != null) {
            mAdapter.restoreInstanceState(adapterState);
        }
        SparseArray<Parcelable> header = state.getSparseParcelableArray(STATE_HEADER);
        if (header != null) {
            mHeaderLayout.restoreHierarchyState(header);
        }
    }
}
Also used : Bundle(android.os.Bundle) Parcelable(android.os.Parcelable)

Example 35 with Parcelable

use of android.os.Parcelable in project material-components-android by material-components.

the class NavigationMenuPresenter method onSaveInstanceState.

@Override
public Parcelable onSaveInstanceState() {
    if (Build.VERSION.SDK_INT >= 11) {
        // API 9-10 does not support ClassLoaderCreator, therefore things can crash if they're
        // loaded via different loaders. Rather than crash we just won't save state on those
        // platforms
        final Bundle state = new Bundle();
        if (mMenuView != null) {
            SparseArray<Parcelable> hierarchy = new SparseArray<>();
            mMenuView.saveHierarchyState(hierarchy);
            state.putSparseParcelableArray(STATE_HIERARCHY, hierarchy);
        }
        if (mAdapter != null) {
            state.putBundle(STATE_ADAPTER, mAdapter.createInstanceState());
        }
        if (mHeaderLayout != null) {
            SparseArray<Parcelable> header = new SparseArray<>();
            mHeaderLayout.saveHierarchyState(header);
            state.putSparseParcelableArray(STATE_HEADER, header);
        }
        return state;
    }
    return null;
}
Also used : SparseArray(android.util.SparseArray) Bundle(android.os.Bundle) Parcelable(android.os.Parcelable)

Aggregations

Parcelable (android.os.Parcelable)826 Bundle (android.os.Bundle)99 View (android.view.View)85 Intent (android.content.Intent)58 SparseArray (android.util.SparseArray)38 Test (org.junit.Test)31 ArrayList (java.util.ArrayList)26 MenuItem (android.view.MenuItem)23 ImageView (android.widget.ImageView)23 TextView (android.widget.TextView)17 MenuItem (com.actionbarsherlock.view.MenuItem)14 SuppressLint (android.annotation.SuppressLint)13 Dialog (android.app.Dialog)13 MediumTest (android.support.test.filters.MediumTest)13 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)12 Paint (android.graphics.Paint)12 MenuView (com.android.internal.view.menu.MenuView)12 RemoteException (android.os.RemoteException)11 Bitmap (android.graphics.Bitmap)10 ShortcutIconResource (android.content.Intent.ShortcutIconResource)9