Java Code Examples for android.content.DialogInterface.OnClickListener

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Android-automation, under directory /TmtsApp/src/com/taobao/tmts/framework/app/.

Source file: MainActivity.java

  18 
vote

private void createDialogWithList(){
  Builder dialog=new AlertDialog.Builder(this);
  View view=getViewFromLayout(this,R.layout.listview_layout);
  initListView((ListView)view.findViewById(R.id.my_listview));
  dialog.setView(view);
  dialog.setNegativeButton("OK",new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
    }
  }
);
  dialog.create();
  dialog.show();
}
 

Example 2

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: MenuHelper.java

  18 
vote

public static void confirmAction(Context context,String title,String message,final Runnable action){
  OnClickListener listener=new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
        if (action != null)         action.run();
    }
  }
}
;
new AlertDialog.Builder(context).setIcon(android.R.drawable.ic_dialog_alert).setTitle(title).setMessage(message).setPositiveButton(android.R.string.ok,listener).setNegativeButton(android.R.string.cancel,listener).create().show();
}
 

Example 3

From project platform_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: MenuHelper.java

  18 
vote

public static void confirmAction(Context context,String title,String message,final Runnable action){
  OnClickListener listener=new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
        if (action != null)         action.run();
    }
  }
}
;
new AlertDialog.Builder(context).setIcon(android.R.drawable.ic_dialog_alert).setTitle(title).setMessage(message).setPositiveButton(android.R.string.ok,listener).setNegativeButton(android.R.string.cancel,listener).create().show();
}
 

Example 4

From project QuickSnap, under directory /Camera/src/com/lightbox/android/camera/.

Source file: MenuHelper.java

  18 
vote

public static void confirmAction(Context context,String title,String message,final Runnable action){
  OnClickListener listener=new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
        if (action != null)         action.run();
    }
  }
}
;
new AlertDialog.Builder(context).setIcon(android.R.drawable.ic_dialog_alert).setTitle(title).setMessage(message).setPositiveButton(android.R.string.ok,listener).setNegativeButton(android.R.string.cancel,listener).create().show();
}
 

Example 5

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/list/activity/.

Source file: AbstractDrilldownListActivity.java

  17 
vote

/** 
 * Permanently delete the selected item.
 */
@Override protected void deleteItem(final Id groupId){
  int childCount=getChildCount(groupId);
  if (childCount > 0) {
    OnClickListener buttonListener=new OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        if (which == DialogInterface.BUTTON1) {
          Log.i(cTag,"Deleting group id " + groupId);
          AbstractDrilldownListActivity.super.deleteItem(groupId);
          Log.i(cTag,"Deleting all child for group id " + groupId);
          deleteChildren(groupId);
        }
 else {
          Log.d(cTag,"Hit Cancel button. Do nothing.");
        }
      }
    }
;
    AlertUtils.showDeleteGroupWarning(this,getDrilldownListConfig().getItemName(this),getDrilldownListConfig().getChildName(this),childCount,buttonListener);
  }
 else {
    super.deleteItem(groupId);
  }
}
 

Example 6

From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/.

Source file: FileManagerActivity.java

  17 
vote

/** 
 * @since 2011-09-30
 */
private void showWarningDialog(){
  LayoutInflater li=LayoutInflater.from(this);
  View warningView=li.inflate(R.layout.dialog_warning,null);
  final CheckBox showWarningAgain=(CheckBox)warningView.findViewById(R.id.showagaincheckbox);
  showWarningAgain.setChecked(PreferenceActivity.getShowAllWarning(FileManagerActivity.this));
  new AlertDialog.Builder(this).setView(warningView).setTitle(getString(R.string.title_warning_some_may_not_work)).setMessage(getString(R.string.warning_some_may_not_work,mContextText)).setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton(android.R.string.ok,new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      PreferenceActivity.setShowAllWarning(FileManagerActivity.this,showWarningAgain.isChecked());
      showMoreCommandsDialog();
    }
  }
).create().show();
}
 

Example 7

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/app/.

Source file: AbstractGalleryActivity.java

  17 
vote

@Override protected void onStart(){
  super.onStart();
  if (getExternalCacheDir() == null) {
    OnCancelListener onCancel=new OnCancelListener(){
      @Override public void onCancel(      DialogInterface dialog){
        finish();
      }
    }
;
    OnClickListener onClick=new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        dialog.cancel();
      }
    }
;
    mAlertDialog=new AlertDialog.Builder(this).setIconAttribute(android.R.attr.alertDialogIcon).setTitle(R.string.no_storage_title).setMessage(R.string.no_storage_message).setNegativeButton(android.R.string.cancel,onClick).setOnCancelListener(onCancel).show();
    registerReceiver(mMountReceiver,mMountFilter);
  }
}
 

Example 8

From project android_packages_apps_Tag, under directory /src/com/android/apps/tag/.

Source file: MyTagList.java

  17 
vote

@Override public void onClick(View target){
switch (target.getId()) {
case R.id.toggle_enabled_target:
    boolean enabled=!mEnabled.isChecked();
  if (enabled) {
    if (mActiveTag != null) {
      enableSharingAndStoreTag();
      return;
    }
    Toast.makeText(this,getResources().getString(R.string.no_tag_selected),Toast.LENGTH_SHORT).show();
  }
disableSharing();
break;
case R.id.add_tag:
showDialog(DIALOG_ID_ADD_NEW_TAG);
break;
case R.id.active_tag:
if (mAdapter.getCursor() == null || mAdapter.getCursor().isClosed()) {
return;
}
if (mAdapter.getCursor().getCount() == 0) {
OnClickListener onAdd=new OnClickListener(){
@Override public void onClick(DialogInterface dialog,int which){
if (which == AlertDialog.BUTTON_POSITIVE) {
showDialog(DIALOG_ID_ADD_NEW_TAG);
}
}
}
;
new AlertDialog.Builder(this).setNegativeButton(android.R.string.cancel,null).setPositiveButton(R.string.add_tag,onAdd).setMessage(R.string.no_tags_created).show();
return;
}
showDialog(DIALOG_ID_SELECT_ACTIVE_TAG);
break;
}
}
 

Example 9

From project apps-for-android, under directory /WikiNotes/src/com/google/android/wikinotes/.

Source file: WikiActivityHelper.java

  17 
vote

/** 
 * If requested, delete the current note. The user is prompted to confirm this operation with a dialog, and if they choose to go ahead with the deletion, the current activity is finish()ed once the data has been removed, so that android naturally backtracks to the previous activity.
 */
public void deleteNote(final Cursor cursor){
  new AlertDialog.Builder(mContext).setTitle(mContext.getResources().getString(R.string.delete_title)).setMessage(R.string.delete_message).setPositiveButton(R.string.yes_button,new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int arg1){
      Uri noteUri=ContentUris.withAppendedId(WikiNote.Notes.ALL_NOTES_URI,cursor.getInt(0));
      mContext.getContentResolver().delete(noteUri,null,null);
      mContext.setResult(Activity.RESULT_OK);
      mContext.finish();
    }
  }
).setNegativeButton(R.string.no_button,null).show();
}
 

Example 10

From project be.norio.twunch.android, under directory /src/be/norio/twunch/android/ui/.

Source file: BaseActivity.java

  17 
vote

private Dialog createHtmlDialog(String title,int contentResourceId,String pageName){
  AnalyticsUtils.trackPageView(pageName);
  WebView webView=new WebView(this);
  webView.loadDataWithBaseURL(null,Util.readTextFromResource(this,contentResourceId),"text/html","utf-8",null);
  return new AlertDialog.Builder(this).setTitle(title).setView(webView).setPositiveButton(android.R.string.ok,null).setNeutralButton(R.string.rate,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=" + getPackageName())));
    }
  }
).create();
}
 

Example 11

From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/utils/.

Source file: Utils.java

  17 
vote

/** 
 * Displays an AlertDialog with the given error message and just a close button
 * @param context
 * @param errorMessage
 */
public static void displayErrorMessage(Context context,String errorMessage){
  Builder builder=new AlertDialog.Builder(context);
  builder.setTitle(context.getString(R.string.error));
  builder.setMessage(errorMessage);
  builder.setNeutralButton(context.getString(R.string.close),new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
    }
  }
);
  builder.show();
}
 

Example 12

From project com.juick.android, under directory /src/com/juick/android/.

Source file: JuickMessageMenu.java

  17 
vote

private void confirmAction(final int resId,final Runnable action){
  AlertDialog.Builder builder=new AlertDialog.Builder(activity);
  builder.setIcon(android.R.drawable.ic_dialog_alert);
  builder.setMessage(activity.getResources().getString(resId));
  builder.setPositiveButton(R.string.Yes,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      action.run();
    }
  }
);
  builder.setNegativeButton(R.string.Cancel,null);
  builder.show();
}
 

Example 13

From project DeskSMS, under directory /DeskSMS/src/com/koushikdutta/desktopsms/.

Source file: BuyActivity.java

  17 
vote

@Override public void onFinished(PurchaseResult result){
  if (result != PurchaseResult.SUCCEEDED) {
    finish();
    return;
  }
  Helper.showAlertDialog(this,R.string.purchase_thanks,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      finish();
    }
  }
);
}
 

Example 14

From project droid-fu, under directory /src/main/java/com/github/droidfu/activities/.

Source file: BetterActivityHelper.java

  17 
vote

/** 
 * Creates a new AlertDialog to display a simple message
 * @param context
 * @param dialogTitle
 * @param screenMessage
 * @param iconResourceId
 * @return
 */
public static AlertDialog newMessageDialog(final Context context,String dialogTitle,String screenMessage,int iconResourceId){
  AlertDialog.Builder builder=new AlertDialog.Builder(context);
  builder.setCancelable(false);
  builder.setPositiveButton("Okay",new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      dialog.dismiss();
    }
  }
);
  builder.setTitle(dialogTitle);
  builder.setMessage(screenMessage);
  builder.setIcon(iconResourceId);
  return builder.create();
}
 

Example 15

From project fanfoudroid, under directory /src/com/ch_linghu/fanfoudroid/ui/base/.

Source file: BaseActivity.java

  17 
vote

public void logout(){
  Dialog dialog=new AlertDialog.Builder(BaseActivity.this).setTitle("???").setMessage("?????????").setPositiveButton("???",new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      _logout();
    }
  }
).setNegativeButton("???",new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      dialog.dismiss();
    }
  }
).create();
  dialog.show();
}
 

Example 16

From project filemanager, under directory /FileManager/src/org/openintents/filemanager/util/.

Source file: MenuUtils.java

  17 
vote

/** 
 * Call this to show the dialog that informs the user about possibly broken options in the "More" dialog.
 * @param context The context that will be used for this dialog.
 * @param holder A {@link FileHolder} containing the file to act upon.
 */
private static void showWarningDialog(final FileHolder holder,final Context context){
  LayoutInflater li=LayoutInflater.from(context);
  View warningView=li.inflate(R.layout.dialog_warning,null);
  final CheckBox showWarningAgain=(CheckBox)warningView.findViewById(R.id.showagaincheckbox);
  showWarningAgain.setChecked(PreferenceActivity.getShowAllWarning(context));
  new AlertDialog.Builder(context).setView(warningView).setTitle(context.getString(R.string.title_warning_some_may_not_work)).setMessage(context.getString(R.string.warning_some_may_not_work)).setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton(android.R.string.ok,new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      PreferenceActivity.setShowAllWarning(context,showWarningAgain.isChecked());
      showMoreCommandsDialog(holder,context);
    }
  }
).create().show();
}
 

Example 17

From project HabReader, under directory /src/net/meiolania/apps/habrahabr/activities/.

Source file: CompaniesActivity.java

  17 
vote

@Override protected OnClickListener getConnectionDialogListener(){
  return new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      finish();
    }
  }
;
}
 

Example 18

From project ignition, under directory /ignition-core/ignition-core-lib/src/com/github/ignition/core/dialogs/.

Source file: IgnitedDialogs.java

  17 
vote

/** 
 * Builds a new AlertDialog to display a simple message
 * @param context
 * @param title
 * @param message
 * @param iconId
 * @return
 */
public static AlertDialog.Builder newMessageDialog(final Context context,String title,String message,int iconId){
  AlertDialog.Builder builder=new AlertDialog.Builder(context);
  builder.setCancelable(false);
  builder.setPositiveButton(context.getString(android.R.string.ok),new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      dialog.dismiss();
    }
  }
);
  builder.setTitle(title);
  builder.setMessage(message);
  builder.setIcon(iconId);
  return builder;
}
 

Example 19

From project LigiAndroidCommons, under directory /src/org/ligi/android/common/intents/.

Source file: IntentHelper.java

  17 
vote

public static void open_market_for_missing_action(final Context ctx,final String action){
  new AlertDialog.Builder(ctx).setTitle("App not found").setMessage("I am missing an APP to do that - please install!").setPositiveButton("OK",new OnClickListener(){
    public void onClick(    DialogInterface arg0,    int arg1){
      goToMarketPackage(ctx,action);
    }
  }
).show();
}
 

Example 20

From project nuxeo-android, under directory /nuxeo-android/src/org/nuxeo/android/simpleclient/.

Source file: NuxeoAndroidSplashScreenActivity.java

  17 
vote

@Override protected Dialog onCreateDialog(int id){
  if (id == NuxeoAndroidSplashScreenActivity.MISSING_SD_CARD_DIALOG_ID) {
    return new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.applicationName).setMessage(R.string.NuxeoAndroidSplashScreen_dialogMessage_noSdCard).setPositiveButton(android.R.string.ok,new OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        finish();
      }
    }
).create();
  }
  return super.onCreateDialog(id);
}
 

Example 21

From project PageTurner, under directory /src/main/java/net/nightwhistler/pageturner/activity/.

Source file: LibraryActivity.java

  17 
vote

@Override public void importComplete(int booksImported,List<String> errors){
  importDialog.hide();
  OnClickListener dismiss=new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      dialog.dismiss();
    }
  }
;
  if ((!errors.isEmpty())) {
    AlertDialog.Builder builder=new AlertDialog.Builder(LibraryActivity.this);
    builder.setTitle(R.string.import_errors);
    builder.setItems(errors.toArray(new String[errors.size()]),null);
    builder.setNeutralButton(android.R.string.ok,dismiss);
    builder.show();
  }
  listView.setKeepScreenOn(oldKeepScreenOn);
  if (booksImported > 0) {
    if (spinner.getSelectedItemPosition() == LibrarySelection.LAST_ADDED.ordinal()) {
      new LoadBooksTask().execute(LibrarySelection.LAST_ADDED);
    }
 else {
      spinner.setSelection(LibrarySelection.LAST_ADDED.ordinal());
    }
  }
 else {
    AlertDialog.Builder builder=new AlertDialog.Builder(LibraryActivity.this);
    builder.setTitle(R.string.no_books_found);
    builder.setMessage(getString(R.string.no_bks_fnd_text));
    builder.setNeutralButton(android.R.string.ok,dismiss);
    builder.show();
  }
}
 

Example 22

From project platform_packages_apps_contacts, under directory /src/com/android/contacts/calllog/.

Source file: ClearCallLogDialog.java

  17 
vote

@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  final ContentResolver resolver=getActivity().getContentResolver();
  final OnClickListener okListener=new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      final ProgressDialog progressDialog=ProgressDialog.show(getActivity(),getString(R.string.clearCallLogProgress_title),"",true,false);
      final AsyncTask<Void,Void,Void> task=new AsyncTask<Void,Void,Void>(){
        @Override protected Void doInBackground(        Void... params){
          resolver.delete(Calls.CONTENT_URI,null,null);
          return null;
        }
        @Override protected void onPostExecute(        Void result){
          progressDialog.dismiss();
        }
      }
;
      progressDialog.show();
      task.execute();
    }
  }
;
  return new AlertDialog.Builder(getActivity()).setTitle(R.string.clearCallLogConfirmation_title).setIconAttribute(android.R.attr.alertDialogIcon).setMessage(R.string.clearCallLogConfirmation).setNegativeButton(android.R.string.cancel,null).setPositiveButton(android.R.string.ok,okListener).setCancelable(true).create();
}
 

Example 23

From project platform_packages_apps_Gallery2_1, under directory /src/com/android/gallery3d/app/.

Source file: AbstractGalleryActivity.java

  17 
vote

@Override protected void onStart(){
  super.onStart();
  if (getExternalCacheDir() == null) {
    OnCancelListener onCancel=new OnCancelListener(){
      @Override public void onCancel(      DialogInterface dialog){
        finish();
      }
    }
;
    OnClickListener onClick=new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        dialog.cancel();
      }
    }
;
    mAlertDialog=new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle("No Storage").setMessage("No external storage available.").setNegativeButton(android.R.string.cancel,onClick).setOnCancelListener(onCancel).show();
    registerReceiver(mMountReceiver,mMountFilter);
  }
}
 

Example 24

From project Racenet-for-Android, under directory /src/org/racenet/.

Source file: NewsListActivity.java

  17 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  ExpandableListContextMenuInfo info=(ExpandableListContextMenuInfo)item.getMenuInfo();
  final String title=((TextView)info.targetView).getText().toString();
  final int groupPos=ExpandableListView.getPackedPositionGroup(info.packedPosition);
  new AlertDialog.Builder(NewsListActivity.this).setMessage("Do you really want to delete '" + title + "'?").setPositiveButton("Yes",new OnClickListener(){
    public void onClick(    DialogInterface arg0,    int arg1){
      db.deleteNews((int)mAdapter.getGroupId(groupPos));
      mAdapter.notifyDataSetChanged();
      Toast.makeText(NewsListActivity.this,"Deleted '" + title + "'",Toast.LENGTH_SHORT).show();
    }
  }
).setNegativeButton("No",null).show();
  return true;
}
 

Example 25

From project ratebeer-for-Android, under directory /RateBeerForAndroid/src/com/ratebeer/android/gui/fragments/.

Source file: ConfirmDialogFragment.java

  17 
vote

@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  return new AlertDialog.Builder(getActivity()).setIcon(android.R.drawable.ic_dialog_alert).setTitle(getString(dialogTitle,dialogTitleArgs)).setPositiveButton(android.R.string.yes,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      resultListener.onConfirmed();
    }
  }
).setNegativeButton(android.R.string.no,null).create();
}
 

Example 26

