use of tk.zielony.randomdata.RandomData 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.RandomData in project Carbon by ZieIony.
the class QuickReturnActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
List<Serializable> items = Arrays.asList(// new PaddingItem(getResources().getDimensionPixelSize(R.dimen.carbon_toolbarHeight) + getResources().getDimensionPixelSize(R.dimen.carbon_paddingHalf)),
new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem(), new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem(), new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem(), new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem(), new DefaultImageTextSubtextDateItem());
RandomData randomData = new RandomData();
randomData.addGenerator(Drawable.class, new DrawableImageGenerator(this));
randomData.addGenerator(String.class, new StringNameGenerator().withMatcher(f -> f.getName().equals("text") && f.getDeclaringClass().equals(DefaultImageTextSubtextDateItem.class)));
randomData.addGenerator(String.class, new TextGenerator().withMatcher(f -> f.getName().equals("subtext")));
randomData.addGenerator(String.class, new DateGenerator().withTransformer(new DateToStringTransformer()));
randomData.fill(items);
RecyclerView recycler = findViewById(R.id.recycler);
recycler.setLayoutManager(new LinearLayoutManager(this));
RowListAdapter<Serializable> adapter = new RowListAdapter<>(DefaultImageTextSubtextDateItem.class, ImageTextSubtextDateRow::new);
adapter.putFactory(DefaultHeaderItem.class, PaddedHeaderRow::new);
recycler.setAdapter(adapter);
adapter.setItems(items);
final FloatingActionButton fab = findViewById(R.id.fab);
final Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(getTitle());
recycler.addOnScrollListener(new androidx.recyclerview.widget.RecyclerView.OnScrollListener() {
int yScroll = 0;
@Override
public void onScrolled(androidx.recyclerview.widget.RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (fab.getVisibility() == View.VISIBLE && fab.getAnimator() == null && yScroll > 50 * Carbon.getDip(getApplicationContext())) {
yScroll = 0;
fab.animateVisibility(View.GONE);
toolbar.animateVisibility(View.GONE);
}
if (fab.getVisibility() != View.VISIBLE && fab.getAnimator() == null && yScroll < -50 * Carbon.getDip(getApplicationContext())) {
yScroll = 0;
fab.animateVisibility(View.VISIBLE);
toolbar.animateVisibility(View.VISIBLE);
}
if (Math.signum(dy) != Math.signum(yScroll))
yScroll = 0;
yScroll += dy;
}
});
}
use of tk.zielony.randomdata.RandomData 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