Also delete stream state when deleting stream history
This commit is contained in:
parent
10e95bf1b1
commit
36248ff046
|
@ -20,9 +20,9 @@ package org.schabi.newpipe.local.history;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.schabi.newpipe.NewPipeDatabase;
|
import org.schabi.newpipe.NewPipeDatabase;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
@ -101,9 +101,11 @@ public class HistoryRecordManager {
|
||||||
})).subscribeOn(Schedulers.io());
|
})).subscribeOn(Schedulers.io());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Single<Integer> deleteStreamHistory(final long streamId) {
|
public Completable deleteStreamHistoryAndState(final long streamId) {
|
||||||
return Single.fromCallable(() -> streamHistoryTable.deleteStreamHistory(streamId))
|
return Completable.fromAction(() -> {
|
||||||
.subscribeOn(Schedulers.io());
|
streamStateTable.deleteState(streamId);
|
||||||
|
streamHistoryTable.deleteStreamHistory(streamId);
|
||||||
|
}).subscribeOn(Schedulers.io());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Single<Integer> deleteWholeStreamHistory() {
|
public Single<Integer> deleteWholeStreamHistory() {
|
||||||
|
@ -111,7 +113,7 @@ public class HistoryRecordManager {
|
||||||
.subscribeOn(Schedulers.io());
|
.subscribeOn(Schedulers.io());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Single<Integer> deleteCompelteStreamStateHistory() {
|
public Single<Integer> deleteCompleteStreamStateHistory() {
|
||||||
return Single.fromCallable(streamStateTable::deleteAll)
|
return Single.fromCallable(streamStateTable::deleteAll)
|
||||||
.subscribeOn(Schedulers.io());
|
.subscribeOn(Schedulers.io());
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,14 +420,14 @@ public class StatisticsPlaylistFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteEntry(final int index) {
|
private void deleteEntry(final int index) {
|
||||||
final LocalItem infoItem = itemListAdapter.getItemsList()
|
final LocalItem infoItem = itemListAdapter.getItemsList().get(index);
|
||||||
.get(index);
|
|
||||||
if (infoItem instanceof StreamStatisticsEntry) {
|
if (infoItem instanceof StreamStatisticsEntry) {
|
||||||
final StreamStatisticsEntry entry = (StreamStatisticsEntry) infoItem;
|
final StreamStatisticsEntry entry = (StreamStatisticsEntry) infoItem;
|
||||||
final Disposable onDelete = recordManager.deleteStreamHistory(entry.getStreamId())
|
final Disposable onDelete = recordManager
|
||||||
|
.deleteStreamHistoryAndState(entry.getStreamId())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
howManyDeleted -> {
|
() -> {
|
||||||
if (getView() != null) {
|
if (getView() != null) {
|
||||||
Snackbar.make(getView(), R.string.one_item_deleted,
|
Snackbar.make(getView(), R.string.one_item_deleted,
|
||||||
Snackbar.LENGTH_SHORT).show();
|
Snackbar.LENGTH_SHORT).show();
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
|
||||||
.setNegativeButton(R.string.cancel, ((dialog, which) -> dialog.dismiss()))
|
.setNegativeButton(R.string.cancel, ((dialog, which) -> dialog.dismiss()))
|
||||||
.setPositiveButton(R.string.delete, ((dialog, which) -> {
|
.setPositiveButton(R.string.delete, ((dialog, which) -> {
|
||||||
final Disposable onDeletePlaybackStates
|
final Disposable onDeletePlaybackStates
|
||||||
= recordManager.deleteCompelteStreamStateHistory()
|
= recordManager.deleteCompleteStreamStateHistory()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
howManyDeleted -> Toast.makeText(getActivity(),
|
howManyDeleted -> Toast.makeText(getActivity(),
|
||||||
|
@ -113,7 +113,7 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
|
||||||
.setPositiveButton(R.string.delete, ((dialog, which) -> {
|
.setPositiveButton(R.string.delete, ((dialog, which) -> {
|
||||||
|
|
||||||
final Disposable onDeletePlaybackStates
|
final Disposable onDeletePlaybackStates
|
||||||
= recordManager.deleteCompelteStreamStateHistory()
|
= recordManager.deleteCompleteStreamStateHistory()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
howManyDeleted -> Toast.makeText(getActivity(),
|
howManyDeleted -> Toast.makeText(getActivity(),
|
||||||
|
|
Loading…
Reference in New Issue