-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support batch deletion #70
base: main
Are you sure you want to change the base?
Conversation
a49cb91
to
5cecfff
Compare
c4c3c8c
to
6342290
Compare
d58496a
to
5419bb4
Compare
6342290
to
a3266d3
Compare
90410db
to
8df7cee
Compare
4752e78
to
c0ec632
Compare
c0ec632
to
524cbce
Compare
10c794a
to
c0d8998
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SVID_20241022_213104_1.mp4
-
Long click must select the item
-
Back button should deselect all
-
Switch off screen after selection and all checked states are lost
SVID_20241023_153320_1.mp4
- Ripple should have shape of the note item. Observe carefully
c0d8998
to
78aa757
Compare
c0ef5dd
to
b85a4ac
Compare
@shubertm This has been fixed. Please help check again! |
@@ -91,6 +91,13 @@ class NotesRepoHelper | |||
return UserNoteProperties(title, description) | |||
} | |||
|
|||
suspend fun deleteNote(notes: List<Note>): Unit = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suspend fun deleteNote(notes: List<Note>): Unit = | |
suspend fun deleteNotes(notes: List<Note>): Unit = |
|
||
private val selectedNoteCount by lazy { MutableLiveData<Int>() } | ||
val observableSelectedNoteCount by lazy { selectedNoteCount } | ||
val selectedNotedForDelete = mutableListOf<Note>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val selectedNotedForDelete = mutableListOf<Note>() | |
val selectedNotesForDelete = mutableListOf<Note>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shubertm Thanks. Please review again!
1723e15
to
5aef805
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix problem with exposing mutable variables wherever possible
@@ -206,16 +230,45 @@ class NotesListAdapter( | |||
notifyDataSetChanged() | |||
} | |||
|
|||
fun getNotes(): List<Note> { | |||
fun getNotes(): MutableList<Note> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need mutable list here? We expect this list to change only within this class to have single source of truth
var onItemLongPressed: ((pos: Int, note: Note) -> Unit)? = null | ||
var onItemClicked: (() -> Unit)? = null | ||
|
||
private val selectedNoteCount by lazy { MutableLiveData<Int>() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private val selectedNoteCount by lazy { MutableLiveData<Int>() } | |
private val selectedNotesCount by lazy { MutableLiveData<Int>() } |
var onItemClicked: (() -> Unit)? = null | ||
|
||
private val selectedNoteCount by lazy { MutableLiveData<Int>() } | ||
val observableSelectedNoteCount by lazy { selectedNoteCount } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val observableSelectedNoteCount by lazy { selectedNoteCount } | |
val observableSelectedNotesCount by lazy { selectedNoteCount } |
viewModelScope.launch(iODispatcher) { | ||
notes.value = textNotesRepo.read() + graphicNotesRepo.read() + voiceNotesRepo.read() | ||
notes.value.let { | ||
withContext(Dispatchers.Main) { | ||
onSuccess(it.sortedByDescending { note -> note.resource?.modified }) | ||
notes.value = it.sortedByDescending { note -> note.resource?.modified } | ||
onSuccess(notes.value.toMutableList()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to pass MutableList
here. We should not be passing mutable variable to other object unless specified
note: Note, | ||
onSuccess: () -> Unit, | ||
notes: List<Note>, | ||
onSuccess: (newList: MutableList<Note>) -> Unit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onSuccess: (newList: MutableList<Note>) -> Unit, | |
onSuccess: (newList: List<Note>) -> Unit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ok
withContext(Dispatchers.Main) { | ||
onSuccess.invoke() | ||
onSuccess.invoke([email protected]()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is not needed, I mean [email protected]()
SVID_20241114_062853_1.mp4
|
* Long pressing on an item should also select it * Navigating back while in action mode should destroy it first * Update ripple effect for note item
* Fix a bug in selecting notes for deletion logic
5aef805
to
4775613
Compare
@shubertm I haven't been clear what the issue is. |
Description:
Support batch deletion: #47
Screenshots: