Java Code Examples for android.content.DialogInterface

The following are top voted examples for showing how to use android.content.DialogInterface. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: JavaIsFun   File: OQueEJava6.java   View source code 7 votes vote down vote up
public void imageDialog2(View view){
    AlertDialog.Builder builder;

    builder = new AlertDialog.Builder(this);

    ImageView imageView = new ImageView(this);

    imageView.setImageResource(R.drawable.step2);
    builder.setTitle("Clique em 'Novo projeto'...")
            .setView(imageView)
            .setNegativeButton("Voltar", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            })
            .show();
}
 
Example 2
Project: DailyStudy   File: GetuiSdkDemoActivity.java   View source code 6 votes vote down vote up
private void bindAlias() {
    final EditText editText = new EditText(GetuiSdkDemoActivity.this);
    new AlertDialog.Builder(GetuiSdkDemoActivity.this).setTitle(R.string.bind_alias).setView(editText)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (editText.getEditableText() != null) {
                        String alias = editText.getEditableText().toString();
                        if (alias.length() > 0) {
                            PushManager.getInstance().bindAlias(GetuiSdkDemoActivity.this, alias);
                            Log.d(TAG, "bind alias = " + editText.getEditableText().toString());
                        }
                    }
                }
            }).setNegativeButton(android.R.string.cancel, null).show();
}
 
Example 3
Project: sonicky   File: MessageDialogFragment.java   View source code 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    return new AlertDialog.Builder(getContext())
            .setMessage(getArguments().getString(ARG_MESSAGE))
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ((Listener) getActivity()).onMessageDialogDismissed();
                }
            })
            .setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    ((Listener) getActivity()).onMessageDialogDismissed();
                }
            })
            .create();
}
 
Example 4
Project: QRCodeScanner   File: DialogUtil.java   View source code 6 votes vote down vote up
public static final Dialog createCameraAlertDialog(final Context context, int titleId, int messageId, int posiBtntextId){
    CustomDialog r = new CustomDialog(context);
    r.setTitle(titleId);
    r.setMessage(messageId);
    DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    dialog.cancel();
                    break;
            }
        }
    };
    r.setPositiveButton(posiBtntextId, onClickListener);
    r.setCancelable(false);
    return r;
}
 
Example 5
Project: ScreenRecordCaptureMaster   File: RecordScreenDialog.java   View source code 6 votes vote down vote up
private void initData() {
    File parent = new File(TextUtils.isEmpty(mFilePath) ? Environment.getExternalStorageDirectory() + File.separator
            + Environment.DIRECTORY_DCIM + File.separator + "weibo" : mFilePath);
    if (!parent.exists()) {
        parent.mkdirs();
    }

    mFile = new File(parent.getAbsolutePath() + File.separator + "weibo" + new Date().getTime()
            + ".mp4");
    mTotalController = TotalController.getInstance();
    mTotalController.initEncodeThread();
    setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
            return true;
        }
    });
}
 
Example 6
Project: LibVNCAndroid   File: ActivityTabs.java   View source code 6 votes vote down vote up
/**
 * @brief Shows the dialog to indicate about info
 * @return The new dialog
 * @details Shows the dialog to indicate about info
 */
private Dialog createAboutDialog()
 {
	//necesario para poder clicar en los links
	final TextView message = new TextView(this);
	final SpannableString s = 
               new SpannableString(this.getText(R.string.about_message));
  Linkify.addLinks(s, Linkify.WEB_URLS);
  message.setText(s);
  message.setMovementMethod(LinkMovementMethod.getInstance());
  
  return new AlertDialog.Builder(this)
  .setTitle(R.string.about_title)
  .setView(message)
  .setPositiveButton(R.string.about_ok,
   new DialogInterface.OnClickListener() {
    
    @Override
    public void onClick(DialogInterface dialog, int which) {
     // Auto-generated method stub
     
    }
   }
    )
  .show();
 }
 
