@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); Task t = mAdapter.getItem(info.position); current = info.position; switch (item.getItemId()) { case R.id.due_date: DialogFragment newFragment = new DatePickerFragment(); newFragment.show(getFragmentManager(), "datePicker"); return true; case R.id.remove_due_date: t.setDueYear(0); t.saveEventually(); mAdapter.notifyDataSetChanged(); return true; case R.id.delete: try { t.delete(); } catch (ParseException e) { e.printStackTrace(); } mAdapter.remove(t); mAdapter.notifyDataSetChanged(); return true; default: mAdapter.notifyDataSetChanged(); return super.onContextItemSelected(item); } }
/** * Display the info of this photo. * * @param activity the triggering activity * @param eyePhoto the photo for which the image should be displayed. */ public static void displayImageInfo( @NonNull final Activity activity, @NonNull final EyePhoto eyePhoto) { StringBuilder message = new StringBuilder(); message.append( formatImageInfoLine(activity, R.string.imageinfo_line_filename, eyePhoto.getFilename())); message.append( formatImageInfoLine(activity, R.string.imageinfo_line_filedate, eyePhoto.getDateString())); try { JpegMetadata metadata = JpegSynchronizationUtil.getJpegMetadata(eyePhoto.getAbsolutePath()); if (metadata.getPerson() != null && metadata.getPerson().length() > 0) { message.append( formatImageInfoLine(activity, R.string.imageinfo_line_name, metadata.getPerson())); } if (metadata.getComment() != null && metadata.getComment().length() > 0) { message.append( formatImageInfoLine(activity, R.string.imageinfo_line_comment, metadata.getComment())); } } catch (Exception e) { // cannot append metadata. } Bundle bundle = new Bundle(); bundle.putCharSequence(PARAM_MESSAGE, Html.fromHtml(message.toString())); bundle.putString(PARAM_TITLE, activity.getString(R.string.title_dialog_image_info)); bundle.putInt(PARAM_ICON, R.drawable.ic_title_info); DialogFragment fragment = new DisplayMessageDialogFragment(); fragment.setArguments(bundle); fragment.show(activity.getFragmentManager(), fragment.getClass().toString()); }
@Override protected void onPostExecute(Exception e) { super.onPostExecute(e); pd.dismiss(); if (e == null) { Toast.makeText(SshKeyGen.this, "SSH-key generated", Toast.LENGTH_LONG).show(); DialogFragment df = new ShowSshKeyFragment(); df.show(getFragmentManager(), "public_key"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("use_generated_key", true); editor.apply(); } else { new AlertDialog.Builder(SshKeyGen.this) .setTitle("Error while trying to generate the ssh-key") .setMessage( getResources().getString(R.string.ssh_key_error_dialog_text) + e.getMessage()) .setPositiveButton( getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // pass } }) .show(); } }
/** Show edit list name dialog when user selects "Edit list name" menu item */ public void showEditListNameDialog() { /* Create an instance of the dialog fragment and show it */ DialogFragment dialog = EditListNameDialogFragment.newInstance( mShoppingList, mListId, mEncodedEmail, mSharedWithUsers); dialog.show(this.getFragmentManager(), "EditListNameDialogFragment"); }
@Override public void onClick(final DialogInterface dialogInterface, final int arg1) { // TODO add person final EditText nameView = (EditText) view.findViewById(R.id.person_name); final DatePicker birthView = (DatePicker) view.findViewById(R.id.person_birth); final String name = nameView.getText().toString(); final LocalDate birthDate = DateExtractor.extractRequestDate(birthView); final String birth = birthDate.toString(); final Person person = Person.createNew(name, birth); final PersonProvider prov = new PersonProvider(new PersonFileProvider()); final boolean added = prov.addPerson(person); // TODO update list of persons // on success, error // msg otherwise if (added) { final ListView personsView = new ViewProvider().getPersonsListView(dialogFragment.getActivity()); // TODO persons list must have a dynamic datasource // this way changes are not transported to the list view final ArrayAdapter<String> adapter = (ArrayAdapter<String>) personsView.getAdapter(); adapter.add(person.getName()); adapter.notifyDataSetChanged(); // notify the handler notify(handler, person); } dialogFragment.getDialog().dismiss(); }
public void showSelectDayDialog() { final ViewPager viewPager = (ViewPager) view.findViewById(R.id.pager); final Activity a = getActivity(); final Calendar cCal = Calendar.getInstance(); cCal.add(Calendar.DAY_OF_YEAR, viewPager.getCurrentItem() - 500); DialogFragment ds = new DialogFragment() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new DatePickerDialog( a, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet( DatePicker view, int year, int monthOfYear, int dayOfMonth) { Calendar nCal = Calendar.getInstance(); nCal.set(Calendar.YEAR, year); nCal.set(Calendar.MONTH, monthOfYear); nCal.set(Calendar.DAY_OF_MONTH, dayOfMonth); long timeDelta = nCal.getTimeInMillis() - cCal.getTimeInMillis(); int dayDelta = (int) (timeDelta / (60000 * 60 * 24)); viewPager.setCurrentItem(viewPager.getCurrentItem() + dayDelta); } }, cCal.get(Calendar.YEAR), cCal.get(Calendar.MONTH), cCal.get(Calendar.DAY_OF_MONTH)); } }; ds.show(getActivity().getFragmentManager(), "datepicker"); }
@Override public void onClick(View v) { DialogFragment datePickerFragment = new DatePicker_Dialog_Fragment() { int yy, mm, dd; boolean timerOpened = false; @Override public void onDateSet(DatePicker view, int year, int month, int day) { Calendar c = Calendar.getInstance(); c.set(year, month, day); yy = year; mm = month + 1; dd = day; DialogFragment timePickerFragment = new TimePicker_Dialog_Fragment() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { super.onTimeSet(view, hourOfDay, minute); timerOpened = false; editText_in_time_date.setText( dd + "/" + mm + "/" + yy + " " + hourOfDay + ":" + minute); } }; if (!timerOpened) { timerOpened = true; timePickerFragment.show(getActivity().getFragmentManager(), "timePicker"); } } }; datePickerFragment.show(getActivity().getFragmentManager(), "datePicker"); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @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(); switch (id) { /*case R.id.action_settings: Intent newIntent = new Intent(getApplicationContext(), SettingsActivity.class); startActivity(newIntent); return true;*/ case R.id.action_exit: Toast myToast = Toast.makeText(this, R.string.chao, Toast.LENGTH_SHORT); myToast.show(); moveTaskToBack(true); return true; case R.id.action_about: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { DialogFragment dialog = new About(); dialog.show(getFragmentManager(), "test"); } else { showAlert(R.string.about, R.string.createdBy); } return true; default: return super.onOptionsItemSelected(item); } }
@Override protected void populateContent(ViewGroup content) { activity.findViewById(R.id.wonder).setEnabled(false); activity.findViewById(R.id.summary).setEnabled(true); activity.findViewById(R.id.hand).setEnabled(true); activity .findViewById(R.id.help) .setOnClickListener( view -> { DialogFragment helpDialog = new HelpDialog(); Bundle bundle = new Bundle(); bundle.putString(HelpDialog.TITLE, activity.getString(R.string.help_wonder_title)); bundle.putString(HelpDialog.MESSAGE, activity.getString(R.string.help_wonder)); helpDialog.setArguments(bundle); helpDialog.show(activity.getFragmentManager(), "helpDialog"); }); for (Card card : playerViewing.getWonder().getStages()) { CardView cv = new CardView(card, activity, playerViewing, false, false); if (!playerViewing.getPlayedCards().contains(card)) { cv.setText(activity.getString(R.string.not_built, cv.getText())); } content.addView(cv); } for (Card card : playerViewing.getPlayedCards()) { if (card.getType() == Card.Type.STAGE) continue; CardView cv = new CardView(card, activity, playerViewing, false, false); content.addView(cv); } }
/** Show the add list item dialog when user taps "Add list item" fab */ public void showAddListItemDialog(View view) { /* Create an instance of the dialog fragment and show it */ DialogFragment dialog = AddListItemDialogFragment.newInstance( mShoppingList, mListId, mEncodedEmail, mSharedWithUsers); dialog.show(getFragmentManager(), "AddListItemDialogFragment"); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.next: FragmentTransaction ft = getFragmentManager().beginTransaction(); Bundle args = new Bundle(); String host_path = editBaseURI.getText().toString(); args.putString( QueryServerDialogFragment.EXTRA_BASE_URI, URLUtils.sanitize(scheme + host_path)); args.putString( QueryServerDialogFragment.EXTRA_USER_NAME, editUserName.getText().toString()); args.putString(QueryServerDialogFragment.EXTRA_PASSWORD, editPassword.getText().toString()); args.putBoolean( QueryServerDialogFragment.EXTRA_AUTH_PREEMPTIVE, checkboxPreemptive.isChecked()); DialogFragment dialog = new QueryServerDialogFragment(); dialog.setArguments(args); dialog.show(ft, QueryServerDialogFragment.class.getName()); break; default: return false; } return true; }
public void onClickPositiveBtn(DialogFragment dialogFragment, String id) { if ("add_fir".equals(dialogFragment.getTag())) { // OnAddFIR(5000, id); } else if ("remove".equals(dialogFragment.getTag())) { // OnRemoveUser(id); } }
private void openSettings() { try { DialogFragment newFragment = SettingsDialogFragment.newInstance(AppState.SUBSCRIBE); newFragment.show(getFragmentManager().beginTransaction(), "settings_dialog"); } catch (Exception e) { Log.i(TAG, "Can't open settings: " + e.getMessage()); } }
private void showCreateGameChooser() { DialogFragment fr = new CreateGameDialog(); Bundle args = new Bundle(); args.putInt(CreateGameDialog.ARGUMENT_GAME_TYPE, CreateGameDialog.MULTIPLAYER_GAME_TYPE); args.putBoolean(CreateGameDialog.ARGUMENT_IS_HOST, true); fr.setTargetFragment(this, 1000); ApplicationUtils.openDialogFragment(getActivity(), fr, args); }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getTitle().equals("Show XML")) { final DialogFragment dialog = newDialogFragment(mText.toString()); dialog.show(getFragmentManager(), "Show XML"); } return false; }
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference p) { // Show TimePickerDialog if the prefAlarmTime was clicked if (p.getKey().equals("prefAlarmTime")) { DialogFragment newFragment = new AlarmPicker(); newFragment.show(this.getFragmentManager(), "timePicker"); } return super.onPreferenceTreeClick(preferenceScreen, p); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_add: DialogFragment newFragment = new FragmentDialogAddEdit(); newFragment.show(getFragmentManager(), STRING_ADD_ITEM); } return super.onOptionsItemSelected(item); }
/** * Helper method which edits selected city by showing dialog with filled views from selected city. * * @param cityToEdit city that need to be edited * @return true to handle context menu for selected city in list view */ private boolean editCity(City cityToEdit) { Bundle cityBundle = new Bundle(); cityBundle.putSerializable(STRING_CURRENT_CITY, cityToEdit); DialogFragment newFragment = new DialogFragmentAddEdit(); newFragment.setArguments(cityBundle); newFragment.show(getFragmentManager(), "edit_city"); return true; }
@Override public void onNewItemClick() { Bundle bundle = new Bundle(); Purchase purchase = new Purchase(); bundle.putParcelable(Purchase.PARCELABLE_NAME, purchase); DialogFragment dialog = new PurchaseDialog(); dialog.setArguments(bundle); dialog.show(getFragmentManager(), "ADD"); }
@Override public void onDateSet(DatePicker view, int year, int month, int day) { // MainActivity.date = year + " " + month + " " + day; MainActivity.dpYear = year; MainActivity.dpMonth = month; MainActivity.dpDay = day; DialogFragment newFragment = new TimePickerFragment(); newFragment.show(getFragmentManager(), "timePicker"); // #FF4081 }
/** * Helper method which edits selected item by showing dialog with filled views from selected item. * * @param itemToEdit item that need to be edited * @return true to handle context menu for selected item in list view */ private boolean editItem(Item itemToEdit) { Bundle itemBundle = new Bundle(); itemBundle.putSerializable(STRING_CURRENT_ITEM, itemToEdit); DialogFragment newFragment = new FragmentDialogAddEdit(); newFragment.setArguments(itemBundle); newFragment.show(getFragmentManager(), STRING_EDIT_ITEM); return true; }
/** Displays a generic 'information' dialog */ private void showInformationDialog(String title, String body) { FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment prev = getFragmentManager().findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } // Create and show the dialog. DialogFragment newFragment = InformationDialogFragment.newInstance(title, body, true, null); newFragment.show(ft, "dialog"); }
@Override public void onDateRePicker(double which, int year, int month, int day) { Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day); // Make sure the dates picked were not in the past // if (calendar.before(Calendar.getInstance())) // ApplicationHelper.toastShort(getApplicationContext(), "The date picked cannot be // before today"); /*else*/ switch ((int) which) { case 1: // Start date start = calendar; if (end != null) { if (start.before(end)) textStartDate.setText("Pick Up on\n" + ApplicationHelper.printDateCalendar(start)); else { end.setTimeInMillis(start.getTimeInMillis()); end.add(Calendar.DAY_OF_MONTH, 2); textStartDate.setText("Pick Up on\n" + ApplicationHelper.printDateCalendar(start)); textEndDate.setText("Drop off on\n" + ApplicationHelper.printDateCalendar(end)); } setCost(2, ""); } else { DialogFragment newFragment = TimePickerFragment.newInstance( 1, start.get(Calendar.HOUR_OF_DAY), start.get(Calendar.MINUTE)); newFragment.show(getFragmentManager(), "startTimePicker"); } break; case 2: // End date // Change the calendar time to 0, so that the user cannot choose the end date as the same // date as the start date calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 1); if (calendar.after(start)) { end = calendar; // Send the end time to the same of that of the start time end.set(Calendar.HOUR_OF_DAY, start.get(Calendar.HOUR_OF_DAY)); end.set(Calendar.MINUTE, start.get(Calendar.MINUTE)); end.set(Calendar.SECOND, start.get(Calendar.SECOND)); end.set(Calendar.MILLISECOND, start.get(Calendar.MILLISECOND)); // Display the date and time textEndDate.setText("Drop Off on\n" + ApplicationHelper.printDateCalendar(calendar)); textEndTime.setText("Drop Off at\n" + ApplicationHelper.printTimeCalendar(end)); // Adjust the cost setCost(2, ""); } else { // The end date selected was before the start date ApplicationHelper.toastShort(getApplicationContext(), "Select Date After the Start Date"); } break; } }
public static void dialogFragmentShowDialogFragment( Activity fragmentActivity, DialogFragment dialogFragment) { FragmentManager fm = fragmentActivity.getFragmentManager(); String tag = dialogFragment.getClass().getName(); FragmentTransaction ft = fm.beginTransaction(); Fragment f = fm.findFragmentByTag(tag); if (f != null) { ft.remove(f); } dialogFragment.show(ft, tag); }
public void onClick(View v) { if (v.getId() == R.id.requestQueue) { Intent i = new Intent(getApplicationContext(), RequestActivity.class); startActivity(i); } else if (v.getId() == R.id.resetDatabase) { final Bundle bundle = new Bundle(); bundle.putInt("id", ZandyDialogFragment.DIALOG_CONFIRM_DELETE); bundle.putInt("title", R.string.settings_reset_database_warning); DialogFragment newFragment = ZandyDialogFragment.newInstance(this, bundle); newFragment.show(getFragmentManager(), "settings_reset_database_warning"); } }
public void onResume() { super.onResume(); ((FragmentActivity) getActivity()).getSupportLoaderManager().getLoader(LOADER_ID).forceLoad(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); if (sp.contains(BasicMenuActivityNew.TRAININGS_DONE_NUM) && sp.getInt(BasicMenuActivityNew.TRAININGS_DONE_NUM, 0) > 5 && !sp.contains(BasicMenuActivityNew.MARKET_LEAVED_FEEDBACK)) { DialogFragment dialog = new DialogGoToMarket(); dialog.show(getActivity().getFragmentManager(), "dialog_goto_market"); dialog.setCancelable(false); } }
@Override protected void onPostExecute(Boolean result) { if (dialog.isShowing()) { dialog.dismiss(); } if (food != null) { // display confirmation prompt containing nutrition info DialogFragment dialog = FoodInfoFragment.newInstance(food, false); dialog.show(getFragmentManager(), "FoodInfoFragment"); } }
/* image activity filter button listener */ public void filterBtnListener(View view) { // Do something in response to button click setBtnEnable(false); DialogFragment newFragment = new FilterDialog(); Bundle args = new Bundle(); ArrayList<String> filterStr = new ArrayList<String>(); for (Word w : filterWord) { filterStr.add(w.str + " " + w.freq); } args.putStringArrayList(FILTER, filterStr); newFragment.setArguments(args); newFragment.show(getFragmentManager(), "filter"); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_add_category: FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.addToBackStack(null); NewCategoryDialogFragment newCategoryFragment = new NewCategoryDialogFragment(); newCategoryFragment.show(ft, "dialog"); return true; case R.id.menu_settings: Intent settingsIntent = new Intent(getActivity(), SettingsActivity.class); startActivity(settingsIntent); return true; case R.id.menu_about: DialogFragment newFragment = AboutDialogFragment.newInstance(); newFragment.show(getFragmentManager(), "about_dialog"); return true; case R.id.menu_feedback: Intent myIntent = new Intent(android.content.Intent.ACTION_SEND); myIntent.setType("text/plain"); myIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.menu_feedback_subject)); myIntent.putExtra( Intent.EXTRA_EMAIL, new String[] {getString(R.string.menu_feedback_address)}); startActivity( Intent.createChooser( myIntent, getResources().getString(R.string.feedback_chooser_title))); return true; case R.id.menu_share: Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.menu_share_subject)); shareIntent.putExtra( Intent.EXTRA_TEXT, getString(R.string.menu_share_url)); // TODO: fkt. das? startActivity( Intent.createChooser( shareIntent, getResources().getString(R.string.feedback_chooser_title))); return true; case android.R.id.home: Intent intent = new Intent(getActivity().getApplicationContext(), MainActivity.class); MyApplication.showRunningTimers = true; intent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); getActivity().getApplication().startActivity(intent); return true; default: break; } return super.onOptionsItemSelected(item); }
@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.more_info) { DialogFragment newFragment = AlertDialogFragment.newInstance(); newFragment.show(getFragmentManager(), "dialog"); } return super.onOptionsItemSelected(item); }