Show last applied for rules

This commit is contained in:
M66B
2020-12-24 08:30:03 +01:00
parent 00008a8954
commit 4cf74900fa
8 changed files with 2392 additions and 13 deletions

View File

@@ -54,6 +54,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Iterator;
@@ -67,6 +68,9 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
private LifecycleOwner owner;
private LayoutInflater inflater;
private DateFormat DF;
private NumberFormat NF = NumberFormat.getNumberInstance();
private int protocol = -1;
private String search = null;
private List<TupleRuleEx> all = new ArrayList<>();
@@ -79,9 +83,9 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
private ImageView ivStop;
private TextView tvCondition;
private TextView tvAction;
private TextView tvLastApplied;
private TextView tvApplied;
private NumberFormat NF = NumberFormat.getNumberInstance();
private TwoStateOwner powner = new TwoStateOwner(owner, "RulePopup");
ViewHolder(View itemView) {
@@ -93,6 +97,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
ivStop = itemView.findViewById(R.id.ivStop);
tvCondition = itemView.findViewById(R.id.tvCondition);
tvAction = itemView.findViewById(R.id.tvAction);
tvLastApplied = itemView.findViewById(R.id.tvLastApplied);
tvApplied = itemView.findViewById(R.id.tvApplied);
}
@@ -183,6 +188,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
tvAction.setText(ex.getMessage());
}
tvLastApplied.setText(rule.last_applied == null ? null : DF.format(rule.last_applied));
tvApplied.setText(NF.format(rule.applied));
}
@@ -405,6 +411,8 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
this.owner = parentFragment.getViewLifecycleOwner();
this.inflater = LayoutInflater.from(context);
this.DF = Helper.getDateTimeInstance(this.context);
setHasStableIds(true);
owner.getLifecycle().addObserver(new LifecycleObserver() {