Skip to content

Commit 3fa9beb

Browse files
committed
Add option to move checklist item all the way top or bottom #370
1 parent a64eabd commit 3fa9beb

File tree

41 files changed

+107
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+107
-0
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList<Checkl
6060
}
6161

6262
when (id) {
63+
R.id.cab_move_to_top -> moveSelectedItems(true)
64+
R.id.cab_move_to_bottom -> moveSelectedItems(false)
6365
R.id.cab_rename -> renameChecklistItem()
6466
R.id.cab_delete -> deleteSelection()
6567
}
@@ -145,6 +147,21 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList<Checkl
145147
}
146148
}
147149

150+
private fun moveSelectedItems(isMoveToTop: Boolean) {
151+
selectedKeys.withIndex()
152+
.forEach { keys ->
153+
val position = items.indexOfFirst { it.id == keys.value }
154+
val tempItem = items[position]
155+
items.remove(tempItem)
156+
if (isMoveToTop)
157+
items.add(0, tempItem)
158+
else
159+
items.add(items.size, tempItem)
160+
}
161+
notifyDataSetChanged()
162+
listener?.saveChecklist()
163+
}
164+
148165
private fun getItemWithKey(key: Int): ChecklistItem? = items.firstOrNull { it.id == key }
149166

150167
private fun getSelectedItems() = items.filter { selectedKeys.contains(it.id) } as ArrayList<ChecklistItem>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="#FFFFFF"
7+
android:alpha="0.8">
8+
<path
9+
android:fillColor="@android:color/white"
10+
android:pathData="M16,13h-3V3h-2v10H8l4,4 4,-4zM4,19v2h16v-2H4z"/>
11+
</vector>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="#FFFFFF"
7+
android:alpha="0.8">
8+
<path
9+
android:fillColor="@android:color/white"
10+
android:pathData="M8,11h3v10h2V11h3l-4,-4 -4,4zM4,3v2h16V3H4z"/>
11+
</vector>
188 Bytes
182 Bytes
119 Bytes
116 Bytes
162 Bytes
161 Bytes
205 Bytes

0 commit comments

Comments
 (0)