use of com.bumptech.glide.load.DataSource in project Robot-Scouter by SUPERCILEX.
the class TeamDetailsDialog method updateUi.
private void updateUi() {
if (mMedia != null && mName != null && mNameEditText != null && mMediaCapture != null && mWebsiteEditText != null) {
Team team = mTeamHelper.getTeam();
mMediaLoadProgress.setVisibility(View.VISIBLE);
Glide.with(getContext()).load(team.getMedia()).apply(RequestOptions.circleCropTransform().error(R.drawable.ic_memory_grey_48dp).fallback(R.drawable.ic_memory_grey_48dp)).listener(new RequestListener<Drawable>() {
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
mMediaLoadProgress.setVisibility(View.GONE);
return false;
}
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
mMediaLoadProgress.setVisibility(View.GONE);
return false;
}
}).into(mMedia);
mName.setText(team.toString());
mNameEditText.setText(team.getName());
mMediaEditText.setText(team.getMedia());
mWebsiteEditText.setText(team.getWebsite());
}
}
use of com.bumptech.glide.load.DataSource in project glide by bumptech.
the class FullscreenActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fullscreen_activity);
String resultJson = getIntent().getStringExtra(EXTRA_RESULT_JSON);
final Api.GifResult result = new Gson().fromJson(resultJson, Api.GifResult.class);
ImageView gifView = (ImageView) findViewById(R.id.fullscreen_gif);
gifView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("giphy_url", result.images.original.url);
clipboard.setPrimaryClip(clip);
if (gifDrawable != null) {
if (gifDrawable.isRunning()) {
gifDrawable.stop();
} else {
gifDrawable.start();
}
}
}
});
RequestBuilder<Drawable> thumbnailRequest = Glide.with(this).load(result).apply(decodeTypeOf(Bitmap.class));
Glide.with(this).load(result.images.original.url).thumbnail(thumbnailRequest).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
if (resource instanceof GifDrawable) {
gifDrawable = (GifDrawable) resource;
} else {
gifDrawable = null;
}
return false;
}
}).into(gifView);
}
Aggregations