Search in sources :

Example 1 with MyMapAdapter

use of com.junjunguo.pocketmaps.fragments.MyMapAdapter in project PocketMaps by junjunguo.

the class MainActivity method activateRecyclerView.

/**
 * active directions, and directions view
 */
private void activateRecyclerView(List<MyMap> myMaps) {
    RecyclerView.LayoutManager layoutManager;
    mapsRV = (RecyclerView) findViewById(R.id.my_maps_recycler_view);
    DefaultItemAnimator animator = new DefaultItemAnimator();
    animator.setAddDuration(2000);
    animator.setRemoveDuration(600);
    mapsRV.setItemAnimator(animator);
    // use this setting to improve performance if you know that changes
    // in content do not change the layout size of the RecyclerView
    mapsRV.setHasFixedSize(true);
    // use a linear layout manager
    layoutManager = new LinearLayoutManager(this);
    mapsRV.setLayoutManager(layoutManager);
    // specify an adapter (see also next example)
    if (mapAdapter == null) {
        mapAdapter = new MyMapAdapter(myMaps, this, false);
    } else {
        mapAdapter.clearList();
        mapAdapter.addAll(myMaps);
    }
    mapsRV.setAdapter(mapAdapter);
    deleteItemHandler();
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) MyMapAdapter(com.junjunguo.pocketmaps.fragments.MyMapAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator)

Example 2 with MyMapAdapter

use of com.junjunguo.pocketmaps.fragments.MyMapAdapter in project PocketMaps by junjunguo.

the class DownloadMapActivity method activateRecyclerView.

/**
 * active directions, and directions view
 */
private void activateRecyclerView(List<MyMap> myMaps) {
    mapsRV = (RecyclerView) findViewById(R.id.my_maps_download_recycler_view);
    DefaultItemAnimator animator = new DefaultItemAnimator();
    animator.setAddDuration(600);
    animator.setRemoveDuration(600);
    mapsRV.setItemAnimator(animator);
    // use this setting to improve performance if you know that changes
    // in content do not change the layout size of the RecyclerView
    mapsRV.setHasFixedSize(true);
    // use a linear layout manager
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    mapsRV.setLayoutManager(layoutManager);
    myDownloadAdapter = new MyMapAdapter(myMaps, this, true);
    mapsRV.setAdapter(myDownloadAdapter);
}
Also used : MyMapAdapter(com.junjunguo.pocketmaps.fragments.MyMapAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator)

Aggregations

DefaultItemAnimator (androidx.recyclerview.widget.DefaultItemAnimator)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 MyMapAdapter (com.junjunguo.pocketmaps.fragments.MyMapAdapter)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)1