Example 7
Project: KUtils   File: Buildable.java   View source code 6 votes vote down vote up
protected BuildBean buildSingleChoose(final BuildBean bean) {
    AlertDialog.Builder builder = new AlertDialog.Builder(bean.mContext);
    singleChosen = bean.defaultChosen;
    builder.setTitle(bean.title)
            .setSingleChoiceItems(bean.wordsMd, bean.defaultChosen, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    singleChosen = i;
                    if (bean.itemListener != null) {
                        bean.itemListener.onItemClick(bean.wordsMd[i], i);
                    }

                    if (bean.listener == null) {
                        DialogUIUtils.dismiss(dialogInterface);
                    }

                }
            });

    AlertDialog dialog = builder.create();
    bean.alertDialog = dialog;
    return bean;
}
 
Example 8
Project: touchtestweb-android   File: SimpleWebChromeClient.java   View source code 6 votes vote down vote up
@Override
public boolean onJsAlert(final WebView view, final String url, final String message, final JsResult result)
{
  new AlertDialog.Builder(m_activity)
    .setTitle("Alert")
    .setMessage(message)
    .setPositiveButton(android.R.string.ok,
      new AlertDialog.OnClickListener()
      {
        @Override
        public void onClick(DialogInterface dialog, int which)
        {
          result.confirm();
        }
      })
    .setCancelable(false)
    .create()
    .show();
  return true;
}
 
Example 9
Project: custode   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    for (int grantResult : grantResults)
        if (grantResult == PackageManager.PERMISSION_DENIED) {
            new AlertDialog.Builder(this)
                    .setCancelable(false)
                    .setMessage(R.string.permission_denied_dialog_message)
                    .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            final Intent intent = new Intent();
                            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                            intent.setData(Uri.parse("package:" + MainActivity.this.getPackageName()));
                            MainActivity.this.startActivity(intent);
                        }
                    })
                    .show();
            break;
        }
}
 
Example 10
Project: Android-Wear-Projects   File: MapsActivity.java   View source code 6 votes vote down vote up
@Override
public void onInfoWindowClick(final Marker marker) {
    final Memory memory = mMemories.get(marker.getId());
    String[] actions  = {"Delete"};
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(memory.city+", "+memory.country)
            .setItems(actions, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (which == 0){
                        marker.remove();
                        mDataSource.deleteMemory(memory);
                    }
                }
            });

    builder.create().show();
}
 
Example 11
Project: MKAPP   File: DownloadTask.java   View source code 6 votes vote down vote up
@Override
protected void onPreExecute() {
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
    wakeLock.acquire();

    progressDialog = new ProgressDialog(context);
    progressDialog.setIcon(R.mipmap.ic_launcher);
    progressDialog.setTitle(R.string.app_name);
    progressDialog.setMessage(context.getString(R.string.msg_downloading, url.toString()));
    progressDialog.setIndeterminate(true);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setCancelable(true);
    progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            DownloadTask.this.cancel(true);
        }
    });
    progressDialog.show();
}
 
Example 12
Project: mDL-ILP   File: PersoActivity.java   View source code 6 votes vote down vote up
@Override
protected void onPostExecute(Certificate certificate) {
    progressDialog.dismiss();

    if (certificate != null) {
        StorageUtils.saveObject(PersoActivity.this, getString(R.string.tls_client_cert_key), certificate);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(PersoActivity.this);
        builder.setTitle(R.string.perso_problem_title);
        builder.setMessage(R.string.perso_problem_register);
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.create().show();
    }
}
 
Example 13
Project: Overkill   File: MainActivity.java   View source code 6 votes vote down vote up
private void checkInternetConnection() {
    ConnectivityManager  cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getActiveNetworkInfo();
    if ( netInfo == null || !netInfo.isConnectedOrConnecting() ) {
        AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
        alertDialog.setTitle("Warning");
        alertDialog.setMessage("This app has limited functions without the internet connection.");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        alertDialog.show();
    }
}
 
Example 14
Project: NotifyTools   File: CameraBridgeViewBase.java   View source code 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 15
Project: ChatExchange-old   File: MainActivity.java   View source code 6 votes vote down vote up
/**
 * Removes all chats on confirmation
 *
 * @param v the view calling this function
 */

public void removeAllChats(View v)
{
    final FloatingActionMenu fam = findViewById(R.id.chat_slide_menu);
    fam.close(true);

    new AlertDialog.Builder(this)
            .setTitle("Are you sure?")
            .setMessage("Are you sure you want to remove all chats?")
            .setPositiveButton(getResources().getText(R.string.generic_yes), new DialogInterface.OnClickListener()
            {
                @Override
                public void onClick(DialogInterface dialogInterface, int i)
                {
                    fragStuff.removeAllFragmentsFromList();
                    fragStuff.setFragmentByTag("home");
                }
            })
            .setNegativeButton(getResources().getText(R.string.generic_no), null)
            .show();
}
 
Example 16
Project: Android-FileBrowser-FilePicker   File: UIUtils.java   View source code 6 votes vote down vote up
public static void ShowError(String msg, Context context)
{
	AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(context);                      
    dlgAlert.setMessage(msg);
    dlgAlert.setTitle("Error");
    dlgAlert.setIcon(android.R.drawable.ic_dialog_alert);
    dlgAlert.setPositiveButton("OK", new OnClickListener() {
		
		@Override
		public void onClick(DialogInterface popup, int arg1) {
			// TODO Auto-generated method stub
			popup.dismiss();
		}
	});
    dlgAlert.setCancelable(false);
    dlgAlert.show();
}
 
Example 17
Project: oma-riista-android   File: LoginTask.java   View source code 6 votes vote down vote up
@Override
protected void onError() {
    if (!mIsSilent) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getWorkContext().getContext());
        if (getHttpStatusCode() == 418) {
            builder.setMessage(getWorkContext().getContext().getResources().getString(R.string.version_outdated));
        } else if (getHttpStatusCode() == 403) {
            builder.setMessage(getWorkContext().getContext().getResources().getString(R.string.login_failed));
        } else {
            builder.setMessage(getWorkContext().getContext().getResources().getString(R.string.connecting_failed));
        }
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
            }
        });
        builder.show();
    }
    loginFailed();
}
 
Example 18
Project: MOAAP   File: CameraBridgeViewBase.java   View source code 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 19
Project: MuslimMateAndroid   File: Validations.java   View source code 6 votes vote down vote up
public static boolean isNetworkAvailable(final Context context) {
    ConnectivityManager connectivityManager
            = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
    boolean state = activeNetworkInfo != null && activeNetworkInfo.isConnected();
    if (!state) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setMessage(context.getString(R.string.internet_alert))
                .setCancelable(false)
                .setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() {
                    public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
                        dialog.cancel();
                    }
                });
        final AlertDialog alert = builder.create();
        alert.show();
    }

    return state;

}
 
Example 20
Project: Plamber-Android   File: ChangeAvatarDialog.java   View source code 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflate = getActivity().getLayoutInflater();
    View v = inflate.inflate(R.layout.change_avatar_dialog, null);
    ButterKnife.bind(this, v);
    loadData(v);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(v)
            .setNegativeButton(R.string.ok_btn, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dismiss();
                }
            }).setPositiveButton(R.string.change_avatar_btn, null);
    return builder.create();
}
 
Example 21
Project: Moodr   File: PermissionUtils.java   View source code 6 votes vote down vote up
@Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            Bundle arguments = getArguments();
            final int requestCode = arguments.getInt(ARGUMENT_PERMISSION_REQUEST_CODE);
            mFinishActivity = arguments.getBoolean(ARGUMENT_FINISH_ACTIVITY);

            return new AlertDialog.Builder(getActivity())
//                    .setMessage(R.string.permission_rationale_location)
                    .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // After click on Ok, request the permission.
                            ActivityCompat.requestPermissions(getActivity(),
                                    new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
                                    requestCode);
                            // Do not finish the Activity while requesting permission.
                            mFinishActivity = false;
                        }
                    })
                    .setNegativeButton(android.R.string.cancel, null)
                    .create();
        }
 
Example 22
Project: FCM-for-Mojo   File: MainActivity.java   View source code 6 votes vote down vote up
private void checkGoogleServiceFramework() {
    boolean ok = false;
    try {
        ok = getPackageManager().getApplicationInfo("com.google.android.gsf", 0).enabled;
    } catch (PackageManager.NameNotFoundException e) {
    }

    if (!ok) {
        new AlertDialog.Builder(this)
                .setTitle(R.string.dialog_no_google_title)
                .setMessage(R.string.dialog_no_google_message)
                .setPositiveButton(R.string.dialog_no_google_exit, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                })
                .setCancelable(false)
                .show();
    }
}
 
