41 lines
1.2 KiB
Java
41 lines
1.2 KiB
Java
|
package app.fedilab.fedilabtube.asynctasks;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.os.AsyncTask;
|
||
|
|
||
|
import java.lang.ref.WeakReference;
|
||
|
|
||
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||
|
import app.fedilab.fedilabtube.client.PeertubeAPI;
|
||
|
import app.fedilab.fedilabtube.interfaces.OnRetrieveFeedsInterface;
|
||
|
|
||
|
|
||
|
public class RetrievePeertubeSearchAsyncTask extends AsyncTask<Void, Void, Void> {
|
||
|
|
||
|
private String query, instance;
|
||
|
private APIResponse apiResponse;
|
||
|
private OnRetrieveFeedsInterface listener;
|
||
|
private WeakReference<Context> contextReference;
|
||
|
|
||
|
public RetrievePeertubeSearchAsyncTask(Context context, String instance, String query, OnRetrieveFeedsInterface onRetrieveFeedsInterface) {
|
||
|
this.contextReference = new WeakReference<>(context);
|
||
|
this.query = query;
|
||
|
this.listener = onRetrieveFeedsInterface;
|
||
|
this.instance = instance;
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
protected Void doInBackground(Void... params) {
|
||
|
PeertubeAPI api = new PeertubeAPI(this.contextReference.get());
|
||
|
apiResponse = api.searchPeertube(instance, query);
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void onPostExecute(Void result) {
|
||
|
listener.onRetrieveFeeds(apiResponse);
|
||
|
}
|
||
|
|
||
|
}
|