Fix an issue for refreshing remote instances
This commit is contained in:
parent
3d346cd666
commit
8ddcbf6f17
|
@ -38,6 +38,7 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
private List<fr.gouv.etalab.mastodon.client.Entities.Status> statuses = new ArrayList<>();
|
||||
private RetrieveFeedsAsyncTask.Type type;
|
||||
private WeakReference<Context> contextReference;
|
||||
private String remoteInstance;
|
||||
|
||||
public RetrieveMissingFeedsAsyncTask(Context context, String since_id, RetrieveFeedsAsyncTask.Type type, OnRetrieveMissingFeedsInterface onRetrieveMissingFeedsInterface){
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
|
@ -46,6 +47,14 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public RetrieveMissingFeedsAsyncTask(Context context, String remoteInstance, String since_id, RetrieveFeedsAsyncTask.Type type, OnRetrieveMissingFeedsInterface onRetrieveMissingFeedsInterface){
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.since_id = since_id;
|
||||
this.listener = onRetrieveMissingFeedsInterface;
|
||||
this.type = type;
|
||||
this.remoteInstance = remoteInstance;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
@ -58,6 +67,8 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
apiResponse = api.getPublicTimelineSinceId(true, since_id);
|
||||
else if( type == RetrieveFeedsAsyncTask.Type.PUBLIC)
|
||||
apiResponse = api.getPublicTimelineSinceId(false, since_id);
|
||||
else if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE)
|
||||
apiResponse = api.getInstanceTimelineSinceId(remoteInstance, since_id);
|
||||
if (apiResponse != null) {
|
||||
tempStatus = apiResponse.getStatuses();
|
||||
if( tempStatus != null)
|
||||
|
|
|
@ -562,7 +562,15 @@ public class API {
|
|||
return getPublicTimeline(local, null, null, since_id, tootPerPage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves instance timeline since an Id value *synchronously*
|
||||
* @param instanceName String instance name
|
||||
* @param since_id String id since
|
||||
* @return APIResponse
|
||||
*/
|
||||
public APIResponse getInstanceTimelineSinceId(String instanceName, String since_id) {
|
||||
return getPublicTimeline(true, null, null, since_id, tootPerPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves public timeline for the account *synchronously*
|
||||
|
|
|
@ -476,7 +476,10 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
* @param sinceId String
|
||||
*/
|
||||
public void retrieveMissingToots(String sinceId){
|
||||
asyncTask = new RetrieveMissingFeedsAsyncTask(context, sinceId, type, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE)
|
||||
asyncTask = new RetrieveMissingFeedsAsyncTask(context, sinceId, type, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else
|
||||
asyncTask = new RetrieveMissingFeedsAsyncTask(context, remoteInstance, sinceId, type, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue