diff --git a/app/src/main/java/org/schabi/newpipe/local/history/HistoryRecordManager.java b/app/src/main/java/org/schabi/newpipe/local/history/HistoryRecordManager.java index 01d909c3c..6af57bc94 100644 --- a/app/src/main/java/org/schabi/newpipe/local/history/HistoryRecordManager.java +++ b/app/src/main/java/org/schabi/newpipe/local/history/HistoryRecordManager.java @@ -20,9 +20,9 @@ package org.schabi.newpipe.local.history; import android.content.Context; import android.content.SharedPreferences; -import androidx.preference.PreferenceManager; import androidx.annotation.NonNull; +import androidx.preference.PreferenceManager; import org.schabi.newpipe.NewPipeDatabase; import org.schabi.newpipe.R; @@ -101,9 +101,11 @@ public class HistoryRecordManager { })).subscribeOn(Schedulers.io()); } - public Single deleteStreamHistory(final long streamId) { - return Single.fromCallable(() -> streamHistoryTable.deleteStreamHistory(streamId)) - .subscribeOn(Schedulers.io()); + public Completable deleteStreamHistoryAndState(final long streamId) { + return Completable.fromAction(() -> { + streamStateTable.deleteState(streamId); + streamHistoryTable.deleteStreamHistory(streamId); + }).subscribeOn(Schedulers.io()); } public Single deleteWholeStreamHistory() { @@ -111,7 +113,7 @@ public class HistoryRecordManager { .subscribeOn(Schedulers.io()); } - public Single deleteCompelteStreamStateHistory() { + public Single deleteCompleteStreamStateHistory() { return Single.fromCallable(streamStateTable::deleteAll) .subscribeOn(Schedulers.io()); } diff --git a/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java index 8eb6dcb55..48a0e3430 100644 --- a/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java @@ -423,14 +423,14 @@ public class StatisticsPlaylistFragment } private void deleteEntry(final int index) { - final LocalItem infoItem = itemListAdapter.getItemsList() - .get(index); + final LocalItem infoItem = itemListAdapter.getItemsList().get(index); if (infoItem instanceof StreamStatisticsEntry) { final StreamStatisticsEntry entry = (StreamStatisticsEntry) infoItem; - final Disposable onDelete = recordManager.deleteStreamHistory(entry.getStreamId()) + final Disposable onDelete = recordManager + .deleteStreamHistoryAndState(entry.getStreamId()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( - howManyDeleted -> { + () -> { if (getView() != null) { Snackbar.make(getView(), R.string.one_item_deleted, Snackbar.LENGTH_SHORT).show(); diff --git a/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java index d9b404204..893e7c740 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java @@ -55,7 +55,7 @@ public class HistorySettingsFragment extends BasePreferenceFragment { .setNegativeButton(R.string.cancel, ((dialog, which) -> dialog.dismiss())) .setPositiveButton(R.string.delete, ((dialog, which) -> { final Disposable onDeletePlaybackStates - = recordManager.deleteCompelteStreamStateHistory() + = recordManager.deleteCompleteStreamStateHistory() .observeOn(AndroidSchedulers.mainThread()) .subscribe( howManyDeleted -> Toast.makeText(getActivity(), @@ -113,7 +113,7 @@ public class HistorySettingsFragment extends BasePreferenceFragment { .setPositiveButton(R.string.delete, ((dialog, which) -> { final Disposable onDeletePlaybackStates - = recordManager.deleteCompelteStreamStateHistory() + = recordManager.deleteCompleteStreamStateHistory() .observeOn(AndroidSchedulers.mainThread()) .subscribe( howManyDeleted -> Toast.makeText(getActivity(),