use of tk.zielony.randomdata.person.DrawableAvatarGenerator 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 tk.zielony.randomdata.person.DrawableAvatarGenerator in project Carbon by ZieIony.
the class SearchToolbarActivity method generateItems.
@NotNull
private List<DefaultAvatarTextItem> generateItems() {
RandomData randomData = new RandomData();
randomData.addGenerator(Drawable.class, new DrawableAvatarGenerator(this));
randomData.addGenerator(String.class, new StringNameGenerator().withMatcher(f -> f.getName().equals("text")));
return randomData.generateList(DefaultAvatarTextItem.class, 20);
}
use of tk.zielony.randomdata.person.DrawableAvatarGenerator in project Carbon by ZieIony.
the class BehaviorActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RecyclerView recycler = findViewById(R.id.recycler);
recycler.setLayoutManager(new LinearLayoutManager(this));
RowListAdapter<DefaultAvatarTextItem> adapter = new RowListAdapter<>(DefaultAvatarTextItem.class, AvatarTextRow::new);
recycler.setAdapter(adapter);
List<DefaultAvatarTextItem> items = Stream.generate(DefaultAvatarTextItem::new).limit(10).collect(Collectors.toList());
RandomData randomData = new RandomData();
randomData.addGenerator(Drawable.class, new DrawableAvatarGenerator(this));
randomData.addGenerator(String.class, new StringNameGenerator().withMatcher(f -> f.getName().equals("text")));
randomData.fill(items);
adapter.setItems(items);
RelativeLayout layout = findViewById(R.id.layout);
LandscapeView landscapeView = findViewById(R.id.landscape);
float minHeight = getResources().getDimension(carbon.R.dimen.carbon_toolbarHeight);
float maxHeight = minHeight * 4;
layout.addBehavior(new HeightBehavior<>(landscapeView, minHeight, maxHeight, HeightBehavior.Direction.Up));
layout.addBehavior(new RecyclerScrollBehavior(recycler));
layout.addBehavior(new HeightBehavior<>(landscapeView, minHeight, maxHeight, HeightBehavior.Direction.Down));
}
Aggregations