From project ratebeerforandroid, under directory /RateBeerForAndroid/src/com/ratebeer/android/gui/fragments/.

Source file: ConfirmDialogFragment.java

  17 
vote

@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  return new AlertDialog.Builder(getActivity()).setIcon(android.R.drawable.ic_dialog_alert).setTitle(getString(dialogTitle,dialogTitleArgs)).setPositiveButton(android.R.string.yes,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      resultListener.onConfirmed();
    }
  }
).setNegativeButton(android.R.string.no,null).create();
}
 

Example 27

From project roman10-android-tutorial, under directory /dash/src/roman10/media/dash/.

Source file: VideoBrowser.java

  17 
vote

private void selectPlayMethod(final String url){
  String lMsg="Select a Method to Play";
  AlertDialog.Builder builder=new AlertDialog.Builder(VideoBrowser.this);
  OnClickListener yesButtonListener=new OnClickListener(){
    public void onClick(    DialogInterface arg0,    int arg1){
      playVideoViaBrowser(url);
    }
  }
;
  OnClickListener noButtonListener=new OnClickListener(){
    public void onClick(    DialogInterface arg0,    int arg1){
      playVideoViaPlayer(url);
    }
  }
;
  builder.setMessage(lMsg).setCancelable(true).setPositiveButton("Browser",yesButtonListener).setNegativeButton("Player",noButtonListener);
  AlertDialog alert=builder.create();
  alert.show();
}
 

Example 28

From project shoppinglist, under directory /ShoppingList/src/org/openintents/.

Source file: OpenIntents.java

  17 
vote

/** 
 * shows an English message if open intents is not installed, finishes the activity after user clicked "ok".
 * @param activity
 */
public static final void requiresOpenIntents(final Activity activity){
  try {
    activity.getPackageManager().getPackageInfo("org.openintents",0);
  }
 catch (  NameNotFoundException e) {
    new AlertDialog.Builder(activity).setTitle("Warning").setMessage("Requires OpenIntents! Please install the open intents application from www.openintents.org first.").setPositiveButton("ok",new OnClickListener(){
      public void onClick(      DialogInterface arg0,      int arg1){
        activity.finish();
      }
    }
).show();
  }
}
 

Example 29

From project simplefacebook, under directory /src/com/androidquery/simplefeed/util/.

Source file: DialogUtility.java

  17 
vote

public static Dialog makeDialog(final Activity act,final List<ActionItem> items,final OnClickListener listener){
  final PQuery aq=new PQuery(act);
  ArrayAdapter<ActionItem> adapter=new ArrayAdapter<DialogUtility.ActionItem>(act,R.layout.item_dialog,items){
    @Override public View getView(    int position,    View convertView,    ViewGroup parent){
      convertView=aq.inflate(convertView,R.layout.item_dialog,parent);
      aq.recycle(convertView);
      ActionItem item=getItem(position);
      String name=item.name;
      String tb=item.tb;
      if (name == null && item.text > 0) {
        aq.id(R.id.tb).image(item.icon).background(0).getImageView().setScaleType(ScaleType.FIT_CENTER);
        String text=convertView.getContext().getString(item.text);
        if (item.count > 0) {
          text+=" (" + item.count + ")";
        }
        aq.id(R.id.name).text(text);
      }
 else       if (name != null) {
        aq.id(R.id.tb).background(R.color.ph).image(tb,true,true,0,0,null,AQuery.FADE_IN_NETWORK,1.0f);
        String text=item.name;
        aq.id(R.id.name).text(text);
      }
      return convertView;
    }
  }
;
  OnClickListener ocl=new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      ActionItem item=items.get(which);
      listener.onClick(dialog,item.id);
    }
  }
;
  AlertDialog dia=new AlertDialog.Builder(act).setAdapter(adapter,ocl).create();
  dia.setCanceledOnTouchOutside(true);
  dia.setInverseBackgroundForced(false);
  return dia;
}
 

Example 30

From project sls, under directory /src/com/adam/aslfms/util/.

Source file: Util.java

  17 
vote

public static void deleteScrobbleFromCache(Context ctx,final ScrobblesDatabase db,final NetApp napp,final Cursor cursor,final int id){
  Util.confirmDialog(ctx,ctx.getString(R.string.confirm_delete_sc).replaceAll("%1",napp.getName()),R.string.remove,R.string.cancel,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      Log.d(TAG,"Will remove scrobble from cache: " + napp.getName() + ", "+ id);
      db.deleteScrobble(napp,id);
      db.cleanUpTracks();
      if (cursor != null)       cursor.requery();
    }
  }
);
}
 

Example 31

From project Android, under directory /app/src/main/java/com/github/mobile/accounts/.

Source file: AccountUtils.java

  16 
vote

/** 
 * Show conflict message about previously registered authenticator from another application
 * @param activity
 */
private static void showConflictMessage(final Activity activity){
  AlertDialog dialog=LightAlertDialog.create(activity);
  dialog.setTitle(activity.getString(string.authenticator_conflict_title));
  dialog.setMessage(activity.getString(string.authenticator_conflict_message));
  dialog.setOnCancelListener(new OnCancelListener(){
    @Override public void onCancel(    DialogInterface dialog){
      activity.finish();
    }
  }
);
  dialog.setButton(BUTTON_POSITIVE,activity.getString(android.R.string.ok),new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      activity.finish();
    }
  }
);
  dialog.show();
}
 

Example 32

From project Android-GifStitch, under directory /src/com/phunkosis/gifstitch/dialogs/.

Source file: DialogHelper.java

  16 
vote

public static void showRateDialog(final Context c){
  String title=c.getString(R.string.dialog_rate_app_title);
  String message=c.getString(R.string.dialog_rate_app_message);
  AlertDialog.Builder alertBuilder=new AlertDialog.Builder(c).setIcon(android.R.drawable.btn_star).setMessage(message).setTitle(title).setPositiveButton(c.getString(R.string.heckyeah),new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      GSSettings.setShowRatedDialog(false);
      c.startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=com.phunkosis.gifstitch")));
      dialog.dismiss();
    }
  }
).setNegativeButton(c.getString(R.string.heckno),new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      GSSettings.setShowRatedDialog(false);
    }
  }
);
  alertBuilder.create().show();
}
 

Example 33

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/controller/.

Source file: AbstractController.java

  16 
vote

protected void showDialog(final AlertDialog.Builder builder){
  builder.setCancelable(true);
  builder.setNegativeButton("Close",new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      dialog.cancel();
      mDialogShowing=false;
    }
  }
);
  mActivity.runOnUiThread(new Runnable(){
    public void run(){
      final AlertDialog alert=builder.create();
      try {
        if (!mDialogShowing) {
          alert.show();
          mDialogShowing=true;
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
  }
);
}
 

Example 34

From project android_7, under directory /src/org/immopoly/android/fragments/.

Source file: ItemActivateFragment.java

  16 
vote

@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  mTracker=GoogleAnalyticsTracker.getInstance();
  mTracker.startNewSession(TrackingManager.UA_ACCOUNT,Const.ANALYTICS_INTERVAL,getActivity().getApplicationContext());
  mTracker.trackPageView(TrackingManager.VIEW_ACTION_ITEM_SPY);
  ImmopolyActionItem item=ImmopolyUser.getInstance().getActionItems().get(mItemId);
  return new AlertDialog.Builder(getActivity()).setTitle(item.getText()).setMessage(item.getDescription()).setPositiveButton("Aktivieren",new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      Fragment fragment=getFragmentManager().findFragmentByTag(ImmopolyActivity.FRAGMENT_MAP);
      if (fragment instanceof MapFragment) {
        ((MapFragment)fragment).filterFreeFlats();
      }
    }
  }
).setNegativeButton("Abbrechen",null).create();
}
 

Example 35

From project android_8, under directory /src/com/defuzeme/gui/.

Source file: Gui.java

  16 
vote

public void showSelectClientDialog(final String[] hostnames){
  this._selectedVal=0;
  Gui._builder=new AlertDialog.Builder(this._activity);
  Gui._builder.setTitle(string.SelectHost);
  Gui._builder.setSingleChoiceItems(hostnames,0,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      _selectedVal=which;
    }
  }
);
  Gui._builder.setPositiveButton(android.R.string.ok,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int whichButton){
      String hostNamePref=DefuzeMe.Preferences.get(string.hostName);
      if (hostNamePref != hostnames[_selectedVal]) {
        DefuzeMe.Preferences.delete();
        DefuzeMe.Preferences.save(string.hostName,hostnames[_selectedVal]);
      }
      DefuzeMe.Network.onNetworkComplete(Settings._ConnectClient);
    }
  }
);
  Gui._builder.setNegativeButton(android.R.string.cancel,null);
  Gui._builder.create();
  Gui._builder.show();
}
 

Example 36

From project Anki-Android, under directory /src/com/ichi2/anki/.

Source file: PersonalDeckPicker.java

  16 
vote

/** 
 * Create AlertDialogs used on all the activity
 */
