Add keyword to multiple messages

master
M66B 1 week ago
parent 00bc2580f3
commit 22608ab9e5

@ -37,8 +37,7 @@ public class FragmentDialogKeywordAdd extends FragmentDialogBase {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
final long id = getArguments().getLong("id");
Bundle args = getArguments();
final Context context = getContext();
View view = LayoutInflater.from(context).inflate(R.layout.dialog_keyword_add, null);
@ -52,25 +51,24 @@ public class FragmentDialogKeywordAdd extends FragmentDialogBase {
public void onClick(DialogInterface dialog, int which) {
String keyword = MessageHelper.sanitizeKeyword(etKeyword.getText().toString());
if (!TextUtils.isEmpty(keyword)) {
Bundle args = new Bundle();
args.putLong("id", id);
args.putString("keyword", keyword);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
long[] ids = args.getLongArray("ids");
String keyword = args.getString("keyword");
DB db = DB.getInstance(context);
try {
db.beginTransaction();
if (ids != null)
for (long id : ids) {
EntityMessage message = db.message().getMessage(id);
if (message == null)
return null;
if (message != null)
EntityOperation.queue(context, message, EntityOperation.KEYWORD, keyword, true);
}
db.setTransactionSuccessful();
} finally {

@ -64,7 +64,7 @@ public class FragmentDialogKeywordManage extends FragmentDialogBase {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putLong("id", id);
args.putLongArray("ids", new long[]{id});
FragmentDialogKeywordAdd fragment = new FragmentDialogKeywordAdd();
fragment.setArguments(args);
@ -101,7 +101,7 @@ public class FragmentDialogKeywordManage extends FragmentDialogBase {
.setIcon(R.drawable.twotone_label_important_24)
.setTitle(R.string.title_manage_keywords)
.setView(dview)
.setPositiveButton(android.R.string.ok, null)
.setNegativeButton(R.string.title_setup_done, null)
.create();
}

Loading…
Cancel
Save