Java Code Examples for androidx.core.app.ActivityCompat#finishAfterTransition()

The following examples show how to use androidx.core.app.ActivityCompat#finishAfterTransition() . 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: AwesomeActivity.java    From AndroidNavigation with MIT License 6 votes vote down vote up
@Override
public void onBackPressed() {
    FragmentManager fragmentManager = getSupportFragmentManager();
    int count = fragmentManager.getBackStackEntryCount();
    if (count > 0) {
        FragmentManager.BackStackEntry entry = fragmentManager.getBackStackEntryAt(count - 1);
        AwesomeFragment fragment = (AwesomeFragment) fragmentManager.findFragmentByTag(entry.getName());
        if (fragment != null && fragment.isAdded() && !fragment.dispatchBackPressed()) {
            if (count == 1) {
                if (!handleBackPressed()) {
                    ActivityCompat.finishAfterTransition(this);
                }
            } else {
                dismissFragment(fragment);
            }
        }
    } else {
        super.onBackPressed();
    }
}
 
Example 2
Source File: SettingsActivity.java    From HgLauncher with GNU General Public License v3.0 5 votes vote down vote up
public void restartActivity() {
    Intent intent = getIntent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    ActivityCompat.finishAfterTransition(this);
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    startActivity(intent);
}
 
Example 3
Source File: SettingsActivity.java    From HgLauncher with GNU General Public License v3.0 5 votes vote down vote up
public void restartActivity() {
    Intent intent = getIntent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    ActivityCompat.finishAfterTransition(this);
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    startActivity(intent);
}
 
Example 4
Source File: FilterEditorActivity.java    From NekoSMS with GNU General Public License v3.0 5 votes vote down vote up
private void saveAndFinish() {
    Uri filterUri = persistFilterData();
    int messageId = (filterUri != null) ? R.string.filter_saved : R.string.filter_save_failed;
    Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show();
    Intent intent = new Intent();
    intent.setData(filterUri);
    setResult(RESULT_OK, intent);
    ActivityCompat.finishAfterTransition(this);
}
 
Example 5
Source File: SplashActivity.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    if (Utils.hasLollipop()) requestWindowFeature(Window.FEATURE_CONTENT_TRANSITIONS);
    super.onCreate(savedInstanceState);

    if (Utils.hasLollipop()) {
        getWindow().setExitTransition(new Fade());
    }

    Intent intent = new Intent(this, MainActivity.class);
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this);
    ActivityCompat.startActivity(this, intent, options.toBundle());
    ActivityCompat.finishAfterTransition(this);
}
 
Example 6
Source File: ImagePreViewActivity.java    From NewFastFrame with Apache License 2.0 4 votes vote down vote up
@Override
public void onBackPressed() {
    RxBusManager.getInstance().post(new PhotoPreEvent(flag, display.getCurrentItem()));
    ActivityCompat.finishAfterTransition(this);
}
 
Example 7
Source File: NavigationFinishClickListener.java    From Android-RefreshAndLoadMore-Demo with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(View v) {
    ActivityCompat.finishAfterTransition(activity);
}
 
Example 8
Source File: SearchActivity.java    From GeometricWeather with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void finishSelf(boolean selected) {
    setResult(selected ? RESULT_OK : RESULT_CANCELED, null);
    binding.searchContainer.setAlpha(0);
    ActivityCompat.finishAfterTransition(this);
}
 
Example 9
Source File: FilterEditorActivity.java    From NekoSMS with GNU General Public License v3.0 4 votes vote down vote up
private void discardAndFinish() {
    setResult(RESULT_CANCELED, null);
    ActivityCompat.finishAfterTransition(this);
}