use of com.turingtechnologies.materialscrollbar.DragScrollBar in project FastAdapter by mikepenz.
the class GenericItemActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.sample_generic_item);
//style our ui
new MaterializeBuilder().withActivity(this).build();
//create our FastAdapter which will manage everything
fastAdapter = new FastAdapter();
fastAdapter.withSelectable(true);
//get our recyclerView and do basic setup
RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
//init our gridLayoutManager and configure RV
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
GenericItemAdapter<IconModel, GenericIconItem> itemAdapter = new GenericItemAdapter<>(GenericIconItem.class, IconModel.class);
final FastScrollIndicatorAdapter<GenericIconItem> fastScrollIndicatorAdapter = new FastScrollIndicatorAdapter<>();
rv.setAdapter(fastScrollIndicatorAdapter.wrap(itemAdapter.wrap(fastAdapter)));
DragScrollBar materialScrollBar = new DragScrollBar(this, rv, true);
materialScrollBar.setHandleColour(ContextCompat.getColor(this, R.color.colorAccent));
materialScrollBar.setHandleOffColour(ContextCompat.getColor(this, R.color.colorAccent));
materialScrollBar.addIndicator(new CustomIndicator(this), true);
rv.setLayoutManager(gridLayoutManager);
rv.setItemAnimator(new SlideDownAlphaAnimator());
//order fonts by their name
List<ITypeface> mFonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
Collections.sort(mFonts, new Comparator<ITypeface>() {
@Override
public int compare(final ITypeface object1, final ITypeface object2) {
return object1.getFontName().compareTo(object2.getFontName());
}
});
//add all icons of all registered Fonts to the list
ArrayList<IconModel> models = new ArrayList<>();
for (ITypeface font : mFonts) {
for (String icon : font.getIcons()) {
models.add(new IconModel(font.getIcon(icon)));
}
}
//fill with some sample data
itemAdapter.addModel(models);
//restore selections (this has to be done after the items were added
fastAdapter.withSavedInstanceState(savedInstanceState);
//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}
Aggregations