use of com.bumptech.glide.request.target.SimpleTarget in project ride-read-android by Ride-Read.
the class MapFragment method addMomentToMap.
private void addMomentToMap(MapMoment moment) {
LatLng latLng = new LatLng(moment.getLatitude(), moment.getLongitude());
// imageView.setImageResource(R.raw.landing_hot_product_1);
String uri01 = moment.getPictures().get(0);
String uri02 = moment.getPictures().get(0) + QiNiuUtils.CROP_SMALL_100;
SimpleTarget target = new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) {
Bitmap bitmap1 = convertBitmapFromXML(getActivity(), moment.getCount(), bitmap);
addMarker(latLng, bitmap1, moment);
}
};
Glide.with(this).load(uri01).asBitmap().into(target);
}
use of com.bumptech.glide.request.target.SimpleTarget in project MusicLake by caiyonglong.
the class PlayControlsPresenter method updateNowPlayingCard.
@Override
public void updateNowPlayingCard() {
Log.d(TAG, "updateNowPlayingCard" + mProgress);
Music music = PlayManager.getPlayingMusic();
if (music == null || PlayManager.getPlayList().size() == 0) {
Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.default_cover);
mView.setAlbumArt(bitmap);
mView.setTitle(mContext.getResources().getString(R.string.app_name));
mView.setArtist("");
mView.updatePanelLayout(false);
return;
} else {
mView.updatePanelLayout(true);
}
final String title = PlayManager.getSongName();
final String artist = PlayManager.getSongArtist();
if (TextUtils.isEmpty(title) && TextUtils.isEmpty(artist)) {
mView.setTitle(mContext.getResources().getString(R.string.app_name));
mView.setArtist("");
} else {
mView.setTitle(title);
mView.setArtist(artist);
}
String picUrl = CoverLoader.getInstance().getCoverUriByMusic(music);
// 设置音乐来源
mView.setOtherInfo(music.getTypeName(false));
// 获取当前歌曲状态
AppRepository.getMusicInfo(mContext, music).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(music1 -> mView.updateFavorite(music1.isLove()));
if (!isPlayPauseClick && !activity.isFinishing()) {
loadLyric();
GlideApp.with(mContext).asBitmap().load(picUrl != null ? picUrl : CoverLoader.getInstance().getCoverUriByRandom()).error(CoverLoader.getInstance().getCoverUriByRandom()).diskCacheStrategy(DiskCacheStrategy.ALL).into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
mView.setAlbumArt(resource);
mView.setAlbumArt(ImageUtils.createBlurredImageFromBitmap(resource, mContext, 12));
new Palette.Builder(resource).generate(palette -> mView.setPalette(palette));
}
});
}
isPlayPauseClick = false;
mHandler.post(updateProgress);
}
use of com.bumptech.glide.request.target.SimpleTarget in project android by nextcloud.
the class DrawerActivity method updateHeader.
public void updateHeader() {
if (getAccount() != null && getStorageManager().getCapability(getAccount().name).getServerBackground() != null) {
OCCapability capability = getStorageManager().getCapability(getAccount().name);
String logo = capability.getServerLogo();
int primaryColor = ThemeColorUtils.primaryColor(getAccount(), false, this);
// set background to primary color
LinearLayout drawerHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_view);
drawerHeader.setBackgroundColor(ThemeColorUtils.unchangedPrimaryColor(getAccount(), this));
if (!TextUtils.isEmpty(logo) && URLUtil.isValidUrl(logo)) {
// background image
GenericRequestBuilder<Uri, InputStream, SVGorImage, Bitmap> requestBuilder = Glide.with(this).using(Glide.buildStreamModelLoader(Uri.class, this), InputStream.class).from(Uri.class).as(SVGorImage.class).transcode(new SvgOrImageBitmapTranscoder(128, 128), Bitmap.class).sourceEncoder(new StreamEncoder()).cacheDecoder(new FileToStreamDecoder<>(new SvgOrImageDecoder())).decoder(new SvgOrImageDecoder());
// background image
SimpleTarget target = new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
Bitmap logo = resource;
int width = resource.getWidth();
int height = resource.getHeight();
int max = Math.max(width, height);
if (max > MAX_LOGO_SIZE_PX) {
logo = BitmapUtils.scaleBitmap(resource, MAX_LOGO_SIZE_PX, width, height, max);
}
Drawable[] drawables = { new ColorDrawable(primaryColor), new BitmapDrawable(logo) };
LayerDrawable layerDrawable = new LayerDrawable(drawables);
String name = capability.getServerName();
setDrawerHeaderLogo(layerDrawable, name);
}
};
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE).load(Uri.parse(logo)).into(target);
}
}
}
use of com.bumptech.glide.request.target.SimpleTarget in project android by nextcloud.
the class DrawerActivity method updateQuotaLink.
private void updateQuotaLink() {
if (mQuotaTextLink != null) {
if (getBaseContext().getResources().getBoolean(R.bool.show_external_links)) {
List<ExternalLink> quotas = externalLinksProvider.getExternalLink(ExternalLinkType.QUOTA);
float density = getResources().getDisplayMetrics().density;
final int size = Math.round(24 * density);
if (quotas.size() > 0) {
final ExternalLink firstQuota = quotas.get(0);
mQuotaTextLink.setText(firstQuota.getName());
mQuotaTextLink.setClickable(true);
mQuotaTextLink.setVisibility(View.VISIBLE);
mQuotaTextLink.setOnClickListener(v -> {
Intent externalWebViewIntent = new Intent(getApplicationContext(), ExternalSiteWebView.class);
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, firstQuota.getName());
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_URL, firstQuota.getUrl());
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, true);
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, -1);
startActivity(externalWebViewIntent);
});
SimpleTarget target = new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(Drawable resource, GlideAnimation glideAnimation) {
Drawable test = resource.getCurrent();
test.setBounds(0, 0, size, size);
mQuotaTextLink.setCompoundDrawablesWithIntrinsicBounds(test, null, null, null);
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
Drawable test = errorDrawable.getCurrent();
test.setBounds(0, 0, size, size);
mQuotaTextLink.setCompoundDrawablesWithIntrinsicBounds(test, null, null, null);
}
};
DisplayUtils.downloadIcon(getUserAccountManager(), clientFactory, this, firstQuota.getIconUrl(), target, R.drawable.ic_link, size, size);
} else {
mQuotaTextLink.setVisibility(View.GONE);
}
} else {
mQuotaTextLink.setVisibility(View.GONE);
}
}
}
use of com.bumptech.glide.request.target.SimpleTarget in project android by nextcloud.
the class ContactListAdapter method setPhoto.
private void setPhoto(ImageView imageView, Photo firstPhoto) {
String url = firstPhoto.getUrl();
byte[] data = firstPhoto.getData();
if (data != null && data.length > 0) {
Bitmap thumbnail = BitmapFactory.decodeByteArray(data, 0, data.length);
RoundedBitmapDrawable drawable = BitmapUtils.bitmapToCircularBitmapDrawable(context.getResources(), thumbnail);
imageView.setImageDrawable(drawable);
} else if (url != null) {
SimpleTarget target = new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(Drawable resource, GlideAnimation glideAnimation) {
imageView.setImageDrawable(resource);
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
imageView.setImageDrawable(errorDrawable);
}
};
DisplayUtils.downloadIcon(accountManager, clientFactory, context, url, target, R.drawable.ic_user, imageView.getWidth(), imageView.getHeight());
}
}
Aggregations