本文整理汇总了Java中com.bumptech.glide.request.target.SizeReadyCallback类的典型用法代码示例。如果您正苦于以下问题:Java SizeReadyCallback类的具体用法?Java SizeReadyCallback怎么用?Java SizeReadyCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SizeReadyCallback类属于com.bumptech.glide.request.target包,在下文中一共展示了SizeReadyCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
Glide.tearDown();
RobolectricPackageManager pm = RuntimeEnvironment.getRobolectricPackageManager();
ApplicationInfo info =
pm.getApplicationInfo(RuntimeEnvironment.application.getPackageName(), 0);
info.metaData = new Bundle();
info.metaData.putString(SetupModule.class.getName(), "GlideModule");
// Ensure that target's size ready callback will be called synchronously.
target = mock(Target.class);
imageView = new ImageView(RuntimeEnvironment.application);
imageView.setLayoutParams(new ViewGroup.LayoutParams(100, 100));
imageView.layout(0, 0, 100, 100);
doAnswer(new CallSizeReady()).when(target).getSize(isA(SizeReadyCallback.class));
Handler bgHandler = mock(Handler.class);
when(bgHandler.post(isA(Runnable.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
Runnable runnable = (Runnable) invocation.getArguments()[0];
runnable.run();
return true;
}
});
Lifecycle lifecycle = mock(Lifecycle.class);
RequestManagerTreeNode treeNode = mock(RequestManagerTreeNode.class);
requestManager = new RequestManager(Glide.get(getContext()), lifecycle, treeNode);
requestManager.resumeRequests();
}
示例2: testClone
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Test
public void testClone() throws IOException {
Target<Drawable> firstTarget = mock(Target.class);
doAnswer(new CallSizeReady(100, 100)).when(firstTarget).getSize(isA(SizeReadyCallback.class));
Target<Drawable> secondTarget = mock(Target.class);
doAnswer(new CallSizeReady(100, 100)).when(secondTarget).getSize(isA(SizeReadyCallback.class));
RequestBuilder<Drawable> firstRequest = requestManager
.load(mockUri("content://first"));
firstRequest.into(firstTarget);
firstRequest.clone()
.apply(placeholderOf(new ColorDrawable(Color.RED)))
.into(secondTarget);
verify(firstTarget).onResourceReady(isA(Drawable.class), isA(Transition.class));
verify(secondTarget).onResourceReady(notNull(Drawable.class), isA(Transition.class));
}
示例3: testCanReRunCancelledRequests
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Test
public void testCanReRunCancelledRequests() {
doAnswer(new CallSizeReady(100, 100)).when(harness.target)
.getSize(any(SizeReadyCallback.class));
when(harness.engine
.load(eq(harness.glideContext), eq(harness.model), eq(harness.signature), eq(100), eq(100),
eq(Object.class), eq(List.class), any(Priority.class), any(DiskCacheStrategy.class),
eq(harness.transformations), anyBoolean(), any(Options.class),
anyBoolean(), anyBoolean(), anyBoolean(), any(ResourceCallback.class)))
.thenAnswer(new CallResourceCallback(harness.resource));
SingleRequest<List> request = harness.getRequest();
request.begin();
request.cancel();
request.begin();
verify(harness.target, times(2)).onResourceReady(eq(harness.result), anyTransition());
}
示例4: testCallsSourceUnlimitedExecutorEngineIfOptionsIsSet
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Test
public void testCallsSourceUnlimitedExecutorEngineIfOptionsIsSet() {
doAnswer(new CallSizeReady(100, 100)).when(harness.target)
.getSize(any(SizeReadyCallback.class));
harness.useUnlimitedSourceGeneratorsPool = true;
SingleRequest<List> request = harness.getRequest();
request.begin();
verify(harness.engine)
.load(eq(harness.glideContext), eq(harness.model), eq(harness.signature), anyInt(),
anyInt(), eq(Object.class), eq(List.class), any(Priority.class),
any(DiskCacheStrategy.class), eq(harness.transformations), anyBoolean(),
any(Options.class), anyBoolean(), eq(Boolean.TRUE), anyBoolean(),
any(ResourceCallback.class));
}
示例5: testCallsSourceExecutorEngineIfOptionsIsSet
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Test
public void testCallsSourceExecutorEngineIfOptionsIsSet() {
doAnswer(new CallSizeReady(100, 100)).when(harness.target)
.getSize(any(SizeReadyCallback.class));
harness.useUnlimitedSourceGeneratorsPool = false;
SingleRequest<List> request = harness.getRequest();
request.begin();
verify(harness.engine)
.load(eq(harness.glideContext), eq(harness.model), eq(harness.signature), anyInt(),
anyInt(), eq(Object.class), eq(List.class), any(Priority.class),
any(DiskCacheStrategy.class), eq(harness.transformations), anyBoolean(),
any(Options.class), anyBoolean(), eq(Boolean.FALSE), anyBoolean(),
any(ResourceCallback.class));
}
示例6: loadResource
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
public static void loadResource(@DrawableRes int drawableId, @NonNull ImageView image) {
DisplayMetrics metrics = image.getResources().getDisplayMetrics();
final int w = metrics.widthPixels, h = metrics.heightPixels;
Glide.with(image.getContext())
.load(drawableId)
.animate(ANIMATOR)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.into(new GlideDrawableImageViewTarget(image) {
@Override
public void getSize(final SizeReadyCallback cb) {
// We don't want to load very big images on devices with small screens.
// This will help Glide correctly choose images scale when reading them.
super.getSize(new SizeReadyCallback() {
@Override
public void onSizeReady(int width, int height) {
cb.onSizeReady(w / 2, h / 2);
}
});
}
});
}
示例7: onBindViewHolder
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Override
public void onBindViewHolder(final ViewHolder holder,final int position) {
Girl entity = mListData.get(position);
Glide.with(mContext)
.load(entity.url)
.centerCrop()
.into(holder.mIvIndexPhoto)
.getSize(new SizeReadyCallback() {
@Override
public void onSizeReady(int width, int height) {
holder.mIvIndexPhoto.setColorFilter(mColorFilter);
}
});
holder.mTvTime.setText(DateUtil.toDate(entity.publishedAt));
if(mIClickItem!=null){
holder.mIvIndexPhoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mIClickItem.onClickPhoto(position, holder.mIvIndexPhoto,holder.mTvTime);
}
});
}
}
示例8: onBindViewHolder
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Override
public void onBindViewHolder(final ViewHolder holder,final int position) {
Girl entity = mListData.get(position);
Glide.with(mContext)
.load(entity.url)
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.dontAnimate()
.into(holder.mIvIndexPhoto)
.getSize(new SizeReadyCallback() {
@Override
public void onSizeReady(int width, int height) {
//holder.mIvIndexPhoto.setColorFilter(mColorFilter);
}
});
holder.mTvTime.setText(DateUtil.toDate(entity.publishedAt));
if(mIClickItem!=null){
holder.mIvIndexPhoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mIClickItem.onClickPhoto(position, holder.mIvIndexPhoto,holder.mTvTime);
}
});
}
}
示例9: testCallsGetSizeIfOverrideWidthIsLessThanZero
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Test
public void testCallsGetSizeIfOverrideWidthIsLessThanZero() {
harness.overrideWidth = -1;
harness.overrideHeight = 100;
SingleRequest<List> request = harness.getRequest();
request.begin();
verify(harness.target).getSize(any(SizeReadyCallback.class));
}
示例10: testCallsGetSizeIfOverrideHeightIsLessThanZero
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Test
public void testCallsGetSizeIfOverrideHeightIsLessThanZero() {
harness.overrideHeight = -1;
harness.overrideWidth = 100;
SingleRequest<List> request = harness.getRequest();
request.begin();
verify(harness.target).getSize(any(SizeReadyCallback.class));
}
示例11: testDoesNotCallGetSizeIfOverrideWidthAndHeightAreSet
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Test
public void testDoesNotCallGetSizeIfOverrideWidthAndHeightAreSet() {
harness.overrideWidth = 100;
harness.overrideHeight = 100;
SingleRequest<List> request = harness.getRequest();
request.begin();
verify(harness.target, never()).getSize(any(SizeReadyCallback.class));
}
示例12: getTargetsSizes
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
private <R> List<Integer> getTargetsSizes(
RequestBuilder<R> requestBuilder, VerificationMode mode) {
ArgumentCaptor<Integer> integerArgumentCaptor = ArgumentCaptor.forClass(Integer.class);
ArgumentCaptor<Target<R>> targetArgumentCaptor = cast(ArgumentCaptor.forClass(Target.class));
SizeReadyCallback cb = mock(SizeReadyCallback.class);
verify(requestBuilder, mode).into(targetArgumentCaptor.capture());
for (Target<R> target : targetArgumentCaptor.getAllValues()) {
target.getSize(cb);
}
verify(cb, mode).onSizeReady(integerArgumentCaptor.capture(), integerArgumentCaptor.capture());
return integerArgumentCaptor.getAllValues();
}
示例13: setUp
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
context = RuntimeEnvironment.application;
// Run all tasks on the main thread so they complete synchronously.
GlideExecutor executor = MockGlideExecutor.newMainThreadExecutor();
when(diskCacheFactory.build()).thenReturn(diskCache);
Glide.init(
context,
new GlideBuilder()
.setMemoryCache(memoryCache)
.setDiskCache(diskCacheFactory)
.setSourceExecutor(executor)
.setDiskCacheExecutor(executor));
Registry registry = Glide.get(context).getRegistry();
registerMockModelLoader(
GlideUrl.class, InputStream.class, new ByteArrayInputStream(new byte[0]), registry);
registerMockModelLoader(
File.class, InputStream.class, new ByteArrayInputStream(new byte[0]), registry);
registerMockModelLoader(
File.class, ParcelFileDescriptor.class, mock(ParcelFileDescriptor.class), registry);
registerMockModelLoader(File.class, ByteBuffer.class, ByteBuffer.allocate(10), registry);
// Ensure that target's size ready callback will be called synchronously.
imageView = new ImageView(context);
imageView.setLayoutParams(new ViewGroup.LayoutParams(100, 100));
imageView.layout(0, 0, 100, 100);
doAnswer(new CallSizeReady()).when(target).getSize(isA(SizeReadyCallback.class));
when(bgHandler.post(isA(Runnable.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
Runnable runnable = (Runnable) invocation.getArguments()[0];
runnable.run();
return true;
}
});
requestManager = new RequestManager(Glide.get(context), lifecycle, treeNode, context);
requestManager.resumeRequests();
}
示例14: testCallsGetSizeIfOverrideWidthIsLessThanZero
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Test
public void testCallsGetSizeIfOverrideWidthIsLessThanZero() {
SingleRequest<List> request = builder
.setOverrideWidth(-1)
.setOverrideHeight(100)
.build();
request.begin();
verify(builder.target).getSize(any(SizeReadyCallback.class));
}
示例15: testCallsGetSizeIfOverrideHeightIsLessThanZero
import com.bumptech.glide.request.target.SizeReadyCallback; //导入依赖的package包/类
@Test
public void testCallsGetSizeIfOverrideHeightIsLessThanZero() {
SingleRequest<List> request = builder
.setOverrideWidth(100)
.setOverrideHeight(-1)
.build();
request.begin();
verify(builder.target).getSize(any(SizeReadyCallback.class));
}