Skip to content

Commit 58d9a23

Browse files
authored
Merge pull request #189 from ndefeijter/master
FirebaseRecyclerAdapter: use use the parameter 'viewType' to inflate view layout. #86
2 parents 78e3c6d + 1b16991 commit 58d9a23

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public long getItemId(int position) {
157157

158158
@Override
159159
public VH onCreateViewHolder(ViewGroup parent, int viewType) {
160-
ViewGroup view = (ViewGroup) LayoutInflater.from(parent.getContext()).inflate(mModelLayout, parent, false);
160+
ViewGroup view = (ViewGroup) LayoutInflater.from(parent.getContext()).inflate(viewType, parent, false);
161161
try {
162162
Constructor<VH> constructor = mViewHolderClass.getConstructor(View.class);
163163
return constructor.newInstance(view);
@@ -177,6 +177,11 @@ public void onBindViewHolder(VH viewHolder, int position) {
177177
populateViewHolder(viewHolder, model, position);
178178
}
179179

180+
@Override
181+
public int getItemViewType(int position) {
182+
return mModelLayout;
183+
}
184+
180185
/**
181186
* Each time the data at the given Firebase location changes, this method will be called for each item that needs
182187
* to be displayed. The first two arguments correspond to the mLayout and mModelClass given to the constructor of

0 commit comments

Comments
 (0)