use of com.hannesdorfmann.adapterdelegates4.sample.model.DisplayableItem in project AdapterDelegates by sockeqwe.
the class ReptilesActivity method getAnimals.
private List<DisplayableItem> getAnimals() {
List<DisplayableItem> animals = new ArrayList<>();
animals.add(new Snake("Mub Adder", "Adder"));
animals.add(new Snake("Texas Blind Snake", "Blind snake"));
animals.add(new Snake("Tree Boa", "Boa"));
animals.add(new Gecko("Fat-tailed", "Hemitheconyx"));
animals.add(new Gecko("Stenodactylus", "Dune Gecko"));
animals.add(new Gecko("Leopard Gecko", "Eublepharis"));
animals.add(new Gecko("Madagascar Gecko", "Phelsuma"));
animals.add(new UnknownReptile());
animals.add(new Snake("Mub Adder", "Adder"));
animals.add(new Snake("Texas Blind Snake", "Blind snake"));
animals.add(new Snake("Tree Boa", "Boa"));
animals.add(new Gecko("Fat-tailed", "Hemitheconyx"));
animals.add(new Gecko("Stenodactylus", "Dune Gecko"));
animals.add(new Gecko("Leopard Gecko", "Eublepharis"));
animals.add(new Gecko("Madagascar Gecko", "Phelsuma"));
animals.add(new Snake("Mub Adder", "Adder"));
animals.add(new Snake("Texas Blind Snake", "Blind snake"));
animals.add(new Snake("Tree Boa", "Boa"));
animals.add(new Gecko("Fat-tailed", "Hemitheconyx"));
animals.add(new Gecko("Stenodactylus", "Dune Gecko"));
animals.add(new Gecko("Leopard Gecko", "Eublepharis"));
animals.add(new Gecko("Madagascar Gecko", "Phelsuma"));
Collections.shuffle(animals);
return animals;
}
use of com.hannesdorfmann.adapterdelegates4.sample.model.DisplayableItem in project AdapterDelegates by sockeqwe.
the class PaginationActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pagination);
RecyclerView recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
AdapterDelegatesManager<List<DisplayableItem>> delegatesManager = new AdapterDelegatesManager<List<DisplayableItem>>().addDelegate(new AdvertisementAdapterDelegate(this)).addDelegate(new CatAdapterDelegate(this)).addDelegate(new DogAdapterDelegate(this)).addDelegate(new GeckoAdapterDelegate(this)).addDelegate(new SnakeListItemAdapterDelegate(this)).setFallbackDelegate(new LoadingAdapterDelegate(this));
final PagedListDelegationAdapter<DisplayableItem> adapter = new PagedListDelegationAdapter<DisplayableItem>(delegatesManager, callback);
recyclerView.setAdapter(adapter);
LiveData<PagedList<DisplayableItem>> pagedListLiveData = new LivePagedListBuilder<>(new SampleDataSource.Factory(), 20).setBoundaryCallback(new PagedList.BoundaryCallback<DisplayableItem>() {
@Override
public void onZeroItemsLoaded() {
Log.d("PaginationSource", "onZeroItemsLoaded");
super.onZeroItemsLoaded();
}
@Override
public void onItemAtFrontLoaded(@NonNull DisplayableItem itemAtFront) {
Log.d("PaginationSource", "onItemAtFrontLoaded " + itemAtFront);
super.onItemAtFrontLoaded(itemAtFront);
}
@Override
public void onItemAtEndLoaded(@NonNull DisplayableItem itemAtEnd) {
Log.d("PaginationSource", "onItemAtEndLoaded " + itemAtEnd);
super.onItemAtEndLoaded(itemAtEnd);
}
}).build();
pagedListLiveData.observe(this, new Observer<PagedList<DisplayableItem>>() {
@Override
public void onChanged(PagedList<DisplayableItem> displayableItems) {
adapter.submitList(displayableItems);
}
});
}
use of com.hannesdorfmann.adapterdelegates4.sample.model.DisplayableItem in project AdapterDelegates by sockeqwe.
the class ReptilesActivity method getAnimals.
private List<DisplayableItem> getAnimals() {
List<DisplayableItem> animals = new ArrayList<>();
animals.add(new Snake("Mub Adder", "Adder"));
animals.add(new Snake("Texas Blind Snake", "Blind snake"));
animals.add(new Snake("Tree Boa", "Boa"));
animals.add(new Gecko("Fat-tailed", "Hemitheconyx"));
animals.add(new Gecko("Stenodactylus", "Dune Gecko"));
animals.add(new Gecko("Leopard Gecko", "Eublepharis"));
animals.add(new Gecko("Madagascar Gecko", "Phelsuma"));
animals.add(new UnknownReptile());
animals.add(new Snake("Mub Adder", "Adder"));
animals.add(new Snake("Texas Blind Snake", "Blind snake"));
animals.add(new Snake("Tree Boa", "Boa"));
animals.add(new Gecko("Fat-tailed", "Hemitheconyx"));
animals.add(new Gecko("Stenodactylus", "Dune Gecko"));
animals.add(new Gecko("Leopard Gecko", "Eublepharis"));
animals.add(new Gecko("Madagascar Gecko", "Phelsuma"));
animals.add(new Snake("Mub Adder", "Adder"));
animals.add(new Snake("Texas Blind Snake", "Blind snake"));
animals.add(new Snake("Tree Boa", "Boa"));
animals.add(new Gecko("Fat-tailed", "Hemitheconyx"));
animals.add(new Gecko("Stenodactylus", "Dune Gecko"));
animals.add(new Gecko("Leopard Gecko", "Eublepharis"));
animals.add(new Gecko("Madagascar Gecko", "Phelsuma"));
Collections.shuffle(animals);
return animals;
}
use of com.hannesdorfmann.adapterdelegates4.sample.model.DisplayableItem in project AdapterDelegates by sockeqwe.
the class DogAdapterDelegate method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull List<DisplayableItem> items, int position, @NonNull RecyclerView.ViewHolder holder, @Nullable List<Object> payloads) {
DogViewHolder vh = (DogViewHolder) holder;
Dog dog = (Dog) items.get(position);
vh.name.setText(dog.getName());
Log.d("Scroll", "DogAdapterDelegate bind " + position);
}
use of com.hannesdorfmann.adapterdelegates4.sample.model.DisplayableItem in project AdapterDelegates by sockeqwe.
the class MainActivity method getAnimals.
private List<DisplayableItem> getAnimals() {
List<DisplayableItem> animals = new ArrayList<>();
animals.add(new Cat("American Curl"));
animals.add(new Cat("Baliness"));
animals.add(new Cat("Bengal"));
animals.add(new Cat("Corat"));
animals.add(new Cat("Manx"));
animals.add(new Cat("Nebelung"));
animals.add(new Dog("Aidi"));
animals.add(new Dog("Chinook"));
animals.add(new Dog("Appenzeller"));
animals.add(new Dog("Collie"));
animals.add(new Snake("Mub Adder", "Adder"));
animals.add(new Snake("Texas Blind Snake", "Blind snake"));
animals.add(new Snake("Tree Boa", "Boa"));
animals.add(new Gecko("Fat-tailed", "Hemitheconyx"));
animals.add(new Gecko("Stenodactylus", "Dune Gecko"));
animals.add(new Gecko("Leopard Gecko", "Eublepharis"));
animals.add(new Gecko("Madagascar Gecko", "Phelsuma"));
animals.add(new Advertisement());
animals.add(new Advertisement());
animals.add(new Advertisement());
animals.add(new Advertisement());
animals.add(new Advertisement());
Collections.shuffle(animals);
return animals;
}
Aggregations