Java Code Examples for android.support.annotation.AnimRes

The following are top voted examples for showing how to use android.support.annotation.AnimRes. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: MarqueeView.java   View source code 6 votes vote down vote up
/**
 * 根据字符串,启动翻页公告
 *
 * @param notice       字符串
 * @param inAnimResId  进入动画的resID
 * @param outAnimResID 离开动画的resID
 */
@SuppressWarnings("deprecation")
public void startWithText(final String notice, final @AnimRes int inAnimResId, final @AnimRes int outAnimResID) {
    if (TextUtils.isEmpty(notice)) return;
    getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                getViewTreeObserver().removeOnGlobalLayoutListener(this);
            } else {
                getViewTreeObserver().removeGlobalOnLayoutListener(this);
            }
            startWithFixedWidth(notice, inAnimResId, outAnimResID);
        }
    });
}
 
Example 2
Project: GitHub   File: MarqueeView.java   View source code 6 votes vote down vote up
/**
 * 根据字符串和宽度,启动翻页公告
 *
 * @param notice 字符串
 */
private void startWithFixedWidth(String notice, @AnimRes int inAnimResId, @AnimRes int outAnimResID) {
    int noticeLength = notice.length();
    int width = Utils.px2dip(getContext(), getWidth());
    if (width == 0) {
        throw new RuntimeException("Please set the width of MarqueeView !");
    }
    int limit = width / textSize;
    List list = new ArrayList();

    if (noticeLength <= limit) {
        list.add(notice);
    } else {
        int size = noticeLength / limit + (noticeLength % limit != 0 ? 1 : 0);
        for (int i = 0; i < size; i++) {
            int startIndex = i * limit;
            int endIndex = ((i + 1) * limit >= noticeLength ? noticeLength : (i + 1) * limit);
            list.add(notice.substring(startIndex, endIndex));
        }
    }

    if (notices == null) notices = new ArrayList<>();
    notices.clear();
    notices.addAll(list);
    start(inAnimResId, outAnimResID);
}
 
Example 3
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 6 votes vote down vote up
/**
 * 结束到指定 Activity
 *
 * @param activity      activity
 * @param isIncludeSelf 是否结束该 activity 自己
 * @param enterAnim     入场动画
 * @param exitAnim      出场动画
 */
public static boolean finishToActivity(@NonNull final Activity activity,
                                       final boolean isIncludeSelf,
                                       @AnimRes final int enterAnim,
                                       @AnimRes final int exitAnim) {
    List<Activity> activities = Utils.sActivityList;
    for (int i = activities.size() - 1; i >= 0; --i) {
        Activity aActivity = activities.get(i);
        if (aActivity.equals(activity)) {
            if (isIncludeSelf) {
                finishActivity(aActivity, enterAnim, exitAnim);
            }
            return true;
        }
        finishActivity(aActivity, enterAnim, exitAnim);
    }
    return false;
}
 
Example 4
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 6 votes vote down vote up
/**
 * 结束到指定 Activity
 *
 * @param clz           Activity 类
 * @param isIncludeSelf 是否结束该 activity 自己
 * @param enterAnim     入场动画
 * @param exitAnim      出场动画
 */
public static boolean finishToActivity(@NonNull final Class<?> clz,
                                       final boolean isIncludeSelf,
                                       @AnimRes final int enterAnim,
                                       @AnimRes final int exitAnim) {
    List<Activity> activities = Utils.sActivityList;
    for (int i = activities.size() - 1; i >= 0; --i) {
        Activity aActivity = activities.get(i);
        if (aActivity.getClass().equals(clz)) {
            if (isIncludeSelf) {
                finishActivity(aActivity, enterAnim, exitAnim);
            }
            return true;
        }
        finishActivity(aActivity, enterAnim, exitAnim);
    }
    return false;
}
 