private void initDialogs(){
  Resources res=getResources();
  AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle(res.getString(R.string.connection_error_title));
  builder.setIcon(android.R.drawable.ic_dialog_alert);
  builder.setMessage(res.getString(R.string.connection_needed));
  builder.setPositiveButton(res.getString(R.string.ok),new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      finish();
    }
  }
);
  mNoConnectionAlert=builder.create();
  builder.setTitle(res.getString(R.string.connection_error_title));
  builder.setIcon(android.R.drawable.ic_dialog_alert);
  builder.setMessage(res.getString(R.string.connection_error_return_message));
  builder.setPositiveButton(res.getString(R.string.retry),new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      getPersonalDecks();
    }
  }
);
  builder.setNegativeButton(res.getString(R.string.cancel),new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      PersonalDeckPicker.this.finish();
    }
  }
);
  mConnectionErrorAlert=builder.create();
}
 

Example 37

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/ui/.

Source file: SendBugReportUiActivity.java

  16 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  final AlertDialog dialog=new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher).setTitle(R.string.ime_name).setMessage("Oops, didn't see that coming...").setPositiveButton("Send :)",new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      sendCrashReportViaEmail();
      finish();
    }
  }
).setCancelable(true).setNegativeButton("No",new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      finish();
    }
  }
).create();
  dialog.show();
}
 

Example 38

From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/ui/.

Source file: PreferencesActivity.java

  16 
vote

@Override public boolean onPreferenceTreeClick(final PreferenceScreen preferenceScreen,final Preference preference){
  final String key=preference.getKey();
  if (PREFS_KEY_INITIATE_RESET.equals(key)) {
    final AlertDialog.Builder dialog=new AlertDialog.Builder(this);
    dialog.setTitle(R.string.preferences_initiate_reset_title);
    dialog.setMessage(R.string.preferences_initiate_reset_dialog_message);
    dialog.setPositiveButton(R.string.preferences_initiate_reset_dialog_positive,new OnClickListener(){
      public void onClick(      final DialogInterface dialog,      final int which){
        application.resetBlockchain();
        finish();
      }
    }
);
    dialog.setNegativeButton(R.string.preferences_initiate_reset_dialog_negative,null);
    dialog.show();
    return true;
  }
  return false;
}
 

Example 39

From project callmeter, under directory /src/de/ub0r/android/callmeter/ui/prefs/.

Source file: Preferences.java

  16 
vote

/** 
 * Reset internal Logs.
 */
private void resetDataDialog(){
  AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle(R.string.reset_data_);
  builder.setMessage(R.string.reset_data_hint);
  builder.setCancelable(false);
  builder.setPositiveButton(android.R.string.yes,new OnClickListener(){
    @Override public void onClick(    final DialogInterface dialog,    final int which){
      Preferences.this.resetData(DataProvider.TYPE_CALL);
      Preferences.this.resetData(DataProvider.TYPE_SMS);
      Preferences.this.resetData(DataProvider.TYPE_MMS);
    }
  }
);
  builder.setNeutralButton(R.string.reset_data_data_,new OnClickListener(){
    @Override public void onClick(    final DialogInterface dialog,    final int which){
      Preferences.this.resetData(-1);
    }
  }
);
  builder.setNegativeButton(android.R.string.no,null);
  builder.show();
}
 

Example 40

From project convertcsv, under directory /ConvertCSV/src/org/openintents/convertcsv/common/.

Source file: ConvertCsvBaseActivity.java

  16 
vote

@Override protected Dialog onCreateDialog(int id){
switch (id) {
case DIALOG_ID_WARN_OVERWRITE:
    LayoutInflater inflater=LayoutInflater.from(this);
  View view=inflater.inflate(R.layout.file_exists,null);
final CheckBox cb=(CheckBox)view.findViewById(R.id.dont_ask_again);
return new AlertDialog.Builder(this).setView(view).setPositiveButton(android.R.string.yes,new OnClickListener(){
public void onClick(DialogInterface dialog,int which){
  saveBooleanPreference(PreferenceActivity.PREFS_ASK_IF_FILE_EXISTS,!cb.isChecked());
  finish();
}
}
).setNegativeButton(android.R.string.no,new OnClickListener(){
public void onClick(DialogInterface dialog,int which){
}
}
).create();
case DIALOG_ID_WARN_RESTORE_POLICY:
return new AlertDialog.Builder(this).setTitle(R.string.warn_restore_policy_title).setMessage(R.string.warn_restore_policy).setPositiveButton(android.R.string.yes,new OnClickListener(){
public void onClick(DialogInterface dialog,int which){
startImportPostCheck();
}
}
).setNegativeButton(android.R.string.no,null).create();
case DIALOG_ID_NO_FILE_MANAGER_AVAILABLE:
return new DownloadOIAppDialog(this,DownloadOIAppDialog.OI_FILEMANAGER);
}
return super.onCreateDialog(id);
}
 

Example 41

From project danbooru-gallery-android, under directory /src/tw/idv/palatis/danboorugallery/.

Source file: DanbooruGalleryPreferenceActivity.java

  16 
vote

@Override public void onClick(DialogInterface idialog,int which){
  final AlertDialog dialog=(AlertDialog)idialog;
  final EditText edit_name=(EditText)dialog.findViewById(R.id.preferences_hosts_dialog_hosts_name_input);
  final EditText edit_url=(EditText)dialog.findViewById(R.id.preferences_hosts_dialog_url_input);
  final Spinner api=(Spinner)dialog.findViewById(R.id.preferences_hosts_dialog_api);
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
    if (edit_name.getTag() == null)     newHost(edit_name.getText().toString(),edit_url.getText().toString(),api.getSelectedItem().toString());
 else     editHost((Integer)edit_name.getTag(),edit_name.getText().toString(),edit_url.getText().toString(),api.getSelectedItem().toString());
  break;
case DialogInterface.BUTTON_NEUTRAL:
Builder builder=new AlertDialog.Builder(dialog.getContext());
builder.setTitle(R.string.preferences_hosts_dialog_delete_confirm_title);
Host host=hosts.get((Integer)edit_name.getTag());
builder.setMessage(String.format(getString(R.string.preferences_hosts_dialog_delete_confirm_message),host.name,host.url));
builder.setPositiveButton(android.R.string.ok,new OnClickListener(){
@Override public void onClick(DialogInterface dialog,int which){
deleteHost((Integer)edit_name.getTag());
}
}
);
builder.setNegativeButton(android.R.string.cancel,null);
builder.create().show();
break;
}
}
 

Example 42

From project DiscogsForAndroid, under directory /src/com/discogs/activities/.

Source file: CollectionActivity.java

  16 
vote

/** 
 * Dialogs
 */
protected Dialog onCreateDialog(int id){
  Dialog dialog=null;
switch (id) {
case DIALOG_ADD_FOLDER:
{
      AlertDialog.Builder builder=new AlertDialog.Builder(this);
      builder.setTitle("Folder name");
      final View view=LayoutInflater.from(this).inflate(R.layout.layout_add_folder,null);
      builder.setView(view);
      builder.setPositiveButton("OK",new OnClickListener(){
        @Override public void onClick(        DialogInterface dialog,        int which){
          EditText folderNameEditText=(EditText)view.findViewById(R.id.folderNameEditText);
          String folderName=folderNameEditText.getText().toString();
          if (StringUtils.isNotBlank(folderName)) {
            String resourceUrl="http://api.discogs.com/users/" + userName + "/collection/folders";
            engine.createFolder(resourceUrl,folderName);
          }
        }
      }
);
      builder.setNegativeButton("Cancel",new OnClickListener(){
        @Override public void onClick(        DialogInterface dialog,        int which){
        }
      }
);
      dialog=builder.create();
      break;
    }
default :
{
    dialog=null;
  }
}
return dialog;
}
 

Example 43

From project dmix, under directory /MPDroid/src/com/namelessdev/mpdroid/.

Source file: MPDApplication.java

  16 
vote

public void connectionFailed(String message){
  dismissAlertDialog();
  if (currentActivity == null)   return;
  if (currentActivity != null && connectionLocks.size() > 0) {
    if (currentActivity.getClass() == SettingsActivity.class) {
      AlertDialog.Builder builder=new AlertDialog.Builder(currentActivity);
      builder.setMessage(String.format(getResources().getString(R.string.connectionFailedMessageSetting),message));
      builder.setPositiveButton("OK",new OnClickListener(){
        public void onClick(        DialogInterface arg0,        int arg1){
        }
      }
);
      ad=builder.show();
    }
 else {
      AlertDialog.Builder builder=new AlertDialog.Builder(currentActivity);
      builder.setTitle(getResources().getString(R.string.connectionFailed));
      builder.setMessage(String.format(getResources().getString(R.string.connectionFailedMessage),message));
      DialogClickListener oDialogClickListener=new DialogClickListener();
      builder.setNegativeButton(getResources().getString(R.string.quit),oDialogClickListener);
      builder.setNeutralButton(getResources().getString(R.string.settings),oDialogClickListener);
      builder.setPositiveButton(getResources().getString(R.string.retry),oDialogClickListener);
      try {
        ad=builder.show();
      }
 catch (      BadTokenException e) {
      }
    }
  }
}
 

Example 44

From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.

Source file: FriendicaImgUploadActivity.java

  16 
vote

