本文整理汇总了Java中com.bumptech.glide.request.target.SimpleTarget类的典型用法代码示例。如果您正苦于以下问题:Java SimpleTarget类的具体用法?Java SimpleTarget怎么用?Java SimpleTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleTarget类属于com.bumptech.glide.request.target包,在下文中一共展示了SimpleTarget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showWhenPictureReady
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的package包/类
public void showWhenPictureReady (final int id) {
Glide.with(getCenter().getContext()).load(url)
.asBitmap().into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
Log.v(TAG, "showWhenPictureReady onResourceReady");
bigPicture(resource).show(id);
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
getCenter().show(id);
Log.v(TAG, "showWhenPictureReady onLoadFailed " + e.getMessage());
}
});
}
示例2: setImgBackGround
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的package包/类
private void setImgBackGround() {
String[] images = getResources().getStringArray(R.array.splash_background);
int position = new Random().nextInt(images.length - 1) % (images.length);
Glide.with(this)
.load(images[position])
.into(mImgBackGround);
String path = SpUtil.getString(this, "path");
Glide.with(this)
.load(path)
.asBitmap()
.error(R.drawable.def_avatar)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
mCircleImageView.setImageBitmap(resource);
}
});
//设置图像的透明度
AlphaAnimation animation = new AlphaAnimation(0.1f, 1.0f);
animation.setDuration(800);
mCircleImageView.startAnimation(animation);
animation.setAnimationListener(this);
}
示例3: onCreateView
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View contentView = inflater.inflate(R.layout.fragment_image_preview, container, false);
final ImageView imageView = (ImageView) contentView.findViewById(R.id.preview_image);
final PhotoViewAttacher mAttacher = new PhotoViewAttacher(imageView);
Glide.with(container.getContext())
.load(new File(getArguments().getString(PATH)))
.asBitmap()
.into(new SimpleTarget<Bitmap>(480, 800) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
imageView.setImageBitmap(resource);
mAttacher.update();
}
});
mAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
@Override
public void onViewTap(View view, float x, float y) {
ImagePreviewActivity activity = (ImagePreviewActivity) getActivity();
activity.switchBarVisibility();
}
});
return contentView;
}
示例4: initEventAndData
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的package包/类
@Override
protected void initEventAndData() {
setToolBar(toolBar,"");
mRealmHelper = App.getAppComponent().realmHelper();
Intent intent = getIntent();
url = intent.getExtras().getString(Constants.IT_GANK_GRIL_URL);
id = intent.getExtras().getString(Constants.IT_GANK_GRIL_ID);
if (url != null) {
Glide.with(mContext).load(url).asBitmap().into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
bitmap = resource;
ivGirlDetail.setImageBitmap(resource);
mAttacher = new PhotoViewAttacher(ivGirlDetail);
}
});
}
}
示例5: setupDetailsOverviewRow
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的package包/类
private DetailsOverviewRow setupDetailsOverviewRow(Object event) {
final DetailsOverviewRow row = new DetailsOverviewRow(event);
String thumbUrl;
if (event instanceof Event) {
thumbUrl = ((Event) event).getThumbUrl();
} else {
thumbUrl = ((Room) event).getThumb();
}
Glide.with(getActivity())
.load(thumbUrl)
.asBitmap()
.into(new SimpleTarget<Bitmap>(DETAIL_THUMB_WIDTH, DETAIL_THUMB_HEIGHT) {
@Override
public void onResourceReady(Bitmap resource,
GlideAnimation<? super Bitmap> glideAnimation) {
row.setImageBitmap(getActivity(), resource);
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
// super.onLoadFailed(e, errorDrawable);
row.setImageDrawable(getResources().getDrawable(DEFAULT_DRAWABLE));
}
});
return row;
}
示例6: loadImageView
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的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);
}
});
}
示例7: onUpdateMusicNotification
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的package包/类
/**
* 更新通知
*/
public void onUpdateMusicNotification(MusicBean bean, boolean isplay){
Log.e(TAG,"更新通知--歌曲名称:"+ bean.getSongname()+"--isplay:"+isplay);
if (null == bean) return;
//更新歌曲名称
remoteViews.setTextViewText(R.id.tv_song_name,(bean.getSongname() == null ? "" : bean.getSongname()));
//更新歌手名字
remoteViews.setTextViewText(R.id.tv_singer,(bean.getSingername() == null ? "" : bean.getSingername()));
//更新歌曲图片
Glide.with(context).load(bean.getAlbumpic_big()).asBitmap().into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
remoteViews.setImageViewBitmap(R.id.img_song, resource);
}
});
//更新播放状态:播放或者暂停
if (isplay){
remoteViews.setImageViewResource(R.id.img_play,R.mipmap.play);
}else {
remoteViews.setImageViewResource(R.id.img_play,R.mipmap.pause);
}
onCreateMusicNotification();//弹出更新的通知
}
示例8: initEventAndData
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的package包/类
@Override
protected void initEventAndData() {
setToolBar(toolBar,"");
mRealmHelper = App.getAppComponent().realmHelper();
Intent intent = getIntent();
url = intent.getExtras().getString("url");
id = intent.getExtras().getString("id");
if (url != null) {
Glide.with(mContext).load(url).asBitmap().into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
bitmap = resource;
ivGirlDetail.setImageBitmap(resource);
mAttacher = new PhotoViewAttacher(ivGirlDetail);
}
});
}
}
示例9: removeFromManagers_afterRequestManagerRemoved_clearsRequest
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的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();
}
示例10: getUserProfile
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的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: onActivityResult
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的package包/类
@Override
public void onActivityResult(int reqCode, int resultCode, final Intent data) {
super.onActivityResult(reqCode, resultCode, data);
Uri outputFile = Uri.fromFile(new File(getCacheDir(), "cropped"));
if (data == null || resultCode != Activity.RESULT_OK)
return;
switch (reqCode) {
case PICK_CONTACT:
List<String> selected = data.getStringArrayListExtra("contacts");
for (String contact : selected) {
final Recipient recipient = RecipientFactory.getRecipientsFromString(this, contact, false).getPrimaryRecipient();
if (recipient != null) addSelectedContacts(recipient);
}
break;
case Crop.REQUEST_PICK:
new Crop(data.getData()).output(outputFile).asSquare().start(this);
break;
case Crop.REQUEST_CROP:
Glide.with(this).load(Crop.getOutput(data)).asBitmap()
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.centerCrop().override(AVATAR_SIZE, AVATAR_SIZE)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
setAvatar(Crop.getOutput(data), resource);
}
});
}
}
示例12: renderImage
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的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: updateBackground
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的package包/类
protected void updateBackground(String uri) {
int width = mMetrics.widthPixels;
int height = mMetrics.heightPixels;
Glide.with(getActivity())
.load(uri)
.centerCrop()
.error(mDefaultBackground)
.into(new SimpleTarget<GlideDrawable>(width, height) {
@Override
public void onResourceReady(GlideDrawable resource,
GlideAnimation<? super GlideDrawable>
glideAnimation) {
mBackgroundManager.setDrawable(resource);
}
});
mBackgroundTimer.cancel();
}
示例14: onBindViewHolder
import com.bumptech.glide.request.target.SimpleTarget; //导入依赖的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.target.SimpleTarget; //导入依赖的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);
}
}
});
}
}