Skip to content

Recyclerview Performance #20

@dyangcoding

Description

@dyangcoding

1 recyclerView.setHasFixedSize(true), this do improve the profermance, only for the case that all item of view has fixed width and height.

2 recyclerView.setItemViewCacheSize(20);
recyclerView.setDrawingCacheEnabled(true);
recyclerView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
Not sure about this

3 set OnClickListener once in onCreateViewHolder() and call through an interface a listener outside of the Adapter, passing the clicked view. don't create extra objects all the time. Already done

4 by updateing adapter, consider do not collect all items all the time, take advantage of the following methods may help, not tests
adapter.notifyItemRangeInserted(rangeStart, rangeEnd)
adapter.setHasStableIds(true);
adapter.notifyItemRemoved(position);
adapter.notifyItemChanged(position);
adapter.notifyItemInserted(position);
this requires that data which to be served has unique ids.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions