Commit c7721004 authored by Mathilde BALLOUHEY's avatar Mathilde BALLOUHEY
Browse files

Ajout du chargement de la liste de favotis en Asynchrone

parent fdf11f24
Pipeline #23276 failed with stages
in 2 minutes and 46 seconds
......@@ -9,6 +9,7 @@ import androidx.recyclerview.widget.RecyclerView;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
......@@ -150,6 +151,11 @@ public class HomeActivity extends AppCompatActivity {
@Override
protected void onResume() {
super.onResume();
AsyncTaskGetFavourites v_asyncTaskGetFavourites = new AsyncTaskGetFavourites();
v_asyncTaskGetFavourites.execute((Nullable) null);
}
private void getFav() {
m_favourites.clear();
m_favourites.addAll(DnDSheet.getFavs(this));
sortFavourites();
......@@ -162,7 +168,6 @@ public class HomeActivity extends AppCompatActivity {
else {
Collections.sort(m_favourites, DnDSheet.COMPARATOR_BY_CLASS);
}
m_adapter.notifyDataSetChanged();
}
private View.OnClickListener onClickDelFav() {
......@@ -180,4 +185,18 @@ public class HomeActivity extends AppCompatActivity {
};
return v_onClickListener;
}
private class AsyncTaskGetFavourites extends AsyncTask<Nullable, String, Nullable> {
@Override
protected Nullable doInBackground(Nullable... nullables) {
getFav();
return null;
}
@Override
protected void onPostExecute(Nullable nullable) {
super.onPostExecute(nullable);
m_adapter.notifyDataSetChanged();
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment