Show mark seen in rule list

pull/217/head
M66B 7 months ago
parent 7112d93d47
commit c19099e5d0

@ -264,8 +264,10 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
if (TextUtils.isEmpty(method))
method = "GET";
setAction(getAction(type), method + " " + url);
} else
setAction(getAction(type), null);
} else {
boolean seen = jaction.optBoolean("seen");
setAction(getAction(type), seen ? context.getString(R.string.title_rule_seen) : null, null);
}
if (type == EntityRule.TYPE_MOVE || type == EntityRule.TYPE_COPY ||
(type == EntityRule.TYPE_ANSWER && TextUtils.isEmpty(to))) {
@ -302,7 +304,9 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
if (id != AdapterRule.this.getItemId(pos))
return;
setAction(getAction(args.getInt("type")), value);
boolean seen = jaction.optBoolean("seen");
setAction(getAction(args.getInt("type")),
seen ? context.getString(R.string.title_rule_seen) : null, value);
}
@Override
@ -565,16 +569,24 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
}
private void setAction(int resid, String value) {
if (TextUtils.isEmpty(value))
setAction(resid, null, value);
}
private void setAction(int resid, String extra, String value) {
if (TextUtils.isEmpty(extra) && TextUtils.isEmpty(value))
tvAction.setText(resid);
else {
SpannableStringBuilder ssb = new SpannableStringBuilderEx();
ssb.append(context.getString(resid));
ssb.append(" \"");
int start = ssb.length();
ssb.append(value);
ssb.setSpan(new StyleSpan(Typeface.ITALIC), start, ssb.length(), 0);
ssb.append("\"");
if (extra != null)
ssb.append('+').append(extra);
if (value != null) {
ssb.append(" \"");
int start = ssb.length();
ssb.append(value);
ssb.setSpan(new StyleSpan(Typeface.ITALIC), start, ssb.length(), 0);
ssb.append("\"");
}
tvAction.setText(ssb);
}
}

Loading…
Cancel
Save