Example usage for android.app DialogFragment dismiss

List of usage examples for android.app DialogFragment dismiss

Introduction

In this page you can find the example usage for android.app DialogFragment dismiss.

Prototype

public void dismiss() 

Source Link

Document

Dismiss the fragment and its dialog.

Usage

From source file:org.mariotaku.twidere.util.SaveFileTask.java

@Override
protected void onPostExecute(final File result) {
    final FragmentManager fm = activity.getFragmentManager();
    final DialogFragment fragment = (DialogFragment) fm.findFragmentByTag(PROGRESS_FRAGMENT_TAG);
    if (fragment != null) {
        fragment.dismiss();
    }/*from   ww w .  j  a va 2  s  . c  o  m*/
    super.onPostExecute(result);
    if (result != null && result.exists()) {
        Toast.makeText(activity, R.string.saved_to_gallery, Toast.LENGTH_SHORT).show();
    } else {
        Toast.makeText(activity, R.string.error_occurred, Toast.LENGTH_SHORT).show();
    }
}

From source file:org.mariotaku.twidere.util.SaveFileTask.java

@Override
protected void onCancelled() {
    final FragmentManager fm = activity.getFragmentManager();
    final DialogFragment fragment = (DialogFragment) fm.findFragmentByTag(PROGRESS_FRAGMENT_TAG);
    if (fragment != null && fragment.isVisible()) {
        fragment.dismiss();
    }//from   w  w  w  . j  a v  a  2  s . c o  m
    super.onCancelled();
}

From source file:com.bccs.bsecure.Conversation.java

@Override
public void onCancelPressed(DialogFragment dialog) {
    dialog.dismiss();
}

From source file:com.facebook.react.modules.timepicker.TimePickerDialogModule.java

