Java Code Examples for android.support.v4.app.ActivityOptionsCompat#makeCustomAnimation()

The following examples show how to use android.support.v4.app.ActivityOptionsCompat#makeCustomAnimation() . 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: OptionsCompatDemoActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 简单做一个定制的动画,这个参数很简单,传入一个进入的动画的id,和移除动画的id即可
 */
private void showCustomAnim() {
    if (mTestSwitch) {
        ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeCustomAnimation(
                OptionsCompatDemoActivity.this,
                R.anim.slide_bottom_in,
                R.anim.slide_bottom_out);
        ActivityCompat.startActivity(
                OptionsCompatDemoActivity.this,
                mIntent,
                optionsCompat.toBundle());
    } else {
        ActivityOptionsCompatICS optionsCompatICS
                = ActivityOptionsCompatICS.makeCustomAnimation(
                OptionsCompatDemoActivity.this,
                R.anim.slide_bottom_in,
                R.anim.slide_bottom_out);
        ActivityCompatICS.startActivity(
                OptionsCompatDemoActivity.this,
                mIntent,
                optionsCompatICS.toBundle());
    }
}
 
Example 2
Source File: TransitionActivityFirst.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
private void startActivityWithAnim(int startAnimId, int endAnimId) {
    Intent intent = new Intent(
            TransitionActivityFirst.this,
            TransitionActivitySecond.class
    );
    if (mUseActivityOptionsCompat) {
        ActivityOptionsCompat activityOptionsCompat
                = ActivityOptionsCompat.makeCustomAnimation(
                TransitionActivityFirst.this,
                startAnimId,
                endAnimId);
        ActivityCompat.startActivity(
                TransitionActivityFirst.this,
                intent,
                activityOptionsCompat.toBundle());
    } else if (mUseActivityOptionsCompatICS) {
        ActivityOptionsCompatICS activityOptionsCompatICS
                = ActivityOptionsCompatICS.makeCustomAnimation(
                TransitionActivityFirst.this,
                startAnimId,
                endAnimId);
        ActivityCompatICS.startActivity(
                TransitionActivityFirst.this,
                intent,
                activityOptionsCompatICS.toBundle());
    } else {
        startActivity(intent);
        overridePendingTransition(startAnimId, endAnimId);
    }
}
 
Example 3
Source File: AddEntryActivity.java    From GoogleFitExample with Apache License 2.0 5 votes vote down vote up
/**
 * Used to start the activity using a custom animation.
 *
 * @param activity Reference to the Android Activity we are animating from
 * @param activityType Fitness activity type used to pre-populate the form field
 */
public static void launch(BaseActivity activity, int activityType) {
    ActivityOptionsCompat options =
            ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.enter_anim, R.anim.no_anim);
    Intent intent = new Intent(activity, AddEntryActivity.class);
    intent.putExtra(ARG_ACTIVITY_TYPE, activityType);
    ActivityCompat.startActivity(activity, intent, options.toBundle());
}
 
Example 4
Source File: RecentActivity.java    From GoogleFitExample with Apache License 2.0 5 votes vote down vote up
/**
 * Used to start the activity using a custom animation.
 *
 * @param activity Reference to the Android Activity we are animating from
 */
public static void launch(BaseActivity activity) {
    ActivityOptionsCompat options =
            ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.enter_anim, R.anim.no_anim);
    Intent intent = new Intent(activity, RecentActivity.class);
    ActivityCompat.startActivity(activity, intent, options.toBundle());
}
 
Example 5
Source File: ActivityAnimate.java    From SmartGo with Apache License 2.0 4 votes vote down vote up
public static void animate(@NonNull final Context context,final @NonNull Box<ActivityOptionsCompat> box,
                           @AnimRes int enterResId, @AnimRes int exitResId){
    final ActivityOptionsCompat compat = ActivityOptionsCompat
            .makeCustomAnimation(context,enterResId,exitResId);
    box.set(compat);
}
 
Example 6
Source File: TrackListData.java    From Pasta-for-Spotify with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.menu:
            PopupMenu popup = new PopupMenu(v.getContext(), v);
            MenuInflater inflater = popup.getMenuInflater();
            inflater.inflate(R.menu.menu_track, popup.getMenu());

            final MenuItem fav = popup.getMenu().findItem(R.id.action_fav);
            new Action<Boolean>() {
                @NonNull
                @Override
                public String id() {
                    return "isTrackFav";
                }

                @Nullable
                @Override
                protected Boolean run() throws InterruptedException {
                    return pasta.isFavorite(listData);
                }

                @Override
                protected void done(@Nullable Boolean result) {
                    if (result == null) return;
                    if (result) {
                        fav.setTitle(R.string.unfav);
                    } else {
                        fav.setTitle(R.string.fav);
                    }
                }

            }.execute();

            popup.setOnMenuItemClickListener(this);
            popup.show();
            break;
        default:
            ArrayList<TrackListData> trackList = new ArrayList<TrackListData>();
            if (listData.tracks != null)
                trackList.addAll(listData.tracks);
            else trackList.add(listData);

            StaticUtils.play(trackList.indexOf(listData), trackList, activity);

            ActivityOptionsCompat options = ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.slide_up, R.anim.blank);
            activity.startActivity(new Intent(activity, PlayerActivity.class), options.toBundle());
            break;
    }
}