<p dir="auto"><strong>Glide Version</strong>: 4.0.0-RC1</p>

<p dir="auto"><strong>Integration libraries</strong>: okhttp3, recyclerview</p>

<p dir="auto"><strong>Device/Android Version</strong>: Fails on One plus 3t, and Nexus 6p</p>

<p dir="auto"><strong>Issue details / Repro steps / Use case background</strong>: Have a long list of items, scroll fast, when you rotate the screen (setRetainInstance(true)) the fragment stays in position. as soon as you then start to scroll this crash happens</p>

<p dir="auto"><strong>Stack trace / LogCat</strong>:</p>
<div class="highlight highlight-source-ruby notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="java.lang.IllegalStateException: Failed to remove target from managers
       at com.bumptech.glide.Glide.removeFromManagers(Glide.java:625)
       at com.bumptech.glide.RequestManager.untrackOrDelegate(RequestManager.java:426)
       at com.bumptech.glide.RequestManager.clear(RequestManager.java:412)
       at com.bumptech.glide.RequestManager.clear(RequestManager.java:397)
       at xxx.loadImage(ChatAdapter.java:162)
       at xxx.onBindViewHolder(ChatAdapter.java:156)
       at xxx.onBindViewHolder(ChatAdapter.java:111)
       at xxx.onBindViewHolder(ChatAdapter.java:49)
       at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6507)
       at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5450)
       at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5716)
       at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5555)
       at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5551)
       at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2211)
       at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1538)
       at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1498)
       at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1312)
       at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:1057)
       at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4836)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:886)
       at android.view.Choreographer.doCallbacks(Choreographer.java:698)
       at android.view.Choreographer.doFrame(Choreographer.java:630)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:872)
       at android.os.Handler.handleCallback(Handler.java:769)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6541)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)"><pre class="notranslate"><span class="pl-en">java</span><span class="pl-kos">.</span><span class="pl-en">lang</span><span class="pl-kos">.</span><span class="pl-en">IllegalStateException</span>: <span class="pl-en">Failed</span> <span class="pl-en">to</span> <span class="pl-en">remove</span> <span class="pl-en">target</span> <span class="pl-en">from</span> <span class="pl-en">managers</span>
       <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">Glide</span><span class="pl-kos">.</span><span class="pl-en">removeFromManagers</span><span class="pl-kos">(</span><span class="pl-v">Glide</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:625</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">RequestManager</span><span class="pl-kos">.</span><span class="pl-en">untrackOrDelegate</span><span class="pl-kos">(</span><span class="pl-v">RequestManager</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:426</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">RequestManager</span><span class="pl-kos">.</span><span class="pl-en">clear</span><span class="pl-kos">(</span><span class="pl-v">RequestManager</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:412</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">RequestManager</span><span class="pl-kos">.</span><span class="pl-en">clear</span><span class="pl-kos">(</span><span class="pl-v">RequestManager</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:397</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">xxx</span><span class="pl-kos">.</span><span class="pl-en">loadImage</span><span class="pl-kos">(</span><span class="pl-v">ChatAdapter</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:162</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">xxx</span><span class="pl-kos">.</span><span class="pl-en">onBindViewHolder</span><span class="pl-kos">(</span><span class="pl-v">ChatAdapter</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:156</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">xxx</span><span class="pl-kos">.</span><span class="pl-en">onBindViewHolder</span><span class="pl-kos">(</span><span class="pl-v">ChatAdapter</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:111</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">xxx</span><span class="pl-kos">.</span><span class="pl-en">onBindViewHolder</span><span class="pl-kos">(</span><span class="pl-v">ChatAdapter</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:49</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">support</span><span class="pl-kos">.</span><span class="pl-en">v7</span><span class="pl-kos">.</span><span class="pl-en">widget</span><span class="pl-kos">.</span><span class="pl-en">RecyclerView</span>$Adapter<span class="pl-kos">.</span><span class="pl-en">bindViewHolder</span><span class="pl-kos">(</span><span class="pl-v">RecyclerView</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:6507</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">support</span><span class="pl-kos">.</span><span class="pl-en">v7</span><span class="pl-kos">.</span><span class="pl-en">widget</span><span class="pl-kos">.</span><span class="pl-en">RecyclerView</span>$Recycler<span class="pl-kos">.</span><span class="pl-en">tryBindViewHolderByDeadline</span><span class="pl-kos">(</span><span class="pl-v">RecyclerView</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:5450</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">support</span><span class="pl-kos">.</span><span class="pl-en">v7</span><span class="pl-kos">.</span><span class="pl-en">widget</span><span class="pl-kos">.</span><span class="pl-en">RecyclerView</span>$Recycler<span class="pl-kos">.</span><span class="pl-en">tryGetViewHolderForPositionByDeadline</span><span class="pl-kos">(</span><span class="pl-v">RecyclerView</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:5716</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">support</span><span class="pl-kos">.</span><span class="pl-en">v7</span><span class="pl-kos">.</span><span class="pl-en">widget</span><span class="pl-kos">.</span><span class="pl-en">RecyclerView</span>$Recycler<span class="pl-kos">.</span><span class="pl-en">getViewForPosition</span><span class="pl-kos">(</span><span class="pl-v">RecyclerView</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:5555</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">support</span><span class="pl-kos">.</span><span class="pl-en">v7</span><span class="pl-kos">.</span><span class="pl-en">widget</span><span class="pl-kos">.</span><span class="pl-en">RecyclerView</span>$Recycler<span class="pl-kos">.</span><span class="pl-en">getViewForPosition</span><span class="pl-kos">(</span><span class="pl-v">RecyclerView</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:5551</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">support</span><span class="pl-kos">.</span><span class="pl-en">v7</span><span class="pl-kos">.</span><span class="pl-en">widget</span><span class="pl-kos">.</span><span class="pl-en">LinearLayoutManager</span>$LayoutState<span class="pl-kos">.</span><span class="pl-en">next</span><span class="pl-kos">(</span><span class="pl-v">LinearLayoutManager</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:2211</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">support</span><span class="pl-kos">.</span><span class="pl-en">v7</span><span class="pl-kos">.</span><span class="pl-en">widget</span><span class="pl-kos">.</span><span class="pl-en">LinearLayoutManager</span><span class="pl-kos">.</span><span class="pl-en">layoutChunk</span><span class="pl-kos">(</span><span class="pl-v">LinearLayoutManager</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:1538</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">support</span><span class="pl-kos">.</span><span class="pl-en">v7</span><span class="pl-kos">.</span><span class="pl-en">widget</span><span class="pl-kos">.</span><span class="pl-en">LinearLayoutManager</span><span class="pl-kos">.</span><span class="pl-en">fill</span><span class="pl-kos">(</span><span class="pl-v">LinearLayoutManager</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:1498</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">support</span><span class="pl-kos">.</span><span class="pl-en">v7</span><span class="pl-kos">.</span><span class="pl-en">widget</span><span class="pl-kos">.</span><span class="pl-en">LinearLayoutManager</span><span class="pl-kos">.</span><span class="pl-en">scrollBy</span><span class="pl-kos">(</span><span class="pl-v">LinearLayoutManager</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:1312</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">support</span><span class="pl-kos">.</span><span class="pl-en">v7</span><span class="pl-kos">.</span><span class="pl-en">widget</span><span class="pl-kos">.</span><span class="pl-en">LinearLayoutManager</span><span class="pl-kos">.</span><span class="pl-en">scrollVerticallyBy</span><span class="pl-kos">(</span><span class="pl-v">LinearLayoutManager</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:1057</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">support</span><span class="pl-kos">.</span><span class="pl-en">v7</span><span class="pl-kos">.</span><span class="pl-en">widget</span><span class="pl-kos">.</span><span class="pl-en">RecyclerView</span>$ViewFlinger<span class="pl-kos">.</span><span class="pl-en">run</span><span class="pl-kos">(</span><span class="pl-v">RecyclerView</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:4836</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">view</span><span class="pl-kos">.</span><span class="pl-en">Choreographer</span>$CallbackRecord<span class="pl-kos">.</span><span class="pl-en">run</span><span class="pl-kos">(</span><span class="pl-v">Choreographer</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:886</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">view</span><span class="pl-kos">.</span><span class="pl-en">Choreographer</span><span class="pl-kos">.</span><span class="pl-en">doCallbacks</span><span class="pl-kos">(</span><span class="pl-v">Choreographer</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:698</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">view</span><span class="pl-kos">.</span><span class="pl-en">Choreographer</span><span class="pl-kos">.</span><span class="pl-en">doFrame</span><span class="pl-kos">(</span><span class="pl-v">Choreographer</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:630</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">view</span><span class="pl-kos">.</span><span class="pl-en">Choreographer</span>$FrameDisplayEventReceiver<span class="pl-kos">.</span><span class="pl-en">run</span><span class="pl-kos">(</span><span class="pl-v">Choreographer</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:872</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">os</span><span class="pl-kos">.</span><span class="pl-en">Handler</span><span class="pl-kos">.</span><span class="pl-en">handleCallback</span><span class="pl-kos">(</span><span class="pl-v">Handler</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:769</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">os</span><span class="pl-kos">.</span><span class="pl-en">Handler</span><span class="pl-kos">.</span><span class="pl-en">dispatchMessage</span><span class="pl-kos">(</span><span class="pl-v">Handler</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:98</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">os</span><span class="pl-kos">.</span><span class="pl-en">Looper</span><span class="pl-kos">.</span><span class="pl-en">loop</span><span class="pl-kos">(</span><span class="pl-v">Looper</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:164</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">app</span><span class="pl-kos">.</span><span class="pl-en">ActivityThread</span><span class="pl-kos">.</span><span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-v">ActivityThread</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:6541</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">java</span><span class="pl-kos">.</span><span class="pl-en">lang</span><span class="pl-kos">.</span><span class="pl-en">reflect</span><span class="pl-kos">.</span><span class="pl-en">Method</span><span class="pl-kos">.</span><span class="pl-en">invoke</span><span class="pl-kos">(</span><span class="pl-en">Native</span> <span class="pl-v">Method</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">internal</span><span class="pl-kos">.</span><span class="pl-en">os</span><span class="pl-kos">.</span><span class="pl-en">Zygote</span>$MethodAndArgsCaller<span class="pl-kos">.</span><span class="pl-en">run</span><span class="pl-kos">(</span><span class="pl-v">Zygote</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:240</span><span class="pl-kos">)</span>
       <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">internal</span><span class="pl-kos">.</span><span class="pl-en">os</span><span class="pl-kos">.</span><span class="pl-en">ZygoteInit</span><span class="pl-kos">.</span><span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-v">ZygoteInit</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:767</span><span class="pl-kos">)</span></pre></div>
<p dir="auto"><strong>Glide Version</strong>: 3.7.0</p>

<p dir="auto"><strong>Integration libraries</strong>: no</p>

<p dir="auto"><strong>Device/Android Version</strong>: HUAWEI P7</p>

<p dir="auto"><strong>Issue details / Repro steps / Use case background</strong>: Set a touch effect for ImageView</p>

<p dir="auto"><strong>Glide load line / <code class="notranslate">GlideModule</code> (if any) / list Adapter code (if any)</strong>:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    class TestAdapter extends RecyclerView.Adapter&lt;TestAdapter.TestViewHolder&gt;  {

        private String[] imageUrls;
        private Context mContext;

        public TestAdapter(Context context, String[] imageUrls) {
            this.mContext = context;
            this.imageUrls = imageUrls;
        }

        @Override
        public TestViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.
                    from(mContext).inflate(R.layout.item_recyclerview_history, parent, false);
            TestActivity.TestAdapter.TestViewHolder holder = new TestActivity.TestAdapter.TestViewHolder(view);
            holder.image.setRatio(1.5f);
            return holder;
        }

        @Override
        public void onBindViewHolder(TestViewHolder holder, int position) {

            Glide.with(TestActivity.this).load(imageUrls[position]).
                    crossFade().placeholder(R.mipmap.pic_error).into(holder.image);
        }

        @Override
        public int getItemCount() {
            return imageUrls.length;
        }

        class TestViewHolder extends RecyclerView.ViewHolder {

            RatioImageView image;

            public TestViewHolder(View itemView) {
                super(itemView);
                image = (RatioImageView) itemView.findViewById(R.id.image);
            }
        }
    }
// This is my RatioImageView .Actually it is from (https://github.com/HMY314/NineGridLayout/blob/master/app/src/main/java/com/hmy/ninegridlayout/view/RatioImageView.java)
public class RatioImageView extends ImageView {

    private float mRatio = 0f;

    public RatioImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public RatioImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RatioImageView);

        mRatio = typedArray.getFloat(R.styleable.RatioImageView_ratio, 0f);
        typedArray.recycle();
    }

    public RatioImageView(Context context) {
        super(context);
    }

    public void setRatio(float ratio) {
        mRatio = ratio;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);
        if (mRatio != 0) {
            float height = width / mRatio;
            heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) height, MeasureSpec.EXACTLY);
        }
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                Drawable drawable = getDrawable();
                if (drawable != null) {
                    drawable.mutate().setColorFilter(Color.GRAY,
                            PorterDuff.Mode.MULTIPLY);
                }
                break;
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP:
                Drawable drawableUp = getDrawable();
                if (drawableUp != null) {
                    drawableUp.mutate().clearColorFilter();
                }
                break;
        }

        return super.onTouchEvent(event);
    }
}
"><pre class="notranslate">    <span class="pl-k">class</span> <span class="pl-smi">TestAdapter</span> <span class="pl-k">extends</span> <span class="pl-smi">RecyclerView</span>.<span class="pl-smi">Adapter</span>&lt;<span class="pl-smi">TestAdapter</span>.<span class="pl-smi">TestViewHolder</span>&gt;  {

        <span class="pl-k">private</span> <span class="pl-smi">String</span>[] <span class="pl-s1">imageUrls</span>;
        <span class="pl-k">private</span> <span class="pl-smi">Context</span> <span class="pl-s1">mContext</span>;

        <span class="pl-k">public</span> <span class="pl-smi">TestAdapter</span>(<span class="pl-smi">Context</span> <span class="pl-s1">context</span>, <span class="pl-smi">String</span>[] <span class="pl-s1">imageUrls</span>) {
            <span class="pl-smi">this</span>.<span class="pl-s1">mContext</span> = <span class="pl-s1">context</span>;
            <span class="pl-smi">this</span>.<span class="pl-s1">imageUrls</span> = <span class="pl-s1">imageUrls</span>;
        }

        <span class="pl-c1">@</span><span class="pl-c1">Override</span>
        <span class="pl-k">public</span> <span class="pl-smi">TestViewHolder</span> <span class="pl-en">onCreateViewHolder</span>(<span class="pl-smi">ViewGroup</span> <span class="pl-s1">parent</span>, <span class="pl-smi">int</span> <span class="pl-s1">viewType</span>) {
            <span class="pl-smi">View</span> <span class="pl-s1">view</span> = <span class="pl-smi">LayoutInflater</span>.
                    <span class="pl-en">from</span>(<span class="pl-s1">mContext</span>).<span class="pl-en">inflate</span>(<span class="pl-smi">R</span>.<span class="pl-s1">layout</span>.<span class="pl-s1">item_recyclerview_history</span>, <span class="pl-s1">parent</span>, <span class="pl-c1">false</span>);
            <span class="pl-smi">TestActivity</span>.<span class="pl-smi">TestAdapter</span>.<span class="pl-smi">TestViewHolder</span> <span class="pl-s1">holder</span> = <span class="pl-k">new</span> <span class="pl-smi">TestActivity</span>.<span class="pl-smi">TestAdapter</span>.<span class="pl-smi">TestViewHolder</span>(<span class="pl-s1">view</span>);
            <span class="pl-s1">holder</span>.<span class="pl-s1">image</span>.<span class="pl-en">setRatio</span>(<span class="pl-c1">1.5f</span>);
            <span class="pl-k">return</span> <span class="pl-s1">holder</span>;
        }

        <span class="pl-c1">@</span><span class="pl-c1">Override</span>
        <span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">onBindViewHolder</span>(<span class="pl-smi">TestViewHolder</span> <span class="pl-s1">holder</span>, <span class="pl-smi">int</span> <span class="pl-s1">position</span>) {

            <span class="pl-smi">Glide</span>.<span class="pl-en">with</span>(<span class="pl-smi">TestActivity</span>.<span class="pl-smi">this</span>).<span class="pl-en">load</span>(<span class="pl-s1">imageUrls</span>[<span class="pl-s1">position</span>]).
                    <span class="pl-en">crossFade</span>().<span class="pl-en">placeholder</span>(<span class="pl-smi">R</span>.<span class="pl-s1">mipmap</span>.<span class="pl-s1">pic_error</span>).<span class="pl-en">into</span>(<span class="pl-s1">holder</span>.<span class="pl-s1">image</span>);
        }

        <span class="pl-c1">@</span><span class="pl-c1">Override</span>
        <span class="pl-k">public</span> <span class="pl-smi">int</span> <span class="pl-en">getItemCount</span>() {
            <span class="pl-k">return</span> <span class="pl-s1">imageUrls</span>.<span class="pl-s1">length</span>;
        }

        <span class="pl-k">class</span> <span class="pl-smi">TestViewHolder</span> <span class="pl-k">extends</span> <span class="pl-smi">RecyclerView</span>.<span class="pl-smi">ViewHolder</span> {

            <span class="pl-smi">RatioImageView</span> <span class="pl-s1">image</span>;

            <span class="pl-k">public</span> <span class="pl-smi">TestViewHolder</span>(<span class="pl-smi">View</span> <span class="pl-s1">itemView</span>) {
                <span class="pl-en">super</span>(<span class="pl-s1">itemView</span>);
                <span class="pl-s1">image</span> = (<span class="pl-smi">RatioImageView</span>) <span class="pl-s1">itemView</span>.<span class="pl-en">findViewById</span>(<span class="pl-smi">R</span>.<span class="pl-s1">id</span>.<span class="pl-s1">image</span>);
            }
        }
    }
<span class="pl-c">// This is my RatioImageView .Actually it is from (https://github.com/HMY314/NineGridLayout/blob/master/app/src/main/java/com/hmy/ninegridlayout/view/RatioImageView.java)</span>
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">RatioImageView</span> <span class="pl-k">extends</span> <span class="pl-smi">ImageView</span> {

    <span class="pl-k">private</span> <span class="pl-smi">float</span> <span class="pl-s1">mRatio</span> = <span class="pl-c1">0f</span>;

    <span class="pl-k">public</span> <span class="pl-smi">RatioImageView</span>(<span class="pl-smi">Context</span> <span class="pl-s1">context</span>, <span class="pl-smi">AttributeSet</span> <span class="pl-s1">attrs</span>, <span class="pl-smi">int</span> <span class="pl-s1">defStyleAttr</span>) {
        <span class="pl-en">super</span>(<span class="pl-s1">context</span>, <span class="pl-s1">attrs</span>, <span class="pl-s1">defStyleAttr</span>);
    }

    <span class="pl-k">public</span> <span class="pl-smi">RatioImageView</span>(<span class="pl-smi">Context</span> <span class="pl-s1">context</span>, <span class="pl-smi">AttributeSet</span> <span class="pl-s1">attrs</span>) {
        <span class="pl-en">super</span>(<span class="pl-s1">context</span>, <span class="pl-s1">attrs</span>);
        <span class="pl-smi">TypedArray</span> <span class="pl-s1">typedArray</span> = <span class="pl-s1">context</span>.<span class="pl-en">obtainStyledAttributes</span>(<span class="pl-s1">attrs</span>, <span class="pl-smi">R</span>.<span class="pl-s1">styleable</span>.<span class="pl-s1">RatioImageView</span>);

        <span class="pl-s1">mRatio</span> = <span class="pl-s1">typedArray</span>.<span class="pl-en">getFloat</span>(<span class="pl-smi">R</span>.<span class="pl-s1">styleable</span>.<span class="pl-s1">RatioImageView_ratio</span>, <span class="pl-c1">0f</span>);
        <span class="pl-s1">typedArray</span>.<span class="pl-en">recycle</span>();
    }

    <span class="pl-k">public</span> <span class="pl-smi">RatioImageView</span>(<span class="pl-smi">Context</span> <span class="pl-s1">context</span>) {
        <span class="pl-en">super</span>(<span class="pl-s1">context</span>);
    }

    <span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">setRatio</span>(<span class="pl-smi">float</span> <span class="pl-s1">ratio</span>) {
        <span class="pl-s1">mRatio</span> = <span class="pl-s1">ratio</span>;
    }

    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">protected</span> <span class="pl-smi">void</span> <span class="pl-en">onMeasure</span>(<span class="pl-smi">int</span> <span class="pl-s1">widthMeasureSpec</span>, <span class="pl-smi">int</span> <span class="pl-s1">heightMeasureSpec</span>) {
        <span class="pl-smi">int</span> <span class="pl-s1">width</span> = <span class="pl-smi">MeasureSpec</span>.<span class="pl-en">getSize</span>(<span class="pl-s1">widthMeasureSpec</span>);
        <span class="pl-k">if</span> (<span class="pl-s1">mRatio</span> != <span class="pl-c1">0</span>) {
            <span class="pl-smi">float</span> <span class="pl-s1">height</span> = <span class="pl-s1">width</span> / <span class="pl-s1">mRatio</span>;
            <span class="pl-s1">heightMeasureSpec</span> = <span class="pl-smi">MeasureSpec</span>.<span class="pl-en">makeMeasureSpec</span>((<span class="pl-smi">int</span>) <span class="pl-s1">height</span>, <span class="pl-smi">MeasureSpec</span>.<span class="pl-c1">EXACTLY</span>);
        }
        <span class="pl-en">super</span>.<span class="pl-en">onMeasure</span>(<span class="pl-s1">widthMeasureSpec</span>, <span class="pl-s1">heightMeasureSpec</span>);
    }

    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">public</span> <span class="pl-smi">boolean</span> <span class="pl-en">onTouchEvent</span>(<span class="pl-smi">MotionEvent</span> <span class="pl-s1">event</span>) {

        <span class="pl-k">switch</span> (<span class="pl-s1">event</span>.<span class="pl-en">getAction</span>()) {
            <span class="pl-k">case</span> <span class="pl-smi">MotionEvent</span>.<span class="pl-c1">ACTION_DOWN</span>:
                <span class="pl-smi">Drawable</span> <span class="pl-s1">drawable</span> = <span class="pl-en">getDrawable</span>();
                <span class="pl-k">if</span> (<span class="pl-s1">drawable</span> != <span class="pl-c1">null</span>) {
                    <span class="pl-s1">drawable</span>.<span class="pl-en">mutate</span>().<span class="pl-en">setColorFilter</span>(<span class="pl-smi">Color</span>.<span class="pl-c1">GRAY</span>,
                            <span class="pl-smi">PorterDuff</span>.<span class="pl-s1">Mode</span>.<span class="pl-c1">MULTIPLY</span>);
                }
                <span class="pl-k">break</span>;
            <span class="pl-k">case</span> <span class="pl-smi">MotionEvent</span>.<span class="pl-c1">ACTION_CANCEL</span>:
            <span class="pl-k">case</span> <span class="pl-smi">MotionEvent</span>.<span class="pl-c1">ACTION_UP</span>:
                <span class="pl-smi">Drawable</span> <span class="pl-s1">drawableUp</span> = <span class="pl-en">getDrawable</span>();
                <span class="pl-k">if</span> (<span class="pl-s1">drawableUp</span> != <span class="pl-c1">null</span>) {
                    <span class="pl-s1">drawableUp</span>.<span class="pl-en">mutate</span>().<span class="pl-en">clearColorFilter</span>();
                }
                <span class="pl-k">break</span>;
        }

        <span class="pl-k">return</span> <span class="pl-en">super</span>.<span class="pl-en">onTouchEvent</span>(<span class="pl-s1">event</span>);
    }
}</pre></div>

