コード例 #1
0
  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();
  }
コード例 #2
0
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle bundle = this.getArguments();
    position = bundle.getInt("position", 0);
    int favoriteId = bundle.getInt("favoriteId", 0);
    favoriteIsSelected = bundle.getBoolean("favoriteIsSelected", false);

    db = new DatabaseHelper(activity);
    favorite = db.getFavorite(favoriteId);

    MaterialDialog dialog =
        new MaterialDialog.Builder(activity)
            .title(R.string.edit_favorite)
            .customView(R.layout.add_edit_favorite_dialog, true)
            .positiveText(R.string.dialog_positive_text)
            .negativeText(android.R.string.cancel)
            .onPositive(
                new MaterialDialog.SingleButtonCallback() {
                  @Override
                  public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    inputName = input.getText().toString().trim();
                    if (iconPath == 0) {
                      iconPath = favorite.getFavoriteImage();
                    }
                    favorite.setFavoriteImage(iconPath);
                    favorite.setFavoriteName(inputName);
                    favorite.setSelected(favoriteIsSelected);
                    db.updateFavorite(favorite);
                    db.closeDB();

                    reloadHost();
                  }
                })
            .build();

    favoriteImage = (ImageView) dialog.findViewById(R.id.favorite_image);

    int iconName = favorite.getFavoriteImage();
    if (iconName == 0) {
      iconName = R.drawable.image_favorites;
    }
    favoriteImage.setImageResource(iconName);
    favoriteImage.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            favoriteImages = new FavoriteImages();

            View view = activity.getLayoutInflater().inflate(R.layout.icon_selector_grid, null);
            GridView gridView = (GridView) view.findViewById(R.id.icons_grid_view);
            gridView.setAdapter(new IconAdapter(activity, favoriteImages.getFavoriteImagesIds()));
            gridView.setOnItemClickListener(
                new AdapterView.OnItemClickListener() {
                  @Override
                  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    favoriteImage.setImageResource(favoriteImages.getFavoriteImageId(position));
                    iconPath = favoriteImages.getFavoriteImageId(position);
                    positiveAction.setEnabled(true);
                    gridDialog.dismiss();
                  }
                });
            gridDialog = new MaterialDialog.Builder(activity).customView(gridView, false).build();

            gridDialog.show();
          }
        });

    input = (EditText) dialog.findViewById(R.id.favorite_name);
    input.requestFocus();
    input.setText(favorite.getFavoriteName());

    positiveAction = dialog.getActionButton(DialogAction.POSITIVE);
    input.addTextChangedListener(new OnTextChange(positiveAction));

    positiveAction.setEnabled(false);

    return dialog;
  }
コード例 #3
0
  public void addTask(final View view) {
    boolean wrapInScrollView = true;
    final MaterialDialog dialog =
        new MaterialDialog.Builder(this)
            .title("Create task")
            .customView(R.layout.layout, wrapInScrollView)
            .positiveText("Add")
            .negativeText("Cancel")
            .build();

    // Create the SPINNER to select the LIST
    Spinner spinner = (Spinner) dialog.findViewById(R.id.spinner);
    CharSequence[] charSequences = new CharSequence[groups.size() - 3];
    int j = 0;
    for (int i = 0; i < groups.size(); i++) {
      if (i == 1 || i == 2 || i == (groups.size() - 1)) {

      } else {
        charSequences[j] = groups.get(i).getName();
        j++;
      }
    }
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter =
        new ArrayAdapter<CharSequence>(
            this, android.R.layout.simple_spinner_dropdown_item, charSequences);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);

    final EditText taskName = (EditText) dialog.findViewById(R.id.editText);

    final Spinner listId = (Spinner) dialog.findViewById(R.id.spinner);

    dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
    taskName.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) {}

          @Override
          public void afterTextChanged(Editable s) {
            if (s.length() > 0) dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
            else dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
          }
        });

    dialog
        .getBuilder()
        .onPositive(
            new MaterialDialog.SingleButtonCallback() {
              @Override
              public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {

                if (taskName.getText().toString().isEmpty()) return;

                Task task = new Task();
                task.setAuthor(ParseUser.getCurrentUser());
                task.setUuidString();
                task.setName(taskName.getText().toString());
                task.setDraft(true);
                task.setImportant(false);
                task.setDone(false);

                saveTask(task, (int) listId.getSelectedItemId());
              }
            });

    dialog.show();
  }
コード例 #4
0
 public void setTlsClientCrtPath(String path) {
   if (securityDialog != null) {
     setTlsClientCrtPath(path, (TextView) securityDialog.findViewById(R.id.tlsClientCrt));
   }
 }