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 startActivity(final Activity thisActivity, final Intent intent, final View triggerView,
        int colorOrImageRes, final long durationMills) {
    int[] location = new int[2];
    triggerView.getLocationInWindow(location);
    final int cx = location[0] + triggerView.getWidth();
    final int cy = location[1] + triggerView.getHeight() + (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 160, thisActivity.getResources().getDisplayMetrics());
    final ImageView view = new ImageView(thisActivity);
    view.setScaleType(ImageView.ScaleType.CENTER_CROP);
    view.setImageResource(colorOrImageRes);
    final ViewGroup decorView = (ViewGroup) thisActivity.getWindow().getDecorView();
    int w = decorView.getWidth();
    int h = decorView.getHeight();
    decorView.addView(view, w, h);//w  w w .  ja  va  2s .c om
    final int finalRadius = (int) Math.sqrt(w * w + h * h) + 1;
    Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
    anim.setDuration(durationMills);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            thisActivity.startActivity(intent);
            thisActivity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
        }
    });
    anim.start();
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static void overrideNormalActivityCloseAnimation(final Activity activity) {
    final TypedArray a = activity.obtainStyledAttributes(null, ANIM_CLOSE_STYLE_ATTRS, 0,
            android.R.style.Animation_Activity);
    final int activityCloseEnterAnimation = a.getResourceId(0, 0);
    final int activityCloseExitAnimation = a.getResourceId(1, 0);
    a.recycle();//from w ww .  j a v a2  s .  c  o m
    activity.overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation);
}

From source file:com.amaze.filemanager.activities.Preferences.java

@Override
public void onBackPressed() {
    if (select == 1 && changed == 1)
        restartPC(this);
    else if (select == 1 || select == 2) {
        selectItem(0);/*from  w w  w .  j av a  2s.  c om*/
    } else {
        Intent in = new Intent(Preferences.this, MainActivity.class);
        in.setAction(Intent.ACTION_MAIN);
        final int enter_anim = android.R.anim.fade_in;
        final int exit_anim = android.R.anim.fade_out;
        Activity activity = this;
        activity.overridePendingTransition(enter_anim, exit_anim);
        activity.finish();
        activity.overridePendingTransition(enter_anim, exit_anim);
        activity.startActivity(in);
    }
}

From source file:com.amaze.carbonfilemanager.activities.PreferencesActivity.java

public void restartPC(final Activity activity) {
    if (activity == null)
        return;/* ww  w. j  a  va2 s  .  co  m*/
    final int enter_anim = android.R.anim.fade_in;
    final int exit_anim = android.R.anim.fade_out;
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.finish();
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.startActivity(activity.getIntent());
}

From source file:com.amaze.filemanager.activities.Preferences.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // Navigate "up" the demo structure to the launchpad activity.
        if (select == 1 && changed == 1)
            restartPC(this);
        else if (select == 1) {
            selectItem(0);/*  w w w . j a  v  a  2  s.  c  om*/
        } else {
            Intent in = new Intent(Preferences.this, MainActivity.class);
            in.setAction(Intent.ACTION_MAIN);
            final int enter_anim = android.R.anim.fade_in;
            final int exit_anim = android.R.anim.fade_out;
            Activity activity = this;
            activity.overridePendingTransition(enter_anim, exit_anim);
            activity.finish();
            activity.overridePendingTransition(enter_anim, exit_anim);
            activity.startActivity(in);
        }
        return true;

    }
    return true;
}

From source file:net.zionsoft.obadiah.ui.fragments.TranslationListFragment.java

private void initializeUi() {
    mSwipeContainer.setColorSchemeResources(R.color.dark_cyan, R.color.dark_lime, R.color.blue,
            R.color.dark_blue);//from w  ww. j av a  2 s.c om
    mSwipeContainer.setOnRefreshListener(this);

    // workaround for https://code.google.com/p/android/issues/detail?id=77712
    mSwipeContainer.setProgressViewOffset(false, 0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            24, getResources().getDisplayMetrics()));
    mSwipeContainer.setRefreshing(true);

    mTranslationListAdapter = new TranslationListAdapter(getActivity(), mCurrentTranslation);
    mTranslationListView.setAdapter(mTranslationListAdapter);
    mTranslationListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!isAdded()) {
                return;
            }

            final Pair<TranslationInfo, Boolean> translation = mTranslationListAdapter.getTranslation(position);
            if (translation == null) {
                return;
            }

            if (translation.second) {
                Analytics.trackTranslationSelection(translation.first.shortName);

                mPreferences.edit()
                        .putString(Constants.PREF_KEY_LAST_READ_TRANSLATION, translation.first.shortName)
                        .apply();

                Activity activity = getActivity();
                activity.finish();
                activity.overridePendingTransition(R.anim.fade_in, R.anim.slide_out_left_to_right);
            } else {
                downloadTranslation(translation.first);
            }
        }
    });
    registerForContextMenu(mTranslationListView);
}

From source file:net.zionsoft.obadiah.ui.fragments.TranslationListFragment.java

private void loadTranslations(final boolean forceRefresh) {
    mTranslationListView.setVisibility(View.GONE);

    mBible.loadTranslations(forceRefresh, new Bible.OnTranslationsLoadedListener() {
        @Override/*from   ww  w. j ava  2 s  .c  o  m*/
        public void onTranslationsLoaded(List<TranslationInfo> downloaded, List<TranslationInfo> available) {
            if (!isAdded())
                return;

            if (downloaded == null || available == null) {
                DialogHelper.showDialog(getActivity(), false, R.string.dialog_retry_network,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                loadTranslations(forceRefresh);
                            }
                        }, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                final Activity activity = getActivity();
                                activity.finish();
                                activity.overridePendingTransition(R.anim.fade_in,
                                        R.anim.slide_out_left_to_right);
                            }
                        });
                return;
            }

            mSwipeContainer.setRefreshing(false);
            AnimationHelper.fadeIn(mTranslationListView);

            mTranslationListAdapter.setTranslations(downloaded, available);
            mTranslationListAdapter.notifyDataSetChanged();
        }
    });
}

From source file:com.github.ppamorim.library.DraggerView.java

private void finish() {
    if (canFinish) {
        Context context = getContext();
        if (context instanceof Activity) {
            Activity activity = (Activity) context;
            if (!activity.isFinishing()) {
                activity.overridePendingTransition(0, android.R.anim.fade_out);
                activity.finish();//  w  w w .java2s . c o m
            }
        }
    }
}

From source file:com.mercandalli.android.apps.files.user.ConversationUserModel.java

public void open(final Activity activity) {
    final Intent intent = new Intent(activity, ConversationActivity.class);
    intent.putExtra("LOGIN", "" + Config.getUser().getAccessLogin());
    intent.putExtra("PASSWORD", "" + Config.getUser().getAccessPassword());
    intent.putExtra("ID_CONVERSATION", "" + this.id_conversation);
    activity.startActivity(intent);//from   w  w  w . j  a v  a  2s  .co m
    activity.overridePendingTransition(R.anim.left_in, R.anim.left_out);
}

From source file:cn.liuguangqiang.swipeback.SwipeBackLayout.java

private void finish() {
    Activity act = (Activity) getContext();
    act.finish();
    act.overridePendingTransition(0, android.R.anim.fade_out);
}