protected void showErrorDialog(int errorMessageId) { stopLoop = true; final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.test_dialog_error_title); builder.setMessage(errorMessageId); builder.setNeutralButton(android.R.string.ok, null); dismissDialogs(); errorDialog = builder.create(); errorDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { final RMBTMainActivity activity = (RMBTMainActivity) getActivity(); if (activity != null) activity.getSupportFragmentManager().popBackStack(); } }); errorDialog.show(); }
@Override protected void onPreExecute() { // mProgressDialog = new ProgressDialog(context, ProgressDialog.THEME_DEVICE_DEFAULT_LIGHT); mProgressDialog.setTitle(""); mProgressDialog.setMessage(activity .getString(R.string.mixradio_dialog)); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mProgressDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { // mTask.cancel(true); } }); mProgressDialog.show(); super.onPreExecute(); }
/** * Show the attributes dialog for the specified {@code viewItem} if applicable * * @param viewItem * the item chosen to show the attributes */ private void showDialogAttributes(final ViewItem viewItem) { ArrayList<ModelAttribute> attributesValid = (ArrayList<ModelAttribute>) getAttributes(viewItem); // Show the dialog finally if they have any choice. if (!attributesValid.isEmpty()) { DlgAttributes dlg = new DlgAttributes(this, attributesValid); dlg.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { // Fetch the attribute they chose, if any. ModelAttribute modelAttribute = ((DlgAttributes) dialog).getSelectedAttribute(); if (modelAttribute != null) { viewItem.insertAttribute(modelAttribute); } } }); dlg.show(); } else { // Shouldn't happen but leaving in for safety UtilUI.showAlert(this, "Sorry!", "There are no matching parameters for the selected attribute type!"); } }
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ID_INFO: AlertDialog dlgInfo = new AlertDialog.Builder(this) .setTitle(mStateHolder.getDlgInfoTitle()) .setIcon(0) .setMessage(mStateHolder.getDlgInfoMessage()).create(); dlgInfo.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { removeDialog(DIALOG_ID_INFO); } }); try { Uri icon = Uri.parse(mStateHolder.getDlgInfoBadgeIconUrl()); dlgInfo.setIcon(new BitmapDrawable(((Foursquared) getApplication()) .getRemoteResourceManager().getInputStream(icon))); } catch (Exception e) { Log.e(TAG, "Error loading badge dialog!", e); dlgInfo.setIcon(R.drawable.default_on); } return dlgInfo; } return null; }
/**弹出窗口消失会发送该事件**/ public synchronized static void setOnDismissListener(OnDismissListener l) { if(mOnDismissListener == l) return; final OnDismissListener oldListnener = mOnDismissListener; mOnDismissListener = l; if(oldListnener != null) { final MyDialog dialog = MyDialog.get(); if(dialog != null) { if(mUiThread != Thread.currentThread()) { if(mHandler != null) mHandler.post(new Runnable() { @Override public void run() { oldListnener.onDismiss(dialog); } }); }else { oldListnener.onDismiss(dialog); } } } }
private void createListeningDialog() { _listeningDialog = new ListeningDialog(this); _listeningDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (_currentRecognizer != null) // Cancel the current recognizer { _currentRecognizer.cancel(); _currentRecognizer = null; } if (!_destroyed) { VoiceActivity.this.removeDialog(LISTENING_DIALOG); createListeningDialog(); } } }); }
@Override public boolean touchdown(int pid, float x, float y) { if (dRect.contains(x, y)) { final Selector selector = new Selector(parent.getContext(), getValues()); selector.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { Integer v = selector.getSelectedValue(); if (v != null){ val = v; doSend(); parent.threadSafeInvalidate(); } dialog.dismiss(); } }); selector.show(); return true; } return false; }
private void openEditDialog() { final NumberboxDialog editDialog = new NumberboxDialog(parent.getContext(), val); editDialog.setTitle(label == null ? "Edit number" : label); editDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { Float selectedValue = editDialog.getSelectedValue(); if(selectedValue != null) { setval(selectedValue.floatValue()); sendFloat(val); parent.invalidate(); } } }); editDialog.show(); }
private void openEditDialog() { final SymbolDialog editDialog = new SymbolDialog(parent.getContext(), value); editDialog.setTitle(label == null ? "Edit symbol" : label); editDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { String selectedValue = editDialog.getSelectedValue(); if(selectedValue != null) { setValue(selectedValue); parent.invalidate(); } } }); editDialog.show(); }
@Override public void onAttach(final Activity activity) { super.onAttach(activity); if (activity instanceof OnClickListener) { mClickListener = (OnClickListener) activity; } else { throw new IllegalStateException("Activity must implement DialogInterface.OnClickListener"); } if (activity instanceof OnDismissListener) { mOnDismissListener = (OnDismissListener) activity; } }
/** * Show a list of the templates in the database, selection will either load a template or start the edit dialog on * it * * @param context Android context * @param manage if true the template editor will be started otherwise the template will replace the current OH * value */ void loadOrManageTemplate(Context context, boolean manage) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(context); View templateView = (View) inflater.inflate(R.layout.template_list, null); alertDialog.setTitle(manage ? R.string.manage_templates_title : R.string.load_templates_title); alertDialog.setView(templateView); ListView lv = (ListView) templateView.findViewById(R.id.listView1); final SQLiteDatabase writableDb = new TemplateDatabaseHelper(context).getWritableDatabase(); templateCursor = TemplateDatabase.queryByKey(writableDb, manage ? null : key); templateAdapter = new TemplateAdapter(writableDb, context, templateCursor, manage); lv.setAdapter(templateAdapter); alertDialog.setNegativeButton(R.string.Done, null); alertDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { templateCursor.close(); writableDb.close(); } }); templateDialog = alertDialog.show(); }
private void showDialog() { final MaterialDialog materialDialog = new MaterialDialog(mContext); materialDialog.setCanceledOnTouchOutside(true); materialDialog.setMessage("这里是用来展示的文字信息的东西").setTitle("标题").setPositiveButton("确定", new OnClickListener() { @Override public void onClick(View v) { materialDialog.dismiss(); } }).setNegativeButton("取消", null); materialDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { Toast.makeText(mContext, "运行到关闭了", Toast.LENGTH_SHORT).show(); } }); materialDialog.show(); }
public static final void showProgressDialog(Context context, String title, String message, OnDismissListener onDismissListener) { if (context == null) { return; } dismissDialog(); if (TextUtils.isEmpty(title)) { title = ""; } if (TextUtils.isEmpty(message)) { message = context.getString(R.string.loading); } mProgressDialog = ProgressDialog.show(context, title, message); mProgressDialog.setCancelable(true); mProgressDialog.setCanceledOnTouchOutside(false); mProgressDialog.setOnDismissListener(onDismissListener); }
private void browse() { if (mBrowser == null) { mBrowser = FileBrowser.createFileBrowser(this, "/", ".m3u", new OnFileSelectedListener() { @Override public void onFileSelected(String path) { prepareData(path); if (mBrowser != null && mBrowser.isShowing()) { mBrowser.dismiss(); } } }); mBrowser.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { mBrowse.requestFocus(); } }); } mBrowser.show(); }
public void pmTopicSeeAllPreviousMessagesClick(View view) { seeAllMessagesDialog = new ProgressDialog(this); seeAllMessagesDialog.setCancelable(true); seeAllMessagesDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { stopLoadingAllMessages = true; } }); seeAllMessagesDialog.setTitle(R.string.genericLoading); seeAllMessagesDialog.setIndeterminate(true); seeAllMessagesDialog.setMessage(String.format(getString(R.string.pmTopicLoadedMessages), 0)); seeAllMessagesDialog.show(); allMessagesCounter = 25; currentPage++; loadPreviousMessages(true); }
/** * Displays a dialog to select question sets for voting. Loads selected * question set and sets UI to display values. */ private void loadQuestion() { if (!_isVotingRunning) { String title = getString(R.string.load_question_set); final FileImportDialog dialog = new FileImportDialog(this, new NameXMLFileFilter(), title); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog2) { setCurrentFile(dialog.getSelectedFile()); if (_currentFile != null) { readFile(_currentFile); } } }); dialog.show(); } }
/** * Opens a dialog to choose the voting results from. Triggers file * processing, if a valid file has been selected. */ private void openResults() { String title = getString(R.string.title_load_votes); final FileImportDialog dialog = new FileImportDialog(this, new LectureFileFilter(), title); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog2) { File f = dialog.getSelectedFile(); if (f != null) { readFile(f); } } }); dialog.show(); }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final int selectedPosition = position; final TextInputDialog input = new TextInputDialog(getActivity(), getString(R.string.enter_answer)); input.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { String updatedText = input.getText(); if (!updatedText.equals("")) { _questionModel.getAnswers().set(selectedPosition, updatedText); _answerAdapter.notifyDataSetChanged(); } } }); input.setInputText(_questionModel.getAnswers().get(selectedPosition)); input.show(); }
/** * Method to import qti questions and add them to the current questionset. */ private void importQTI() { String title = getString(R.string.qti_import); final FileImportDialog dialog = new FileImportDialog(this, new ZipFileFilter(), title); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog2) { setQtiFile(dialog.getSelectedFile()); if (_qtiFile != null) { QTIImportService qtiService = new QTIImportService(); QuestionSet questions = qtiService.getQuestions(_qtiFile); for (QuestionModel questionModel : questions) { _currentQuestionset.addQuestionModel(questionModel); } _questionAdapter.notifyDataSetChanged(); // Check if qti import was 100% successful checkQTIAfterImport(qtiService, questions); } } }); dialog.show(); }
/** * Opens a dialog to select previously saved questions. Loads them after * selection. */ private void loadQuestion() { String title = getString(R.string.load_question_set); final FileImportDialog dialog = new FileImportDialog(this, new NameXMLFileFilter(), title); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog2) { File f = dialog.getSelectedFile(); if (f != null) { setCurrentFile(f); readFile(_currentFile); } } }); dialog.show(); }
private static void showErrorDialog(Exception e, android.content.Context androidContext){ // show a dialog AlertDialog alertDialog = new AlertDialog.Builder( androidContext).create(); alertDialog.setTitle("Error starting application"); alertDialog.setMessage("Failed to start the OSGi runtime \n" +e.getMessage()); alertDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { System.exit(-1); } }); alertDialog.show(); }
/** * Show a dialog with the acceleration event settings. */ private void showSettingsDialog() { SettingsDialog dialog = new SettingsDialog(this); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { // Read the new preferences. readPrefs(); } }); dialog.show(); }
@Override protected Dialog onCreateDialog(int id) { switch (id) { case CPU_WARNING_DIALOG: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.app_name).setMessage(R.string.cpu_warning); AlertDialog alert = builder.create(); alert.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { finish(); } }); return alert; } return null; }
/** * Creates a dialog for given message. * * @param activity Parent activity. * @param message Message contents * @param dismissListener Listener that will be called when dialog is closed or * cancelled. * @return Created dialog. */ public static Dialog createMessageDialog(Activity activity, Message message, OnDismissListener dismissListener) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); final String title = message.description == null ? null : message.description.get(MessageDescription.KEY_TITLE); if (!Utilities.isNullOrEmpty(title)) { builder.setTitle(title); } final View dialogContentsView = createMessageDialogContentsView(activity, message.description); builder.setView(dialogContentsView); initializeMessageDialogButtons(activity, builder, message); builder.setCancelable(true); final AlertDialog dialog = builder.create(); if (Utilities.isNullOrEmpty(title)) { dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); } dialog.setOnDismissListener(dismissListener); return dialog; }
private Dialog createDialogInstructions(String title, String msg, String buttonText, OnDismissListener onDismiss) { // Use the custom instruction layout for the dialog. LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layoutInstructions = (LinearLayout) inflater.inflate(R.layout.linearlayout_instructions, null, false); TextView textViewMessage = (TextView) layoutInstructions.findViewById(R.id.TextViewDialogInstructions); Button buttonOK = (Button) layoutInstructions.findViewById(R.id.ButtonDialogInstructionsOK); Dialog dialog = new Dialog(mActivity); dialog.getWindow().setBackgroundDrawableResource(R.color.background_dialog); dialog.setContentView(layoutInstructions); dialog.setTitle(title); dialog.setOnDismissListener(onDismiss); textViewMessage.setText(msg); buttonOK.setText(buttonText); buttonOK.setOnClickListener(mOnClickButtonDialogInstructionsOK); mDialogInstructions = dialog; return mDialogInstructions; }
@Click(R.id.addAccount) public void addAccount() { dialog = new AccountDialog(this, null); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(final DialogInterface paramDialogInterface) { final Account account = dialog.getAccount(); if (account != null) { accounts.add(account); } updateAccounts(); } }); dialog.show(); }
/** * 设置关闭dialog 监听 * * @param listener * @return */ public UIActionSheetView setOnDismissListener(OnDismissListener listener) { dialog.setOnDismissListener(listener); if (lLayoutItem != null) { lLayoutItem.removeAllViews(); } if (lLayoutItem != null) lLayoutItem.removeAllViews(); return this; }
private void updatePresentation() { MediaRouter.RouteInfo route = mediaRouter .getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO); Display presentationDisplay = route != null ? route .getPresentationDisplay() : null; if (displayPresentation != null && displayPresentation.getDisplay() != presentationDisplay) { displayPresentation.dismiss(); displayPresentation = null; } if (displayPresentation == null && presentationDisplay != null) { displayPresentation = new DisplayPresentation(this, presentationDisplay); displayPresentation.setOnDismissListener( new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (dialog == displayPresentation) { displayPresentation = null; } } } ); displayPresentation.show(); displayPresentation.go(displayLayout.getCurrentSlidePos(), displayLayout.getCurrentSlidePhase()); } }
/** * @param autoPlay 是否自动播放提示 * @return */ @TargetApi(Build.VERSION_CODES.KITKAT) public GuideHelper show(boolean autoPlay) { this.autoPlay = autoPlay; //关闭dialog,移除handler消息 dismiss(); handler.removeCallbacksAndMessages(null); //创建dialog layout = new InnerChildRelativeLayout(activity); baseDialog = new Dialog(activity, android.R.style.Theme_DeviceDefault_Light_DialogWhenLarge_NoActionBar); baseDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0x66000000)); //设置沉浸式状态栏 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WindowManager.LayoutParams localLayoutParams = baseDialog.getWindow().getAttributes(); localLayoutParams.flags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; localLayoutParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; } baseDialog.setContentView(layout); //设置dialog的窗口大小全屏 baseDialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); //dialog关闭的时候移除所有消息 baseDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { handler.removeCallbacksAndMessages(null); if (onDismissListener != null) { baseDialog.setOnDismissListener(onDismissListener); } } }); //显示 baseDialog.show(); startSend(); return this; }
private void showMemoryLowDialog() { memoryLowDialog = new ErrorDialog(this, getString(R.string.memory_low_title), getString(R.string.memory_low_message)); memoryLowDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { ShowModuleActivity.this.finish(); } }); memoryLowDialog.show(); }
/** * 显示推荐话题的Dialog</br> */ private void showRecommendTopic() { if (mRecommendTopicFragment == null) { mRecommendTopicFragment = RecommendTopicFragment.newRecommendTopicFragment(); mRecommendTopicFragment.setSaveButtonInVisiable(); mRecommendTopicFragment.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { showFindPage(); } }); } showCommFragment(mRecommendTopicFragment); }
/** * 显示话题引导页面</br> */ private void showTopicFragment() { RecommendTopicFragment topicRecommendDialog =RecommendTopicFragment.newRecommendTopicFragment(); topicRecommendDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { showRecommendUserFragment(); } }); addFragment(mContainer, topicRecommendDialog); }