title: Duplicate value append in recycleview multiple view android pagination
body: <p>i m integrate recycleview with multiple view so below is my code </p>
  
  <pre><code>public class ActivityProdcutListWithMulipleView extends AppCompatActivity {
  
  RecyclerView mRecyclerView;
  Toolbar mToolbar;
  PostParseGet mPostParseGet;
  AllMethods mAllMethods;
  GetProductListing mGetProductListing;
  RecyclerView.LayoutManager mLayoutManager;
  ProgressDialog mProgressDialog;
  int page = 1;
  int total = 0;
  int totalFeature = 0;
  int totalbanner = 0;
  ImageView mImageViewBack;
  ArrayList&lt;GetProductListing.ListingBlock&gt; mListingBlocks;
  ArrayList&lt;GetProductListing.ListingBlock&gt; mListingBlocksFeature;
  ArrayList&lt;GetProductListing.ListingBlock&gt; mListingBlocksBanner;
  
  ArrayList&lt;OrderItemDemo&gt; mOrderItemDemos = new ArrayList&lt;OrderItemDemo&gt;();
  GridLayoutManager mLayoutManagerGrid;
  DifferentRowAdapter adapter;
  private Handler handler;
  ArrayList&lt;GetProductListing.ListingBlock&gt; adapterData;
  public static Activity mActivity;
  
  @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.layout_product_list);
      mListingBlocks = new ArrayList&lt;&gt;();
      mActivity = this;
      mListingBlocksFeature = new ArrayList&lt;&gt;();
      mListingBlocksBanner = new ArrayList&lt;&gt;();
  
      mRecyclerView = (RecyclerView) findViewById(R.id.recycle);
      mToolbar = (Toolbar) findViewById(R.id.toolbar);
      mImageViewBack = (ImageView) mToolbar.findViewById(R.id.imgBack);
      WebAPIApplication.mArrayListingAllProductBlocks.clear();
      mPostParseGet = new PostParseGet(ActivityProdcutListWithMulipleView.this);
      mAllMethods = new AllMethods(ActivityProdcutListWithMulipleView.this);
      mGetProductListing = new GetProductListing();
      mLayoutManagerGrid = new GridLayoutManager(ActivityProdcutListWithMulipleView.this, 2);
      mLayoutManager = new LinearLayoutManager(ActivityProdcutListWithMulipleView.this);
      mRecyclerView.setHasFixedSize(true);
      mRecyclerView.setLayoutManager(mLayoutManagerGrid);
      handler = new Handler();
      adapterData = new ArrayList&lt;&gt;();
  
  
      mRecyclerView.addOnScrollListener(new EndlessRecyclerGridOnScrollListener(mLayoutManagerGrid) {
          @Override
          public void onLoadMore(int current_page) {
              if (WebAPIApplication.mArrayListingAllProductBlocks.size() &lt; total) {
  
                  page++;
                  new getProductData(false, true).execute();
              }
          }
      });
  
      adapter = new DifferentRowAdapter(mOrderItemDemos);
      mRecyclerView.setAdapter(adapter);
  
  
      mLayoutManagerGrid.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
          @Override
          public int getSpanSize(int position) {
              return adapter.getItemViewType(position) == OrderItemDemo.BANNER_TYPE ? 2 : 1;
          }
      });
  
      if (mAllMethods.check_Internet() == true) {
          new getProductData(true, false).execute();
      } else {
          mAllMethods.ShowDialog(ActivityProdcutListWithMulipleView.this, "", getString(R.string.net_not_available), "OK");
      }
      mImageViewBack.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              finish();
          }
      });
  }
  
  
  public static class DifferentRowAdapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; {
      private int visibleThreshold = 5;
      private int lastVisibleItem, totalItemCount;
      private boolean loading;
      boolean isLoading = false, isMoreDataAvailable = true;
      private List&lt;OrderItemDemo&gt; mList;
      OnLoadMoreListener loadMoreListener;
  
  
      public DifferentRowAdapter(List&lt;OrderItemDemo&gt; list) {
          this.mList = list;
      }
  
      @Override
      public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view;
  
          switch (viewType) {
              case OrderItemDemo.NORMAL_TYPE:
                  view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_list_file, parent, false);
                  return new ProductListRow(view);
              case OrderItemDemo.FEATURE_TYPE:
                  view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_list_feature_file, parent, false);
                  return new ProductListRow(view);
              case OrderItemDemo.BANNER_TYPE:
                  view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_list_file, parent, false);
                  return new ProductListRow(view);
          }
          return null;
      }
  
      @Override
      public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
          if (position &gt;= getItemCount() - 1 &amp;&amp; isMoreDataAvailable &amp;&amp; !isLoading &amp;&amp; loadMoreListener != null) {
              isLoading = true;
              loadMoreListener.onLoadMore();
          }
  
          final OrderItemDemo object = mList.get(position);
          if (object != null) {
              switch (object.getmType()) {
                  case OrderItemDemo.NORMAL_TYPE:
                      ((ProductListRow) holder).name.setText(object.getId() + " " + object.getTitle());
                      ((ProductListRow) holder).price.setText(object.getType());
  
                      Picasso.with(mActivity)
                              .load(object.getImage())
                              .into(((ProductListRow) holder).mImageViewProduct);
                      ((ProductListRow) holder).mImageViewBanner.setVisibility(View.GONE);
                      ((ProductListRow) holder).mRelativeLayout.setVisibility(View.VISIBLE);
                      break;
                  case OrderItemDemo.FEATURE_TYPE:
                      ((ProductListRow) holder).name.setText(object.getId() + " " + object.getTitle());
                      ((ProductListRow) holder).price.setText(object.getType());
                      ((ProductListRow) holder).mImageViewBanner.setVisibility(View.GONE);
                      ((ProductListRow) holder).mRelativeLayout.setVisibility(View.VISIBLE);
                      Picasso.with(mActivity)
                              .load(object.getImage())
                              .into(((ProductListRow) holder).mImageViewProduct);
                      break;
                  case OrderItemDemo.BANNER_TYPE:
                      ((ProductListRow) holder).price.setText(object.getType());
                      ((ProductListRow) holder).mImageViewBanner.setVisibility(View.VISIBLE);
                      ((ProductListRow) holder).mRelativeLayout.setVisibility(View.GONE);
  
                      break;
              }
          }
      }
  
  
      public void setMoreDataAvailable(boolean moreDataAvailable) {
          isMoreDataAvailable = moreDataAvailable;
      }
  
  
      public void notifyDataChanged() {
          notifyDataSetChanged();
          isLoading = false;
      }
  
  
      interface OnLoadMoreListener {
          void onLoadMore();
      }
  
      public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
          this.loadMoreListener = loadMoreListener;
      }
  
  
      @Override
      public int getItemCount() {
          if (mList == null)
              return 0;
          return mList.size();
      }
  
      @Override
      public int getItemViewType(int position) {
          if (mList != null) {
              OrderItemDemo object = mList.get(position);
              if (object != null) {
                  return object.getmType();
              }
          }
          return 0;
      }
  
  
  }
  
  public abstract class EndlessRecyclerGridOnScrollListener extends
          RecyclerView.OnScrollListener {
      public String TAG = EndlessRecyclerGridOnScrollListener.class
              .getSimpleName();
      private int previousTotal = 0;
      private boolean loading = true;
      private int visibleThreshold = 5;
      int firstVisibleItem, visibleItemCount, totalItemCount;
      private int current_page = 1;
      private LinearLayoutManager mLinearLayoutManager;
  
      public EndlessRecyclerGridOnScrollListener(
              GridLayoutManager linearLayoutManager) {
          this.mLinearLayoutManager = linearLayoutManager;
      }
  
      @Override
      public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
          super.onScrolled(recyclerView, dx, dy);
          visibleItemCount = recyclerView.getChildCount();
          totalItemCount = mLinearLayoutManager.getItemCount();
          firstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition();
          visibleThreshold = total;
          if (loading) {
              if (totalItemCount &gt; previousTotal) {
                  loading = false;
                  previousTotal = totalItemCount;
              }
          }
          if (!loading
                  &amp;&amp; (totalItemCount - visibleItemCount) &lt;= (firstVisibleItem + visibleThreshold)) {
              // End has been reached
              // Do something
              current_page++;
              onLoadMore(current_page);
              loading = true;
          }
      }
  
      public abstract void onLoadMore(int current_page);
  }
  
  
  public class getProductData extends AsyncTask&lt;Void, Void, Void&gt; {
      boolean showLoading;
      boolean pagination;
  
      public getProductData(boolean showLoading, boolean page) {
          this.showLoading = showLoading;
          this.pagination = page;
      }
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          if (showLoading == true) {
              mProgressDialog = ProgressDialog.show(ActivityProdcutListWithMulipleView.this, "", "Loading..");
          }
      }
  
      @Override
      protected Void doInBackground(Void... voids) {
          mGetProductListing = (GetProductListing) mPostParseGet.getTopSearchData(mGetProductListing, page);
          return null;
  
      }
  
      @Override
      protected void onPostExecute(Void aVoid) {
          super.onPostExecute(aVoid);
          if (showLoading == true) {
              if (mProgressDialog != null) {
                  mProgressDialog.dismiss();
              }
          }
          if (mGetProductListing != null) {
              try {
                  total = Integer.parseInt(mGetProductListing.getListing().getTotal());
                  if (mGetProductListing.getListing().getData().size() &gt; 0) {
                      mListingBlocks = getProductBlock();
                      Log.e("FeatureSize", String.valueOf(mListingBlocksFeature.size()));
                      Log.e("BannerSize", String.valueOf(mListingBlocksBanner.size()));
  
                      for (int i = 0; i &lt; WebAPIApplication.mArrayListingAllProductBlocks.size(); i++) {
  
                          if (WebAPIApplication.mArrayListingAllProductBlocks.get(i).getType().equalsIgnoreCase("product")) {
                              mOrderItemDemos.add(new OrderItemDemo(WebAPIApplication.mArrayListingAllProductBlocks.get(i).getId(), WebAPIApplication.mArrayListingAllProductBlocks.get(i).getTitle(), WebAPIApplication.mArrayListingAllProductBlocks.get(i).getType(), WebAPIApplication.mArrayListingAllProductBlocks.get(i).getMedium_image(), OrderItemDemo.NORMAL_TYPE));
                          } else if (WebAPIApplication.mArrayListingAllProductBlocks.get(i).getType().equalsIgnoreCase("featured")) {
                              mOrderItemDemos.add(new OrderItemDemo(WebAPIApplication.mArrayListingAllProductBlocks.get(i).getId(), WebAPIApplication.mArrayListingAllProductBlocks.get(i).getTitle(), WebAPIApplication.mArrayListingAllProductBlocks.get(i).getType(), WebAPIApplication.mArrayListingAllProductBlocks.get(i).getMedium_image(), OrderItemDemo.FEATURE_TYPE));
                          } else {
                              mOrderItemDemos.add(new OrderItemDemo(WebAPIApplication.mArrayListingAllProductBlocks.get(i).getId(), WebAPIApplication.mArrayListingAllProductBlocks.get(i).getTitle(), WebAPIApplication.mArrayListingAllProductBlocks.get(i).getType(), WebAPIApplication.mArrayListingAllProductBlocks.get(i).getMedium_image(), OrderItemDemo.BANNER_TYPE));
                          }
                      }
  
                      adapter = new DifferentRowAdapter(mOrderItemDemos);
                      if (pagination == false) {
                          mRecyclerView.setAdapter(adapter);
                      }
                      adapter.notifyDataSetChanged();
  
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
          }
      }
  }
  
  /*Get Product data  */
  public ArrayList&lt;GetProductListing.ListingBlock&gt; getProductBlock() {
      ArrayList&lt;GetProductListing.ListingBlock&gt; mArrayListParserLog = new ArrayList&lt;GetProductListing.ListingBlock&gt;();
      for (int i = 0; i &lt; mGetProductListing.getListing().getData().size(); i++) {
  
  
          GetProductListing.ListingBlock mParserLog = new GetProductListing.ListingBlock();
          mParserLog.setId(mGetProductListing.getListing().getData().get(i).getId());
          mParserLog.setType(mGetProductListing.getListing().getData().get(i).getType());
          mParserLog.setTitle(mGetProductListing.getListing().getData().get(i).getTitle());
          mParserLog.setDiscountSale(mGetProductListing.getListing().getData().get(i).getDiscountSale());
          mParserLog.setDiscountSelling(mGetProductListing.getListing().getData().get(i).getDiscountSelling());
          mParserLog.setPrice(mGetProductListing.getListing().getData().get(i).getPrice());
          mParserLog.setAupc(mGetProductListing.getListing().getData().get(i).getAupc());
          mParserLog.setSale_end(mGetProductListing.getListing().getData().get(i).getSale_end());
          mParserLog.setSale_start(mGetProductListing.getListing().getData().get(i).getSale_start());
          mParserLog.setSelling_price(mGetProductListing.getListing().getData().get(i).getSelling_price());
          mParserLog.setProduct_rating(mGetProductListing.getListing().getData().get(i).getProduct_rating());
          mParserLog.setSlug(mGetProductListing.getListing().getData().get(i).getSlug());
          mParserLog.setSold_out(mGetProductListing.getListing().getData().get(i).getSold_out());
          mParserLog.setImage(mGetProductListing.getListing().getData().get(i).getImage());
          mParserLog.setSku_id(mGetProductListing.getListing().getData().get(i).getSku_id());
          mParserLog.setMedium_image(mGetProductListing.getListing().getData().get(i).getMedium_image());
          mArrayListParserLog.add(mParserLog);
          WebAPIApplication.mArrayListingAllProductBlocks.add(mParserLog);
  
  
      }
      return mArrayListParserLog;
    }
  
  
  }
  </code></pre>
  
  <p>When i run above code in first page i get proper value but when i call second page at that time first page value will append again with second page data so any idea how can i solve this ? your all suggestions are appreciable </p>