Android RecyclerView item sequence issue
<p>I am new to Android. I am currently trying to build an app having a list view screen where a list of books is displayed. On each item, there is an image downloaded from URL and 2 icons who's image resource is set based on values set in a POJO object.</p>

<p>My Adapter code is as below:</p>

<pre><code>    Context context = view.getContext();
    view.setLayoutManager(new LinearLayoutManager(context));
    view.setAdapter(new MySearchBooksItemRecyclerViewAdapter(SearchBooks.ITEMS, mListener, getActivity()));
</code></pre>

<hr>

<pre><code>    public void onBindViewHolder(final ViewHolder holder, int position) {
    Log.d(TAG, "onBindViewHolder: binding variables of object: " + position);
    Log.d(TAG, "onBindViewHolder: holder value: " + holder.mItem);
    Log.d(TAG, "onBindViewHolder: holder value: " + holder.mTitle);
    Log.d(TAG, "onBindViewHolder: holder value: " + holder.mISBN);

    holder.mItem = mValues.get(position);
    holder.mTitle.setText(mValues.get(position).getTitle());
    holder.mTitle.setTag(mValues.get(position).getId());
    holder.mISBN.setText(mValues.get(position).getIsbn());
    holder.mDesc.setText(mValues.get(position).getDesc());
    holder.mView.setOnClickListener(new ClickListItem());

    getImages(holder.mBookImage, mValues.get(position).getImage());

    if (bookList.get(mValues.get(position).getId()) != null) {
        holder.mIsFav.setImageResource(bookList.get(mValues.get(position).getId()).isBookmarked() ? R.drawable.ic_favorite_white_24dp : R.drawable.ic_favorite_border_white_24dp);
        holder.mIsDownloaded.setImageResource(new File(bookList.get(mValues.get(position).getId()).getSavedBookName()).exists() ? R.drawable.ic_offline_pin_white_24dp : R.drawable.ic_get_app_white_24dp);
    }

    Log.d(TAG, "onBindViewHolder: variables bound: " + mValues.get(position));
}

@Override
public int getItemCount() {
    Log.d(TAG, "getItemCount: item count: " + mValues.size());
    return mValues.size();
}
</code></pre>

<hr>

<pre><code>    &lt;LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:backgroundTint="@android:color/darker_gray"
    android:orientation="horizontal"&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:background="@color/background_material_dark"
        android:orientation="vertical"&gt;

        &lt;ImageView
            android:id="@+id/bookImage"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:minHeight="100dp"

            android:layout_weight="2"
            android:src="@drawable/icon_img_tu" /&gt;

        &lt;LinearLayout
            android:layout_weight="1"
            android:minHeight="40dp"
            android:layout_gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:orientation="horizontal"&gt;

            &lt;ImageView
                android:id="@+id/is_fav_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:src="@drawable/ic_favorite_border_white_24dp" /&gt;

            &lt;ImageView
                android:id="@+id/is_downloaded_image"
                android:layout_weight="1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/background_material_dark"
                android:src="@drawable/ic_get_app_white_24dp" /&gt;

        &lt;/LinearLayout&gt;
    &lt;/LinearLayout&gt;
</code></pre>

<p>Now the problem comes when I scroll through the screen. in the first load the icon values and images are perfectly loaded. but when I scroll across and return back, the 'onBindViewHolder' is again called and wrong random values are used. thus showing wrong icons in the images.</p>

<p>can anyone help me how to fix this...??</p>

<p>i don't want the images to be reloaded or the icons to be refreshed unless needed</p>