@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.view_debug:
    Intent callingIntent=getIntent();
  if (callingIntent != null) {
    Bundle e=callingIntent.getExtras();
    String[] val=new String[e.keySet().size()];
    String[] val2=new String[e.keySet().size()];
    int i=0;
    for (    String key : e.keySet()) {
      val[i]=key + ": " + String.valueOf(e.get(key));
      val2[i++]=getTypeName(e.get(key)) + " " + key+ ":\n"+ String.valueOf(e.get(key));
    }
    final String[] values=val2;
    new AlertDialog.Builder(FriendicaImgUploadActivity.this).setItems(val,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        new AlertDialog.Builder(FriendicaImgUploadActivity.this).setMessage(values[which]).show();
      }
    }
).setTitle("Debug Info [File]").show();
  }
return true;
default :
return super.onOptionsItemSelected(item);
}
}
 

Example 45

From project Gaggle, under directory /src/com/geeksville/gaggle/.

Source file: ListWaypointsActivity.java

  16 
vote

/** 
 * Delete all waypoints
 */
private void handleDeleteMenu(){
  AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle(R.string.delete_waypoints);
  builder.setMessage(R.string.are_you_sure);
  builder.setNegativeButton(R.string.cancel,null);
  builder.setPositiveButton(R.string.delete,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      db.deleteAllWaypoints();
      myCursor.requery();
    }
  }
);
  AlertDialog alert=builder.create();
  alert.show();
}
 

Example 46

From project gmarks-android, under directory /src/main/java/org/thomnichols/android/gmarks/.

Source file: WebViewLoginActivity.java

  16 
vote

protected void showTwoFactorAuthDialog(){
  dismissWaitDialog();
  final Intent launchAuthIntent=new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setClassName(AUTHENTICATOR_PACKAGE,"com.google.android.apps.authenticator.AuthenticatorActivity");
  ResolveInfo ri=getPackageManager().resolveActivity(launchAuthIntent,0);
  if (ri == null) {
    WebViewLoginActivity.this.showAuthenticatorMissingDialog();
    return;
  }
  Log.d(TAG,"Resolve info: " + ri);
  new AlertDialog.Builder(this).setTitle(R.string.two_factor_auth_dlg_title).setMessage(Html.fromHtml(getString(R.string.two_factor_auth_dlg_msg))).setCancelable(true).setNegativeButton(R.string.btn_cancel,new OnClickListener(){
    public void onClick(    DialogInterface dlg,    int _){
      dlg.dismiss();
    }
  }
).setPositiveButton(R.string.btn_ok,new OnClickListener(){
    public void onClick(    DialogInterface dlg,    int _){
      try {
        startActivity(launchAuthIntent);
      }
 catch (      ActivityNotFoundException ex) {
        Log.d(TAG,"Activity not found",ex);
        WebViewLoginActivity.this.showAuthenticatorMissingDialog();
      }
    }
  }
).show();
}
 

Example 47

From project gobandroid, under directory /src/org/ligi/gobandroid_hd/ui/gnugo/.

Source file: PlayAgainstGnugoActivity.java

  16 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
  EasyTracker.getTracker().trackEvent("ui_action","gnugo","play",null);
  dlg=new GnuGoSetupDialog(this);
  dlg.setPositiveButton(R.string.ok,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      playing_black=dlg.isBlackActive() | dlg.isBothActive();
      playing_white=dlg.isWhiteActive() | dlg.isBothActive();
      level=(byte)dlg.getStrength();
      dlg.saveRecentAsDefault();
      dialog.dismiss();
    }
  }
);
  dlg.setNegativeButton(R.string.cancel,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      dialog.dismiss();
      finish();
    }
  }
);
  dlg.show();
}
 

Example 48

From project kumvandroid, under directory /src/com/ijuru/kumva/ui/.

Source file: Dialogs.java

  16 
vote

/** 
 * Displays a text input dialog
 * @param context the context
 * @param title the title
 * @param hint the input hint
 * @param inputType the input type
 */
public static void prompt(Context context,String title,String hint,int inputType,final InputListener listener){
  final EditText input=new EditText(context);
  input.setHint(hint);
  input.setInputType(inputType);
  LinearLayout layout=new LinearLayout(context);
  layout.setOrientation(LinearLayout.VERTICAL);
  layout.setPadding(5,0,5,0);
  layout.addView(input);
  new AlertDialog.Builder(context).setTitle(title).setView(layout).setNegativeButton(android.R.string.cancel,null).setPositiveButton(android.R.string.ok,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      listener.entered(input.getText().toString());
    }
  }
).show();
}
 

Example 49

From project LG-Optimus-2X-Black-Notifications, under directory /src/com/martinborjesson/o2xtouchlednotifications/ui/.

Source file: MainPreferences.java

  16 
vote

/** 
 * If the app is not enabled in the accessibility settings, popup an alert and return false, otherwise show nothing and return true
 * @return
 */
private boolean askIfNotEnabledInAccessibilitySettings(int message){
  if (!enabledInAccessibilitySettings()) {
    AlertDialog.Builder builder=new AlertDialog.Builder(this);
    builder.setMessage(message).setCancelable(false).setPositiveButton(android.R.string.yes,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        startActivityForResult(new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS),0);
      }
    }
).setNegativeButton(android.R.string.no,new OnClickListener(){
      public void onClick(      DialogInterface dialog,      int id){
        dialog.cancel();
      }
    }
);
    Dialog enableAccessibilityDialog=builder.create();
    enableAccessibilityDialog.show();
    return false;
  }
  return true;
}
 

Example 50

From project mythmote, under directory /src/tkj/android/homecontrol/mythmote/db/.

Source file: MythMoteDbManager.java

  16 
vote

/** 
 * Return a Cursor positioned at the note that matches the given rowId
 * @param rowId id of note to retrieve
 * @return Cursor positioned to matching note, if found
 */
public Cursor fetchFrontendLocation(long rowId){
  Cursor mCursor=null;
  try {
    mCursor=db.query(true,FRONTEND_TABLE,new String[]{KEY_ROWID,KEY_NAME,KEY_ADDRESS,KEY_PORT},KEY_ROWID + "=" + rowId,null,null,null,null,null);
    if (mCursor != null) {
      mCursor.moveToFirst();
    }
  }
 catch (  SQLException e) {
    AlertDialog.Builder builder=new AlertDialog.Builder(context);
    builder.setTitle("DataBase Error");
    builder.setMessage(e.getLocalizedMessage());
    builder.setNeutralButton(R.string.ok_str,new OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
      }
    }
);
  }
  return mCursor;
}
 

Example 51

From project npr-android-app, under directory /src/org/npr/android/news/.

Source file: PodcastActivity.java

  16 
vote

@Override public void handleMessage(Message msg){
  if (podcast != null) {
    ArrayAdapter<Item> adapter=new ArrayAdapter<Item>(PodcastActivity.this,android.R.layout.simple_list_item_2,android.R.id.text1,podcast.getItems()){
      @Override public View getView(      int position,      View convertView,      ViewGroup parent){
        View v=super.getView(position,convertView,parent);
        Item i=getItem(position);
        TextView tv=(TextView)v.findViewById(android.R.id.text2);
        tv.setText(i.getPubDate());
        return v;
      }
    }
;
    progressBar.setVisibility(View.GONE);
    listView.setAdapter(adapter);
    if (podcast.getSummary() != null) {
      miscText.setText(podcast.getSummary());
      miscText.setVisibility(View.VISIBLE);
    }
  }
 else {
    final AlertDialog.Builder builder=new AlertDialog.Builder(PodcastActivity.this);
    builder.setTitle(R.string.msg_error);
    builder.setMessage(R.string.msg_parse_error);
    builder.setNeutralButton(R.string.msg_ok,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        PodcastActivity.this.finish();
      }
    }
);
    builder.create().show();
  }
}
 

Example 52

From project OpenBike, under directory /src/fr/openbike/android/utils/.

Source file: ActivityHelper.java

  16 
vote

public Dialog onCreateDialog(int id){
  if (id == R.id.json_error || id == R.id.database_error || id == R.id.network_error || id == R.id.message) {
    return new AlertDialog.Builder(mActivity).setCancelable(false).setPositiveButton(R.string.Ok,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int id){
        dialog.cancel();
      }
    }
).setTitle(R.string.network_error).setMessage(R.string.network_error_summary).create();
  }
 else   if (id == R.id.no_location_provider || id == R.id.enable_gps) {
    return new AlertDialog.Builder(mActivity).setCancelable(false).setPositiveButton(R.string.yes,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int id){
        Intent gpsOptionsIntent=new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        mActivity.startActivity(gpsOptionsIntent);
      }
    }
).setNegativeButton(R.string.no,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int id){
        dialog.cancel();
      }
    }
).setTitle(R.string.gps_disabled).setMessage(R.string.location_disabled).create();
  }
 else   if (id == R.id.stations_update) {
    mProgressDialog=new ProgressDialog(mActivity);
    return mProgressDialog;
  }
 else {
    return null;
  }
}
 

Example 53

From project Pixelesque, under directory /src/com/rj/pixelesque/.

Source file: Dialogs.java

  16 
vote

