Can somebody explain what is the problem.
I have a recycler grid view with each item consisting countdown timer and view which changes after a countdown time is completed.
But the problem arises when I do scroll to down and back to top, my items were change for other items in the list, and if I do scroll again, the items again are changed.
This is my adapter.
public class TableTransactionRecyclerView extends RecyclerView.Adapter<TableTransactionRecyclerView.ViewHolder> {
    private ArrayList<TableInfo> tableList;
    private OnItemClickListener listener;
    private static Context context;
    private static SharedPreferences preferences;
    private static List<ViewHolder> lstHolders;
    public Runnable updateRemainingTimeRunnable = new Runnable() {
        @Override
        public void run() {
            synchronized (lstHolders) {
                for (ViewHolder holder : lstHolders) {
                    holder.updateTimeRemaining();
                }
            }
        }
    };
    public TableTransactionRecyclerView(Context context, ArrayList<TableInfo> tableList, OnItemClickListener listener) {
        this.tableList = tableList;
        this.listener = listener;
        this.context = context;
        preferences = context.getSharedPreferences(CommonConsts.MY_PREFERENCES, Context.MODE_PRIVATE);
        lstHolders = new ArrayList<>();
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ViewHolder vh;
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.table_transaction_row_layout, parent, false);
        vh = new ViewHolder(itemView);
        synchronized (lstHolders) {
            lstHolders.add(vh);
        }
        return vh;
    }
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.bind(tableList, position, listener);
    }
    @Override
    public int getItemCount() {
        return tableList.size();
    }
    public static class ViewHolder extends  RecyclerView.ViewHolder {
        private TextView textView;
        public ImageButton popupMenuBtn;
        private ProgressBar showLoadingImage;
        private ImageView successTick;
        private ImageView tableIcon;
        private LinearLayout processingLayout;
        private View lineView;
        private LatoTextView transactionAmountTextView;
        private LatoTextView timerCountTextView;
        private ArrayList<TableInfo> tableList;
        private int position;
        public ViewHolder(View itemView) {
            super(itemView);
            textView = (TextView) itemView.findViewById(R.id.table_id_text_view);
            popupMenuBtn = (ImageButton) itemView.findViewById(R.id.pop_menu_btn);
            showLoadingImage = (ProgressBar) itemView.findViewById(R.id.show_loading_image);
            successTick = (ImageView) itemView.findViewById(R.id.success_image_view);
            lineView = itemView.findViewById(R.id.view_id);
            tableIcon = (ImageView) itemView.findViewById(R.id.table_icon);
            processingLayout = (LinearLayout) itemView.findViewById(R.id.processing_layout);
            transactionAmountTextView = (LatoTextView) itemView.findViewById(R.id.transaction_amount_text_view);
            timerCountTextView = (LatoTextView) itemView.findViewById(R.id.timer_count_down_id);
        }
        public void bind(final ArrayList<TableInfo> tableList, final int position, final OnItemClickListener listener) {
            TableInfo item = tableList.get(position);
            this.tableList = tableList;
            this.position = position;
            textView.setText(item.getTableNumber());
            if (item.getIsProcessing()) {
                showLoadingImage.setVisibility(View.VISIBLE);
                successTick.setVisibility(View.GONE);
                tableIcon.setVisibility(View.GONE);
                processingLayout.setVisibility(View.VISIBLE);
                transactionAmountTextView.setText(Utils.setFormattedText(String.valueOf(item.getTransactionAmt())));
                synchronized (lstHolders) {
                    updateTimeRemaining();
                }
            } else {
                showLoadingImage.setVisibility(View.GONE);
                tableIcon.setVisibility(View.VISIBLE);
                processingLayout.setVisibility(View.GONE);
            }
            setLayout(tableList, position, item.getIsProcessing(), item.isLastTransactionSuccess());
        }
        public void setLayout(final ArrayList<TableInfo> tableList, final int position, boolean isTransaction, boolean isSuccess) {
            final TableInfo item = tableList.get(position);
            if(isTransaction){
                item.setHandler(null);
                item.setUIChangeCompletedSuccess(true);
                showLoadingImage.setVisibility(View.VISIBLE);
                tableIcon.setVisibility(View.GONE);
                processingLayout.setVisibility(View.VISIBLE);
                transactionAmountTextView.setText(Utils.setFormattedText(String.valueOf(item.getTransactionAmt())));
                lineView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.txn_view_drawable));
            }else{
                showLoadingImage.setVisibility(View.GONE);
                tableIcon.setVisibility(View.VISIBLE);
                processingLayout.setVisibility(View.GONE);
                if(item.isUIChangeCompletedSuccess()) {
                    item.setUIChangeCompletedSuccess(false);
                    if (isSuccess) {
                        successTick.setVisibility(View.VISIBLE);
                        lstHolders.get(position).lineView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.txn_success_view_drawable));
                        Handler handler;
                        if (item.getHandler() == null) {
                            handler = new Handler();
                            item.setHandler(handler);
                            handler.postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    lstHolders.get(position).lineView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.txn_view_drawable));
                                    successTick.setVisibility(View.GONE);
                                    item.setHandler(null);
                                }
                            }, 25000);
                        }
                    } else {
                        successTick.setVisibility(View.GONE);
                        lstHolders.get(0).lineView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.txn_unsuccess_view_drawable));
                        Handler handler;
                        if (item.getHandler() == null) {
                            handler = new Handler();
                            item.setHandler(handler);
                            handler.postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    lstHolders.get(position).lineView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.txn_view_drawable));
                                    successTick.setVisibility(View.GONE);
                                    item.setHandler(null);
                                }
                            }, 25000);
                        }
                    }
                }
            }
        }
        public void updateTimeRemaining() {
            timerCountTextView.setText(preferences.getString(tableList.get(position).getTableId(), ""));
        }
    }
}
and i have set adapter like this:
mAdapter = new TableTransactionRecyclerView(this, tableList, this);
            RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getApplicationContext(), 4, GridLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setHasFixedSize(true);
recyclerView.setAdapter(mAdapter);
I have also looked at the problem in following links which didnot solved my problem.
 
    