本文整理汇总了Java中android.os.Parcelable类的典型用法代码示例。如果您正苦于以下问题:Java Parcelable类的具体用法?Java Parcelable怎么用?Java Parcelable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Parcelable类属于android.os包,在下文中一共展示了Parcelable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRestoreInstanceState
import android.os.Parcelable; //导入依赖的package包/类
@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);
}
示例2: getDefaultScreenGettingFunction
import android.os.Parcelable; //导入依赖的package包/类
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.");
}
}
};
}
示例3: onRestoreInstanceState
import android.os.Parcelable; //导入依赖的package包/类
@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);
}
示例4: addArg
import android.os.Parcelable; //导入依赖的package包/类
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;
}
示例5: onRestoreInstanceState
import android.os.Parcelable; //导入依赖的package包/类
/**
* 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);
}
}
}
示例6: onRestoreInstanceState
import android.os.Parcelable; //导入依赖的package包/类
/**
* {@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());
}
示例7: onRestoreInstanceState
import android.os.Parcelable; //导入依赖的package包/类
@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();
}
示例8: onRestoreInstanceState
import android.os.Parcelable; //导入依赖的package包/类
@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;
}
}
示例9: onRestoreInstanceState
import android.os.Parcelable; //导入依赖的package包/类
@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();
}
示例10: onRestoreInstanceState
import android.os.Parcelable; //导入依赖的package包/类
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);
}
示例11: onSaveInstanceState
import android.os.Parcelable; //导入依赖的package包/类
@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;
}
示例12: onRestoreInstanceState
import android.os.Parcelable; //导入依赖的package包/类
@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;
}
示例13: getUriArrayFromNotificationParcelableArray
import android.os.Parcelable; //导入依赖的package包/类
@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;
}
示例14: onRestoreInstanceState
import android.os.Parcelable; //导入依赖的package包/类
@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);
}
示例15: onSaveInstanceState
import android.os.Parcelable; //导入依赖的package包/类
@Override
protected Parcelable onSaveInstanceState() {
Parcelable parentState = super.onSaveInstanceState();
SavedState savedState = new SavedState(parentState);
savedState.currentState = currentState;
savedState.previousState = previousState;
return savedState;
}