Refactor MessageListFragment.onOptionsItemSelected()
This commit is contained in:
parent
4486782166
commit
9f45fe1d46
1 changed files with 13 additions and 42 deletions
|
@ -745,50 +745,21 @@ class MessageListFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
val id = item.itemId
|
when (item.itemId) {
|
||||||
if (id == R.id.set_sort_date) {
|
R.id.set_sort_date -> changeSort(SortType.SORT_DATE)
|
||||||
changeSort(SortType.SORT_DATE)
|
R.id.set_sort_arrival -> changeSort(SortType.SORT_ARRIVAL)
|
||||||
return true
|
R.id.set_sort_subject -> changeSort(SortType.SORT_SUBJECT)
|
||||||
} else if (id == R.id.set_sort_arrival) {
|
R.id.set_sort_sender -> changeSort(SortType.SORT_SENDER)
|
||||||
changeSort(SortType.SORT_ARRIVAL)
|
R.id.set_sort_flag -> changeSort(SortType.SORT_FLAGGED)
|
||||||
return true
|
R.id.set_sort_unread -> changeSort(SortType.SORT_UNREAD)
|
||||||
} else if (id == R.id.set_sort_subject) {
|
R.id.set_sort_attach -> changeSort(SortType.SORT_ATTACHMENT)
|
||||||
changeSort(SortType.SORT_SUBJECT)
|
R.id.select_all -> selectAll()
|
||||||
return true
|
R.id.send_messages -> onSendPendingMessages()
|
||||||
} else if (id == R.id.set_sort_sender) {
|
R.id.expunge -> onExpunge()
|
||||||
changeSort(SortType.SORT_SENDER)
|
else -> return super.onOptionsItemSelected(item)
|
||||||
return true
|
|
||||||
} else if (id == R.id.set_sort_flag) {
|
|
||||||
changeSort(SortType.SORT_FLAGGED)
|
|
||||||
return true
|
|
||||||
} else if (id == R.id.set_sort_unread) {
|
|
||||||
changeSort(SortType.SORT_UNREAD)
|
|
||||||
return true
|
|
||||||
} else if (id == R.id.set_sort_attach) {
|
|
||||||
changeSort(SortType.SORT_ATTACHMENT)
|
|
||||||
return true
|
|
||||||
} else if (id == R.id.select_all) {
|
|
||||||
selectAll()
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSingleAccountMode) {
|
return true
|
||||||
// None of the options after this point are "safe" for search results
|
|
||||||
// TODO: This is not true for "unread" and "starred" searches in regular folders
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id == R.id.send_messages) {
|
|
||||||
onSendPendingMessages()
|
|
||||||
return true
|
|
||||||
} else if (id == R.id.expunge) {
|
|
||||||
currentFolder?.let { folderInfoHolder ->
|
|
||||||
onExpunge(account, folderInfoHolder.databaseId)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onSendPendingMessages() {
|
fun onSendPendingMessages() {
|
||||||
|
|
Loading…
Reference in a new issue