public static void showExport(final PixelArtEditor p){
  Log.d("PixelArt","alertz showexport");
  int[] origxy={p.art.width,p.art.height};
  int[] lowxy=getResize(p.art.width,p.art.height,PixelArtEditor.EXPORT_SMALL_LONGSIDE);
  int[] medxy=getResize(p.art.width,p.art.height,PixelArtEditor.EXPORT_MEDIUM_LONGSIDE);
  int[] highxy=getResize(p.art.width,p.art.height,PixelArtEditor.EXPORT_LARGE_LONGSIDE);
  final String[] qualities={String.format(p.getResources().getString(R.string.export_size_original),origxy[0],origxy[1]),String.format(p.getResources().getString(R.string.export_size_low),lowxy[0],lowxy[1]),String.format(p.getResources().getString(R.string.export_size_medium),medxy[0],medxy[1]),String.format(p.getResources().getString(R.string.export_size_high),highxy[0],highxy[1])};
  AlertDialog.Builder builder=new AlertDialog.Builder(p);
  builder.setTitle(R.string.export_title);
  builder.setItems(qualities,new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      if (which == 0)       p.export(PixelArtEditor.EXPORT_ORIGINAL,"original");
 else       if (which == 1)       p.export(PixelArtEditor.EXPORT_SMALL_LONGSIDE,"small");
 else       if (which == 2)       p.export(PixelArtEditor.EXPORT_MEDIUM_LONGSIDE,"medium");
 else       p.export(PixelArtEditor.EXPORT_LARGE_LONGSIDE,"large");
    }
  }
);
  builder.setPositiveButton(R.string.export_button_other,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      showExportCustom(p);
    }
  }
);
  builder.setNegativeButton(R.string.export_button_cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      dialog.dismiss();
    }
  }
);
  AlertDialog alert=builder.create();
  alert.show();
  Log.d("PixelArt","alertz shownew");
}
 

Example 54

From project platform_packages_apps_browser, under directory /src/com/android/browser/preferences/.

Source file: GeneralPreferencesFragment.java

  16 
vote

void promptForHomepage(final ListPreference pref){
  final BrowserSettings settings=BrowserSettings.getInstance();
  final EditText editText=new EditText(getActivity());
  editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
  editText.setText(settings.getHomePage());
  editText.setSelectAllOnFocus(true);
  editText.setSingleLine(true);
  editText.setImeActionLabel(null,EditorInfo.IME_ACTION_DONE);
  final AlertDialog dialog=new AlertDialog.Builder(getActivity()).setView(editText).setPositiveButton(android.R.string.ok,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      String homepage=editText.getText().toString().trim();
      homepage=UrlUtils.smartUrlFilter(homepage);
      settings.setHomePage(homepage);
      pref.setValue(getHomepageValue());
      pref.setSummary(getHomepageSummary());
    }
  }
).setNegativeButton(android.R.string.cancel,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      dialog.cancel();
    }
  }
).setTitle(R.string.pref_set_homepage_to).create();
  editText.setOnEditorActionListener(new OnEditorActionListener(){
    @Override public boolean onEditorAction(    TextView v,    int actionId,    KeyEvent event){
      if (actionId == EditorInfo.IME_ACTION_DONE) {
        dialog.getButton(AlertDialog.BUTTON_POSITIVE).performClick();
        return true;
      }
      return false;
    }
  }
);
  dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
  dialog.show();
}
 

Example 55

From project platform_packages_apps_mms, under directory /src/com/android/mms/ui/.

Source file: ManageSimMessages.java

  16 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterView.AdapterContextMenuInfo info;
  try {
    info=(AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
  }
 catch (  ClassCastException exception) {
    Log.e(TAG,"Bad menuInfo.",exception);
    return false;
  }
  final Cursor cursor=(Cursor)mListAdapter.getItem(info.position);
switch (item.getItemId()) {
case MENU_COPY_TO_PHONE_MEMORY:
    copyToPhoneMemory(cursor);
  return true;
case MENU_DELETE_FROM_SIM:
confirmDeleteDialog(new OnClickListener(){
  public void onClick(  DialogInterface dialog,  int which){
    updateState(SHOW_BUSY);
    deleteFromSim(cursor);
    dialog.dismiss();
  }
}
,R.string.confirm_delete_SIM_message);
return true;
case MENU_VIEW:
viewMessage(cursor);
return true;
}
return super.onContextItemSelected(item);
}
 

Example 56

From project platform_packages_apps_settings, under directory /src/com/android/settings/.

Source file: DevelopmentSettings.java

  16 
vote

@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  final Context context=getActivity();
  final AlertDialog.Builder builder=new AlertDialog.Builder(context);
  builder.setTitle(R.string.enforce_read_external_confirm_title);
  builder.setMessage(R.string.enforce_read_external_confirm_message);
  builder.setPositiveButton(android.R.string.ok,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      setPermissionEnforced(context,READ_EXTERNAL_STORAGE,true);
      ((DevelopmentSettings)getTargetFragment()).updateAllOptions();
    }
  }
);
  builder.setNegativeButton(android.R.string.cancel,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      ((DevelopmentSettings)getTargetFragment()).updateAllOptions();
    }
  }
);
  return builder.create();
}
 

Example 57

From project QuotaForAndroid, under directory /Quota/src/com/southfreo/quota/control/.

Source file: UIManager.java

  16 
vote

public void showWelcomeMessage(boolean force,final Context c){
  final SharedPreferences preferences=SlotManager.getInstance().preferences;
  final String current=getVersion(c);
  String version=preferences.getString("version","");
  Locale here=Locale.getDefault();
  boolean canada=here == Locale.CANADA || here == Locale.CANADA_FRENCH;
  if (canada && (!version.equals(current) || force)) {
    MsgBoxInfo(c,"Canada Notice","Canadian Providers can be enabled by tapping \"i\" then Load QuotaXML pack canada.zip");
  }
  if (!version.equals(current) || force) {
    AlertDialog dialog=new AlertDialog.Builder(c).create();
    dialog.setIcon(R.drawable.icon);
    dialog.setTitle(AppName() + " for Android\n" + getVersion(c));
    String welcome_msg=null;
    if (this.isUnlocked) {
      welcome_msg=c.getString(R.string.welcomemsg_full);
    }
 else {
      welcome_msg=c.getString(R.string.welcomemsg_lite);
    }
    dialog.setMessage(welcome_msg + "\n\n" + c.getString(R.string.release_notes));
    dialog.setButton2(c.getString(R.string.close),new OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        preferences.edit().putString("version",current).commit();
      }
    }
);
    dialog.setButton(c.getString(R.string.website),new OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        openWebsite(c,c.getString(R.string.support_site));
      }
    }
);
    dialog.show();
  }
}
 

Example 58

From project RA_Launcher, under directory /src/com/android/ra/launcher/settings/.

Source file: LauncherActionPreference.java

  16 
vote

@Override protected void onClick(){
  AlertDialog.Builder builder=new Builder(getContext());
  builder.setTitle(this.getTitle());
  final ListAdapter adapter=LauncherActions.getInstance().getSelectActionAdapter();
  builder.setAdapter(adapter,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      Action act=(Action)adapter.getItem(which);
      Intent intent=LauncherActions.getInstance().getIntentForAction(act);
      String sIntent=intent.toUri(0).toString();
      persistString(sIntent);
    }
  }
);
  builder.create().show();
}
 

Example 59

From project Sage-Mobile-Calc, under directory /src/org/connectbot/.

Source file: PubkeyListActivity.java

  16 
vote

/** 
 */
private void pickFileSimple(){
  final File sdcard=Environment.getExternalStorageDirectory();
  Log.d(TAG,sdcard.toString());
  final String state=Environment.getExternalStorageState();
  if (!Environment.MEDIA_MOUNTED_READ_ONLY.equals(state) && !Environment.MEDIA_MOUNTED.equals(state)) {
    new AlertDialog.Builder(PubkeyListActivity.this).setMessage(R.string.alert_sdcard_absent).setNegativeButton(android.R.string.cancel,null).create().show();
    return;
  }
  List<String> names=new LinkedList<String>();
{
    File[] files=sdcard.listFiles();
    if (files != null) {
      for (      File file : sdcard.listFiles()) {
        if (file.isDirectory())         continue;
        names.add(file.getName());
      }
    }
  }
  Collections.sort(names);
  final String[] namesList=names.toArray(new String[]{});
  Log.d(TAG,names.toString());
  new AlertDialog.Builder(PubkeyListActivity.this).setTitle(R.string.pubkey_list_pick).setItems(namesList,new OnClickListener(){
    public void onClick(    DialogInterface arg0,    int arg1){
      String name=namesList[arg1];
      readKeyFromFile(new File(sdcard,name));
    }
  }
).setNegativeButton(android.R.string.cancel,null).create().show();
}
 

Example 60

From project SeriesGuide, under directory /SeriesGuide/src/com/battlelancer/seriesguide/ui/dialogs/.

Source file: ConfirmDeleteDialogFragment.java

  16 
vote

@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  final String showId=getArguments().getString("showid");
  final Cursor show=getActivity().getContentResolver().query(Shows.buildShowUri(showId),new String[]{Shows.TITLE},null,null,null);
  String showName=getString(R.string.unknown);
  if (show != null && show.moveToFirst()) {
    showName=show.getString(0);
  }
  show.close();
  return new AlertDialog.Builder(getActivity()).setMessage(getString(R.string.confirm_delete,showName)).setPositiveButton(getString(R.string.delete_show),new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      final ProgressDialog progress=new ProgressDialog(getActivity());
      progress.setCancelable(false);
      progress.show();
      new Thread(new Runnable(){
        public void run(){
          DBUtils.deleteShow(getActivity(),getArguments().getString("showid"),progress);
        }
      }
).start();
    }
  }
).setNegativeButton(getString(R.string.dontdelete_show),null).create();
}
 

