This commit is contained in:
NudeDude 2019-03-28 09:37:03 +01:00
parent 4f08306d4b
commit 77d47e2984

View File

@ -50,12 +50,14 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
private long homeId; private long homeId;
private int highlight; private int highlight;
private boolean imgEnabled; private boolean imgEnabled;
private boolean isHome = false; private boolean isHome;
private boolean isFollowing = false; private boolean isFollowing;
private boolean isFollowed = false; private boolean isFollowed;
private boolean isBlocked = false; private boolean isBlocked;
private boolean isMuted = false; private boolean isMuted;
private boolean canDm = false; private boolean canDm;
/** /**
* @param context Context to Activity * @param context Context to Activity
* @see UserProfile * @see UserProfile
@ -81,6 +83,7 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
homeFav = (TimelineAdapter) profileFavors.getAdapter(); homeFav = (TimelineAdapter) profileFavors.getAdapter();
} }
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
if (ui.get() != null) { if (ui.get() != null) {
@ -93,6 +96,7 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
} }
} }
@Override @Override
protected Void doInBackground(Long... args) { protected Void doInBackground(Long... args) {
final long UID = args[0]; final long UID = args[0];
@ -205,6 +209,7 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
return null; return null;
} }
@Override @Override
protected void onProgressUpdate(Void... v) { protected void onProgressUpdate(Void... v) {
if (ui.get() == null) return; if (ui.get() == null) return;
@ -238,6 +243,8 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
date_ico.setVisibility(View.VISIBLE); date_ico.setVisibility(View.VISIBLE);
if (user.isVerified()) if (user.isVerified())
ui.get().findViewById(R.id.profile_verify).setVisibility(View.VISIBLE); ui.get().findViewById(R.id.profile_verify).setVisibility(View.VISIBLE);
if (isFollowed)
followback.setVisibility(View.VISIBLE);
} }
Spanned bio = Tagger.makeText(user.getBio(), highlight, ui.get()); Spanned bio = Tagger.makeText(user.getBio(), highlight, ui.get());
@ -262,17 +269,13 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
txtLink.setText(""); txtLink.setText("");
link_ico.setVisibility(View.GONE); link_ico.setVisibility(View.GONE);
} }
if (isFollowed)
followback.setVisibility(View.VISIBLE);
if (imgEnabled) { if (imgEnabled) {
String link = user.getImageLink() + "_bigger"; String link = user.getImageLink() + "_bigger";
Picasso.get().load(link).into(profile); Picasso.get().load(link).into(profile);
} }
if (user.isLocked()) if (user.isLocked()) {
locked.setVisibility(View.VISIBLE); locked.setVisibility(View.VISIBLE);
else { } else {
txtFollowing.setOnClickListener(new View.OnClickListener() { txtFollowing.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -299,12 +302,24 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
} }
}); });
ui.get().setTweetCount(user.getTweetCount(), user.getFavorCount()); ui.get().setTweetCount(user.getTweetCount(), user.getFavorCount());
if (!tweets.isEmpty()) {
SwipeRefreshLayout homeReload = ui.get().findViewById(R.id.hometweets);
homeTl.setData(tweets);
homeTl.notifyDataSetChanged();
homeReload.setRefreshing(false);
}
if (!favors.isEmpty()) {
SwipeRefreshLayout favReload = ui.get().findViewById(R.id.homefavorits);
homeFav.setData(favors);
homeFav.notifyDataSetChanged();
favReload.setRefreshing(false);
}
} }
@Override @Override
protected void onPostExecute(final Void v) { protected void onPostExecute(final Void v) {
SwipeRefreshLayout homeReload, favReload;
if (ui.get() == null) return; if (ui.get() == null) return;
if (!isHome) { if (!isHome) {
@ -314,37 +329,28 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
switch (mode) { switch (mode) {
case LDR_PROFILE: case LDR_PROFILE:
homeReload = ui.get().findViewById(R.id.hometweets); if (tweets.isEmpty()) {
favReload = ui.get().findViewById(R.id.homefavorits); SwipeRefreshLayout homeReload = ui.get().findViewById(R.id.hometweets);
if (!tweets.isEmpty()) { homeReload.setRefreshing(false);
homeTl.setData(tweets);
homeTl.notifyDataSetChanged();
} }
homeReload.setRefreshing(false); if (favors.isEmpty()) {
SwipeRefreshLayout favReload = ui.get().findViewById(R.id.homefavorits);
if (!favors.isEmpty()) { favReload.setRefreshing(false);
homeFav.setData(favors);
homeFav.notifyDataSetChanged();
} }
favReload.setRefreshing(false);
break; break;
case GET_TWEETS: case GET_TWEETS:
homeReload = ui.get().findViewById(R.id.hometweets); if (tweets.isEmpty()) {
if (!tweets.isEmpty()) { SwipeRefreshLayout homeReload = ui.get().findViewById(R.id.hometweets);
homeTl.setData(tweets); homeReload.setRefreshing(false);
homeTl.notifyDataSetChanged();
} }
homeReload.setRefreshing(false);
break; break;
case GET_FAVORS: case GET_FAVORS:
favReload = ui.get().findViewById(R.id.homefavorits); if (favors.isEmpty()) {
if (!favors.isEmpty()) { SwipeRefreshLayout favReload = ui.get().findViewById(R.id.homefavorits);
homeFav.setData(favors); favReload.setRefreshing(false);
homeFav.notifyDataSetChanged();
} }
favReload.setRefreshing(false);
break; break;
case ACTION_FOLLOW: case ACTION_FOLLOW:
@ -377,9 +383,9 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
ui.get().finish(); ui.get().finish();
} }
} }
} }
@Override @Override
protected void onCancelled() { protected void onCancelled() {
if (ui.get() != null) { if (ui.get() != null) {