Search in sources :

Example 76 with DialogInterface

use of android.content.DialogInterface in project AntennaPod by AntennaPod.

the class MainActivity method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    final int position = mPosition;
    // reset
    mPosition = -1;
    if (position < 0) {
        return false;
    }
    Feed feed = navDrawerData.feeds.get(position - navAdapter.getSubscriptionOffset());
    switch(item.getItemId()) {
        case R.id.mark_all_seen_item:
            DBWriter.markFeedSeen(feed.getId());
            return true;
        case R.id.mark_all_read_item:
            DBWriter.markFeedRead(feed.getId());
            return true;
        case R.id.rename_item:
            new RenameFeedDialog(this, feed).show();
            return true;
        case R.id.remove_item:
            final FeedRemover remover = new FeedRemover(this, feed) {

                @Override
                protected void onPostExecute(Void result) {
                    super.onPostExecute(result);
                    if (getSelectedNavListIndex() == position) {
                        loadFragment(EpisodesFragment.TAG, null);
                    }
                }
            };
            ConfirmationDialog conDialog = new ConfirmationDialog(this, R.string.remove_feed_label, R.string.feed_delete_confirmation_msg) {

                @Override
                public void onConfirmButtonPressed(DialogInterface dialog) {
                    dialog.dismiss();
                    long mediaId = PlaybackPreferences.getCurrentlyPlayingFeedMediaId();
                    if (mediaId > 0 && FeedItemUtil.indexOfItemWithMediaId(feed.getItems(), mediaId) >= 0) {
                        Log.d(TAG, "Currently playing episode is about to be deleted, skipping");
                        remover.skipOnCompletion = true;
                        int playerStatus = PlaybackPreferences.getCurrentPlayerStatus();
                        if (playerStatus == PlaybackPreferences.PLAYER_STATUS_PLAYING) {
                            sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
                        }
                    }
                    remover.executeAsync();
                }
            };
            conDialog.createNewDialog().show();
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
Also used : FeedRemover(de.danoeh.antennapod.core.asynctask.FeedRemover) DialogInterface(android.content.DialogInterface) RenameFeedDialog(de.danoeh.antennapod.dialog.RenameFeedDialog) Intent(android.content.Intent) Feed(de.danoeh.antennapod.core.feed.Feed) ConfirmationDialog(de.danoeh.antennapod.core.dialog.ConfirmationDialog)

Example 77 with DialogInterface

use of android.content.DialogInterface in project android_frameworks_base by DirtyUnicorns.

the class RetailDemoModeService method showInactivityCountdownDialog.

private void showInactivityCountdownDialog() {
    UserInactivityCountdownDialog dialog = new UserInactivityCountdownDialog(getContext(), mWarningDialogTimeout, MILLIS_PER_SECOND);
    dialog.setNegativeButtonClickListener(null);
    dialog.setPositiveButtonClickListener(new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            mHandler.sendEmptyMessage(MSG_START_NEW_SESSION);
        }
    });
    dialog.setOnCountDownExpiredListener(new OnCountDownExpiredListener() {

        @Override
        public void onCountDownExpired() {
            mHandler.sendEmptyMessage(MSG_START_NEW_SESSION);
        }
    });
    dialog.show();
}
Also used : DialogInterface(android.content.DialogInterface) OnCountDownExpiredListener(com.android.server.retaildemo.UserInactivityCountdownDialog.OnCountDownExpiredListener)

Example 78 with DialogInterface

use of android.content.DialogInterface in project android_frameworks_base by DirtyUnicorns.

the class DirectoryFragment method deleteDocuments.

