code cleanup

This commit is contained in:
NudeDude 2019-04-13 11:11:06 +02:00
parent 82489e2aba
commit 33962cea93
2 changed files with 73 additions and 82 deletions

View File

@ -251,31 +251,31 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
TextView txtBio = ui.get().findViewById(R.id.bio);
TextView txtLocation = ui.get().findViewById(R.id.location);
TextView txtLink = ui.get().findViewById(R.id.links);
TextView txtFollowing = ui.get().findViewById(R.id.following);
TextView txtFollower = ui.get().findViewById(R.id.follower);
ImageView profile = ui.get().findViewById(R.id.profile_img);
View location_ico = ui.get().findViewById(R.id.loction_ico);
View link_ico = ui.get().findViewById(R.id.links_ico);
View followback = ui.get().findViewById(R.id.followback);
View verified = ui.get().findViewById(R.id.profile_verify);
View locked = ui.get().findViewById(R.id.profile_locked);
View profile_head = ui.get().findViewById(R.id.profile_header);
if (mode == Mode.LDR_PROFILE) {
TextView txtCreated = ui.get().findViewById(R.id.profile_date);
String date = sdf.format(new Date(user.getCreatedAt()));
txtCreated.setText(date);
View profile_head = ui.get().findViewById(R.id.profile_header);
if (profile_head.getVisibility() != VISIBLE) {
profile_head.setVisibility(VISIBLE);
if (user.isVerified())
verified.setVisibility(VISIBLE);
if (isFollowed)
followback.setVisibility(VISIBLE);
if (user.isLocked()) {
locked.setVisibility(VISIBLE);
} else {
if(!txtFollowing.isClickable()) {
View verified = ui.get().findViewById(R.id.profile_verify);
View followback = ui.get().findViewById(R.id.followback);
View locked = ui.get().findViewById(R.id.profile_locked);
TextView txtCreated = ui.get().findViewById(R.id.profile_date);
String date = sdf.format(new Date(user.getCreatedAt()));
txtCreated.setText(date);
if (user.isVerified())
verified.setVisibility(VISIBLE);
if (isFollowed)
followback.setVisibility(VISIBLE);
if (user.isLocked()) {
locked.setVisibility(VISIBLE);
} else {
txtFollowing.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -285,8 +285,6 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
ui.get().startActivity(following);
}
});
}
if(!txtFollower.isClickable()) {
txtFollower.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -296,8 +294,6 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
ui.get().startActivity(follower);
}
});
}
if(!profile.isClickable()) {
profile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -339,9 +335,6 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
Picasso.get().load(link).into(profile);
}
if(profile_head.getVisibility() != VISIBLE)
profile_head.setVisibility(VISIBLE);
ui.get().setTweetCount(user.getTweetCount(), user.getFavorCount());
}

View File

