Search in sources :

Example 81 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project FastAdapter by mikepenz.

the class SortActivity 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_sort);
    ButterKnife.bind(this);
    // Handle Toolbar
    setSupportActionBar(toolbar);
    //style our ui
    new MaterializeBuilder().withActivity(this).build();
    //create our FastAdapter which will manage everything
    fastItemAdapter = new FastItemAdapter<>();
    fastItemAdapter.withSelectable(true);
    //configure our fastAdapter
    fastItemAdapter.withOnClickListener(new FastAdapter.OnClickListener<SimpleItem>() {

        @Override
        public boolean onClick(View v, IAdapter<SimpleItem> adapter, SimpleItem item, int position) {
            Toast.makeText(v.getContext(), (item).name.getText(v.getContext()), Toast.LENGTH_LONG).show();
            return false;
        }
    });
    //get our recyclerView and do basic setup
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(fastItemAdapter);
    if (savedInstanceState != null) {
        //Retrieve the previous sorting strategy from the instance state
        sortingStrategy = toSortingStrategy(savedInstanceState.getInt("sorting_strategy"));
    } else {
        //Set the default so
        sortingStrategy = SORT_NONE;
    }
    //we sort the list
    fastItemAdapter.getItemAdapter().withComparator(getComparator());
    //initial filling of the list
    fastItemAdapter.setNewList(generateUnsortedList());
    //restore selections (this has to be done after the items were added
    fastItemAdapter.withSavedInstanceState(savedInstanceState);
    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) FastAdapter(com.mikepenz.fastadapter.FastAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MaterializeBuilder(com.mikepenz.materialize.MaterializeBuilder) SimpleItem(com.mikepenz.fastadapter.app.items.SimpleItem) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 82 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator 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)

Example 83 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project AdvancedMaterialDrawer by madcyph3r.

the class HeaderTypesFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.recycleview_layout, container, false);
    mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    createAdapter(mRecyclerView);
    return v;
}
Also used : DividerItemDecoration(de.madcyph3r.example.DividerItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 84 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project AdvancedMaterialDrawer by madcyph3r.

the class ListenerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.recycleview_layout, container, false);
    mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    createAdapter(mRecyclerView);
    return v;
}
Also used : DividerItemDecoration(de.madcyph3r.example.DividerItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 85 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project AdvancedMaterialDrawer by madcyph3r.

the class MenuFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.recycleview_layout, container, false);
    mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    createAdapter(mRecyclerView);
    return v;
}
Also used : DividerItemDecoration(de.madcyph3r.example.DividerItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Aggregations

DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)103 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)72 RecyclerView (android.support.v7.widget.RecyclerView)63 View (android.view.View)55 TextView (android.widget.TextView)30 ImageView (android.widget.ImageView)25 ArrayList (java.util.ArrayList)16 ClickItemTouchListener (com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener)14 GridLayoutManager (android.support.v7.widget.GridLayoutManager)13 Toolbar (android.support.v7.widget.Toolbar)13 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)10 FastAdapter (com.mikepenz.fastadapter.FastAdapter)10 UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)10 MaterializeBuilder (com.mikepenz.materialize.MaterializeBuilder)9 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)8 LocalTrack (com.sdsmdg.harjot.MusicDNA.models.LocalTrack)8 DividerItemDecoration (de.madcyph3r.example.DividerItemDecoration)8 Button (android.widget.Button)7 Random (java.util.Random)6 Intent (android.content.Intent)5