From 3fa9bebcb26981f4de5755300354495798481ed3 Mon Sep 17 00:00:00 2001 From: tanvirahmod Date: Thu, 21 Jan 2021 16:33:38 +0600 Subject: [PATCH 1/2] Add option to move checklist item all the way top or bottom #370 --- .../notes/pro/adapters/ChecklistAdapter.kt | 17 +++++++++++++++++ .../res/drawable-anydpi/ic_move_to_bottom.xml | 11 +++++++++++ .../res/drawable-anydpi/ic_move_to_top.xml | 11 +++++++++++ .../res/drawable-hdpi/ic_move_to_bottom.png | Bin 0 -> 188 bytes .../main/res/drawable-hdpi/ic_move_to_top.png | Bin 0 -> 182 bytes .../res/drawable-mdpi/ic_move_to_bottom.png | Bin 0 -> 119 bytes .../main/res/drawable-mdpi/ic_move_to_top.png | Bin 0 -> 116 bytes .../res/drawable-xhdpi/ic_move_to_bottom.png | Bin 0 -> 162 bytes .../main/res/drawable-xhdpi/ic_move_to_top.png | Bin 0 -> 161 bytes .../res/drawable-xxhdpi/ic_move_to_bottom.png | Bin 0 -> 205 bytes .../res/drawable-xxhdpi/ic_move_to_top.png | Bin 0 -> 207 bytes app/src/main/res/menu/cab_checklist.xml | 10 ++++++++++ app/src/main/res/values-ar/strings.xml | 2 ++ app/src/main/res/values-az/strings.xml | 2 ++ app/src/main/res/values-cs/strings.xml | 2 ++ app/src/main/res/values-cy/strings.xml | 2 ++ app/src/main/res/values-da/strings.xml | 2 ++ app/src/main/res/values-de/strings.xml | 2 ++ app/src/main/res/values-el/strings.xml | 2 ++ app/src/main/res/values-es/strings.xml | 2 ++ app/src/main/res/values-fr/strings.xml | 2 ++ app/src/main/res/values-gl/strings.xml | 2 ++ app/src/main/res/values-hr/strings.xml | 2 ++ app/src/main/res/values-hu/strings.xml | 2 ++ app/src/main/res/values-id/strings.xml | 2 ++ app/src/main/res/values-in/strings.xml | 2 ++ app/src/main/res/values-it/strings.xml | 2 ++ app/src/main/res/values-ja/strings.xml | 2 ++ app/src/main/res/values-lt/strings.xml | 2 ++ app/src/main/res/values-nl/strings.xml | 2 ++ app/src/main/res/values-pl/strings.xml | 2 ++ app/src/main/res/values-pt-rBR/strings.xml | 2 ++ app/src/main/res/values-pt/strings.xml | 2 ++ app/src/main/res/values-ru/strings.xml | 2 ++ app/src/main/res/values-sk/strings.xml | 2 ++ app/src/main/res/values-sv/strings.xml | 2 ++ app/src/main/res/values-tr/strings.xml | 2 ++ app/src/main/res/values-uk/strings.xml | 2 ++ app/src/main/res/values-zh-rCN/strings.xml | 2 ++ app/src/main/res/values-zh-rTW/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 41 files changed, 107 insertions(+) create mode 100644 app/src/main/res/drawable-anydpi/ic_move_to_bottom.xml create mode 100644 app/src/main/res/drawable-anydpi/ic_move_to_top.xml create mode 100644 app/src/main/res/drawable-hdpi/ic_move_to_bottom.png create mode 100644 app/src/main/res/drawable-hdpi/ic_move_to_top.png create mode 100644 app/src/main/res/drawable-mdpi/ic_move_to_bottom.png create mode 100644 app/src/main/res/drawable-mdpi/ic_move_to_top.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_move_to_bottom.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_move_to_top.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_move_to_bottom.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_move_to_top.png diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt index d3511954..9dbb1460 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt @@ -60,6 +60,8 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList moveSelectedItems(true) + R.id.cab_move_to_bottom -> moveSelectedItems(false) R.id.cab_rename -> renameChecklistItem() R.id.cab_delete -> deleteSelection() } @@ -145,6 +147,21 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList + val position = items.indexOfFirst { it.id == keys.value } + val tempItem = items[position] + items.remove(tempItem) + if (isMoveToTop) + items.add(0, tempItem) + else + items.add(items.size, tempItem) + } + notifyDataSetChanged() + listener?.saveChecklist() + } + private fun getItemWithKey(key: Int): ChecklistItem? = items.firstOrNull { it.id == key } private fun getSelectedItems() = items.filter { selectedKeys.contains(it.id) } as ArrayList diff --git a/app/src/main/res/drawable-anydpi/ic_move_to_bottom.xml b/app/src/main/res/drawable-anydpi/ic_move_to_bottom.xml new file mode 100644 index 00000000..c8adf15c --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_move_to_bottom.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/drawable-anydpi/ic_move_to_top.xml b/app/src/main/res/drawable-anydpi/ic_move_to_top.xml new file mode 100644 index 00000000..4c8580d3 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_move_to_top.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/drawable-hdpi/ic_move_to_bottom.png b/app/src/main/res/drawable-hdpi/ic_move_to_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..62b6ae788ef19e45fb6959e5f2535a57e3aa51ec GIT binary patch literal 188 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k1|%Oc%$NbBnmt_{Ln>~)y?&avK|#PZaMl8j zt_7T@7IMs95HQCxLf}#R3FVdQ&MBb@069ZK;Q#;t literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/ic_move_to_top.png b/app/src/main/res/drawable-hdpi/ic_move_to_top.png new file mode 100644 index 0000000000000000000000000000000000000000..5f64fafc89abc3fb99e29cc1fe9492ac1e34c20d GIT binary patch literal 182 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k1|%Oc%$NbBYCT;XLn>}1CrGd^Zg6|>|Nno- zEk~YMWEkpx+)!}gLD!~0ho>@{T!)%Z8rBBrSVhP%pSERwuA$Q>Y2p5`kms+gYfJKr z*BT2{w`H`(h)z;ob>T@4`zoO}ON|VJl;45uy;d1l92fIRm0noU>?Z4y%AToYYHs4b f+h%dX0!9V_rK|Rrc3PJL9m3%0>gTe~DWM4f{((Ud literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_move_to_bottom.png b/app/src/main/res/drawable-mdpi/ic_move_to_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..36f2a775f62f881cab79c3e152735504d9267cec GIT binary patch literal 119 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjcAhSdAr-fh6C_x#u>Al3Kc45% zVzHhmgRFxAn;9|^1kNPrSaeLA#&YqJy5p9vW`$Xjc3)1_6n#7pZNPPbkwLVBsbdRI Rz6{VL22WQ%mvv4FO#t_`CS3pk literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_move_to_top.png b/app/src/main/res/drawable-mdpi/ic_move_to_top.png new file mode 100644 index 0000000000000000000000000000000000000000..0e6852f482b4cfa7b47960b135cd78ecdd406096 GIT binary patch literal 116 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gj)}AhoAr-fh6C_xdH2weoUw;`3 z{~p%Ec6Ch-Gp4m2K4jG~tu6SvkWAayB3S}L>Xi;%IZkWWMJ@n$kcK0<$hJ5 OF$|urelF{r5}E*@C?)p* literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_move_to_bottom.png b/app/src/main/res/drawable-xhdpi/ic_move_to_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..096fce2f929a6b060f8072c8521ee8b604a50fa0 GIT binary patch literal 162 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUtOivfbkcwMxuQ_rx7znT&+*7#! zh4W%}&W?^QzZGqJ{TDW^^}ICY>%HlJ8G))1;0)W1V^=M{9SSvCG-VChk-}|>G z9iOjYbWC1h(=q;zGaoPM-2HLB@(BaOJ~od_tJelA?&Ndqy2G8G z^Su=ocIrumHF`%*fBgC0<)^~)z1qp!pdjGtn6<=} z>nNLuzDw$J)%^@=Hz!O|@tpMKYS!A++!O{zCKe6>1&0Pa3^p6Pe8!T9HWTY}&K@^+ zx*mSnVq$*IcZr0B_{5}#b6mPQiv={z&hZJ&VFMu<&q;B=yH3w%2b-(J>^VtA(~Vnf X`MHPPLG|)L_c3_7`njxgN@xNARqH#t literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_move_to_top.png b/app/src/main/res/drawable-xxhdpi/ic_move_to_top.png new file mode 100644 index 0000000000000000000000000000000000000000..22629474e9f9d94909225113414cdee60449eb12 GIT binary patch literal 207 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!(>z@qLn>~)y|IzE!GMS1;F%L$ zJXtP|k|_!zo$pok3tCfmntD!B$#fCic;2Rgfsu)2h0z2R&sTEzopr07PIuxc~qF literal 0 HcmV?d00001 diff --git a/app/src/main/res/menu/cab_checklist.xml b/app/src/main/res/menu/cab_checklist.xml index 846ca634..668197c7 100644 --- a/app/src/main/res/menu/cab_checklist.xml +++ b/app/src/main/res/menu/cab_checklist.xml @@ -1,6 +1,16 @@ + + إضافة عناصر قائمة تدقيق جديدة قائمة التدقيق فارغة Remove done items + Move to top + Move to bottom تصدير جميع الملاحظات كملفات diff --git a/app/src/main/res/values-az/strings.xml b/app/src/main/res/values-az/strings.xml index 7d9b2696..0d9f5505 100644 --- a/app/src/main/res/values-az/strings.xml +++ b/app/src/main/res/values-az/strings.xml @@ -56,6 +56,8 @@ Add new checklist items The checklist is empty Remove done items + Move to top + Move to bottom Bütün qeydləri fayl şəklində çıxar diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 24b45f43..0384f8cb 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -56,6 +56,8 @@ Přidat do seznamu nové položky Seznam položek je prázdný Remove done items + Move to top + Move to bottom Exportovat všechny poznámky jako soubory diff --git a/app/src/main/res/values-cy/strings.xml b/app/src/main/res/values-cy/strings.xml index 9d98224d..fa14a758 100644 --- a/app/src/main/res/values-cy/strings.xml +++ b/app/src/main/res/values-cy/strings.xml @@ -56,6 +56,8 @@ Ychwanegu eitemau newydd at restr wirio Mae\'r rhestr wirio yn wag Remove done items + Move to top + Move to bottom Allforio pob nodyn fel ffeil diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 40e8d1ce..53865748 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -56,6 +56,8 @@ Føj nye punkter til tjeklisten Tjeklisten er tom Remove done items + Move to top + Move to bottom Eksporter alle noter som filer diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index c42e7dd7..b59f7479 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -56,6 +56,8 @@ Neue Checklisteneinträge hinzufügen Die Checkliste ist leer Remove done items + Move to top + Move to bottom Alle Notizen als Dateien exportieren diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 326d144a..0ae274e9 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -56,6 +56,8 @@ Προσθήκη νέων στοιχείων λίστας ελέγχου Η λίστα ελέγχου είναι κενή Remove done items + Move to top + Move to bottom Εξαγωγή όλων των σημειώσεων ως αρχεία diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index d39a8230..ea44ce12 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -56,6 +56,8 @@ Añadir nuevos items a la lista La lista está vacía Remove done items + Move to top + Move to bottom Exportar todas las notas como archivos diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 588f08bd..2efc2365 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -56,6 +56,8 @@ Ajouter de nouveaux éléments La checklist est vide Remove done items + Move to top + Move to bottom Exporter toutes les notes en tant que fichiers diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml index 79239339..de51d9d1 100644 --- a/app/src/main/res/values-gl/strings.xml +++ b/app/src/main/res/values-gl/strings.xml @@ -56,6 +56,8 @@ Engadir elementos a unha nova lista de verificación A lista de verificación está baleira Remove done items + Move to top + Move to bottom Exportar todas as notas como ficheiros diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index da44924a..943df4ff 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -56,6 +56,8 @@ Dodajte nove stavke na spisak Spisak je prazan Remove done items + Move to top + Move to bottom Izvezi sve bilješke kao datoteke diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 74af6462..c768b421 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -56,6 +56,8 @@ Add new checklist items The checklist is empty Remove done items + Move to top + Move to bottom Export all notes as files diff --git a/app/src/main/res/values-id/strings.xml b/app/src/main/res/values-id/strings.xml index 7bc2c54f..433bedc6 100644 --- a/app/src/main/res/values-id/strings.xml +++ b/app/src/main/res/values-id/strings.xml @@ -56,6 +56,8 @@ Tambah item checklist baru Checklist kosong Remove done items + Move to top + Move to bottom Ekspor semua catatan ke berkas diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 7bc2c54f..433bedc6 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -56,6 +56,8 @@ Tambah item checklist baru Checklist kosong Remove done items + Move to top + Move to bottom Ekspor semua catatan ke berkas diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 442a88e4..bee6b69a 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -56,6 +56,8 @@ Aggiungi nuovi elementi La scaletta è vuota Remove done items + Move to top + Move to bottom Esporta le note come file diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 95f3096a..649fbdd1 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -56,6 +56,8 @@ 新しいチェックリスト項目を追加 チェックリストが空です Remove done items + Move to top + Move to bottom すべてのメモをファイルとしてエクスポート diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 8d3e0b15..5daa0558 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -56,6 +56,8 @@ Pridėti naujus kontrolinio sąrašo objektus Kontrolinis sąršas tuščias Remove done items + Move to top + Move to bottom Eksportuoti visus užrašus kaip bylas diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 6f51f564..2ed49414 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -56,6 +56,8 @@ Items toevoegen De lijst is leeg Afgeronde items wissen + Move to top + Move to bottom Alle notities naar bestanden exporteren diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index dcd5bb98..966bd434 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -56,6 +56,8 @@ Add new checklist items The checklist is empty Remove done items + Move to top + Move to bottom Eksportuj wszystkie notatki jako pliki diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index e10c0a85..fe525633 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -56,6 +56,8 @@ Adicionar novos itens de lista de verificação A lista de verificação está vazia Remove done items + Move to top + Move to bottom Exportar todas as notas como arquivo diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index e245d344..858a6660 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -56,6 +56,8 @@ Adicionar itens à lista de verificação A lista está vazia Remover itens realizados + Move to top + Move to bottom Exportar todas as notas como ficheiros diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index f2f88b9a..8c84ef63 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -56,6 +56,8 @@ Добавить позиции в список Список пуст Remove done items + Move to top + Move to bottom Экспортировать все заметки в файлы diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index ea1075ac..4288962c 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -56,6 +56,8 @@ Pridať do zoznamu nové položky Zoznam položiek je prázdny Odstrániť splnené položky + Move to top + Move to bottom Exportovať všetky poznámky ako súbory diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 65cd3c46..cf99e37b 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -56,6 +56,8 @@ Lägg till nya checklisteobjekt Checklistan är tom Remove done items + Move to top + Move to bottom Exportera alla anteckningar som filer diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index b492a6d4..18bdad40 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -56,6 +56,8 @@ Yeni yapılacak listesi öğeleri ekle Yapılacak listesi boş Remove done items + Move to top + Move to bottom Tüm notları dosya olarak dışa aktar diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 5819bd6c..bb8757fd 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -56,6 +56,8 @@ Додати нові позиції у списку Список порожній Remove done items + Move to top + Move to bottom Експортувати всі нотатки як файли diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index cb6a3a66..d8907f7b 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -56,6 +56,8 @@ 添加新的清单项目 清单为空 Remove done items + Move to top + Move to bottom 以文件导出所有笔记 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 35814d14..83ace3db 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -56,6 +56,8 @@ 新增新的核對清單項目 核對清單為空白 Remove done items + Move to top + Move to bottom 將全部筆記匯出成檔案 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 447b1549..430db9e7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -56,6 +56,8 @@ Add new checklist items The checklist is empty Remove done items + Move to top + Move to bottom Export all notes as files From e6e1df75632890cfff806e7b15a0882b9c1ff2c2 Mon Sep 17 00:00:00 2001 From: tanvirahmod Date: Thu, 21 Jan 2021 17:17:47 +0600 Subject: [PATCH 2/2] Fix item movement issue --- .../notes/pro/adapters/ChecklistAdapter.kt | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt index 9dbb1460..2460c0f9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt @@ -60,8 +60,8 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList moveSelectedItems(true) - R.id.cab_move_to_bottom -> moveSelectedItems(false) + R.id.cab_move_to_top -> moveSelectedItemsToTop() + R.id.cab_move_to_bottom -> moveSelectedItemsToBottom() R.id.cab_rename -> renameChecklistItem() R.id.cab_delete -> deleteSelection() } @@ -147,16 +147,26 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList + val position = items.indexOfFirst { it.id == keys.value } + val tempItem = items[position] + items.removeAt(position) + items.add(0, tempItem) + } + notifyDataSetChanged() + listener?.saveChecklist() + } + + private fun moveSelectedItemsToBottom() { selectedKeys.withIndex() .forEach { keys -> val position = items.indexOfFirst { it.id == keys.value } val tempItem = items[position] - items.remove(tempItem) - if (isMoveToTop) - items.add(0, tempItem) - else - items.add(items.size, tempItem) + items.removeAt(position) + items.add(items.size, tempItem) } notifyDataSetChanged() listener?.saveChecklist()