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);
}
}
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();
}
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();
}
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;
}
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();
}
Aggregations