Example 23
Project: PLDroidShortVideo   File: VideoTrimActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    mProcessingDialog = new CustomProgressDialog(this);
    mProcessingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            mShortVideoTrimmer.cancelTrim();
        }
    });

    Intent intent = new Intent();
    if (Build.VERSION.SDK_INT < 19) {
        intent.setAction(Intent.ACTION_GET_CONTENT);
        intent.setType("video/*");
    } else {
        intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType("video/*");
    }
    startActivityForResult(Intent.createChooser(intent, "选择要导入的视频"), 0);
}
 
Example 24
Project: AndroidCameraSudokuSolver   File: CameraBridgeViewBase.java   View source code 6 votes vote down vote up
private void onEnterStartedState() {
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 25
Project: Android-Fitness   File: DietActivity.java   View source code 6 votes vote down vote up
private void itemOnLongClick() {
	this.listview.setOnItemLongClickListener(new OnItemLongClickListener() {
				        @Override
				        public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
				        	
				                new AlertDialog.Builder(DietActivity.this)
				                        .setItems(R.array.menu_diet, new DialogInterface.OnClickListener() {
                                                public void onClick(DialogInterface dialog, int which) {
                                                        String[] PK = getResources().getStringArray(R.array.menu_diet);
                                                        if(PK[which].equals("ɾ��������¼")) {
                                                        	   //Log.i("test", "itemDelete:"+position);
                                                               itemDelete(position);
                                                        }
                                                }
                                        }).show();
				                return true;
				       }
	});
}
 
Example 26
Project: encdroidMC   File: EDAccountsActivity.java   View source code 6 votes vote down vote up
protected Dialog onCreateDialog(int id) {

		AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
		AlertDialog alertDialog = null;

		switch (id) {
		case DIALOG_ERROR:
			alertBuilder.setMessage(mErrDialogText);
			alertBuilder.setCancelable(false);
			alertBuilder.setNeutralButton(getString(R.string.btn_ok_str),
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog,
								int whichButton) {
							dialog.dismiss();
						}
					});
			alertDialog = alertBuilder.create();
			break;

		default:
			Log.d(TAG, "Unknown dialog ID requested " + id);
			return null;
		}

		return alertDialog;
	}
 
Example 27
Project: trascendentAR   File: ARLauncher.java   View source code 6 votes vote down vote up
@Override
protected void onStart() {
	super.onStart();
	Log.i(TAG, "onStart(): Activity starting.");

	if (ARToolKit.getInstance().initialiseNative(this.getCacheDir().getAbsolutePath()) == false) { // Use cache directory for Data files.

		new AlertDialog.Builder(this)
				.setMessage("The native library is not loaded. The application cannot continue.")
				.setTitle("Error")
				.setCancelable(true)
				.setNeutralButton(android.R.string.cancel,
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int whichButton) {
								finish();
							}
						})
				.show();

		return;
	}
}
 
Example 28
Project: GitHub   File: MyBookListActivity.java   View source code 6 votes vote down vote up
/**
 * 显示长按对话框
 *
 * @param position
 */
private void showLongClickDialog(final int position) {
    new AlertDialog.Builder(this)
            .setTitle(mAdapter.getItem(position).title)
            .setItems(getResources().getStringArray(R.array.my_book_list_item_long_click_choice),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            switch (which) {
                                case 0:
                                    //删除
                                    CacheManager.getInstance().removeCollection(mAdapter.getItem(position)._id);
                                    mAdapter.remove(position);
                                    break;
                                default:
                                    break;
                            }
                            dialog.dismiss();
                        }
                    })
            .setNegativeButton(null, null)
            .create().show();
}
 