Example 5
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 6 votes vote down vote up
/**
 * 结束所有其他类型的 Activity
 *
 * @param clz       Activity 类
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void finishOtherActivities(@NonNull final Class<?> clz,
                                         @AnimRes final int enterAnim,
                                         @AnimRes final int exitAnim) {
    List<Activity> activities = Utils.sActivityList;
    boolean flag = false;
    for (int i = activities.size() - 1; i >= 0; i--) {
        Activity activity = activities.get(i);
        if (activity.getClass().equals(clz)) {
            if (flag) {
                finishActivity(activity, enterAnim, exitAnim);
            } else {
                flag = true;
            }
        } else {
            finishActivity(activity, enterAnim, exitAnim);
        }
    }
}
 
Example 6
Project: GitHub   File: MarqueeView.java   View source code 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);
    if (hasSetAnimDuration) inAnim.setDuration(animDuration);
    setInAnimation(inAnim);

    Animation outAnim = AnimationUtils.loadAnimation(getContext(), outAnimResID);
    if (hasSetAnimDuration) outAnim.setDuration(animDuration);
    setOutAnimation(outAnim);
}
 
Example 7
Project: GitHub   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动Activity
 *
 * @param cls       activity类
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Class<?> cls,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    Context context = getActivityOrApp();
    startActivity(context, null, context.getPackageName(), cls.getName(),
            getOptionsBundle(context, enterAnim, exitAnim));
}
 
Example 8
Project: GitHub   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动Activity
 *
 * @param activity  activity
 * @param cls       activity类
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Activity activity,
                                 @NonNull final Class<?> cls,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {

    startActivity(activity, null, activity.getPackageName(), cls.getName(),
            getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example 9
Project: GitHub   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动Activity
 *
 * @param extras    extras
 * @param cls       activity类
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Bundle extras,
                                 @NonNull final Class<?> cls,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    Context context = getActivityOrApp();
    startActivity(context, extras, context.getPackageName(), cls.getName(),
            getOptionsBundle(context, enterAnim, exitAnim));
}
 
Example 10
Project: GitHub   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动Activity
 *
 * @param extras    extras
 * @param activity  activity
 * @param cls       activity类
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Bundle extras,
                                 @NonNull final Activity activity,
                                 @NonNull final Class<?> cls,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    startActivity(activity, extras, activity.getPackageName(), cls.getName(),
            getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example 11
Project: GitHub   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动Activity
 *
 * @param activity  activity
 * @param pkg       包名
 * @param cls       全类名
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Activity activity,
                                 @NonNull final String pkg,
                                 @NonNull final String cls,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    startActivity(activity, null, pkg, cls, getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example 12
Project: GitHub   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动Activity
 *
 * @param extras    extras
 * @param pkg       包名
 * @param cls       全类名
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Bundle extras,
                                 @NonNull final Activity activity,
                                 @NonNull final String pkg,
                                 @NonNull final String cls,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    startActivity(activity, extras, pkg, cls, getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example 13
Project: GitHub   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动Activity
 *
 * @param activity  activity
 * @param intent    意图
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Activity activity,
                                 @NonNull final Intent intent,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    startActivity(intent, activity, getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example 14
Project: GitHub   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动Activity
 *
 * @param activity  activity
 * @param intents   意图
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivities(@NonNull final Activity activity,
                                   @NonNull final Intent[] intents,
                                   @AnimRes final int enterAnim,
                                   @AnimRes final int exitAnim) {
    startActivities(intents, activity, getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example 15
Project: SkinFramework   File: ComposedResources.java   View source code 5 votes vote down vote up
@Override
public XmlResourceParser getAnimation(@AnimRes int id) throws NotFoundException {
    int realId = getCorrespondResIdStrictly(id);
    if (realId > 0) {
        return mSkinResources.getAnimation(realId);
    }
    return super.getAnimation(id);
}
 
Example 16
Project: MVP-Android   File: RecyclerViewUtils.java   View source code 5 votes vote down vote up
public static void runLayoutAnimation(final RecyclerView recyclerView, @AnimRes int res) {
    final Context context = recyclerView.getContext();
    final LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(context, res);

    recyclerView.setLayoutAnimation(controller);
    recyclerView.getAdapter().notifyDataSetChanged();
    recyclerView.scheduleLayoutAnimation();
}
 
Example 17
Project: XinFramework   File: ExtraTransaction.java   View source code 5 votes vote down vote up
@Override
public ExtraTransaction setCustomAnimations(@AnimRes int targetFragmentEnter
        , @AnimRes int currentFragmentPopExit) {
    mRecord.targetFragmentEnter = targetFragmentEnter;
    mRecord.currentFragmentPopExit = currentFragmentPopExit;
    mRecord.currentFragmentPopEnter = 0;
    mRecord.targetFragmentExit = 0;
    return this;
}
 
Example 18
Project: XinFramework   File: ExtraTransaction.java   View source code 5 votes vote down vote up
@Override
public ExtraTransaction setCustomAnimations(@AnimRes int targetFragmentEnter,
                                            @AnimRes int currentFragmentPopExit,
                                            @AnimRes int currentFragmentPopEnter,
                                            @AnimRes int targetFragmentExit) {
    mRecord.targetFragmentEnter = targetFragmentEnter;
    mRecord.currentFragmentPopExit = currentFragmentPopExit;
    mRecord.currentFragmentPopEnter = currentFragmentPopEnter;
    mRecord.targetFragmentExit = targetFragmentExit;
    return this;
}
 
Example 19
Project: chromium-for-android-56-debug-video   File: CustomTabsIntent.java   View source code 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 20
Project: flowr   File: Flowr.java   View source code 5 votes vote down vote up
/**
 * Set a Custom Animation to a Fragment transaction
 *
 * @param transaction  The transaction that will
 * @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..
 */
