Пример #1
0
  /**
   * Displays a message box to the user with an OK button.
   *
   * @param title
   * @param message
   * @param context The calling class, such as GpsMainActivity.this or mainActivity.
   * @param msgCallback An object which implements IHasACallBack so that the click event can call
   *     the callback method.
   */
  public static void alert(
      String title, String message, Context context, final MessageBoxCallback msgCallback) {
    MaterialDialog alertDialog =
        new MaterialDialog.Builder(context)
            .title(title)
            .content(Html.fromHtml(message))
            .positiveText(R.string.ok)
            .onPositive(
                new MaterialDialog.SingleButtonCallback() {
                  @Override
                  public void onClick(
                      @NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
                    if (msgCallback != null) {
                      msgCallback.messageBoxResult(MessageBoxCallback.OK);
                    }
                  }
                })
            .onNegative(
                new MaterialDialog.SingleButtonCallback() {
                  @Override
                  public void onClick(
                      @NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
                    if (msgCallback != null) {
                      msgCallback.messageBoxResult(MessageBoxCallback.CANCEL);
                    }
                  }
                })
            .build();

    if (context instanceof Activity && !((Activity) context).isFinishing()) {
      alertDialog.show();
    } else {
      alertDialog.show();
    }
  }
Пример #2
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;
  }
Пример #3
0
  /**
   * Displays a message box to the user with an OK button.
   *
   * @param title
   * @param message
   * @param className The calling class, such as GpsMainActivity.this or mainActivity.
   * @param msgCallback An object which implements IHasACallBack so that the click event can call
   *     the callback method.
   */
  private static void MsgBox(
      String title, String message, Context className, final IMessageBoxCallback msgCallback) {
    MaterialDialog alertDialog =
        new MaterialDialog.Builder(className)
            .title(title)
            .content(message)
            .positiveText(R.string.ok)
            .callback(
                new MaterialDialog.ButtonCallback() {
                  @Override
                  public void onPositive(MaterialDialog dialog) {
                    if (msgCallback != null) {
                      msgCallback.MessageBoxResult(0);
                    }
                  }

                  @Override
                  public void onNegative(MaterialDialog dialog) {
                    super.onNegative(dialog);
                  }
                })
            .build();

    if (className instanceof Activity && !((Activity) className).isFinishing()) {
      alertDialog.show();
    } else {
      alertDialog.show();
    }
  }
Пример #4
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();
  }
Пример #5
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();
 }
Пример #6
0
 private void updateStage(@Nullable MaterialDialog dialog) {
   if (mLastStage == null || (mLastStage != mStage && mCallback != null)) {
     mLastStage = mStage;
     mCallback.onFingerprintDialogStageUpdated(this, mStage);
   }
   if (dialog == null) dialog = (MaterialDialog) getDialog();
   if (dialog == null) return;
   switch (mStage) {
     case FINGERPRINT:
       dialog.setActionButton(DialogAction.POSITIVE, android.R.string.cancel);
       dialog.setActionButton(DialogAction.NEGATIVE, R.string.use_password);
       mFingerprintContent.setVisibility(View.VISIBLE);
       mBackupContent.setVisibility(View.GONE);
       break;
     case NEW_FINGERPRINT_ENROLLED:
       // Intentional fall through
     case PASSWORD:
       dialog.setActionButton(DialogAction.POSITIVE, android.R.string.cancel);
       dialog.setActionButton(DialogAction.NEGATIVE, android.R.string.ok);
       mFingerprintContent.setVisibility(View.GONE);
       mBackupContent.setVisibility(View.VISIBLE);
       if (mStage == Stage.NEW_FINGERPRINT_ENROLLED) {
         mPasswordDescriptionTextView.setVisibility(View.GONE);
         mNewFingerprintEnrolledTextView.setVisibility(View.VISIBLE);
         mUseFingerprintFutureCheckBox.setVisibility(View.VISIBLE);
       }
       break;
   }
 }
