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.OnRetrieveAccountsInterface;
|
|
|
|
|
|
public class RetrieveAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|
|
|
private APIResponse apiResponse;
|
|
private OnRetrieveAccountsInterface listener;
|
|
private WeakReference<Context> contextReference;
|
|
private String name;
|
|
|
|
public RetrieveAccountsAsyncTask(Context context, String name, OnRetrieveAccountsInterface onRetrieveAccountsInterface) {
|
|
this.contextReference = new WeakReference<>(context);
|
|
this.name = name;
|
|
this.listener = onRetrieveAccountsInterface;
|
|
}
|
|
|
|
|
|
@Override
|
|
protected Void doInBackground(Void... params) {
|
|
PeertubeAPI peertubeAPI = new PeertubeAPI(this.contextReference.get());
|
|
apiResponse = peertubeAPI.getPeertubeChannel(name);
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
protected void onPostExecute(Void result) {
|
|
listener.onRetrieveAccounts(apiResponse);
|
|
}
|
|
|
|
|
|
}
|