private void setCustomAnimations(FragmentTransaction transaction, @AnimRes int enterAnim,
                                 @AnimRes int exitAnim, @AnimRes int popEnterAnim, @AnimRes int popExitAnim) {
    transaction.setCustomAnimations(
            enterAnim,
            exitAnim,
            popEnterAnim,
            popExitAnim
    );
}
 
Example 21
Project: flowr   File: Flowr.java   View source code 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 22
Project: CXJPadProject   File: BActivity.java   View source code 5 votes vote down vote up
/**
     * 替换fragement 并添加动画
     */
    public void replaceFragment(@IdRes int id_content, @AnimRes int anim_in, @AnimRes int anim_out, Fragment fragment) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
//        transaction.setCustomAnimations(anim_in, anim_out);
        transaction.replace(id_content, fragment);
        transaction.commit();
    }
 
Example 23
Project: CXJPadProject   File: BActivity.java   View source code 5 votes vote down vote up
/**
     * 替换fragement 并添加动画
     * 替换fragement的同时对fragment进行“入back栈”操作 ,据我所知并不是真正的进入内存栈
     *
     * @param id_content
     * @param anim_in
     * @param anim_out
     * @param fragment
     */
    @Deprecated
    public void replaceFragmentWithBackStack(@IdRes int id_content, @AnimRes int anim_in, @AnimRes int anim_out, Fragment fragment) {
        String tag = fragment.getClass().getSimpleName();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
//        transaction.setCustomAnimations(anim_in, anim_out);
        transaction.replace(id_content, fragment, tag);
        //记录commit一次操作,与mFragmentManager.popBackStack();匹配使用
        transaction.addToBackStack(tag);
        //commitAllowingStateLoss 优于 commit 方法,当使用commit方法时,系统将进行状态判断,如果状态(mStateSaved)已经保存,将发生"Can not perform this action after onSaveInstanceState"错误。
        //如果mNoTransactionsBecause已经存在,将发生"Can not perform this action inside of " + mNoTransactionsBecause错误。
        transaction.commitAllowingStateLoss();
    }
 
Example 24
Project: HeadlineNews   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动Activity
 *
 * @param extras    extras
 * @param pkg       包名
 * @param cls       全类名
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Bundle extras,
                                 @NonNull final Activity activity,
                                 @NonNull final String pkg,
                                 @NonNull final String cls,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    startActivity(activity, extras, pkg, cls, null);
    activity.overridePendingTransition(enterAnim, exitAnim);
}
 
Example 25
Project: AutoScrollr   File: CustomTabs.java   View source code 5 votes vote down vote up
/**
 * Method used to set the Animations when the Custom Tab opens
 * @param startEnterAnimation The Enter Animation of the custom tab
 * @param startCloseAnimation The Close Animation of the new activity
 */
public Style setStartAnimation(@AnimRes int startEnterAnimation, @AnimRes int
        startCloseAnimation){
    this.startEnterAnimation = startEnterAnimation;
    this.startCloseAnimation = startCloseAnimation;
    return this;
}
 
Example 26
Project: AutoScrollr   File: CustomTabs.java   View source code 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 27
Project: UIKit-ViewBlock   File: ViewBlock.java   View source code 5 votes vote down vote up
@Override
public ViewBlock setCustomAnimations(@AnimRes int enter, @AnimRes int exit,
                                     @AnimRes int popEnter, @AnimRes int popExit) {
    mEnterAnim = enter;
    mExitAnim = exit;
    mPopEnterAnim = popEnter;
    mPopExitAnim = popExit;
    return this;
}
 
Example 28
Project: AndroidUtilCode   File: FragmentUtils.java   View source code 5 votes vote down vote up
/**
 * 替换 fragment
 *
 * @param srcFragment  源 fragment
 * @param destFragment 目标 fragment
 * @param isAddStack   是否入回退栈
 * @param enterAnim    入场动画
 * @param exitAnim     出场动画
 * @param popEnterAnim 入栈动画
 * @param popExitAnim  出栈动画
 */