@ -94,6 +94,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Void> {
protected Void doInBackground(Long... data) {
final long TWEETID = data[0];
long sinceId = TWEETID;
boolean updateStatus = false;
try {
switch (mode) {
case LOAD:
@ -101,22 +102,24 @@ public class StatusLoader extends AsyncTask<Long, Void, Void> {
if(tweet != null) {
answers = database.getAnswers(TWEETID);
publishProgress();
updateStatus = true;
}
case ANS:
tweet = mTwitter.getStatus(TWEETID);
boolean storeStatus = database.containStatus(TWEETID);
if (!updateStatus)
updateStatus = database.containStatus(TWEETID);
if (mode == Mode.ANS || toggleAns) {
if (answerAdapter.getItemCount() > 0)
sinceId = answerAdapter.getItemId(0);
answers = mTwitter.getAnswers(tweet.getUser().getScreenname(), TWEETID, sinceId);
if (storeStatus && !answers.isEmpty())
if (updateStatus && !answers.isEmpty())
database.storeReplies(answers);
answers.addAll(answerAdapter.getData());
}
publishProgress();
if(storeStatus)
if (updateStatus)
database.updateStatus(tweet);
break;
@ -170,43 +173,6 @@ public class StatusLoader extends AsyncTask<Long, Void, Void> {
answerAdapter.notifyDataSetChanged();
}
if(mode == Mode.LOAD) {
TextView tweetText = ui.get().findViewById(R.id.tweet_detailed);
TextView tweetDate = ui.get().findViewById(R.id.timedetail);
TextView tweet_api = ui.get().findViewById(R.id.used_api);
View tweet_verify = ui.get().findViewById(R.id.tweet_verify);
View tweet_locked = ui.get().findViewById(R.id.tweet_locked);
Spannable sTweet = Tagger.makeText(tweet.getTweet(), highlight, ui.get());
tweetText.setMovementMethod(LinkMovementMethod.getInstance());
tweetText.setText(sTweet);
tweetText.setTextColor(font_color);
tweetDate.setText(sdf.format(tweet.getTime()));
tweetDate.setTextColor(font_color);
tweet_api.setText(R.string.sent_from);
tweet_api.append(tweet.getSource());
tweet_api.setTextColor(font_color);
if (tweet.getUser().isVerified()) {
tweet_verify.setVisibility(VISIBLE);
}
if (tweet.getUser().isLocked()) {
tweet_locked.setVisibility(VISIBLE);
}
if (tweet.getMediaLinks() != null && tweet.getMediaLinks().length > 0) {
View mediaButton = ui.get().findViewById(R.id.image_attach);
mediaButton.setVisibility(VISIBLE);
if(!mediaButton.isClickable()) {
mediaButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ui.get().imageClick(tweet.getMediaLinks());
}
});
}
}
}
TextView username = ui.get().findViewById(R.id.usernamedetail);
TextView scrName = ui.get().findViewById(R.id.scrnamedetail);
TextView replyName = ui.get().findViewById(R.id.answer_reference_detail);
@ -216,8 +182,56 @@ public class StatusLoader extends AsyncTask<Long, Void, Void> {
ImageView profile_img = ui.get().findViewById(R.id.profileimage_detail);
ImageView retweetButton = ui.get().findViewById(R.id.rt_button_detail);
ImageView favoriteButton = ui.get().findViewById(R.id.fav_button_detail);
View tweet_header = ui.get().findViewById(R.id.tweet_head);
View tweet_footer = ui.get().findViewById(R.id.tweet_foot);
if(mode == Mode.LOAD) {
View tweet_header = ui.get().findViewById(R.id.tweet_head);
if (tweet_header.getVisibility() != VISIBLE) {
TextView tweetText = ui.get().findViewById(R.id.tweet_detailed);
TextView tweetDate = ui.get().findViewById(R.id.timedetail);
TextView tweet_api = ui.get().findViewById(R.id.used_api);
View tweet_verify = ui.get().findViewById(R.id.tweet_verify);
View tweet_locked = ui.get().findViewById(R.id.tweet_locked);
View tweet_footer = ui.get().findViewById(R.id.tweet_foot);
Spannable sTweet = Tagger.makeText(tweet.getTweet(), highlight, ui.get());
tweetText.setMovementMethod(LinkMovementMethod.getInstance());
tweetText.setText(sTweet);
tweetText.setTextColor(font_color);
tweetDate.setText(sdf.format(tweet.getTime()));
tweetDate.setTextColor(font_color);
tweet_api.setText(R.string.sent_from);
tweet_api.append(tweet.getSource());
tweet_api.setTextColor(font_color);
if (tweet.getUser().isVerified()) {
tweet_verify.setVisibility(VISIBLE);
}
if (tweet.getUser().isLocked()) {
tweet_locked.setVisibility(VISIBLE);
}
if (tweet.getMediaLinks() != null && tweet.getMediaLinks().length > 0) {
View mediaButton = ui.get().findViewById(R.id.image_attach);
mediaButton.setVisibility(VISIBLE);
mediaButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ui.get().imageClick(tweet.getMediaLinks());
}
});
}
profile_img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent profile = new Intent(ui.get(), UserProfile.class);
profile.putExtra("userID", tweet.getUser().getId());
profile.putExtra("username", tweet.getUser().getScreenname());
ui.get().startActivity(profile);
}
});
tweet_header.setVisibility(VISIBLE);
tweet_footer.setVisibility(VISIBLE);
}
}
username.setText(tweet.getUser().getUsername());
username.setTextColor(font_color);
@ -247,18 +261,6 @@ public class StatusLoader extends AsyncTask<Long, Void, Void> {
}
}
if(!profile_img.isClickable()) {
profile_img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent profile = new Intent(ui.get(), UserProfile.class);
profile.putExtra("userID", tweet.getUser().getId());
profile.putExtra("username", tweet.getUser().getScreenname());
ui.get().startActivity(profile);
}
});
}
if (toggleImg) {
Picasso.get().load(tweet.getUser().getImageLink() + "_bigger").into(profile_img);
}
@ -275,10 +277,6 @@ public class StatusLoader extends AsyncTask<Long, Void, Void> {
if(tweet.getUser().getId() == homeId) {
ui.get().enableDelete();
}
if(tweet_header.getVisibility() != VISIBLE)
tweet_header.setVisibility(VISIBLE);
if(tweet_footer.getVisibility() != VISIBLE)
tweet_footer.setVisibility(VISIBLE);
}