Example 61

From project Sketchy-Truck, under directory /andengine/src/org/anddev/andengine/ui/dialog/.

Source file: GenericInputDialogBuilder.java

  16 
vote

public Dialog create(){
  final EditText etInput=new EditText(this.mContext);
  etInput.setText(this.mDefaultText);
  final AlertDialog.Builder ab=new AlertDialog.Builder(this.mContext);
  if (this.mTitleResID != 0) {
    ab.setTitle(this.mTitleResID);
  }
  if (this.mMessageResID != 0) {
    ab.setMessage(this.mMessageResID);
  }
  if (this.mIconResID != 0) {
    ab.setIcon(this.mIconResID);
  }
  this.setView(ab,etInput);
  ab.setOnCancelListener(this.mOnCancelListener).setPositiveButton(android.R.string.ok,new OnClickListener(){
    @Override public void onClick(    final DialogInterface pDialog,    final int pWhich){
      final T result;
      try {
        result=GenericInputDialogBuilder.this.generateResult(etInput.getText().toString());
      }
 catch (      final IllegalArgumentException e) {
        Debug.e("Error in GenericInputDialogBuilder.generateResult()",e);
        Toast.makeText(GenericInputDialogBuilder.this.mContext,GenericInputDialogBuilder.this.mErrorResID,Toast.LENGTH_SHORT).show();
        return;
      }
      GenericInputDialogBuilder.this.mSuccessCallback.onCallback(result);
      pDialog.dismiss();
    }
  }
).setNegativeButton(android.R.string.cancel,new OnClickListener(){
    @Override public void onClick(    final DialogInterface pDialog,    final int pWhich){
      GenericInputDialogBuilder.this.mOnCancelListener.onCancel(pDialog);
      pDialog.dismiss();
    }
  }
);
  return ab.create();
}
 

Example 62

From project android_5, under directory /src/aarddict/android/.

Source file: ArticleViewActivity.java

  15 
vote

private void showError(final String message){
  runOnUiThread(new Runnable(){
    public void run(){
      currentTask=null;
      setProgress(10000);
      resetTitleToCurrent();
      AlertDialog.Builder dialogBuilder=new AlertDialog.Builder(ArticleViewActivity.this);
      dialogBuilder.setTitle(R.string.titleError).setMessage(message).setNeutralButton(R.string.btnDismiss,new OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          dialog.dismiss();
          if (backItems.isEmpty()) {
            finish();
          }
        }
      }
);
      dialogBuilder.show();
    }
  }
);
}
 

Example 63

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/widget/.

Source file: AncientNumberPickerDialog.java

  15 
vote

/** 
 * @param context Parent.
 * @param theme the theme to apply to this dialog
 * @param callBack How parent is notified.
 * @param number The initial number.
 */
public AncientNumberPickerDialog(Context context,int theme,OnNumberSetListener callBack,int number,int rangeMin,int rangeMax,int title,int units){
  super(context,theme);
  mCallback=callBack;
  setTitle(title);
  setButton(DialogInterface.BUTTON_POSITIVE,context.getText(R.string.set),this);
  setButton(DialogInterface.BUTTON_NEGATIVE,context.getText(R.string.cancel),(OnClickListener)null);
  LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(R.layout.ancient_number_picker_dialog,null);
  setView(view);
  mNumberPicker=(AncientNumberPicker)view.findViewById(R.id.number_picker);
  if (units != 0) {
    TextView unit=(TextView)view.findViewById(R.id.unit);
    unit.setText(units);
    unit.setVisibility(View.VISIBLE);
  }
  mNumberPicker.setRange(rangeMin,rangeMax);
  mNumberPicker.setCurrent(number);
  mNumberPicker.setSpeed(150);
}
 

Example 64

From project CalendarView_1, under directory /src/org/kazzz/view/dialog/.

Source file: TimePickerDialogEx.java

  15 
vote

/** 
 * ??????????
 * @param context ?????????(?????ctivity???)
 * @param callBack ???????????????????????????????
 * @param hourOfDay ??????????????
 * @param minute ?????????????
 */
public TimePickerDialogEx(Context context,OnTimeSetListener callBack,int hourOfDay,int minute){
  super(context);
  this.callback=callBack;
  this.initialHourOfDay=hourOfDay;
  this.initialMinute=minute;
  this.dateFormat=DateFormat.getTimeFormat(context);
  this.calendar=Calendar.getInstance();
  this.updateTitle(this.initialHourOfDay,this.initialMinute);
  this.setButton(context.getText(R.string.button_set),this);
  this.setButton2(context.getText(R.string.button_cancel),(OnClickListener)null);
  this.setIcon(R.drawable.ic_dialog_time);
  LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(R.layout.time_picker_dialog,null);
  this.setView(view);
  this.timePicker=(TimePickerEx)view.findViewById(R.id.timePicker);
  this.timePicker.setCurrentHour(this.initialHourOfDay);
  this.timePicker.setCurrentMinute(this.initialMinute);
  this.timePicker.setOnTimeChangedListener(this);
}
 

Example 65

From project danbo, under directory /src/us/donmai/danbooru/danbo/activity/.

Source file: HomeActivity.java

  15 
vote

private boolean checkPhoneStatus(){
  NetworkState ns=new NetworkState(this);
  if (!ns.connectionAvailable()) {
    Log.d("danbo","No connection available");
    AlertDialog.Builder alertBuilder=new AlertDialog.Builder(this);
    alertBuilder.setMessage(R.string.error_no_connection_available);
    alertBuilder.setNegativeButton(R.string.button_exit,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface arg0,      int arg1){
        HomeActivity.this.finish();
      }
    }
);
    AlertDialog networkAlert=alertBuilder.create();
    networkAlert.show();
    return false;
  }
  String state=Environment.getExternalStorageState();
  if (!(Environment.MEDIA_MOUNTED.equals(state))) {
    AlertDialog.Builder alertBuilder=new AlertDialog.Builder(this);
    alertBuilder.setMessage(R.string.error_sd_not_available);
    alertBuilder.setNegativeButton(R.string.button_exit,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface arg0,      int arg1){
        HomeActivity.this.finish();
      }
    }
);
    AlertDialog alert=alertBuilder.create();
    alert.show();
    return false;
  }
  return true;
}
 

Example 66

From project dreamDroid, under directory /libraries/numberpicker/src/com/michaelnovakjr/numberpicker/.

Source file: NumberPickerDialog.java

  15 
vote

public NumberPickerDialog(Context context,int theme,int initialValue){
  super(context,theme);
  mInitialValue=initialValue;
  setButton(BUTTON_POSITIVE,context.getString(R.string.dialog_set_number),this);
  setButton(BUTTON_NEGATIVE,context.getString(R.string.dialog_cancel),(OnClickListener)null);
  LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(R.layout.dialog_number_picker,null);
  setView(view);
  mNumberPicker=(NumberPicker)view.findViewById(R.id.num_picker);
  mNumberPicker.setCurrent(mInitialValue);
}
 

Example 67

From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/actions/.

Source file: ShareTrack.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.sharedialog);
  mTrackUri=getIntent().getData();
  calculator=new StatisticsCalulator(this,new UnitsI18n(this,null));
  mFileNameView=(EditText)findViewById(R.id.fileNameField);
  mTweetView=(EditText)findViewById(R.id.tweetField);
  mShareTypeSpinner=(Spinner)findViewById(R.id.shareTypeSpinner);
  ArrayAdapter<CharSequence> shareTypeAdapter=ArrayAdapter.createFromResource(this,R.array.sharetype_choices,android.R.layout.simple_spinner_item);
  shareTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  mShareTypeSpinner.setAdapter(shareTypeAdapter);
  mShareTargetSpinner=(Spinner)findViewById(R.id.shareTargetSpinner);
  mShareTypeSpinner.setOnItemSelectedListener(new OnItemSelectedListener(){
    public void onItemSelected(    AdapterView<?> arg0,    View arg1,    int position,    long arg3){
      adjustTargetToType(position);
    }
    public void onNothingSelected(    AdapterView<?> arg0){
    }
  }
);
  int lastType=PreferenceManager.getDefaultSharedPreferences(this).getInt(Constants.EXPORT_TYPE,EXPORT_TYPE_KMZ);
  mShareTypeSpinner.setSelection(lastType);
  adjustTargetToType(lastType);
  mFileNameView.setText(queryForTrackName());
  Button okay=(Button)findViewById(R.id.okayshare_button);
  okay.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      share();
    }
  }
);
  Button cancel=(Button)findViewById(R.id.cancelshare_button);
  cancel.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      ShareTrack.this.finish();
    }
  }
);
}
 

Example 68

From project Hackful-Europe-Reader, under directory /src/com/nineducks/hereader/.

Source file: HackfulReaderActivity.java

  15 
vote

