Ezerous
5 years ago
No known key found for this signature in database
GPG Key ID: 262B2954BBA319E3
3 changed files with
39 additions and
12 deletions
-
app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java
-
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
-
app/src/main/java/gr/thmmy/mthmmy/utils/ui/GlideUtils.java
|
|
@ -1,5 +1,7 @@ |
|
|
|
package gr.thmmy.mthmmy.activities.profile; |
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
import android.content.Context; |
|
|
|
import android.content.Intent; |
|
|
|
import android.graphics.Color; |
|
|
|
import android.graphics.Typeface; |
|
|
@ -57,6 +59,7 @@ import timber.log.Timber; |
|
|
|
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; |
|
|
|
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; |
|
|
|
import static gr.thmmy.mthmmy.utils.parsing.ParseHelpers.emojiTagToHtml; |
|
|
|
import static gr.thmmy.mthmmy.utils.ui.GlideUtils.isValidContextForGlide; |
|
|
|
import static gr.thmmy.mthmmy.utils.ui.PhotoViewUtils.displayPhotoViewImage; |
|
|
|
|
|
|
|
/** |
|
|
@ -222,12 +225,16 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment |
|
|
|
avatarView.setOnClickListener(v -> displayPhotoViewImage(ProfileActivity.this, avatarUrl)); |
|
|
|
} |
|
|
|
|
|
|
|
Glide.with(this) |
|
|
|
.load(avatarUri) |
|
|
|
.circleCrop() |
|
|
|
.error(R.drawable.ic_default_user_avatar) |
|
|
|
.placeholder(R.drawable.ic_default_user_avatar) |
|
|
|
.into(avatarView); |
|
|
|
if(isValidContextForGlide(this)){ |
|
|
|
Glide.with(this) |
|
|
|
.load(avatarUri) |
|
|
|
.circleCrop() |
|
|
|
.error(R.drawable.ic_default_user_avatar) |
|
|
|
.placeholder(R.drawable.ic_default_user_avatar) |
|
|
|
.into(avatarView); |
|
|
|
} |
|
|
|
else |
|
|
|
Timber.d("Will not load Glide image (invalid context)"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
@ -88,6 +88,7 @@ import static gr.thmmy.mthmmy.activities.topic.TopicParser.USER_COLOR_WHITE; |
|
|
|
import static gr.thmmy.mthmmy.activities.topic.TopicParser.USER_COLOR_YELLOW; |
|
|
|
import static gr.thmmy.mthmmy.base.BaseActivity.getSessionManager; |
|
|
|
import static gr.thmmy.mthmmy.utils.FileUtils.faIconFromFilename; |
|
|
|
import static gr.thmmy.mthmmy.utils.ui.GlideUtils.isValidContextForGlide; |
|
|
|
|
|
|
|
/** |
|
|
|
* Custom {@link RecyclerView.Adapter} used for topics. |
|
|
@ -810,12 +811,14 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
|
if(imageUrl!=null) |
|
|
|
imageUrl = imageUrl.trim(); |
|
|
|
|
|
|
|
Glide.with(context) |
|
|
|
.load(imageUrl) |
|
|
|
.circleCrop() |
|
|
|
.error(R.drawable.ic_default_user_avatar_darker) |
|
|
|
.placeholder(R.drawable.ic_default_user_avatar_darker) |
|
|
|
.into(imageView); |
|
|
|
if(isValidContextForGlide(context)) { |
|
|
|
Glide.with(context) |
|
|
|
.load(imageUrl) |
|
|
|
.circleCrop() |
|
|
|
.error(R.drawable.ic_default_user_avatar_darker) |
|
|
|
.placeholder(R.drawable.ic_default_user_avatar_darker) |
|
|
|
.into(imageView); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@ -0,0 +1,17 @@ |
|
|
|
package gr.thmmy.mthmmy.utils.ui; |
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
import android.content.Context; |
|
|
|
|
|
|
|
public class GlideUtils { |
|
|
|
public static boolean isValidContextForGlide(final Context context) { |
|
|
|
if (context == null) |
|
|
|
return false; |
|
|
|
|
|
|
|
if (context instanceof Activity) { |
|
|
|
final Activity activity = (Activity) context; |
|
|
|
return !activity.isDestroyed() && !activity.isFinishing(); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |