reformat project
This commit is contained in:
parent
6ab2c57e3c
commit
5e53678fb2
|
@ -289,17 +289,17 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||||
if (parent.getId() == R.id.tl_list) {
|
if (parent.getId() == R.id.tl_list) {
|
||||||
if (timelineAdapter != null && !timelineReload.isRefreshing()) {
|
if (timelineAdapter != null && !timelineReload.isRefreshing()) {
|
||||||
Tweet tweet = timelineAdapter.getData().get(position);
|
Tweet tweet = timelineAdapter.getData().get(position);
|
||||||
if (tweet.embedded != null)
|
if (tweet.getEmbeddedTweet() != null)
|
||||||
tweet = tweet.embedded;
|
tweet = tweet.getEmbeddedTweet();
|
||||||
Intent intent = new Intent(this, TweetDetail.class);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
intent.putExtra("tweetID", tweet.tweetID);
|
intent.putExtra("tweetID", tweet.getId());
|
||||||
intent.putExtra("userID", tweet.user.userID);
|
intent.putExtra("userID", tweet.getUser().getId());
|
||||||
intent.putExtra("username", tweet.user.screenname);
|
intent.putExtra("username", tweet.getUser().getScreenname());
|
||||||
startActivityForResult(intent, TWEET);
|
startActivityForResult(intent, TWEET);
|
||||||
}
|
}
|
||||||
} else if (parent.getId() == R.id.tr_list) {
|
} else if (parent.getId() == R.id.tr_list) {
|
||||||
if (trendsAdapter != null && !trendReload.isRefreshing()) {
|
if (trendsAdapter != null && !trendReload.isRefreshing()) {
|
||||||
String search = trendsAdapter.getData().get(position).trend;
|
String search = trendsAdapter.getData().get(position).getName();
|
||||||
Intent intent = new Intent(this, SearchPage.class);
|
Intent intent = new Intent(this, SearchPage.class);
|
||||||
if (!search.startsWith("#"))
|
if (!search.startsWith("#"))
|
||||||
search = '\"' + search + '\"';
|
search = '\"' + search + '\"';
|
||||||
|
@ -309,12 +309,12 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||||
} else if (parent.getId() == R.id.m_list) {
|
} else if (parent.getId() == R.id.m_list) {
|
||||||
if (mentionAdapter != null && !mentionReload.isRefreshing()) {
|
if (mentionAdapter != null && !mentionReload.isRefreshing()) {
|
||||||
Tweet tweet = mentionAdapter.getData().get(position);
|
Tweet tweet = mentionAdapter.getData().get(position);
|
||||||
if (tweet.embedded != null)
|
if (tweet.getEmbeddedTweet() != null)
|
||||||
tweet = tweet.embedded;
|
tweet = tweet.getEmbeddedTweet();
|
||||||
Intent intent = new Intent(this, TweetDetail.class);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
intent.putExtra("tweetID", tweet.tweetID);
|
intent.putExtra("tweetID", tweet.getId());
|
||||||
intent.putExtra("userID", tweet.user.userID);
|
intent.putExtra("userID", tweet.getUser().getId());
|
||||||
intent.putExtra("username", tweet.user.screenname);
|
intent.putExtra("username", tweet.getUser().getScreenname());
|
||||||
startActivityForResult(intent, TWEET);
|
startActivityForResult(intent, TWEET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageH
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int pos) {
|
public long getItemId(int pos) {
|
||||||
return messages.get(pos).messageId;
|
return messages.get(pos).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,20 +102,22 @@ public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageH
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull MessageHolder vh, int index) {
|
public void onBindViewHolder(@NonNull MessageHolder vh, int index) {
|
||||||
Message message = messages.get(index);
|
Message message = messages.get(index);
|
||||||
Spanned text = Tagger.makeText(message.message, highlight, mListener);
|
Spanned text = Tagger.makeText(message.getText(), highlight, mListener);
|
||||||
vh.message.setMovementMethod(LinkMovementMethod.getInstance());
|
vh.message.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
vh.message.setText(text);
|
vh.message.setText(text);
|
||||||
vh.username.setText(message.sender.username);
|
vh.username.setText(message.getSender().getUsername());
|
||||||
vh.screenname.setText(message.sender.screenname);
|
vh.screenname.setText(message.getSender().getScreenname());
|
||||||
vh.createdAt.setText(stringTime(message.time));
|
vh.createdAt.setText(stringTime(message.getTime()));
|
||||||
|
|
||||||
vh.message.setTextColor(fontColor);
|
vh.message.setTextColor(fontColor);
|
||||||
vh.username.setTextColor(fontColor);
|
vh.username.setTextColor(fontColor);
|
||||||
vh.screenname.setTextColor(fontColor);
|
vh.screenname.setTextColor(fontColor);
|
||||||
vh.createdAt.setTextColor(fontColor);
|
vh.createdAt.setTextColor(fontColor);
|
||||||
|
|
||||||
if (loadImage)
|
if (loadImage) {
|
||||||
Picasso.get().load(message.sender.profileImg + "_mini").into(vh.profile_img);
|
String link = message.getSender().getImageLink() + "_mini";
|
||||||
|
Picasso.get().load(link).into(vh.profile_img);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class TimelineAdapter extends Adapter<TimelineAdapter.ItemHolder> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int pos) {
|
public long getItemId(int pos) {
|
||||||
return tweets.get(pos).tweetID;
|
return tweets.get(pos).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,22 +93,22 @@ public class TimelineAdapter extends Adapter<TimelineAdapter.ItemHolder> {
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ItemHolder vh, int index) {
|
public void onBindViewHolder(@NonNull ItemHolder vh, int index) {
|
||||||
Tweet tweet = tweets.get(index);
|
Tweet tweet = tweets.get(index);
|
||||||
String retweet = Integer.toString(tweet.retweet);
|
String retweet = Integer.toString(tweet.getRetweetCount());
|
||||||
String favorit = Integer.toString(tweet.favorit);
|
String favorit = Integer.toString(tweet.getFavorCount());
|
||||||
if (tweet.embedded != null) {
|
if (tweet.getEmbeddedTweet() != null) {
|
||||||
String retweeter = "RT " + tweet.user.screenname;
|
String retweeter = "RT " + tweet.getUser().getScreenname();
|
||||||
vh.retweeter.setText(retweeter);
|
vh.retweeter.setText(retweeter);
|
||||||
tweet = tweet.embedded;
|
tweet = tweet.getEmbeddedTweet();
|
||||||
} else {
|
} else {
|
||||||
vh.retweeter.setText("");
|
vh.retweeter.setText("");
|
||||||
}
|
}
|
||||||
Spanned text = Tagger.makeText(tweet.tweet, highlight);
|
Spanned text = Tagger.makeText(tweet.getText(), highlight);
|
||||||
vh.username.setText(tweet.user.username);
|
vh.username.setText(tweet.getUser().getUsername());
|
||||||
vh.screenname.setText(tweet.user.screenname);
|
vh.screenname.setText(tweet.getUser().getScreenname());
|
||||||
vh.tweet.setText(text);
|
vh.tweet.setText(text);
|
||||||
vh.retweet.setText(retweet);
|
vh.retweet.setText(retweet);
|
||||||
vh.favorite.setText(favorit);
|
vh.favorite.setText(favorit);
|
||||||
vh.time.setText(stringTime(tweet.time));
|
vh.time.setText(stringTime(tweet.getTime()));
|
||||||
|
|
||||||
vh.username.setTextColor(font_color);
|
vh.username.setTextColor(font_color);
|
||||||
vh.screenname.setTextColor(font_color);
|
vh.screenname.setTextColor(font_color);
|
||||||
|
@ -116,9 +116,9 @@ public class TimelineAdapter extends Adapter<TimelineAdapter.ItemHolder> {
|
||||||
vh.time.setTextColor(font_color);
|
vh.time.setTextColor(font_color);
|
||||||
|
|
||||||
if (img_ldr) {
|
if (img_ldr) {
|
||||||
Picasso.get().load(tweet.user.profileImg + "_mini").into(vh.profile);
|
Picasso.get().load(tweet.getUser().getImageLink() + "_mini").into(vh.profile);
|
||||||
}
|
}
|
||||||
if (tweet.user.isVerified) {
|
if (tweet.getUser().isVerified()) {
|
||||||
vh.verify.setVisibility(View.VISIBLE);
|
vh.verify.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
vh.verify.setVisibility(View.GONE);
|
vh.verify.setVisibility(View.GONE);
|
||||||
|
|
|
@ -68,8 +68,9 @@ public class TrendAdapter extends Adapter<TrendAdapter.ItemHolder> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ItemHolder vh, int index) {
|
public void onBindViewHolder(@NonNull ItemHolder vh, int index) {
|
||||||
String posStr = Integer.toString(trendList.get(index).position) + '.';
|
Trend trend = trendList.get(index);
|
||||||
vh.trends.setText(trendList.get(index).trend);
|
String posStr = Integer.toString(trend.getPosition()) + '.';
|
||||||
|
vh.trends.setText(trend.getName());
|
||||||
vh.pos.setText(posStr);
|
vh.pos.setText(posStr);
|
||||||
vh.trends.setTextColor(font_color);
|
vh.trends.setTextColor(font_color);
|
||||||
vh.pos.setTextColor(font_color);
|
vh.pos.setTextColor(font_color);
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class UserAdapter extends Adapter<UserAdapter.ItemHolder> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int pos) {
|
public long getItemId(int pos) {
|
||||||
return mUser.get(pos).userID;
|
return mUser.get(pos).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,22 +84,22 @@ public class UserAdapter extends Adapter<UserAdapter.ItemHolder> {
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ItemHolder vh, int index) {
|
public void onBindViewHolder(@NonNull ItemHolder vh, int index) {
|
||||||
TwitterUser user = mUser.get(index);
|
TwitterUser user = mUser.get(index);
|
||||||
vh.screenname.setText(user.screenname);
|
vh.screenname.setText(user.getScreenname());
|
||||||
vh.username.setText(user.username);
|
vh.username.setText(user.getUsername());
|
||||||
|
|
||||||
vh.screenname.setTextColor(font_color);
|
vh.screenname.setTextColor(font_color);
|
||||||
vh.username.setTextColor(font_color);
|
vh.username.setTextColor(font_color);
|
||||||
|
|
||||||
|
|
||||||
if (loadImage) {
|
if (loadImage) {
|
||||||
Picasso.get().load(user.profileImg + "_mini").into(vh.profileImg);
|
Picasso.get().load(user.getImageLink() + "_mini").into(vh.profileImg);
|
||||||
}
|
}
|
||||||
if (user.isVerified) {
|
if (user.isVerified()) {
|
||||||
vh.verifyIco.setVisibility(View.VISIBLE);
|
vh.verifyIco.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
vh.verifyIco.setVisibility(View.GONE);
|
vh.verifyIco.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if (user.isLocked) {
|
if (user.isLocked()) {
|
||||||
vh.lockIco.setVisibility(View.VISIBLE);
|
vh.lockIco.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
vh.lockIco.setVisibility(View.GONE);
|
vh.lockIco.setVisibility(View.GONE);
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class ProfileLoader extends AsyncTask<Long, Long, Long> {
|
||||||
mTwitter.muteAction(UID, isMuted);
|
mTwitter.muteAction(UID, isMuted);
|
||||||
publishProgress(GET_USER);
|
publishProgress(GET_USER);
|
||||||
} else {
|
} else {
|
||||||
if (!user.isLocked || isFollowing) {
|
if (!user.isLocked() || isFollowing) {
|
||||||
if ((MODE == GET_TWEETS || homeTl.getItemCount() == 0)) {
|
if ((MODE == GET_TWEETS || homeTl.getItemCount() == 0)) {
|
||||||
if (homeTl.getItemCount() > 0)
|
if (homeTl.getItemCount() > 0)
|
||||||
sinceId = homeTl.getItemId(0);
|
sinceId = homeTl.getItemId(0);
|
||||||
|
@ -195,14 +195,14 @@ public class ProfileLoader extends AsyncTask<Long, Long, Long> {
|
||||||
View link_ico = ui.get().findViewById(R.id.links_ico);
|
View link_ico = ui.get().findViewById(R.id.links_ico);
|
||||||
View date_ico = ui.get().findViewById(R.id.date_ico);
|
View date_ico = ui.get().findViewById(R.id.date_ico);
|
||||||
|
|
||||||
String follower = Integer.toString(user.follower);
|
String follower = Integer.toString(user.getFollower());
|
||||||
String following = Integer.toString(user.following);
|
String following = Integer.toString(user.getFollowing());
|
||||||
String date = sdf.format(new Date(user.created));
|
String date = sdf.format(new Date(user.getCreatedAt()));
|
||||||
Spanned bio = Tagger.makeText(user.bio, highlight, ui.get());
|
Spanned bio = Tagger.makeText(user.getBio(), highlight, ui.get());
|
||||||
txtBio.setMovementMethod(LinkMovementMethod.getInstance());
|
txtBio.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
txtBio.setText(bio);
|
txtBio.setText(bio);
|
||||||
txtUser.setText(user.username);
|
txtUser.setText(user.getUsername());
|
||||||
txtScrName.setText(user.screenname);
|
txtScrName.setText(user.getScreenname());
|
||||||
txtFollower.setText(follower);
|
txtFollower.setText(follower);
|
||||||
txtFollowing.setText(following);
|
txtFollowing.setText(following);
|
||||||
txtCreated.setText(date);
|
txtCreated.setText(date);
|
||||||
|
@ -211,31 +211,32 @@ public class ProfileLoader extends AsyncTask<Long, Long, Long> {
|
||||||
following_ico.setVisibility(View.VISIBLE);
|
following_ico.setVisibility(View.VISIBLE);
|
||||||
date_ico.setVisibility(View.VISIBLE);
|
date_ico.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (user.location != null && !user.location.isEmpty()) {
|
if (user.getLocation() != null && !user.getLocation().isEmpty()) {
|
||||||
txtLocation.setText(user.location);
|
txtLocation.setText(user.getLocation());
|
||||||
location_ico.setVisibility(View.VISIBLE);
|
location_ico.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
if (user.link != null && !user.link.isEmpty()) {
|
if (user.getLink() != null && !user.getLink().isEmpty()) {
|
||||||
txtLink.setText(user.link);
|
txtLink.setText(user.getLink());
|
||||||
link_ico.setVisibility(View.VISIBLE);
|
link_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) {
|
if (isFollowed) {
|
||||||
ui.get().findViewById(R.id.followback).setVisibility(View.VISIBLE);
|
ui.get().findViewById(R.id.followback).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
if (imgEnabled) {
|
if (imgEnabled) {
|
||||||
Picasso.get().load(user.profileImg + "_bigger").into(profile);
|
String link = user.getImageLink() + "_bigger";
|
||||||
|
Picasso.get().load(link).into(profile);
|
||||||
}
|
}
|
||||||
if (user.isLocked) {
|
if (user.isLocked()) {
|
||||||
ui.get().findViewById(R.id.profile_locked).setVisibility(View.VISIBLE);
|
ui.get().findViewById(R.id.profile_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) {
|
||||||
Intent following = new Intent(ui.get(), UserDetail.class);
|
Intent following = new Intent(ui.get(), UserDetail.class);
|
||||||
following.putExtra("userID", user.userID);
|
following.putExtra("userID", user.getId());
|
||||||
following.putExtra("mode", 0);
|
following.putExtra("mode", 0);
|
||||||
ui.get().startActivity(following);
|
ui.get().startActivity(following);
|
||||||
}
|
}
|
||||||
|
@ -244,7 +245,7 @@ public class ProfileLoader extends AsyncTask<Long, Long, Long> {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent follower = new Intent(ui.get(), UserDetail.class);
|
Intent follower = new Intent(ui.get(), UserDetail.class);
|
||||||
follower.putExtra("userID", user.userID);
|
follower.putExtra("userID", user.getId());
|
||||||
follower.putExtra("mode", 1);
|
follower.putExtra("mode", 1);
|
||||||
ui.get().startActivity(follower);
|
ui.get().startActivity(follower);
|
||||||
}
|
}
|
||||||
|
@ -253,7 +254,7 @@ public class ProfileLoader extends AsyncTask<Long, Long, Long> {
|
||||||
profile.setOnClickListener(new View.OnClickListener() {
|
profile.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
ui.get().imageClick(user.profileImg);
|
ui.get().imageClick(user.getImageLink());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||||
tweet = mTwitter.getStatus(TWEETID);
|
tweet = mTwitter.getStatus(TWEETID);
|
||||||
if (answerAdapter.getItemCount() > 0)
|
if (answerAdapter.getItemCount() > 0)
|
||||||
sinceId = answerAdapter.getItemId(0);
|
sinceId = answerAdapter.getItemId(0);
|
||||||
answers = mTwitter.getAnswers(tweet.user.screenname, TWEETID, sinceId);
|
answers = mTwitter.getAnswers(tweet.getUser().getScreenname(), TWEETID, sinceId);
|
||||||
publishProgress();
|
publishProgress();
|
||||||
|
|
||||||
if (database.containStatus(TWEETID)) {
|
if (database.containStatus(TWEETID)) {
|
||||||
|
@ -100,13 +100,13 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||||
|
|
||||||
} else if (MODE == RETWEET) {
|
} else if (MODE == RETWEET) {
|
||||||
tweet = mTwitter.retweet(TWEETID);
|
tweet = mTwitter.retweet(TWEETID);
|
||||||
if (!tweet.retweeted)
|
if (!tweet.retweeted())
|
||||||
database.removeStatus(tweet.retweetId);
|
database.removeStatus(tweet.getMyRetweetId());
|
||||||
publishProgress();
|
publishProgress();
|
||||||
|
|
||||||
} else if (MODE == FAVORITE) {
|
} else if (MODE == FAVORITE) {
|
||||||
tweet = mTwitter.favorite(TWEETID);
|
tweet = mTwitter.favorite(TWEETID);
|
||||||
if (tweet.favorized)
|
if (tweet.favorized())
|
||||||
database.storeFavorite(TWEETID);
|
database.storeFavorite(TWEETID);
|
||||||
else
|
else
|
||||||
database.removeFavorite(TWEETID);
|
database.removeFavorite(TWEETID);
|
||||||
|
@ -150,64 +150,64 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
|
||||||
View mediaButton = ui.get().findViewById(R.id.image_attach);
|
View mediaButton = ui.get().findViewById(R.id.image_attach);
|
||||||
View tweet_verify = ui.get().findViewById(R.id.tweet_verify);
|
View tweet_verify = ui.get().findViewById(R.id.tweet_verify);
|
||||||
|
|
||||||
Spannable sTweet = Tagger.makeText(tweet.tweet, highlight, ui.get());
|
Spannable sTweet = Tagger.makeText(tweet.getText(), highlight, ui.get());
|
||||||
tweetText.setMovementMethod(LinkMovementMethod.getInstance());
|
tweetText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
tweetText.setText(sTweet);
|
tweetText.setText(sTweet);
|
||||||
tweetText.setTextColor(font_color);
|
tweetText.setTextColor(font_color);
|
||||||
username.setText(tweet.user.username);
|
username.setText(tweet.getUser().getUsername());
|
||||||
username.setTextColor(font_color);
|
username.setTextColor(font_color);
|
||||||
scrName.setText(tweet.user.screenname);
|
scrName.setText(tweet.getUser().getScreenname());
|
||||||
scrName.setTextColor(font_color);
|
scrName.setTextColor(font_color);
|
||||||
date.setText(sdf.format(tweet.time));
|
date.setText(sdf.format(tweet.getTime()));
|
||||||
date.setTextColor(font_color);
|
date.setTextColor(font_color);
|
||||||
used_api.setText(R.string.sent_from);
|
used_api.setText(R.string.sent_from);
|
||||||
used_api.append(tweet.source);
|
used_api.append(tweet.getSource());
|
||||||
used_api.setTextColor(font_color);
|
used_api.setTextColor(font_color);
|
||||||
|
|
||||||
String ansStr = Integer.toString(answerAdapter.getItemCount() + answers.size());
|
String ansStr = Integer.toString(answerAdapter.getItemCount() + answers.size());
|
||||||
String favStr = Integer.toString(tweet.favorit);
|
String favStr = Integer.toString(tweet.getFavorCount());
|
||||||
String rtStr = Integer.toString(tweet.retweet);
|
String rtStr = Integer.toString(tweet.getRetweetCount());
|
||||||
txtFav.setText(favStr);
|
txtFav.setText(favStr);
|
||||||
txtRet.setText(rtStr);
|
txtRet.setText(rtStr);
|
||||||
txtAns.setText(ansStr);
|
txtAns.setText(ansStr);
|
||||||
|
|
||||||
if (tweet.replyID > 1) {
|
if (tweet.getReplyId() > 1) {
|
||||||
String reply = ui.get().getString(R.string.answering);
|
String reply = ui.get().getString(R.string.answering);
|
||||||
reply += tweet.replyName;
|
reply += tweet.getReplyName();
|
||||||
replyName.setText(reply);
|
replyName.setText(reply);
|
||||||
replyName.setVisibility(View.VISIBLE);
|
replyName.setVisibility(View.VISIBLE);
|
||||||
replyName.setOnClickListener(new View.OnClickListener() {
|
replyName.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(ui.get(), TweetDetail.class);
|
Intent intent = new Intent(ui.get(), TweetDetail.class);
|
||||||
intent.putExtra("tweetID", tweet.replyID);
|
intent.putExtra("tweetID", tweet.getReplyId());
|
||||||
intent.putExtra("userID", tweet.replyUserId);
|
intent.putExtra("userID", tweet.getUser().getId());
|
||||||
intent.putExtra("username", tweet.replyName);
|
intent.putExtra("username", tweet.getReplyName());
|
||||||
ui.get().startActivity(intent);
|
ui.get().startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (tweet.media != null && tweet.media.length != 0) {
|
if (tweet.getMediaLinks() != null && tweet.getMediaLinks().length != 0) {
|
||||||
mediaButton.setVisibility(View.VISIBLE);
|
mediaButton.setVisibility(View.VISIBLE);
|
||||||
mediaButton.setOnClickListener(new View.OnClickListener() {
|
mediaButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
ui.get().imageClick(tweet.media);
|
ui.get().imageClick(tweet.getMediaLinks());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (tweet.user.isVerified) {
|
if (tweet.getUser().isVerified()) {
|
||||||
tweet_verify.setVisibility(View.VISIBLE);
|
tweet_verify.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
if (toggleImg) {
|
if (toggleImg) {
|
||||||
Picasso.get().load(tweet.user.profileImg + "_bigger").into(profile_img);
|
Picasso.get().load(tweet.getUser().getImageLink() + "_bigger").into(profile_img);
|
||||||
}
|
}
|
||||||
if (tweet.retweeted) {
|
if (tweet.retweeted()) {
|
||||||
retweetButton.setImageResource(R.drawable.retweet_enabled);
|
retweetButton.setImageResource(R.drawable.retweet_enabled);
|
||||||
} else {
|
} else {
|
||||||
retweetButton.setImageResource(R.drawable.retweet);
|
retweetButton.setImageResource(R.drawable.retweet);
|
||||||
}
|
}
|
||||||
if (tweet.favorized) {
|
if (tweet.favorized()) {
|
||||||
favoriteButton.setImageResource(R.drawable.favorite_enabled);
|
favoriteButton.setImageResource(R.drawable.favorite_enabled);
|
||||||
} else {
|
} else {
|
||||||
favoriteButton.setImageResource(R.drawable.favorite);
|
favoriteButton.setImageResource(R.drawable.favorite);
|
||||||
|
|
|
@ -4,10 +4,10 @@ import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import org.nuclearfog.twidda.backend.listitems.Message;
|
import org.nuclearfog.twidda.backend.items.Message;
|
||||||
import org.nuclearfog.twidda.backend.listitems.Trend;
|
import org.nuclearfog.twidda.backend.items.Trend;
|
||||||
import org.nuclearfog.twidda.backend.listitems.Tweet;
|
import org.nuclearfog.twidda.backend.items.Tweet;
|
||||||
import org.nuclearfog.twidda.backend.listitems.TwitterUser;
|
import org.nuclearfog.twidda.backend.items.TwitterUser;
|
||||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -204,7 +204,7 @@ public class TwitterEngine {
|
||||||
twitter4j.Trend trends[] = twitter.getPlaceTrends(woeId).getTrends();
|
twitter4j.Trend trends[] = twitter.getPlaceTrends(woeId).getTrends();
|
||||||
|
|
||||||
for (int i = 0; i < trends.length; i++) {
|
for (int i = 0; i < trends.length; i++) {
|
||||||
Trend item = new Trend(i + 1, trends[i].getName(), trends[i].getURL());
|
Trend item = new Trend(i + 1, trends[i].getName());
|
||||||
result.add(item);
|
result.add(item);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -453,18 +453,18 @@ public class TwitterEngine {
|
||||||
*/
|
*/
|
||||||
public Tweet retweet(long tweetId) throws TwitterException {
|
public Tweet retweet(long tweetId) throws TwitterException {
|
||||||
Tweet tweet = getStatus(tweetId);
|
Tweet tweet = getStatus(tweetId);
|
||||||
int retweet = tweet.retweet;
|
int retweet = tweet.getRetweetCount();
|
||||||
|
|
||||||
if (tweet.retweeted) {
|
if (tweet.retweeted()) {
|
||||||
deleteTweet(tweet.retweetId);
|
deleteTweet(tweet.getMyRetweetId());
|
||||||
retweet--;
|
retweet--;
|
||||||
} else {
|
} else {
|
||||||
twitter.retweetStatus(tweet.tweetID);
|
twitter.retweetStatus(tweet.getId());
|
||||||
retweet++;
|
retweet++;
|
||||||
}
|
}
|
||||||
return new Tweet(tweetId, retweet, tweet.favorit, tweet.user, tweet.tweet,
|
return new Tweet(tweetId, retweet, tweet.getFavorCount(), tweet.getUser(), tweet.getText(),
|
||||||
tweet.time, tweet.replyName, tweet.replyUserId, tweet.media, tweet.source,
|
tweet.getTime(), tweet.getReplyName(), tweet.getReplyUserId(), tweet.getMediaLinks(), tweet.getSource(),
|
||||||
tweet.replyID, tweet.embedded, tweet.retweetId, !tweet.retweeted, tweet.favorized);
|
tweet.getReplyId(), tweet.getEmbeddedTweet(), tweet.getMyRetweetId(), !tweet.retweeted(), tweet.favorized());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -476,17 +476,17 @@ public class TwitterEngine {
|
||||||
*/
|
*/
|
||||||
public Tweet favorite(long tweetId) throws TwitterException {
|
public Tweet favorite(long tweetId) throws TwitterException {
|
||||||
Tweet tweet = getStatus(tweetId);
|
Tweet tweet = getStatus(tweetId);
|
||||||
int favorite = tweet.favorit;
|
int favorite = tweet.getFavorCount();
|
||||||
if (tweet.favorized) {
|
if (tweet.favorized()) {
|
||||||
twitter.destroyFavorite(tweet.tweetID);
|
twitter.destroyFavorite(tweet.getId());
|
||||||
favorite--;
|
favorite--;
|
||||||
} else {
|
} else {
|
||||||
twitter.createFavorite(tweet.tweetID);
|
twitter.createFavorite(tweet.getId());
|
||||||
favorite++;
|
favorite++;
|
||||||
}
|
}
|
||||||
return new Tweet(tweetId, tweet.retweet, favorite, tweet.user, tweet.tweet,
|
return new Tweet(tweetId, tweet.getRetweetCount(), favorite, tweet.getUser(), tweet.getText(),
|
||||||
tweet.time, tweet.replyName, tweet.replyUserId, tweet.media, tweet.source,
|
tweet.getTime(), tweet.getReplyName(), tweet.getReplyUserId(), tweet.getMediaLinks(), tweet.getSource(),
|
||||||
tweet.replyID, tweet.embedded, tweet.retweetId, tweet.retweeted, !tweet.favorized);
|
tweet.getReplyId(), tweet.getEmbeddedTweet(), tweet.getMyRetweetId(), tweet.retweeted(), !tweet.favorized());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -508,9 +508,9 @@ public class TwitterEngine {
|
||||||
* @throws TwitterException if Access is unavailable
|
* @throws TwitterException if Access is unavailable
|
||||||
*/
|
*/
|
||||||
public List<TwitterUser> getRetweeter(long tweetID, long cursor) throws TwitterException {
|
public List<TwitterUser> getRetweeter(long tweetID, long cursor) throws TwitterException {
|
||||||
Tweet embeddedStat = getStatus(tweetID).embedded;
|
Tweet embeddedStat = getStatus(tweetID).getEmbeddedTweet();
|
||||||
if (embeddedStat != null)
|
if (embeddedStat != null)
|
||||||
tweetID = embeddedStat.tweetID;
|
tweetID = embeddedStat.getId();
|
||||||
long[] userIds = twitter.getRetweeterIds(tweetID, load, cursor).getIDs();
|
long[] userIds = twitter.getRetweeterIds(tweetID, load, cursor).getIDs();
|
||||||
if (userIds.length == 0) {
|
if (userIds.length == 0) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
@ -630,8 +630,8 @@ public class TwitterEngine {
|
||||||
TwitterUser user = getUser(status.getUser());
|
TwitterUser user = getUser(status.getUser());
|
||||||
int retweet, favorite;
|
int retweet, favorite;
|
||||||
if (retweetedStat != null) {
|
if (retweetedStat != null) {
|
||||||
retweet = retweetedStat.retweet;
|
retweet = retweetedStat.getRetweetCount();
|
||||||
favorite = retweetedStat.favorit;
|
favorite = retweetedStat.getFavorCount();
|
||||||
} else {
|
} else {
|
||||||
retweet = status.getRetweetCount();
|
retweet = status.getRetweetCount();
|
||||||
favorite = status.getFavoriteCount();
|
favorite = status.getFavoriteCount();
|
||||||
|
@ -653,7 +653,8 @@ public class TwitterEngine {
|
||||||
*/
|
*/
|
||||||
private TwitterUser getUser(User user) {
|
private TwitterUser getUser(User user) {
|
||||||
String description = user.getDescription().replace('\n', ' ');
|
String description = user.getDescription().replace('\n', ' ');
|
||||||
return new TwitterUser(user.getId(), user.getName(), user.getScreenName(),
|
String screenname = '@' + user.getScreenName();
|
||||||
|
return new TwitterUser(user.getId(), user.getName(), screenname,
|
||||||
user.getOriginalProfileImageURL(), description, user.getLocation(), user.isVerified(),
|
user.getOriginalProfileImageURL(), description, user.getLocation(), user.isVerified(),
|
||||||
user.isProtected(), user.getURL(), user.getProfileBannerURL(), user.getCreatedAt().getTime(),
|
user.isProtected(), user.getURL(), user.getProfileBannerURL(), user.getCreatedAt().getTime(),
|
||||||
user.getFriendsCount(), user.getFollowersCount());
|
user.getFriendsCount(), user.getFollowersCount());
|
||||||
|
|
|
@ -2,10 +2,10 @@ package org.nuclearfog.twidda.backend.items;
|
||||||
|
|
||||||
public class Message {
|
public class Message {
|
||||||
|
|
||||||
public final long messageId;
|
private final long messageId;
|
||||||
public final TwitterUser sender, receiver;
|
private final TwitterUser sender, receiver;
|
||||||
public final String message;
|
private final String message;
|
||||||
public final long time;
|
private final long time;
|
||||||
|
|
||||||
public Message(long messageId, TwitterUser sender, TwitterUser receiver, long time, String message) {
|
public Message(long messageId, TwitterUser sender, TwitterUser receiver, long time, String message) {
|
||||||
this.messageId = messageId;
|
this.messageId = messageId;
|
||||||
|
@ -14,4 +14,49 @@ public class Message {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get message ID
|
||||||
|
*
|
||||||
|
* @return message ID
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get sender of DM
|
||||||
|
*
|
||||||
|
* @return user
|
||||||
|
*/
|
||||||
|
public TwitterUser getSender() {
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get receiver of DM
|
||||||
|
*
|
||||||
|
* @return user
|
||||||
|
*/
|
||||||
|
public TwitterUser getReceiver() {
|
||||||
|
return receiver;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Message content
|
||||||
|
*
|
||||||
|
* @return message
|
||||||
|
*/
|
||||||
|
public String getText() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get time of DM
|
||||||
|
*
|
||||||
|
* @return raw time
|
||||||
|
*/
|
||||||
|
public long getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,31 @@
|
||||||
package org.nuclearfog.twidda.backend.items;
|
package org.nuclearfog.twidda.backend.items;
|
||||||
|
|
||||||
public class Trend {
|
public class Trend {
|
||||||
public final String trend;
|
private final String trend;
|
||||||
public final String link;
|
private final int position;
|
||||||
public final int position;
|
|
||||||
|
|
||||||
public Trend(int position, String trend, String link) {
|
public Trend(int position, String trend) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.trend = trend;
|
this.trend = trend;
|
||||||
this.link = link;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Trend name
|
||||||
|
*
|
||||||
|
* @return trend name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return trend;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get trend rank
|
||||||
|
*
|
||||||
|
* @return trend rank
|
||||||
|
*/
|
||||||
|
public int getPosition() {
|
||||||
|
return position;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,21 +3,21 @@ package org.nuclearfog.twidda.backend.items;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
public class Tweet {
|
public class Tweet {
|
||||||
public final TwitterUser user; // Tweet Author
|
private final TwitterUser user;
|
||||||
public final Tweet embedded; // Retweetet Tweet
|
private final Tweet embedded;
|
||||||
public final long tweetID; // Unique Tweet ID
|
private final long tweetID;
|
||||||
public final String tweet; // Tweet Text
|
private final String tweet;
|
||||||
public final String replyName; // Screenname of Answered User
|
private final String replyName;
|
||||||
public final String source; // Used Tweet API
|
private final String source;
|
||||||
public final long time; // Tweet Time in millisecond
|
private final long time;
|
||||||
public final long replyID; // Unique ID of Replied Tweet
|
private final long replyID;
|
||||||
public final long retweetId; // Unique ID of My retweet
|
private final long retweetId;
|
||||||
public final long replyUserId; // ID of Replied User
|
private final long replyUserId;
|
||||||
public final int retweet; // Retweet Count
|
private final int retweet;
|
||||||
public final int favorit; // Favorite Count
|
private final int favorit;
|
||||||
public final String[] media; // Media Link container
|
private final String[] media;
|
||||||
public final boolean retweeted; // Retweeted by me
|
private final boolean retweeted;
|
||||||
public final boolean favorized; // Favorited by me
|
private final boolean favorized;
|
||||||
|
|
||||||
|
|
||||||
public Tweet(long tweetID, int retweet, int favorit, TwitterUser user, String tweet, long time,
|
public Tweet(long tweetID, int retweet, int favorit, TwitterUser user, String tweet, long time,
|
||||||
|
@ -39,4 +39,141 @@ public class Tweet {
|
||||||
this.retweetId = retweetId;
|
this.retweetId = retweetId;
|
||||||
this.replyUserId = replyUserId;
|
this.replyUserId = replyUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tweet ID
|
||||||
|
*
|
||||||
|
* @return tweetID
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return tweetID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tweet Content
|
||||||
|
*
|
||||||
|
* @return tweet text
|
||||||
|
*/
|
||||||
|
public String getText() {
|
||||||
|
return tweet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get author
|
||||||
|
*
|
||||||
|
* @return tweet owner
|
||||||
|
*/
|
||||||
|
public TwitterUser getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get time
|
||||||
|
*
|
||||||
|
* @return raw time
|
||||||
|
*/
|
||||||
|
public long getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get used tweet api
|
||||||
|
*
|
||||||
|
* @return api name
|
||||||
|
*/
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get embedded Tweet
|
||||||
|
*
|
||||||
|
* @return tweet
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Tweet getEmbeddedTweet() {
|
||||||
|
return embedded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name of replied user
|
||||||
|
*
|
||||||
|
* @return username
|
||||||
|
*/
|
||||||
|
public String getReplyName() {
|
||||||
|
return replyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of replied user
|
||||||
|
*
|
||||||
|
* @return user Id
|
||||||
|
*/
|
||||||
|
public long getReplyUserId() {
|
||||||
|
return replyUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of replied tweet
|
||||||
|
*
|
||||||
|
* @return tweet id
|
||||||
|
*/
|
||||||
|
public long getReplyId() {
|
||||||
|
return replyID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of my retweet
|
||||||
|
*
|
||||||
|
* @return tweet ID
|
||||||
|
*/
|
||||||
|
public long getMyRetweetId() {
|
||||||
|
return retweetId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get number of retweets
|
||||||
|
*
|
||||||
|
* @return retweet count
|
||||||
|
*/
|
||||||
|
public int getRetweetCount() {
|
||||||
|
return retweet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get number of favors
|
||||||
|
*
|
||||||
|
* @return favor count
|
||||||
|
*/
|
||||||
|
public int getFavorCount() {
|
||||||
|
return favorit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get media links of tweet
|
||||||
|
*
|
||||||
|
* @return media links array
|
||||||
|
*/
|
||||||
|
public String[] getMediaLinks() {
|
||||||
|
return media;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is tweet retweeted by me
|
||||||
|
*
|
||||||
|
* @return retweet status
|
||||||
|
*/
|
||||||
|
public boolean retweeted() {
|
||||||
|
return retweeted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is tweet favored by me
|
||||||
|
*
|
||||||
|
* @return favor status
|
||||||
|
*/
|
||||||
|
public boolean favorized() {
|
||||||
|
return favorized;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,19 +1,19 @@
|
||||||
package org.nuclearfog.twidda.backend.items;
|
package org.nuclearfog.twidda.backend.items;
|
||||||
|
|
||||||
public class TwitterUser {
|
public class TwitterUser {
|
||||||
public final String username;
|
private final String username;
|
||||||
public final String screenname;
|
private final String screenname;
|
||||||
public final String bio;
|
private final String bio;
|
||||||
public final String profileImg;
|
private final String profileImg;
|
||||||
public final String bannerImg;
|
private final String bannerImg;
|
||||||
public final String location;
|
private final String location;
|
||||||
public final String link;
|
private final String link;
|
||||||
public final boolean isVerified;
|
private final boolean isVerified;
|
||||||
public final boolean isLocked;
|
private final boolean isLocked;
|
||||||
public final long userID; // Unique User ID
|
private final long userID;
|
||||||
public final long created; // User since
|
private final long created;
|
||||||
public final int following; // Following count
|
private final int following;
|
||||||
public final int follower; // Follower count
|
private final int follower;
|
||||||
|
|
||||||
public TwitterUser(long userID, String username, String screenname, String profileImg,
|
public TwitterUser(long userID, String username, String screenname, String profileImg,
|
||||||
String bio, String location, boolean isVerified, boolean isLocked, String link,
|
String bio, String location, boolean isVerified, boolean isLocked, String link,
|
||||||
|
@ -32,4 +32,121 @@ public class TwitterUser {
|
||||||
this.following = following;
|
this.following = following;
|
||||||
this.follower = follower;
|
this.follower = follower;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get user id
|
||||||
|
*
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return userID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get User name
|
||||||
|
*
|
||||||
|
* @return username
|
||||||
|
*/
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get @screenname
|
||||||
|
*
|
||||||
|
* @return screen name
|
||||||
|
*/
|
||||||
|
public String getScreenname() {
|
||||||
|
return screenname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get date of creation
|
||||||
|
*
|
||||||
|
* @return raw time
|
||||||
|
*/
|
||||||
|
public long getCreatedAt() {
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Profile image link
|
||||||
|
*
|
||||||
|
* @return link
|
||||||
|
*/
|
||||||
|
public String getImageLink() {
|
||||||
|
return profileImg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get banner image link
|
||||||
|
*
|
||||||
|
* @return link
|
||||||
|
*/
|
||||||
|
public String getBannerLink() {
|
||||||
|
return bannerImg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get user bio
|
||||||
|
*
|
||||||
|
* @return bio text
|
||||||
|
*/
|
||||||
|
public String getBio() {
|
||||||
|
return bio;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get location name
|
||||||
|
*
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
|
public String getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get link
|
||||||
|
*
|
||||||
|
* @return link
|
||||||
|
*/
|
||||||
|
public String getLink() {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* user verified
|
||||||
|
*
|
||||||
|
* @return if verified
|
||||||
|
*/
|
||||||
|
public boolean isVerified() {
|
||||||
|
return isVerified;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* user locked
|
||||||
|
*
|
||||||
|
* @return if locked
|
||||||
|
*/
|
||||||
|
public boolean isLocked() {
|
||||||
|
return isLocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get following count
|
||||||
|
*
|
||||||
|
* @return following
|
||||||
|
*/
|
||||||
|
public int getFollowing() {
|
||||||
|
return following;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get follower count
|
||||||
|
*
|
||||||
|
* @return follower count
|
||||||
|
*/
|
||||||
|
public int getFollower() {
|
||||||
|
return follower;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -105,7 +105,7 @@ public class DatabaseAdapter {
|
||||||
for (Tweet tweet : fav) {
|
for (Tweet tweet : fav) {
|
||||||
storeStatus(tweet, 0, db);
|
storeStatus(tweet, 0, db);
|
||||||
ContentValues favTable = new ContentValues();
|
ContentValues favTable = new ContentValues();
|
||||||
favTable.put("tweetID", tweet.tweetID);
|
favTable.put("tweetID", tweet.getId());
|
||||||
favTable.put("ownerID", ownerId);
|
favTable.put("ownerID", ownerId);
|
||||||
db.insertWithOnConflict("favorit", null, favTable, CONFLICT_IGNORE);
|
db.insertWithOnConflict("favorit", null, favTable, CONFLICT_IGNORE);
|
||||||
}
|
}
|
||||||
|
@ -343,22 +343,22 @@ public class DatabaseAdapter {
|
||||||
public void updateStatus(Tweet tweet) {
|
public void updateStatus(Tweet tweet) {
|
||||||
SQLiteDatabase db = getDbWrite();
|
SQLiteDatabase db = getDbWrite();
|
||||||
ContentValues status = new ContentValues();
|
ContentValues status = new ContentValues();
|
||||||
int register = getStatRegister(db, tweet.tweetID);
|
int register = getStatRegister(db, tweet.getId());
|
||||||
if (tweet.retweeted)
|
if (tweet.retweeted())
|
||||||
register |= retweetedMask;
|
register |= retweetedMask;
|
||||||
else
|
else
|
||||||
register &= ~retweetedMask;
|
register &= ~retweetedMask;
|
||||||
|
|
||||||
if (tweet.favorized)
|
if (tweet.favorized())
|
||||||
register |= favoritedMask;
|
register |= favoritedMask;
|
||||||
else
|
else
|
||||||
register &= ~favoritedMask;
|
register &= ~favoritedMask;
|
||||||
status.put("retweet", tweet.retweet);
|
status.put("retweet", tweet.getRetweetCount());
|
||||||
status.put("favorite", tweet.favorit);
|
status.put("favorite", tweet.getFavorCount());
|
||||||
status.put("statusregister", register);
|
status.put("statusregister", register);
|
||||||
|
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
db.update("tweet", status, "tweet.tweetID=" + tweet.tweetID, null);
|
db.update("tweet", status, "tweet.tweetID=" + tweet.getId(), null);
|
||||||
commit(db);
|
commit(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,9 +422,7 @@ public class DatabaseAdapter {
|
||||||
int position = cursor.getInt(index);
|
int position = cursor.getInt(index);
|
||||||
index = cursor.getColumnIndex("trendname");
|
index = cursor.getColumnIndex("trendname");
|
||||||
String name = cursor.getString(index);
|
String name = cursor.getString(index);
|
||||||
index = cursor.getColumnIndex("trendlink");
|
trends.add(new Trend(position, name));
|
||||||
String link = cursor.getString(index);
|
|
||||||
trends.add(new Trend(position, name, link));
|
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
@ -572,83 +570,83 @@ public class DatabaseAdapter {
|
||||||
private void storeUser(TwitterUser user, SQLiteDatabase db) {
|
private void storeUser(TwitterUser user, SQLiteDatabase db) {
|
||||||
ContentValues userColumn = new ContentValues();
|
ContentValues userColumn = new ContentValues();
|
||||||
int userRegister = 0;
|
int userRegister = 0;
|
||||||
if (user.isVerified)
|
if (user.isVerified())
|
||||||
userRegister |= verifiedMask;
|
userRegister |= verifiedMask;
|
||||||
if (user.isLocked)
|
if (user.isLocked())
|
||||||
userRegister |= lockedMask;
|
userRegister |= lockedMask;
|
||||||
userColumn.put("userID", user.userID);
|
userColumn.put("userID", user.getId());
|
||||||
userColumn.put("username", user.username);
|
userColumn.put("username", user.getUsername());
|
||||||
userColumn.put("scrname", user.screenname.substring(1));
|
userColumn.put("scrname", user.getScreenname());
|
||||||
userColumn.put("pbLink", user.profileImg);
|
userColumn.put("pbLink", user.getUsername());
|
||||||
userColumn.put("userregister", userRegister);
|
userColumn.put("userregister", userRegister);
|
||||||
userColumn.put("bio", user.bio);
|
userColumn.put("bio", user.getBio());
|
||||||
userColumn.put("link", user.link);
|
userColumn.put("link", user.getLink());
|
||||||
userColumn.put("location", user.location);
|
userColumn.put("location", user.getLocation());
|
||||||
userColumn.put("banner", user.bannerImg);
|
userColumn.put("banner", user.getBannerLink());
|
||||||
userColumn.put("createdAt", user.created);
|
userColumn.put("createdAt", user.getCreatedAt());
|
||||||
userColumn.put("following", user.following);
|
userColumn.put("following", user.getFollowing());
|
||||||
userColumn.put("follower", user.follower);
|
userColumn.put("follower", user.getFollower());
|
||||||
db.insertWithOnConflict("user", null, userColumn, CONFLICT_REPLACE);
|
db.insertWithOnConflict("user", null, userColumn, CONFLICT_REPLACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void storeStatus(Tweet tweet, int newStatusRegister, SQLiteDatabase db) {
|
private void storeStatus(Tweet tweet, int newStatusRegister, SQLiteDatabase db) {
|
||||||
ContentValues status = new ContentValues();
|
ContentValues status = new ContentValues();
|
||||||
TwitterUser user = tweet.user;
|
TwitterUser user = tweet.getUser();
|
||||||
Tweet rtStat = tweet.embedded;
|
Tweet rtStat = tweet.getEmbeddedTweet();
|
||||||
long rtId = 1L;
|
long rtId = 1L;
|
||||||
|
|
||||||
if (rtStat != null) {
|
if (rtStat != null) {
|
||||||
storeStatus(rtStat, 0, db);
|
storeStatus(rtStat, 0, db);
|
||||||
rtId = rtStat.tweetID;
|
rtId = rtStat.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentValues userColumn = new ContentValues();
|
ContentValues userColumn = new ContentValues();
|
||||||
int userRegister = 0;
|
int userRegister = 0;
|
||||||
if (user.isVerified)
|
if (user.isVerified())
|
||||||
userRegister |= verifiedMask;
|
userRegister |= verifiedMask;
|
||||||
if (user.isLocked)
|
if (user.isLocked())
|
||||||
userRegister |= lockedMask;
|
userRegister |= lockedMask;
|
||||||
|
|
||||||
userColumn.put("userID", user.userID);
|
userColumn.put("userID", user.getId());
|
||||||
userColumn.put("username", user.username);
|
userColumn.put("username", user.getUsername());
|
||||||
userColumn.put("scrname", user.screenname.substring(1));
|
userColumn.put("scrname", user.getScreenname());
|
||||||
userColumn.put("pbLink", user.profileImg);
|
userColumn.put("pbLink", user.getImageLink());
|
||||||
userColumn.put("userregister", userRegister);
|
userColumn.put("userregister", userRegister);
|
||||||
userColumn.put("bio", user.bio);
|
userColumn.put("bio", user.getBio());
|
||||||
userColumn.put("link", user.link);
|
userColumn.put("link", user.getLink());
|
||||||
userColumn.put("location", user.location);
|
userColumn.put("location", user.getLocation());
|
||||||
userColumn.put("banner", user.bannerImg);
|
userColumn.put("banner", user.getBannerLink());
|
||||||
userColumn.put("createdAt", user.created);
|
userColumn.put("createdAt", user.getCreatedAt());
|
||||||
userColumn.put("following", user.following);
|
userColumn.put("following", user.getFollowing());
|
||||||
userColumn.put("follower", user.follower);
|
userColumn.put("follower", user.getFollower());
|
||||||
|
|
||||||
status.put("tweetID", tweet.tweetID);
|
status.put("tweetID", tweet.getId());
|
||||||
status.put("userID", user.userID);
|
status.put("userID", user.getId());
|
||||||
status.put("time", tweet.time);
|
status.put("time", tweet.getTime());
|
||||||
status.put("tweet", tweet.tweet);
|
status.put("tweet", tweet.getText());
|
||||||
status.put("retweetID", rtId);
|
status.put("retweetID", rtId);
|
||||||
status.put("source", tweet.source);
|
status.put("source", tweet.getSource());
|
||||||
status.put("replyID", tweet.replyID);
|
status.put("replyID", tweet.getReplyId());
|
||||||
status.put("replyname", tweet.replyName);
|
status.put("replyname", tweet.getReplyName());
|
||||||
status.put("retweet", tweet.retweet);
|
status.put("retweet", tweet.getRetweetCount());
|
||||||
status.put("favorite", tweet.favorit);
|
status.put("favorite", tweet.getFavorCount());
|
||||||
status.put("retweeterID", tweet.retweetId);
|
status.put("retweeterID", tweet.getMyRetweetId());
|
||||||
status.put("replyUserID", tweet.replyUserId);
|
status.put("replyUserID", tweet.getReplyUserId());
|
||||||
String[] mediaLinks = tweet.media;
|
String[] mediaLinks = tweet.getMediaLinks();
|
||||||
StringBuilder media = new StringBuilder();
|
StringBuilder media = new StringBuilder();
|
||||||
for (String link : mediaLinks) {
|
for (String link : mediaLinks) {
|
||||||
media.append(link);
|
media.append(link);
|
||||||
media.append(";");
|
media.append(";");
|
||||||
}
|
}
|
||||||
status.put("media", media.toString());
|
status.put("media", media.toString());
|
||||||
int statusRegister = getStatRegister(db, tweet.tweetID);
|
int statusRegister = getStatRegister(db, tweet.getId());
|
||||||
statusRegister |= newStatusRegister;
|
statusRegister |= newStatusRegister;
|
||||||
if (tweet.favorized)
|
if (tweet.favorized())
|
||||||
statusRegister |= favoritedMask;
|
statusRegister |= favoritedMask;
|
||||||
else
|
else
|
||||||
statusRegister &= ~favoritedMask;
|
statusRegister &= ~favoritedMask;
|
||||||
if (tweet.retweeted)
|
if (tweet.retweeted())
|
||||||
statusRegister |= retweetedMask;
|
statusRegister |= retweetedMask;
|
||||||
else
|
else
|
||||||
statusRegister &= ~retweetedMask;
|
statusRegister &= ~retweetedMask;
|
||||||
|
@ -661,13 +659,13 @@ public class DatabaseAdapter {
|
||||||
|
|
||||||
private void storeMessage(Message message, SQLiteDatabase db) {
|
private void storeMessage(Message message, SQLiteDatabase db) {
|
||||||
ContentValues messageColumn = new ContentValues();
|
ContentValues messageColumn = new ContentValues();
|
||||||
messageColumn.put("messageID", message.messageId);
|
messageColumn.put("messageID", message.getId());
|
||||||
messageColumn.put("time", message.time);
|
messageColumn.put("time", message.getTime());
|
||||||
messageColumn.put("senderID", message.sender.userID);
|
messageColumn.put("senderID", message.getSender().getId());
|
||||||
messageColumn.put("receiverID", message.receiver.userID);
|
messageColumn.put("receiverID", message.getReceiver().getId());
|
||||||
messageColumn.put("message", message.message);
|
messageColumn.put("message", message.getText());
|
||||||
storeUser(message.sender, db);
|
storeUser(message.getSender(), db);
|
||||||
storeUser(message.receiver, db);
|
storeUser(message.getReceiver(), db);
|
||||||
db.insertWithOnConflict("message", null, messageColumn, CONFLICT_IGNORE);
|
db.insertWithOnConflict("message", null, messageColumn, CONFLICT_IGNORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,9 +673,9 @@ public class DatabaseAdapter {
|
||||||
private void storeTrends(Trend trend, int woeId, SQLiteDatabase db) {
|
private void storeTrends(Trend trend, int woeId, SQLiteDatabase db) {
|
||||||
ContentValues trendColumn = new ContentValues();
|
ContentValues trendColumn = new ContentValues();
|
||||||
trendColumn.put("woeID", woeId);
|
trendColumn.put("woeID", woeId);
|
||||||
trendColumn.put("trendpos", trend.position);
|
trendColumn.put("trendpos", trend.getPosition());
|
||||||
trendColumn.put("trendname", trend.trend);
|
trendColumn.put("trendname", trend.getName());
|
||||||
trendColumn.put("trendlink", trend.link);
|
// trendColumn.put("trendlink", "");//todo
|
||||||
db.insertWithOnConflict("trend", null, trendColumn, CONFLICT_REPLACE);
|
db.insertWithOnConflict("trend", null, trendColumn, CONFLICT_REPLACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class DirectMessage extends AppCompatActivity implements OnRefreshListene
|
||||||
if (mAdapter != null && !refresh.isRefreshing()) {
|
if (mAdapter != null && !refresh.isRefreshing()) {
|
||||||
Message message = mAdapter.getData().get(index);
|
Message message = mAdapter.getData().get(index);
|
||||||
Intent sendDm = new Intent(this, MessagePopup.class);
|
Intent sendDm = new Intent(this, MessagePopup.class);
|
||||||
sendDm.putExtra("username", message.sender.screenname);
|
sendDm.putExtra("username", message.getSender().getScreenname());
|
||||||
startActivity(sendDm);
|
startActivity(sendDm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ public class DirectMessage extends AppCompatActivity implements OnRefreshListene
|
||||||
if (mLoader != null && mLoader.getStatus() != RUNNING) {
|
if (mLoader != null && mLoader.getStatus() != RUNNING) {
|
||||||
if (mAdapter != null && !refresh.isRefreshing()) {
|
if (mAdapter != null && !refresh.isRefreshing()) {
|
||||||
Message message = mAdapter.getData().get(index);
|
Message message = mAdapter.getData().get(index);
|
||||||
final long messageId = message.messageId;
|
final long messageId = message.getId();
|
||||||
new Builder(this).setMessage(R.string.confirm_delete_dm)
|
new Builder(this).setMessage(R.string.confirm_delete_dm)
|
||||||
.setNegativeButton(R.string.no_confirm, null)
|
.setNegativeButton(R.string.no_confirm, null)
|
||||||
.setPositiveButton(R.string.yes_confirm, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.yes_confirm, new DialogInterface.OnClickListener() {
|
||||||
|
|
|
@ -177,9 +177,9 @@ public class SearchPage extends AppCompatActivity implements UserAdapter.OnItemC
|
||||||
if (tweetAdapter != null) {
|
if (tweetAdapter != null) {
|
||||||
Tweet tweet = tweetAdapter.getData().get(position);
|
Tweet tweet = tweetAdapter.getData().get(position);
|
||||||
Intent intent = new Intent(this, TweetDetail.class);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
intent.putExtra("tweetID", tweet.tweetID);
|
intent.putExtra("tweetID", tweet.getId());
|
||||||
intent.putExtra("userID", tweet.user.userID);
|
intent.putExtra("userID", tweet.getUser().getId());
|
||||||
intent.putExtra("username", tweet.user.screenname);
|
intent.putExtra("username", tweet.getUser().getScreenname());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -187,8 +187,8 @@ public class SearchPage extends AppCompatActivity implements UserAdapter.OnItemC
|
||||||
if (userAdapter != null) {
|
if (userAdapter != null) {
|
||||||
TwitterUser user = userAdapter.getData().get(position);
|
TwitterUser user = userAdapter.getData().get(position);
|
||||||
Intent intent = new Intent(this, UserProfile.class);
|
Intent intent = new Intent(this, UserProfile.class);
|
||||||
intent.putExtra("userID", user.userID);
|
intent.putExtra("userID", user.getId());
|
||||||
intent.putExtra("username", user.screenname);
|
intent.putExtra("username", user.getScreenname());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,9 +232,9 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
|
||||||
if (timeLineAdapter != null && !answerReload.isRefreshing()) {
|
if (timeLineAdapter != null && !answerReload.isRefreshing()) {
|
||||||
Tweet tweet = timeLineAdapter.getData().get(position);
|
Tweet tweet = timeLineAdapter.getData().get(position);
|
||||||
Intent intent = new Intent(this, TweetDetail.class);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
intent.putExtra("tweetID", tweet.tweetID);
|
intent.putExtra("tweetID", tweet.getId());
|
||||||
intent.putExtra("userID", tweet.user.userID);
|
intent.putExtra("userID", tweet.getUser().getId());
|
||||||
intent.putExtra("username", tweet.user.screenname);
|
intent.putExtra("username", tweet.getUser().getScreenname());
|
||||||
startActivityForResult(intent, TWEET);
|
startActivityForResult(intent, TWEET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,8 @@ public class UserDetail extends AppCompatActivity implements OnItemClicked, OnRe
|
||||||
UserAdapter userListAdapter = (UserAdapter) userList.getAdapter();
|
UserAdapter userListAdapter = (UserAdapter) userList.getAdapter();
|
||||||
if (userListAdapter != null && !refresh.isRefreshing()) {
|
if (userListAdapter != null && !refresh.isRefreshing()) {
|
||||||
TwitterUser user = userListAdapter.getData().get(position);
|
TwitterUser user = userListAdapter.getData().get(position);
|
||||||
long userID = user.userID;
|
long userID = user.getId();
|
||||||
String username = user.screenname;
|
String username = user.getScreenname();
|
||||||
Intent intent = new Intent(this, UserProfile.class);
|
Intent intent = new Intent(this, UserProfile.class);
|
||||||
intent.putExtra("userID", userID);
|
intent.putExtra("userID", userID);
|
||||||
intent.putExtra("username", username);
|
intent.putExtra("username", username);
|
||||||
|
|
|
@ -302,24 +302,24 @@ public class UserProfile extends AppCompatActivity implements OnRefreshListener,
|
||||||
TimelineAdapter tweetAdapter = (TimelineAdapter) homeList.getAdapter();
|
TimelineAdapter tweetAdapter = (TimelineAdapter) homeList.getAdapter();
|
||||||
if (tweetAdapter != null && !homeReload.isRefreshing()) {
|
if (tweetAdapter != null && !homeReload.isRefreshing()) {
|
||||||
Tweet tweet = tweetAdapter.getData().get(position);
|
Tweet tweet = tweetAdapter.getData().get(position);
|
||||||
if (tweet.embedded != null)
|
if (tweet.getEmbeddedTweet() != null)
|
||||||
tweet = tweet.embedded;
|
tweet = tweet.getEmbeddedTweet();
|
||||||
Intent intent = new Intent(this, TweetDetail.class);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
intent.putExtra("tweetID", tweet.tweetID);
|
intent.putExtra("tweetID", tweet.getId());
|
||||||
intent.putExtra("userID", tweet.user.userID);
|
intent.putExtra("userID", tweet.getUser().getId());
|
||||||
intent.putExtra("username", tweet.user.screenname);
|
intent.putExtra("username", tweet.getUser().getId());
|
||||||
startActivityForResult(intent, TWEET);
|
startActivityForResult(intent, TWEET);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TimelineAdapter tweetAdapter = (TimelineAdapter) favoriteList.getAdapter();
|
TimelineAdapter tweetAdapter = (TimelineAdapter) favoriteList.getAdapter();
|
||||||
if (tweetAdapter != null && !favoriteReload.isRefreshing()) {
|
if (tweetAdapter != null && !favoriteReload.isRefreshing()) {
|
||||||
Tweet tweet = tweetAdapter.getData().get(position);
|
Tweet tweet = tweetAdapter.getData().get(position);
|
||||||
if (tweet.embedded != null)
|
if (tweet.getEmbeddedTweet() != null)
|
||||||
tweet = tweet.embedded;
|
tweet = tweet.getEmbeddedTweet();
|
||||||
Intent intent = new Intent(this, TweetDetail.class);
|
Intent intent = new Intent(this, TweetDetail.class);
|
||||||
intent.putExtra("tweetID", tweet.tweetID);
|
intent.putExtra("tweetID", tweet.getId());
|
||||||
intent.putExtra("userID", tweet.user.userID);
|
intent.putExtra("userID", tweet.getUser().getId());
|
||||||
intent.putExtra("username", tweet.user.screenname);
|
intent.putExtra("username", tweet.getUser().getScreenname());
|
||||||
startActivityForResult(intent, TWEET);
|
startActivityForResult(intent, TWEET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue