I have fragment "Incoming" on one slide of a viewpager
. This fragment contains a RecyclerView
populated with custom-relative-layouts
. The LinearLayoutManager
orientation is Vertical.
I have a second fragment "Find" on the next slide of the said viewpager. "Find" will consist of two recyclerviews. It will have a Horizontal recyclerview
filled with cardviews
(fast loading of profile pictures). Underneath that, I am loading more slowly another recyclerview
with a custom-relative-layout
, the same as in the "incoming" fragment.
Does that make sense? I'll elaborate some more:
The question is for these three recyclerviews, should I declare a new RecyclerAdapter
for each one? The reason I ask is that they'll all have unknown variable item_counts.
Here is the RecyclerAdapter I have for "Incoming":
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ViewHolder>{
private Context mContext;
public RecyclerAdapter(Context context, List<Incoming> items) {
mContext = context;
}
public static class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(View v) {
super(v);
// Define all of the components in the view
}
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater mInf = LayoutInflater.from(mContext);
View customView = mInf.inflate(R.layout.item_layout_incoming, parent, false);
final ViewHolder vh = new ViewHolder(customView);
return vh;
}
@Override
public int getItemCount(){ return 6; } // THIS IS TEMPORARY; WILL BE VARIABLE
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
// Replace contents
}
For my criteria, should I create another Adapter for my horizontal-cardview-recyclerview
? It seems repetitive, but otherwise, how would I handle either inflating cardview
or item_layout_incoming
?
Seems like there should be a DRY way to do this, without hits to performance. Thanks