Simplified updating keyword colors

pull/178/head
M66B 5 years ago
parent e862382770
commit efa8a88a55

@ -165,41 +165,6 @@ public class AdapterKeyword extends RecyclerView.Adapter<AdapterKeyword.ViewHold
prefs.edit().remove("keyword." + keyword.name).apply(); prefs.edit().remove("keyword." + keyword.name).apply();
else else
prefs.edit().putInt("keyword." + keyword.name, keyword.color).apply(); prefs.edit().putInt("keyword." + keyword.name, keyword.color).apply();
Bundle args = new Bundle();
args.putLong("id", id);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id);
if (message == null)
return null;
// Update keyword colors
try {
db.beginTransaction();
db.message().setMessageKeywords(message.id, DB.Converters.fromStringArray(null));
db.message().setMessageKeywords(message.id, DB.Converters.fromStringArray(message.keywords));
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.e(ex);
}
}.execute(context, owner, args, "keyword:set");
} }
} }

@ -4166,6 +4166,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
FragmentDialogKeywordManage fragment = new FragmentDialogKeywordManage(); FragmentDialogKeywordManage fragment = new FragmentDialogKeywordManage();
fragment.setArguments(args); fragment.setArguments(args);
fragment.setTargetFragment(parentFragment, FragmentMessages.REQUEST_KEYWORDS);
fragment.show(parentFragment.getParentFragmentManager(), "keyword:manage"); fragment.show(parentFragment.getParentFragmentManager(), "keyword:manage");
} }
@ -4993,10 +4994,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
same = false; same = false;
log("duplicate changed", next.id); log("duplicate changed", next.id);
} }
if (!Arrays.equals(prev.keyword_colors, next.keyword_colors)) {
same = false;
log("keyword colors changed", next.id);
}
return same; return same;
} }

@ -324,6 +324,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private static final int REQUEST_EMPTY_FOLDER = 20; private static final int REQUEST_EMPTY_FOLDER = 20;
private static final int REQUEST_BOUNDARY_RETRY = 21; private static final int REQUEST_BOUNDARY_RETRY = 21;
static final int REQUEST_PICK_CONTACT = 22; static final int REQUEST_PICK_CONTACT = 22;
static final int REQUEST_KEYWORDS = 23;
static final String ACTION_STORE_RAW = BuildConfig.APPLICATION_ID + ".STORE_RAW"; static final String ACTION_STORE_RAW = BuildConfig.APPLICATION_ID + ".STORE_RAW";
static final String ACTION_DECRYPT = BuildConfig.APPLICATION_ID + ".DECRYPT"; static final String ACTION_DECRYPT = BuildConfig.APPLICATION_ID + ".DECRYPT";
@ -5049,6 +5050,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (resultCode == RESULT_OK && data != null) if (resultCode == RESULT_OK && data != null)
onPickContact(data.getData()); onPickContact(data.getData());
break; break;
case REQUEST_KEYWORDS:
adapter.notifyDataSetChanged();
break;
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);

Loading…
Cancel
Save