summaryrefslogtreecommitdiffstats
path: root/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java')
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java
index d3a117234..9f224caa9 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java
@@ -24,18 +24,21 @@ import java.util.List;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.APIResponse;
+import fr.gouv.etalab.mastodon.client.Entities.ManageTimelines;
import fr.gouv.etalab.mastodon.client.Entities.Peertube;
import fr.gouv.etalab.mastodon.client.Entities.RemoteInstance;
import fr.gouv.etalab.mastodon.client.Entities.TagTimeline;
import fr.gouv.etalab.mastodon.client.GNUAPI;
import fr.gouv.etalab.mastodon.client.PeertubeAPI;
import fr.gouv.etalab.mastodon.helper.FilterToots;
+import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
import fr.gouv.etalab.mastodon.sqlite.InstancesDAO;
import fr.gouv.etalab.mastodon.sqlite.PeertubeFavoritesDAO;
import fr.gouv.etalab.mastodon.sqlite.SearchDAO;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
import fr.gouv.etalab.mastodon.sqlite.StatusCacheDAO;
+import fr.gouv.etalab.mastodon.sqlite.TimelinesDAO;
/**
@@ -59,6 +62,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
private FilterToots filterToots;
private String instanceName,remoteInstance, name;
private boolean cached = false;
+ private int timelineId;
public enum Type{
HOME,
@@ -75,6 +79,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
TAG,
REMOTE_INSTANCE,
ART,
+ PEERTUBE,
NOTIFICATION,
SEARCH,
@@ -118,6 +123,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
this.filterToots = filterToots;
}
+
public RetrieveFeedsAsyncTask(Context context, Type action, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface){
this.contextReference = new WeakReference<>(context);
this.action = action;
@@ -133,6 +139,14 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
this.instanceName = instanceName;
}
+ public RetrieveFeedsAsyncTask(Context context, Type action, int timelineId, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface){
+ this.contextReference = new WeakReference<>(context);
+ this.action = action;
+ this.max_id = max_id;
+ this.listener = onRetrieveFeedsInterface;
+ this.timelineId = timelineId;
+ }
+
public RetrieveFeedsAsyncTask(Context context, Type action, String targetedID, String max_id, boolean showMediaOnly, boolean showPinned, OnRetrieveFeedsInterface onRetrieveFeedsInterface){
this.contextReference = new WeakReference<>(context);
this.action = action;
@@ -174,6 +188,8 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
protected Void doInBackground(Void... params) {
API api = new API(this.contextReference.get());
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
+ if( action == null )
+ return null;
switch (action){
case HOME:
apiResponse = api.getHomeTimeline(max_id);
@@ -266,15 +282,14 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
break;
case TAG:
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
- List<TagTimeline> tagTimelines = new SearchDAO(contextReference.get(), db).getTimelineInfo(tag);
- if (tagTimelines != null && tagTimelines.size() > 0) {
- TagTimeline tagTimeline = tagTimelines.get(0);
- boolean isArt = tagTimeline.isART();
+ ManageTimelines manageTimelines = new TimelinesDAO(contextReference.get(), db).getById(timelineId);
+ if( manageTimelines != null && manageTimelines.getTagTimeline() != null){
+ boolean isArt = manageTimelines.getTagTimeline().isART();
if (isArt)
- apiResponse = api.getCustomArtTimeline(false, tag, max_id, tagTimelines.get(0).getAny(), tagTimelines.get(0).getAll(), tagTimelines.get(0).getNone());
+ apiResponse = api.getCustomArtTimeline(false, manageTimelines.getTagTimeline().getName(), max_id, manageTimelines.getTagTimeline().getAny(), manageTimelines.getTagTimeline().getAll(), manageTimelines.getTagTimeline().getNone());
else
- apiResponse = api.getPublicTimelineTag(tag, false, max_id, tagTimelines.get(0).getAny(), tagTimelines.get(0).getAll(), tagTimelines.get(0).getNone());
- } else {
+ apiResponse = api.getPublicTimelineTag(manageTimelines.getTagTimeline().getName(), false, max_id, manageTimelines.getTagTimeline().getAny(), manageTimelines.getTagTimeline().getAll(), manageTimelines.getTagTimeline().getNone());
+ }else{
apiResponse = api.getPublicTimelineTag(tag, false, max_id, null, null, null);
}
}else{