<p dir="auto"><strong>Layout XML</strong>:</p>
<div class="highlight highlight-text-xml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;!--This is what my Item for RecyclerView looks like--&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;match_parent&quot;
    android:orientation=&quot;vertical&quot;
    android:padding=&quot;10dp&quot;
    android:layout_height=&quot;wrap_content&quot;&gt;

    &lt;com.glidetest.view.RatioImageView
        android:id=&quot;@+id/image&quot;
        android:layout_width=&quot;match_parent&quot;
        android:layout_gravity=&quot;center&quot;
        android:scaleType=&quot;fitXY&quot;
        android:layout_height=&quot;match_parent&quot;
        android:clickable=&quot;true&quot;
        android:src=&quot;@mipmap/pic_error&quot;/&gt;

&lt;/LinearLayout&gt;"><pre class="notranslate"><span class="pl-c"><span class="pl-c">&lt;!--</span>This is what my Item for RecyclerView looks like<span class="pl-c">--&gt;</span></span>
&lt;<span class="pl-ent">LinearLayout</span> <span class="pl-e">xmlns</span><span class="pl-e">:</span><span class="pl-e">android</span>=<span class="pl-s"><span class="pl-pds">"</span>http://schemas.android.com/apk/res/android<span class="pl-pds">"</span></span>
    <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>match_parent<span class="pl-pds">"</span></span>
    <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">orientation</span>=<span class="pl-s"><span class="pl-pds">"</span>vertical<span class="pl-pds">"</span></span>
    <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">padding</span>=<span class="pl-s"><span class="pl-pds">"</span>10dp<span class="pl-pds">"</span></span>
    <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>wrap_content<span class="pl-pds">"</span></span>&gt;

    &lt;<span class="pl-ent">com</span>.glidetest.view.RatioImageView
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">"</span>@+id/image<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>match_parent<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_gravity</span>=<span class="pl-s"><span class="pl-pds">"</span>center<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">scaleType</span>=<span class="pl-s"><span class="pl-pds">"</span>fitXY<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>match_parent<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">clickable</span>=<span class="pl-s"><span class="pl-pds">"</span>true<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">src</span>=<span class="pl-s"><span class="pl-pds">"</span>@mipmap/pic_error<span class="pl-pds">"</span></span>/&gt;