@Override protected Dialog onCreateDialog(int id){
  Dialog result=null;
  AlertDialog.Builder builder=null;
switch (id) {
case R.id.open_dialog:
    builder=new AlertDialog.Builder(this);
  builder.setTitle(R.string.open_dialog_title);
builder.setItems(R.array.open_dialog_options,(OnClickListener)itemsController);
builder.setCancelable(true);
result=builder.create();
break;
case R.id.about_dialog:
builder=new AlertDialog.Builder(this);
builder.setTitle(R.string.about_dialog_title);
ScrollView scroll=new ScrollView(this);
TextView msg=new TextView(this);
SpannableString s=new SpannableString(getString(R.string.about_dialog_text));
Linkify.addLinks(s,Linkify.WEB_URLS);
msg.setText(s);
msg.setMovementMethod(LinkMovementMethod.getInstance());
msg.setTextSize(16);
msg.setPadding(15,15,15,15);
scroll.addView(msg);
builder.setView(scroll);
builder.setInverseBackgroundForced(true);
result=builder.create();
break;
}
return result;
}
 

Example 69

From project MicDroid, under directory /src/com/intervigil/micdroid/helper/.

Source file: DialogHelper.java

  15 
vote

public static void showWarning(Context context,int titleId,int warningId){
  Builder warningBuilder=new AlertDialog.Builder(context);
  warningBuilder.setMessage(context.getString(warningId)).setTitle(context.getString(titleId)).setCancelable(false).setPositiveButton("Ok",new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      dialog.dismiss();
    }
  }
);
  warningBuilder.create().show();
}
 

Example 70

From project motelib, under directory /src/com/cafbit/motelib/settings/.

Source file: SettingsActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  MoteContext moteContext=MoteContext.getInstance(this);
  addPreferencesFromResource(moteContext.getSettingsXmlResource());
  Preference devicesPref=(Preference)findPreference("devicesPref");
  devicesPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      Intent intent=new Intent(SettingsActivity.this,DevicesActivity.class);
      startActivity(intent);
      return true;
    }
  }
);
  Preference resetPref=(Preference)findPreference("resetPref");
  resetPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      AlertDialog.Builder builder=new AlertDialog.Builder(SettingsActivity.this);
      builder.setPositiveButton("OK",new OnClickListener(){
        @Override public void onClick(        DialogInterface dialog,        int which){
          MoteContext moteContext=MoteContext.getInstance(SettingsActivity.this);
          moteContext.coldReset();
          Toast.makeText(getBaseContext(),"Resetting to factory defaults...",Toast.LENGTH_LONG).show();
          SettingsActivity.this.finish();
        }
      }
);
      builder.setNegativeButton("Cancel",null);
      AlertDialog alertDialog=builder.create();
      alertDialog.setTitle("Are you sure?");
      alertDialog.setMessage("Are you sure you want to erase all configured devices, components, and other settings?");
      alertDialog.show();
      return true;
    }
  }
);
}
 

Example 71

From project NotePad, under directory /NotePad/src/org/openintents/notepad/dialog/.

Source file: DeleteConfirmationDialog.java

  15 
vote

public DeleteConfirmationDialog(Context context,OnClickListener onClickListener){
  super(context);
  setIcon(android.R.drawable.ic_dialog_alert);
  setTitle(R.string.confirm_delete_title);
  setMessage(R.string.confirm_delete);
  setPositiveButton(R.string.ok,onClickListener);
  setNegativeButton(R.string.cancel,null);
}
 

Example 72

From project Notes, under directory /src/net/micode/notes/ui/.

Source file: DateTimePickerDialog.java

  15 
vote

public DateTimePickerDialog(Context context,long date){
  super(context);
  mDateTimePicker=new DateTimePicker(context);
  setView(mDateTimePicker);
  mDateTimePicker.setOnDateTimeChangedListener(new OnDateTimeChangedListener(){
    public void onDateTimeChanged(    DateTimePicker view,    int year,    int month,    int dayOfMonth,    int hourOfDay,    int minute){
      mDate.set(Calendar.YEAR,year);
      mDate.set(Calendar.MONTH,month);
      mDate.set(Calendar.DAY_OF_MONTH,dayOfMonth);
      mDate.set(Calendar.HOUR_OF_DAY,hourOfDay);
      mDate.set(Calendar.MINUTE,minute);
      updateTitle(mDate.getTimeInMillis());
    }
  }
);
  mDate.setTimeInMillis(date);
  mDate.set(Calendar.SECOND,0);
  mDateTimePicker.setCurrentDate(mDate.getTimeInMillis());
  setButton(context.getString(R.string.datetime_dialog_ok),this);
  setButton2(context.getString(R.string.datetime_dialog_cancel),(OnClickListener)null);
  set24HourView(DateFormat.is24HourFormat(this.getContext()));
  updateTitle(mDate.getTimeInMillis());
}
 

Example 73

From project packages_apps_FileManager, under directory /src/org/openintents/filemanager/.

Source file: FileManagerActivity.java

  15 
vote

private void onCreateDirectoryInput(){
  mDirectoryInput=(LinearLayout)findViewById(R.id.directory_input);
  mEditDirectory=(EditText)findViewById(R.id.directory_text);
  mButtonDirectoryPick=(ImageButton)findViewById(R.id.button_directory_pick);
  mButtonDirectoryPick.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View arg0){
      goToDirectoryInEditText();
    }
  }
);
}
 

Example 74

From project packages_apps_God_Mode, under directory /src/com/t3hh4xx0r/god_mode/utils/.

Source file: NumberPickerDialog.java

  15 
vote

public NumberPickerDialog(Context context,int theme,int initialValue){
  super(context,theme);
  mInitialValue=initialValue;
  setButton(BUTTON_POSITIVE,context.getString(R.string.dialog_set_number),this);
  setButton(BUTTON_NEGATIVE,context.getString(R.string.dialog_cancel),(OnClickListener)null);
  LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(R.layout.number_picker_pref,null);
  setView(view);
  mNumberPicker=(NumberPicker)view.findViewById(R.id.pref_num_picker);
  mNumberPicker.setCurrent(mInitialValue);
}
 

Example 75

From project platform_packages_apps_VideoEditor, under directory /src/com/android/videoeditor/.

Source file: AlertDialogs.java

  15 
vote

/** 
 * Creates an alert dialog box.
 * @param context The context
 * @param title The title string
 * @param iconId The icon id
 * @param content The content string
 * @param positive The positive button text
 * @param positiveListener The positive listener
 * @param negative The negative button text
 * @param negativeListener The negative listener
 * @param cancelListener The cancel listener
 * @param cancelable true if cancelable
 */
public static AlertDialog createAlert(Context context,String title,int iconId,String content,String positive,OnClickListener positiveListener,String negative,OnClickListener negativeListener,OnCancelListener cancelListener,boolean cancelable){
  final AlertDialog.Builder builder=new AlertDialog.Builder(context);
  builder.setTitle(title);
  if (iconId != 0) {
    builder.setIcon(context.getResources().getDrawable(iconId));
  }
  builder.setMessage(content);
  builder.setPositiveButton(positive,positiveListener);
  builder.setNegativeButton(negative,negativeListener);
  builder.setOnCancelListener(cancelListener);
  builder.setCancelable(cancelable);
  final AlertDialog dialog=builder.create();
  dialog.setCanceledOnTouchOutside(true);
  return dialog;
}
 

Example 76

From project rozkladpkp-android, under directory /src/org/tyszecki/rozkladpkp/widgets/.

Source file: ExtendedTimePicker.java

  15 
vote

protected ExtendedTimePicker(Context context,OnExtendedTimeChanged callBack,int hourOfDay,int minute,boolean arrival){
  super(context,R.style.AboutDialog);
  callback=callBack;
  initialHourOfDay=hourOfDay;
  initialMinute=minute;
  dateFormat=DateFormat.getTimeFormat(context);
  calendar=Calendar.getInstance();
  updateTitle(initialHourOfDay,initialMinute);
  setButton("Ustaw",this);
  setButton2("Anuluj",(OnClickListener)null);
  View view=View.inflate(new ContextThemeWrapper(context,R.style.AboutDialog),R.layout.extended_time_picker_dialog,null);
  setView(view);
  picker=(TimePicker)view.findViewById(R.id.timePicker);
  checkbox=(CheckBox)view.findViewById(R.id.arrivalCheckbox);
  checkbox.setChecked(arrival);
  picker.setCurrentHour(initialHourOfDay);
  picker.setCurrentMinute(initialMinute);
  picker.setIs24HourView(true);
  picker.setOnTimeChangedListener(this);
}
 

Example 77

From project safe, under directory /Safe/src/org/openintents/safe/dialog/.

Source file: AllowExternalAccessDialog.java

  15 
vote

public AllowExternalAccessDialog(Context context){
  super(context);
  mContext=context;
  setTitle(context.getText(R.string.dialog_title_external_access));
  setButton(BUTTON_POSITIVE,context.getText(android.R.string.ok),this);
  setButton(BUTTON_NEGATIVE,context.getText(android.R.string.cancel),(OnClickListener)null);
  setIcon(android.R.drawable.ic_dialog_alert);
  LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(R.layout.dialog_allow_access,null);
  setView(view);
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(mContext);
  boolean externalAccess=sp.getBoolean(Preferences.PREFERENCE_ALLOW_EXTERNAL_ACCESS,false);
  mCheckBox=(CheckBox)view.findViewById(R.id.checkbox);
  mCheckBox.setChecked(externalAccess);
}