List of usage examples for android.app Dialog getContext
public final @NonNull Context getContext()
From source file:Main.java
public static void hideSoftInput(Dialog dialog) { View view = dialog.getCurrentFocus(); if (view != null) { InputMethodManager imm = (InputMethodManager) dialog.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }/* w w w.jav a 2s. c o m*/ }
From source file:Main.java
public static void closeKeyboard(Dialog dialog) { View view = dialog.getWindow().peekDecorView(); if (view != null) { InputMethodManager inputMethodManager = (InputMethodManager) dialog.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); }/*from www . jav a2 s .c om*/ }
From source file:Main.java
public static void dismissDialog(Dialog dialog) { if (dialog.isShowing()) { //check if dialog is showing. //get the Context object that was used to great the dialog Context context = ((ContextWrapper) dialog.getContext()).getBaseContext(); //if the Context used here was an activity AND it hasn't been finished //then dismiss it if (context instanceof Activity) { if (!((Activity) context).isFinishing()) { dialog.dismiss();/*w ww .ja v a 2 s . co m*/ } } else { //if the Context used wasnt an Activity, then dismiss it too dialog.dismiss(); } } }
From source file:android.support.v7.app.AppCompatDelegate.java
/** * Create a {@link android.support.v7.app.AppCompatDelegate} to use with {@code dialog}. * * @param callback An optional callback for AppCompat specific events *///from ww w . j a v a 2 s . c om public static AppCompatDelegate create(Dialog dialog, AppCompatCallback callback) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { return new AppCompatDelegateImplV11(dialog.getContext(), dialog.getWindow(), callback); } else { return new AppCompatDelegateImplV7(dialog.getContext(), dialog.getWindow(), callback); } }
From source file:android.support.v7ox.app.AppCompatDelegate.java
/** * Create a {@link android.support.v7ox.app.AppCompatDelegate} to use with {@code dialog}. * * @param callback An optional callback for AppCompat specific events */// w ww. j a va 2 s .c o m public static AppCompatDelegate create(Dialog dialog, AppCompatCallback callback) { return create(dialog.getContext(), dialog.getWindow(), callback); }
From source file:com.linkbubble.util.Util.java
static public void showThemedDialog(Dialog dialog) { dialog.show();/*from w w w . ja va 2 s . c om*/ Resources resources = dialog.getContext().getResources(); int color = resources.getColor( Settings.get().getDarkThemeEnabled() ? R.color.color_primary_bright : R.color.color_primary); int dividerId = resources.getIdentifier("android:id/titleDivider", null, null); if (dividerId > 0) { View divider = dialog.findViewById(dividerId); if (divider != null) { divider.setBackgroundColor(color); } } int titleTextViewId = resources.getIdentifier("android:id/alertTitle", null, null); if (titleTextViewId > 0) { TextView textView = (TextView) dialog.findViewById(titleTextViewId); if (textView != null) { textView.setTextColor(color); } } }
From source file:org.andstatus.app.SelectorDialog.java
@NonNull @Override//from w w w . j ava 2 s.c o m public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = new Dialog(getActivity(), MyTheme.getThemeId(getActivity(), MyTheme.getThemeName())); MyTheme.applyStyles(dialog.getContext(), true); return dialog; }
From source file:com.filelocker.andy.MainActivity.java
public void browseButton_Click(View view) { final TextView vFileChooserText = (TextView) findViewById(R.id.fileChooserText); final FileChooserDialog dialog = new FileChooserDialog(this); dialog.show();/* w w w .j a v a 2 s. com*/ dialog.addListener(new FileChooserDialog.OnFileSelectedListener() { public void onFileSelected(Dialog source, File file) { source.hide(); Toast toast = Toast.makeText(source.getContext(), "File selected: " + file.getName(), Toast.LENGTH_LONG); toast.show(); vFileChooserText.setText(file.getAbsolutePath()); dialog.hide(); } public void onFileSelected(Dialog source, File folder, String name) { source.hide(); Toast toast = Toast.makeText(source.getContext(), "File created: " + folder.getName() + "/" + name, Toast.LENGTH_LONG); toast.show(); dialog.hide(); } }); }
From source file:com.konsula.app.gcm.MyGcmListenerService.java
private void handleGCM(Bundle bundle) { try {//from w w w. j a va 2 s . c om Bundle data = bundle; String message = data.getString(TAG_MESSAGE, ""); final String doc_name = data.getString(TAG_DOC_NAME, ""); final String schedule = data.getString(TAG_SCHEDULE, ""); final String specialization = data.getString(TAG_SPECIALIZATION, ""); final String status = data.getString(TAG_STATUS, ""); String tele_uuid = data.getString(TAG_TELE_UUID, ""); String page = data.getString(TAG_PAGE, ""); String type = data.getString(TAG_TYPE, ""); if (type.equals("dialog")) { if (page.equals("teledoc-confirmed")) { CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this, getResources().getColor(R.color.green_xxl)); View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_confirm, null); TextView textViewname = (TextView) invoiceDetail.findViewById(R.id.tvNamaDokter); TextView textViewspeciality = (TextView) invoiceDetail.findViewById(R.id.etSpeciality); TextView textViewdate = (TextView) invoiceDetail.findViewById(R.id.tvDate); TextView textViewstatus = (TextView) invoiceDetail.findViewById(R.id.text_status); TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button); btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl)); btnCancel.setText(getResources().getString(R.string.mdtp_ok)); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); textViewname.setText(doc_name); textViewspeciality.setText(specialization); textViewdate.setText(schedule); textViewstatus.setText(status.toUpperCase()); builder.setView(invoiceDetail); builder.setTitle(getResources().getString(R.string.title_teledokter)); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { // TODO Auto-generated method stub Dialog d = ((Dialog) dialog); int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null); View divider = d.findViewById(dividerId); if (divider != null) { divider.setBackgroundColor(getResources().getColor(R.color.green_xxl)); } } }); dialog.show(); } if (page.equals("teledoc-cancel")) { CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this, getResources().getColor(R.color.green_xxl)); View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_cancel_confirm, null); TextView textView = (TextView) invoiceDetail.findViewById(R.id.message); TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button); btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl)); btnCancel.setText(getResources().getString(R.string.mdtp_ok)); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); textView.setText(getResources().getString(R.string.text_teledoc_cancel)); builder.setView(invoiceDetail); builder.setTitle(getResources().getString(R.string.title_teledokter)); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { // TODO Auto-generated method stub Dialog d = ((Dialog) dialog); int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null); View divider = d.findViewById(dividerId); if (divider != null) { divider.setBackgroundColor(getResources().getColor(R.color.green_xxl)); } } }); dialog.show(); } if (page.equals("teledoc-reschedule")) { CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this, getResources().getColor(R.color.green_xxl)); View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_cancel_confirm, null); TextView textView = (TextView) invoiceDetail.findViewById(R.id.message); TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button); btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl)); btnCancel.setText(getResources().getString(R.string.mdtp_ok)); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); textView.setText(getResources().getString(R.string.text_reschedule_information)); builder.setView(invoiceDetail); builder.setTitle(getResources().getString(R.string.title_teledokter)); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { // TODO Auto-generated method stub Dialog d = ((Dialog) dialog); int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null); View divider = d.findViewById(dividerId); if (divider != null) { divider.setBackgroundColor(getResources().getColor(R.color.green_xxl)); } } }); dialog.show(); } } else if (type.equals("intent") && (page.equals("teledoc-confirmation-reschedule"))) { Intent intent = new Intent(this, TeledocRescheduleActivity.class); intent.putExtra(TeledocRescheduleActivity.TAG_TELE_UUID, tele_uuid); intent.putExtra(TeledocRescheduleActivity.TAG_DOC_NAME, doc_name); intent.putExtra(TeledocRescheduleActivity.TAG_DOC_SPECIALIZATION, specialization); intent.putExtra(TeledocRescheduleActivity.TAG_DOC_SCHEDULE, schedule); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } } catch (Exception e) { Log.e("ee", e.getMessage()); Log.e("ee", String.valueOf(e)); } }
From source file:org.zakky.memopad.MyDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.setContentView(R.layout.dialog); dialog.setTitle(R.string.app_name);// w w w. ja v a2 s .c o m dialog.findViewById(R.id.ok_button).setOnClickListener(new OnClickListener() { public void onClick(View v) { v.setEnabled(false); final CheckBox box = (CheckBox) dialog.findViewById(R.id.show_this_dialog_at_startup); final SharedPreferences pref = dialog.getContext().getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE); final Editor editor = pref.edit(); try { editor.putBoolean(PREF_KEY_SHOW_AT_STARTUP, box.isChecked()); } finally { editor.commit(); } dialog.dismiss(); } }); return dialog; }