&lt;/<span class="pl-ent">LinearLayout</span>&gt;</pre></div>

<p dir="auto"><strong>Stack trace / LogCat</strong>:</p>
<div class="highlight highlight-source-ruby notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="paste stack trace and/or log here"><pre class="notranslate"><span class="pl-en">paste</span> <span class="pl-en">stack</span> <span class="pl-en">trace</span> <span class="pl-k">and</span>/<span class="pl-en">or</span> <span class="pl-en">log</span> <span class="pl-en">here</span></pre></div>

<p dir="auto">&lt;br&gt;<br>
The original ImageView<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/7380327/19336896/e66b43aa-9141-11e6-890c-ccb9c817be3c.jpeg"><img src="https://cloud.githubusercontent.com/assets/7380327/19336896/e66b43aa-9141-11e6-890c-ccb9c817be3c.jpeg" alt="screenshot_2016-10-13-12-13-16" style="max-width: 100%;"></a><br>
&lt;br&gt;<br>
When touch ImageView<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/7380327/19336906/f7da214c-9141-11e6-8339-b967e5145437.jpeg"><img src="https://cloud.githubusercontent.com/assets/7380327/19336906/f7da214c-9141-11e6-8339-b967e5145437.jpeg" alt="screenshot_2016-10-13-12-13-10" style="max-width: 100%;"></a><br>
&lt;br&gt;<br>
Scroll the RecyclerView and scroll back, then touch the ImageView again, it disappears!!<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/7380327/19336922/1a17d3da-9142-11e6-9618-10e0137367c1.jpeg"><img src="https://cloud.githubusercontent.com/assets/7380327/19336922/1a17d3da-9142-11e6-9618-10e0137367c1.jpeg" alt="screenshot_2016-10-13-12-14-04" style="max-width: 100%;"></a></p>