/** 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");
 }
  /**
   * 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
  public void onClick(View v) {
    if (v.getId() != R.id.inBag) {
      if (selectDishCount != v) {
        selectOffButton(selectDishCount);
        selectOnButton((Button) v);
      }
    } else {
      BoxAdapter.object
          .get(mViewPager.getCurrentItem())
          .setCountOrder(Integer.valueOf(String.valueOf(selectDishCount.getTag())));
      AppController.getInstance().addInBag(BoxAdapter.object.get(mViewPager.getCurrentItem()));
      mainActivity.updateBagPrice();

      dialogInBag.show(mainActivity.getFragmentManager(), "dialogInBag");
      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  try {
                    Thread.sleep(1000);
                  } catch (InterruptedException e) {
                    e.printStackTrace();
                  }
                  dialogInBag.dismiss();
                }
              })
          .start();
    }
  }
        @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");
        }
  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 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;
  }
  @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);
    }
  }
 private void sendIdleWarning() {
   if (mIdleDialogShowing) {
     return;
   }
   mIdleDialogFragment.show(getFragmentManager(), "idle");
   mIdleDialogShowing = true;
 }
 @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);
   }
 }
Exemple #10
0
  @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);
    }
  }
 @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 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");
 }
Exemple #13
0
 @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;
 }
 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());
   }
 }
 @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);
 }
 @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
 }
  @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");
  }
  /**
   * 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;
  }
  /**
   * 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;
  }
  @Override
  public void onDialogPositiveClick(DialogFragment dialog) {
    // User touched the dialog's positive button - "Add to Meal"
    FoodInfoFragment frag = (FoodInfoFragment) dialog;

    if (replacedFood == null) {
      // First prompt for density or servings
      if (frag.food.usesMass()) {
        if (FoodItem.getAllDensities() == null) {
          displayToast("Error: Cannot access densities.", this);
          return;
        }
        findDensityMatches(frag.food);
      } else if (!frag.food.usesVolume()) {
        DialogFragment servingsDialog = FoodServingFragment.newInstance(frag.food, false);
        servingsDialog.show(getFragmentManager(), "FoodServingFragment");
      } else {
        // Only uses volume, nothing else needed
        meal.addFoodItem(frag.food);
        displayToast("Added to meal.", this);
        saveAndFinish();
      }

    } else {
      // Replace previously added food item
      if (frag.food.usesMass()) {
        if (FoodItem.getAllDensities() == null) {
          displayToast("Error: Cannot access densities.", this);
          return;
        }
        findDensityMatches(frag.food);
      } else if (!frag.food.usesVolume()) {
        DialogFragment servingsDialog = FoodServingFragment.newInstance(frag.food, false);
        servingsDialog.show(getFragmentManager(), "FoodServingFragment");
      } else {
        // Only uses volume, nothing else needed
        meal.replaceFoodItem(replacedFood, frag.food);
        displayToast("Replaced food item.", this);
        saveAndFinish();
      }
    }
  }
  /** 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);
 }
    @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");
      }
    }
 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);
   }
 }
  /** 初始化数据 */
  private void initData(Bundle savedInstanceState) {
    if (savedInstanceState != null) mDatas = savedInstanceState.getStringArrayList("mDatas");

    if (mDatas == null) {
      mLoadingDialog = new LoadingDialog();
      mLoadingDialog.show(getFragmentManager(), "LoadingDialog");
      mLoadDataAsyncTask = new LoadDataAsyncTask();
      mLoadDataAsyncTask.execute();

    } else {
      initAdapter();
    }
  }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.back:
       finish();
       break;
     case R.id.ok:
       new ConfirmTask().execute((Void) null);
       break;
     case R.id.ydqx:
       showDialog(DATE_DIALOG_ID);
       break;
     case R.id.from:
       DialogFragment frag = AreaDialog.newInstance(10);
       frag.show(getFragmentManager(), "area");
       break;
     case R.id.to:
       DialogFragment f = AreaDialog.newInstance(11);
       f.show(getFragmentManager(), "area");
       break;
   }
 }
  private void openDialogFragment(DialogFragment dialogStandardFragment) {
    if (dialogStandardFragment != null) {
      FragmentManager fm = getFragmentManager();
      FragmentTransaction ft = fm.beginTransaction();
      Fragment prev = fm.findFragmentByTag("carddemo_dialog");
      if (prev != null) {
        ft.remove(prev);
      }
      // ft.addToBackStack(null);

      dialogStandardFragment.show(ft, "carddemo_dialog");
    }
  }