title: IndexOutOfBoundsException: Inconsistency detected. Invalid item position
body: <p><a href="https://i.stack.imgur.com/UK0jE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UK0jE.png" alt="enter image description here"></a></p>
  
  <p>I have a recylerview that have items (containing circle progress bar for survey time left)</p>
  
  <p>I use background thread to update the <code>CircularProgress bar</code> to time left</p>
  
  <p>When I scroll my <code>Recyclerview</code> I get <strong>java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 26(offset:26).state:30</strong></p>
  
  <p>MeetingSurveryAdapter.java</p>
  
  <pre><code>public class MeetingSurveryAdapter extends RecyclerView.Adapter&lt;MeetingSurveryAdapter.SurveyViewHolder&gt; {
  
          private static final String TAG = "SurveryAdapter";
  
          private List&lt;MeetingSurveyModel&gt; list;
          MeetingSurveyModel model;
          private Context mContext;
          private int mSize;
          private UtilMethods utilMethods;
          private AppCompatActivity activity;
  
          private int mPreviousPosition;
  
          // Adapters
          private ArrayAdapter&lt;String&gt; adapterCountry;
  
          private final List&lt;SurveyViewHolder&gt; lstHolders;
  
          private Handler mHandler = new Handler();
          private Runnable updateRemainingTimeRunnable = new Runnable() {
                  @Override
                  public void run() {
                          synchronized (lstHolders) {
                                  long currentTime = System.currentTimeMillis();
                                  for (SurveyViewHolder holder : lstHolders) {
                                          holder.updateTimeRemaining(currentTime);
                                  }
                          }
                  }
          };
  
  
          public MeetingSurveryAdapter(Context mContext, List&lt;MeetingSurveyModel&gt; list) {
                  this.list = list;
                  this.mContext = mContext;
                  this.activity = (AppCompatActivity) mContext;
                  utilMethods = new UtilMethods(mContext);
                  lstHolders = new ArrayList&lt;&gt;();
                  startUpdateTimer();
          }
  
          @Override
          public SurveyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
  
                  View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.row_meeting_survey, viewGroup, false);
                  SurveyViewHolder viewHolder = new SurveyViewHolder(view);
                  return viewHolder;
          }
  
          @Override
          public void onBindViewHolder(final SurveyViewHolder surveyViewHolder, final int position) {
  
                  model = list.get(position);
                  surveyViewHolder.tvTitle.setText(model.Title);
                  surveyViewHolder.tvDate.setText(utilMethods.formatDateMeetingSurvey(model.MeetingDate));
                  surveyViewHolder.tvParticipantsCount.setText("Participants: " + model.Participants);
  
                  surveyViewHolder.setData(list.get(position));
                  synchronized (lstHolders) {
                          lstHolders.add(surveyViewHolder);
                  }
                  surveyViewHolder.updateTimeRemaining(System.currentTimeMillis());
  
                  surveyViewHolder.relativeTitle.setOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
                                  openMettingSurveyList(surveyViewHolder, position);
                          }
                  });
                  if (position &gt; mPreviousPosition) {
                          animate1(surveyViewHolder, true);
                  } else {
                          animate1(surveyViewHolder, false);
                  }
                  mPreviousPosition = position;
          }
  
          private void openMettingSurveyList(SurveyViewHolder surveyViewHolder, int position) {
                  MeetingSurveyModel model = list.get(position);
                  Intent intent = new Intent(mContext, NewActivity.class);
                  intent.putExtra(QrgSensContants.EMP_SURVEY_ID, model.ManualSurvey_Id);
                  activity.startActivity(intent);
          }
  
          @Override
          public int getItemCount() {
                  return list.size();
          }
  
          public class SurveyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
                  @Bind(R.id.relative_title)
                  RelativeLayout relativeTitle;
                  @Bind(R.id.img_number3)
                  ImageView imgNumber3;
                  @Bind(R.id.tv_title)
                  TextView tvTitle;
                  @Bind(R.id.tv_date)
                  TextView tvDate;
                  @Bind(R.id.tv_participants_count)
                  TextView tvParticipantsCount;
                  @Bind(R.id.prg_counter)
                  DonutProgress prgCounter;
                  @Bind(R.id.tv_counter)
                  TextView tvCounter;
  
                  public void setData(MeetingSurveyModel item) {
                          model = item;
                          prgCounter.setSuffixText("");
                          updateTimeRemaining(System.currentTimeMillis());
                  }
  
                  public void updateTimeRemaining(long currentTime) {
                          long timeDiff = utilMethods.getLongDate(model.MeetingDeadLine) - currentTime;
                          if (timeDiff &gt; 0) {
                                  //int minutes= Integer.parseInt(String.format("%d", TimeUnit.MILLISECONDS.toMinutes(timeDiff) ));
                                  int minutes = (int) ((timeDiff / (1000 * 60)) % 60);
                                  prgCounter.setProgress(minutes);
                                  //prgCounter.setSuffixText(""+minutes);
                          } else {
                                  list.remove(getLayoutPosition());
                                  //notifyItemRemoved(getLayoutPosition());
                                  tvCounter.setText("Expired!!");
                                  //prgCounter.setSuffixText("0");
                          }
                  }
  
                  public SurveyViewHolder(View itemView) {
                          super(itemView);
                          ButterKnife.bind(this, itemView);
                          prgCounter.setTextSize(18);
                          prgCounter.setTextColor(mContext.getResources().getColor(R.color.black));
                  }
  
                  @Override
                  public void onClick(View view) {
                          switch (view.getId()) {
                          }
                  }
          }
  
          private void startUpdateTimer() {
                  Timer tmr = new Timer();
                  tmr.schedule(new TimerTask() {
                          @Override
                          public void run() {
                                  mHandler.post(updateRemainingTimeRunnable);
                          }
                  }, 0, 60000);
          }
  
          public void animate1(RecyclerView.ViewHolder holder, boolean goesDown) {
                  int holderHeight = holder.itemView.getHeight();
                  holder.itemView.setPivotY(goesDown == true ? 0 : holderHeight);
  
                  AnimatorSet animatorSet = new AnimatorSet();
                  ObjectAnimator animatorTranslateY = ObjectAnimator.ofFloat(holder.itemView, "translationY", goesDown == true ? 200 : 0, 0);
                  animatorTranslateY.setInterpolator(new AccelerateInterpolator());
  
                  animatorTranslateY.setDuration(700);
                  animatorTranslateY.start();
          }
  }
  </code></pre>