Example 29
Project: Bigbang   File: ColorPickerPreference.java   View source code 6 votes vote down vote up
@Override
protected void onClick() {
	ColorPickerDialogBuilder builder = ColorPickerDialogBuilder
		.with(getContext())
		.setTitle(pickerTitle)
		.initialColor(selectedColor)
		.wheelType(wheelType)
		.density(density)
		.setPositiveButton(pickerButtonOk, new ColorPickerClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int selectedColorFromPicker, Integer[] allColors) {
				setValue(selectedColorFromPicker);
			}
		})
		.setNegativeButton(pickerButtonCancel, null);

	if (!alphaSlider && !lightSlider) builder.noSliders();
	else if (!alphaSlider) builder.lightnessSliderOnly();
	else if (!lightSlider) builder.alphaSliderOnly();


	builder
		.build()
		.show();
}
 
Example 30
Project: GitHub   File: SettingActivity.java   View source code 6 votes vote down vote up
@OnClick(R.id.rlFlipStyle)
public void onClickFlipStyle() {
    new AlertDialog.Builder(mContext)
            .setTitle("阅读页翻页效果")
            .setSingleChoiceItems(getResources().getStringArray(R.array.setting_dialog_style_choice),
                    SharedPreferencesUtil.getInstance().getInt(Constant.FLIP_STYLE, 0),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            mTvFlipStyle.setText(getResources().getStringArray(R.array.setting_dialog_style_choice)[which]);
                            SharedPreferencesUtil.getInstance().putInt(Constant.FLIP_STYLE, which);
                            dialog.dismiss();
                        }
                    })
            .create().show();
}
 
Example 31
Project: Task-Reminder   File: ReminderAddActivity.java   View source code 6 votes vote down vote up
public void selectRepeatType(View v){
    final String[] items = new String[5];

    items[0] = "Minute";
    items[1] = "Hour";
    items[2] = "Day";
    items[3] = "Week";
    items[4] = "Month";

    // Create List Dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Select Type");
    builder.setItems(items, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int item) {

            mRepeatType = items[item];
            mRepeatTypeText.setText(mRepeatType);
            mRepeatText.setText("Every " + mRepeatNo + " " + mRepeatType + "(s)");
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}
 
Example 32
Project: Team9261-2017-2018   File: CameraBridgeViewBase.java   View source code 6 votes vote down vote up
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
Example 33
Project: GitHub   File: DefaultPromptClickListener.java   View source code 6 votes vote down vote up
@Override
public void onClick(DialogInterface dialog, int which) {

    switch (which) {
    case DialogInterface.BUTTON_POSITIVE:
        mAgent.update();
        break;
    case DialogInterface.BUTTON_NEUTRAL:
        mAgent.ignore();
        break;
    case DialogInterface.BUTTON_NEGATIVE:
        // not now
        break;
    }
    if (mIsAutoDismiss) {
        dialog.dismiss();
    }
}
 
Example 34
Project: youkes_browser   File: LightningDownloadListener.java   View source code 5 votes vote down vote up
@Override
public void onDownloadStart(final String url, final String userAgent,
		final String contentDisposition, final String mimetype, long contentLength) {
	String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
	DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
		@Override
		public void onClick(DialogInterface dialog, int which) {
			switch (which) {
				case DialogInterface.BUTTON_POSITIVE:
					DownloadHandler.onDownloadStart(mActivity, url, userAgent,
							contentDisposition, mimetype, false);
					break;

				case DialogInterface.BUTTON_NEGATIVE:
					break;
			}
		}
	};

	AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
	builder.setTitle(fileName)
			.setMessage(mActivity.getResources().getString(R.string.dialog_download))
			.setPositiveButton(mActivity.getResources().getString(R.string.action_download),
					dialogClickListener)
			.setNegativeButton(mActivity.getResources().getString(R.string.action_cancel),
					dialogClickListener).show();
	Log.i(Constants.TAG, "Downloading" + fileName);

}
 
Example 35
Project: CardSimulator   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.about) {
        ((TextView)new AlertDialog.Builder(this).setTitle(getString(R.string.about))
                .setMessage(Html.fromHtml(getString(R.string.aboutmsg)))
                .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                })
                .show().findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
        return true;
    }
    if(id == R.id.license){
        ld.show();
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 36
Project: MVVMFrames   File: BaseDialogFragment.java   View source code 5 votes vote down vote up
@Override
public boolean onKey(DialogInterface dialogInterface, int keyCode, KeyEvent keyEvent) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        dismiss();
        return true;
    } else {
        return false;
    }
}
 
