use of carbon.widget.EditText in project Carbon by ZieIony.
the class SelectDialogActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initToolbar();
EditText titleText = findViewById(R.id.titleText);
DropDown dropDown = findViewById(R.id.dropDown);
dropDown.setItems(new String[] { "Single select", "Multi select" });
StringFruitGenerator generator = new StringFruitGenerator();
List<String> items = Stream.generate(generator::next).limit(5).toList();
selectedItem = items.get(0);
selectedItems = new ArrayList<>();
selectedItems.add(selectedItem);
findViewById(R.id.button).setOnClickListener(view -> {
switch(dropDown.getSelectedIndex()) {
case 0:
{
SingleSelectDialog<String> dialog = new SingleSelectDialog<>(this);
if (titleText.length() > 0)
dialog.setTitle(titleText.getText());
dialog.setItems(items);
dialog.setOnDismissListener(dialogInterface -> selectedItem = dialog.getSelectedItem());
dialog.setSelectedItem(selectedItem);
dialog.show();
}
break;
case 1:
{
MultiSelectDialog<String> dialog = new MultiSelectDialog<>(this);
if (titleText.length() > 0)
dialog.setTitle(titleText.getText());
dialog.setItems(items);
dialog.addButton("ok", null);
dialog.setOnDismissListener(dialogInterface -> selectedItems = dialog.getSelectedItems());
dialog.setSelectedItems(selectedItems);
dialog.show();
}
break;
}
});
}
use of carbon.widget.EditText in project Carbon by ZieIony.
the class FlowLayoutActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initToolbar();
DrawableAvatarGenerator avatarGenerator = new DrawableAvatarGenerator(this);
StringFirstNameGenerator nameGenerator = new StringFirstNameGenerator(Gender.Both, false, false);
Random random = new Random();
FlowLayout layout = findViewById(R.id.flowLayout);
Stream.of(layout.getViews()).filter(v -> v instanceof Chip).forEach(v -> {
final Chip chip = (Chip) v;
DataContext dataContext = new DataContext();
chip.setText(nameGenerator.next(dataContext));
if (random.nextBoolean())
chip.setIcon(avatarGenerator.next(dataContext));
chip.setRemovable(random.nextBoolean());
chip.setOnRemoveListener(() -> {
chip.setVisibility(View.GONE);
});
});
EditText addChip = findViewById(R.id.addChip);
addChip.setOnEditorActionListener((textView, i, keyEvent) -> {
if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
Chip chip = new Chip(FlowLayoutActivity.this);
chip.setText(addChip.getText());
chip.setRemovable(random.nextBoolean());
chip.setSelected(random.nextBoolean());
layout.addView(chip);
addChip.setText("");
}
return true;
});
}
use of carbon.widget.EditText in project Carbon by ZieIony.
the class ProgressDialogActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initToolbar();
EditText titleText = findViewById(R.id.titleText);
EditText messageText = findViewById(R.id.messageText);
EditText buttonText = findViewById(R.id.buttonText);
findViewById(R.id.showProgressDialog).setOnClickListener(view -> {
ProgressDialog dialog = new ProgressDialog(this);
if (titleText.length() > 0)
dialog.setTitle(titleText.getText());
if (buttonText.length() > 0)
dialog.addButton(buttonText.getText().toString(), null);
Handler handler = new Handler(Looper.getMainLooper());
Runnable dismissRunnable = dialog::dismiss;
dialog.setOnDismissListener(dialogInterface -> handler.removeCallbacks(dismissRunnable));
dialog.setText(messageText.getText());
dialog.show();
handler.postDelayed(dialog::dismiss, 2000);
});
}
Aggregations