Fixed newly introduced bugs
This commit is contained in:
parent
9f26ade617
commit
2a1aa736cc
@ -220,6 +220,7 @@ class MainActivity : AppCompatActivity(), ListSelectionListener<Serializable> {
|
|||||||
|
|
||||||
val drawerItems = ArrayList<IDrawerItem<*, *>>()
|
val drawerItems = ArrayList<IDrawerItem<*, *>>()
|
||||||
drawerItems.add(PrimaryDrawerItem()
|
drawerItems.add(PrimaryDrawerItem()
|
||||||
|
.withIdentifier(LABEL_ARCHIVE.id as Long)
|
||||||
.withName(R.string.archive)
|
.withName(R.string.archive)
|
||||||
.withTag(LABEL_ARCHIVE)
|
.withTag(LABEL_ARCHIVE)
|
||||||
.withIcon(CommunityMaterial.Icon.cmd_archive)
|
.withIcon(CommunityMaterial.Icon.cmd_archive)
|
||||||
@ -343,7 +344,7 @@ class MainActivity : AppCompatActivity(), ListSelectionListener<Serializable> {
|
|||||||
}
|
}
|
||||||
Singleton.getMessageListener(this).resetNotification()
|
Singleton.getMessageListener(this).resetNotification()
|
||||||
currentLabel.addObserver(this) { label ->
|
currentLabel.addObserver(this) { label ->
|
||||||
if (label != null) {
|
if (label != null && label.id is Long) {
|
||||||
drawer.setSelection(label.id as Long)
|
drawer.setSelection(label.id as Long)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ class AndroidLabelRepository(private val sql: SqlHelper, private val context: Co
|
|||||||
internal fun findLabels(msgId: Any) = find("id IN (SELECT label_id FROM Message_Label WHERE message_id=$msgId)")
|
internal fun findLabels(msgId: Any) = find("id IN (SELECT label_id FROM Message_Label WHERE message_id=$msgId)")
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val LABEL_ARCHIVE = Label("archive", null, 0)
|
val LABEL_ARCHIVE = Label("archive", null, 0).apply { id = Long.MAX_VALUE }
|
||||||
|
|
||||||
private const val TABLE_NAME = "Label"
|
private const val TABLE_NAME = "Label"
|
||||||
private const val COLUMN_ID = "id"
|
private const val COLUMN_ID = "id"
|
||||||
|
@ -50,36 +50,38 @@ object Singleton {
|
|||||||
private var swipeableMessageAdapter: WeakReference<SwipeableMessageAdapter>? = null
|
private var swipeableMessageAdapter: WeakReference<SwipeableMessageAdapter>? = null
|
||||||
val labeler = DefaultLabeler().apply {
|
val labeler = DefaultLabeler().apply {
|
||||||
listener = { message, added, removed ->
|
listener = { message, added, removed ->
|
||||||
swipeableMessageAdapter?.get()?.let { swipeableMessageAdapter ->
|
MainActivity.apply {
|
||||||
currentLabel.value?.let { label ->
|
runOnUiThread {
|
||||||
when {
|
swipeableMessageAdapter?.get()?.let { swipeableMessageAdapter ->
|
||||||
label.type == Label.Type.TRASH
|
currentLabel.value?.let { label ->
|
||||||
&& added.all { it.type == Label.Type.TRASH }
|
when {
|
||||||
&& removed.any { it.type == Label.Type.TRASH } -> {
|
label.type == Label.Type.TRASH
|
||||||
// work-around for messages that are deleted from trash
|
&& added.all { it.type == Label.Type.TRASH }
|
||||||
swipeableMessageAdapter.remove(message)
|
&& removed.any { it.type == Label.Type.TRASH } -> {
|
||||||
}
|
// work-around for messages that are deleted from trash
|
||||||
label.type == Label.Type.UNREAD
|
swipeableMessageAdapter.remove(message)
|
||||||
&& added.all { it.type == Label.Type.TRASH } -> {
|
}
|
||||||
// work-around for messages that are deleted from unread, which already have the unread label removed
|
label.type == Label.Type.UNREAD
|
||||||
swipeableMessageAdapter.remove(message)
|
&& added.all { it.type == Label.Type.TRASH } -> {
|
||||||
}
|
// work-around for messages that are deleted from unread, which already have the unread label removed
|
||||||
added.contains(label) -> {
|
swipeableMessageAdapter.remove(message)
|
||||||
// in most cases, top should be the correct position, but time will show if
|
}
|
||||||
// the message should be properly sorted in
|
added.contains(label) -> {
|
||||||
swipeableMessageAdapter.addFirst(message)
|
// in most cases, top should be the correct position, but time will show if
|
||||||
}
|
// the message should be properly sorted in
|
||||||
removed.contains(label) -> {
|
swipeableMessageAdapter.addFirst(message)
|
||||||
swipeableMessageAdapter.remove(message)
|
}
|
||||||
}
|
removed.contains(label) -> {
|
||||||
removed.any { it.type == Label.Type.UNREAD } || added.any { it.type == Label.Type.UNREAD } -> {
|
swipeableMessageAdapter.remove(message)
|
||||||
swipeableMessageAdapter.update(message)
|
}
|
||||||
|
removed.any { it.type == Label.Type.UNREAD } || added.any { it.type == Label.Type.UNREAD } -> {
|
||||||
|
swipeableMessageAdapter.update(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (removed.any { it.type == Label.Type.UNREAD } || added.any { it.type == Label.Type.UNREAD }) {
|
||||||
if (removed.any { it.type == Label.Type.UNREAD } || added.any { it.type == Label.Type.UNREAD }) {
|
|
||||||
MainActivity.apply {
|
|
||||||
updateUnread()
|
updateUnread()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user