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();
}
}
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);
}
}
}
}
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;
}
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);
}
}
}
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;
}
Aggregations