當前位置: 首頁>>代碼示例>>Java>>正文


Java Parcelable類代碼示例

本文整理匯總了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);
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:19,代碼來源:TouchImageView.java

示例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.");
			}
		}
	};
}
 
開發者ID:aartikov,項目名稱:Alligator,代碼行數:18,代碼來源:DialogFragmentConverter.java

示例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);
  }
 
開發者ID:tateisu,項目名稱:SubwayTooter,代碼行數:17,代碼來源:ColorPickerView.java

示例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;
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:21,代碼來源:ProviderCall.java

示例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);
        }
    }
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:26,代碼來源:ProfilePictureView.java

示例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());
}
 
開發者ID:sathishmscict,項目名稱:ChipsLayoutManager,代碼行數:28,代碼來源:ChipsLayoutManager.java

示例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();
}
 
開發者ID:OlayinkaPeter,項目名稱:Toodoo,代碼行數:25,代碼來源:FloatingActionButton.java

示例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;
    }
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:20,代碼來源:ViewPagerCompat.java

示例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();
}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:23,代碼來源:CircularSeekBar.java

示例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);
}
 
開發者ID:asif-patel,項目名稱:ImageEraser,代碼行數:17,代碼來源:TouchImageView.java

示例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;
}
 
開發者ID:michaelprimez,項目名稱:searchablespinner,代碼行數:23,代碼來源:SearchableSpinner.java

示例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;
}
 
開發者ID:zhudongya123,項目名稱:WechatChatroomHelper,代碼行數:18,代碼來源:BGASwipeBackLayout2.java

示例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;
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:17,代碼來源:Notification.java

示例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);
}
 
開發者ID:767954322,項目名稱:FlycoTabLayout,代碼行數:14,代碼來源:SlidingTabLayout.java

示例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;
}
 
開發者ID:elms1990,項目名稱:many-faced-view,代碼行數:10,代碼來源:ManyFacedView.java


注:本文中的android.os.Parcelable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。