@ReactMethod
public void open(@Nullable final ReadableMap options, Promise promise) {

    Activity activity = getCurrentActivity();
    if (activity == null) {
        promise.reject(ERROR_NO_ACTIVITY,
                "Tried to open a TimePicker dialog while not attached to an Activity");
        return;// w  w w .  j av a 2  s  .c  o  m
    }
    // We want to support both android.app.Activity and the pre-Honeycomb FragmentActivity
    // (for apps that use it for legacy reasons). This unfortunately leads to some code duplication.
    if (activity instanceof android.support.v4.app.FragmentActivity) {
        android.support.v4.app.FragmentManager fragmentManager = ((android.support.v4.app.FragmentActivity) activity)
                .getSupportFragmentManager();
        android.support.v4.app.DialogFragment oldFragment = (android.support.v4.app.DialogFragment) fragmentManager
                .findFragmentByTag(FRAGMENT_TAG);
        if (oldFragment != null) {
            oldFragment.dismiss();
        }
        SupportTimePickerDialogFragment fragment = new SupportTimePickerDialogFragment();
        if (options != null) {
            Bundle args = createFragmentArguments(options);
            fragment.setArguments(args);
        }
        TimePickerDialogListener listener = new TimePickerDialogListener(promise);
        fragment.setOnDismissListener(listener);
        fragment.setOnTimeSetListener(listener);
        fragment.show(fragmentManager, FRAGMENT_TAG);
    } else {
        FragmentManager fragmentManager = activity.getFragmentManager();
        DialogFragment oldFragment = (DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
        if (oldFragment != null) {
            oldFragment.dismiss();
        }
        TimePickerDialogFragment fragment = new TimePickerDialogFragment();
        if (options != null) {
            final Bundle args = createFragmentArguments(options);
            fragment.setArguments(args);
        }
        TimePickerDialogListener listener = new TimePickerDialogListener(promise);
        fragment.setOnDismissListener(listener);
        fragment.setOnTimeSetListener(listener);
        fragment.show(fragmentManager, FRAGMENT_TAG);
    }
}

From source file:com.facebook.react.modules.datepicker.DatePickerDialogModule.java

/**
 * Show a date picker dialog.//from   w  w w  .  j  ava 2  s. com
 *
 * @param options a map containing options. Available keys are:
 *
 * <ul>
 *   <li>{@code date} (timestamp in milliseconds) the date to show by default</li>
 *   <li>
 *     {@code minDate} (timestamp in milliseconds) the minimum date the user should be allowed
 *     to select
 *   </li>
 *   <li>
 *     {@code maxDate} (timestamp in milliseconds) the maximum date the user should be allowed
 *     to select
 *    </li>
 * </ul>
 *
 * @param promise This will be invoked with parameters action, year,
 *                month (0-11), day, where action is {@code dateSetAction} or
 *                {@code dismissedAction}, depending on what the user did. If the action is
 *                dismiss, year, month and date are undefined.
 */
@ReactMethod
public void open(@Nullable final ReadableMap options, Promise promise) {
    Activity activity = getCurrentActivity();
    if (activity == null) {
        promise.reject(ERROR_NO_ACTIVITY,
                "Tried to open a DatePicker dialog while not attached to an Activity");
        return;
    }
    // We want to support both android.app.Activity and the pre-Honeycomb FragmentActivity
    // (for apps that use it for legacy reasons). This unfortunately leads to some code duplication.
    if (activity instanceof android.support.v4.app.FragmentActivity) {
        android.support.v4.app.FragmentManager fragmentManager = ((android.support.v4.app.FragmentActivity) activity)
                .getSupportFragmentManager();
        android.support.v4.app.DialogFragment oldFragment = (android.support.v4.app.DialogFragment) fragmentManager
                .findFragmentByTag(FRAGMENT_TAG);
        if (oldFragment != null) {
            oldFragment.dismiss();
        }
        SupportDatePickerDialogFragment fragment = new SupportDatePickerDialogFragment();
        if (options != null) {
            final Bundle args = createFragmentArguments(options);
            fragment.setArguments(args);
        }
        final DatePickerDialogListener listener = new DatePickerDialogListener(promise);
        fragment.setOnDismissListener(listener);
        fragment.setOnDateSetListener(listener);
        fragment.show(fragmentManager, FRAGMENT_TAG);
    } else {
        FragmentManager fragmentManager = activity.getFragmentManager();
        DialogFragment oldFragment = (DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
        if (oldFragment != null) {
            oldFragment.dismiss();
        }
        DatePickerDialogFragment fragment = new DatePickerDialogFragment();
        if (options != null) {
            final Bundle args = createFragmentArguments(options);
            fragment.setArguments(args);
        }
        final DatePickerDialogListener listener = new DatePickerDialogListener(promise);
        fragment.setOnDismissListener(listener);
        fragment.setOnDateSetListener(listener);
        fragment.show(fragmentManager, FRAGMENT_TAG);
    }
}

From source file:com.bccs.bsecure.Main.java

@Override
public void onOKPressed(DialogFragment dialog) {

    ConversationManager manager = ConversationManager.getManager(this);
    manager.clearAllConversations();//w w w. jav  a  2 s  . c  om
    dialog.dismiss();
    activeNums = new ArrayList<>();
    activeInfoAdapter.clearItems();
    updateActiveNums();
}

From source file:com.rubixconsulting.walletcracker.WalletCrackerMain.java

private void hideDialog(String tag) {
    DialogFragment fragment = (DialogFragment) getFragmentManager().findFragmentByTag(tag);
    if (fragment != null) {
        Log.d(TAG, "dismissing " + tag);
        fragment.dismiss();
    }// w  ww.  j av a  2 s  .  co m
}

From source file:com.vaporwarecorp.mirror.feature.main.MirrorActivity.java

private void hideDialogFragment(final DialogFragment dialogFragment) {
    dialogFragment.dismiss();
}

From source file:com.bccs.bsecure.Conversation.java

@Override
public void onOKPressed(DialogFragment dialog) {
    ConversationManager.ConversationHelper helper = ConversationManager.getConversation(this,
            currentNumber.getId());//  w  ww  .ja  v a 2s.  c  o  m
    helper.deleteConversation();
    dialog.dismiss();
    Intent intent = new Intent(Conversation.this, Main.class);
    startActivity(intent);
}

From source file:com.hijridatepicker.HijriDatePickerAndroidModule.java

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.//from ww  w.  j ava 2 s.c  o  m
 * <p>
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 * Show a date picker dialog.
 *
 * @param options a map containing options. Available keys are:
 *                <p>
 *                <ul>
 *                <li>{@code date} (timestamp in milliseconds) the date to show by default</li>
 *                <li>
 *                {@code minDate} (timestamp in milliseconds) the minimum date the user should be allowed
 *                to select
 *                </li>
 *                <li>
 *                {@code maxDate} (timestamp in milliseconds) the maximum date the user should be allowed
 *                to select
 *                </li>
 *                <li>
 *                {@code mode} To set the date picker mode to ' no_arrows/default' ,
 *                currently there's only one mode for HijriDatePicker, so this field works only with mode no_arrows/default
 *                </li>
 *                <li>
 *                {@code weekDayLabels} (array of strings) the day labels that appears on the calendar
 *                </li>
 *                </ul>
 * @param promise This will be invoked with parameters action, year,
 *                month (0-11), day, where action is {@code dateSetAction} or
 *                {@code dismissedAction}, depending on what the user did. If the action is
 *                dismiss, year, month and date are undefined.
 */
@ReactMethod
public void open(@Nullable final ReadableMap options, Promise promise) {
    try {
        Activity activity = getCurrentActivity();
        if (activity == null) {
            promise.reject(ERROR_NO_ACTIVITY,
                    "Tried to open a DatePicker dialog while not attached to an Activity");
            return;
        }
        // We want to support both android.app.Activity and the pre-Honeycomb FragmentActivity
        // (for apps that use it for legacy reasons). This unfortunately leads to some code duplication.
        if (activity instanceof android.support.v4.app.FragmentActivity) {
            android.support.v4.app.FragmentManager fragmentManager = ((android.support.v4.app.FragmentActivity) activity)
                    .getSupportFragmentManager();
            android.support.v4.app.DialogFragment oldFragment = (android.support.v4.app.DialogFragment) fragmentManager
                    .findFragmentByTag(FRAGMENT_TAG);
            if (oldFragment != null) {
                oldFragment.dismiss();
            }
            SupportHijriDatePickerDialogFragment fragment = new SupportHijriDatePickerDialogFragment();
            if (options != null) {
                final Bundle args = createFragmentArguments(options, promise);
                if (args == null)
                    return;
                fragment.setArguments(args);
            }
            final DatePickerDialogListener listener = new DatePickerDialogListener(promise);
            fragment.setOnDismissListener(listener);
            fragment.setOnDateSetListener(listener);
            fragment.setOnExceptionListener(listener);
            fragment.show(fragmentManager, FRAGMENT_TAG);
        } else {
            FragmentManager fragmentManager = activity.getFragmentManager();
            DialogFragment oldFragment = (DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
            if (oldFragment != null) {
                oldFragment.dismiss();
            }
            HijriDatePickerDialogFragment fragment = new HijriDatePickerDialogFragment();
            if (options != null) {
                final Bundle args = createFragmentArguments(options, promise);
                if (args == null)
                    return;
                fragment.setArguments(args);
            }
            final DatePickerDialogListener listener = new DatePickerDialogListener(promise);
            fragment.setOnDismissListener(listener);
            fragment.setOnDateSetListener(listener);
            fragment.setOnExceptionListener(listener);
            fragment.show(fragmentManager, FRAGMENT_TAG);
        }
    } catch (Exception e) {
        promise.reject(ERROR_OPEN,
                "Exception happened while executing open method, details: " + e.getMessage());
    }
}