本文整理汇总了Java中com.bumptech.glide.request.transition.Transition类的典型用法代码示例。如果您正苦于以下问题:Java Transition类的具体用法?Java Transition怎么用?Java Transition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Transition类属于com.bumptech.glide.request.transition包,在下文中一共展示了Transition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadImageView
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
private void loadImageView() {
final String url = getArguments().getString(ARGUMENTS_IMAGE);
Glide.with(this).downloadOnly().load(url)
/* todo replace error icon */
.apply(new RequestOptions().error(R.mipmap.qq_refresh_success))
.into(new SimpleTarget<File>() {
@Override
public void onResourceReady(File resource, Transition<? super File> transition) {
mImageView.setImage(ImageSource.uri(Uri.fromFile(resource)));
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
}
});
}
示例2: onGranted
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
@Override
public void onGranted() {
Glide.with(context).load(url).into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
String path = String.format("%s/Android/data/%s/",
Environment.getExternalStorageDirectory(), AppUtils.getAppPackageName());
String filename = TimeUtils.getNowString() + ".png";
boolean ok = ImageUtils.save(ImageUtils.drawable2Bitmap(resource),
path + filename, Bitmap.CompressFormat.PNG);
if (ok) {
ToastUtils.showShort(R.string.success);
} else {
ToastUtils.showShort(R.string.error);
}
}
});
}
示例3: onResourceReady
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
/**
* Internal {@link #onResourceReady(Resource, DataSource)} where arguments are known to be safe.
*
* @param resource original {@link Resource}, never <code>null</code>
* @param result object returned by {@link Resource#get()}, checked for type and never
* <code>null</code>
*/
private void onResourceReady(Resource<R> resource, R result, DataSource dataSource) {
// We must call isFirstReadyResource before setting status.
boolean isFirstResource = isFirstReadyResource();
status = Status.COMPLETE;
this.resource = resource;
if (glideContext.getLogLevel() <= Log.DEBUG) {
Log.d(GLIDE_TAG, "Finished loading " + result.getClass().getSimpleName() + " from "
+ dataSource + " for " + model + " with size [" + width + "x" + height + "] in "
+ LogTime.getElapsedMillis(startTime) + " ms");
}
if (requestListener == null
|| !requestListener.onResourceReady(result, model, target, dataSource, isFirstResource)) {
Transition<? super R> animation =
animationFactory.build(dataSource, isFirstResource);
target.onResourceReady(result, animation);
}
notifyLoadSuccess();
}
示例4: testClone
import com.bumptech.glide.request.transition.Transition; //导入依赖的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));
}
示例5: testLoadColorDrawable_withUnitBitmapTransformation_returnsColorDrawable
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
@Test
public void testLoadColorDrawable_withUnitBitmapTransformation_returnsColorDrawable() {
ColorDrawable colorDrawable = new ColorDrawable(Color.RED);
requestManager
.load(colorDrawable)
.apply(new RequestOptions()
.override(100, 100)
.centerCrop())
.into(target);
ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class);
verify(target).onResourceReady(argumentCaptor.capture(), isA(Transition.class));
Object result = argumentCaptor.getValue();
assertThat(result).isInstanceOf(ColorDrawable.class);
assertThat(((ColorDrawable) result).getColor()).isEqualTo(Color.RED);
}
示例6: testLoadColorDrawable_withNonUnitBitmapTransformation_returnsBitmapDrawable
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
@Test
public void testLoadColorDrawable_withNonUnitBitmapTransformation_returnsBitmapDrawable() {
ColorDrawable colorDrawable = new ColorDrawable(Color.RED);
requestManager
.load(colorDrawable)
.apply(new RequestOptions()
.override(100, 100)
.circleCrop())
.into(target);
ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class);
verify(target).onResourceReady(argumentCaptor.capture(), isA(Transition.class));
Object result = argumentCaptor.getValue();
assertThat(result).isInstanceOf(BitmapDrawable.class);
Bitmap bitmap = ((BitmapDrawable) result).getBitmap();
assertThat(bitmap.getWidth()).isEqualTo(100);
assertThat(bitmap.getHeight()).isEqualTo(100);
}
示例7: removeFromManagers_afterRequestManagerRemoved_clearsRequest
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
@Test
public void removeFromManagers_afterRequestManagerRemoved_clearsRequest() {
target = requestManager.load(mockUri("content://uri")).into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
// Do nothing.
}
});
Request request = Preconditions.checkNotNull(target.getRequest());
requestManager.onDestroy();
requestManager.clear(target);
assertThat(target.getRequest()).isNull();
assertThat(request.isCancelled()).isTrue();
}
示例8: changeViewState
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
private void changeViewState(){
imageName.setText(mainObject.getFileName());
if (image.getDrawable() == null) {
Glide.with(parentActivity)
.load(mainObject.getPath())
.into(new DrawableImageViewTarget(image) {
@Override
public void onResourceReady(Drawable resource, @Nullable Transition<? super Drawable> transition) {
super.onResourceReady(resource, transition);
circleProgress.setVisibility(View.GONE);
mainObject.setState(ImageState.unselected);
}
});
}
}
示例9: onResume
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
@Override
public void onResume(){
super.onResume();
if(mUserService.isLoggedIn()){
mUserService.me()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(u -> {
userName.setText(u.getUsername());
mAvatarView.setAvatarOfUser(u);
GlideApp.with(this)
.load(NodeBBService.url(u.getCoverUrl()))
.into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
mHeaderView.setBackground(resource);
}
});
});
}
}
示例10: getUserProfile
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
private void getUserProfile() {
mUserService.me()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(u -> {
mUserName.setText(u.getUsername());
mAvatarView.setAvatarOfUser(u);
mReputation.setText(u.getReputation());
mPost.setText(u.getPostcount());
mFollowing.setText(String.valueOf(u.getFollowingCount()));
mFollower.setText(String.valueOf(u.getFollowerCount()));
mLoginTime.setText(DateTimeFormatter.format(Long.parseLong(u.getLastonline())));
mRegTime.setText(DateTimeFormatter.format(Long.parseLong(u.getJoindate())));
mProfileViews.setText(u.getProfileviews());
mEmail.setText(u.getEmail());
GlideApp.with(UserProfileActivity.this)
.load(NodeBBService.url(u.getCoverUrl()))
.into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
mHeaderView.setBackground(resource);
}
});
});
}
示例11: onResourceReady
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
@Override
public void onResourceReady(final Bitmap resource, Transition<? super Bitmap> transition) {
try {
final ViewTreeObserver observer = getView().getViewTreeObserver();
observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
//final Bitmap scaledBitmap = Bitmap.createScaledBitmap(resource, mPhotoContainer.getWidth(), mPhotoContainer.getHeight(), true);
mPhoto.setImageBitmap(resource);
mPhoto.invalidate();
mPhoto.setVisibility(View.VISIBLE);
mPhotoNoImage.setVisibility(View.GONE);
return true;
}
});
} catch (Exception ex) {
Log.e(getClass().getSimpleName(),ex.getMessage());
}
}
示例12: renderImage
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
private void renderImage(Object image, final ImageView imageView){
GlideApp.with(mContext)
.asBitmap()
.load(image)
.placeholder(R.drawable.iconerror)
.error(R.drawable.iconerror)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(final Bitmap resource, Transition<? super Bitmap> transition) {
int valueWidth = (int) mContext.getResources().getDimension(R.dimen.book_cover_width);
int valueHeight = (int) mContext.getResources().getDimension(R.dimen.book_cover_height);
final Bitmap scaledBitmap = Bitmap.createScaledBitmap(resource, valueWidth, valueHeight, true);
imageView.setImageBitmap(resource);
imageView.invalidate();
}
});
}
示例13: onResourceReady
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
@Override
public void onResourceReady(Drawable resource, @Nullable Transition<? super Drawable> transition) {
super.onResourceReady(resource, transition);
BadgedFourThreeImageView badgedImageView = (BadgedFourThreeImageView) getView();
if (resource instanceof GifDrawable) {
Bitmap image = ((GifDrawable) resource).getFirstFrame();
if (image != null) {
// look at the corner to determine the gif badge color
int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics
().scaledDensity);
Bitmap corner = Bitmap.createBitmap(image,
image.getWidth() - cornerSize,
image.getHeight() - cornerSize,
cornerSize, cornerSize);
boolean isDark = ColorUtils.isDark(corner);
corner.recycle();
badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(),
isDark ? R.color.gif_badge_dark_image : R.color.gif_badge_light_image));
} else {
badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(),
R.color.gif_badge_light_image));
}
}
}
示例14: onBindViewHolder
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
@Override
public void onBindViewHolder(final ContributorAdapter.ViewHolder holder, int position) {
ContributorData contributor = contributors.get(position);
Glide.with(holder.imageView.getContext()).asBitmap().load(contributor.imageUrl).into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
holder.imageView.setImageBitmap(resource);
}
});
holder.textView.setText(contributor.name);
holder.itemView.setTag(contributor);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (view.getTag() != null && view.getTag() instanceof ContributorData)
view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(((ContributorData) view.getTag()).url)));
}
});
}
示例15: loadArtWork
import com.bumptech.glide.request.transition.Transition; //导入依赖的package包/类
@Override
public void loadArtWork(long artistId) {
LogUtils.i(TAG, "loadArtWork");
if (mView != null) {
Glide.with(mView.getContext()).asBitmap().load(String.valueOf(artistId))
.into(new SimpleTarget<Bitmap>() {
@Override
public void onLoadFailed(Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
if (mView != null) {
mView.showArtwork(errorDrawable);
}
}
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
if (mView != null) {
mView.showArtwork(resource);
}
}
});
}
}