title: Manage Multiple View Types - RecyclerView
body: <p>I am using <a href="https://github.com/yqritc/RecyclerView-MultipleViewTypesAdapter" rel="nofollow">this</a> library to display mutiple types of views inside a RecyclerView .</p>
  
  <p>Here I am using EnumMapBindAdapter to display userposts list .</p>
  
  <p>I have 4 DataBinder classes ,each binder has a list of size 3 (size may change depending on the 
  user posts ) . 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 inside getEnumFromPosition() method then it will return a single view when position exceeds .</p>
  
  <p><strong>Here is the code of SampleEnumMapAdapter.java</strong></p>
  
  <pre><code> public class SampleEnumMapAdapter extends EnumMapBindAdapter&lt;SampleEnumMapAdapter.SampleViewType&gt; {
  
      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&lt;TextData&gt; dataSetText ,List&lt;ImageAndTextData&gt; dataSetTextAndImage ,List&lt;AudioAndTextData&gt; dataSetTextAndAudio ,List&lt;VideoAndTextData&gt; 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];
      }
  }
  </code></pre>