Code example for Activity

Methods: overridePendingTransitionstartActivity

1
	 */ 
	public void launchActivity(Class<?> cls) {
		Log.v(TAG, "launch activity :" + cls.getName());
		Intent intent = new Intent();
		intent.setClass(mActivity, cls);
		mActivity.startActivity(intent);
 
	} 
 
	public void setToastResource(int[] resourceIds) {
		mToastEnabled = true;
		mToastResourcesMap = resourceIds;
	} 
 
	private void maybeShowToast(int whichActicity) {
		if (mToastEnabled && whichActicity < mToastResourcesMap.length) {
			final Toast myToast = new Toast(mActivity);
			final ImageView myView = new ImageView(mActivity);
			myView.setImageResource(mToastResourcesMap[whichActicity]);
			myToast.setView(myView);
			myToast.setDuration(Toast.LENGTH_SHORT);
			myToast.setGravity(Gravity.BOTTOM | Gravity.CENTER, 0, 0);
			myToast.show();
		} 
	} 
 
	private void maybeShowAnimation(int whichActivity) {
		if (mAnimationEnabled) {
			boolean showPrevious = (mDirection == SHOW_PROVIOUS);
			if (showPrevious && mPreviousInAnimation != -1
					&& mPreviousOutAnimation != -1) {
				mActivity.overridePendingTransition(mPreviousInAnimation,
						mPreviousOutAnimation);
				return; // use Previous Animation 
			} 
 
			if (mNextInAnimation != -1 && mNextOutAnimation != -1) {
				mActivity.overridePendingTransition(mNextInAnimation,
						mNextOutAnimation);
			} 
		} 
	}