Example 37
Project: CollegeDoc   File: Topics.java   View source code 5 votes vote down vote up
public void confirmation_dialogbox(final DatabaseReference databaseReference1, final String new_topic)
{
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which){
                case DialogInterface.BUTTON_POSITIVE:
                    databaseReference1.push().setValue(new_topic);
                    mStorageRef = FirebaseStorage.getInstance().getReferenceFromUrl
                            ("gs://college-doc.appspot.com//"+u);
                    Intent intent = new Intent();
                    intent.setType("application/pdf");
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                    try {
                        startActivityForResult(Intent.createChooser(intent, "Select PDF of name "+new_topic+".pdf"), SELECT_PDF);
                    } catch (ActivityNotFoundException f) {
                        Toast.makeText(Topics.this, "Activity Not Found", Toast.LENGTH_SHORT).show();
                    }
                    //Yes button clicked
                    break;

                case DialogInterface.BUTTON_NEGATIVE:
                    //No button clicked
                    break;
            }
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage("Are you sure to add "+new_topic+".pdf ?" +
            " in subject "+ u.toString()).setPositiveButton("Yes", dialogClickListener)
            .setNegativeButton("No", dialogClickListener).show();
}
 
Example 38
Project: PlusGram   File: LoginActivity.java   View source code 5 votes vote down vote up
private void needShowInvalidAlert(final String phoneNumber, final boolean banned) {
    if (getParentActivity() == null) {
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    if (banned) {
        builder.setMessage(LocaleController.getString("BannedPhoneNumber", R.string.BannedPhoneNumber));
    } else {
        builder.setMessage(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
    }
    builder.setNeutralButton(LocaleController.getString("BotHelp", R.string.BotHelp), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
                String version = String.format(Locale.US, "%s (%d)", pInfo.versionName, pInfo.versionCode);

                Intent mailer = new Intent(Intent.ACTION_SEND);
                mailer.setType("message/rfc822");
                mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
                if (banned) {
                    mailer.putExtra(Intent.EXTRA_SUBJECT, "Banned phone number: " + phoneNumber);
                    mailer.putExtra(Intent.EXTRA_TEXT, "I'm trying to use my mobile phone number: " + phoneNumber + "\nBut Telegram says it's banned. Please help.\n\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault());
                } else {
                    mailer.putExtra(Intent.EXTRA_SUBJECT, "Invalid phone number: " + phoneNumber);
                    mailer.putExtra(Intent.EXTRA_TEXT, "I'm trying to use my mobile phone number: " + phoneNumber + "\nBut Telegram says it's invalid. Please help.\n\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault());
                }
                getParentActivity().startActivity(Intent.createChooser(mailer, "Send email..."));
            } catch (Exception e) {
                needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("NoMailInstalled", R.string.NoMailInstalled));
            }
        }
    });
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
    showDialog(builder.create());
}
 
Example 39
Project: TensorFlowDetector-App   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if(item.getItemId()==R.id.connect){

        View view= LayoutInflater.from(MainActivity.this).inflate(R.layout.alert_connection,null);
        final EditText ipEditText=(EditText)view.findViewById(R.id.connection_ip_editText);
        final EditText portEditText=(EditText)view.findViewById(R.id.connection_port_editText);

        AlertDialog.Builder builder=new AlertDialog.Builder(MainActivity.this)
                .setMessage("Enter connection details: ")
                .setView(view)
                .setPositiveButton("Connect", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        Toast.makeText(MainActivity.this,"Connected"
                                ,Toast.LENGTH_SHORT).show();

                        serverIP=ipEditText.getText().toString();
                        serverPort=Integer.parseInt(portEditText.getText().toString());

                    }
                }).setNegativeButton("Cancel",null)
                .setCancelable(false);
        AlertDialog alert=builder.create();
        alert.show();

    }

    return true;
}
 
Example 40
Project: privacyidea-authenticator   File: MainActivity.java   View source code 5 votes vote down vote up
public static void changeDialogFontColor(final AlertDialog dialog) {
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            doChangeDialogFontColor(dialog);
        }
    });

}