Пример #7
0
  @OnClick(R.id.customView)
  public void showCustomView() {
    MaterialDialog dialog =
        new MaterialDialog.Builder(this)
            .title(R.string.googleWifi)
            .customView(R.layout.dialog_customview, true)
            .positiveText(R.string.connect)
            .negativeText(android.R.string.cancel)
            .onPositive(
                new MaterialDialog.SingleButtonCallback() {
                  @Override
                  public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    showToast("Password: " + passwordInput.getText().toString());
                  }
                })
            .build();

    positiveAction = dialog.getActionButton(DialogAction.POSITIVE);
    //noinspection ConstantConditions
    passwordInput = (EditText) dialog.getCustomView().findViewById(R.id.password);
    passwordInput.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            positiveAction.setEnabled(s.toString().trim().length() > 0);
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });

    // Toggling the show password CheckBox will mask or unmask the password input EditText
    CheckBox checkbox = (CheckBox) dialog.getCustomView().findViewById(R.id.showPassword);
    checkbox.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            passwordInput.setInputType(
                !isChecked ? InputType.TYPE_TEXT_VARIATION_PASSWORD : InputType.TYPE_CLASS_TEXT);
            passwordInput.setTransformationMethod(
                !isChecked ? PasswordTransformationMethod.getInstance() : null);
          }
        });

    int widgetColor = ThemeSingleton.get().widgetColor;
    MDTintHelper.setTint(
        checkbox,
        widgetColor == 0 ? ContextCompat.getColor(this, R.color.material_teal_500) : widgetColor);

    MDTintHelper.setTint(
        passwordInput,
        widgetColor == 0 ? ContextCompat.getColor(this, R.color.material_teal_500) : widgetColor);

    dialog.show();
    positiveAction.setEnabled(false); // disabled by default
  }
Пример #8
0
  private void showCustomView() {
    MaterialDialog dialog =
        new MaterialDialog.Builder(this)
            .title(R.string.googleWifi)
            .positiveText(R.string.agree)
            .customView(R.layout.dialog_customview)
            .positiveText(R.string.connect)
            .negativeText(android.R.string.cancel)
            .callback(
                new MaterialDialog.Callback() {
                  @Override
                  public void onPositive(MaterialDialog dialog) {
                    Toast.makeText(
                            getApplicationContext(),
                            "Password: " + passwordInput.getText().toString(),
                            Toast.LENGTH_SHORT)
                        .show();
                  }

                  @Override
                  public void onNegative(MaterialDialog dialog) {}
                })
            .build();

    positiveAction = dialog.getActionButton(DialogAction.POSITIVE);
    passwordInput = (EditText) dialog.getCustomView().findViewById(R.id.password);
    passwordInput.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            positiveAction.setEnabled(s.toString().trim().length() > 0);
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });

    // Toggling the show password CheckBox will mask or unmask the password input EditText
    ((CheckBox) dialog.getCustomView().findViewById(R.id.showPassword))
        .setOnCheckedChangeListener(
            new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                passwordInput.setInputType(
                    !isChecked
                        ? InputType.TYPE_TEXT_VARIATION_PASSWORD
                        : InputType.TYPE_CLASS_TEXT);
                passwordInput.setTransformationMethod(
                    !isChecked ? PasswordTransformationMethod.getInstance() : null);
              }
            });

    dialog.show();
    positiveAction.setEnabled(false); // disabled by default
  }
 private void invalidateDynamicButtonColors() {
   final Builder builder = getBuilder();
   if (builder.mDynamicButtonColor) {
     final MaterialDialog dialog = (MaterialDialog) getDialog();
     int selectedColor = getSelectedColor();
     dialog.getActionButton(DialogAction.POSITIVE).setTextColor(selectedColor);
     dialog.getActionButton(DialogAction.NEUTRAL).setTextColor(selectedColor);
   }
 }
  @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;
  }
