diff options
author | tom79 <tschneider.ac@gmail.com> | 2017-10-07 08:34:50 +0200 |
---|---|---|
committer | tom79 <tschneider.ac@gmail.com> | 2017-10-07 08:34:50 +0200 |
commit | 4d0c3dae7e465301585f50e447a3e09c5154ce41 (patch) | |
tree | cdd4b02d4511ef0e2d459ef5aaa01c50af6b2c86 /app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveMissingFeedsAsyncTask.java | |
parent | fb0ee85e7fd6a9b8139f65d403f2e9dcbc21136b (diff) |
Some fixes
Diffstat (limited to 'app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveMissingFeedsAsyncTask.java')
-rw-r--r-- | app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveMissingFeedsAsyncTask.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveMissingFeedsAsyncTask.java b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveMissingFeedsAsyncTask.java index c6773404c..2e1950ace 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveMissingFeedsAsyncTask.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveMissingFeedsAsyncTask.java @@ -35,11 +35,13 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> { private String since_id; private OnRetrieveMissingFeedsInterface listener; private List<fr.gouv.etalab.mastodon.client.Entities.Status> statuses = new ArrayList<>(); + private RetrieveFeedsAsyncTask.Type type; - public RetrieveMissingFeedsAsyncTask(Context context, String since_id, OnRetrieveMissingFeedsInterface onRetrieveMissingFeedsInterface){ + public RetrieveMissingFeedsAsyncTask(Context context, String since_id, RetrieveFeedsAsyncTask.Type type, OnRetrieveMissingFeedsInterface onRetrieveMissingFeedsInterface){ this.context = context; this.since_id = since_id; this.listener = onRetrieveMissingFeedsInterface; + this.type = type; } @@ -48,18 +50,27 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> { int loopInc = 0; API api = new API(context); List<fr.gouv.etalab.mastodon.client.Entities.Status> tempStatus; + APIResponse apiResponse = null; while (loopInc < 10){ - APIResponse apiResponse = api.getHomeTimelineSinceId(since_id, 80); + + if( type == RetrieveFeedsAsyncTask.Type.HOME) + apiResponse = api.getHomeTimelineSinceId(since_id, 80); + else if( type == RetrieveFeedsAsyncTask.Type.LOCAL) + apiResponse = api.getPublicTimelineSinceId(true, since_id, 80); + else if( type == RetrieveFeedsAsyncTask.Type.PUBLIC) + apiResponse = api.getPublicTimelineSinceId(false, since_id, 80); + if (apiResponse == null) + break; String max_id = apiResponse.getMax_id(); since_id = apiResponse.getSince_id(); tempStatus = apiResponse.getStatuses(); if( statuses != null && tempStatus != null) statuses.addAll(0, tempStatus); loopInc++; - if( max_id == null || max_id.equals(since_id)) + if( tempStatus == null || max_id == null || max_id.equals(since_id) || tempStatus.size() == 0) break; } - if( statuses != null && statuses.size() > 0) { + if( type == RetrieveFeedsAsyncTask.Type.HOME && statuses != null && statuses.size() > 0) { MainActivity.lastHomeId = statuses.get(0).getId(); } return null; |