本文整理了Java中android.widget.ImageView.getDrawable()
方法的一些代码示例,展示了ImageView.getDrawable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.getDrawable()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:getDrawable
暂无
代码示例来源:origin: bumptech/glide
/**
* Returns the current {@link android.graphics.drawable.Drawable} being displayed in the view
* using {@link android.widget.ImageView#getDrawable()}.
*/
@Override
@Nullable
public Drawable getCurrentDrawable() {
return view.getDrawable();
}
代码示例来源:origin: square/picasso
/**
* Create or update the drawable on the target {@link ImageView} to display the supplied
* placeholder image.
*/
static void setPlaceholder(ImageView target, @Nullable Drawable placeholderDrawable) {
target.setImageDrawable(placeholderDrawable);
if (target.getDrawable() instanceof Animatable) {
((Animatable) target.getDrawable()).start();
}
}
代码示例来源:origin: chrisbanes/PhotoView
public boolean setDisplayMatrix(Matrix finalMatrix) {
if (finalMatrix == null) {
throw new IllegalArgumentException("Matrix cannot be null");
}
if (mImageView.getDrawable() == null) {
return false;
}
mSuppMatrix.set(finalMatrix);
checkAndDisplayMatrix();
return true;
}
代码示例来源:origin: scwang90/SmartRefreshLayout
@Override
public void onStartAnimator(@NonNull RefreshLayout refreshLayout, int height, int maxDragHeight) {
final View progressView = mProgressView;
if (progressView.getVisibility() != VISIBLE) {
progressView.setVisibility(VISIBLE);
Drawable drawable = mProgressView.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
} else {
progressView.animate().rotation(36000).setDuration(100000);
}
}
}
代码示例来源:origin: bumptech/glide
private Bitmap copyFromImageViewDrawable(ImageView imageView) {
if (imageView.getDrawable() == null) {
fail("Drawable unexpectedly null");
}
// Glide mutates Bitmaps, so it's possible that a Bitmap loaded into a View in one place may
// be re-used to load a different image later. Create a defensive copy just in case.
return Bitmap.createBitmap(((BitmapDrawable) imageView.getDrawable()).getBitmap());
}
代码示例来源:origin: chrisbanes/PhotoView
public void update() {
if (mZoomEnabled) {
// Update the base matrix using the current drawable
updateBaseMatrix(mImageView.getDrawable());
} else {
// Reset the Matrix...
resetMatrix();
}
}
代码示例来源:origin: bumptech/glide
@Test
public void testSetsBitmapOnViewInSetResource() {
Bitmap bitmap = Bitmap.createBitmap(100, 75, Bitmap.Config.RGB_565);
target.setResource(bitmap);
assertEquals(bitmap, ((BitmapDrawable) view.getDrawable()).getBitmap());
}
}
代码示例来源:origin: bumptech/glide
private void runTestFileDefaultLoader() {
File file = new File("fake");
mockUri(Uri.fromFile(file));
requestManager.load(file).into(target);
requestManager.load(file).into(imageView);
verify(target).onResourceReady(isA(BitmapDrawable.class), isA(Transition.class));
verify(target).setRequest((Request) notNull());
assertNotNull(imageView.getDrawable());
}
代码示例来源:origin: square/picasso
@Test
public void stopPlaceholderAnimationOnError() {
Picasso picasso = mock(Picasso.class);
AnimationDrawable placeholder = mock(AnimationDrawable.class);
ImageView target = mockImageViewTarget();
when(target.getDrawable()).thenReturn(placeholder);
ImageViewAction request =
new ImageViewAction(picasso, target, null, null, 0, false, null);
request.error(new RuntimeException());
verify(placeholder).stop();
}
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
@Test
public void testUrlDefaultLoader() throws MalformedURLException {
URL url = new URL("http://www.google.com");
requestManager.load(url).into(target);
requestManager.load(url).into(imageView);
verify(target).onResourceReady(isA(BitmapDrawable.class), isA(Transition.class));
verify(target).setRequest((Request) notNull());
assertNotNull(imageView.getDrawable());
}
代码示例来源:origin: bumptech/glide
private void runTestUriDefaultLoader() {
Uri uri = Uri.parse("content://test/something");
mockUri(uri);
requestManager.load(uri).into(target);
requestManager.load(uri).into(imageView);
verify(target).onResourceReady(notNull(), isA(Transition.class));
verify(target).setRequest((Request) notNull());
assertNotNull(imageView.getDrawable());
}
代码示例来源:origin: bumptech/glide
@Test
public void testByteArrayDefaultLoader() {
byte[] bytes = new byte[10];
requestManager.load(bytes).into(target);
requestManager.load(bytes).into(imageView);
verify(target).onResourceReady(isA(BitmapDrawable.class), isA(Transition.class));
verify(target).setRequest((Request) notNull());
assertNotNull(imageView.getDrawable());
}
代码示例来源:origin: bumptech/glide
private void runTestIntegerDefaultLoader() {
int integer = android.R.drawable.star_on;
mockUri("android.resource://" + "android" + "/drawable/star_on");
requestManager.load(integer).into(target);
requestManager.load(integer).into(imageView);
verify(target).onResourceReady(isA(BitmapDrawable.class), isA(Transition.class));
verify(target).setRequest((Request) notNull());
assertNotNull(imageView.getDrawable());
}
代码示例来源:origin: bumptech/glide
@Test
public void clear_withSingleRequest_nullsOutDrawableInView() {
concurrency.loadOnMainThread(
GlideApp.with(context)
.load(ResourceIds.raw.canonical),
imageView);
assertThat(imageView.getDrawable()).isNotNull();
concurrency.clearOnMainThread(imageView);
assertThat(imageView.getDrawable()).isNull();
}
代码示例来源:origin: bumptech/glide
@Test
public void testSetsDrawableSetsDrawableOnView() {
target.setDrawable(drawable);
assertEquals(drawable, view.getDrawable());
}
代码示例来源:origin: bumptech/glide
@Test
public void testSetsDrawableOnLoadStarted() {
target.onLoadStarted(drawable);
assertEquals(drawable, view.getDrawable());
}
代码示例来源:origin: bumptech/glide
@Test
public void onStop_withSingleRequest_doesNotNullOutDrawableInView() {
concurrency.loadOnMainThread(
GlideApp.with(context)
.load(ResourceIds.raw.canonical),
imageView);
assertThat(imageView.getDrawable()).isNotNull();
concurrency.runOnMainThread(new Runnable() {
@Override
public void run() {
GlideApp.with(context).onStop();
}
});
assertThat(imageView.getDrawable()).isNotNull();
}
代码示例来源:origin: bumptech/glide
@Test
public void testSetDrawableOnLoadFailed() {
target.onLoadFailed(drawable);
assertEquals(drawable, view.getDrawable());
}
代码示例来源:origin: bumptech/glide
@Test
public void testSetsDrawableOnLoadCleared() {
target.onLoadCleared(drawable);
assertEquals(drawable, view.getDrawable());
}
代码示例来源:origin: bumptech/glide
@Test
public void clear_withRequestWithThumbnail_nullsOutDrawableInView() {
concurrency.loadOnMainThread(
GlideApp.with(context)
.load(ResourceIds.raw.canonical)
.thumbnail(
GlideApp.with(context)
.load(ResourceIds.raw.canonical)
.override(100, 100)),
imageView);
assertThat(imageView.getDrawable()).isNotNull();
concurrency.clearOnMainThread(imageView);
assertThat(imageView.getDrawable()).isNull();
}
内容来源于网络,如有侵权,请联系作者删除!