use of com.bumptech.glide.load.engine.GlideException in project xabber-android by redsolution.
the class ImageViewerFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// get params
Bundle args = getArguments();
if (args == null)
return;
String source;
String uri = args.getString(IMAGE_URL);
final String path = args.getString(IMAGE_PATH);
if (path != null)
source = path;
else
source = uri;
final String attachmentId = args.getString(ATTACHMENT_ID);
// find views
ivPhoto = view.findViewById(R.id.ivPhoto);
progressBar = view.findViewById(R.id.progressBar);
// setup image
progressBar.setVisibility(View.VISIBLE);
Glide.with(getActivity()).load(source).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
if (e != null)
showError(e.toString());
if (path != null)
MessageManager.setAttachmentLocalPathToNull(attachmentId);
progressBar.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
}).into(ivPhoto);
}
use of com.bumptech.glide.load.engine.GlideException in project Signal-Android by WhisperSystems.
the class AvatarPreviewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState, boolean ready) {
super.onCreate(savedInstanceState, ready);
setTheme(R.style.TextSecure_MediaPreview);
setContentView(R.layout.contact_photo_preview_activity);
if (Build.VERSION.SDK_INT >= 21) {
postponeEnterTransition();
TransitionInflater inflater = TransitionInflater.from(this);
getWindow().setSharedElementEnterTransition(inflater.inflateTransition(R.transition.full_screen_avatar_image_enter_transition_set));
getWindow().setSharedElementReturnTransition(inflater.inflateTransition(R.transition.full_screen_avatar_image_return_transition_set));
}
Toolbar toolbar = findViewById(R.id.toolbar);
EmojiTextView title = findViewById(R.id.title);
ImageView avatar = findViewById(R.id.avatar);
setSupportActionBar(toolbar);
requireSupportActionBar().setDisplayHomeAsUpEnabled(true);
requireSupportActionBar().setDisplayShowTitleEnabled(false);
Context context = getApplicationContext();
RecipientId recipientId = RecipientId.from(getIntent().getStringExtra(RECIPIENT_ID_EXTRA));
Recipient.live(recipientId).observe(this, recipient -> {
ContactPhoto contactPhoto = recipient.isSelf() ? new ProfileContactPhoto(recipient, recipient.getProfileAvatar()) : recipient.getContactPhoto();
FallbackContactPhoto fallbackPhoto = recipient.isSelf() ? new ResourceContactPhoto(R.drawable.ic_profile_outline_40, R.drawable.ic_profile_outline_20, R.drawable.ic_person_large) : recipient.getFallbackContactPhoto();
Resources resources = this.getResources();
GlideApp.with(this).asBitmap().load(contactPhoto).fallback(fallbackPhoto.asCallCard(this)).error(fallbackPhoto.asCallCard(this)).diskCacheStrategy(DiskCacheStrategy.ALL).addListener(new RequestListener<Bitmap>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
Log.w(TAG, "Unable to load avatar, or avatar removed, closing");
finish();
return false;
}
@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
}).into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
avatar.setImageDrawable(RoundedBitmapDrawableFactory.create(resources, resource));
if (Build.VERSION.SDK_INT >= 21) {
startPostponedEnterTransition();
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
title.setText(recipient.getDisplayName(context));
});
FullscreenHelper fullscreenHelper = new FullscreenHelper(this);
findViewById(android.R.id.content).setOnClickListener(v -> fullscreenHelper.toggleUiVisibility());
fullscreenHelper.configureToolbarSpacer(findViewById(R.id.toolbar_cutout_spacer));
fullscreenHelper.showAndHideWithSystemUI(getWindow(), findViewById(R.id.toolbar_layout));
}
use of com.bumptech.glide.load.engine.GlideException in project xabber-android by redsolution.
the class FileMessageVH method setUpImage.
private void setUpImage(String imagePath, String imageUrl, final String uniqueId, Integer imageWidth, Integer imageHeight, Context context) {
if (!SettingsManager.connectionLoadImages())
return;
if (imagePath != null) {
boolean result = FileManager.loadImageFromFile(context, imagePath, messageImage);
if (result) {
messageImage.setVisibility(View.VISIBLE);
} else {
final Realm realm = MessageDatabaseManager.getInstance().getRealmUiThread();
realm.executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
MessageItem first = realm.where(MessageItem.class).equalTo(MessageItem.Fields.UNIQUE_ID, uniqueId).findFirst();
if (first != null) {
first.setFilePath(null);
}
}
});
}
} else {
final ViewGroup.LayoutParams layoutParams = messageImage.getLayoutParams();
if (imageWidth != null && imageHeight != null) {
FileManager.scaleImage(layoutParams, imageHeight, imageWidth);
Glide.with(context).load(imageUrl).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
messageImage.setVisibility(View.GONE);
return true;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
}).into(messageImage);
messageImage.setVisibility(View.VISIBLE);
} else {
Glide.with(context).asBitmap().load(imageUrl).placeholder(R.drawable.ic_recent_image_placeholder).error(R.drawable.ic_recent_image_placeholder).into(new CustomTarget<Bitmap>() {
@Override
public void onLoadStarted(@Nullable Drawable placeholder) {
super.onLoadStarted(placeholder);
messageImage.setImageDrawable(placeholder);
messageImage.setVisibility(View.VISIBLE);
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
messageImage.setImageDrawable(errorDrawable);
messageImage.setVisibility(View.VISIBLE);
}
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
final int width = resource.getWidth();
final int height = resource.getHeight();
if (width <= 0 || height <= 0) {
messageImage.setVisibility(View.GONE);
return;
}
final Realm realm = MessageDatabaseManager.getInstance().getRealmUiThread();
realm.executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
MessageItem first = realm.where(MessageItem.class).equalTo(MessageItem.Fields.UNIQUE_ID, uniqueId).findFirst();
if (first != null) {
first.setImageWidth(width);
first.setImageHeight(height);
}
}
});
FileManager.scaleImage(layoutParams, height, width);
messageImage.setImageBitmap(resource);
messageImage.setVisibility(View.VISIBLE);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
}
}
}
use of com.bumptech.glide.load.engine.GlideException 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.load.engine.GlideException 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);
});
}
Aggregations