Search in sources :

Example 16 with MaterializeBuilder

use of com.mikepenz.materialize.MaterializeBuilder in project FastAdapter by mikepenz.

the class ImageListActivity 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_image_list);
    //style our ui
    new MaterializeBuilder().withActivity(this).build();
    //create our FastAdapter which will manage everything
    mFastItemAdapter = new FastItemAdapter<>();
    //init the ClickListenerHelper which simplifies custom click listeners on views of the Adapter
    mClickListenerHelper = new ClickListenerHelper<>(mFastItemAdapter);
    //configure our fastAdapter
    mFastItemAdapter.withOnClickListener(new FastAdapter.OnClickListener<ImageItem>() {

        @Override
        public boolean onClick(View v, IAdapter<ImageItem> adapter, ImageItem item, int position) {
            Toast.makeText(v.getContext(), item.mName, Toast.LENGTH_SHORT).show();
            return false;
        }
    });
    //get our recyclerView and do basic setup
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
    //find out how many columns we display
    int columns = getResources().getInteger(R.integer.wall_splash_columns);
    if (columns == 1) {
        //linearLayoutManager for one column
        rv.setLayoutManager(new LinearLayoutManager(this));
    } else {
        //gridLayoutManager for more than one column ;)
        rv.setLayoutManager(new GridLayoutManager(this, columns));
    }
    rv.setItemAnimator(new DefaultItemAnimator());
    rv.setAdapter(mFastItemAdapter);
    //fill with some sample data
    mFastItemAdapter.add(ImageDummyData.getImageItems());
    //restore selections (this has to be done after the items were added
    mFastItemAdapter.withSavedInstanceState(savedInstanceState);
    //a custom OnCreateViewHolder listener class which is used to create the viewHolders
    //we define the listener for the imageLovedContainer here for better performance
    //you can also define the listener within the items bindView method but performance is better if you do it like this
    mFastItemAdapter.withItemEvent(new ImageItem.ImageItemHeartClickEvent());
    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MaterializeBuilder(com.mikepenz.materialize.MaterializeBuilder) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) FastAdapter(com.mikepenz.fastadapter.FastAdapter) ImageItem(com.mikepenz.fastadapter.app.items.ImageItem) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)16 MaterializeBuilder (com.mikepenz.materialize.MaterializeBuilder)16 Toolbar (android.support.v7.widget.Toolbar)15 FastAdapter (com.mikepenz.fastadapter.FastAdapter)14 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)13 ArrayList (java.util.ArrayList)12 View (android.view.View)11 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)9 SlideDownAlphaAnimator (com.mikepenz.itemanimators.SlideDownAlphaAnimator)6 IItem (com.mikepenz.fastadapter.IItem)5 SimpleItem (com.mikepenz.fastadapter.app.items.SimpleItem)5 GridLayoutManager (android.support.v7.widget.GridLayoutManager)4 IconicsLayoutInflater (com.mikepenz.iconics.context.IconicsLayoutInflater)4 Random (java.util.Random)4 ActionMode (android.support.v7.view.ActionMode)3 SearchView (android.support.v7.widget.SearchView)3 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)3 IItemAdapter (com.mikepenz.fastadapter.IItemAdapter)3 ActionModeHelper (com.mikepenz.fastadapter_extensions.ActionModeHelper)3 ITypeface (com.mikepenz.iconics.typeface.ITypeface)3