mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-01 04:17:21 +01:00
project reformat, bug fix
This commit is contained in:
parent
6b0a359aff
commit
05104df9df
@ -2,10 +2,5 @@
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="BooleanMethodIsAlwaysInverted" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="WeakerAccess" enabled="false" level="WARNING" enabled_by_default="false">
|
||||
<option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="true" />
|
||||
<option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="true" />
|
||||
<option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
@ -8,8 +8,8 @@ android {
|
||||
applicationId 'org.nuclearfog.twidda'
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
versionCode 6
|
||||
versionName '1.6'
|
||||
versionCode 7
|
||||
versionName '1.6.1'
|
||||
vectorDrawables.useSupportLibrary true
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ import com.squareup.picasso.Picasso;
|
||||
import org.nuclearfog.tag.Tagger;
|
||||
import org.nuclearfog.tag.Tagger.OnTagClickListener;
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.helper.TimeFormat;
|
||||
import org.nuclearfog.twidda.backend.helper.StringTools;
|
||||
import org.nuclearfog.twidda.backend.items.Message;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
@ -96,7 +96,7 @@ public class MessageAdapter extends Adapter<MessageAdapter.MessageHolder> {
|
||||
vh.message.setLinkTextColor(highlight);
|
||||
vh.username.setText(message.getSender().getUsername());
|
||||
vh.screenname.setText(message.getSender().getScreenname());
|
||||
vh.createdAt.setText(TimeFormat.getString(message.getTime()));
|
||||
vh.createdAt.setText(StringTools.getString(message.getTime()));
|
||||
vh.receivername.setText(message.getReceiver().getScreenname());
|
||||
vh.message.setTextColor(fontColor);
|
||||
vh.username.setTextColor(fontColor);
|
||||
|
@ -18,7 +18,7 @@ import com.squareup.picasso.Picasso;
|
||||
|
||||
import org.nuclearfog.tag.Tagger;
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.helper.TimeFormat;
|
||||
import org.nuclearfog.twidda.backend.helper.StringTools;
|
||||
import org.nuclearfog.twidda.backend.items.Tweet;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
@ -141,7 +141,7 @@ public class TweetAdapter extends Adapter<TweetAdapter.ItemHolder> {
|
||||
vh.tweet.setText(text);
|
||||
vh.retweet.setText(formatter.format(tweet.getRetweetCount()));
|
||||
vh.favorite.setText(formatter.format(tweet.getFavorCount()));
|
||||
vh.time.setText(TimeFormat.getString(tweet.getTime()));
|
||||
vh.time.setText(StringTools.getString(tweet.getTime()));
|
||||
vh.username.setTextColor(font_color);
|
||||
vh.screenname.setTextColor(font_color);
|
||||
vh.tweet.setTextColor(font_color);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.nuclearfog.twidda.fragment.backend;
|
||||
package org.nuclearfog.twidda.backend;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
@ -6,7 +6,6 @@ import android.widget.Toast;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.adapter.MessageAdapter;
|
||||
import org.nuclearfog.twidda.backend.TwitterEngine;
|
||||
import org.nuclearfog.twidda.backend.items.Message;
|
||||
import org.nuclearfog.twidda.database.AppDatabase;
|
||||
import org.nuclearfog.twidda.fragment.MessageListFragment;
|
@ -138,6 +138,8 @@ public class StatusLoader extends AsyncTask<Long, Tweet, Tweet> {
|
||||
if (twException.statusNotFound())
|
||||
ui.get().setResult(RETURN_TWEET_CHANGED);
|
||||
ui.get().finish();
|
||||
} else if (!ui.get().tweetSet()) {
|
||||
ui.get().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.nuclearfog.twidda.fragment.backend;
|
||||
package org.nuclearfog.twidda.backend;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
@ -7,7 +7,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.adapter.TrendAdapter;
|
||||
import org.nuclearfog.twidda.backend.TwitterEngine;
|
||||
import org.nuclearfog.twidda.database.AppDatabase;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.fragment.TrendListFragment;
|
@ -1,4 +1,4 @@
|
||||
package org.nuclearfog.twidda.fragment.backend;
|
||||
package org.nuclearfog.twidda.backend;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
@ -6,7 +6,6 @@ import android.widget.Toast;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.adapter.TweetAdapter;
|
||||
import org.nuclearfog.twidda.backend.TwitterEngine;
|
||||
import org.nuclearfog.twidda.backend.items.Tweet;
|
||||
import org.nuclearfog.twidda.database.AppDatabase;
|
||||
import org.nuclearfog.twidda.fragment.TweetListFragment;
|
@ -102,7 +102,7 @@ public class TwitterEngine {
|
||||
* @return Link to App Registration
|
||||
* @throws EngineException if internet connection is unavailable
|
||||
*/
|
||||
public String request() throws EngineException {
|
||||
String request() throws EngineException {
|
||||
try {
|
||||
if (reqToken == null) {
|
||||
reqToken = twitter.getOAuthRequestToken();
|
||||
@ -122,7 +122,7 @@ public class TwitterEngine {
|
||||
* @throws EngineException if pin is false or request token is null
|
||||
* @see #initKeys(String, String)
|
||||
*/
|
||||
public void initialize(String twitterPin) throws EngineException {
|
||||
void initialize(String twitterPin) throws EngineException {
|
||||
try {
|
||||
if (reqToken != null) {
|
||||
AccessToken accessToken = twitter.getOAuthAccessToken(reqToken, twitterPin);
|
||||
@ -171,7 +171,7 @@ public class TwitterEngine {
|
||||
* @return List of Tweets
|
||||
* @throws EngineException if access is unavailable
|
||||
*/
|
||||
public List<Tweet> getHome(int page, long lastId) throws EngineException {
|
||||
List<Tweet> getHome(int page, long lastId) throws EngineException {
|
||||
try {
|
||||
List<Status> homeTweets = twitter.getHomeTimeline(new Paging(page, load, lastId));
|
||||
return convertStatusList(homeTweets);
|
||||
@ -189,7 +189,7 @@ public class TwitterEngine {
|
||||
* @return List of Mention Tweets
|
||||
* @throws EngineException if access is unavailable
|
||||
*/
|
||||
public List<Tweet> getMention(int page, long id) throws EngineException {
|
||||
List<Tweet> getMention(int page, long id) throws EngineException {
|
||||
try {
|
||||
List<Status> mentions = twitter.getMentionsTimeline(new Paging(page, load, id));
|
||||
return convertStatusList(mentions);
|
||||
@ -207,7 +207,7 @@ public class TwitterEngine {
|
||||
* @return List of Tweets
|
||||
* @throws EngineException if acces is unavailable
|
||||
*/
|
||||
public List<Tweet> searchTweets(String search, long id) throws EngineException {
|
||||
List<Tweet> searchTweets(String search, long id) throws EngineException {
|
||||
try {
|
||||
Query q = new Query();
|
||||
q.setQuery(search + " +exclude:retweets");
|
||||
@ -229,7 +229,7 @@ public class TwitterEngine {
|
||||
* @return Trend Resource
|
||||
* @throws EngineException if access is unavailable
|
||||
*/
|
||||
public List<String> getTrends(int woeId) throws EngineException {
|
||||
List<String> getTrends(int woeId) throws EngineException {
|
||||
try {
|
||||
List<String> result = new LinkedList<>();
|
||||
Trend[] trends = twitter.getPlaceTrends(woeId).getTrends();
|
||||
@ -248,7 +248,7 @@ public class TwitterEngine {
|
||||
* @return list of locations
|
||||
* @throws EngineException if access is unavailable
|
||||
*/
|
||||
public List<TrendLocation> getLocations() throws EngineException {
|
||||
List<TrendLocation> getLocations() throws EngineException {
|
||||
try {
|
||||
List<TrendLocation> result = new LinkedList<>();
|
||||
List<Location> locations = twitter.getAvailableTrends();
|
||||
@ -268,7 +268,7 @@ public class TwitterEngine {
|
||||
* @return List of Users
|
||||
* @throws EngineException if access is unavailable
|
||||
*/
|
||||
public List<TwitterUser> searchUsers(String search) throws EngineException {
|
||||
List<TwitterUser> searchUsers(String search) throws EngineException {
|
||||
try {
|
||||
return convertUserList(twitter.searchUsers(search, -1));
|
||||
} catch (TwitterException err) {
|
||||
@ -286,7 +286,7 @@ public class TwitterEngine {
|
||||
* @return List of User Tweets
|
||||
* @throws EngineException if access is unavailable
|
||||
*/
|
||||
public List<Tweet> getUserTweets(long userId, long sinceId, long page) throws EngineException {
|
||||
List<Tweet> getUserTweets(long userId, long sinceId, long page) throws EngineException {
|
||||
try {
|
||||
Paging paging = new Paging((int) page, load, sinceId);
|
||||
return convertStatusList(twitter.getUserTimeline(userId, paging));
|
||||
@ -305,7 +305,7 @@ public class TwitterEngine {
|
||||
* @return List of User Favs
|
||||
* @throws EngineException if access is unavailable
|
||||
*/
|
||||
public List<Tweet> getUserFavs(long userId, long sinceId, long page) throws EngineException {
|
||||
List<Tweet> getUserFavs(long userId, long sinceId, long page) throws EngineException {
|
||||
try {
|
||||
Paging paging = new Paging((int) page, load, sinceId);
|
||||
List<Status> favorits = twitter.getFavorites(userId, paging);
|
||||
@ -323,7 +323,7 @@ public class TwitterEngine {
|
||||
* @return User Object
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public TwitterUser getUser(long userId) throws EngineException {
|
||||
TwitterUser getUser(long userId) throws EngineException {
|
||||
try {
|
||||
return new TwitterUser(twitter.showUser(userId));
|
||||
} catch (TwitterException err) {
|
||||
@ -338,7 +338,7 @@ public class TwitterEngine {
|
||||
* @return curent user
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public TwitterUser getCurrentUser() throws EngineException {
|
||||
TwitterUser getCurrentUser() throws EngineException {
|
||||
try {
|
||||
return new TwitterUser(twitter.showUser(twitterID));
|
||||
} catch (TwitterException err) {
|
||||
@ -354,7 +354,7 @@ public class TwitterEngine {
|
||||
* @return User Properties
|
||||
* @throws EngineException if Connection is unavailable
|
||||
*/
|
||||
public UserProperties getConnection(long userId) throws EngineException {
|
||||
UserProperties getConnection(long userId) throws EngineException {
|
||||
try {
|
||||
return new UserProperties(twitter.showFriendship(twitterID, userId));
|
||||
} catch (TwitterException err) {
|
||||
@ -370,7 +370,7 @@ public class TwitterEngine {
|
||||
* @return Twitter User
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public TwitterUser followUser(long userID) throws EngineException {
|
||||
TwitterUser followUser(long userID) throws EngineException {
|
||||
try {
|
||||
return new TwitterUser(twitter.createFriendship(userID));
|
||||
} catch (TwitterException err) {
|
||||
@ -386,7 +386,7 @@ public class TwitterEngine {
|
||||
* @return Twitter User
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public TwitterUser unfollowUser(long userID) throws EngineException {
|
||||
TwitterUser unfollowUser(long userID) throws EngineException {
|
||||
try {
|
||||
return new TwitterUser(twitter.destroyFriendship(userID));
|
||||
} catch (TwitterException err) {
|
||||
@ -402,7 +402,7 @@ public class TwitterEngine {
|
||||
* @return Twitter User
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public TwitterUser blockUser(long UserID) throws EngineException {
|
||||
TwitterUser blockUser(long UserID) throws EngineException {
|
||||
try {
|
||||
return new TwitterUser(twitter.createBlock(UserID));
|
||||
} catch (TwitterException err) {
|
||||
@ -418,7 +418,7 @@ public class TwitterEngine {
|
||||
* @return Twitter User
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public TwitterUser unblockUser(long UserID) throws EngineException {
|
||||
TwitterUser unblockUser(long UserID) throws EngineException {
|
||||
try {
|
||||
return new TwitterUser(twitter.destroyBlock(UserID));
|
||||
} catch (TwitterException err) {
|
||||
@ -434,7 +434,7 @@ public class TwitterEngine {
|
||||
* @return Twitter User
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public TwitterUser muteUser(long UserID) throws EngineException {
|
||||
TwitterUser muteUser(long UserID) throws EngineException {
|
||||
try {
|
||||
return new TwitterUser(twitter.createMute(UserID));
|
||||
} catch (TwitterException err) {
|
||||
@ -450,7 +450,7 @@ public class TwitterEngine {
|
||||
* @return Twitter User
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public TwitterUser unmuteUser(long UserID) throws EngineException {
|
||||
TwitterUser unmuteUser(long UserID) throws EngineException {
|
||||
try {
|
||||
return new TwitterUser(twitter.destroyMute(UserID));
|
||||
} catch (TwitterException err) {
|
||||
@ -466,7 +466,7 @@ public class TwitterEngine {
|
||||
* @return List of Following User
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public List<TwitterUser> getFollowing(long userId) throws EngineException {
|
||||
List<TwitterUser> getFollowing(long userId) throws EngineException {
|
||||
try {
|
||||
IDs userIDs = twitter.getFriendsIDs(userId, -1, load);
|
||||
long[] ids = userIDs.getIDs();
|
||||
@ -486,7 +486,7 @@ public class TwitterEngine {
|
||||
* @return List of Follower
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public List<TwitterUser> getFollower(long userId) throws EngineException {
|
||||
List<TwitterUser> getFollower(long userId) throws EngineException {
|
||||
try {
|
||||
IDs userIDs = twitter.getFollowersIDs(userId, -1, load);
|
||||
long[] ids = userIDs.getIDs();
|
||||
@ -505,7 +505,7 @@ public class TwitterEngine {
|
||||
* @param tweet Tweet holder
|
||||
* @throws EngineException if twitter service is unavailable or media was not found
|
||||
*/
|
||||
public void uploadStatus(TweetHolder tweet) throws EngineException {
|
||||
void uploadStatus(TweetHolder tweet) throws EngineException {
|
||||
try {
|
||||
StatusUpdate mStatus = new StatusUpdate(tweet.getText());
|
||||
if (tweet.isReply())
|
||||
@ -533,7 +533,7 @@ public class TwitterEngine {
|
||||
* @return Tweet Object
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public Tweet getStatus(long tweetId) throws EngineException {
|
||||
Tweet getStatus(long tweetId) throws EngineException {
|
||||
try {
|
||||
Status tweet = twitter.showStatus(tweetId);
|
||||
return new Tweet(tweet);
|
||||
@ -552,7 +552,7 @@ public class TwitterEngine {
|
||||
* @return List of Answers
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public List<Tweet> getAnswers(String name, long tweetId, long sinceId) throws EngineException {
|
||||
List<Tweet> getAnswers(String name, long tweetId, long sinceId) throws EngineException {
|
||||
try {
|
||||
List<Status> answers = new LinkedList<>();
|
||||
Query query = new Query("to:" + name + " since_id:" + sinceId + " +exclude:retweets");
|
||||
@ -577,7 +577,7 @@ public class TwitterEngine {
|
||||
* @param tweetId Tweet ID
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public Tweet retweet(long tweetId) throws EngineException {
|
||||
Tweet retweet(long tweetId) throws EngineException {
|
||||
try {
|
||||
Status tweet = twitter.showStatus(tweetId);
|
||||
boolean retweeted = tweet.isRetweeted();
|
||||
@ -606,7 +606,7 @@ public class TwitterEngine {
|
||||
* @param tweetId Tweet ID
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public Tweet favorite(long tweetId) throws EngineException {
|
||||
Tweet favorite(long tweetId) throws EngineException {
|
||||
try {
|
||||
Status tweet = twitter.showStatus(tweetId);
|
||||
boolean retweeted = tweet.isRetweeted();
|
||||
@ -634,7 +634,7 @@ public class TwitterEngine {
|
||||
* @return dummy tweet
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public Tweet deleteTweet(long tweetId) throws EngineException {
|
||||
Tweet deleteTweet(long tweetId) throws EngineException {
|
||||
try {
|
||||
return new Tweet(twitter.destroyStatus(tweetId));
|
||||
} catch (TwitterException err) {
|
||||
@ -650,7 +650,7 @@ public class TwitterEngine {
|
||||
* @return List of users or empty list if no match
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public List<TwitterUser> getRetweeter(long tweetID) throws EngineException {
|
||||
List<TwitterUser> getRetweeter(long tweetID) throws EngineException {
|
||||
try {
|
||||
Tweet embeddedStat = getStatus(tweetID).getEmbeddedTweet();
|
||||
if (embeddedStat != null)
|
||||
@ -671,7 +671,7 @@ public class TwitterEngine {
|
||||
* @return DM List
|
||||
* @throws EngineException if access is unavailable
|
||||
*/
|
||||
public List<Message> getMessages() throws EngineException {
|
||||
List<Message> getMessages() throws EngineException {
|
||||
try {
|
||||
List<DirectMessage> dmList = twitter.getDirectMessages(load);
|
||||
List<Message> result = new LinkedList<>();
|
||||
@ -691,7 +691,7 @@ public class TwitterEngine {
|
||||
* @param messageHolder message informations
|
||||
* @throws EngineException if access is unavailable
|
||||
*/
|
||||
public void sendMessage(MessageHolder messageHolder) throws EngineException {
|
||||
void sendMessage(MessageHolder messageHolder) throws EngineException {
|
||||
try {
|
||||
long id = twitter.showUser(messageHolder.getUsername()).getId();
|
||||
if (messageHolder.hasMedia()) {
|
||||
@ -713,7 +713,7 @@ public class TwitterEngine {
|
||||
* @param id Message ID
|
||||
* @throws TwitterException if Access is unavailable
|
||||
*/
|
||||
public void deleteMessage(long id) throws TwitterException {
|
||||
void deleteMessage(long id) throws TwitterException {
|
||||
twitter.destroyDirectMessage(id);
|
||||
}
|
||||
|
||||
@ -725,7 +725,7 @@ public class TwitterEngine {
|
||||
* @return updated user profile
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public TwitterUser updateProfile(UserHolder userHolder) throws EngineException {
|
||||
TwitterUser updateProfile(UserHolder userHolder) throws EngineException {
|
||||
try {
|
||||
String username = userHolder.getName();
|
||||
String user_link = userHolder.getLink();
|
||||
@ -745,7 +745,7 @@ public class TwitterEngine {
|
||||
* @param path image path
|
||||
* @throws EngineException if Access is unavailable
|
||||
*/
|
||||
public void updateProfileImage(String path) throws EngineException {
|
||||
void updateProfileImage(String path) throws EngineException {
|
||||
try {
|
||||
File image = new File(path);
|
||||
twitter.updateProfileImage(image);
|
||||
@ -851,8 +851,8 @@ public class TwitterEngine {
|
||||
*/
|
||||
public class EngineException extends Exception {
|
||||
|
||||
public static final int FILENOTFOUND = 600;
|
||||
public static final int TOKENNOTSET = 601;
|
||||
private static final int FILENOTFOUND = 600;
|
||||
private static final int TOKENNOTSET = 601;
|
||||
|
||||
@StringRes
|
||||
private int messageResource;
|
||||
@ -864,7 +864,7 @@ public class TwitterEngine {
|
||||
*
|
||||
* @param error Twitter4J Exception
|
||||
*/
|
||||
public EngineException(TwitterException error) {
|
||||
private EngineException(TwitterException error) {
|
||||
super(error);
|
||||
switch (error.getErrorCode()) {
|
||||
case 88:
|
||||
@ -941,7 +941,7 @@ public class TwitterEngine {
|
||||
*
|
||||
* @param errorCode custom error code
|
||||
*/
|
||||
public EngineException(int errorCode) {
|
||||
private EngineException(int errorCode) {
|
||||
switch (errorCode) {
|
||||
case FILENOTFOUND:
|
||||
messageResource = R.string.error_media_not_found;
|
||||
@ -963,7 +963,7 @@ public class TwitterEngine {
|
||||
* @return string recource for
|
||||
*/
|
||||
@StringRes
|
||||
public int getMessageResource() {
|
||||
int getMessageResource() {
|
||||
return messageResource;
|
||||
}
|
||||
|
||||
@ -972,7 +972,7 @@ public class TwitterEngine {
|
||||
*
|
||||
* @return true if hard fault
|
||||
*/
|
||||
public boolean isHardFault() {
|
||||
boolean isHardFault() {
|
||||
return hardFault;
|
||||
}
|
||||
|
||||
@ -981,7 +981,7 @@ public class TwitterEngine {
|
||||
*
|
||||
* @return true if author or tweet not found
|
||||
*/
|
||||
public boolean statusNotFound() {
|
||||
boolean statusNotFound() {
|
||||
return statusNotFound;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.nuclearfog.twidda.fragment.backend;
|
||||
package org.nuclearfog.twidda.backend;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
@ -7,7 +7,6 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.adapter.UserAdapter;
|
||||
import org.nuclearfog.twidda.backend.TwitterEngine;
|
||||
import org.nuclearfog.twidda.backend.items.TwitterUser;
|
||||
import org.nuclearfog.twidda.fragment.UserListFragment;
|
||||
|
@ -2,7 +2,10 @@ package org.nuclearfog.twidda.backend.helper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public abstract class FilenameTools {
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public abstract class StringTools {
|
||||
|
||||
public enum FileType {
|
||||
IMAGE,
|
||||
@ -12,27 +15,26 @@ public abstract class FilenameTools {
|
||||
NONE
|
||||
}
|
||||
|
||||
private static String getExtension(@NonNull String path) {
|
||||
String filename = getFilename(path);
|
||||
String ext = "";
|
||||
int start = lastIndexOf(filename, '.') + 1;
|
||||
if (start > 0 && start < filename.length()) {
|
||||
int end = lastIndexOf(filename, '?');
|
||||
if (end > 0)
|
||||
ext = filename.substring(start, end);
|
||||
else
|
||||
ext = filename.substring(start);
|
||||
ext = asciiLowerCase(ext);
|
||||
public static String getString(long time) {
|
||||
long diff = new Date().getTime() - time;
|
||||
long seconds = diff / 1000;
|
||||
long minutes = seconds / 60;
|
||||
long hours = minutes / 60;
|
||||
long days = hours / 24;
|
||||
long weeks = days / 7;
|
||||
if (weeks > 4) {
|
||||
Date tweetDate = new Date(time);
|
||||
return SimpleDateFormat.getDateInstance().format(tweetDate);
|
||||
}
|
||||
return ext;
|
||||
}
|
||||
|
||||
private static String getFilename(@NonNull String path) {
|
||||
String filename = "";
|
||||
int end = lastIndexOf(path, '/') + 1;
|
||||
if (end > 0 && end < path.length())
|
||||
filename = path.substring(end);
|
||||
return filename;
|
||||
if (weeks > 0)
|
||||
return weeks + " w";
|
||||
if (days > 0)
|
||||
return days + " d";
|
||||
if (hours > 0)
|
||||
return hours + " h";
|
||||
if (minutes > 0)
|
||||
return minutes + " m";
|
||||
return seconds + " s";
|
||||
}
|
||||
|
||||
public static FileType getFileType(String path) {
|
||||
@ -58,6 +60,29 @@ public abstract class FilenameTools {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getExtension(@NonNull String path) {
|
||||
String filename = getFilename(path);
|
||||
String ext = "";
|
||||
int start = lastIndexOf(filename, '.') + 1;
|
||||
if (start > 0 && start < filename.length()) {
|
||||
int end = lastIndexOf(filename, '?');
|
||||
if (end > 0)
|
||||
ext = filename.substring(start, end);
|
||||
else
|
||||
ext = filename.substring(start);
|
||||
ext = asciiLowerCase(ext);
|
||||
}
|
||||
return ext;
|
||||
}
|
||||
|
||||
private static String getFilename(@NonNull String path) {
|
||||
String filename = "";
|
||||
int end = lastIndexOf(path, '/') + 1;
|
||||
if (end > 0 && end < path.length())
|
||||
filename = path.substring(end);
|
||||
return filename;
|
||||
}
|
||||
|
||||
private static String asciiLowerCase(String ext) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int index = 0; index < ext.length(); index++) {
|
@ -1,29 +0,0 @@
|
||||
package org.nuclearfog.twidda.backend.helper;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public abstract class TimeFormat {
|
||||
|
||||
public static String getString(long time) {
|
||||
long diff = new Date().getTime() - time;
|
||||
long seconds = diff / 1000;
|
||||
long minutes = seconds / 60;
|
||||
long hours = minutes / 60;
|
||||
long days = hours / 24;
|
||||
long weeks = days / 7;
|
||||
if (weeks > 4) {
|
||||
Date tweetDate = new Date(time);
|
||||
return SimpleDateFormat.getDateInstance().format(tweetDate);
|
||||
}
|
||||
if (weeks > 0)
|
||||
return weeks + " w";
|
||||
if (days > 0)
|
||||
return days + " d";
|
||||
if (hours > 0)
|
||||
return hours + " h";
|
||||
if (minutes > 0)
|
||||
return minutes + " m";
|
||||
return seconds + " s";
|
||||
}
|
||||
}
|
@ -4,8 +4,8 @@ import android.location.Location;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.nuclearfog.twidda.backend.helper.FilenameTools;
|
||||
import org.nuclearfog.twidda.backend.helper.FilenameTools.FileType;
|
||||
import org.nuclearfog.twidda.backend.helper.StringTools;
|
||||
import org.nuclearfog.twidda.backend.helper.StringTools.FileType;
|
||||
|
||||
public class TweetHolder {
|
||||
|
||||
@ -26,7 +26,7 @@ public class TweetHolder {
|
||||
|
||||
|
||||
public void addMedia(String[] mediaLinks) {
|
||||
FileType type = FilenameTools.getFileType(mediaLinks[0]);
|
||||
FileType type = StringTools.getFileType(mediaLinks[0]);
|
||||
|
||||
switch (type) {
|
||||
case VIDEO:
|
||||
|
@ -16,10 +16,10 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener;
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.adapter.MessageAdapter;
|
||||
import org.nuclearfog.twidda.adapter.MessageAdapter.OnItemSelected;
|
||||
import org.nuclearfog.twidda.backend.MessageLoader;
|
||||
import org.nuclearfog.twidda.backend.MessageLoader.Mode;
|
||||
import org.nuclearfog.twidda.backend.items.Message;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.fragment.backend.MessageLoader;
|
||||
import org.nuclearfog.twidda.fragment.backend.MessageLoader.Mode;
|
||||
import org.nuclearfog.twidda.window.MessagePopup;
|
||||
import org.nuclearfog.twidda.window.SearchPage;
|
||||
import org.nuclearfog.twidda.window.UserProfile;
|
||||
@ -127,7 +127,7 @@ public class MessageListFragment extends Fragment implements OnRefreshListener,
|
||||
reload.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (messageTask.getStatus() != FINISHED)
|
||||
if (messageTask.getStatus() != FINISHED && !reload.isRefreshing())
|
||||
reload.setRefreshing(true);
|
||||
}
|
||||
}, 500);
|
||||
|
@ -17,8 +17,8 @@ import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.adapter.FragmentAdapter.FragmentChangeObserver;
|
||||
import org.nuclearfog.twidda.adapter.OnItemClickListener;
|
||||
import org.nuclearfog.twidda.adapter.TrendAdapter;
|
||||
import org.nuclearfog.twidda.backend.TrendLoader;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.fragment.backend.TrendLoader;
|
||||
import org.nuclearfog.twidda.window.SearchPage;
|
||||
|
||||
import static android.os.AsyncTask.Status.FINISHED;
|
||||
@ -124,7 +124,7 @@ public class TrendListFragment extends Fragment implements OnRefreshListener, On
|
||||
reload.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (trendTask.getStatus() != FINISHED)
|
||||
if (trendTask.getStatus() != FINISHED && !reload.isRefreshing())
|
||||
reload.setRefreshing(true);
|
||||
}
|
||||
}, 500);
|
||||
|
@ -17,10 +17,10 @@ import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.adapter.FragmentAdapter.FragmentChangeObserver;
|
||||
import org.nuclearfog.twidda.adapter.OnItemClickListener;
|
||||
import org.nuclearfog.twidda.adapter.TweetAdapter;
|
||||
import org.nuclearfog.twidda.backend.TweetLoader;
|
||||
import org.nuclearfog.twidda.backend.TweetLoader.Mode;
|
||||
import org.nuclearfog.twidda.backend.items.Tweet;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.fragment.backend.TweetLoader;
|
||||
import org.nuclearfog.twidda.fragment.backend.TweetLoader.Mode;
|
||||
import org.nuclearfog.twidda.window.TweetDetail;
|
||||
|
||||
import static android.os.AsyncTask.Status.FINISHED;
|
||||
@ -169,7 +169,7 @@ public class TweetListFragment extends Fragment implements OnRefreshListener, On
|
||||
reload.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (tweetTask.getStatus() != FINISHED)
|
||||
if (tweetTask.getStatus() != FINISHED && !reload.isRefreshing())
|
||||
reload.setRefreshing(true);
|
||||
}
|
||||
}, 500);
|
||||
|
@ -18,10 +18,10 @@ import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.adapter.FragmentAdapter.FragmentChangeObserver;
|
||||
import org.nuclearfog.twidda.adapter.OnItemClickListener;
|
||||
import org.nuclearfog.twidda.adapter.UserAdapter;
|
||||
import org.nuclearfog.twidda.backend.UserLoader;
|
||||
import org.nuclearfog.twidda.backend.UserLoader.Mode;
|
||||
import org.nuclearfog.twidda.backend.items.TwitterUser;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.fragment.backend.UserLoader;
|
||||
import org.nuclearfog.twidda.fragment.backend.UserLoader.Mode;
|
||||
import org.nuclearfog.twidda.window.UserProfile;
|
||||
|
||||
import static android.os.AsyncTask.Status.FINISHED;
|
||||
@ -145,7 +145,7 @@ public class UserListFragment extends Fragment implements OnRefreshListener, OnI
|
||||
reload.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (userTask.getStatus() != FINISHED)
|
||||
if (userTask.getStatus() != FINISHED && !reload.isRefreshing())
|
||||
reload.setRefreshing(true);
|
||||
}
|
||||
}, 500);
|
||||
|
@ -43,7 +43,7 @@ import org.nuclearfog.twidda.adapter.FragmentAdapter;
|
||||
import org.nuclearfog.twidda.adapter.FragmentAdapter.AdapterType;
|
||||
import org.nuclearfog.twidda.backend.StatusLoader;
|
||||
import org.nuclearfog.twidda.backend.StatusLoader.Action;
|
||||
import org.nuclearfog.twidda.backend.helper.FilenameTools;
|
||||
import org.nuclearfog.twidda.backend.helper.StringTools;
|
||||
import org.nuclearfog.twidda.backend.items.Tweet;
|
||||
import org.nuclearfog.twidda.backend.items.TwitterUser;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
@ -368,7 +368,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
}
|
||||
if (tweet.hasMedia()) {
|
||||
String[] links = tweet.getMediaLinks();
|
||||
FilenameTools.FileType ext = FilenameTools.getFileType(links[0]);
|
||||
StringTools.FileType ext = StringTools.getFileType(links[0]);
|
||||
switch (ext) {
|
||||
case IMAGE:
|
||||
imageButton.setVisibility(VISIBLE);
|
||||
@ -445,6 +445,11 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
}
|
||||
|
||||
|
||||
public boolean tweetSet() {
|
||||
return tweet != null;
|
||||
}
|
||||
|
||||
|
||||
private void getTweet(@NonNull Uri link) {
|
||||
String path = link.getPath() == null ? "" : link.getPath();
|
||||
Matcher linkMatch = linkPattern.matcher(path);
|
||||
|
@ -23,8 +23,8 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.StatusUploader;
|
||||
import org.nuclearfog.twidda.backend.helper.FilenameTools;
|
||||
import org.nuclearfog.twidda.backend.helper.FilenameTools.FileType;
|
||||
import org.nuclearfog.twidda.backend.helper.StringTools;
|
||||
import org.nuclearfog.twidda.backend.helper.StringTools.FileType;
|
||||
import org.nuclearfog.twidda.backend.items.TweetHolder;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
|
||||
@ -140,7 +140,7 @@ public class TweetPopup extends AppCompatActivity implements OnClickListener, Lo
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
int index = cursor.getColumnIndex(GET_MEDIA[0]);
|
||||
String path = cursor.getString(index);
|
||||
FileType type = FilenameTools.getFileType(path);
|
||||
FileType type = StringTools.getFileType(path);
|
||||
|
||||
switch (type) {
|
||||
case IMAGE:
|
||||
|
@ -6,7 +6,7 @@ buildscript {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.2'
|
||||
classpath 'com.android.tools.build:gradle:3.5.3'
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user