Removing Item From Recyclerview When Time Expired
<p>I need to remove an item when time expired, partially i got output by referring this <a href="https://stackoverflow.com/questions/31059251/how-to-handle-multiple-countdown-timers-in-listview">How to handle multiple countdown timers in ListView?</a></p>

<p>After scrolled the list, some of the time expired items are not removed and times are not updated.</p>

<pre><code>package com.techno.deliveryboy.Adapter;

import android.os.Handler;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.techno.deliveryboy.Pojos.DummyTimer;
import com.techno.deliveryboy.R;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by developer on 23/7/16.
 */
public class Incoiming_orders_Adapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt;  {

    private LayoutInflater lf;
    Boolean onBind = true;
    private List&lt;MyViewHolder&gt; lstHolders;
    ArrayList&lt;Integer&gt; unbindvalues=new ArrayList&lt;&gt;();
    private Handler mHandler = new Handler();
    List&lt;DummyTimer&gt; lstProducts=new ArrayList&lt;&gt;();
    private Runnable updateRemainingTimeRunnable = new Runnable() {
        @Override
        public void run() {
            synchronized (lstHolders) {
                long currentTime = System.currentTimeMillis();

                for (MyViewHolder holder : lstHolders) {

                    holder.updateTimeRemaining(currentTime);


                }


            }
        }
    };

    public Incoiming_orders_Adapter(FragmentActivity activity, List&lt;DummyTimer&gt; lstProduct) {

        lstHolders = new ArrayList&lt;&gt;();
        lstProducts=lstProduct;

        startUpdateTimer();
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.incoming_orders_item, parent, false);
        return new MyViewHolder(itemView);
    }

    private void startUpdateTimer() {
        Timer tmr = new Timer();
        tmr.schedule(new TimerTask() {
            @Override
            public void run() {
                mHandler.post(updateRemainingTimeRunnable);

            }
        }, 1000, 1000);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
      if(holder instanceof MyViewHolder){
          onBind=true;
          MyViewHolder holder1= (MyViewHolder) holder;
          synchronized (lstHolders) {
              lstHolders.add(holder1);

           }
          holder1.setData(lstProducts.get(position),position);
          onBind=false;

      }
    }

    @Override
    public int getItemCount() {
        return lstProducts.size();
    }
    public void removeAt(int position) {

       /* for (Iterator&lt;MyViewHolder&gt; iterator = lstHolders.iterator(); iterator.hasNext();) {

           iterator.remove();
        }*/


        if(!onBind) {
            if(unbindvalues!=null&amp;&amp;unbindvalues.size()!=0&amp;&amp;position&gt;=0){
                for (Integer i:unbindvalues) {
                    lstProducts.remove(position);
                    notifyItemRemoved(position);
                }
                unbindvalues.clear();

            }else {
                if(position&gt;=0){
                    lstProducts.remove(position);
                    notifyItemRemoved(position);
                }

            }




            notifyDataSetChanged();
        }else {
            System.out.println("+Bind-&gt;true+");
            if(position&gt;=0)
            unbindvalues.add(position);
        }
    }


    public class MyViewHolder extends RecyclerView.ViewHolder {
        public TextView title, tvTimeRemaining, genre;
        DummyTimer mProduct;
        public void setData(DummyTimer item, int position) {
            mProduct = item;
            title.setText(item.name);
            updateTimeRemaining(System.currentTimeMillis());
        }

        public MyViewHolder(View view) {
            super(view);
            title = (TextView) view.findViewById(R.id.Item_Totalvalue);
            tvTimeRemaining= (TextView) view.findViewById(R.id.Item_timeout);
        }

        public void updateTimeRemaining(long currentTime) {
            long timeDiff = mProduct.expirationTime - currentTime;
            if (timeDiff &gt; 0) {
                int seconds = (int) (timeDiff / 1000) % 60;
                int minutes = (int) ((timeDiff / (1000 * 60)) % 60);
                int hours = (int) ((timeDiff / (1000 * 60 * 60)) % 24);
                tvTimeRemaining.setText(hours + " hrs " + minutes + " mins " + seconds + " sec");
            } else {
              // tvTimeRemaining.setText(String.valueOf(getAdapterPosition()));


                removeAt(getAdapterPosition());

            }
        }
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
}
</code></pre>

<p>Please give your comment.</p>