Example usage for android.app Activity finishAfterTransition

List of usage examples for android.app Activity finishAfterTransition

Introduction

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

Prototype

public void finishAfterTransition() 

Source Link

Document

Reverses the Activity Scene entry Transition and triggers the calling Activity to reverse its exit Transition.

Usage

From source file:Main.java

/**
 * @see android.app.Activity#finishAfterTransition().
 *///from  ww  w  . ja v  a 2  s .c o m
public static void finishAfterTransition(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.finishAfterTransition();
    } else {
        activity.finish();
    }
}

From source file:shetye.prathamesh.notifyme.Utilities.java

public void createWhenDialog(final Context context, final Activity parentActivity, final Notif note,
        final boolean back) {
    mDialog = new Dialog(context);
    mDialog.setContentView(R.layout.datetimepicker_dialog);
    mDialog.setTitle("When to Notify??");
    mDialogOKBtn = (Button) mDialog.findViewById(R.id.btn_ok);
    mDialogOKBtn.setOnClickListener(new View.OnClickListener() {
        @Override//from  w w  w .  j  a  v a 2  s  .c  o  m
        public void onClick(View v) {
            note.setNotification_when(getSelectedTime());
            DatabaseHelper.getInstance(context).addNotif(note);
            setZoneInTimer(context, note);
            mDialog.dismiss();
            if (parentActivity != null) {
                if (back) {
                    parentActivity.finishAfterTransition();
                } else {
                    ((Notifications) parentActivity).refreshNotifications();
                }
            }
        }
    });
    mDialogOKBtn.setEnabled(false);
    mDialogCancelBtn = (Button) mDialog.findViewById(R.id.btn_cancel);
    mDialogCancelBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mDialog.dismiss();
            if (parentActivity != null) {
                parentActivity.finishAfterTransition();
            }
        }
    });
    mTimeBtn = (Button) mDialog.findViewById(R.id.btntimeset);
    mDateBtn = (Button) mDialog.findViewById(R.id.btndateset);
    final Time dtNow = new Time();
    dtNow.setToNow();
    mSelectedHours = dtNow.hour;
    mSelectedMinutes = dtNow.minute;
    mSelectedYear = dtNow.year;
    mSelectedMonth = dtNow.month;
    mSelectedDay = dtNow.monthDay;
    updateBtnText(dtNow, false, context);
    Time selectedTime = new Time();
    selectedTime.set(0, mSelectedMinutes, mSelectedHours, mSelectedDay, mSelectedMonth, mSelectedYear);
    mPastDateSelected = true;
    mTimeBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            TimePickerDialog timePickerDialog = new TimePickerDialog(context,
                    new TimePickerDialog.OnTimeSetListener() {
                        @Override
                        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                            Time selectedTime = new Time();
                            mSelectedHours = hourOfDay;
                            mSelectedMinutes = minute;
                            selectedTime.set(0, mSelectedMinutes, mSelectedHours, mSelectedDay, mSelectedMonth,
                                    mSelectedYear);
                            if (Time.compare(selectedTime, dtNow) <= 0) {
                                mPastDateSelected = true;
                            } else {
                                mPastDateSelected = false;
                            }
                            updateBtnText(selectedTime, true, context);
                        }
                    }, mSelectedHours, mSelectedMinutes, false);
            timePickerDialog.show();
        }
    });
    mDateBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DatePickerDialog datePickerDialog = new DatePickerDialog(context,
                    new DatePickerDialog.OnDateSetListener() {
                        @Override
                        public void onDateSet(DatePicker view, int yy, int mm, int dd) {
                            Time selectedTime = new Time();
                            mSelectedYear = yy;
                            mSelectedMonth = mm;
                            mSelectedDay = dd;
                            selectedTime.set(0, mSelectedMinutes, mSelectedHours, mSelectedDay, mSelectedMonth,
                                    mSelectedYear);
                            if (Time.compare(selectedTime, dtNow) <= 0) {
                                mPastDateSelected = true;
                            } else {
                                mPastDateSelected = false;
                            }
                            updateBtnText(selectedTime, false, context);
                        }
                    }, mSelectedYear, mSelectedMonth, mSelectedDay);
            datePickerDialog.show();
        }
    });
    mDialog.show();
}