Пример #11
0
  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (getArguments() == null || !getArguments().containsKey("key_name"))
      throw new IllegalStateException(
          "FingerprintDialog must be shown with show(Activity, String, int).");
    else if (savedInstanceState != null)
      mStage = (Stage) savedInstanceState.getSerializable("stage");
    setCancelable(getArguments().getBoolean("cancelable", true));

    MaterialDialog dialog =
        new MaterialDialog.Builder(getActivity())
            .title(R.string.sign_in)
            .customView(R.layout.fingerprint_dialog_container, false)
            .positiveText(android.R.string.cancel)
            .negativeText(R.string.use_password)
            .autoDismiss(false)
            .cancelable(getArguments().getBoolean("cancelable", true))
            .onPositive(
                new MaterialDialog.SingleButtonCallback() {
                  @Override
                  public void onClick(
                      @NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
                    materialDialog.cancel();
                  }
                })
            .onNegative(
                new MaterialDialog.SingleButtonCallback() {
                  @Override
                  public void onClick(
                      @NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
                    if (mStage == Stage.FINGERPRINT) {
                      goToBackup(materialDialog);
                    } else {
                      verifyPassword();
                    }
                  }
                })
            .build();

    final View v = dialog.getCustomView();
    assert v != null;
    mFingerprintContent = v.findViewById(R.id.fingerprint_container);
    mBackupContent = v.findViewById(R.id.backup_container);
    mPassword = (EditText) v.findViewById(R.id.password);
    mPassword.setOnEditorActionListener(this);
    mPasswordDescriptionTextView = (TextView) v.findViewById(R.id.password_description);
    mUseFingerprintFutureCheckBox = (CheckBox) v.findViewById(R.id.use_fingerprint_in_future_check);
    mNewFingerprintEnrolledTextView =
        (TextView) v.findViewById(R.id.new_fingerprint_enrolled_description);
    mFingerprintIcon = (ImageView) v.findViewById(R.id.fingerprint_icon);
    mFingerprintStatus = (TextView) v.findViewById(R.id.fingerprint_status);
    mFingerprintStatus.setText(R.string.initializing);

    return dialog;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    tracer = LoggerFactory.getLogger(NotificationAnnotationActivity.class.getSimpleName());

    MaterialDialog alertDialog =
        new MaterialDialog.Builder(this)
            .title(R.string.add_description)
            .customView(R.layout.alertview, false)
            .positiveText(R.string.ok)
            .negativeText(R.string.cancel)
            .callback(
                new MaterialDialog.ButtonCallback() {
                  @Override
                  public void onNeutral(MaterialDialog dialog) {
                    super.onNeutral(dialog);
                  }

                  @Override
                  public void onNegative(MaterialDialog dialog) {
                    finish();
                  }

                  @Override
                  public void onPositive(MaterialDialog dialog) {

                    EditText userInput =
                        (EditText) dialog.getCustomView().findViewById(R.id.alert_user_input);
                    tracer.info("Annotation from notification: " + userInput.getText().toString());

                    EventBus.getDefault()
                        .postSticky(new CommandEvents.Annotate(userInput.getText().toString()));

                    Intent serviceIntent =
                        new Intent(getApplicationContext(), GpsLoggingService.class);
                    getApplicationContext().startService(serviceIntent);

                    finish();
                  }
                })
            .cancelListener(
                new DialogInterface.OnCancelListener() {
                  @Override
                  public void onCancel(DialogInterface dialog) {
                    dialog.dismiss();
                    finish();
                  }
                })
            .build();
    TextView tvMessage =
        (TextView) alertDialog.getCustomView().findViewById(R.id.alert_user_message);
    tvMessage.setText(R.string.letters_numbers);
    alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    alertDialog.show();
  }
 @Override
 public void onDownloadFinished(boolean success, File file) {
   if (downloadDialog.isShowing()) downloadDialog.cancel();
   if (success) {
     downloadDialog = new BaseDialog(this).getDownloadFinishedDialog(true, file.getAbsolutePath());
   } else {
     downloadDialog = new BaseDialog(this).getDownloadFinishedDialog(false, null);
   }
   downloadDialog.show();
 }
  @SuppressWarnings("ResourceType")
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    assert getArguments() != null;
    MaterialDialog dialog =
        new MaterialDialog.Builder(getActivity())
            .title(getArguments().getInt(KEY_TITLE))
            .customView(R.layout.dialog_textsize, true)
            .negativeText(android.R.string.cancel)
            .positiveText(android.R.string.ok)
            .neutralText(R.string.defaultValue)
            .autoDismiss(false)
            .onAny(this)
            .build();

    final View view = dialog.getCustomView();
    assert view != null;
    mPreview = (TextView) view.findViewById(R.id.preview);
    mSeeker = (SeekBar) view.findViewById(R.id.seeker);
    mValue = (TextView) view.findViewById(R.id.value);

    final int defaultValue =
        Config.textSizeForMode(
            getActivity(),
            getArguments().getString(KEY_ATEKEY),
            getArguments().getString(KEY_MODE));
    mPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, defaultValue);
    mSeeker.setMax(111);
    final int dpValue = pxToSp(this, defaultValue);
    mSeeker.setProgress(dpValue - 1);
    mValue.setText(String.format("%dsp", dpValue));

    mSeeker.setOnSeekBarChangeListener(
        new SeekBar.OnSeekBarChangeListener() {
          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progress++;
            if (fromUser) {
              final int pxValue = spToPx(progress);
              mPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, pxValue);
              mValue.setText(String.format("%dsp", progress));
            }
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {}
        });

    ATE.apply(view, getArguments().getString(KEY_ATEKEY));
    return dialog;
  }
