1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-17 23:34:54 +00:00

Delete on long press

This commit is contained in:
Somethingweirdhere 2018-06-28 20:43:46 +02:00
parent a68823491c
commit 0b7593ad28

View File

@ -8,8 +8,12 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.Parcelable; import android.os.Parcelable;
@ -21,6 +25,7 @@ import android.support.v7.app.ActionBar;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log; import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -78,6 +83,7 @@ import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function; import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import static android.content.ContentValues.TAG;
import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_MODE; import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_MODE;
import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_VALUE; import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_VALUE;
import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.PREVIOUS_EXPORT_MODE; import static org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.PREVIOUS_EXPORT_MODE;
@ -400,20 +406,20 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe((@NonNull ChannelInfo result) -> { .subscribe((@NonNull ChannelInfo result) -> {
mapOnUnsubscribe(SubscriptionEntity.from(result)); new LongOperation().execute(SubscriptionEntity.from(result));
}, (@NonNull Throwable throwable) -> { }, (@NonNull Throwable throwable) -> {
}); });
} }
private Function<Object, Object> mapOnUnsubscribe(final SubscriptionEntity subscription) {
return new Function<Object, Object>() { private class LongOperation extends AsyncTask<SubscriptionEntity, Void, Void> {
@Override
public Object apply(@NonNull Object o) throws Exception { @Override
subscriptionService.subscriptionTable().delete(subscription); protected Void doInBackground(SubscriptionEntity... params) {
return o; subscriptionService.subscriptionTable().delete(params[0]);
} return null;
}; }
} }
private void resetFragment() { private void resetFragment() {