public static void replace(@NonNull final Fragment srcFragment,
                           @NonNull final Fragment destFragment,
                           final boolean isAddStack,
                           @AnimRes final int enterAnim,
                           @AnimRes final int exitAnim,
                           @AnimRes final int popEnterAnim,
                           @AnimRes final int popExitAnim) {
    Args args = getArgs(srcFragment);
    replace(srcFragment.getFragmentManager(), destFragment, args.id, isAddStack,
            enterAnim, exitAnim, popEnterAnim, popExitAnim);
}
 
Example 29
Project: AndroidUtilCode   File: FragmentUtils.java   View source code 5 votes vote down vote up
/**
 * 替换 fragment
 *
 * @param fm           fragment 管理器
 * @param containerId  布局 Id
 * @param fragment     fragment
 * @param isAddStack   是否入回退栈
 * @param enterAnim    入场动画
 * @param exitAnim     出场动画
 * @param popEnterAnim 入栈动画
 * @param popExitAnim  出栈动画
 */
public static void replace(@NonNull final FragmentManager fm,
                           @NonNull final Fragment fragment,
                           @IdRes final int containerId,
                           final boolean isAddStack,
                           @AnimRes final int enterAnim,
                           @AnimRes final int exitAnim,
                           @AnimRes final int popEnterAnim,
                           @AnimRes final int popExitAnim) {
    FragmentTransaction ft = fm.beginTransaction();
    putArgs(fragment, new Args(containerId, false, isAddStack));
    addAnim(ft, enterAnim, exitAnim, popEnterAnim, popExitAnim);
    operate(TYPE_REPLACE_FRAGMENT, fm, ft, null, fragment);
}
 
Example 30
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动 Activity
 *
 * @param clz       Activity 类
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Class<?> clz,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    Context context = getActivityOrApp();
    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 31
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动 Activity
 *
 * @param activity  activity
 * @param clz       Activity 类
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Activity activity,
                                 @NonNull final Class<?> 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 32
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动 Activity
 *
 * @param extras    extras
 * @param clz       Activity 类
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Bundle extras,
                                 @NonNull final Class<?> clz,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    Context context = getActivityOrApp();
    startActivity(context, extras, 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 33
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动 Activity
 *
 * @param extras    extras
 * @param activity  activity
 * @param clz       Activity 类
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Bundle extras,
                                 @NonNull final Activity activity,
                                 @NonNull final Class<?> 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 34
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动 Activity
 *
 * @param pkg       包名
 * @param cls       全类名
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final String pkg,
                                 @NonNull final String cls,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    Context context = getActivityOrApp();
    startActivity(context, null, 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 35
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动 Activity
 *
 * @param activity  activity
 * @param pkg       包名
 * @param cls       全类名
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Activity activity,
                                 @NonNull final String pkg,
                                 @NonNull final String cls,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    startActivity(activity, null, pkg, cls, getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example 36
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动 Activity
 *
 * @param extras    extras
 * @param pkg       包名
 * @param cls       全类名
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
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 = getActivityOrApp();
    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 37
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动 Activity
 *
 * @param extras    extras
 * @param pkg       包名
 * @param cls       全类名
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Bundle extras,
                                 @NonNull final Activity activity,
                                 @NonNull final String pkg,
                                 @NonNull final String cls,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    startActivity(activity, extras, pkg, cls, getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example 38
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动 Activity
 *
 * @param intent    意图
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Intent intent,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    Context context = getActivityOrApp();
    startActivity(intent, context, getOptionsBundle(context, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN && context instanceof Activity) {
        ((Activity) context).overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example 39
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动 Activity
 *
 * @param activity  activity
 * @param intent    意图
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivity(@NonNull final Activity activity,
                                 @NonNull final Intent intent,
                                 @AnimRes final int enterAnim,
                                 @AnimRes final int exitAnim) {
    startActivity(intent, activity, getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}
 
Example 40
Project: AndroidUtilCode   File: ActivityUtils.java   View source code 5 votes vote down vote up
/**
 * 启动多个 Activity
 *
 * @param intents   意图
 * @param enterAnim 入场动画
 * @param exitAnim  出场动画
 */
public static void startActivities(@NonNull final Intent[] intents,
                                   @AnimRes final int enterAnim,
                                   @AnimRes final int exitAnim) {
    Context context = getActivityOrApp();
    startActivities(intents, context, getOptionsBundle(context, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN && context instanceof Activity) {
        ((Activity) context).overridePendingTransition(enterAnim, exitAnim);
    }
}