Пример #15
0
 public void showAwesomePopup() {
   MaterialDialog awesomeDialog =
       new MaterialDialog.Builder(hostActivity)
           .title(R.string.how_is_the_app)
           .items(R.array.greatOrNot)
           .itemsCallbackSingleChoice(
               0,
               new MaterialDialog.ListCallbackSingleChoice() {
                 @Override
                 public boolean onSelection(
                     MaterialDialog dialog, View view, int which, CharSequence text) {
                   switch (which) {
                     case 0:
                       showRatingPopup();
                       break;
                     case 1:
                       isClickedNotGreate = true;
                       mEditor.putBoolean(PREF_CLICKED_NOT_GREAT, true).commit();
                       showFeedbackPopup();
                       break;
                   }
                   return true; // allow selection
                 }
               })
           //                .positiveText(R.string.great)
           .negativeText(R.string.cancel)
           //                .neutralText(R.string.cancel)
           .onAny(
               new MaterialDialog.SingleButtonCallback() {
                 @Override
                 public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                   switch (which) {
                     case POSITIVE: // great
                       showRatingPopup();
                       break;
                     case NEGATIVE: // not great
                       isClickedNotGreate = true;
                       mEditor.putBoolean(PREF_CLICKED_NOT_GREAT, true).commit();
                       showFeedbackPopup();
                       break;
                     case NEUTRAL: // later
                       isClickedLater = true;
                       startUsingAppTime = System.currentTimeMillis();
                       mEditor.putBoolean(PREF_CLICKED_LATER, true).commit();
                       break;
                   }
                 }
               })
           .build();
   awesomeDialog.show();
 }
Пример #16
0
  private void requestGplusPermission() {
    final String[] PERMISSIONS = {Manifest.permission.GET_ACCOUNTS, Manifest.permission.INTERNET};
    if (ActivityCompat.shouldShowRequestPermissionRationale(
            getActivity(), Manifest.permission.GET_ACCOUNTS)
        || ActivityCompat.shouldShowRequestPermissionRationale(
            getActivity(), Manifest.permission.INTERNET)) {
      // Provide an additional rationale to the user if the permission was not granted
      // and the user would benefit from additional context for the use of the permission.
      // For example, if the request has been denied previously.

      String fab_skin = (BaseActivity.accentSkin);
      final MaterialDialog materialDialog =
          Futils.showBasicDialog(
              getActivity(),
              fab_skin,
              theme,
              new String[] {
                getResources().getString(R.string.grantgplus),
                getResources().getString(R.string.grantper),
                getResources().getString(R.string.grant),
                getResources().getString(R.string.cancel),
                null
              });
      materialDialog
          .getActionButton(DialogAction.POSITIVE)
          .setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  ActivityCompat.requestPermissions(getActivity(), PERMISSIONS, 66);
                  materialDialog.dismiss();
                }
              });
      materialDialog
          .getActionButton(DialogAction.NEGATIVE)
          .setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  getActivity().finish();
                }
              });
      materialDialog.setCancelable(false);
      materialDialog.show();

    } else {
      // Contact permissions have not been granted yet. Request them directly.
      ActivityCompat.requestPermissions(getActivity(), PERMISSIONS, 66);
    }
  }
Пример #17
0
 @Override
 public void showProgress() {
   if (progressDialog == null || !progressDialog.isShowing()) {
     progressDialog =
         new MaterialDialog.Builder(this)
             .title(R.string.app_name)
             .content(R.string.creating_keys)
             .progress(true, 0)
             .build();
     progressDialog.setCanceledOnTouchOutside(false);
   }
   if (!isFinishing()) {
     progressDialog.show();
   }
 }
Пример #18
0
 @Override
 protected void onPostExecute(Boolean result) {
   super.onPostExecute(result);
   materialDialog.dismiss();
   myRecycerAdapter = new ScoreAdapter(scoreList);
   recyclerView.setAdapter(myRecycerAdapter);
 }
