Ejemplo n.º 1
0
  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    String text =
        String.format(
            "%s\n\n%s\n\n%s",
            DreamDroid.VERSION_STRING,
            getString(R.string.license),
            getString(R.string.source_code_link));

    MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity());
    builder
        .title(R.string.about)
        .content(text)
        .neutralText(R.string.donate)
        .positiveText(R.string.privacy)
        .callback(
            new MaterialDialog.ButtonCallback() {
              @Override
              public void onNeutral(MaterialDialog dialog) {
                ExtendedHashMap skus = ((BaseActivity) getActivity()).getIabItems();
                DonationDialog d = DonationDialog.newInstance(skus);
                ((MultiPaneHandler) getActivity()).showDialogFragment(d, "donate_dialog");
              }

              @Override
              public void onPositive(MaterialDialog dialog) {
                finishDialog(Statics.ACTION_SHOW_PRIVACY_STATEMENT, null);
              }
            });

    MaterialDialog dialog = builder.build();
    Linkify.addLinks(dialog.getContentView(), Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS);
    return dialog;
  }
Ejemplo n.º 2
0
 public static void showInputDialog(
     Activity context, int title, int hint, String prefillInput, final InputCallback callback) {
   @SuppressLint("InflateParams")
   final View view = context.getLayoutInflater().inflate(R.layout.dialog_input, null);
   MaterialDialog.Builder dialog =
       new MaterialDialog.Builder(context)
           .title(title)
           .positiveText(android.R.string.ok)
           .negativeText(android.R.string.cancel)
           .callback(
               new MaterialDialog.ButtonCallback() {
                 @Override
                 public void onPositive(MaterialDialog dialog) {
                   if (callback != null) {
                     EditText input = (EditText) view.findViewById(R.id.input);
                     callback.onInput(input.getText().toString().trim());
                   }
                 }
               })
           .customView(view, true);
   final EditText input = (EditText) view.findViewById(R.id.input);
   if (hint != 0) input.setHint(hint);
   if (prefillInput != null) input.append(prefillInput);
   MaterialDialog alert = dialog.build();
   alert.setOnDismissListener(
       new DialogInterface.OnDismissListener() {
         @Override
         public void onDismiss(DialogInterface dialog) {
           if (callback instanceof InputCancelCallback)
             ((InputCancelCallback) callback).onCancel();
         }
       });
   alert.show();
 }
Ejemplo n.º 3
0
  @Override
  public void showLoadDialog(String title, String message) {
    MaterialDialog.Builder builder =
        new MaterialDialog.Builder(this)
            .title(title)
            .content(message)
            .positiveText("确定")
            .onPositive(
                new MaterialDialog.SingleButtonCallback() {
                  @Override
                  public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    presenter.updateOrderCargo(unRemoveEt.getText().toString());
                  }
                })
            .negativeText("取消")
            .onNegative(
                new MaterialDialog.SingleButtonCallback() {
                  @Override
                  public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    dialog.dismiss();
                  }
                });

    MaterialDialog dialog = builder.build();
    dialog.show();
  }
Ejemplo n.º 4
0
  /**
   * Create a dialog containing (parts of the) change log.
   *
   * @param full If this is {@code true} the full change log is displayed. Otherwise only changes
   *     for versions newer than the last version are displayed.
   * @return A dialog containing the (partial) change log.
   */
  protected Dialog getDialog(boolean full) {
    WebView wv = new WebView(mContext);
    // wv.setBackgroundColor(0); // transparent
    wv.loadDataWithBaseURL(null, getLog(full), "text/html", "UTF-8", null);

    MaterialDialog.Builder builder = new MaterialDialog.Builder(mContext);
    builder
        .title(
            mContext
                .getResources()
                .getString(full ? R.string.changelog_full_title : R.string.changelog_title))
        .customView(wv, false)
        .positiveText(mContext.getResources().getString(R.string.changelog_ok_button))
        .onPositive(
            new MaterialDialog.SingleButtonCallback() {
              @Override
              public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                updateVersionInPreferences();
              }
            })
        .onNegative(
            new MaterialDialog.SingleButtonCallback() {
              @Override
              public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                getFullLogDialog().show();
              }
            });
    if (!full) {
      // Show "More…" button if we're only displaying a partial change log.
      builder.negativeText(R.string.changelog_show_full);
    }

    return builder.build();
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Resources res = getResources();

    Activity activity = getActivity();
    final MaterialDialog.Builder builder = new MaterialDialog.Builder(activity);

    int type = getArguments().getInt("type");
    if (type == CARD_BROWSER_MY_SEARCHES_TYPE_LIST) {
      mSavedFilters = (HashMap<String, String>) getArguments().getSerializable("savedFilters");
      mSearchesAdapter =
          new MySearchesArrayAdapter(activity, new ArrayList<>(mSavedFilters.keySet()));
      mSearchesAdapter.notifyDataSetChanged(); // so the values are sorted.
      builder
          .title(res.getString(R.string.card_browser_list_my_searches_title))
          .adapter(
              mSearchesAdapter,
              new MaterialDialog.ListCallback() {
                @Override
                public void onSelection(
                    MaterialDialog dialog, View itemView, int which, CharSequence text) {
                  mMySearchesDialogListener.OnSelection(mSearchesAdapter.getItem(which));
                  dialog.dismiss();
                }
              });
    } else if (type == CARD_BROWSER_MY_SEARCHES_TYPE_SAVE) {
      mCurrentSearchTerms = getArguments().getString("currentSearchTerms");
      builder
          .title(getString(R.string.card_browser_list_my_searches_save))
          .positiveText(getString(android.R.string.ok))
          .negativeText(getString(R.string.cancel))
          .input(
              R.string.card_browser_list_my_searches_new_name,
              R.string.empty_string,
              new MaterialDialog.InputCallback() {
                @Override
                public void onInput(MaterialDialog dialog, CharSequence text) {
                  mMySearchesDialogListener.OnSaveSearch(text.toString(), mCurrentSearchTerms);
                }
              });
    }
    MaterialDialog dialog = builder.build();
    if (dialog.getListView() != null) {
      dialog
          .getListView()
          .setDivider(
              new ColorDrawable(ContextCompat.getColor(activity, R.color.material_grey_600)));
      dialog.getListView().setDividerHeight(1);
      // adjust padding to use dp as seen here: http://stackoverflow.com/a/9685690/1332026
      float scale = res.getDisplayMetrics().density;
      int dpAsPixels = (int) (5 * scale + 0.5f);
      dialog.getView().setPadding(dpAsPixels, 0, dpAsPixels, dpAsPixels);
    }

    return dialog;
  }
