android.support.annotation.AnimRes Java Examples

The following examples show how to use android.support.annotation.AnimRes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 6 votes vote down vote up
/**
 * Finish to the activity.
 *
 * @param activity      The activity.
 * @param isIncludeSelf True to include the activity, false otherwise.
 * @param enterAnim     A resource ID of the animation resource to use for the
 *                      incoming activity.
 * @param exitAnim      A resource ID of the animation resource to use for the
 *                      outgoing activity.
 */
public static boolean finishToActivity(@NonNull final Activity activity,
                                       final boolean isIncludeSelf,
                                       @AnimRes final int enterAnim,
                                       @AnimRes final int exitAnim) {
    List<Activity> activities = UtilsBridge.getActivityList();
    for (Activity act : activities) {
        if (act.equals(activity)) {
            if (isIncludeSelf) {
                finishActivity(act, enterAnim, exitAnim);
            }
            return true;
        }
        finishActivity(act, enterAnim, exitAnim);
    }
    return false;
}
 
Example #2
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
/**
 * Start the activity.
 *
 * @param intent    The description of the activity to start.
 * @param enterAnim A resource ID of the animation resource to use for the
 *                  incoming activity.
 * @param exitAnim  A resource ID of the animation resource to use for the
 *                  outgoing activity.
 * @return {@code true}: success<br>{@code false}: fail
 */
public static boolean startActivity(@NonNull final Intent intent,
                                    @AnimRes final int enterAnim,
                                    @AnimRes final int exitAnim) {
    Context context = UtilsBridge.getTopActivityOrApp();
    boolean isSuccess = startActivity(intent, context, getOptionsBundle(context, enterAnim, exitAnim));
    if (isSuccess) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN && context instanceof Activity) {
            ((Activity) context).overridePendingTransition(enterAnim, exitAnim);
        }
    }
    return isSuccess;
}
 
Example #3
Source File: CustomTabsIntent.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the exit animations.
 *
 * @param context Application context.
 * @param enterResId Resource ID of the "enter" animation for the application.
 * @param exitResId Resource ID of the "exit" animation for the browser.
 */
public Builder setExitAnimations(
        @NonNull Context context, @AnimRes int enterResId, @AnimRes int exitResId) {
    Bundle bundle = ActivityOptionsCompat.makeCustomAnimation(
            context, enterResId, exitResId).toBundle();
    mIntent.putExtra(EXTRA_EXIT_ANIMATION_BUNDLE, bundle);
    return this;
}
 
Example #4
Source File: SweetToast.java    From SweetTips with Apache License 2.0 5 votes vote down vote up
/**
 * 设置当前SweetToast实例的出入场动画(App中自定义)
 * @param animEnter
 * @param animExit
 * @return
 */
public SweetToast setAnimations(@AnimRes int animEnter,@AnimRes int animExit){
    try {
        Animation enter = AnimationUtils.loadAnimation(mContentView.getContext(),animEnter);
        Animation exit = AnimationUtils.loadAnimation(mContentView.getContext(),animExit);
        return setAnimations(enter,exit);
    }catch (Exception e){
        //用户传入的动画资源找不到/出现异常,直接返回
        Log.e("幻海流心","setAnimations ->  e:"+e.getLocalizedMessage());
        return this;
    }
}
 
Example #5
Source File: BaseRecyclerViewAdapter.java    From ZZShow with Apache License 2.0 5 votes vote down vote up
/**
 *  item 加载动画
 * @param holder
 * @param position
 * @param type
 */
protected void setItemAppearAnimation(RecyclerView.ViewHolder holder, int position, @AnimRes int type){
    if(position > mLastPosition){
        Animation animation = AnimationUtils.loadAnimation(holder.itemView.getContext(),type);
        holder.itemView.startAnimation(animation);
        mLastPosition = position;
    }
}
 
