You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using EnumMapBindAdapter to display userposts list .Here I am using 4 binders ,each binder has a list of size 3 .
I have problem with getEnumFromPosition() ,According to my assumptions number of executions of
getEnumFromPosition() method should be equal to number of binders (4) . But it is not happening .I have total 4 binders and I assume getEnumFromPosition()
method should execute 4 times only (0,1,2,3) ,but executions are being excedeed . My assumption may be wrong ,If I am wrong then how can
I manage 4 binders inside getEnumFromPosition() for different positions . If I put else section then it will return a single view when position exceeds .
Here is the code of SampleEnumMapAdapter.java
public class SampleEnumMapAdapter extends EnumMapBindAdapter<SampleEnumMapAdapter.SampleViewType> {
enum SampleViewType{
TEXT,IMAGE_AND_TEXT, AUDIO_AND_TEXT, VIDEO_AND_TEXT
}
public SampleEnumMapAdapter(){
putBinder(SampleViewType.TEXT, new TextBinder(this));
putBinder(SampleViewType.IMAGE_AND_TEXT, new ImageAndTextBinder(this));
putBinder(SampleViewType.AUDIO_AND_TEXT, new AudioAndTextBinder(this));
putBinder(SampleViewType.VIDEO_AND_TEXT, new VideoAndTextBinder(this));
}
public void setData(List<TextData> dataSetText ,List<ImageAndTextData> dataSetTextAndImage ,List<AudioAndTextData> dataSetTextAndAudio ,List<VideoAndTextData> dataSetTextAndVideo ) {
((TextBinder) getDataBinder(SampleViewType.TEXT)).addAll(dataSetText);
((ImageAndTextBinder) getDataBinder(SampleViewType.IMAGE_AND_TEXT)).addAll(dataSetTextAndImage);
((AudioAndTextBinder) getDataBinder(SampleViewType.AUDIO_AND_TEXT)).addAll(dataSetTextAndAudio);
((VideoAndTextBinder) getDataBinder(SampleViewType.VIDEO_AND_TEXT)).addAll(dataSetTextAndVideo);
}
@Override
public SampleViewType getEnumFromPosition(int position){
if (position == 0) {
return SampleViewType.TEXT;
} else if (position == 1) {
return SampleViewType.IMAGE_AND_TEXT;
} else if(position == 2){
return SampleViewType.AUDIO_AND_TEXT;
}else if(position == 3){
return SampleViewType.VIDEO_AND_TEXT;
}
return null;
}
@Override
public SampleViewType getEnumFromOrdinal(int ordinal) {
return SampleViewType.values()[ordinal];
}
}
The text was updated successfully, but these errors were encountered:
ersps25
changed the title
Problem with having 4 Binders
Manage 4 Binders
Nov 24, 2015
@ersps25
Position parameter of getEnumFromPosition is not the position of binder, but the position in total items of binders.
Use EnumListBindAdapter class if you want to show binder items in sequence.
EnumMapBindAdapter is used for the complex layout which need the mapping of position and view type.
So use it if you RecyclerView needs to show items like the following.
eg.
2 items in TextBinder
1 items in ImageAndTextBinder
3 items in AudioAndTextBinder
1 items in ImageAndTextBinder
1 items in TextBinder
etc...
I am using EnumMapBindAdapter to display userposts list .Here I am using 4 binders ,each binder has a list of size 3 .
I have problem with getEnumFromPosition() ,According to my assumptions number of executions of
getEnumFromPosition() method should be equal to number of binders (4) . But it is not happening .I have total 4 binders and I assume getEnumFromPosition()
method should execute 4 times only (0,1,2,3) ,but executions are being excedeed . My assumption may be wrong ,If I am wrong then how can
I manage 4 binders inside getEnumFromPosition() for different positions . If I put else section then it will return a single view when position exceeds .
Here is the code of SampleEnumMapAdapter.java
public class SampleEnumMapAdapter extends EnumMapBindAdapter<SampleEnumMapAdapter.SampleViewType> {
}
The text was updated successfully, but these errors were encountered: