mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-03 12:37:33 +01:00
Bugfix
Major Cleanup
This commit is contained in:
parent
1cda733c39
commit
6296179746
@ -22,7 +22,6 @@ import java.lang.ref.WeakReference;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import twitter4j.User;
|
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
||||||
@ -80,20 +79,20 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
|
|||||||
}
|
}
|
||||||
if(MODE == GET_INFORMATION)
|
if(MODE == GET_INFORMATION)
|
||||||
{
|
{
|
||||||
User user = mTwitter.getUser(userId);
|
TwitterUser user = mTwitter.getUser(userId);
|
||||||
screenName = '@'+user.getScreenName();
|
screenName = '@'+user.screenname;
|
||||||
username = user.getName();
|
username = user.username;
|
||||||
description = user.getDescription();
|
description = user.bio;
|
||||||
location = user.getLocation();
|
location = user.location;
|
||||||
isVerified = user.isVerified();
|
isVerified = user.isVerified;
|
||||||
isLocked = user.isProtected();
|
isLocked = user.isLocked;
|
||||||
link = user.getURL();
|
link = user.link;
|
||||||
follower = Integer.toString(user.getFollowersCount());
|
follower = Integer.toString(user.follower);
|
||||||
following = Integer.toString(user.getFriendsCount());
|
following = Integer.toString(user.following);
|
||||||
imageLink = user.getProfileImageURL();
|
imageLink = user.profileImg;
|
||||||
// bannerLink = user.getProfileBannerMobileURL();
|
// bannerLink = user.bannerImg;
|
||||||
fullPbLink = user.getOriginalProfileImageURL();
|
fullPbLink = user.fullpb;
|
||||||
Date d = user.getCreatedAt();
|
Date d = new Date(user.created);
|
||||||
dateString = "seit "+ DateFormat.getDateTimeInstance().format(d);
|
dateString = "seit "+ DateFormat.getDateTimeInstance().format(d);
|
||||||
}
|
}
|
||||||
else if(MODE == GET_TWEETS)
|
else if(MODE == GET_TWEETS)
|
||||||
|
@ -35,8 +35,8 @@ import twitter4j.conf.ConfigurationBuilder;
|
|||||||
*/
|
*/
|
||||||
public class TwitterEngine {
|
public class TwitterEngine {
|
||||||
|
|
||||||
private final String TWITTER_CONSUMER_KEY = "GrylGIgQK3cDjo9mSTBqF1vwf";
|
private final String TWITTER_CONSUMER_KEY = "1JwXJbVrvGWrc9SSKPnnEWslJ";
|
||||||
private final String TWITTER_CONSUMER_SECRET = "pgaWUlDVS5b7Q6VJQDgBzHKw0mIxJIX0UQBcT1oFJEivsCl5OV";
|
private final String TWITTER_CONSUMER_SECRET = "4SNMCHbg68LM14X2wYDjWkmzuNqq5dnB7tfAj2b4Muu8uPQ2QE";
|
||||||
|
|
||||||
private static TwitterEngine mTwitter;
|
private static TwitterEngine mTwitter;
|
||||||
private static long twitterID;
|
private static long twitterID;
|
||||||
@ -126,6 +126,7 @@ public class TwitterEngine {
|
|||||||
e.apply();
|
e.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* recall Keys from Shared-Preferences
|
* recall Keys from Shared-Preferences
|
||||||
* & initialize Twitter
|
* & initialize Twitter
|
||||||
@ -140,6 +141,7 @@ public class TwitterEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Home Timeline
|
* Get Home Timeline
|
||||||
* @param page current page
|
* @param page current page
|
||||||
@ -202,6 +204,7 @@ public class TwitterEngine {
|
|||||||
return convertUserList(twitter.searchUsers(search, -1));
|
return convertUserList(twitter.searchUsers(search, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get User Tweets
|
* Get User Tweets
|
||||||
* @param userId User ID
|
* @param userId User ID
|
||||||
@ -213,6 +216,7 @@ public class TwitterEngine {
|
|||||||
return convertStatusList(twitter.getUserTimeline(userId, new Paging((int)page,load, id)));
|
return convertStatusList(twitter.getUserTimeline(userId, new Paging((int)page,load, id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get User Favs
|
* Get User Favs
|
||||||
* @param userId User ID
|
* @param userId User ID
|
||||||
@ -224,16 +228,18 @@ public class TwitterEngine {
|
|||||||
return convertStatusList(twitter.getFavorites(userId,new Paging((int)page,load,id)));
|
return convertStatusList(twitter.getFavorites(userId,new Paging((int)page,load,id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get User Context
|
* Get User Context
|
||||||
* @param id User ID
|
* @param id User ID
|
||||||
* @return User Object
|
* @return User Object
|
||||||
* @throws TwitterException if Access is unavailable
|
* @throws TwitterException if Access is unavailable
|
||||||
*/
|
*/
|
||||||
public User getUser(long id) throws TwitterException {
|
public TwitterUser getUser(long id) throws TwitterException {
|
||||||
return twitter.showUser(id);
|
return getUser(twitter.showUser(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Connection between Home and another User
|
* Get Connection between Home and another User
|
||||||
* @param id User ID
|
* @param id User ID
|
||||||
@ -248,6 +254,7 @@ public class TwitterEngine {
|
|||||||
return twitter.showFriendship(twitterID,id).isTargetFollowingSource();
|
return twitter.showFriendship(twitterID,id).isTargetFollowingSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Block Status
|
* Get Block Status
|
||||||
* @param id User ID
|
* @param id User ID
|
||||||
@ -275,6 +282,7 @@ public class TwitterEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch blocking User
|
* Switch blocking User
|
||||||
* @param id User ID
|
* @param id User ID
|
||||||
@ -303,6 +311,7 @@ public class TwitterEngine {
|
|||||||
return convertUserList(twitter.lookupUsers(userIDs.getIDs()));
|
return convertUserList(twitter.lookupUsers(userIDs.getIDs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get Follower
|
* get Follower
|
||||||
* @param id User ID
|
* @param id User ID
|
||||||
@ -314,6 +323,7 @@ public class TwitterEngine {
|
|||||||
return convertUserList(twitter.lookupUsers(userIDs.getIDs()));
|
return convertUserList(twitter.lookupUsers(userIDs.getIDs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send Tweet
|
* Send Tweet
|
||||||
* @param text Tweet Text
|
* @param text Tweet Text
|
||||||
@ -327,6 +337,7 @@ public class TwitterEngine {
|
|||||||
twitter.tweets().updateStatus(mStatus);
|
twitter.tweets().updateStatus(mStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send Tweet
|
* Send Tweet
|
||||||
* @param text Tweet Text
|
* @param text Tweet Text
|
||||||
@ -353,6 +364,7 @@ public class TwitterEngine {
|
|||||||
twitter.tweets().updateStatus(mStatus);
|
twitter.tweets().updateStatus(mStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Tweet
|
* Get Tweet
|
||||||
* @param id Tweet ID
|
* @param id Tweet ID
|
||||||
@ -370,6 +382,7 @@ public class TwitterEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Answer Tweets
|
* Get Answer Tweets
|
||||||
* @param name name of receiver
|
* @param name name of receiver
|
||||||
@ -391,6 +404,7 @@ public class TwitterEngine {
|
|||||||
return convertStatusList(answers);
|
return convertStatusList(answers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retweet Action
|
* Retweet Action
|
||||||
* @param id Tweet ID
|
* @param id Tweet ID
|
||||||
@ -405,6 +419,7 @@ public class TwitterEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Favorite Action
|
* Favorite Action
|
||||||
* @param id Tweet ID
|
* @param id Tweet ID
|
||||||
@ -419,6 +434,7 @@ public class TwitterEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get User who retweeted a Tweet
|
* Get User who retweeted a Tweet
|
||||||
* @param tweetID Tweet ID
|
* @param tweetID Tweet ID
|
||||||
@ -442,19 +458,23 @@ public class TwitterEngine {
|
|||||||
/**
|
/**
|
||||||
* convert #twitter4j.User to TwitterUser List
|
* convert #twitter4j.User to TwitterUser List
|
||||||
* @param users Twitter4J user List
|
* @param users Twitter4J user List
|
||||||
* @return #TwitterEngine.TwitteUser
|
* @return TwitterUser
|
||||||
*/
|
*/
|
||||||
private List<TwitterUser> convertUserList(List<User> users) {
|
private List<TwitterUser> convertUserList(List<User> users) {
|
||||||
List <TwitterUser> result = new ArrayList<>();
|
List <TwitterUser> result = new ArrayList<>();
|
||||||
for(User user : users) {
|
for(User user : users) {
|
||||||
TwitterUser item = new TwitterUser(user.getId(), user.getName(), user.getScreenName(),
|
TwitterUser item = getUser(user);
|
||||||
user.getMiniProfileImageURL(),user.getDescription(), user.getLocation(),user.isVerified(),
|
|
||||||
user.isProtected(), user.getURL(), user.getProfileBannerURL());
|
|
||||||
result.add(item);
|
result.add(item);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert #twitter4j.Status to Tweet List
|
||||||
|
* @param statuses Twitter4J status List
|
||||||
|
* @return TwitterStatus
|
||||||
|
*/
|
||||||
private List<Tweet> convertStatusList(List<Status> statuses) {
|
private List<Tweet> convertStatusList(List<Status> statuses) {
|
||||||
List<Tweet> result = new ArrayList<>();
|
List<Tweet> result = new ArrayList<>();
|
||||||
for(Status status : statuses) {
|
for(Status status : statuses) {
|
||||||
@ -471,6 +491,12 @@ public class TwitterEngine {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param status twitter4j.Status
|
||||||
|
* @param retweetedStat embedded Status
|
||||||
|
* @return Tweet item
|
||||||
|
*/
|
||||||
private Tweet getTweet(Status status, Tweet retweetedStat) {
|
private Tweet getTweet(Status status, Tweet retweetedStat) {
|
||||||
User user = status.getUser();
|
User user = status.getUser();
|
||||||
return new Tweet(status.getId(), user.getId(), user.getName(), user.getScreenName(),
|
return new Tweet(status.getId(), user.getId(), user.getName(), user.getScreenName(),
|
||||||
@ -480,6 +506,23 @@ public class TwitterEngine {
|
|||||||
retweetedStat, status.isRetweetedByMe(), status.isFavorited());
|
retweetedStat, status.isRetweetedByMe(), status.isFavorited());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param user Twitter4J User
|
||||||
|
* @return User item
|
||||||
|
*/
|
||||||
|
private TwitterUser getUser(User user) {
|
||||||
|
return new TwitterUser(user.getId(),user.getName(),user.getScreenName(),user.getMiniProfileImageURL(),
|
||||||
|
user.getOriginalProfileImageURL(),user.getDescription(),user.getLocation(),user.isVerified(),
|
||||||
|
user.isProtected(),user.getURL(),user.getProfileBannerURL(),user.getCreatedAt().getTime(),
|
||||||
|
user.getFriendsCount(),user.getFollowersCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param status Twitter4J status
|
||||||
|
* @return Array of Medialinks
|
||||||
|
*/
|
||||||
private String[] getMediaLinks(Status status) {
|
private String[] getMediaLinks(Status status) {
|
||||||
MediaEntity[] mediaEntities = status.getMediaEntities();
|
MediaEntity[] mediaEntities = status.getMediaEntities();
|
||||||
String medialinks[] = new String[mediaEntities.length];
|
String medialinks[] = new String[mediaEntities.length];
|
||||||
@ -499,6 +542,7 @@ public class TwitterEngine {
|
|||||||
twitter.destroyStatus(id);
|
twitter.destroyStatus(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return User ID
|
* Return User ID
|
||||||
* @return result
|
* @return result
|
||||||
@ -507,6 +551,7 @@ public class TwitterEngine {
|
|||||||
return twitterID;
|
return twitterID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton
|
* Singleton
|
||||||
* @param context Main Thread Context
|
* @param context Main Thread Context
|
||||||
|
@ -2,23 +2,29 @@ package org.nuclearfog.twidda.backend.listitems;
|
|||||||
|
|
||||||
public class TwitterUser {
|
public class TwitterUser {
|
||||||
public final String username,screenname,bio;
|
public final String username,screenname,bio;
|
||||||
public final String profileImg,bannerImg;
|
public final String profileImg,fullpb,bannerImg;
|
||||||
public final String location,link;
|
public final String location,link;
|
||||||
public final boolean isVerified,isLocked;
|
public final boolean isVerified,isLocked;
|
||||||
public final long userID;
|
public final long userID;
|
||||||
|
public final long created;
|
||||||
|
public final int following, 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 fullpb, String bio, String location, boolean isVerified, boolean isLocked,
|
||||||
String link, String bannerImg) {
|
String link, String bannerImg, long created, int following, int follower) {
|
||||||
this.userID = userID;
|
this.userID = userID;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.screenname = screenname;
|
this.screenname = screenname;
|
||||||
this.profileImg = profileImg;
|
this.profileImg = profileImg;
|
||||||
|
this.fullpb = fullpb;
|
||||||
this.bio = bio;
|
this.bio = bio;
|
||||||
this.link = link;
|
this.link = link;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.bannerImg = bannerImg;
|
this.bannerImg = bannerImg;
|
||||||
this.isVerified = isVerified;
|
this.isVerified = isVerified;
|
||||||
this.isLocked = isLocked;
|
this.isLocked = isLocked;
|
||||||
|
this.created = created;
|
||||||
|
this.following = following;
|
||||||
|
this.follower = follower;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user