Пример #19
0
  private void executequery() {

    materialDialog.show();

    Client.INSTANCE.getServiceReport(
        MkShop.AUTH,
        sFromDate,
        sToDate,
        new Callback<List<ServiceCenterEntity>>() {
          @Override
          public void success(final List<ServiceCenterEntity> serviceList, Response response) {

            Myenum.INSTANCE.setServiceList(serviceList);
            if (materialDialog != null && materialDialog.isShowing()) materialDialog.dismiss();
            tabLayout.setTabsFromPagerAdapter(adapter);
            viewPager.setAdapter(adapter);
          }

          @Override
          public void failure(RetrofitError error) {
            if (materialDialog != null && materialDialog.isShowing()) materialDialog.dismiss();
            MkShop.toast(getActivity(), error.getMessage());
          }
        });
  }
  private void showDialogCustomDates() {
    MaterialDialog dialog =
        new MaterialDialog.Builder(getActivity())
            .customView(R.layout.dialog_choose_date_report, false)
            .positiveText(android.R.string.ok)
            .onPositive(
                new MaterialDialog.SingleButtonCallback() {
                  @Override
                  public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
                    View view = materialDialog.getCustomView();
                    DatePicker fromDatePicker =
                        (DatePicker) view.findViewById(R.id.datePickerFromDate);
                    DatePicker toDatePicker = (DatePicker) view.findViewById(R.id.datePickerToDate);

                    mDateFrom = DateTimeUtils.fromDatePicker(fromDatePicker);
                    mDateTo = DateUtils.getDateFromDatePicker(toDatePicker);

                    String whereClause =
                        ViewMobileData.Date
                            + ">='"
                            + FormatUtilities.getIsoDateFrom(mDateFrom)
                            + "' AND "
                            + ViewMobileData.Date
                            + "<='"
                            + DateUtils.getIsoStringDate(mDateTo)
                            + "'";

                    Bundle args = new Bundle();
                    args.putString(KEY_WHERE_CLAUSE, whereClause);

                    startLoader(args);

                    // super.onPositive(dialog);
                  }
                })
            .show();
    // set date if is null
    if (mDateFrom == null) mDateFrom = DateTimeUtils.today();
    if (mDateTo == null) mDateTo = Calendar.getInstance().getTime();

    View view = dialog.getCustomView();
    DatePicker fromDatePicker = (DatePicker) view.findViewById(R.id.datePickerFromDate);
    DatePicker toDatePicker = (DatePicker) view.findViewById(R.id.datePickerToDate);

    DateTimeUtils.setDatePicker(mDateFrom, fromDatePicker);
    DateUtils.setDateToDatePicker(mDateTo, toDatePicker);
  }
Пример #21
0
  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    MaterialDialog dialog =
        new MaterialDialog.Builder(getActivity())
            .customView(R.layout.dialog_edit_point_info, false)
            .positiveText(R.string.ok)
            .negativeText(R.string.cancel)
            .positiveColorRes(R.color.dark_blue)
            .negativeColorRes(R.color.black)
            .iconRes(R.drawable.ic_marker_location)
            .autoDismiss(false)
            .title(R.string.edit_title_dialog)
            .callback(
                new MaterialDialog.ButtonCallback() {
                  @Override
                  public void onPositive(MaterialDialog dialog) {
                    super.onPositive(dialog);
                    boolean isTitleEmpty = !titleInput.testValidity();
                    boolean isDescrEmpty = !descrInput.testValidity();
                    if (!isDescrEmpty && !isTitleEmpty) {
                      EventBus.getDefault()
                          .post(
                              new PointInfoEditedEvent(
                                  titleInput.getText().toString(),
                                  descrInput.getText().toString()));
                      dialog.dismiss();
                    }
                  }

                  @Override
                  public void onNegative(MaterialDialog dialog) {
                    super.onNegative(dialog);
                    dialog.dismiss();
                  }
                })
            .build();
    titleInput = ButterKnife.findById(dialog, R.id.input_title);
    descrInput = ButterKnife.findById(dialog, R.id.input_description);
    titleInput.setText(getArguments().getString(TITLE_DIALOG));
    descrInput.setText(getArguments().getString(INFO_DIALOG));
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return dialog;
  }
