public void testCallback() throws Throwable { final WritableMap options = new WritableNativeMap(); options.putDouble("date", getDateInMillis(2020, 5, 6)); final DialogFragment datePickerFragment = showDialog(options); runTestOnUiThread( new Runnable() { @Override public void run() { ((DatePickerDialog) datePickerFragment.getDialog()) .getButton(DialogInterface.BUTTON_POSITIVE).performClick(); } }); getInstrumentation().waitForIdleSync(); waitForBridgeAndUIIdle(); assertEquals(0, mRecordingModule.getErrors()); assertEquals(1, mRecordingModule.getDates().size()); assertEquals(2020, (int) mRecordingModule.getDates().get(0)[0]); assertEquals(5, (int) mRecordingModule.getDates().get(0)[1]); assertEquals(6, (int) mRecordingModule.getDates().get(0)[2]); }
public void testDismissCallback() throws Throwable { final DialogFragment fragment = showDialog(null); assertEquals(0, mRecordingModule.getDismissed()); runTestOnUiThread( new Runnable() { @Override public void run() { fragment.getDialog().dismiss(); } }); getInstrumentation().waitForIdleSync(); waitForBridgeAndUIIdle(); assertEquals(0, mRecordingModule.getErrors()); assertEquals(0, mRecordingModule.getTimes().size()); assertEquals(1, mRecordingModule.getDismissed()); }
public void onEventMainThread(ThrowableFailureEvent event) { if (!isInExecutionScope(executionScope, event)) { return; } checkLogException(event); // Execute pending commits before finding to avoid multiple error fragments being shown FragmentManager fm = getFragmentManager(); fm.executePendingTransactions(); DialogFragment existingFragment = (DialogFragment) fm.findFragmentByTag(TAG_ERROR_DIALOG); if (existingFragment != null) { // Just show the latest error existingFragment.dismiss(); } DialogFragment errorFragment = (DialogFragment) factory .prepareErrorFragment(event, finishAfterDialog, argumentsForErrorDialog); if (errorFragment != null) { errorFragment.show(fm, TAG_ERROR_DIALOG); } }
/** * 监听返回键 */ private void onBackPressed() { //设置窗口以对话框样式显示 setStyle(DialogFragment.STYLE_NO_TITLE, R.style.Dialog); //设置对话框背景色,否则有虚框 getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); getDialog().setCancelable(isCancelable); getDialog().setCanceledOnTouchOutside(isCancelableTouchOutSide); getDialog().setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { if (isBack) { onCancel(); } return !isBack; } return false; } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_guide); ArrayList<Integer> layouts = new ArrayList<>(); List<Integer> list = Arrays.asList(R.layout.view_guide_one, R.layout.view_guide_two, R.layout.view_guide_three, R.layout.view_guide_four); layouts.addAll(list); DialogFragment guideFg = GuideFragment.newInstance(0.85f, 0.7f, layouts); FragmentManager fm = getSupportFragmentManager(); guideFg.show(fm, "guide fg"); }
public void onEventMainThread(ThrowableFailureEvent event) { if (!isInExecutionScope(executionScope, event)) { return; } checkLogException(event); // Execute pending commits before finding to avoid multiple error fragments being shown android.app.FragmentManager fm = getFragmentManager(); fm.executePendingTransactions(); android.app.DialogFragment existingFragment = (android.app.DialogFragment) fm .findFragmentByTag(TAG_ERROR_DIALOG); if (existingFragment != null) { // Just show the latest error existingFragment.dismiss(); } android.app.DialogFragment errorFragment = (android.app.DialogFragment) factory.prepareErrorFragment(event, finishAfterDialog, argumentsForErrorDialog); if (errorFragment != null) { errorFragment.show(fm, TAG_ERROR_DIALOG); } }
/** * Factory method for creating the DialogFragment with a listener. * @param item QuadrantItem being manipulated * @param listener Listener for passing back the information to update item in QuadrantItem * @return New EditItemDialogFragment instance */ public static DialogFragment newInstance(QuadrantItem item, ModifyItemListener listener, String title) { // Initialize new EditItemDialogFragment fragment DialogFragment dialog = new EditItemDialogFragment(); // Pass itemUid to onCreateDialog Bundle args = new Bundle(); args.putParcelable("quadrantItem", item); dialog.setArguments(args); // Set the listener ((EditItemDialogFragment) dialog).setListener(listener); ((ModifyItemDialogFragment) dialog).setTitle(title); // Return the dialog return dialog; }
@Override protected View createView(ViewGroup parent) { View root = LayoutInflater.from(parent.getContext()) .inflate(R.layout.dialog_option, parent, false); TextView title = (TextView) root.findViewById(R.id.preference_dialog_title); TextView detail = (TextView) root.findViewById(R.id.preference_dialog_description); mDetailTextView = new WeakReference<>(detail); title.setText(getTitle()); detail.setText(getSelection().getName()); root.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment fragment = ListDialogFragment.create(getValues(), getSelection()); fragment.setTargetFragment(getFragment(), getOptionId()); fragment.show(getFragment().getFragmentManager(), DIALOG_TAG); } }); return root; }
public void testPresetDate() { final WritableMap options = new WritableNativeMap(); options.putDouble("date", getDateInMillis(2020, 5, 6)); final DialogFragment datePickerFragment = showDialog(options); final DatePicker datePicker = ((DatePickerDialog) datePickerFragment.getDialog()).getDatePicker(); assertEquals(2020, datePicker.getYear()); assertEquals(5, datePicker.getMonth()); assertEquals(6, datePicker.getDayOfMonth()); }
@Override public void onNoteEditPositiveClock(String str, DialogFragment dialog) { ContentValues values = new ContentValues(); values.put(ActivityDiaryContract.Diary.NOTE, str); mQHandler.startUpdate(0, null, mCurrentDiaryUri, values, null, null); mNoteTextView.setText(str); ActivityHelper.helper.setCurrentNote(str); }
protected boolean dismissDialog() { boolean isVisible = false; Fragment prev = getSupportFragmentManager().findFragmentByTag(LoadingDialog.DIALOG_TAG); if (prev != null) { DialogFragment df = (DialogFragment) prev; df.dismiss(); isVisible = true; } return isVisible; }
@NonNull @Override protected DialogFragment onCreateDialogFragment(String key) { final HttpUriPreferenceDialogFragment fragment = new HttpUriPreferenceDialogFragment(); final Bundle b = new Bundle(1); b.putString(PreferenceDialogFragment.ARG_KEY, key); b.putString(HttpUriPreferenceDialogFragment.ARG_KEY_USERNAME, keyUsername); b.putString(HttpUriPreferenceDialogFragment.ARG_KEY_PASSWORD, keyPassword); fragment.setArguments(b); return fragment; }
@Override public void onCreateHomeScreenShortcutCreate(DialogFragment dialog) { Intent bookmarkShortcut = new Intent(); bookmarkShortcut.setAction(Intent.ACTION_VIEW); bookmarkShortcut.setData(Uri.parse(UrlCleaner)); Intent shortcutMaker = new Intent(); shortcutMaker.putExtra("duplicate", false); shortcutMaker.putExtra("android.intent.extra.shortcut.INTENT", bookmarkShortcut); shortcutMaker.putExtra("android.intent.extra.shortcut.ICON", favoriteIcon); shortcutMaker.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); sendBroadcast(shortcutMaker); }
public void showDialog(ArrayList<Boolean> state) { FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment prev = getFragmentManager().findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); //String inputText = inputTextField.getText().toString(); DialogFragment newFragment = MyDialogFragment.newInstance(state, list); newFragment.show(ft, "dialog"); }
private void showDialog(final DialogFragment dialog, final String nameOfFragment) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); final Fragment prev = getSupportFragmentManager().findFragmentByTag(nameOfFragment); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); dialog.show(ft, nameOfFragment); }
private static void showFileDialog(FragmentActivity activity, FileDialog dialog) { Bundle args = new Bundle(); args.putString(FileDialog.EXTENSION, REPOSITORY_EXTENSION); dialog.setArguments(args); dialog.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.AppTheme); dialog.show(activity.getSupportFragmentManager(), OpenFileDialog.class.getName()); }
private void showChooserDialog(DialogFragment dialogFragment) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); Fragment prev = getSupportFragmentManager().findFragmentByTag(TAG_DIALOG); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); dialogFragment.show(ft, "dialog"); }
@Override public void onDialogPositiveClick(DialogFragment dialog, TaskItem dataModel) { int position=TaskItem.findTaskPosition((ArrayList) mainList,dataModel.getTask()); Log.d("MainActivity",mainList.get(position).getDeadlineDate()+", new: "+dataModel.getDeadlineDate()); mainList.get(position).setDeadlineDate(dataModel.getDeadlineDate()); ad.notifyDataSetChanged(); }
public void dismissDialog() { final FragmentManager fm = getFragmentManager(); if (fm == null) return; Fragment prev = fm.findFragmentByTag("cadfragment"); if (prev != null) { DialogFragment df = (DialogFragment) prev; df.dismiss(); } }
/** * click 'Close'in the Memo Dialog. * @param dialog the Memo Dialog. */ @Override public void onMemoDialogCloseClick(DialogFragment dialog){ if(dialog == null){ throw new IllegalArgumentException("Invalid argument 'dialog' on onMemoDialogCloseClick method"); } }
private DialogFragment showDialog(WritableMap options) { getTestModule().showDatePickerDialog(options); waitForBridgeAndUIIdle(); getInstrumentation().waitForIdleSync(); return (DialogFragment) getActivity().getSupportFragmentManager() .findFragmentByTag(DatePickerDialogModule.FRAGMENT_TAG); }
public void showAllowingStateLost(DialogFragment fragment, FragmentActivity activity) { if (activity != null) { FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); ft.add(fragment, RPConstant.RP_PACKET_DIALOG_TAG); ft.commitAllowingStateLoss(); } }
public void hideDialog() { DialogFragment dialogFragment = (DialogFragment) mFragmentManager.findFragmentByTag(TAG); if (dialogFragment == null) { throw new IllegalStateException("Dialog is not visible."); } dialogFragment.dismiss(); mFragmentManager.executePendingTransactions(); }
private DialogFragment showDialog(WritableMap options) { getTestModule().showTimePickerDialog(options); waitForBridgeAndUIIdle(); getInstrumentation().waitForIdleSync(); return (DialogFragment) getActivity().getSupportFragmentManager() .findFragmentByTag(TimePickerDialogModule.FRAGMENT_TAG); }
protected void showDialog() { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); Fragment prev = getSupportFragmentManager().findFragmentByTag(LoadingDialog.DIALOG_TAG); if (prev == null) { ft.addToBackStack(null); DialogFragment newFragment = LoadingDialog.newInstance(); newFragment.show(ft, LoadingDialog.DIALOG_TAG); } }
/** * click 'Accept' in a Challenge Dialog. * @param dialog the Challenge Dialog. */ @Override public void onSendChallengeDialogPositiveClick(DialogFragment dialog) { if(dialog == null){ throw new IllegalArgumentException("Invalid argument 'dialog' on onSendChallengeDialogPositiveClick method"); } Challenge.Type challengeType = ((RequestChallengeDialogFragment)dialog).getType(); int firstValue = ((RequestChallengeDialogFragment)dialog).getFirstValue(); int secondValue = ((RequestChallengeDialogFragment)dialog).getSecondValue(); // Send message String from = ((AppRunnest) getApplication()).getUser().getEmail(); String to = FirebaseHelper.getFireBaseMail(challengedUserEmail); String sender = ((AppRunnest) getApplication()).getUser().getName(); Random rnd = new Random(); int rndNumber = 100000 + rnd.nextInt(900000); String message = Integer.toString(rndNumber); Date timestampId = new Date(); Message challengeRequestMessage = new Message(from, to, sender, challengedUserName, Message.Type.CHALLENGE_REQUEST, message, timestampId, firstValue, secondValue, challengeType); FirebaseHelper firebaseHelper = new FirebaseHelper(); firebaseHelper.sendMessage(challengeRequestMessage); Intent intent = new Intent(this, ChallengeActivity.class); intent.putExtra("type", challengeType); intent.putExtra("firstValue", firstValue); intent.putExtra("secondValue", secondValue); intent.putExtra("owner", true); intent.putExtra("opponent", challengedUserName); intent.putExtra("msgId", message); searchView.setQuery("", false); //TODO define result code startActivityForResult(intent, 1); }
/** * Shows a dialog UI to the user. Only one dialog will be shown at a time and if there is * already an existing one it will be replaced. This can be used for showing application or * block specific UIs, such as a mutator UI. When the user finishes using the fragment * {@link #closeDialogFragment()} should be called. * * @param fragment The fragment to show. */ public void showDialogFragment(@NonNull DialogFragment fragment) { if (fragment == mDialogFragment) { return; } FragmentTransaction ft = mActivity.getSupportFragmentManager().beginTransaction(); if (mDialogFragment != null) { ft.remove(mDialogFragment); } fragment.show(ft, "blockly_dialog"); mDialogFragment = fragment; }
@Override public void showDiaryEntryDeletionMessage(final int position) { mDeletionPosition = position; DialogFragment newFragment = new DeleteDiaryEntryDialogFragment(); newFragment.setTargetFragment(this, ENTRY_DELETION_REQ_CODE); newFragment.show(getFragmentManager(), "delete entry"); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStyle(DialogFragment.STYLE_NO_TITLE, R.style.BottomDialog); //创建Presenter mPresenter = createPresenter(); //内存泄漏 //关联View mPresenter.attachView((V) this); mDisposableContainer = new ListCompositeDisposable(); mActivityContext = getContext(); L.logFile("创建fragment:" + getClass().getSimpleName()); }
public static void showDialog(FragmentManager manager, DialogFragment fragment) { FragmentTransaction ft = manager.beginTransaction(); Fragment prev = manager.findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); fragment.show(ft, "dialog"); }
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStyle(DialogFragment.STYLE_NO_TITLE, R.style.AppTheme_AppCompat_Dialog_Alert); mCurrentTheme = ThemeHelper.getTheme(getActivity()); }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Action bar menu item selected switch (item.getItemId()) { case R.id.menu_debug: new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void... voids) { if (locBound) { return locService.dumpDebugInfo(); } return ""; } @Override protected void onPostExecute(String s) { if (!isFinishing() && isVisible) { DialogFragment newFragment = HtmlDialogFragment.newInstance(s, false); newFragment.show(getSupportFragmentManager(), "debugtext"); } } }.execute(); return true; } return super.onOptionsItemSelected(item); }
/** * Launch Stage Editor Dialog where the user can manipulate the Stage's properties. */ private void showStageEditorDialog() { // Get correct Stage. Stage stage = mTimeControl.getStageManager().getStages()[mEditableStageIndex]; // Setup Stage Editor Dialog. DialogFragment newFragment = new StageEditorDialogFragment(getActivity(), stage); newFragment.setTargetFragment(this, REQUEST_STAGE_DIALOG); // Launch Stage Editor Dialog. newFragment.show(getActivity().getSupportFragmentManager(), TAG_STAGE_EDITOR_DIALOG_FRAGMENT); }
private void dismissPictureChooserDialog() { Fragment prev = getSupportFragmentManager().findFragmentByTag("fragment_dialog"); if (prev != null) { DialogFragment df = (DialogFragment) prev; df.dismissAllowingStateLoss(); } }
@Nullable @Override public DialogFragment onCreatePreferenceDialog(Preference preference) { if (preference instanceof NowPlayingScreenPreference) { return NowPlayingScreenPreferenceDialog.newInstance(); } else if (preference instanceof BlacklistPreference) { return BlacklistPreferenceDialog.newInstance(); } else if (preference instanceof LibraryPreference) { return LibraryPreferenceDialog.newInstance(); } return super.onCreatePreferenceDialog(preference); }
@Override public void onItemLongClick(QuadrantItem item) { FragmentManager manager = getActivity().getSupportFragmentManager(); // Get a new instance of the AddItemDialogFragment DialogFragment dialog = EditItemDialogFragment.newInstance(item, new AddItemOnClickListener(presenter.getMatrixPresenter().getPager()), getString(R.string.edit_item)); // Show the dialog and set its tag. dialog.show(manager, "Edit Item"); }