fedilab-Android-App/app/src/main/java/app/fedilab/android/asynctasks/RetrieveFeedsAsyncTask.java

496 lines
23 KiB
Java
Raw Normal View History

2017-05-05 16:36:04 +02:00
/* Copyright 2017 Thomas Schneider
*
2019-05-18 11:10:30 +02:00
* This file is a part of Fedilab
2017-05-05 16:36:04 +02:00
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
2019-05-18 11:10:30 +02:00
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
2017-05-05 16:36:04 +02:00
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
2019-05-18 11:10:30 +02:00
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
2017-05-05 16:36:04 +02:00
* see <http://www.gnu.org/licenses>. */
2019-05-18 11:10:30 +02:00
package app.fedilab.android.asynctasks;
2017-05-05 16:36:04 +02:00
import android.content.Context;
2018-02-15 16:59:52 +01:00
import android.database.sqlite.SQLiteDatabase;
2017-05-05 16:36:04 +02:00
import android.os.AsyncTask;
2017-10-27 15:09:26 +02:00
import java.lang.ref.WeakReference;
2019-08-19 15:17:18 +02:00
import java.util.ArrayList;
2018-02-15 16:59:52 +01:00
import java.util.List;
2017-10-27 15:09:26 +02:00
2019-11-15 16:32:25 +01:00
import app.fedilab.android.activities.MainActivity;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.client.API;
import app.fedilab.android.client.APIResponse;
import app.fedilab.android.client.Entities.ManageTimelines;
import app.fedilab.android.client.Entities.Peertube;
import app.fedilab.android.client.Entities.RemoteInstance;
2019-08-19 14:50:30 +02:00
import app.fedilab.android.client.Entities.Results;
2019-05-25 12:37:50 +02:00
import app.fedilab.android.client.Entities.RetrieveFeedsParam;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.client.GNUAPI;
import app.fedilab.android.client.PeertubeAPI;
import app.fedilab.android.helper.FilterToots;
2019-11-15 16:32:25 +01:00
import app.fedilab.android.interfaces.OnRetrieveFeedsInterface;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.sqlite.InstancesDAO;
import app.fedilab.android.sqlite.PeertubeFavoritesDAO;
import app.fedilab.android.sqlite.Sqlite;
import app.fedilab.android.sqlite.StatusCacheDAO;
2019-08-19 14:50:30 +02:00
import app.fedilab.android.sqlite.TimelineCacheDAO;
2019-05-18 11:10:30 +02:00
import app.fedilab.android.sqlite.TimelinesDAO;
2017-05-05 16:36:04 +02:00
/**
* Created by Thomas on 23/04/2017.
* Retrieves toots on the instance
*/
public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
2017-10-27 15:09:26 +02:00
2017-05-05 16:36:04 +02:00
private Type action;
2017-06-03 18:18:27 +02:00
private APIResponse apiResponse;
2017-05-05 16:36:04 +02:00
private String max_id;
private OnRetrieveFeedsInterface listener;
private String targetedID;
private String tag;
private boolean showMediaOnly = false;
private boolean showPinned = false;
2018-09-05 10:19:07 +02:00
private boolean showReply = false;
2017-10-27 15:09:26 +02:00
private WeakReference<Context> contextReference;
2018-02-17 14:43:12 +01:00
private FilterToots filterToots;
2019-09-06 17:55:14 +02:00
private String instanceName, remoteInstance, name;
private boolean cached = false;
2019-04-26 15:50:26 +02:00
private int timelineId;
2019-05-25 12:37:50 +02:00
private String currentfilter;
private String social;
2019-09-06 17:55:14 +02:00
public RetrieveFeedsAsyncTask(Context context, FilterToots filterToots, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface) {
2018-02-17 14:43:12 +01:00
this.contextReference = new WeakReference<>(context);
this.action = Type.CACHE_STATUS;
this.max_id = max_id;
this.listener = onRetrieveFeedsInterface;
this.filterToots = filterToots;
}
2019-04-22 13:16:35 +02:00
2019-09-06 17:55:14 +02:00
public RetrieveFeedsAsyncTask(Context context, Type action, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface) {
2017-10-27 15:09:26 +02:00
this.contextReference = new WeakReference<>(context);
2017-05-05 16:36:04 +02:00
this.action = action;
this.max_id = max_id;
this.listener = onRetrieveFeedsInterface;
}
2019-11-15 16:32:25 +01:00
2019-09-06 17:55:14 +02:00
public RetrieveFeedsAsyncTask(Context context, Type action, String instanceName, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface) {
2018-08-20 19:00:20 +02:00
this.contextReference = new WeakReference<>(context);
this.action = action;
this.max_id = max_id;
this.listener = onRetrieveFeedsInterface;
this.instanceName = instanceName;
}
2019-09-06 17:55:14 +02:00
public RetrieveFeedsAsyncTask(Context context, Type action, int timelineId, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface) {
2019-04-26 15:50:26 +02:00
this.contextReference = new WeakReference<>(context);
this.action = action;
this.max_id = max_id;
this.listener = onRetrieveFeedsInterface;
this.timelineId = timelineId;
}
2019-09-06 17:55:14 +02:00
public RetrieveFeedsAsyncTask(Context context, Type action, String targetedID, String max_id, boolean showMediaOnly, boolean showPinned, OnRetrieveFeedsInterface onRetrieveFeedsInterface) {
2017-10-27 15:09:26 +02:00
this.contextReference = new WeakReference<>(context);
2017-05-05 16:36:04 +02:00
this.action = action;
this.max_id = max_id;
this.listener = onRetrieveFeedsInterface;
this.targetedID = targetedID;
this.showMediaOnly = showMediaOnly;
this.showPinned = showPinned;
2017-05-05 16:36:04 +02:00
}
2019-09-06 17:55:14 +02:00
public RetrieveFeedsAsyncTask(Context context, Type action, String targetedID, String max_id, boolean showMediaOnly, boolean showPinned, boolean showReply, OnRetrieveFeedsInterface onRetrieveFeedsInterface) {
2018-09-05 10:19:07 +02:00
this.contextReference = new WeakReference<>(context);
this.action = action;
this.max_id = max_id;
this.listener = onRetrieveFeedsInterface;
this.targetedID = targetedID;
this.showMediaOnly = showMediaOnly;
this.showPinned = showPinned;
this.showReply = showReply;
}
2019-09-06 17:55:14 +02:00
public RetrieveFeedsAsyncTask(Context context, Type action, String tag, String targetedID, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface) {
2017-10-27 15:09:26 +02:00
this.contextReference = new WeakReference<>(context);
2017-05-05 16:36:04 +02:00
this.action = action;
this.max_id = max_id;
this.listener = onRetrieveFeedsInterface;
this.targetedID = targetedID;
this.tag = tag;
}
2019-09-06 17:55:14 +02:00
public RetrieveFeedsAsyncTask(Context context, String remoteInstance, String name, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface) {
2018-10-22 19:19:39 +02:00
this.contextReference = new WeakReference<>(context);
this.remoteInstance = remoteInstance;
this.max_id = max_id;
this.listener = onRetrieveFeedsInterface;
this.name = name;
this.action = Type.REMOTE_INSTANCE;
}
2019-09-06 17:55:14 +02:00
public RetrieveFeedsAsyncTask(Context context, RetrieveFeedsParam retrieveFeedsParam, OnRetrieveFeedsInterface onRetrieveFeedsInterface) {
2019-05-25 12:37:50 +02:00
this.contextReference = new WeakReference<>(context);
this.listener = onRetrieveFeedsInterface;
this.action = retrieveFeedsParam.getAction();
this.max_id = retrieveFeedsParam.getMax_id();
this.targetedID = retrieveFeedsParam.getTargetedID();
this.tag = retrieveFeedsParam.getTag();
this.showMediaOnly = retrieveFeedsParam.isShowMediaOnly();
this.showPinned = retrieveFeedsParam.isShowPinned();
this.showReply = retrieveFeedsParam.isShowReply();
this.name = retrieveFeedsParam.getName();
this.currentfilter = retrieveFeedsParam.getCurrentfilter();
this.social = retrieveFeedsParam.getSocial();
2019-05-25 14:20:17 +02:00
this.instanceName = retrieveFeedsParam.getInstanceName();
this.remoteInstance = retrieveFeedsParam.getRemoteInstance();
2019-05-25 12:37:50 +02:00
}
2017-05-05 16:36:04 +02:00
@Override
protected Void doInBackground(Void... params) {
2017-10-27 15:09:26 +02:00
API api = new API(this.contextReference.get());
2018-10-22 19:19:39 +02:00
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2019-09-06 17:55:14 +02:00
if (action == null)
2019-04-22 13:16:35 +02:00
return null;
2019-09-06 17:55:14 +02:00
switch (action) {
2017-05-05 16:36:04 +02:00
case HOME:
2019-05-12 09:53:10 +02:00
apiResponse = api.getHomeTimelineCache(max_id);
2017-05-05 16:36:04 +02:00
break;
case LOCAL:
2017-06-03 18:18:27 +02:00
apiResponse = api.getPublicTimeline(true, max_id);
2017-05-05 16:36:04 +02:00
break;
case PUBLIC:
2017-06-03 18:18:27 +02:00
apiResponse = api.getPublicTimeline(false, max_id);
2017-05-05 16:36:04 +02:00
break;
2019-06-08 18:55:30 +02:00
case NEWS:
apiResponse = api.getNews(max_id);
break;
2019-01-19 19:41:55 +01:00
case SCHEDULED_TOOTS:
2019-01-20 15:20:07 +01:00
apiResponse = api.scheduledAction("GET", null, max_id, null);
2019-01-19 19:41:55 +01:00
break;
2018-10-10 08:33:36 +02:00
case DIRECT:
apiResponse = api.getDirectTimeline(max_id);
break;
2018-10-29 15:49:13 +01:00
case CONVERSATION:
apiResponse = api.getConversationTimeline(max_id);
break;
2019-05-25 12:37:50 +02:00
case REMOTE_INSTANCE_FILTERED:
2019-09-06 17:55:14 +02:00
if (this.social != null && this.social.equals("MASTODON")) {
apiResponse = api.getPublicTimelineTag(this.currentfilter, true, max_id, this.remoteInstance);
if (apiResponse != null) {
2019-05-25 14:20:17 +02:00
List<app.fedilab.android.client.Entities.Status> statusesTemp = apiResponse.getStatuses();
2019-09-06 17:55:14 +02:00
if (statusesTemp != null) {
for (app.fedilab.android.client.Entities.Status status : statusesTemp) {
2019-05-25 14:20:17 +02:00
status.setType(action);
}
2019-05-25 12:37:50 +02:00
}
}
2019-09-06 17:55:14 +02:00
} else if (this.social != null && this.social.equals("GNU")) {
2019-05-25 12:37:50 +02:00
GNUAPI gnuapi = new GNUAPI(this.contextReference.get());
2019-09-06 17:55:14 +02:00
apiResponse = gnuapi.searchRemote(this.remoteInstance, currentfilter, max_id);
} else {
2019-05-25 14:20:17 +02:00
apiResponse = api.searchPeertube(this.remoteInstance, currentfilter);
2019-05-25 12:37:50 +02:00
}
break;
2018-08-20 19:00:20 +02:00
case REMOTE_INSTANCE:
2019-09-06 17:55:14 +02:00
if (this.name != null && this.remoteInstance != null) { //For Peertube channels
2018-10-22 19:19:39 +02:00
apiResponse = api.getPeertubeChannelVideos(this.remoteInstance, this.name);
2019-09-06 17:55:14 +02:00
} else { //For other remote instance
2018-10-22 19:19:39 +02:00
List<RemoteInstance> remoteInstanceObj = new InstancesDAO(this.contextReference.get(), db).getInstanceByName(this.instanceName);
2019-09-06 17:55:14 +02:00
if (remoteInstanceObj != null && remoteInstanceObj.size() > 0 && remoteInstanceObj.get(0).getType().equals("MASTODON")) {
apiResponse = api.getPublicTimeline(this.instanceName, true, max_id);
2019-05-18 11:10:30 +02:00
List<app.fedilab.android.client.Entities.Status> statusesTemp = apiResponse.getStatuses();
2019-09-06 17:55:14 +02:00
if (statusesTemp != null) {
for (app.fedilab.android.client.Entities.Status status : statusesTemp) {
2018-10-22 19:19:39 +02:00
status.setType(action);
}
2018-10-07 10:45:34 +02:00
}
2019-09-06 17:55:14 +02:00
} else if (remoteInstanceObj != null && remoteInstanceObj.size() > 0 && remoteInstanceObj.get(0).getType().equals("MISSKEY")) {
2018-12-29 12:09:02 +01:00
apiResponse = api.getMisskey(this.instanceName, max_id);
2019-05-18 11:10:30 +02:00
List<app.fedilab.android.client.Entities.Status> statusesTemp = apiResponse.getStatuses();
2019-09-06 17:55:14 +02:00
if (statusesTemp != null) {
for (app.fedilab.android.client.Entities.Status status : statusesTemp) {
2018-12-29 12:09:02 +01:00
status.setType(action);
}
}
2019-09-06 17:55:14 +02:00
} else if (remoteInstanceObj != null && remoteInstanceObj.size() > 0 && remoteInstanceObj.get(0).getType().equals("PIXELFED")) {
apiResponse = api.getPixelfedTimeline(instanceName, max_id);
2019-09-06 17:55:14 +02:00
} else if (remoteInstanceObj != null && remoteInstanceObj.size() > 0 && remoteInstanceObj.get(0).getType().equals("GNU")) {
2019-05-11 19:58:41 +02:00
apiResponse = api.getGNUTimeline(instanceName, max_id);
2019-09-06 17:55:14 +02:00
} else {
2018-10-22 19:19:39 +02:00
apiResponse = api.getPeertube(this.instanceName, max_id);
}
}
2018-08-20 19:00:20 +02:00
break;
2017-05-05 16:36:04 +02:00
case FAVOURITES:
2019-09-06 17:55:14 +02:00
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
2019-02-05 18:05:21 +01:00
apiResponse = api.getFavourites(max_id);
2019-09-06 17:55:14 +02:00
} else {
2019-02-05 18:05:21 +01:00
GNUAPI gnuapi = new GNUAPI(this.contextReference.get());
apiResponse = gnuapi.getFavourites(max_id);
}
2017-05-05 16:36:04 +02:00
break;
case USER:
2019-09-25 11:29:58 +02:00
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
2019-01-03 17:11:53 +01:00
if (showMediaOnly)
apiResponse = api.getStatusWithMedia(targetedID, max_id);
else if (showPinned)
apiResponse = api.getPinnedStatuses(targetedID, max_id);
else
apiResponse = api.getAccountTLStatuses(targetedID, max_id, !showReply);
2019-09-06 17:55:14 +02:00
} else if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
2019-02-03 16:06:06 +01:00
GNUAPI gnuapi = new GNUAPI(this.contextReference.get());
if (showMediaOnly)
apiResponse = gnuapi.getStatusWithMedia(targetedID, max_id);
else if (showPinned)
apiResponse = gnuapi.getPinnedStatuses(targetedID, max_id);
else
apiResponse = gnuapi.getAccountTLStatuses(targetedID, max_id, !showReply);
2019-09-06 17:55:14 +02:00
} else if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
2019-01-03 17:11:53 +01:00
PeertubeAPI peertubeAPI = new PeertubeAPI(this.contextReference.get());
apiResponse = peertubeAPI.getVideos(targetedID, max_id);
}
2017-05-05 16:36:04 +02:00
break;
2019-01-09 17:30:18 +01:00
case MYVIDEOS:
2019-01-03 18:59:44 +01:00
PeertubeAPI peertubeAPI = new PeertubeAPI(this.contextReference.get());
2019-01-09 17:30:18 +01:00
apiResponse = peertubeAPI.getMyVideos(max_id);
break;
2019-05-26 12:04:00 +02:00
case PEERTUBE_HISTORY:
peertubeAPI = new PeertubeAPI(this.contextReference.get());
apiResponse = peertubeAPI.getMyHistory(max_id);
break;
2019-01-09 17:30:18 +01:00
case CHANNEL:
peertubeAPI = new PeertubeAPI(this.contextReference.get());
2019-01-03 18:59:44 +01:00
apiResponse = peertubeAPI.getVideosChannel(targetedID, max_id);
break;
2017-05-05 16:36:04 +02:00
case ONESTATUS:
2017-06-03 18:18:27 +02:00
apiResponse = api.getStatusbyId(targetedID);
2017-05-05 16:36:04 +02:00
break;
2019-03-31 15:15:46 +02:00
case SEARCH:
2019-08-19 14:50:30 +02:00
2019-09-06 17:55:14 +02:00
if (!tag.contains("_cache_")) {
2019-08-19 14:50:30 +02:00
apiResponse = api.search2(tag, API.searchType.STATUSES, max_id);
2019-09-06 17:55:14 +02:00
} else {
tag = tag.replace("_cache_", "");
2019-08-19 14:50:30 +02:00
apiResponse = new APIResponse();
Results results = new Results();
List<app.fedilab.android.client.Entities.Status> statuses = new TimelineCacheDAO(contextReference.get(), db).search(tag, max_id);
2019-09-06 17:55:14 +02:00
if (statuses != null && statuses.size() > 0) {
2019-08-19 14:50:30 +02:00
apiResponse.setMax_id(statuses.get(statuses.size() - 1).getId());
}
2019-08-19 15:17:18 +02:00
List<app.fedilab.android.client.Entities.Status> statusesNew = null;
2019-09-06 17:55:14 +02:00
if (statuses != null) {
2019-08-19 15:17:18 +02:00
statusesNew = new ArrayList<>();
2019-09-06 17:55:14 +02:00
for (app.fedilab.android.client.Entities.Status status : statuses) {
2019-08-19 16:33:09 +02:00
if (tag != null && !tag.contains("\"")) {
2019-08-19 15:17:18 +02:00
String[] searches = tag.split(" ");
for (String search : searches) {
if (status.getContent().contains(search) || status.getSpoiler_text().contains(search)) {
statusesNew.add(status);
}
}
2019-09-06 17:55:14 +02:00
} else {
2019-08-19 16:33:09 +02:00
statusesNew.addAll(statuses);
2019-08-19 15:17:18 +02:00
}
}
}
results.setStatuses(statusesNew);
2019-08-19 14:50:30 +02:00
apiResponse.setResults(results);
}
2019-03-31 15:15:46 +02:00
break;
2017-05-05 16:36:04 +02:00
case TAG:
2019-09-06 17:55:14 +02:00
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
2019-04-26 15:50:26 +02:00
ManageTimelines manageTimelines = new TimelinesDAO(contextReference.get(), db).getById(timelineId);
2019-09-06 17:55:14 +02:00
if (manageTimelines != null && manageTimelines.getTagTimeline() != null) {
2019-04-26 15:50:26 +02:00
boolean isArt = manageTimelines.getTagTimeline().isART();
2019-02-03 19:18:04 +01:00
if (isArt)
2019-09-06 17:55:14 +02:00
apiResponse = api.getCustomArtTimeline(false, manageTimelines.getTagTimeline().getName(), max_id, manageTimelines.getTagTimeline().getAny(), manageTimelines.getTagTimeline().getAll(), manageTimelines.getTagTimeline().getNone());
2019-02-03 19:18:04 +01:00
else
2019-04-26 15:50:26 +02:00
apiResponse = api.getPublicTimelineTag(manageTimelines.getTagTimeline().getName(), false, max_id, manageTimelines.getTagTimeline().getAny(), manageTimelines.getTagTimeline().getAll(), manageTimelines.getTagTimeline().getNone());
2019-09-06 17:55:14 +02:00
} else {
apiResponse = api.getPublicTimelineTag(tag, false, max_id, null, null, null);
2019-02-03 19:18:04 +01:00
}
2019-09-06 17:55:14 +02:00
} else {
2019-02-03 19:18:04 +01:00
GNUAPI gnuapi = new GNUAPI(this.contextReference.get());
2019-09-06 17:55:14 +02:00
apiResponse = gnuapi.search(tag, max_id);
2018-12-15 12:21:03 +01:00
}
2017-05-05 16:36:04 +02:00
break;
2018-12-05 12:04:49 +01:00
case ART:
2018-12-27 18:40:18 +01:00
apiResponse = api.getArtTimeline(false, max_id, null, null, null);
2018-12-05 12:04:49 +01:00
break;
2018-02-15 16:59:52 +01:00
case CACHE_BOOKMARKS:
apiResponse = new APIResponse();
2018-10-07 10:45:34 +02:00
db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2019-05-18 11:10:30 +02:00
List<app.fedilab.android.client.Entities.Status> statuses = new StatusCacheDAO(contextReference.get(), db).getAllStatus(StatusCacheDAO.BOOKMARK_CACHE);
2018-02-15 16:59:52 +01:00
apiResponse.setStatuses(statuses);
break;
2018-10-21 18:43:57 +02:00
case CACHE_BOOKMARKS_PEERTUBE:
apiResponse = new APIResponse();
db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<Peertube> peertubes = new PeertubeFavoritesDAO(contextReference.get(), db).getAllPeertube();
apiResponse.setPeertubes(peertubes);
break;
2018-02-17 11:28:52 +01:00
case CACHE_STATUS:
apiResponse = new APIResponse();
db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
2018-02-17 14:43:12 +01:00
statuses = new StatusCacheDAO(contextReference.get(), db).getStatusFromID(StatusCacheDAO.ARCHIVE_CACHE, filterToots, max_id);
2019-09-06 17:55:14 +02:00
if (statuses != null && statuses.size() > 0) {
2018-02-17 11:28:52 +01:00
apiResponse.setStatuses(statuses);
2018-02-17 18:08:06 +01:00
apiResponse.setSince_id(statuses.get(0).getId());
apiResponse.setMax_id(statuses.get(statuses.size() - 1).getId());
2019-09-06 17:55:14 +02:00
} else {
2018-02-17 11:28:52 +01:00
apiResponse.setStatuses(null);
apiResponse.setMax_id(null);
apiResponse.setSince_id(null);
}
break;
2019-01-03 14:23:13 +01:00
case PSUBSCRIPTIONS:
2019-01-03 18:59:44 +01:00
peertubeAPI = new PeertubeAPI(this.contextReference.get());
2019-01-03 14:23:13 +01:00
apiResponse = peertubeAPI.getSubscriptionsTL(max_id);
break;
case POVERVIEW:
peertubeAPI = new PeertubeAPI(this.contextReference.get());
apiResponse = peertubeAPI.getOverviewTL(max_id);
break;
case PTRENDING:
peertubeAPI = new PeertubeAPI(this.contextReference.get());
apiResponse = peertubeAPI.getTrendingTL(max_id);
break;
case PRECENTLYADDED:
peertubeAPI = new PeertubeAPI(this.contextReference.get());
apiResponse = peertubeAPI.getRecentlyAddedTL(max_id);
break;
case PLOCAL:
peertubeAPI = new PeertubeAPI(this.contextReference.get());
2019-01-07 17:00:03 +01:00
apiResponse = peertubeAPI.getLocalTL(max_id);
break;
case PMYVIDEOS:
peertubeAPI = new PeertubeAPI(this.contextReference.get());
2019-01-03 14:23:13 +01:00
apiResponse = peertubeAPI.getLocalTL(max_id);
break;
2019-01-15 15:41:30 +01:00
case PF_HOME:
api = new API(this.contextReference.get());
apiResponse = api.getHomeTimeline(max_id);
break;
2019-09-27 18:52:42 +02:00
case PF_REPLIES:
api = new API(this.contextReference.get());
apiResponse = api.getReplies(targetedID, max_id);
apiResponse.setTargetedId(targetedID);
break;
2019-01-15 15:41:30 +01:00
case PF_LOCAL:
api = new API(this.contextReference.get());
2019-09-06 17:55:14 +02:00
apiResponse = api.getPublicTimeline(true, max_id);
2019-09-25 11:29:58 +02:00
break;
2019-01-15 15:41:30 +01:00
case PF_DISCOVER:
api = new API(this.contextReference.get());
2019-09-06 17:55:14 +02:00
apiResponse = api.getDiscoverTimeline(true, max_id);
2019-01-15 15:41:30 +01:00
break;
2017-05-05 16:36:04 +02:00
case HASHTAG:
break;
2019-02-03 09:27:02 +01:00
case GNU_HOME:
GNUAPI gnuAPI = new GNUAPI(this.contextReference.get());
apiResponse = gnuAPI.getHomeTimeline(max_id);
break;
case GNU_LOCAL:
gnuAPI = new GNUAPI(this.contextReference.get());
2019-09-06 17:55:14 +02:00
apiResponse = gnuAPI.getPublicTimeline(true, max_id);
2019-02-03 09:27:02 +01:00
break;
case GNU_WHOLE:
gnuAPI = new GNUAPI(this.contextReference.get());
2019-09-06 17:55:14 +02:00
apiResponse = gnuAPI.getPublicTimeline(false, max_id);
2019-02-03 09:27:02 +01:00
break;
case GNU_DM:
gnuAPI = new GNUAPI(this.contextReference.get());
2019-02-27 09:54:38 +01:00
apiResponse = gnuAPI.getDirectTimeline(max_id);
2019-02-03 09:27:02 +01:00
break;
2019-07-24 10:16:19 +02:00
case GNU_GROUP_TIMELINE:
gnuAPI = new GNUAPI(this.contextReference.get());
apiResponse = gnuAPI.getGroupTimeline(tag.trim(), max_id);
break;
2017-05-05 16:36:04 +02:00
}
2019-10-01 18:11:43 +02:00
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
2019-01-03 17:11:53 +01:00
List<String> bookmarks = new StatusCacheDAO(contextReference.get(), db).getAllStatusId(StatusCacheDAO.BOOKMARK_CACHE);
if (apiResponse != null && apiResponse.getStatuses() != null && bookmarks != null && apiResponse.getStatuses().size() > 0) {
2019-05-18 11:10:30 +02:00
List<app.fedilab.android.client.Entities.Status> statuses = apiResponse.getStatuses();
for (app.fedilab.android.client.Entities.Status status : statuses) {
2019-01-03 17:11:53 +01:00
status.setBookmarked(bookmarks.contains(status.getId()));
}
}
2019-01-02 13:31:11 +01:00
}
2017-05-05 16:36:04 +02:00
return null;
}
@Override
protected void onPostExecute(Void result) {
listener.onRetrieveFeeds(apiResponse);
2017-05-05 16:36:04 +02:00
}
2019-11-15 16:32:25 +01:00
public enum Type {
HOME,
LOCAL,
DIRECT,
CONVERSATION,
PUBLIC,
HASHTAG,
LIST,
USER,
FAVOURITES,
ONESTATUS,
CONTEXT,
TAG,
REMOTE_INSTANCE,
REMOTE_INSTANCE_FILTERED,
ART,
PEERTUBE,
NOTIFICATION,
SEARCH,
NEWS,
PSUBSCRIPTIONS,
POVERVIEW,
PTRENDING,
PRECENTLYADDED,
PMYVIDEOS,
PLOCAL,
CHANNEL,
MYVIDEOS,
PEERTUBE_HISTORY,
PIXELFED,
PF_HOME,
PF_LOCAL,
PF_DISCOVER,
PF_NOTIFICATION,
PF_REPLIES,
GNU_HOME,
GNU_LOCAL,
GNU_WHOLE,
GNU_NOTIFICATION,
GNU_DM,
GNU_ART,
GNU_TAG,
GNU_GROUP_TIMELINE,
SCHEDULED_TOOTS,
CACHE_BOOKMARKS,
CACHE_BOOKMARKS_PEERTUBE,
CACHE_STATUS,
}
2017-05-05 16:36:04 +02:00
}