Пример #22
0
 public void removeArticle(FeedItem feedItem) {
   final FeedItem feedItemFinal = feedItem;
   MaterialDialog removeArticleDialog =
       new MaterialDialog.Builder(mContext)
           .title(R.string.remove_archive)
           .content(R.string.remove_archive_content)
           .positiveText(R.string.remove)
           .negativeText(R.string.cancel)
           .onPositive(
               new MaterialDialog.SingleButtonCallback() {
                 @Override
                 public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
                   // remove this archive from db
                   mArticleInteractor.deleteArticleInDb(
                       ArticlePresenter.this, mContext, feedItemFinal);
                 }
               })
           .build();
   removeArticleDialog.show();
 }
    @Override
    protected void onPreExecute() {
      super.onPreExecute();

      dialog =
          new MaterialDialog.Builder(getActivity())
              .content("please wait")
              .progress(true, 0)
              .build();
      dialog.show();
    }
 public void showCityDialog(int laseRegionCode) {
   RegionView view =
       new RegionView(
           this,
           region -> {
             getPresenter().finishAddCity(region);
             dialog.dismiss();
           },
           laseRegionCode);
   dialog = new MaterialDialog.Builder(this).title("选择感兴趣的地区").customView(view, false).show();
 }
  @Override
  public void onClick(View v) {
    if (v.getTag() != null) {
      final int index = (Integer) v.getTag();
      final MaterialDialog dialog = (MaterialDialog) getDialog();
      final Builder builder = getBuilder();

      if (isInSub()) {
        subIndex(index);
      } else {
        topIndex(index);
        if (mColorsSub != null && index < mColorsSub.length) {
          dialog.setActionButton(DialogAction.NEUTRAL, builder.mBackBtn);
          isInSub(true);
        }
      }

      invalidateDynamicButtonColors();
      invalidate();
    }
  }
Пример #26
0
  @Override
  public void connect(String address) {

    if (dialog != null && dialog.isShowing()) {
      dialog.dismiss();
    }

    currentBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (currentBluetoothAdapter == null) {
      DisplayUtilities.ShowLargeMessage(
          this.context.getString(R.string.bluetooth_not_supported), "", view, true, null);
      return;
    }

    if (currentBluetoothAdapter.isEnabled()) {
      createConnection(address);
    } else {
      DisplayUtilities.ShowLargeMessage(
          this.context.getString(R.string.bluetooth_cant_connect), "", view, false, null);
    }
  }
  private void consultaTabelaPreco(final Produtos produto) {
    final Integer divisao = 100;

    final MaterialDialog dialog =
        new MaterialDialog.Builder(this)
            .title("Tabela Preço")
            .customView(R.layout.layout_dialogs_tabelapreco, true)
            .negativeText("Sair")
            .autoDismiss(true)
            .build();

    listviewtabelaPreco = (ListView) dialog.findViewById(R.id.listviewtabelaPreco);

    lista = produtodao.listPrecoidprodutoComTabelaItem(produto.getIdproduto());

    arrayAdapter = new AdapterTabelaprecoSpinner(this, lista);

    listviewtabelaPreco.setAdapter(arrayAdapter);

    dialog.show();
  }
 public ReconstructionBuilder(
     MainActivity context, PointCollection collectedPoints, PointCloudARRenderer renderer) {
   this.collectedPoints = collectedPoints;
   this.renderer = renderer;
   dialog =
       new MaterialDialog.Builder(context)
           .title(R.string.calculating_mesh)
           .content(R.string.please_wait)
           .progress(false, 100, true)
           .widgetColor(context.getResources().getColor(R.color.text_primary))
           .build();
   dialog.setProgress(0);
 }
Пример #29
0
 public void showFeedbackPopup() {
   MaterialDialog feedbackDialog =
       new MaterialDialog.Builder(hostActivity)
           .content(R.string.ask_to_leave_feedback)
           .positiveText(R.string.ok)
           .negativeText(R.string.cancel)
           .onAny(
               new MaterialDialog.SingleButtonCallback() {
                 @Override
                 public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                   switch (which) {
                     case POSITIVE: // ok
                       sendFeedbackEmail();
                       break;
                     case NEGATIVE: // do not show
                       break;
                   }
                 }
               })
           .build();
   feedbackDialog.show();
 }
Пример #30
0
  public void notifyPasswordValidation(boolean valid) {
    final MaterialDialog dialog = (MaterialDialog) getDialog();
    final View positive = dialog.getActionButton(DialogAction.POSITIVE);
    final View negative = dialog.getActionButton(DialogAction.NEGATIVE);
    toggleButtonsEnabled(true);

    if (valid) {
      if (mStage == Stage.NEW_FINGERPRINT_ENROLLED && mUseFingerprintFutureCheckBox.isChecked()) {
        // Re-create the key so that fingerprints including new ones are validated.
        Digitus.get().recreateKey();
        mStage = Stage.FINGERPRINT;
      }
      mPassword.setText("");
      mCallback.onFingerprintDialogAuthenticated();
      dismiss();
    } else {
      mPasswordDescriptionTextView.setText(R.string.password_not_recognized);
      final int red = ContextCompat.getColor(getActivity(), R.color.material_red_500);
      MDTintHelper.setTint(mPassword, red);
      ((TextView) positive).setTextColor(red);
      ((TextView) negative).setTextColor(red);
    }
  }