Ejemplo n.º 6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_parsing_json);

    toolbar = (Toolbar) findViewById(R.id.toolbar_spinner);
    setSupportActionBar(toolbar);
    setTitle("수질정보");

    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, PurificationPlant);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    items = (ArrayList<String>) getIntent().getSerializableExtra("data");
    index = getIntent().getIntExtra("index", 1);

    ph = (TextView) findViewById(R.id.ph);
    tak = (TextView) findViewById(R.id.tak);
    zan = (TextView) findViewById(R.id.zan);
    junsujang = (TextView) findViewById(R.id.jungsujang);

    update = (TextView) findViewById(R.id.dayOfUpdate);

    dialogBuilder = new MaterialDialog.Builder(parsingJson.this);
    dialogBuilder.title("데이터 로드중..").content("잠시만 기다려주세요").progress(true, 0);
    mDialog = dialogBuilder.build();

    spinner = (MaterialSpinner) findViewById(R.id.spinner);
    spinner.setAdapter(adapter);
    spinner.setSelection(index);
    spinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
            PurificationPlant_choice = PurificationPlant_code[position];
            data.clear();
            index = position;
            new JsonLoadingTask().execute();
            junsujang.setText(PurificationPlant[index]);
            mDialog.show();
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });

    new JsonLoadingTask().execute();
  }
  @Override
  protected void showDialog(Bundle state) {
    List<Integer> indices = new ArrayList<>();
    for (String s : getValues()) {
      int index = findIndexOfValue(s);
      if (index >= 0) indices.add(findIndexOfValue(s));
    }
    MaterialDialog.Builder builder =
        new MaterialDialog.Builder(context)
            .title(getDialogTitle())
            .icon(getDialogIcon())
            .negativeText(getNegativeButtonText())
            .positiveText(getPositiveButtonText())
            .onAny(
                new MaterialDialog.SingleButtonCallback() {
                  @Override
                  public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    switch (which) {
                      default:
                        MaterialMultiSelectListPreference.this.onClick(
                            dialog, DialogInterface.BUTTON_POSITIVE);
                        break;
                      case NEUTRAL:
                        MaterialMultiSelectListPreference.this.onClick(
                            dialog, DialogInterface.BUTTON_NEUTRAL);
                        break;
                      case NEGATIVE:
                        MaterialMultiSelectListPreference.this.onClick(
                            dialog, DialogInterface.BUTTON_NEGATIVE);
                        break;
                    }
                  }
                })
            .items(getEntries())
            .itemsCallbackMultiChoice(
                indices.toArray(new Integer[indices.size()]),
                new MaterialDialog.ListCallbackMultiChoice() {
                  @Override
                  public boolean onSelection(
                      MaterialDialog dialog, Integer[] which, CharSequence[] text) {
                    onClick(null, DialogInterface.BUTTON_POSITIVE);
                    dialog.dismiss();
                    final Set<String> values = new HashSet<>();
                    for (int i : which) {
                      values.add(getEntryValues()[i].toString());
                    }
                    if (callChangeListener(values)) setValues(values);
                    return true;
                  }
                })
            .dismissListener(this);

    final View contentView = onCreateDialogView();
    if (contentView != null) {
      onBindDialogView(contentView);
      builder.customView(contentView, false);
    } else {
      builder.content(getDialogMessage());
    }

    PrefUtil.registerOnActivityDestroyListener(this, this);

    mDialog = builder.build();
    if (state != null) mDialog.onRestoreInstanceState(state);
    mDialog.show();
  }