rockerhieu / rv-adapter-endless

Endless support for RecyclerView.Adapter
MIT License
107 stars 24 forks source link

Simplify constructors by removing context argument from their parameters #9

Closed ldt116 closed 7 years ago

ldt116 commented 8 years ago

We have 2 contructors as below

public EndlessRecyclerViewAdapter(Context context, Adapter wrapped, RequestToLoadMoreListener requestToLoadMoreListener, @LayoutRes int pendingViewResId, boolean keepOnAppending) {
...
public EndlessRecyclerViewAdapter(Context context, Adapter wrapped, RequestToLoadMoreListener requestToLoadMoreListener) {

Actually, the context is used for getting layout inflater service

 private View getPendingView(ViewGroup viewGroup) {
        return LayoutInflater.from(context).inflate(pendingViewResId, viewGroup, false);
 }

We can reduce this by getting the context from the viewGroup in getPendingView.