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 txtBio = ui.get().findViewById(R.id.bio);
TextView txtLocation = ui.get().findViewById(R.id.location); TextView txtLocation = ui.get().findViewById(R.id.location);
TextView txtLink = ui.get().findViewById(R.id.links); TextView txtLink = ui.get().findViewById(R.id.links);
TextView txtFollowing = ui.get().findViewById(R.id.following); TextView txtFollowing = ui.get().findViewById(R.id.following);
TextView txtFollower = ui.get().findViewById(R.id.follower); TextView txtFollower = ui.get().findViewById(R.id.follower);
ImageView profile = ui.get().findViewById(R.id.profile_img); ImageView profile = ui.get().findViewById(R.id.profile_img);
View location_ico = ui.get().findViewById(R.id.loction_ico); View location_ico = ui.get().findViewById(R.id.loction_ico);
View link_ico = ui.get().findViewById(R.id.links_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) { if (mode == Mode.LDR_PROFILE) {
TextView txtCreated = ui.get().findViewById(R.id.profile_date); View profile_head = ui.get().findViewById(R.id.profile_header);
String date = sdf.format(new Date(user.getCreatedAt())); if (profile_head.getVisibility() != VISIBLE) {
txtCreated.setText(date); profile_head.setVisibility(VISIBLE);
if (user.isVerified()) View verified = ui.get().findViewById(R.id.profile_verify);
verified.setVisibility(VISIBLE); View followback = ui.get().findViewById(R.id.followback);
if (isFollowed) View locked = ui.get().findViewById(R.id.profile_locked);
followback.setVisibility(VISIBLE); TextView txtCreated = ui.get().findViewById(R.id.profile_date);
if (user.isLocked()) { String date = sdf.format(new Date(user.getCreatedAt()));
locked.setVisibility(VISIBLE); txtCreated.setText(date);
} else {
if(!txtFollowing.isClickable()) { if (user.isVerified())
verified.setVisibility(VISIBLE);
if (isFollowed)
followback.setVisibility(VISIBLE);
if (user.isLocked()) {
locked.setVisibility(VISIBLE);
} else {
txtFollowing.setOnClickListener(new View.OnClickListener() { txtFollowing.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -285,8 +285,6 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
ui.get().startActivity(following); ui.get().startActivity(following);
} }
}); });
}
if(!txtFollower.isClickable()) {
txtFollower.setOnClickListener(new View.OnClickListener() { txtFollower.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -296,8 +294,6 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
ui.get().startActivity(follower); ui.get().startActivity(follower);
} }
}); });
}
if(!profile.isClickable()) {
profile.setOnClickListener(new View.OnClickListener() { profile.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -339,9 +335,6 @@ public class ProfileLoader extends AsyncTask<Long, Void, Void> {
Picasso.get().load(link).into(profile); Picasso.get().load(link).into(profile);
} }
if(profile_head.getVisibility() != VISIBLE)
profile_head.setVisibility(VISIBLE);
ui.get().setTweetCount(user.getTweetCount(), user.getFavorCount()); 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) { protected Void doInBackground(Long... data) {
final long TWEETID = data[0]; final long TWEETID = data[0];
long sinceId = TWEETID; long sinceId = TWEETID;
boolean updateStatus = false;
try { try {
switch (mode) { switch (mode) {
case LOAD: case LOAD:
@ -101,22 +102,24 @@ public class StatusLoader extends AsyncTask<Long, Void, Void> {
if(tweet != null) { if(tweet != null) {
answers = database.getAnswers(TWEETID); answers = database.getAnswers(TWEETID);
publishProgress(); publishProgress();
updateStatus = true;
} }
case ANS: case ANS:
tweet = mTwitter.getStatus(TWEETID); tweet = mTwitter.getStatus(TWEETID);
boolean storeStatus = database.containStatus(TWEETID); if (!updateStatus)
updateStatus = database.containStatus(TWEETID);
if (mode == Mode.ANS || toggleAns) { if (mode == Mode.ANS || toggleAns) {
if (answerAdapter.getItemCount() > 0) if (answerAdapter.getItemCount() > 0)
sinceId = answerAdapter.getItemId(0); sinceId = answerAdapter.getItemId(0);
answers = mTwitter.getAnswers(tweet.getUser().getScreenname(), TWEETID, sinceId); answers = mTwitter.getAnswers(tweet.getUser().getScreenname(), TWEETID, sinceId);
if (storeStatus && !answers.isEmpty()) if (updateStatus && !answers.isEmpty())
database.storeReplies(answers); database.storeReplies(answers);
answers.addAll(answerAdapter.getData()); answers.addAll(answerAdapter.getData());
} }
publishProgress(); publishProgress();
if(storeStatus) if (updateStatus)
database.updateStatus(tweet); database.updateStatus(tweet);
break; break;
@ -170,43 +173,6 @@ public class StatusLoader extends AsyncTask<Long, Void, Void> {
answerAdapter.notifyDataSetChanged(); 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 username = ui.get().findViewById(R.id.usernamedetail);
TextView scrName = ui.get().findViewById(R.id.scrnamedetail); TextView scrName = ui.get().findViewById(R.id.scrnamedetail);
TextView replyName = ui.get().findViewById(R.id.answer_reference_detail); 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 profile_img = ui.get().findViewById(R.id.profileimage_detail);
ImageView retweetButton = ui.get().findViewById(R.id.rt_button_detail); ImageView retweetButton = ui.get().findViewById(R.id.rt_button_detail);
ImageView favoriteButton = ui.get().findViewById(R.id.fav_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.setText(tweet.getUser().getUsername());
username.setTextColor(font_color); 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) { if (toggleImg) {
Picasso.get().load(tweet.getUser().getImageLink() + "_bigger").into(profile_img); 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) { if(tweet.getUser().getId() == homeId) {
ui.get().enableDelete(); ui.get().enableDelete();
} }
if(tweet_header.getVisibility() != VISIBLE)
tweet_header.setVisibility(VISIBLE);
if(tweet_footer.getVisibility() != VISIBLE)
tweet_footer.setVisibility(VISIBLE);
} }