List of usage examples for android.app AlertDialog dismiss
@Override public void dismiss()
From source file:com.simadanesh.isatis.LoginActivity.java
public void onDataReady(LoginResult res) { CommonPlace.currentUser = res;// w w w . j a v a 2s . co m /*if (res==null || res.PerssonelName == null) { //res=new LoginResult(); res.PerssonelName = ""; }*/ Boolean localloggedIn = false; if (res != null) { //res.PerssonelName = edUserName.getText().toString(); switch (res.Code) { case LoginResult.Ok: localloggedIn = true; Token = res.Token; Login login = new Login(); List<Login> lst = LoginDA.getInstance(this).getAll("UserName=?", "", new String[] { edUserName.getText().toString() }); if (lst.size() > 0) { login = lst.get(0); login.setUserName(edUserName.getText().toString()); login.setPassword(edPassword.getText().toString()); login.PerssonelName = res.PerssonelName; login.LastLoginTime = Utility.NowDate() + " " + Utility.NowTime(); LoginDA.getInstance(this).update(login); } else { login.setUserName(edUserName.getText().toString()); login.setPassword(edPassword.getText().toString()); login.PerssonelName = res.PerssonelName; login.LastLoginTime = Utility.NowDate() + " " + Utility.NowTime(); LoginDA.getInstance(this).Insert(login); } List<Login> lst1 = LoginDA.getInstance(this).getAll("UserName=? and Password=?", "", new String[] { edUserName.getText().toString(), edPassword.getText().toString() }); if (lst1.size() > 0) { CommonPlace.currentLogin = lst1.get(0); } CommonPlace.isOnline = true; break; case LoginResult.InvalidUser: (new AlertDialog.Builder(this)).setTitle("").setIcon(android.R.drawable.ic_dialog_info) .setMessage(" .").create().show(); break; case LoginResult.Disabled: (new AlertDialog.Builder(this)).setTitle("").setIcon(android.R.drawable.ic_dialog_info) .setMessage(" ? .").create().show(); break; case LoginResult.Expire: (new AlertDialog.Builder(this)).setTitle("").setIcon(android.R.drawable.ic_dialog_info) .setMessage(" .").create() .show(); break; case LoginResult.Waiting: (new AlertDialog.Builder(this)).setTitle("").setIcon(android.R.drawable.ic_dialog_info) .setMessage(" .").create() .show(); break; case LoginResult.SystemException: (new AlertDialog.Builder(this)).setTitle("").setIcon(android.R.drawable.ic_dialog_alert) .setMessage( " ? .") .create().show(); break; } } else { AlertDialog dialog = (new AlertDialog.Builder(this)).setTitle("") .setIcon(android.R.drawable.ic_dialog_alert) .setMessage( " ? .") .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { localLogin(); } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); dialog.show(); } this.loggedIn = localloggedIn; unlockApp(); }
From source file:org.loon.framework.android.game.LGameAndroid2DActivity.java
/** * ??Alter//from w w w . j ava 2s. c o m * * @param message */ public void showAndroidAlert(final String title, final String message) { Runnable showAlert = new Runnable() { public void run() { final AlertDialog alert = new AlertDialog.Builder(LGameAndroid2DActivity.this).create(); alert.setTitle(title); alert.setMessage(message); alert.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { alert.dismiss(); } }); alert.show(); } }; runOnUiThread(showAlert); }
From source file:com.justone.android.main.MainActivity.java
public void userFirstTips() { @SuppressWarnings("deprecation") SharedPreferences preferences = getSharedPreferences("count", MODE_WORLD_READABLE); int count = preferences.getInt("count", 0); // /* w w w . j a v a2s. c o m*/ if (count == 0) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.first_tips, (ViewGroup) findViewById(R.id.first_tips)); final AlertDialog dialog = new AlertDialog.Builder(this).setView(layout).show(); layout.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { dialog.dismiss(); return true; } }); dialog.getWindow().setLayout(650, 650); } Editor editor = preferences.edit(); // editor.putInt("count", ++count); // editor.commit(); }
From source file:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { user = (User) getArguments().getSerializable(USER_KEY); vehicles = (Vehicle[]) getArguments().getSerializable(SEEKER_VEHICLES_KEY); getCurrInfo();//from ww w. j av a2s .c o m rootView = inflater.inflate(R.layout.fragment_seeker_profile_vehicle, container, false); sprof_make = (EditText) rootView.findViewById(R.id.sprof_make); sprof_model = (EditText) rootView.findViewById(R.id.sprof_model); sprof_color = (EditText) rootView.findViewById(R.id.sprof_color); sprof_year = (EditText) rootView.findViewById(R.id.sprof_year); sprof_licenseplate = (EditText) rootView.findViewById(R.id.sprof_licenseplate); tl = (TableLayout) rootView.findViewById(R.id.sprof_vehicle_table); sprof_add_vehicle_button = (Button) rootView.findViewById(R.id.sprof_add_vehicle_button); sprof_edit_vehicle_button = (Button) rootView.findViewById(R.id.sprof_edit_vehicle_button); sprof_delete_vehicle_button = (Button) rootView.findViewById(R.id.sprof_delete_vehicle_button); sprof_add_vehicle_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { String make = sprof_make.getText().toString(); String model = sprof_model.getText().toString(); String color = sprof_color.getText().toString(); String year = sprof_year.getText().toString(); String licensePlate = sprof_licenseplate.getText().toString(); Vehicle vehicle = new Vehicle(); vehicle.setMake(make); vehicle.setModel(model); vehicle.setColor(color); vehicle.setYear(year); vehicle.setLicensePlate(licensePlate); if (!validate(vehicle)) { onAddUpdateVehicleFailed(); return; } Vehicle v = getVehicle(licensePlate); if (v.getMake() == null) { addVehicle(vehicle); } else { Snackbar.make(rootView, "Vehicle with this license plate already exists; cannot re-add", Snackbar.LENGTH_LONG).show(); } } }); sprof_edit_vehicle_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (selectedMake.equals("")) { Snackbar.make(rootView, "Must select a vehicle", Snackbar.LENGTH_LONG).show(); } else { String make = sprof_make.getText().toString(); String model = sprof_model.getText().toString(); String color = sprof_color.getText().toString(); String year = sprof_year.getText().toString(); String licensePlate = sprof_licenseplate.getText().toString(); Vehicle vehicle = new Vehicle(); vehicle.setMake(make); vehicle.setModel(model); vehicle.setColor(color); vehicle.setYear(year); vehicle.setLicensePlate(licensePlate); if (!validate(vehicle)) { onAddUpdateVehicleFailed(); return; } else if (!licensePlate.equals(selectedLicensePlate)) { Snackbar.make(rootView, "Cannot update vehicle license plate; add a new vehicle with this license plate", Snackbar.LENGTH_LONG).show(); } else { vehicles[selectedIndex - 1] = vehicle; TableRow tr = (TableRow) tl.findViewWithTag(selectedIndex); tr.setBackgroundColor(Color.LTGRAY); TextView tv = (TextView) tr.getChildAt(0); tv.setText(vehicle.getMake()); tv = (TextView) tr.getChildAt(1); tv.setText(vehicle.getModel()); editVehicle(); } } } }); sprof_delete_vehicle_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (selectedMake.equals("")) { Snackbar.make(rootView, "Must select a vehicle", Snackbar.LENGTH_LONG).show(); } else if (tag == 2) { Snackbar.make(rootView, "Must add another vehicle before deleting your only listed vehicle", Snackbar.LENGTH_LONG).show(); } else { LayoutInflater li = LayoutInflater.from(myContext); View customView = li.inflate(R.layout.popup_delete_vehicle, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(myContext); alertDialogBuilder.setView(customView); final AlertDialog alertDialog = alertDialogBuilder.create(); TextView deleteText = (TextView) customView.findViewById(R.id.popup_delete_vehicle_text); deleteText.setText("Are you sure you want to delete this vehicle: " + selectedMake + " " + selectedModel + " " + selectedLicensePlate + "?"); ImageButton closeButton = (ImageButton) customView .findViewById(R.id.popup_delete_vehicle_close); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { alertDialog.dismiss(); } }); Button deleteButton = (Button) customView.findViewById(R.id.popup_delete_vehicle_button); deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { deleteVehicle(); alertDialog.dismiss(); } }); alertDialog.show(); } } }); return rootView; }
From source file:org.catrobat.catroid.ui.dialogs.NewSpriteDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_new_object, null); setupPaintroidButton(dialogView);//from ww w . j a v a 2s . c o m setupGalleryButton(dialogView); setupCameraButton(dialogView); setupMediaLibraryButton(dialogView); AlertDialog dialog = null; AlertDialog.Builder dialogBuilder = new CustomAlertDialogBuilder(getActivity()).setView(dialogView) .setTitle(R.string.new_sprite_dialog_title); if (wizardStep == DialogWizardStep.STEP_1) { dialog = createDialogStepOne(dialogBuilder); } else if (wizardStep == DialogWizardStep.STEP_2) { dialog = createDialogStepTwo(dialogBuilder); } dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(final DialogInterface dialog) { Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (handleOkButton()) { dialog.dismiss(); } } }); } }); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); return dialog; }
From source file:hku.fyp14017.blencode.ui.dialogs.NewSpriteDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { dialogView = LayoutInflater.from(getActivity()).inflate(hku.fyp14017.blencode.R.layout.dialog_new_object, null);//from ww w . ja va 2s. c om setupPaintroidButton(dialogView); setupGalleryButton(dialogView); setupCameraButton(dialogView); AlertDialog dialog = null; AlertDialog.Builder dialogBuilder = new CustomAlertDialogBuilder(getActivity()).setView(dialogView) .setTitle(hku.fyp14017.blencode.R.string.new_sprite_dialog_title); if (wizardStep == DialogWizardStep.STEP_1) { dialog = createDialogStepOne(dialogBuilder); } else if (wizardStep == DialogWizardStep.STEP_2) { dialog = createDialogStepTwo(dialogBuilder); } dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(final DialogInterface dialog) { Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (handleOkButton()) { dialog.dismiss(); } } }); } }); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); return dialog; }
From source file:fr.android.scaron.diaspdroid.vues.fragment.ParamsFragment.java
@UiThread public void showResultLogin(boolean loginOK) { String methodName = ".showResultLogin : "; LOG.d(methodName + "Entre"); if (loginOK) { final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( DiasporaConfig.APPLICATION_CONTEXT); final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { @Override/*from ww w . jav a 2 s . co m*/ public void onClick(final DialogInterface dialog, final int which) { String methodName = ".showResultLogin/loginOK/onClick : "; LOG.d(methodName + "Entre"); DiasporaConfig.ParamsOK = true; DiasporaConfig.DB.putBoolean("configOK", true); LOG.d(methodName + "Params to true"); LOG.d(methodName + "main activity type is " + activity.getClass().getName()); if (activity instanceof MainActivity_) { LOG.d(methodName + "call set defaultView on MainActivity_"); ((MainActivity_) activity).setDefaultView(); } else if (activity instanceof MainActivity) { LOG.d(methodName + "call set defaultView on MainActivity"); ((MainActivity) activity).setDefaultView(); } alertDialog.dismiss(); } }); alertDialog.setIcon(R.drawable.ic_launcher); alertDialog.setTitle("Connexion russie"); alertDialog.setMessage("Vos paramtres sont correctes.\nBon surf sur Diaspora !"); alertDialog.show(); LOG.d(methodName + "Sortie"); return; } final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(DiasporaConfig.APPLICATION_CONTEXT); final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { String methodName = ".showResultLogin/loginKO/onClick : "; LOG.d(methodName + "Entre"); DiasporaConfig.ParamsOK = false; DiasporaConfig.DB.putBoolean("configOK", false); LOG.d(methodName + "Params to false"); alertDialog.dismiss(); } }); alertDialog.setIcon(R.drawable.ic_launcher); alertDialog.setTitle("PB Connexion"); alertDialog.setMessage("La connexion a Diaspora a choue"); alertDialog.show(); LOG.d(methodName + "Sortie en erreur"); }
From source file:abanoubm.dayra.main.Main.java
private void register() { LayoutInflater li = LayoutInflater.from(getApplicationContext()); final View view = li.inflate(R.layout.dialogue_create, null, false); final AlertDialog ad = new AlertDialog.Builder(Main.this).setCancelable(true).create(); ad.setView(view, 0, 0, 0, 0);/*w w w. ja v a 2s . c om*/ ad.show(); view.findViewById(R.id.yesBtn).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String str = ((EditText) view.findViewById(R.id.input)).getText().toString().trim(); if (Utility.isInvlaidDBName(str)) { Toast.makeText(getApplicationContext(), R.string.err_msg_dayra_name, Toast.LENGTH_SHORT).show(); } else { if (DB.isDBExists(getApplicationContext(), str)) { Toast.makeText(getApplicationContext(), R.string.err_msg_duplicate_dayra, Toast.LENGTH_SHORT).show(); } else { new RegisterTask().execute(str); ad.dismiss(); } } } }); }
From source file:com.dazone.crewchat.libGallery.activity.BucketHomeFragmentActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { if (requestCode == MediaChooserConstants.BUCKET_SELECT_IMAGE_CODE) { addMedia(mSelectedImage, data.getStringArrayListExtra("list")); } else if (requestCode == MediaChooserConstants.BUCKET_SELECT_VIDEO_CODE) { addMedia(mSelectedVideo, data.getStringArrayListExtra("list")); } else if (requestCode == MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, fileUri)); final AlertDialog alertDialog = MediaChooserConstants.getDialog(BucketHomeFragmentActivity.this) .create();/*from w w w .j a v a 2 s . c om*/ alertDialog.show(); handler.postDelayed(new Runnable() { @Override public void run() { //Do something after 2000ms String fileUriString = fileUri.toString().replaceFirst("file:///", "/").trim(); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); BucketImageFragment bucketImageFragment = (BucketImageFragment) fragmentManager .findFragmentByTag("tab1"); if (bucketImageFragment != null) { bucketImageFragment.getAdapter().addLatestEntry(fileUriString); bucketImageFragment.getAdapter().notifyDataSetChanged(); } alertDialog.dismiss(); } }, 5000); } else if (requestCode == MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) { sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, fileUri)); final AlertDialog alertDialog = MediaChooserConstants.getDialog(BucketHomeFragmentActivity.this) .create(); alertDialog.show(); handler.postDelayed(new Runnable() { @Override public void run() { //Do something after 2000ms String fileUriString = fileUri.toString().replaceFirst("file:///", "/").trim(); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); BucketVideoFragment bucketVideoFragment = (BucketVideoFragment) fragmentManager .findFragmentByTag("tab2"); if (bucketVideoFragment != null) { bucketVideoFragment.getAdapter().addLatestEntry(fileUriString); bucketVideoFragment.getAdapter().notifyDataSetChanged(); } alertDialog.dismiss(); } }, 5000); } } }
From source file:org.sufficientlysecure.ical.ui.UrlDialog.java
@Override public void onStart() { super.onStart(); final AlertDialog dlg = (AlertDialog) getDialog(); if (dlg == null) return;/*from w w w . ja v a2 s. c om*/ View.OnClickListener onClickTask; onClickTask = new View.OnClickListener() { @Override public void onClick(View view) { String url = mTextCalendarUrl.getText().toString(); boolean loginRequired = mCheckboxLoginRequired.isChecked(); String username = loginRequired ? mTextUsername.getText().toString() : ""; String password = loginRequired ? mTextPassword.getText().toString() : ""; if (!mActivity.setSource(url, null, username, password)) { TextView label = (TextView) dlg.findViewById(R.id.TextViewUrlError); label.setText(R.string.invalid_url); return; } Settings settings = mActivity.getSettings(); settings.putString(Settings.PREF_LASTURL, url); if (loginRequired) { settings.putString(Settings.PREF_LASTURLUSERNAME, username); if (settings.getSavePasswords()) settings.putString(Settings.PREF_LASTURLPASSWORD, password); } dlg.dismiss(); } }; dlg.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(onClickTask); }