提交 b476c2aa 编写于 作者: S Sam Judd

Avoid using isLaidOut in ViewTarget.

Fixes #1981.
上级 b905c1bd
package com.bumptech.glide.request.target;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
......@@ -251,9 +250,8 @@ public abstract class ViewTarget<T extends View, Z> extends BaseTarget<Z> {
return true;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return view.isLaidOut();
}
// Avoid using isLaidOut because it appears to be false after a View is re-attached to a
// RecyclerView if the View's size before and after the attach are the same. See #1981.
return !view.isLayoutRequested();
}
......
......@@ -380,14 +380,14 @@ public class ViewTargetTest {
}
@Test
public void getSize_withValidWidthAndHeight_notLaidOut_doesNotCallSizeReady() {
public void getSize_withValidWidthAndHeight_notLaidOut_notLayoutRequested_callsSizeReady() {
shadowView
.setWidth(100)
.setHeight(100)
.setIsLaidOut(false);
target.getSize(cb);
verify(cb, never()).onSizeReady(anyInt(), anyInt());
verify(cb).onSizeReady(100, 100);
}
@Test
......@@ -403,7 +403,7 @@ public class ViewTargetTest {
}
@Test
public void getSize_withLayoutParams_zeroWidthHeight_notLaidOut_doesNotCallSizeReady() {
public void getSize_withLayoutParams_emptyParams_notLaidOutOrLayoutRequested_callsSizeReady() {
shadowView
.setLayoutParams(new LayoutParams(0, 0))
.setWidth(100)
......@@ -411,7 +411,7 @@ public class ViewTargetTest {
.setIsLaidOut(false);
target.getSize(cb);
verify(cb, never()).onSizeReady(anyInt(), anyInt());
verify(cb).onSizeReady(100, 100);
}
@Test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册