Search in sources :

Example 1 with LandscapeView

use of tk.zielony.landscapeview.LandscapeView 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));
}
Also used : ThemedActivity(tk.zielony.carbonsamples.ThemedActivity) LandscapeView(tk.zielony.landscapeview.LandscapeView) Bundle(android.os.Bundle) Collectors(com.annimon.stream.Collectors) Stream(com.annimon.stream.Stream) HeightBehavior(carbon.behavior.HeightBehavior) SampleAnnotation(tk.zielony.carbonsamples.SampleAnnotation) Drawable(android.graphics.drawable.Drawable) StringNameGenerator(tk.zielony.randomdata.person.StringNameGenerator) AvatarTextRow(carbon.component.AvatarTextRow) DrawableAvatarGenerator(tk.zielony.randomdata.person.DrawableAvatarGenerator) List(java.util.List) RecyclerView(carbon.widget.RecyclerView) RandomData(tk.zielony.randomdata.RandomData) RelativeLayout(carbon.widget.RelativeLayout) R(tk.zielony.carbonsamples.R) DefaultAvatarTextItem(carbon.component.DefaultAvatarTextItem) RecyclerScrollBehavior(carbon.behavior.RecyclerScrollBehavior) RowListAdapter(carbon.recycler.RowListAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) StringNameGenerator(tk.zielony.randomdata.person.StringNameGenerator) RecyclerScrollBehavior(carbon.behavior.RecyclerScrollBehavior) RandomData(tk.zielony.randomdata.RandomData) DefaultAvatarTextItem(carbon.component.DefaultAvatarTextItem) RowListAdapter(carbon.recycler.RowListAdapter) AvatarTextRow(carbon.component.AvatarTextRow) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) LandscapeView(tk.zielony.landscapeview.LandscapeView) RelativeLayout(carbon.widget.RelativeLayout) DrawableAvatarGenerator(tk.zielony.randomdata.person.DrawableAvatarGenerator) RecyclerView(carbon.widget.RecyclerView)

Aggregations

Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 HeightBehavior (carbon.behavior.HeightBehavior)1 RecyclerScrollBehavior (carbon.behavior.RecyclerScrollBehavior)1 AvatarTextRow (carbon.component.AvatarTextRow)1 DefaultAvatarTextItem (carbon.component.DefaultAvatarTextItem)1 RowListAdapter (carbon.recycler.RowListAdapter)1 RecyclerView (carbon.widget.RecyclerView)1 RelativeLayout (carbon.widget.RelativeLayout)1 Collectors (com.annimon.stream.Collectors)1 Stream (com.annimon.stream.Stream)1 List (java.util.List)1 R (tk.zielony.carbonsamples.R)1 SampleAnnotation (tk.zielony.carbonsamples.SampleAnnotation)1 ThemedActivity (tk.zielony.carbonsamples.ThemedActivity)1 LandscapeView (tk.zielony.landscapeview.LandscapeView)1 RandomData (tk.zielony.randomdata.RandomData)1 DrawableAvatarGenerator (tk.zielony.randomdata.person.DrawableAvatarGenerator)1 StringNameGenerator (tk.zielony.randomdata.person.StringNameGenerator)1