fixed results being duplicated when reopening the app

This commit is contained in:
Denis Çerri 2023-01-06 16:51:26 +01:00
parent 5d99255ef7
commit b83c73048b
No known key found for this signature in database
GPG key ID: 96B3554AF5B193EE
2 changed files with 4 additions and 3 deletions

View file

@ -121,8 +121,8 @@ public class DownloadsFragment extends Fragment implements DownloadsRecyclerView
databaseManager = new DatabaseManager(context);
databaseManager.clearHistoryItem(v, false);
int position = downloadsObjects.indexOf(v);
downloadsObjects.remove(v);
downloadsRecyclerViewAdapter.notifyItemRemoved(position);
downloadsObjects.remove(v);
if (downloadsObjects.isEmpty()) initCards();
downloading = false;

View file

@ -297,7 +297,6 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
Thread thread = new Thread(() -> {
databaseManager = new DatabaseManager(context);
resultObjects = databaseManager.getResults();
Log.e(TAG, resultObjects.toString());
String playlistTitle = "";
try {
playlistTitle = resultObjects.get(0).getPlaylistTitle();
@ -329,7 +328,9 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
}
uiHandler.post(() -> {
homeRecyclerViewAdapter.add(resultObjects);
if (homeRecyclerViewAdapter.getItemCount() != resultObjects.size()){
homeRecyclerViewAdapter.add(resultObjects);
}
shimmerCards.stopShimmer();
shimmerCards.setVisibility(View.GONE);
});