Example #6
Source File: FinestWebView.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
public Builder setCustomAnimations(@AnimRes int animationOpenEnter,
								   @AnimRes int animationOpenExit, @AnimRes int animationCloseEnter,
								   @AnimRes int animationCloseExit) {
	this.animationOpenEnter = animationOpenEnter;
	this.animationOpenExit = animationOpenExit;
	this.animationCloseEnter = animationCloseEnter;
	this.animationCloseExit = animationCloseExit;
	return this;
}
 
Example #7
Source File: NavOptions.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
NavOptions(int launchMode, @IdRes int popUpTo, boolean popUpToInclusive,
        @AnimRes @AnimatorRes int enterAnim, @AnimRes @AnimatorRes int exitAnim,
        @AnimRes @AnimatorRes int popEnterAnim, @AnimRes @AnimatorRes int popExitAnim) {
    mLaunchMode = launchMode;
    mPopUpTo = popUpTo;
    mPopUpToInclusive = popUpToInclusive;
    mEnterAnim = enterAnim;
    mExitAnim = exitAnim;
    mPopEnterAnim = popEnterAnim;
    mPopExitAnim = popExitAnim;
}
 
Example #8
Source File: PermissMe.java    From PermissMe with Apache License 2.0 5 votes vote down vote up
/**
 * Launches the intent passed in and deals with any of the parameters specified
 *
 * @param activityIntent
 * 		the activity intent to launch
 * @param callerActivity
 * 		the caller activity to launch the intent with
 * @param launchOptionsBundle
 * 		Additional options for how the Activity should be started, passed in through
 * 		{@link AppCompatActivity#startActivity(Intent, Bundle)} or
 * 		{@link AppCompatActivity#startActivityForResult(Intent, int, Bundle)}
 * @param targetFragment
 * 		a target fragment if specified to receive the callback
 * 		{@link AppCompatActivity#onActivityResult(int, int, Intent)} with the specified request code parameter
 * @param enterAnim
 * 		the res id of the activity-enter animation, 0 if none specified
 * @param exitAnim
 * 		the res id of the activity-exit animation, 0 if none specified
 * @param requestCode
 * 		the request code to start the destination activity with
 * 		{@link AppCompatActivity#startActivityForResult(Intent, int)}
 * @param shouldFinishActivityAfterResult
 * 		boolean whether should finish the caller activity after launching the
 */
@SuppressWarnings("checkstyle:parameternumber")
@VisibleForTesting
/*package*/ static void launchIntentWithParameters(@NonNull final Intent activityIntent,
                                                   @NonNull final AppCompatActivity callerActivity,
                                                   @Nullable final Bundle launchOptionsBundle,
                                                   @Nullable final Fragment targetFragment,
                                                   @AnimRes final int enterAnim,
                                                   @AnimRes final int exitAnim,
                                                   final int requestCode,
                                                   final boolean shouldFinishActivityAfterResult) {
	// Launch the activity on the main thread incase there are some animations the caller wants executed
	PermissMeUtils.runOnUiThread(new Runnable() {
		@Override
		public void run() {
			if (requestCode != 0) {
				if (targetFragment != null) {
					targetFragment.startActivityForResult(activityIntent, requestCode, launchOptionsBundle);
				} else {
					callerActivity.startActivityForResult(activityIntent, requestCode, launchOptionsBundle);
				}
			} else {
				callerActivity.startActivity(activityIntent, launchOptionsBundle);
			}

			if (enterAnim != 0 || exitAnim != 0) {
				PermissMe.overrideDefaultTransition(callerActivity, enterAnim, exitAnim);
			}

			if (shouldFinishActivityAfterResult) {
				callerActivity.finish();
			}
		}
	});
}
 
Example #9
Source File: TextBannerView.java    From TextBannerView with Apache License 2.0 5 votes vote down vote up
/**
 * 设置进入动画和离开动画
 *
 * @param inAnimResId  进入动画的resID
 * @param outAnimResID 离开动画的resID
 */
