use of com.bumptech.glide.request.RequestListener in project LuaViewSDK by alibaba.
the class GlideImageProvider method preload.
@Override
public void preload(final Context context, String url, final DrawableLoadCallback callback) {
if (callback != null) {
Glide.with(context).load(url).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
if (callback != null) {
callback.onLoadResult(null);
}
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
if (callback != null) {
Drawable r = resource instanceof GlideBitmapDrawable ? new BitmapDrawable(context.getResources(), ((GlideBitmapDrawable) resource).getBitmap()) : resource;
callback.onLoadResult(r);
}
return false;
}
}).preload();
} else {
Glide.with(context).load(url).preload();
}
}
use of com.bumptech.glide.request.RequestListener in project Douya by DreaminginCodeZH.
the class ImageUtils method loadNavigationHeaderAvatar.
public static void loadNavigationHeaderAvatar(final ImageView view, final String url) {
Context context = view.getContext();
int size = context.getResources().getDimensionPixelSize(R.dimen.navigation_header_avatar_size);
GlideApp.with(context).load(url).apply(REQUEST_OPTIONS_LOAD_NAVIGATION_HEADER_AVATAR.override(size, size)).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
(e != null ? e : new NullPointerException()).printStackTrace();
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
view.setTag(url);
return false;
}
}).into(view);
}
use of com.bumptech.glide.request.RequestListener in project bugzy by cpunq.
the class OrganisationFrgment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mLoginViewModel = ViewModelProviders.of(getActivity(), mViewModelFactory).get(LoginViewModel.class);
mLogoProgressBar.setVisibility(View.GONE);
mOrgNameView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
mOrgImageView.setVisibility(View.GONE);
mLoginViewModel.organisationNameChanged(charSequence.toString());
}
@Override
public void afterTextChanged(Editable editable) {
}
});
mLoginViewModel.getOrganisationLogoResource().observe(this, resourceState -> {
if (resourceState.status == Status.LOADING) {
mLogoProgressBar.setVisibility(View.VISIBLE);
}
if (resourceState.status == Status.ERROR) {
mLogoProgressBar.setVisibility(View.GONE);
}
if (TextUtils.isEmpty(resourceState.data)) {
return;
}
mOrgImageView.setVisibility(View.VISIBLE);
Glide.with(getContext()).load(resourceState.data).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
mLogoProgressBar.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
mLogoProgressBar.setVisibility(View.GONE);
return false;
}
}).into(mOrgImageView);
});
}
use of com.bumptech.glide.request.RequestListener in project AndroidStudy by tinggengyan.
the class GlideMainActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_imageview);
prescale_iamgeview = (ImageView) findViewById(R.id.prescale_iamgeview);
RequestManager requestManager = Glide.with(this);
requestManager.load(Constants.IMAGES[0]).placeholder(R.drawable.accept).diskCacheStrategy(DiskCacheStrategy.NONE).override(100, 100).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
}).into(prescale_iamgeview);
requestManager.load(Constants.IMAGES[1]).diskCacheStrategy(DiskCacheStrategy.SOURCE).preload();
downloadImage(prescale_iamgeview);
}
use of com.bumptech.glide.request.RequestListener in project drift-sdk-android by Driftt.
the class ImageViewerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.drift_sdk_activity_image_viewer);
StatusBarColorizer.setActivityColor(this);
getSupportActionBar().setTitle("Attachment");
imageView = findViewById(R.id.drift_sdk_image_viewer_image_view);
progressBar = findViewById(R.id.drift_sdk_image_viewer_progress_view);
Intent intent = getIntent();
if (intent.getExtras() != null) {
String imageUriAsString = intent.getExtras().getString(IMAGE_URI);
if (imageUriAsString == null || imageUriAsString.isEmpty()) {
finish();
return;
}
imageUri = Uri.parse(imageUriAsString);
}
Glide.with(this).load(imageUri).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Drawable> target, boolean b) {
progressBar.setVisibility(View.GONE);
Toast.makeText(ImageViewerActivity.this, "Failed to load Image", Toast.LENGTH_LONG).show();
finish();
return false;
}
@Override
public boolean onResourceReady(Drawable drawable, Object o, Target<Drawable> target, DataSource dataSource, boolean b) {
progressBar.setVisibility(View.GONE);
return false;
}
}).into(imageView);
}
Aggregations