diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java index 9f38adff4..ae1c8bd06 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java @@ -620,7 +620,22 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi } - Glide.with(getApplicationContext()).load(account.getAvatar()).apply(RequestOptions.circleCropTransform()).into(account_pp); + boolean disableGif = sharedpreferences.getBoolean(Helper.SET_DISABLE_GIF, false); + if( !disableGif) + Glide.with(getApplicationContext()).load(account.getAvatar()).apply(RequestOptions.circleCropTransform()).into(account_pp); + else + Glide.with(getApplicationContext()) + .asBitmap() + .load(account.getAvatar()) + .into(new SimpleTarget() { + @Override + public void onResourceReady(Bitmap resource, Transition transition) { + RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), Helper.addBorder(resource, account_pp.getContext())); + circularBitmapDrawable.setCircular(true); + account_pp.setImageDrawable(circularBitmapDrawable); + } + }); + } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java index 0f8d554a5..4126498a8 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java @@ -32,8 +32,6 @@ import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; -import com.bumptech.glide.Glide; - import java.util.ArrayList; import java.util.List; @@ -149,10 +147,7 @@ public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostA holder.account_fgc.setText(withSuffix(account.getFollowing_count())); holder.account_frc.setText(withSuffix(account.getFollowers_count())); //Profile picture - Glide.with(holder.account_pp.getContext()) - .load(account.getAvatar()) - .into(holder.account_pp); - + Helper.loadGiF(context, account.getAvatar(), holder.account_pp); if( account.isMakingAction()){ holder.account_follow.setEnabled(false); }else { diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index ff5ba50e9..307c34d62 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -375,9 +375,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct imParams.height = (int) Helper.convertDpToPixel(30, context); imParams.width = (int) Helper.convertDpToPixel(30, context); holder.status_replies_profile_pictures.addView(imageView, imParams); - Glide.with(imageView.getContext()) - .load(replies.getAccount().getAvatar()) - .into(imageView); + Helper.loadGiF(context, replies.getAccount().getAvatar(), imageView); i++; addedPictures.add(replies.getAccount().getAcct()); } @@ -602,19 +600,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct Helper.absoluteDateTimeReveal(context, holder.status_toot_date, status.getCreated_at()); if( status.getReblog() != null) { - Glide.with(holder.status_account_profile_boost.getContext()) - .load(ppurl) - .into(holder.status_account_profile_boost); - Glide.with(holder.status_account_profile_boost_by.getContext()) - .load(status.getAccount().getAvatar()) - .into(holder.status_account_profile_boost_by); + Helper.loadGiF(context, ppurl, holder.status_account_profile_boost); + Helper.loadGiF(context, status.getAccount().getAvatar(), holder.status_account_profile_boost_by); holder.status_account_profile_boost.setVisibility(View.VISIBLE); holder.status_account_profile_boost_by.setVisibility(View.VISIBLE); holder.status_account_profile.setVisibility(View.GONE); }else{ - Glide.with(holder.status_account_profile.getContext()) - .load(ppurl) - .into(holder.status_account_profile); + Helper.loadGiF(context, ppurl, holder.status_account_profile); holder.status_account_profile_boost.setVisibility(View.GONE); holder.status_account_profile_boost_by.setVisibility(View.GONE); holder.status_account_profile.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index 528237b37..16fd272a5 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -1675,4 +1675,26 @@ public class Helper { return output; } + + public static void loadGiF(final Context context, String url, final ImageView imageView){ + SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + boolean disableGif = sharedpreferences.getBoolean(SET_DISABLE_GIF, false); + + if( !disableGif) + Glide.with(imageView.getContext()) + .load(url) + .into(imageView); + else + Glide.with(context) + .asBitmap() + .load(url) + .into(new SimpleTarget() { + @Override + public void onResourceReady(Bitmap resource, Transition transition) { + imageView.setImageBitmap(resource); + } + }); + } + + }