Search in sources :

Example 26 with DefaultItemAnimator

use of androidx.recyclerview.widget.DefaultItemAnimator 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)

Example 27 with DefaultItemAnimator

use of androidx.recyclerview.widget.DefaultItemAnimator in project MaxLock by Maxr1998.

the class LogViewerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    getActivity().setTitle(getString(R.string.pref_screen_logs));
    View rootView = inflater.inflate(R.layout.fragment_logs, container, false);
    mLogRecycler = rootView.findViewById(R.id.log_recycler);
    mEmptyText = rootView.findViewById(R.id.logs_empty_text);
    List<String> text = new ArrayList<>();
    try {
        BufferedReader br = new BufferedReader(new FileReader(getActivity().getApplicationInfo().dataDir + File.separator + Common.LOG_FILE));
        String line;
        while ((line = br.readLine()) != null) {
            text.add(line);
        }
    } catch (FileNotFoundException e) {
        mLogRecycler.setVisibility(View.GONE);
        mEmptyText.setVisibility(View.VISIBLE);
        return rootView;
    } catch (IOException e) {
        e.printStackTrace();
    }
    mLogRecycler.setLayoutManager(new LinearLayoutManager(getActivity()));
    mLogRecycler.setItemAnimator(new DefaultItemAnimator());
    LogRecyclerAdapter adapter = new LogRecyclerAdapter(text);
    mLogRecycler.setAdapter(adapter);
    return rootView;
}
Also used : ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) FileReader(java.io.FileReader) IOException(java.io.IOException) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator)

Aggregations

DefaultItemAnimator (androidx.recyclerview.widget.DefaultItemAnimator)27 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)14 RecyclerView (androidx.recyclerview.widget.RecyclerView)12 View (android.view.View)9 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)9 TextView (android.widget.TextView)6 FastScroller (eu.davidea.fastscroller.FastScroller)6 FlexibleItemDecoration (eu.davidea.flexibleadapter.common.FlexibleItemDecoration)6 ExampleAdapter (eu.davidea.samples.flexibleadapter.ExampleAdapter)5 SuppressLint (android.annotation.SuppressLint)3 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 ScrollableUseCaseItem (eu.davidea.samples.flexibleadapter.items.ScrollableUseCaseItem)3 Context (android.content.Context)2 Resources (android.content.res.Resources)2 AdapterView (android.widget.AdapterView)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 SearchView (androidx.appcompat.widget.SearchView)2 BottomSheetDialog (com.google.android.material.bottomsheet.BottomSheetDialog)2