private void deleteDocuments(final Selection selected) {
    Metrics.logUserAction(getContext(), Metrics.USER_ACTION_DELETE);
    assert (!selected.isEmpty());
    final DocumentInfo srcParent = getDisplayState().stack.peek();
    // Model must be accessed in UI thread, since underlying cursor is not threadsafe.
    List<DocumentInfo> docs = mModel.getDocuments(selected);
    TextView message = (TextView) mInflater.inflate(R.layout.dialog_delete_confirmation, null);
    message.setText(generateDeleteMessage(docs));
    // This "insta-hides" files that are being deleted, because
    // the delete operation may be not execute immediately (it
    // may be queued up on the FileOperationService.)
    // To hide the files locally, we call the hide method on the adapter
    // ...which a live object...cannot be parceled.
    // For that reason, for now, we implement this dialog NOT
    // as a fragment (which can survive rotation and have its own state),
    // but as a simple runtime dialog. So rotating a device with an
    // active delete dialog...results in that dialog disappearing.
    // We can do better, but don't have cycles for it now.
    new AlertDialog.Builder(getActivity()).setView(message).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            // the user cancels the delete.
            if (mActionMode != null) {
                mActionMode.finish();
            } else {
                Log.w(TAG, "Action mode is null before deleting documents.");
            }
            // Hide the files in the UI...since the operation
            // might be queued up on FileOperationService.
            // We're walking a line here.
            mAdapter.hide(selected.getAll());
            FileOperations.delete(getActivity(), docs, srcParent, getDisplayState().stack);
        }
    }).setNegativeButton(android.R.string.no, null).show();
}
Also used : DialogInterface(android.content.DialogInterface) TextView(android.widget.TextView) Point(android.graphics.Point) DocumentInfo(com.android.documentsui.model.DocumentInfo)

Example 79 with DialogInterface

use of android.content.DialogInterface in project android_frameworks_base by DirtyUnicorns.

the class PowerNotificationWarnings method showStartSaverConfirmation.

private void showStartSaverConfirmation() {
    if (mSaverConfirmation != null)
        return;
    final SystemUIDialog d = new SystemUIDialog(mContext);
    d.setTitle(R.string.battery_saver_confirmation_title);
    d.setMessage(com.android.internal.R.string.battery_saver_description);
    d.setNegativeButton(android.R.string.cancel, null);
    d.setPositiveButton(R.string.battery_saver_confirmation_ok, mStartSaverMode);
    d.setShowForAllUsers(true);
    d.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            mSaverConfirmation = null;
        }
    });
    d.show();
    mSaverConfirmation = d;
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) DialogInterface(android.content.DialogInterface) OnDismissListener(android.content.DialogInterface.OnDismissListener)

Example 80 with DialogInterface

use of android.content.DialogInterface in project Rashr by DsLNeXuS.

the class Notifyer method showAppRateDialog.

public static void showAppRateDialog(final Context mContext, final String PREF_NAME, final String PREF_KEY_HIDE_RATER) {
    new AlertDialog.Builder(mContext).setTitle(R.string.rate_title).setMessage(R.string.rate_message).setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            Common.setBooleanPref(mContext, PREF_NAME, PREF_KEY_HIDE_RATER, true);
            mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + mContext.getPackageName())));
        }
    }).setNeutralButton(R.string.neutral, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
        }
    }).setNegativeButton(R.string.never_ask, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            Common.setBooleanPref(mContext, PREF_NAME, PREF_KEY_HIDE_RATER, true);
        }
    }).show();
}
Also used : DialogInterface(android.content.DialogInterface) Intent(android.content.Intent)

Aggregations

DialogInterface (android.content.DialogInterface)2727 AlertDialog (android.app.AlertDialog)1227 View (android.view.View)877 Intent (android.content.Intent)708 TextView (android.widget.TextView)653 AlertDialog (android.support.v7.app.AlertDialog)644 EditText (android.widget.EditText)426 ImageView (android.widget.ImageView)308 OnClickListener (android.content.DialogInterface.OnClickListener)285 LayoutInflater (android.view.LayoutInflater)242 SuppressLint (android.annotation.SuppressLint)225 AdapterView (android.widget.AdapterView)220 ListView (android.widget.ListView)220 ArrayList (java.util.ArrayList)213 Dialog (android.app.Dialog)179 Context (android.content.Context)179 File (java.io.File)160 OnClickListener (android.view.View.OnClickListener)157 Bundle (android.os.Bundle)146 Activity (android.app.Activity)143