Allow deleting operations in debug mode

This commit is contained in:
M66B 2019-02-11 15:01:49 +00:00
parent 8398e23d78
commit 253c5b1424
1 changed files with 10 additions and 2 deletions

View File

@ -21,7 +21,9 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -46,6 +48,8 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
private LayoutInflater inflater; private LayoutInflater inflater;
private LifecycleOwner owner; private LifecycleOwner owner;
private boolean debug;
private List<TupleOperationEx> all = new ArrayList<>(); private List<TupleOperationEx> all = new ArrayList<>();
private List<TupleOperationEx> filtered = new ArrayList<>(); private List<TupleOperationEx> filtered = new ArrayList<>();
@ -70,13 +74,13 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
private void wire() { private void wire() {
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG || debug)
itemView.setOnLongClickListener(this); itemView.setOnLongClickListener(this);
} }
private void unwire() { private void unwire() {
itemView.setOnClickListener(null); itemView.setOnClickListener(null);
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG || debug)
itemView.setOnLongClickListener(null); itemView.setOnLongClickListener(null);
} }
@ -208,6 +212,10 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
this.context = context; this.context = context;
this.inflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.owner = owner; this.owner = owner;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.debug = prefs.getBoolean("debug", false);
setHasStableIds(true); setHasStableIds(true);
} }