mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Speed up deleting multiple messages.
This commit is contained in:
@@ -428,9 +428,12 @@ JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_MrMailboxGetMsgInfo(JNIEnv *
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_deleteMsg(JNIEnv *env, jclass cls, jint id)
|
||||
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_deleteMsgs(JNIEnv *env, jclass cls, jintArray msg_ids)
|
||||
{
|
||||
mrmailbox_delete_msg(get_mrmailbox_t(env, cls), id);
|
||||
int msg_ids_cnt;
|
||||
const uint32_t* msg_ids_ptr = jintArray2uint32Pointer(env, msg_ids, &msg_ids_cnt);
|
||||
mrmailbox_delete_msgs(get_mrmailbox_t(env, cls), msg_ids_ptr, msg_ids_cnt);
|
||||
free(msg_ids_ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ public class MrMailbox {
|
||||
return MrMailboxGetMsgInfo(m_hMailbox, id);
|
||||
}
|
||||
|
||||
public native static void deleteMsg(int id);
|
||||
public native static void deleteMsgs(int msg_ids[]);
|
||||
public native static void forwardMsgs(int msg_ids[], int chat_ids);
|
||||
|
||||
private native static long MrMailboxGetMsg (long hMailbox, int id); // return hMsg which must be unref'd after usage
|
||||
|
||||
@@ -2508,13 +2508,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
|
||||
ArrayList<Integer> ids = new ArrayList<>(selectedMessagesIds.keySet());
|
||||
if( ids.size()>0) {
|
||||
ArrayList<Integer> ids_list = new ArrayList<>(selectedMessagesIds.keySet());
|
||||
if( ids_list.size()>0) {
|
||||
int ids_arr[] = new int[selectedMessagesIds.size()], j = 0;
|
||||
for (HashMap.Entry<Integer, Integer> entry : selectedMessagesIds.entrySet()) {
|
||||
Integer id_to_del = entry.getKey();
|
||||
MrMailbox.deleteMsg(id_to_del);
|
||||
ids_arr[j++] = entry.getKey();
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDeleted, ids, 0);
|
||||
MrMailbox.deleteMsgs(ids_arr);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDeleted, ids_list, 0);
|
||||
}
|
||||
|
||||
actionBar.hideActionMode();
|
||||
|
||||
Reference in New Issue
Block a user