Example usage for android.app Activity overridePendingTransition

List of usage examples for android.app Activity overridePendingTransition

Introduction

In this page you can find the example usage for android.app Activity overridePendingTransition.

Prototype

public void overridePendingTransition(int enterAnim, int exitAnim) 

Source Link

Document

Call immediately after one of the flavors of #startActivity(Intent) or #finish to specify an explicit transition animation to perform next.

Usage

From source file:Main.java

public static void openActivity(Activity activity, Class<?> pClass, Bundle pBundle, int requestCode,
        int enterAnim, int exitAnim) {
    if (null == activity)
        return;// w  w  w.  ja va2s  .co  m

    Intent intent = new Intent(activity, pClass);
    if (pBundle != null) {
        intent.putExtras(pBundle);
    }

    if (requestCode < 0) {
        activity.startActivity(intent);
    } else {
        activity.startActivityForResult(intent, requestCode);
    }

    if (enterAnim > 0 && exitAnim > 0) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}

From source file:Main.java

/**
 * Start the activity for result.//from ww w  .  j av  a 2  s .  c o  m
 *
 * @param activity    The activity.
 * @param intent      The description of the activity to start.
 * @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 Activity activity, @NonNull final Intent intent,
        final int requestCode, @AnimRes final int enterAnim, @AnimRes final int exitAnim) {
    startActivityForResult(intent, activity, requestCode, getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}

From source file:com.sythealth.fitness.util.Utils.java

/**
 * /*from  w  w  w .  j a  v a 2s.  c  om*/
 * @param activity ?context
 * @param cls activity
 * @param b ?
 * @param b1 ???activity
 */
public static void jumpUI(final Activity activity, final Class<?> cls, final boolean b, final boolean b1) {
    Intent intent = new Intent();
    intent.setClass(activity, cls);
    activity.startActivity(intent);
    if (b) {
        activity.overridePendingTransition(R.anim.push_left_in, R.anim.push_right_out);
    }
    if (b1) {
        activity.finish();
    }
}

From source file:Main.java

public static void start(Activity activity, Fragment fragment, Class<?> cls, Bundle extras, int req_code,
        int enterAnim, int exitAnim) {
    if (null != activity) {
        Intent intent = new Intent(activity, cls);
        if (null != extras) {
            intent.putExtras(extras);/*  w w w .  j ava  2 s .  co m*/
        }

        if (REQUEST_CODE_INVALID == req_code) {
            activity.startActivity(intent);
        } else {
            activity.startActivityForResult(intent, req_code);
        }

        if (0 != enterAnim || 0 != exitAnim) {
            activity.overridePendingTransition(enterAnim, exitAnim);
        }
    } else if (null != fragment) {
        activity = fragment.getActivity();

        if (null != activity) {
            Intent intent = new Intent(activity, cls);
            if (null != extras) {
                intent.putExtras(extras);
            }
            if (REQUEST_CODE_INVALID == req_code) {
                fragment.startActivity(intent);
            } else {
                fragment.startActivityForResult(intent, req_code);
            }

            if (0 != enterAnim || 0 != exitAnim) {
                activity.overridePendingTransition(enterAnim, exitAnim);
            }
        }
    }
}

From source file:com.desno365.mods.DesnoUtils.java

private static void overrideStartActivityAnimation(Activity activity, int resId) {
    activity.overridePendingTransition(resId, R.anim.hold);
}

From source file:com.desno365.mods.DesnoUtils.java

private static void overrideFinishActivityAnimation(Activity activity, int resId) {
    activity.overridePendingTransition(R.anim.hold, resId);
}

From source file:Main.java

/**
 * Start the activity for result./*from  w w  w. j  a  v  a2  s . c o  m*/
 *
 * @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);
    }
}

From source file:com.mercandalli.android.apps.files.file.text.FileTextActivity.java

public static void start(@NonNull final Activity activity, final FileModel fileModel, final boolean isOnline) {
    final Intent intent = new Intent(activity, FileTextActivity.class);
    intent.putExtra(EXTRA_MODEL_FILE_URL, "" + fileModel.getOnlineUrl());

    if (FileTypeModelENUM.FILESPACE.type.equals(fileModel.getType())) {
        intent.putExtra(EXTRA_MODEL_FILE_ARTICLE_CONTENT_1,
                "" + fileModel.getContent().getArticle().article_content_1);
    }//ww w  . java2  s .  c om

    intent.putExtra(EXTRA_MODEL_FILE_ONLINE, isOnline);
    activity.startActivity(intent);
    activity.overridePendingTransition(R.anim.left_in, R.anim.left_out);
}

From source file:Main.java

/**
 * Start the activity.//ww w .ja  va2 s . c  o m
 *
 * @param activity    The activity.
 * @param clz         The activity 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 Activity activity,
        @NonNull final Class<? extends Activity> clz, final int requestCode, @AnimRes final int enterAnim,
        @AnimRes final int exitAnim) {
    startActivityForResult(activity, null, activity.getPackageName(), clz.getName(), requestCode,
            getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}

From source file:Main.java

/**
 * Start the activity.// w  w  w  .java  2  s .c  o m
 *
 * @param extras      The Bundle of extras to add to this intent.
 * @param activity    The activity.
 * @param clz         The activity 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 Class<? extends Activity> clz, final int requestCode, @AnimRes final int enterAnim,
        @AnimRes final int exitAnim) {
    startActivityForResult(activity, extras, activity.getPackageName(), clz.getName(), requestCode,
            getOptionsBundle(activity, enterAnim, exitAnim));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        activity.overridePendingTransition(enterAnim, exitAnim);
    }
}