private void setInAndOutAnimation(@AnimRes int inAnimResId, @AnimRes int outAnimResID) {
    Animation inAnim = AnimationUtils.loadAnimation(getContext(), inAnimResId);
    inAnim.setDuration(animDuration);
    mViewFlipper.setInAnimation(inAnim);

    Animation outAnim = AnimationUtils.loadAnimation(getContext(), outAnimResID);
    outAnim.setDuration(animDuration);
    mViewFlipper.setOutAnimation(outAnim);
}
 
Example #10
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
/**
 * Start the activity for result.
 *
 * @param extras      The Bundle of extras to add to this intent.
 * @param pkg         The name of the package.
 * @param cls         The name of the class.
 * @param requestCode if &gt;= 0, this code will be returned in
 *                    onActivityResult() when the activity exits.
 * @param enterAnim   A resource ID of the animation resource to use for the
 *                    incoming activity.
 * @param exitAnim    A resource ID of the animation resource to use for the
 *                    outgoing activity.
 */
public static void startActivityForResult(@NonNull final Bundle extras,
                                          @NonNull final Activity activity,
                                          @NonNull final String pkg,
                                          @NonNull final String cls,
                                          final int requestCode,
                                          @AnimRes final int enterAnim,
                                          @AnimRes final int exitAnim) {
    startActivityForResult(activity, extras, pkg, cls,
            requestCode, getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example #11
Source File: MultiContactPicker.java    From MultiContactPicker with Apache License 2.0 5 votes vote down vote up
public Builder setActivityAnimations(@AnimRes Integer animationOpenEnter, @AnimRes Integer animationOpenExit, @AnimRes Integer animationCloseEnter, @AnimRes Integer
        animationCloseExit){
    this.animationOpenEnter = animationOpenEnter;
    this.animationOpenExit = animationOpenExit;
    this.animationCloseEnter = animationCloseEnter;
    this.animationCloseExit = animationCloseExit;
    return this;
}
 
Example #12
Source File: StackManager.java    From FragmentStack with Apache License 2.0 5 votes vote down vote up
/**
 * Set page switch animation
 *
 * @param nextIn  The next page to enter the animation
 * @param nextOut The next page out of the animation
 * @param quitIn  The current page into the animation
 * @param quitOut Exit animation for the current page
 */
public void setAnim(@AnimRes int nextIn, @AnimRes int nextOut, @AnimRes int quitIn, @AnimRes int quitOut) {
    this.nextIn = nextIn;
    this.nextOut = nextOut;
    this.quitIn = quitIn;
    this.quitOut = quitOut;
    next_in = AnimationUtils.loadAnimation(context, quitIn);
    next_out = AnimationUtils.loadAnimation(context, quitOut);
}
 
Example #13
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
/**
 * Finish the activities whose type not equals the activity class.
 *
 * @param clz       The activity class.
 * @param enterAnim A resource ID of the animation resource to use for the
 *                  incoming activity.
 * @param exitAnim  A resource ID of the animation resource to use for the
 *                  outgoing activity.
 */
public static void finishOtherActivities(@NonNull final Class<? extends Activity> clz,
                                         @AnimRes final int enterAnim,
                                         @AnimRes final int exitAnim) {
    List<Activity> activities = UtilsBridge.getActivityList();
    for (Activity act : activities) {
        if (!act.getClass().equals(clz)) {
            finishActivity(act, enterAnim, exitAnim);
        }
    }
}
 
Example #14
Source File: SnackbarUtils.java    From SweetTips with Apache License 2.0 5 votes vote down vote up
/**
 * 设置SweetSnackbar实例的 入场动画 及 离场动画
 * @param animateIn
 * @param animateOut
 * @return
 */
public SnackbarUtils anim(@AnimRes int animateIn, @AnimRes int animateOut){
    if(getSnackbar()!=null){
        getSnackbar().setAnimations(animateIn,animateOut);
    }
    return this;
}
 
Example #15
Source File: PopOptions.java    From scene with Apache License 2.0 5 votes vote down vote up
@NonNull
public PopOptions.Builder setAnimation(@NonNull Activity activity,
                                       @AnimRes @AnimatorRes int enterAnim,
                                       @AnimRes @AnimatorRes int exitAnim) {
    this.mNavigationAnimationExecutor = new AnimationOrAnimatorResourceExecutor(activity, enterAnim, exitAnim);
    return this;
}
 
Example #16
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
/**
 * Start the activity.
 *
 * @param extras    The Bundle of extras to add to this intent.
 * @param pkg       The name of the package.
 * @param cls       The name of the class.
 * @param enterAnim A resource ID of the animation resource to use for the
 *                  incoming activity.
 * @param exitAnim  A resource ID of the animation resource to use for the
 *                  outgoing activity.
 */
public static void startActivity(@NonNull final Bundle extras,
                                 @NonNull final String pkg,
                                 @NonNull final String cls,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    Context context = UtilsBridge.getTopActivityOrApp();
    startActivity(context, extras, pkg, cls, getOptionsBundle(context, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN && context instanceof Activity) {
        ((Activity) context).overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example #17
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
/**
 * Start the activity.
 *
 * @param extras    The Bundle of extras to add to this intent.
 * @param activity  The activity.
 * @param clz       The activity class.
 * @param enterAnim A resource ID of the animation resource to use for the
 *                  incoming activity.
 * @param exitAnim  A resource ID of the animation resource to use for the
 *                  outgoing activity.
 */
public static void startActivity(@NonNull final Bundle extras,
                                 @NonNull final Activity activity,
                                 @NonNull final Class<? extends Activity> clz,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    startActivity(activity, extras, activity.getPackageName(), clz.getName(),
            getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example #18
Source File: SnackbarUtils.java    From SweetTips with Apache License 2.0 5 votes vote down vote up
/**
 * 设置SweetSnackbar实例的 入场动画 及 离场动画
 * @param animateIn
 * @param animateOut
 * @return
 */
public SnackbarUtils anim(@AnimRes int animateIn, @AnimRes int animateOut){
    if(getSnackbar()!=null){
        getSnackbar().setAnimations(animateIn,animateOut);
    }
    return this;
}
 
Example #19
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
/**
 * Start the activity.
 *
 * @param activity  The activity.
 * @param clz       The activity class.
 * @param enterAnim A resource ID of the animation resource to use for the
 *                  incoming activity.
 * @param exitAnim  A resource ID of the animation resource to use for the
 *                  outgoing activity.
 */
public static void startActivity(@NonNull final Activity activity,
                                 @NonNull final Class<? extends Activity> clz,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    startActivity(activity, null, activity.getPackageName(), clz.getName(),
            getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example #20
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
/**
 * Start the activity.
 *
 * @param clz       The activity class.
 * @param enterAnim A resource ID of the animation resource to use for the
 *                  incoming activity.
 * @param exitAnim  A resource ID of the animation resource to use for the
 *                  outgoing activity.
 */
public static void startActivity(@NonNull final Class<? extends Activity> clz,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    Context context = UtilsBridge.getTopActivityOrApp();
    startActivity(context, null, context.getPackageName(), clz.getName(),
            getOptionsBundle(context, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN && context instanceof Activity) {
        ((Activity) context).overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example #21
Source File: CustomTabs.java    From ForceDoze with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method used to set the Animations when the Custom Tab opens
 * @param exitEnterAnimation The Enter Animation of the new activity
 * @param exitCloseAnimation The Close Animation of the custom tab
 */
public Style setExitAnimation(@AnimRes int exitEnterAnimation, @AnimRes int
        exitCloseAnimation){
    this.exitEnterAnimation = exitEnterAnimation;
    this.exitCloseAnimation = exitCloseAnimation;
    return this;
}
 
Example #22
Source File: EasyIntroCarouselFragment.java    From EasyIntro with Apache License 2.0 5 votes vote down vote up
@Override
public void withOverlaySlideAnimation(@AnimRes int enter, @AnimRes int exit, @AnimRes int popEnter, @AnimRes int popExit) {
    // define animations for whole overlay slides
    mOverlaySlidesAnimations[0] = enter;
    mOverlaySlidesAnimations[1] = exit;
    mOverlaySlidesAnimations[2] = popEnter;
    mOverlaySlidesAnimations[3] = popExit;
}
 
Example #23
Source File: SweetToast.java    From SweetTips with Apache License 2.0 5 votes vote down vote up
/**
 * 设置当前SweetToast实例的出入场动画(App中自定义)
 * @param animEnter
 * @param animExit
 * @return
 */
public SweetToast setAnimations(@AnimRes int animEnter,@AnimRes int animExit){
    try {
        Animation enter = AnimationUtils.loadAnimation(mContentView.getContext(),animEnter);
        Animation exit = AnimationUtils.loadAnimation(mContentView.getContext(),animExit);
        return setAnimations(enter,exit);
    }catch (Exception e){
        //用户传入的动画资源找不到/出现异常,直接返回
        Log.e("幻海流心","setAnimations ->  e:"+e.getLocalizedMessage());
        return this;
    }
}
 
Example #24
Source File: Flowr.java    From flowr with Apache License 2.0 5 votes vote down vote up
/**
 * Set a Custom Animation to a Fragment transaction.
 *
 * @param enterAnim    The animation resource to be used when the next fragment enters.
 * @param exitAnim     The animation resource to be used when the current fragment exits.
 * @param popEnterAnim The animation resource to be used when the previous fragment enters on back pressed.
 * @param popExitAnim  The animation resource to be used when the current fragment exits on back pressed..
 */
public Builder setCustomTransactionAnimation(@AnimRes int enterAnim, @AnimRes int exitAnim,
                                             @AnimRes int popEnterAnim, @AnimRes int popExitAnim) {
    data.setEnterAnim(enterAnim);
    data.setExitAnim(exitAnim);
    data.setPopEnterAnim(popEnterAnim);
    data.setPopExitAnim(popExitAnim);
    return this;

}
 
Example #25
Source File: BaseNavigationStrategy.java    From fragment-navigation-2.0 with Apache License 2.0 4 votes vote down vote up
boolean navigateTo(T context, Type fragmentClass, Bundle bundle, @AnimRes int enterAnimId, @AnimRes int exitAnimId) {
    return navigationExecutor(context, fragmentClass, bundle, null, enterAnimId, exitAnimId);
}
 
Example #26
Source File: MNImageBrowser.java    From MNImageBrowser with GNU General Public License v3.0 4 votes vote down vote up
public MNImageBrowser setActivityOpenAnime(@AnimRes int activityOpenAnime) {
    imageBrowserConfig.setActivityOpenAnime(activityOpenAnime);
    return this;
}
 
Example #27
Source File: MNImageBrowser.java    From MNImageBrowser with GNU General Public License v3.0 4 votes vote down vote up
public MNImageBrowser setActivityExitAnime(@AnimRes int activityExitAnime) {
    imageBrowserConfig.setActivityExitAnime(activityExitAnime);
    return this;
}
 
Example #28
Source File: AnimationSet.java    From TabStacker with Apache License 2.0 4 votes vote down vote up
public AnimationSet(@AnimRes int pushInAnim, @AnimRes int pushOutAnim, @AnimRes int popInAnim, @AnimRes int popOutAnim) {
    mPushInAnim = pushInAnim;
    mPushOutAnim = pushOutAnim;
    mPopInAnim = popInAnim;
    mPopOutAnim = popOutAnim;
}
 
Example #29
Source File: ImageBrowserConfig.java    From MNImageBrowser with GNU General Public License v3.0 4 votes vote down vote up
public void setActivityExitAnime(@AnimRes int activityExitAnime) {
    this.activityExitAnime = activityExitAnime;
}
 
Example #30
Source File: ImageBrowserConfig.java    From MNImageBrowser with GNU General Public License v3.0 4 votes vote down vote up
public void setActivityOpenAnime(@AnimRes int activityOpenAnime) {
    this.activityOpenAnime = activityOpenAnime;
}