mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-30 19:05:02 +01:00
renamed classes, added comments
This commit is contained in:
parent
19bc587e0e
commit
19f3d2fbff
@ -34,7 +34,7 @@ import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.adapter.FontAdapter;
|
||||
import org.nuclearfog.twidda.adapter.LocationAdapter;
|
||||
import org.nuclearfog.twidda.backend.LocationLoader;
|
||||
import org.nuclearfog.twidda.backend.LocationListLoader;
|
||||
import org.nuclearfog.twidda.backend.TwitterEngine;
|
||||
import org.nuclearfog.twidda.backend.helper.FontTool;
|
||||
import org.nuclearfog.twidda.backend.items.TrendLocation;
|
||||
@ -64,7 +64,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
|
||||
}
|
||||
|
||||
private GlobalSettings settings;
|
||||
private LocationLoader locationAsync;
|
||||
private LocationListLoader locationAsync;
|
||||
private Button colorButton1, colorButton2, colorButton3, colorButton4;
|
||||
private EditText proxyAddr, proxyPort, proxyUser, proxyPass;
|
||||
private NumberPicker load_picker;
|
||||
@ -161,7 +161,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (settings.getLogin() && locationAdapter.getCount() <= 1) {
|
||||
locationAsync = new LocationLoader(this);
|
||||
locationAsync = new LocationListLoader(this);
|
||||
locationAsync.execute();
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ import org.nuclearfog.tag.Tagger.OnTagClickListener;
|
||||
import org.nuclearfog.twidda.R;
|
||||
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.TweetLoader;
|
||||
import org.nuclearfog.twidda.backend.TweetLoader.Action;
|
||||
import org.nuclearfog.twidda.backend.helper.FontTool;
|
||||
import org.nuclearfog.twidda.backend.helper.StringTools;
|
||||
import org.nuclearfog.twidda.backend.items.Tweet;
|
||||
@ -72,7 +72,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
public static final String KEY_TWEET_NAME = "username";
|
||||
public static final Pattern linkPattern = Pattern.compile(".*/@?[\\w_]+/status/\\d{1,20}/?.*");
|
||||
|
||||
private StatusLoader statusAsync;
|
||||
private TweetLoader statusAsync;
|
||||
private GlobalSettings settings;
|
||||
|
||||
private View header, footer, videoButton, imageButton;
|
||||
@ -148,7 +148,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (statusAsync == null) {
|
||||
statusAsync = new StatusLoader(this, Action.LOAD);
|
||||
statusAsync = new TweetLoader(this, Action.LOAD);
|
||||
statusAsync.execute(tweetID);
|
||||
}
|
||||
}
|
||||
@ -187,7 +187,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
deleteDialog.setPositiveButton(R.string.confirm_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
statusAsync = new StatusLoader(TweetDetail.this, Action.DELETE);
|
||||
statusAsync = new TweetLoader(TweetDetail.this, Action.DELETE);
|
||||
statusAsync.execute(tweetID);
|
||||
}
|
||||
});
|
||||
@ -299,13 +299,13 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
if (statusAsync != null && statusAsync.getStatus() != RUNNING) {
|
||||
switch (v.getId()) {
|
||||
case R.id.tweet_retweet:
|
||||
statusAsync = new StatusLoader(this, Action.RETWEET);
|
||||
statusAsync = new TweetLoader(this, Action.RETWEET);
|
||||
statusAsync.execute(tweetID);
|
||||
Toast.makeText(this, R.string.info_loading, LENGTH_SHORT).show();
|
||||
return true;
|
||||
|
||||
case R.id.tweet_favorit:
|
||||
statusAsync = new StatusLoader(this, Action.FAVORITE);
|
||||
statusAsync = new TweetLoader(this, Action.FAVORITE);
|
||||
statusAsync.execute(tweetID);
|
||||
Toast.makeText(this, R.string.info_loading, LENGTH_SHORT).show();
|
||||
return true;
|
||||
|
@ -23,7 +23,7 @@ import androidx.appcompat.app.AlertDialog.Builder;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.StatusUploader;
|
||||
import org.nuclearfog.twidda.backend.TweetUploader;
|
||||
import org.nuclearfog.twidda.backend.helper.FontTool;
|
||||
import org.nuclearfog.twidda.backend.helper.StringTools;
|
||||
import org.nuclearfog.twidda.backend.helper.StringTools.FileType;
|
||||
@ -71,7 +71,7 @@ public class TweetPopup extends AppCompatActivity implements OnClickListener, Lo
|
||||
|
||||
@Nullable
|
||||
private LocationManager mLocation;
|
||||
private StatusUploader uploaderAsync;
|
||||
private TweetUploader uploaderAsync;
|
||||
private Location location;
|
||||
private List<String> mediaPath;
|
||||
private View mediaBtn, previewBtn, locationProg, locationBtn;
|
||||
@ -219,7 +219,7 @@ public class TweetPopup extends AppCompatActivity implements OnClickListener, Lo
|
||||
tweet.addMedia(mediaPath.toArray(new String[0]));
|
||||
if (location != null)
|
||||
tweet.addLocation(location);
|
||||
uploaderAsync = new StatusUploader(this, tweet);
|
||||
uploaderAsync = new TweetUploader(this, tweet);
|
||||
uploaderAsync.execute();
|
||||
}
|
||||
break;
|
||||
@ -300,7 +300,7 @@ public class TweetPopup extends AppCompatActivity implements OnClickListener, Lo
|
||||
.setPositiveButton(R.string.confirm_retry, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
uploaderAsync = new StatusUploader(TweetPopup.this, tweet);
|
||||
uploaderAsync = new TweetUploader(TweetPopup.this, tweet);
|
||||
uploaderAsync.execute();
|
||||
}
|
||||
})
|
||||
|
@ -16,6 +16,7 @@ import java.net.URL;
|
||||
|
||||
/**
|
||||
* Background task to load images from twitter and storage
|
||||
* @see MediaViewer
|
||||
*/
|
||||
public class ImageLoader extends AsyncTask<String, Bitmap, Boolean> {
|
||||
|
||||
|
@ -14,9 +14,10 @@ import java.util.List;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
/**
|
||||
* Background task to load location information used by twitter
|
||||
* Background task to load location information used by twitter such as location names and world ID's
|
||||
* @see AppSettings
|
||||
*/
|
||||
public class LocationLoader extends AsyncTask<Void, Void, List<TrendLocation>> {
|
||||
public class LocationListLoader extends AsyncTask<Void, Void, List<TrendLocation>> {
|
||||
|
||||
@Nullable
|
||||
private TwitterEngine.EngineException twException;
|
||||
@ -24,12 +25,7 @@ public class LocationLoader extends AsyncTask<Void, Void, List<TrendLocation>> {
|
||||
private TwitterEngine mTwitter;
|
||||
|
||||
|
||||
/**
|
||||
* load location data from twitter
|
||||
*
|
||||
* @param context Activity context
|
||||
*/
|
||||
public LocationLoader(AppSettings context) {
|
||||
public LocationListLoader(AppSettings context) {
|
||||
ui = new WeakReference<>(context);
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
}
|
@ -16,7 +16,12 @@ import java.util.List;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
|
||||
public class MessageLoader extends AsyncTask<Long, Void, List<Message>> {
|
||||
/**
|
||||
* task to download a direct message list from twitter and handle message actions
|
||||
*
|
||||
* @see MessageFragment
|
||||
*/
|
||||
public class MessageListLoader extends AsyncTask<Long, Void, List<Message>> {
|
||||
|
||||
public enum Mode {
|
||||
DB,
|
||||
@ -34,7 +39,7 @@ public class MessageLoader extends AsyncTask<Long, Void, List<Message>> {
|
||||
private long id;
|
||||
|
||||
|
||||
public MessageLoader(MessageFragment fragment, Mode mode) {
|
||||
public MessageListLoader(MessageFragment fragment, Mode mode) {
|
||||
ui = new WeakReference<>(fragment);
|
||||
db = new AppDatabase(fragment.getContext());
|
||||
mTwitter = TwitterEngine.getInstance(fragment.getContext());
|
||||
@ -108,14 +113,4 @@ public class MessageLoader extends AsyncTask<Long, Void, List<Message>> {
|
||||
if (ui.get() != null)
|
||||
ui.get().setRefresh(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCancelled(@Nullable List<Message> messages) {
|
||||
if (ui.get() != null) {
|
||||
if (messages != null)
|
||||
adapter.replaceAll(messages);
|
||||
ui.get().setRefresh(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,8 @@ import java.lang.ref.WeakReference;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
/**
|
||||
* Background task to send direct messages
|
||||
* Background task to send a direct messages to a user
|
||||
* @see MessagePopup
|
||||
*/
|
||||
public class MessageUploader extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
|
@ -17,7 +17,8 @@ import java.lang.ref.WeakReference;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
/**
|
||||
* Twitter profile page loader
|
||||
* task for loading user profile information and take actions
|
||||
* @see UserProfile
|
||||
*/
|
||||
public class ProfileLoader extends AsyncTask<Long, TwitterUser, UserProperties> {
|
||||
|
||||
|
@ -21,6 +21,11 @@ import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.nuclearfog.twidda.activity.UserProfile.RETURN_PROFILE_CHANGED;
|
||||
|
||||
|
||||
/**
|
||||
* Task for editing profile information and updating images
|
||||
*
|
||||
* @see ProfileEditor
|
||||
*/
|
||||
public class ProfileUpdater extends AsyncTask<Void, Void, TwitterUser> {
|
||||
|
||||
private WeakReference<ProfileEditor> ui;
|
||||
@ -31,11 +36,6 @@ public class ProfileUpdater extends AsyncTask<Void, Void, TwitterUser> {
|
||||
private AppDatabase db;
|
||||
|
||||
|
||||
/**
|
||||
* Read User settings from server
|
||||
*
|
||||
* @param context Activity context
|
||||
*/
|
||||
public ProfileUpdater(ProfileEditor context) {
|
||||
ui = new WeakReference<>(context);
|
||||
popup = new WeakReference<>(new Dialog(context));
|
||||
@ -44,12 +44,6 @@ public class ProfileUpdater extends AsyncTask<Void, Void, TwitterUser> {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write User settings to server
|
||||
*
|
||||
* @param context Activity context
|
||||
* @param userHolder user data
|
||||
*/
|
||||
public ProfileUpdater(ProfileEditor context, UserHolder userHolder) {
|
||||
this(context);
|
||||
this.userHolder = userHolder;
|
||||
|
@ -14,7 +14,8 @@ import java.lang.ref.WeakReference;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
/**
|
||||
* Background task for app login
|
||||
* Background task to connect to twitter and initialize keys
|
||||
* @see LoginPage
|
||||
*/
|
||||
public class Registration extends AsyncTask<String, Void, String> {
|
||||
|
||||
|
@ -1,147 +0,0 @@
|
||||
package org.nuclearfog.twidda.backend;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.activity.TweetDetail;
|
||||
import org.nuclearfog.twidda.backend.items.Tweet;
|
||||
import org.nuclearfog.twidda.database.AppDatabase;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.nuclearfog.twidda.fragment.TweetFragment.RETURN_TWEET_CHANGED;
|
||||
|
||||
|
||||
public class StatusLoader extends AsyncTask<Long, Tweet, Tweet> {
|
||||
|
||||
public enum Action {
|
||||
LOAD,
|
||||
RETWEET,
|
||||
FAVORITE,
|
||||
DELETE
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TwitterEngine.EngineException twException;
|
||||
private TwitterEngine mTwitter;
|
||||
private WeakReference<TweetDetail> ui;
|
||||
private AppDatabase db;
|
||||
private final Action action;
|
||||
|
||||
|
||||
public StatusLoader(@NonNull TweetDetail context, Action action) {
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
db = new AppDatabase(context);
|
||||
ui = new WeakReference<>(context);
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Tweet doInBackground(Long[] data) {
|
||||
Tweet tweet = null;
|
||||
long tweetId = data[0];
|
||||
boolean updateStatus = false;
|
||||
try {
|
||||
switch (action) {
|
||||
case LOAD:
|
||||
tweet = db.getStatus(tweetId);
|
||||
if (tweet != null) {
|
||||
publishProgress(tweet);
|
||||
updateStatus = true;
|
||||
}
|
||||
tweet = mTwitter.getStatus(tweetId);
|
||||
publishProgress(tweet);
|
||||
if (updateStatus)
|
||||
db.updateStatus(tweet);
|
||||
break;
|
||||
|
||||
case DELETE:
|
||||
tweet = mTwitter.deleteTweet(tweetId);
|
||||
db.removeStatus(tweetId);
|
||||
break;
|
||||
|
||||
case RETWEET:
|
||||
tweet = mTwitter.retweet(tweetId);
|
||||
publishProgress(tweet);
|
||||
|
||||
if (!tweet.retweeted())
|
||||
db.removeRetweet(tweetId);
|
||||
db.updateStatus(tweet);
|
||||
break;
|
||||
|
||||
case FAVORITE:
|
||||
tweet = mTwitter.favorite(tweetId);
|
||||
publishProgress(tweet);
|
||||
|
||||
if (tweet.favored())
|
||||
db.storeFavorite(tweet);
|
||||
else
|
||||
db.removeFavorite(tweetId);
|
||||
break;
|
||||
}
|
||||
} catch (TwitterEngine.EngineException twException) {
|
||||
this.twException = twException;
|
||||
if (twException.statusNotFound()) {
|
||||
db.removeStatus(tweetId);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return tweet;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(Tweet[] tweets) {
|
||||
Tweet tweet = tweets[0];
|
||||
if (ui.get() != null && tweet != null) {
|
||||
ui.get().setTweet(tweet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(@Nullable Tweet tweet) {
|
||||
if (ui.get() != null) {
|
||||
if (tweet != null) {
|
||||
switch (action) {
|
||||
case RETWEET:
|
||||
if (tweet.retweeted())
|
||||
Toast.makeText(ui.get(), R.string.info_tweet_retweeted, LENGTH_SHORT).show();
|
||||
else
|
||||
Toast.makeText(ui.get(), R.string.info_tweet_unretweeted, LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
case FAVORITE:
|
||||
if (tweet.favored())
|
||||
Toast.makeText(ui.get(), R.string.info_tweet_favored, LENGTH_SHORT).show();
|
||||
else
|
||||
Toast.makeText(ui.get(), R.string.info_tweet_unfavored, LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
case DELETE:
|
||||
Toast.makeText(ui.get(), R.string.info_tweet_removed, LENGTH_SHORT).show();
|
||||
ui.get().setResult(RETURN_TWEET_CHANGED);
|
||||
ui.get().finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (twException != null) {
|
||||
Toast.makeText(ui.get(), twException.getMessageResource(), LENGTH_SHORT).show();
|
||||
if (twException.isHardFault()) {
|
||||
if (twException.statusNotFound())
|
||||
ui.get().setResult(RETURN_TWEET_CHANGED);
|
||||
ui.get().finish();
|
||||
} else {
|
||||
ui.get().finishIfEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,12 @@ import java.util.List;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
|
||||
public class TrendLoader extends AsyncTask<Integer, Void, List<TwitterTrend>> {
|
||||
/**
|
||||
* Background task to load a list of location specific trends
|
||||
*
|
||||
* @see TrendFragment
|
||||
*/
|
||||
public class TrendListLoader extends AsyncTask<Integer, Void, List<TwitterTrend>> {
|
||||
|
||||
@Nullable
|
||||
private TwitterEngine.EngineException twException;
|
||||
@ -27,7 +32,7 @@ public class TrendLoader extends AsyncTask<Integer, Void, List<TwitterTrend>> {
|
||||
private TrendAdapter adapter;
|
||||
|
||||
|
||||
public TrendLoader(@NonNull TrendFragment fragment) {
|
||||
public TrendListLoader(@NonNull TrendFragment fragment) {
|
||||
ui = new WeakReference<>(fragment);
|
||||
db = new AppDatabase(fragment.getContext());
|
||||
mTwitter = TwitterEngine.getInstance(fragment.getContext());
|
||||
@ -84,14 +89,4 @@ public class TrendLoader extends AsyncTask<Integer, Void, List<TwitterTrend>> {
|
||||
if (ui.get() != null)
|
||||
ui.get().setRefresh(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCancelled(@Nullable List<TwitterTrend> trends) {
|
||||
if (ui.get() != null) {
|
||||
if (trends != null)
|
||||
adapter.setData(trends);
|
||||
ui.get().setRefresh(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,199 @@
|
||||
package org.nuclearfog.twidda.backend;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.adapter.TweetAdapter;
|
||||
import org.nuclearfog.twidda.backend.items.Tweet;
|
||||
import org.nuclearfog.twidda.database.AppDatabase;
|
||||
import org.nuclearfog.twidda.fragment.TweetFragment;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
|
||||
/**
|
||||
* Background task to download a list of tweets from different sources
|
||||
*
|
||||
* @see TweetFragment
|
||||
*/
|
||||
public class TweetListLoader extends AsyncTask<Object, Void, List<Tweet>> {
|
||||
|
||||
public enum Mode {
|
||||
TL_HOME,
|
||||
TL_MENT,
|
||||
USR_TWEETS,
|
||||
USR_FAVORS,
|
||||
TWEET_ANS,
|
||||
DB_ANS,
|
||||
TWEET_SEARCH,
|
||||
LIST
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TwitterEngine.EngineException twException;
|
||||
private Mode mode;
|
||||
private WeakReference<TweetFragment> ui;
|
||||
private TweetAdapter adapter;
|
||||
private TwitterEngine mTwitter;
|
||||
private AppDatabase db;
|
||||
|
||||
|
||||
public TweetListLoader(TweetFragment fragment, Mode mode) {
|
||||
ui = new WeakReference<>(fragment);
|
||||
db = new AppDatabase(fragment.getContext());
|
||||
mTwitter = TwitterEngine.getInstance(fragment.getContext());
|
||||
adapter = fragment.getAdapter();
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
if (ui.get() != null) {
|
||||
ui.get().setRefresh(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<Tweet> doInBackground(Object[] param) {
|
||||
List<Tweet> tweets = null;
|
||||
long sinceId = 1;
|
||||
try {
|
||||
switch (mode) {
|
||||
case TL_HOME:
|
||||
int page = (int) param[0];
|
||||
if (adapter.isEmpty()) {
|
||||
tweets = db.getHomeTimeline();
|
||||
if (tweets.isEmpty()) {
|
||||
tweets = mTwitter.getHome(page, sinceId);
|
||||
db.storeHomeTimeline(tweets);
|
||||
}
|
||||
} else {
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.getHome(page, sinceId);
|
||||
db.storeHomeTimeline(tweets);
|
||||
}
|
||||
break;
|
||||
|
||||
case TL_MENT:
|
||||
page = (int) param[0];
|
||||
if (adapter.isEmpty()) {
|
||||
tweets = db.getMentions();
|
||||
if (tweets.isEmpty()) {
|
||||
tweets = mTwitter.getMention(page, sinceId);
|
||||
db.storeMentions(tweets);
|
||||
}
|
||||
} else {
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.getMention(page, sinceId);
|
||||
db.storeMentions(tweets);
|
||||
}
|
||||
break;
|
||||
|
||||
case USR_TWEETS:
|
||||
long id = (long) param[0];
|
||||
page = (int) param[1];
|
||||
if (adapter.isEmpty()) {
|
||||
tweets = db.getUserTweets(id);
|
||||
if (tweets.isEmpty()) {
|
||||
tweets = mTwitter.getUserTweets(id, sinceId, page);
|
||||
db.storeUserTweets(tweets);
|
||||
}
|
||||
} else {
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.getUserTweets(id, sinceId, page);
|
||||
db.storeUserTweets(tweets);
|
||||
}
|
||||
break;
|
||||
|
||||
case USR_FAVORS:
|
||||
id = (long) param[0];
|
||||
page = (int) param[1];
|
||||
if (adapter.isEmpty()) {
|
||||
tweets = db.getUserFavs(id);
|
||||
if (tweets.isEmpty()) {
|
||||
tweets = mTwitter.getUserFavs(id, page);
|
||||
db.storeUserFavs(tweets, id);
|
||||
}
|
||||
} else {
|
||||
tweets = mTwitter.getUserFavs(id, page);
|
||||
db.storeUserFavs(tweets, id);
|
||||
}
|
||||
break;
|
||||
|
||||
case DB_ANS:
|
||||
id = (long) param[0];
|
||||
tweets = db.getAnswers(id);
|
||||
break;
|
||||
|
||||
case TWEET_ANS:
|
||||
id = (long) param[0];
|
||||
String search = (String) param[1];
|
||||
if (adapter.isEmpty()) {
|
||||
tweets = db.getAnswers(id);
|
||||
if (tweets.isEmpty()) {
|
||||
tweets = mTwitter.getAnswers(search, id, sinceId);
|
||||
if (!tweets.isEmpty() && db.containStatus(id))
|
||||
db.storeReplies(tweets);
|
||||
}
|
||||
} else {
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.getAnswers(search, id, sinceId);
|
||||
if (!tweets.isEmpty() && db.containStatus(id))
|
||||
db.storeReplies(tweets);
|
||||
}
|
||||
break;
|
||||
|
||||
case TWEET_SEARCH:
|
||||
search = (String) param[0];
|
||||
if (!adapter.isEmpty())
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.searchTweets(search, sinceId);
|
||||
break;
|
||||
|
||||
case LIST:
|
||||
long listId = (long) param[0];
|
||||
page = (int) param[1];
|
||||
if (!adapter.isEmpty())
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.getListTweets(listId, sinceId, page);
|
||||
break;
|
||||
}
|
||||
} catch (TwitterEngine.EngineException twException) {
|
||||
this.twException = twException;
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return tweets;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(@Nullable List<Tweet> tweets) {
|
||||
if (ui.get() != null) {
|
||||
if (tweets != null) {
|
||||
if (mode == Mode.USR_FAVORS)
|
||||
adapter.add(tweets); // replace all items
|
||||
else
|
||||
adapter.addFirst(tweets);
|
||||
}
|
||||
if (twException != null)
|
||||
Toast.makeText(ui.get().getContext(), twException.getMessageResource(), LENGTH_SHORT).show();
|
||||
ui.get().setRefresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
if (ui.get() != null) {
|
||||
ui.get().setRefresh(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,205 +3,149 @@ package org.nuclearfog.twidda.backend;
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.adapter.TweetAdapter;
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.activity.TweetDetail;
|
||||
import org.nuclearfog.twidda.backend.items.Tweet;
|
||||
import org.nuclearfog.twidda.database.AppDatabase;
|
||||
import org.nuclearfog.twidda.fragment.TweetFragment;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.nuclearfog.twidda.fragment.TweetFragment.RETURN_TWEET_CHANGED;
|
||||
|
||||
|
||||
/**
|
||||
* Timeline loader Task
|
||||
* Background task to download tweet informations and to take actions
|
||||
* @see TweetDetail
|
||||
*/
|
||||
public class TweetLoader extends AsyncTask<Object, Void, List<Tweet>> {
|
||||
public class TweetLoader extends AsyncTask<Long, Tweet, Tweet> {
|
||||
|
||||
public enum Mode {
|
||||
TL_HOME,
|
||||
TL_MENT,
|
||||
USR_TWEETS,
|
||||
USR_FAVORS,
|
||||
TWEET_ANS,
|
||||
DB_ANS,
|
||||
TWEET_SEARCH,
|
||||
LIST
|
||||
public enum Action {
|
||||
LOAD,
|
||||
RETWEET,
|
||||
FAVORITE,
|
||||
DELETE
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TwitterEngine.EngineException twException;
|
||||
private Mode mode;
|
||||
private WeakReference<TweetFragment> ui;
|
||||
private TweetAdapter adapter;
|
||||
private TwitterEngine mTwitter;
|
||||
private WeakReference<TweetDetail> ui;
|
||||
private AppDatabase db;
|
||||
private final Action action;
|
||||
|
||||
|
||||
public TweetLoader(TweetFragment fragment, Mode mode) {
|
||||
ui = new WeakReference<>(fragment);
|
||||
db = new AppDatabase(fragment.getContext());
|
||||
mTwitter = TwitterEngine.getInstance(fragment.getContext());
|
||||
adapter = fragment.getAdapter();
|
||||
this.mode = mode;
|
||||
public TweetLoader(@NonNull TweetDetail context, Action action) {
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
db = new AppDatabase(context);
|
||||
ui = new WeakReference<>(context);
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
if (ui.get() != null) {
|
||||
ui.get().setRefresh(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<Tweet> doInBackground(Object[] param) {
|
||||
List<Tweet> tweets = null;
|
||||
long sinceId = 1;
|
||||
protected Tweet doInBackground(Long[] data) {
|
||||
Tweet tweet = null;
|
||||
long tweetId = data[0];
|
||||
boolean updateStatus = false;
|
||||
try {
|
||||
switch (mode) {
|
||||
case TL_HOME:
|
||||
int page = (int) param[0];
|
||||
if (adapter.isEmpty()) {
|
||||
tweets = db.getHomeTimeline();
|
||||
if (tweets.isEmpty()) {
|
||||
tweets = mTwitter.getHome(page, sinceId);
|
||||
db.storeHomeTimeline(tweets);
|
||||
}
|
||||
} else {
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.getHome(page, sinceId);
|
||||
db.storeHomeTimeline(tweets);
|
||||
switch (action) {
|
||||
case LOAD:
|
||||
tweet = db.getStatus(tweetId);
|
||||
if (tweet != null) {
|
||||
publishProgress(tweet);
|
||||
updateStatus = true;
|
||||
}
|
||||
tweet = mTwitter.getStatus(tweetId);
|
||||
publishProgress(tweet);
|
||||
if (updateStatus)
|
||||
db.updateStatus(tweet);
|
||||
break;
|
||||
|
||||
case TL_MENT:
|
||||
page = (int) param[0];
|
||||
if (adapter.isEmpty()) {
|
||||
tweets = db.getMentions();
|
||||
if (tweets.isEmpty()) {
|
||||
tweets = mTwitter.getMention(page, sinceId);
|
||||
db.storeMentions(tweets);
|
||||
}
|
||||
} else {
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.getMention(page, sinceId);
|
||||
db.storeMentions(tweets);
|
||||
}
|
||||
case DELETE:
|
||||
tweet = mTwitter.deleteTweet(tweetId);
|
||||
db.removeStatus(tweetId);
|
||||
break;
|
||||
|
||||
case USR_TWEETS:
|
||||
long id = (long) param[0];
|
||||
page = (int) param[1];
|
||||
if (adapter.isEmpty()) {
|
||||
tweets = db.getUserTweets(id);
|
||||
if (tweets.isEmpty()) {
|
||||
tweets = mTwitter.getUserTweets(id, sinceId, page);
|
||||
db.storeUserTweets(tweets);
|
||||
}
|
||||
} else {
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.getUserTweets(id, sinceId, page);
|
||||
db.storeUserTweets(tweets);
|
||||
}
|
||||
case RETWEET:
|
||||
tweet = mTwitter.retweet(tweetId);
|
||||
publishProgress(tweet);
|
||||
|
||||
if (!tweet.retweeted())
|
||||
db.removeRetweet(tweetId);
|
||||
db.updateStatus(tweet);
|
||||
break;
|
||||
|
||||
case USR_FAVORS:
|
||||
id = (long) param[0];
|
||||
page = (int) param[1];
|
||||
if (adapter.isEmpty()) {
|
||||
tweets = db.getUserFavs(id);
|
||||
if (tweets.isEmpty()) {
|
||||
tweets = mTwitter.getUserFavs(id, page);
|
||||
db.storeUserFavs(tweets, id);
|
||||
}
|
||||
} else {
|
||||
tweets = mTwitter.getUserFavs(id, page);
|
||||
db.storeUserFavs(tweets, id);
|
||||
}
|
||||
break;
|
||||
case FAVORITE:
|
||||
tweet = mTwitter.favorite(tweetId);
|
||||
publishProgress(tweet);
|
||||
|
||||
case DB_ANS:
|
||||
id = (long) param[0];
|
||||
tweets = db.getAnswers(id);
|
||||
break;
|
||||
|
||||
case TWEET_ANS:
|
||||
id = (long) param[0];
|
||||
String search = (String) param[1];
|
||||
if (adapter.isEmpty()) {
|
||||
tweets = db.getAnswers(id);
|
||||
if (tweets.isEmpty()) {
|
||||
tweets = mTwitter.getAnswers(search, id, sinceId);
|
||||
if (!tweets.isEmpty() && db.containStatus(id))
|
||||
db.storeReplies(tweets);
|
||||
}
|
||||
} else {
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.getAnswers(search, id, sinceId);
|
||||
if (!tweets.isEmpty() && db.containStatus(id))
|
||||
db.storeReplies(tweets);
|
||||
}
|
||||
break;
|
||||
|
||||
case TWEET_SEARCH:
|
||||
search = (String) param[0];
|
||||
if (!adapter.isEmpty())
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.searchTweets(search, sinceId);
|
||||
break;
|
||||
|
||||
case LIST:
|
||||
long listId = (long) param[0];
|
||||
page = (int) param[1];
|
||||
if (!adapter.isEmpty())
|
||||
sinceId = adapter.getItemId(0);
|
||||
tweets = mTwitter.getListTweets(listId, sinceId, page);
|
||||
if (tweet.favored())
|
||||
db.storeFavorite(tweet);
|
||||
else
|
||||
db.removeFavorite(tweetId);
|
||||
break;
|
||||
}
|
||||
} catch (TwitterEngine.EngineException twException) {
|
||||
this.twException = twException;
|
||||
if (twException.statusNotFound()) {
|
||||
db.removeStatus(tweetId);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return tweets;
|
||||
return tweet;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(@Nullable List<Tweet> tweets) {
|
||||
protected void onProgressUpdate(Tweet[] tweets) {
|
||||
Tweet tweet = tweets[0];
|
||||
if (ui.get() != null && tweet != null) {
|
||||
ui.get().setTweet(tweet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(@Nullable Tweet tweet) {
|
||||
if (ui.get() != null) {
|
||||
if (tweets != null) {
|
||||
if (mode == Mode.USR_FAVORS)
|
||||
adapter.add(tweets); // replace all items
|
||||
else
|
||||
adapter.addFirst(tweets);
|
||||
if (tweet != null) {
|
||||
switch (action) {
|
||||
case RETWEET:
|
||||
if (tweet.retweeted())
|
||||
Toast.makeText(ui.get(), R.string.info_tweet_retweeted, LENGTH_SHORT).show();
|
||||
else
|
||||
Toast.makeText(ui.get(), R.string.info_tweet_unretweeted, LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
case FAVORITE:
|
||||
if (tweet.favored())
|
||||
Toast.makeText(ui.get(), R.string.info_tweet_favored, LENGTH_SHORT).show();
|
||||
else
|
||||
Toast.makeText(ui.get(), R.string.info_tweet_unfavored, LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
case DELETE:
|
||||
Toast.makeText(ui.get(), R.string.info_tweet_removed, LENGTH_SHORT).show();
|
||||
ui.get().setResult(RETURN_TWEET_CHANGED);
|
||||
ui.get().finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (twException != null) {
|
||||
Toast.makeText(ui.get(), twException.getMessageResource(), LENGTH_SHORT).show();
|
||||
if (twException.isHardFault()) {
|
||||
if (twException.statusNotFound())
|
||||
ui.get().setResult(RETURN_TWEET_CHANGED);
|
||||
ui.get().finish();
|
||||
} else {
|
||||
ui.get().finishIfEmpty();
|
||||
}
|
||||
}
|
||||
if (twException != null)
|
||||
Toast.makeText(ui.get().getContext(), twException.getMessageResource(), LENGTH_SHORT).show();
|
||||
ui.get().setRefresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
if (ui.get() != null) {
|
||||
ui.get().setRefresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCancelled(@Nullable List<Tweet> tweets) {
|
||||
if (ui.get() != null) {
|
||||
if (tweets != null)
|
||||
adapter.addFirst(tweets);
|
||||
ui.get().setRefresh(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -22,8 +22,9 @@ import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
/**
|
||||
* Background task for uploading tweet
|
||||
* @see TweetPopup
|
||||
*/
|
||||
public class StatusUploader extends AsyncTask<Void, Void, Boolean> {
|
||||
public class TweetUploader extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
@Nullable
|
||||
private TwitterEngine.EngineException twException;
|
||||
@ -38,7 +39,7 @@ public class StatusUploader extends AsyncTask<Void, Void, Boolean> {
|
||||
* @param context Activity context
|
||||
* @param tweet tweet information
|
||||
*/
|
||||
public StatusUploader(@NonNull TweetPopup context, TweetHolder tweet) {
|
||||
public TweetUploader(@NonNull TweetPopup context, TweetHolder tweet) {
|
||||
ui = new WeakReference<>(context);
|
||||
popup = new WeakReference<>(new Dialog(context));
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
@ -17,7 +17,12 @@ import java.util.List;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
|
||||
public class ListLoader extends AsyncTask<Long, Void, List<TwitterList>> {
|
||||
/**
|
||||
* Background task for downloading twitter lists created by a user
|
||||
*
|
||||
* @see ListFragment
|
||||
*/
|
||||
public class TwitterListLoader extends AsyncTask<Long, Void, List<TwitterList>> {
|
||||
|
||||
public enum Action {
|
||||
LOAD,
|
||||
@ -32,7 +37,7 @@ public class ListLoader extends AsyncTask<Long, Void, List<TwitterList>> {
|
||||
private ListAdapter adapter;
|
||||
private Action action;
|
||||
|
||||
public ListLoader(ListFragment frag, Action action) {
|
||||
public TwitterListLoader(ListFragment frag, Action action) {
|
||||
ui = new WeakReference<>(frag);
|
||||
mTwitter = TwitterEngine.getInstance(frag.getContext());
|
||||
adapter = frag.getAdapter();
|
@ -17,9 +17,10 @@ import java.util.List;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
/**
|
||||
* User list loader task
|
||||
* download a list of user such as follower, following or searched users
|
||||
* @see UserFragment
|
||||
*/
|
||||
public class UserLoader extends AsyncTask<Object, Void, List<TwitterUser>> {
|
||||
public class UserListLoader extends AsyncTask<Object, Void, List<TwitterUser>> {
|
||||
|
||||
public enum Mode {
|
||||
FOLLOWS,
|
||||
@ -33,13 +34,13 @@ public class UserLoader extends AsyncTask<Object, Void, List<TwitterUser>> {
|
||||
|
||||
@Nullable
|
||||
private TwitterEngine.EngineException twException;
|
||||
private Mode mode;
|
||||
private WeakReference<UserFragment> ui;
|
||||
private TwitterEngine mTwitter;
|
||||
private UserAdapter adapter;
|
||||
private Mode mode;
|
||||
|
||||
|
||||
public UserLoader(UserFragment fragment, Mode mode) {
|
||||
public UserListLoader(UserFragment fragment, Mode mode) {
|
||||
ui = new WeakReference<>(fragment);
|
||||
mTwitter = TwitterEngine.getInstance(fragment.getContext());
|
||||
adapter = fragment.getAdapter();
|
@ -22,7 +22,7 @@ import org.nuclearfog.twidda.activity.UserDetail;
|
||||
import org.nuclearfog.twidda.activity.UserProfile;
|
||||
import org.nuclearfog.twidda.adapter.ListAdapter;
|
||||
import org.nuclearfog.twidda.adapter.ListAdapter.ListClickListener;
|
||||
import org.nuclearfog.twidda.backend.ListLoader;
|
||||
import org.nuclearfog.twidda.backend.TwitterListLoader;
|
||||
import org.nuclearfog.twidda.backend.items.TwitterList;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
|
||||
@ -34,9 +34,9 @@ import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_ID;
|
||||
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_MODE;
|
||||
import static org.nuclearfog.twidda.activity.UserDetail.USERLIST_SUBSCRIBER;
|
||||
import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_ID;
|
||||
import static org.nuclearfog.twidda.backend.ListLoader.Action.DELETE;
|
||||
import static org.nuclearfog.twidda.backend.ListLoader.Action.FOLLOW;
|
||||
import static org.nuclearfog.twidda.backend.ListLoader.Action.LOAD;
|
||||
import static org.nuclearfog.twidda.backend.TwitterListLoader.Action.DELETE;
|
||||
import static org.nuclearfog.twidda.backend.TwitterListLoader.Action.FOLLOW;
|
||||
import static org.nuclearfog.twidda.backend.TwitterListLoader.Action.LOAD;
|
||||
|
||||
public class ListFragment extends Fragment implements OnRefreshListener, ListClickListener {
|
||||
|
||||
@ -44,7 +44,7 @@ public class ListFragment extends Fragment implements OnRefreshListener, ListCli
|
||||
|
||||
private SwipeRefreshLayout reloadLayout;
|
||||
private ListAdapter adapter;
|
||||
private ListLoader listTask;
|
||||
private TwitterListLoader listTask;
|
||||
|
||||
private long userId;
|
||||
|
||||
@ -114,14 +114,14 @@ public class ListFragment extends Fragment implements OnRefreshListener, ListCli
|
||||
confirmDialog.setPositiveButton(R.string.confirm_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
listTask = new ListLoader(ListFragment.this, FOLLOW);
|
||||
listTask = new TwitterListLoader(ListFragment.this, FOLLOW);
|
||||
listTask.execute(listItem.getId());
|
||||
}
|
||||
});
|
||||
confirmDialog.show();
|
||||
}
|
||||
} else {
|
||||
listTask = new ListLoader(this, FOLLOW);
|
||||
listTask = new TwitterListLoader(this, FOLLOW);
|
||||
listTask.execute(listItem.getId());
|
||||
}
|
||||
break;
|
||||
@ -148,7 +148,7 @@ public class ListFragment extends Fragment implements OnRefreshListener, ListCli
|
||||
confirmDialog.setPositiveButton(R.string.confirm_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
listTask = new ListLoader(ListFragment.this, DELETE);
|
||||
listTask = new TwitterListLoader(ListFragment.this, DELETE);
|
||||
listTask.execute(listItem.getId());
|
||||
}
|
||||
});
|
||||
@ -181,7 +181,7 @@ public class ListFragment extends Fragment implements OnRefreshListener, ListCli
|
||||
|
||||
|
||||
private void load() {
|
||||
listTask = new ListLoader(this, LOAD);
|
||||
listTask = new TwitterListLoader(this, LOAD);
|
||||
listTask.execute(userId);
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ import org.nuclearfog.twidda.activity.TweetDetail;
|
||||
import org.nuclearfog.twidda.activity.UserProfile;
|
||||
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.MessageListLoader;
|
||||
import org.nuclearfog.twidda.backend.MessageListLoader.Mode;
|
||||
import org.nuclearfog.twidda.backend.items.Message;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
|
||||
@ -39,7 +39,7 @@ import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_ID;
|
||||
|
||||
public class MessageFragment extends Fragment implements OnRefreshListener, OnItemSelected {
|
||||
|
||||
private MessageLoader messageTask;
|
||||
private MessageListLoader messageTask;
|
||||
private SwipeRefreshLayout reload;
|
||||
private MessageAdapter adapter;
|
||||
|
||||
@ -132,7 +132,7 @@ public class MessageFragment extends Fragment implements OnRefreshListener, OnIt
|
||||
confirmDialog.setPositiveButton(R.string.confirm_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
messageTask = new MessageLoader(MessageFragment.this, Mode.DEL);
|
||||
messageTask = new MessageListLoader(MessageFragment.this, Mode.DEL);
|
||||
messageTask.execute(message.getId());
|
||||
}
|
||||
});
|
||||
@ -171,7 +171,7 @@ public class MessageFragment extends Fragment implements OnRefreshListener, OnIt
|
||||
|
||||
|
||||
private void load(Mode m) {
|
||||
messageTask = new MessageLoader(this, m);
|
||||
messageTask = new MessageListLoader(this, m);
|
||||
messageTask.execute();
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ import org.nuclearfog.twidda.activity.SearchPage;
|
||||
import org.nuclearfog.twidda.adapter.FragmentAdapter.FragmentChangeObserver;
|
||||
import org.nuclearfog.twidda.adapter.TrendAdapter;
|
||||
import org.nuclearfog.twidda.adapter.TrendAdapter.TrendClickListener;
|
||||
import org.nuclearfog.twidda.backend.TrendLoader;
|
||||
import org.nuclearfog.twidda.backend.TrendListLoader;
|
||||
import org.nuclearfog.twidda.backend.items.TwitterTrend;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
|
||||
@ -29,7 +29,7 @@ import static org.nuclearfog.twidda.activity.SearchPage.KEY_SEARCH_QUERY;
|
||||
|
||||
public class TrendFragment extends Fragment implements OnRefreshListener, TrendClickListener, FragmentChangeObserver {
|
||||
|
||||
private TrendLoader trendTask;
|
||||
private TrendListLoader trendTask;
|
||||
private SwipeRefreshLayout reload;
|
||||
private RecyclerView list;
|
||||
private TrendAdapter adapter;
|
||||
@ -136,7 +136,7 @@ public class TrendFragment extends Fragment implements OnRefreshListener, TrendC
|
||||
|
||||
|
||||
private void load() {
|
||||
trendTask = new TrendLoader(this);
|
||||
trendTask = new TrendListLoader(this);
|
||||
trendTask.execute(settings.getTrendLocation().getWoeId());
|
||||
}
|
||||
}
|
@ -18,8 +18,8 @@ import org.nuclearfog.twidda.activity.TweetDetail;
|
||||
import org.nuclearfog.twidda.adapter.FragmentAdapter.FragmentChangeObserver;
|
||||
import org.nuclearfog.twidda.adapter.TweetAdapter;
|
||||
import org.nuclearfog.twidda.adapter.TweetAdapter.TweetClickListener;
|
||||
import org.nuclearfog.twidda.backend.TweetLoader;
|
||||
import org.nuclearfog.twidda.backend.TweetLoader.Mode;
|
||||
import org.nuclearfog.twidda.backend.TweetListLoader;
|
||||
import org.nuclearfog.twidda.backend.TweetListLoader.Mode;
|
||||
import org.nuclearfog.twidda.backend.items.Tweet;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
|
||||
@ -47,7 +47,7 @@ public class TweetFragment extends Fragment implements OnRefreshListener, TweetC
|
||||
private static final int REQUEST_TWEET_CHANGED = 3;
|
||||
public static final int RETURN_TWEET_CHANGED = 4;
|
||||
|
||||
private TweetLoader tweetTask;
|
||||
private TweetListLoader tweetTask;
|
||||
private GlobalSettings settings;
|
||||
private SwipeRefreshLayout reload;
|
||||
private RecyclerView list;
|
||||
@ -178,41 +178,41 @@ public class TweetFragment extends Fragment implements OnRefreshListener, TweetC
|
||||
private void load() {
|
||||
switch (mode) {
|
||||
case TWEET_FRAG_HOME:
|
||||
tweetTask = new TweetLoader(this, Mode.TL_HOME);
|
||||
tweetTask = new TweetListLoader(this, Mode.TL_HOME);
|
||||
tweetTask.execute(1);
|
||||
break;
|
||||
|
||||
case TWEET_FRAG_MENT:
|
||||
tweetTask = new TweetLoader(this, Mode.TL_MENT);
|
||||
tweetTask = new TweetListLoader(this, Mode.TL_MENT);
|
||||
tweetTask.execute(1);
|
||||
break;
|
||||
|
||||
case TWEET_FRAG_TWEETS:
|
||||
tweetTask = new TweetLoader(this, Mode.USR_TWEETS);
|
||||
tweetTask = new TweetListLoader(this, Mode.USR_TWEETS);
|
||||
tweetTask.execute(id, 1);
|
||||
break;
|
||||
|
||||
case TWEET_FRAG_FAVORS:
|
||||
tweetTask = new TweetLoader(this, Mode.USR_FAVORS);
|
||||
tweetTask = new TweetListLoader(this, Mode.USR_FAVORS);
|
||||
tweetTask.execute(id, 1);
|
||||
break;
|
||||
|
||||
case TWEET_FRAG_ANSWER:
|
||||
boolean loadAnswer = settings.getAnswerLoad();
|
||||
if (tweetTask != null || loadAnswer)
|
||||
tweetTask = new TweetLoader(this, Mode.TWEET_ANS);
|
||||
tweetTask = new TweetListLoader(this, Mode.TWEET_ANS);
|
||||
else
|
||||
tweetTask = new TweetLoader(this, Mode.DB_ANS);
|
||||
tweetTask = new TweetListLoader(this, Mode.DB_ANS);
|
||||
tweetTask.execute(id, search);
|
||||
break;
|
||||
|
||||
case TWEET_FRAG_SEARCH:
|
||||
tweetTask = new TweetLoader(this, Mode.TWEET_SEARCH);
|
||||
tweetTask = new TweetListLoader(this, Mode.TWEET_SEARCH);
|
||||
tweetTask.execute(search);
|
||||
break;
|
||||
|
||||
case TWEET_FRAG_LIST:
|
||||
tweetTask = new TweetLoader(this, Mode.LIST);
|
||||
tweetTask = new TweetListLoader(this, Mode.LIST);
|
||||
tweetTask.execute(id, 1);
|
||||
break;
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ import org.nuclearfog.twidda.activity.UserProfile;
|
||||
import org.nuclearfog.twidda.adapter.FragmentAdapter.FragmentChangeObserver;
|
||||
import org.nuclearfog.twidda.adapter.UserAdapter;
|
||||
import org.nuclearfog.twidda.adapter.UserAdapter.UserClickListener;
|
||||
import org.nuclearfog.twidda.backend.UserLoader;
|
||||
import org.nuclearfog.twidda.backend.UserLoader.Mode;
|
||||
import org.nuclearfog.twidda.backend.UserListLoader;
|
||||
import org.nuclearfog.twidda.backend.UserListLoader.Mode;
|
||||
import org.nuclearfog.twidda.backend.items.TwitterUser;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
|
||||
@ -44,7 +44,7 @@ public class UserFragment extends Fragment implements OnRefreshListener, UserCli
|
||||
|
||||
private SwipeRefreshLayout reload;
|
||||
private UserAdapter adapter;
|
||||
private UserLoader userTask;
|
||||
private UserListLoader userTask;
|
||||
private RecyclerView list;
|
||||
private String search;
|
||||
private long id;
|
||||
@ -147,31 +147,31 @@ public class UserFragment extends Fragment implements OnRefreshListener, UserCli
|
||||
private void load() {
|
||||
switch (mode) {
|
||||
case USER_FRAG_FOLLOWS:
|
||||
userTask = new UserLoader(this, Mode.FOLLOWS);
|
||||
userTask = new UserListLoader(this, Mode.FOLLOWS);
|
||||
userTask.execute(id);
|
||||
break;
|
||||
case USER_FRAG_FRIENDS:
|
||||
userTask = new UserLoader(this, Mode.FRIENDS);
|
||||
userTask = new UserListLoader(this, Mode.FRIENDS);
|
||||
userTask.execute(id);
|
||||
break;
|
||||
case USER_FRAG_RETWEET:
|
||||
userTask = new UserLoader(this, Mode.RETWEET);
|
||||
userTask = new UserListLoader(this, Mode.RETWEET);
|
||||
userTask.execute(id);
|
||||
break;
|
||||
case USER_FRAG_FAVORIT:
|
||||
userTask = new UserLoader(this, Mode.FAVORIT);
|
||||
userTask = new UserListLoader(this, Mode.FAVORIT);
|
||||
userTask.execute(id);
|
||||
break;
|
||||
case USER_FRAG_SEARCH:
|
||||
userTask = new UserLoader(this, Mode.SEARCH);
|
||||
userTask = new UserListLoader(this, Mode.SEARCH);
|
||||
userTask.execute(search);
|
||||
break;
|
||||
case USER_FRAG_SUBSCRIBER:
|
||||
userTask = new UserLoader(this, Mode.SUBSCRIBER);
|
||||
userTask = new UserListLoader(this, Mode.SUBSCRIBER);
|
||||
userTask.execute(id);
|
||||
break;
|
||||
case USER_FRAG_LISTS:
|
||||
userTask = new UserLoader(this, Mode.LIST);
|
||||
userTask = new UserListLoader(this, Mode.LIST);
|
||||
userTask.execute(id);
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user