fix avatars

This commit is contained in:
tom79 2019-08-01 11:41:38 +02:00
parent 5d1a5f6de9
commit dde82c2c57
24 changed files with 109 additions and 164 deletions

View File

@ -124,7 +124,7 @@ public class CustomSharingActivity extends BaseActivity implements OnCustomShari
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account account = new AccountDAO(getApplicationContext(),db).getUniqAccount(userId, instance);
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
Helper.loadGiF(getApplicationContext(), account.getAvatar_static(), account.getAvatar(), pp_actionBar);
Bundle b = getIntent().getExtras();
Status status = null;
if(b != null) {

View File

@ -158,7 +158,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
Helper.loadGiF(getApplicationContext(), account.getAvatar_static(), account.getAvatar(), pp_actionBar);
set_profile_name = findViewById(R.id.set_profile_name);
set_profile_description = findViewById(R.id.set_profile_description);

View File

@ -130,7 +130,7 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account account = new AccountDAO(getApplicationContext(),db).getUniqAccount(userId, instance);
if( account != null) {
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
Helper.loadGiF(getApplicationContext(), account.getAvatar_static(), account.getAvatar(), pp_actionBar);
}
toolbar_close.setOnClickListener(new View.OnClickListener() {

View File

@ -189,7 +189,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
SQLiteDatabase db = Sqlite.getInstance(OwnerStatusActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
Account account = new AccountDAO(OwnerStatusActivity.this,db).getUniqAccount(userId, instance);
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
Helper.loadGiF(getApplicationContext(), account.getAvatar_static(), account.getAvatar(), pp_actionBar);
swipeRefreshLayout = findViewById(R.id.swipeContainer);
new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, null, OwnerStatusActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

View File

@ -225,7 +225,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
Helper.loadGiF(getApplicationContext(), account, my_pp);
Helper.loadGiF(getApplicationContext(), account.getAvatar_static(), account.getAvatar(), my_pp);
Bundle b = getIntent().getExtras();
if(b != null) {
peertubeInstance = b.getString("peertube_instance", null);

View File

@ -338,7 +338,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
actionbar_title.setText(account.getAcct());
pp_actionBar = findViewById(R.id.pp_actionBar);
if( account.getAvatar() != null){
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
Helper.loadGiF(getApplicationContext(), account.getAvatar_static(), account.getAvatar(), pp_actionBar);
}
final AppBarLayout appBar = findViewById(R.id.appBar);

View File

@ -237,7 +237,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetriev
Toasty.error(ShowConversationActivity.this,getString(R.string.toast_error), Toast.LENGTH_LONG).show();
finish();
}
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
Helper.loadGiF(getApplicationContext(), account.getAvatar_static(), account.getAvatar(), pp_actionBar);
swipeRefreshLayout = findViewById(R.id.swipeContainer);

View File

@ -690,7 +690,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
Helper.loadGiF(getApplicationContext(), account, pp_actionBar);
Helper.loadGiF(getApplicationContext(), account.getAvatar_static(), account.getAvatar(), pp_actionBar);
if (sharedContent != null) { //Shared content

View File

@ -17,7 +17,6 @@ package app.fedilab.android.asynctasks;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
import android.util.Log;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@ -30,7 +29,6 @@ import app.fedilab.android.client.Entities.Conversation;
import app.fedilab.android.client.Entities.ManageTimelines;
import app.fedilab.android.client.Entities.TagTimeline;
import app.fedilab.android.client.GNUAPI;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.sqlite.SearchDAO;
import app.fedilab.android.sqlite.Sqlite;
import app.fedilab.android.sqlite.TimelinesDAO;
@ -119,8 +117,14 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
if (conversations != null && conversations.size() > 0) {
for (Conversation conversation : conversations) {
app.fedilab.android.client.Entities.Status status = conversation.getLast_status();
List<Account> ppConversation = new ArrayList<>(conversation.getAccounts());
status.setConversationAccounts(ppConversation);
List<String> ppConversationStatic = new ArrayList<>();
List<String> ppConversation = new ArrayList<>();
for (Account account : conversation.getAccounts()) {
ppConversationStatic.add(account.getAvatar_static());
ppConversation.add(account.getAvatar());
}
status.setConversationProfilePicture(ppConversation);
status.setConversationProfilePictureStatic(ppConversationStatic);
status.setConversationId(conversation.getId());
tempStatus.add(status);
}
@ -166,8 +170,14 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
if (conversations != null && conversations.size() > 0) {
for (Conversation conversation : conversations) {
app.fedilab.android.client.Entities.Status status = conversation.getLast_status();
List<Account> ppConversation = new ArrayList<>(conversation.getAccounts());
status.setConversationAccounts(ppConversation);
List<String> ppConversationStatic = new ArrayList<>();
List<String> ppConversation = new ArrayList<>();
for (Account account : conversation.getAccounts()) {
ppConversationStatic.add(account.getAvatar_static());
ppConversation.add(account.getAvatar());
}
status.setConversationProfilePicture(ppConversation);
status.setConversationProfilePictureStatic(ppConversationStatic);
status.setConversationId(conversation.getId());
tempStatus.add(status);
}

View File

@ -19,7 +19,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

View File

@ -133,7 +133,8 @@ public class Status implements Parcelable{
private boolean showSpoiler = false;
public Status(){}
private List<Account> conversationAccounts;
private List<String> conversationProfilePicture;
private List<String> conversationProfilePictureStatic;
private String webviewURL = null;
private boolean isBoostAnimated = false, isFavAnimated = false;
@ -199,7 +200,8 @@ public class Status implements Parcelable{
dest.writeString(this.conversationId);
dest.writeByte(this.isExpanded ? (byte) 1 : (byte) 0);
dest.writeInt(this.numberLines);
dest.writeTypedList(this.conversationAccounts);
dest.writeStringList(this.conversationProfilePicture);
dest.writeStringList(this.conversationProfilePictureStatic);
dest.writeString(this.webviewURL);
dest.writeByte(this.isBoostAnimated ? (byte) 1 : (byte) 0);
dest.writeByte(this.isFavAnimated ? (byte) 1 : (byte) 0);
@ -265,7 +267,8 @@ public class Status implements Parcelable{
this.conversationId = in.readString();
this.isExpanded = in.readByte() != 0;
this.numberLines = in.readInt();
this.conversationAccounts = in.createTypedArrayList(Account.CREATOR);
this.conversationProfilePicture = in.createStringArrayList();
this.conversationProfilePictureStatic = in.createStringArrayList();
this.webviewURL = in.readString();
this.isBoostAnimated = in.readByte() != 0;
this.isFavAnimated = in.readByte() != 0;
@ -591,7 +594,7 @@ public class Status implements Parcelable{
SpannableString spannableStringContent, spannableStringCW;
if( (status.getReblog() != null && status.getReblog().getContent() == null) || (status.getReblog() == null && status.getContent() == null))
return;
String content = status.getReblog() != null ?status.getReblog().getContent():status.getContent();
Pattern aLink = Pattern.compile("<a((?!href).)*href=\"([^\"]*)\"[^>]*(((?!<\\/a).)*)<\\/a>");
Matcher matcherALink = aLink.matcher(content);
@ -1437,12 +1440,12 @@ public class Status implements Parcelable{
this.type = type;
}
public List<Account> getConversationAccounts() {
return conversationAccounts;
public List<String> getConversationProfilePicture() {
return conversationProfilePicture;
}
public void setConversationAccounts(List<Account> conversationAccounts) {
this.conversationAccounts = conversationAccounts;
public void setConversationProfilePicture(List<String> conversationProfilePicture) {
this.conversationProfilePicture = conversationProfilePicture;
}
public String getWebviewURL() {
@ -1603,4 +1606,12 @@ public class Status implements Parcelable{
public void setImageURL(List<String> imageURL) {
this.imageURL = imageURL;
}
public List<String> getConversationProfilePictureStatic() {
return conversationProfilePictureStatic;
}
public void setConversationProfilePictureStatic(List<String> conversationProfilePictureStatic) {
this.conversationProfilePictureStatic = conversationProfilePictureStatic;
}
}

View File

@ -99,7 +99,7 @@ public class AccountsAdminListAdapter extends RecyclerView.Adapter implements On
holder.account_ac.setVisibility(View.VISIBLE);
holder.report_action_taken.setText(accountAdmin.getIp());
Helper.loadGiF(context, account, holder.account_pp);
Helper.loadGiF(context, account.getAvatar_static(), account.getAvatar(), holder.account_pp);
holder.main_container.setOnClickListener(view ->{

View File

@ -88,7 +88,7 @@ public class AccountsInAListAdapter extends RecyclerView.Adapter implements OnLi
else
holder.account_ac.setVisibility(View.VISIBLE);
//Profile picture
Helper.loadGiF(context, account, holder.account_pp);
Helper.loadGiF(context, account.getAvatar_static(), account.getAvatar(), holder.account_pp);
if( actionType == type.CURRENT){
holder.account_action.setImageResource(R.drawable.ic_close);

View File

@ -199,7 +199,7 @@ public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostA
holder.account_fgc.setText(Helper.withSuffix(account.getFollowing_count()));
holder.account_frc.setText(Helper.withSuffix(account.getFollowers_count()));
//Profile picture
Helper.loadGiF(context, account, holder.account_pp);
Helper.loadGiF(context, account.getAvatar_static(), account.getAvatar(), holder.account_pp);
if( account.isMakingAction()){
holder.account_follow.setEnabled(false);
}else {

View File

@ -182,7 +182,7 @@ public class ArtListAdapter extends RecyclerView.Adapter implements OnPostAction
Status.makeEmojis(context, this, status);
if (status.getAccount() != null && status.getAccount().getAvatar() != null)
Helper.loadGiF(context, status.getAccount(), holder.art_pp);
Helper.loadGiF(context, status.getAccount().getAvatar_static(), status.getAccount().getAvatar(), holder.art_pp);
if (status.getArt_attachment() != null)
Glide.with(context)

View File

@ -1144,7 +1144,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
}
//Profile picture
Helper.loadGiF(context, notification.getAccount(), holder.notification_account_profile);
Helper.loadGiF(context, notification.getAccount().getAvatar_static(), notification.getAccount().getAvatar(), holder.notification_account_profile);
}

View File

@ -117,7 +117,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter implements OnListActio
.into(holder.peertube_video_image);
if (account.getAvatar() != null && !account.getAvatar().equals("null") && !account.getAvatar().startsWith("http"))
account.setAvatar("https://" + peertube.getInstance() + account.getAvatar());
Helper.loadGiF(context, account, holder.peertube_profile);
Helper.loadGiF(context, account.getAvatar_static(), account.getAvatar(), holder.peertube_profile);
if( peertube.getHeaderType() != null && peertube.getHeaderTypeValue() != null) {

View File

@ -101,7 +101,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter {
PeertubeVideoNotification videoAction = null;
if( notification.getPeertubeActorFollow() != null){
String profileUrl = Helper.getLiveInstanceWithProtocol(context) + notification.getPeertubeActorFollow().getFollower().getAvatar();
Helper.loadGiF(context,profileUrl, holder.peertube_notif_pp);
Helper.loadGiF(context,profileUrl, profileUrl, holder.peertube_notif_pp);
accountAction =notification.getPeertubeActorFollow().getFollower();
String type = notification.getPeertubeActorFollow().getFollowing().getType();
String message;
@ -126,7 +126,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter {
});
}else if( notification.getPeertubeComment() != null){ //Comment Notification
String profileUrl = Helper.getLiveInstanceWithProtocol(context) + notification.getPeertubeComment().getPeertubeAccountNotification().getAvatar();
Helper.loadGiF(context, profileUrl, holder.peertube_notif_pp);
Helper.loadGiF(context, profileUrl, profileUrl, holder.peertube_notif_pp);
accountAction = notification.getPeertubeComment().getPeertubeAccountNotification();
videoAction = notification.getPeertubeComment().getPeertubeVideoNotification();
String message = context.getString(R.string.peertube_comment_on_video,accountAction.getDisplayName(), videoAction.getName());
@ -148,7 +148,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter {
}else {//Other Notifications
if (notification.getPeertubeVideoNotification() != null && notification.getPeertubeVideoNotification().getPeertubeAccountNotification() != null){
String profileUrl = Helper.getLiveInstanceWithProtocol(context) + notification.getPeertubeVideoNotification().getPeertubeAccountNotification().getAvatar();
Helper.loadGiF(context, profileUrl, holder.peertube_notif_pp);
Helper.loadGiF(context, profileUrl, profileUrl, holder.peertube_notif_pp);
accountAction = notification.getPeertubeVideoNotification().getPeertubeAccountNotification();
videoAction = notification.getPeertubeVideoNotification();
String message = "";

View File

@ -101,9 +101,9 @@ public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrie
if( target_account.getAvatar() != null) {
Helper.loadGiF(context, target_account, holder.account_pp);
Helper.loadGiF(context, target_account.getAvatar_static(), target_account.getAvatar(), holder.account_pp);
}
Helper.loadGiF(context, account, holder.account_pp_reporter);
Helper.loadGiF(context, account.getAvatar_static(), account.getAvatar(), holder.account_pp_reporter);
if( target_account.getAcct() != null) {
holder.account_ac.setText(target_account.getAcct());
}

View File

@ -250,7 +250,7 @@ public class ScheduledTootsListAdapter extends BaseAdapter implements OnPostActi
holder.scheduled_toot_media_count.setVisibility(View.GONE);
holder.scheduled_toot_date_creation.setVisibility(View.GONE);
holder.scheduled_toot_privacy.setVisibility(View.GONE);
Helper.loadGiF(context, storedStatus.getStatus().getAccount(), holder.scheduled_toot_pp);
Helper.loadGiF(context, storedStatus.getStatus().getAccount().getAvatar_static(), storedStatus.getStatus().getAccount().getAvatar(), holder.scheduled_toot_pp);
}else {
holder.scheduled_toot_pp.setVisibility(View.GONE);
}

View File

@ -2009,21 +2009,21 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
}
if (status.getReblog() != null) {
Helper.loadGiF(context, accountForUrl, holder.status_account_profile_boost);
Helper.loadGiF(context, status.getAccount(), holder.status_account_profile_boost_by);
Helper.loadGiF(context, accountForUrl.getAvatar_static(), accountForUrl.getAvatar(), holder.status_account_profile_boost);
Helper.loadGiF(context, status.getAccount().getAvatar_static(), 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 {
Helper.loadGiF(context, accountForUrl, holder.status_account_profile);
Helper.loadGiF(context, accountForUrl.getAvatar_static(), accountForUrl.getAvatar(), 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);
}
if (type == RetrieveFeedsAsyncTask.Type.CONVERSATION && status.getConversationAccounts() != null) {
if (type == RetrieveFeedsAsyncTask.Type.CONVERSATION && status.getConversationProfilePicture() != null) {
holder.status_account_profile.setVisibility(View.GONE);
holder.conversation_pp.setVisibility(View.VISIBLE);
if (status.getConversationAccounts().size() == 1) {
if (status.getConversationProfilePicture().size() == 1) {
holder.conversation_pp_1.setVisibility(View.VISIBLE);
holder.conversation_pp_1.setScaleType(ImageView.ScaleType.CENTER_CROP);
holder.conversation_pp_2_container.setVisibility(View.GONE);
@ -2031,17 +2031,17 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.conversation_pp_2.setVisibility(View.GONE);
holder.conversation_pp_3.setVisibility(View.GONE);
holder.conversation_pp_4.setVisibility(View.GONE);
Helper.loadGiF(context, status.getConversationAccounts().get(0), holder.conversation_pp_1);
} else if (status.getConversationAccounts().size() == 2) {
Helper.loadGiF(context, status.getConversationProfilePictureStatic().get(0), status.getConversationProfilePicture().get(0), holder.conversation_pp_1);
} else if (status.getConversationProfilePicture().size() == 2) {
holder.conversation_pp_2_container.setVisibility(View.VISIBLE);
holder.conversation_pp_3_container.setVisibility(View.GONE);
holder.conversation_pp_1.setVisibility(View.VISIBLE);
holder.conversation_pp_2.setVisibility(View.VISIBLE);
holder.conversation_pp_3.setVisibility(View.GONE);
holder.conversation_pp_4.setVisibility(View.GONE);
Helper.loadGiF(context, status.getConversationAccounts().get(0), holder.conversation_pp_1);
Helper.loadGiF(context, status.getConversationAccounts().get(1), holder.conversation_pp_2);
} else if (status.getConversationAccounts().size() == 3) {
Helper.loadGiF(context, status.getConversationProfilePictureStatic().get(0), status.getConversationProfilePicture().get(0), holder.conversation_pp_1);
Helper.loadGiF(context, status.getConversationProfilePictureStatic().get(1), status.getConversationProfilePicture().get(1), holder.conversation_pp_2);
} else if (status.getConversationProfilePicture().size() == 3) {
holder.conversation_pp_4.setVisibility(View.GONE);
holder.conversation_pp_1.setVisibility(View.VISIBLE);
holder.conversation_pp_2.setVisibility(View.VISIBLE);
@ -2049,20 +2049,20 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.conversation_pp_4.setVisibility(View.GONE);
holder.conversation_pp_2_container.setVisibility(View.VISIBLE);
holder.conversation_pp_3_container.setVisibility(View.VISIBLE);
Helper.loadGiF(context, status.getConversationAccounts().get(0), holder.conversation_pp_1);
Helper.loadGiF(context, status.getConversationAccounts().get(1), holder.conversation_pp_2);
Helper.loadGiF(context, status.getConversationAccounts().get(2), holder.conversation_pp_3);
} else if (status.getConversationAccounts().size() == 4) {
Helper.loadGiF(context, status.getConversationProfilePictureStatic().get(0), status.getConversationProfilePicture().get(0), holder.conversation_pp_1);
Helper.loadGiF(context, status.getConversationProfilePictureStatic().get(1), status.getConversationProfilePicture().get(1), holder.conversation_pp_2);
Helper.loadGiF(context, status.getConversationProfilePictureStatic().get(2), status.getConversationProfilePicture().get(2), holder.conversation_pp_3);
} else if (status.getConversationProfilePicture().size() == 4) {
holder.conversation_pp_1.setVisibility(View.VISIBLE);
holder.conversation_pp_2.setVisibility(View.VISIBLE);
holder.conversation_pp_3.setVisibility(View.VISIBLE);
holder.conversation_pp_4.setVisibility(View.VISIBLE);
holder.conversation_pp_2_container.setVisibility(View.VISIBLE);
holder.conversation_pp_3_container.setVisibility(View.VISIBLE);
Helper.loadGiF(context, status.getConversationAccounts().get(0), holder.conversation_pp_1);
Helper.loadGiF(context, status.getConversationAccounts().get(1), holder.conversation_pp_2);
Helper.loadGiF(context, status.getConversationAccounts().get(2), holder.conversation_pp_3);
Helper.loadGiF(context, status.getConversationAccounts().get(3), holder.conversation_pp_4);
Helper.loadGiF(context, status.getConversationProfilePictureStatic().get(0), status.getConversationProfilePicture().get(0), holder.conversation_pp_1);
Helper.loadGiF(context, status.getConversationProfilePictureStatic().get(1), status.getConversationProfilePicture().get(1), holder.conversation_pp_2);
Helper.loadGiF(context, status.getConversationProfilePictureStatic().get(2), status.getConversationProfilePicture().get(2), holder.conversation_pp_3);
Helper.loadGiF(context, status.getConversationProfilePictureStatic().get(3), status.getConversationProfilePicture().get(3), holder.conversation_pp_4);
}
}

View File

@ -76,7 +76,7 @@ public class SuggestionsAdapter extends RecyclerView.Adapter {
holder.suggestion_image.setVisibility(View.GONE);
}else{
holder.suggestion_content.setText(suggestion.getContent());
Helper.loadGiF(context, suggestion.getImageUrl(), holder.suggestion_image);
Helper.loadGiF(context, suggestion.getImageUrl(), suggestion.getImageUrl(), holder.suggestion_image);
}
}

View File

@ -503,12 +503,16 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
List<Status> statusesConversations = new ArrayList<>();
if( conversations != null) {
for (Conversation conversation : conversations) {
Status status = conversation.getLast_status();
if (status != null) {
status.setConversationId(conversation.getId());
List<Account> ppConversation = new ArrayList<>(conversation.getAccounts());
status.setConversationAccounts(ppConversation);
app.fedilab.android.client.Entities.Status status = conversation.getLast_status();
List<String> ppConversationStatic = new ArrayList<>();
List<String> ppConversation = new ArrayList<>();
for (Account account : conversation.getAccounts()) {
ppConversationStatic.add(account.getAvatar_static());
ppConversation.add(account.getAvatar());
}
status.setConversationProfilePicture(ppConversation);
status.setConversationProfilePictureStatic(ppConversationStatic);
status.setConversationId(conversation.getId());
statusesConversations.add(status);
}
}

View File

@ -1623,7 +1623,7 @@ public class Helper {
* @param account Account for the profile picture
*/
public static void loadPictureIcon(final Activity activity, Account account, final ImageView imageView){
loadGiF(activity,account, imageView);
loadGiF(activity,account.getAvatar_static(), account.getAvatar(), imageView);
}
@ -2016,7 +2016,7 @@ public class Helper {
account.makeAccountNameEmoji(activity, ((BaseMainActivity)activity), account);
username.setText(String.format("@%s",account.getUsername() + "@" + account.getInstance()));
displayedName.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
loadGiF(activity, account, profilePicture);
loadGiF(activity, account.getAvatar_static(), account.getAvatar(), profilePicture);
String urlHeader = account.getHeader();
if( urlHeader.startsWith("/") ){
urlHeader = Helper.getLiveInstanceWithProtocol(activity) + account.getHeader();
@ -3106,19 +3106,22 @@ public class Helper {
return String.format(Locale.getDefault(), "%s:%s",strMin,strSec);
}
public static void loadGiF(final Context context, String url, final ImageView imageView){
public static void loadGiF(final Context context, String urlStatic, String url, final ImageView imageView){
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean disableGif = sharedpreferences.getBoolean(SET_DISABLE_GIF, false);
if( url == null){
url = urlStatic;
}
if (context instanceof FragmentActivity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && ((FragmentActivity) context).isDestroyed()) {
return;
}
}
if( url != null && url.startsWith("/")){
if( urlStatic != null && urlStatic.startsWith("/")){
url = Helper.getLiveInstanceWithProtocol(context) + url;
urlStatic = Helper.getLiveInstanceWithProtocol(context) + urlStatic;
}
if( url == null || url.equals("null")|| url.equals("false") || url.contains("missing.png") || url.contains(".svg")) {
if( urlStatic == null || urlStatic.equals("null")|| urlStatic.equals("false") || urlStatic.contains("missing.png") || urlStatic.contains(".svg")) {
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
try {
Glide.with(imageView.getContext())
@ -3148,109 +3151,27 @@ public class Helper {
return;
}
}
if( url != null) {
if (!disableGif && url.endsWith(".gif")) {
try {
Glide.with(imageView.getContext())
.asGif()
.load(url)
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
.into(imageView);
} catch (Exception ignored) {
}
} else {
try {
Glide.with(context)
.asBitmap()
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
.load(url)
.into(imageView);
} catch (Exception ignored) {
}
if (!disableGif && url.endsWith(".gif")) {
try {
Glide.with(imageView.getContext())
.asGif()
.load(url)
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
.into(imageView);
} catch (Exception ignored) {
}
} else {
try {
Glide.with(context)
.asBitmap()
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
.load(urlStatic)
.into(imageView);
} catch (Exception ignored) {
}
}
}
public static void loadGiF(final Context context, Account account, final ImageView imageView){
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean disableGif = sharedpreferences.getBoolean(SET_DISABLE_GIF, false);
if ( account == null){
return;
}
String url;
if( !disableGif){
url = account.getAvatar();
}else{
url = account.getAvatar_static();
if( url == null){
url = account.getAvatar();
}
}
if (context instanceof FragmentActivity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && ((FragmentActivity) context).isDestroyed()) {
return;
}
}
if( url != null && url.startsWith("/")){
url = Helper.getLiveInstanceWithProtocol(context) + url;
}
if( url == null || url.equals("null")|| url.equals("false") || url.contains("missing.png") || url.contains(".svg")) {
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
try {
Glide.with(imageView.getContext())
.load(R.drawable.missing)
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
.into(imageView);
} catch (Exception ignored) {
}
return;
}else if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE){
try {
Glide.with(imageView.getContext())
.load(R.drawable.missing_peertube)
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
.into(imageView);
} catch (Exception ignored) {
}
return;
}else if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA){
try {
Glide.with(imageView.getContext())
.load(R.drawable.gnu_default_avatar)
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
.into(imageView);
} catch (Exception ignored) {
}
return;
}
}
if( url != null) {
if (!disableGif && url.endsWith(".gif")) {
try {
Glide.with(imageView.getContext())
.asGif()
.load(url)
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
.into(imageView);
} catch (Exception ignored) {
}
} else {
try {
Glide.with(context)
.asBitmap()
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
.load(url)
.into(imageView);
} catch (Exception ignored) {
}
}
}
}
/**
* Manage URLs to open (built-in or external app)
* @param context Context