forked from upstream-mirrors/quik
Hide drawer once item is clicked
This commit is contained in:
@@ -43,6 +43,7 @@ dependencies {
|
|||||||
compile 'com.github.bumptech.glide:glide:4.3.0'
|
compile 'com.github.bumptech.glide:glide:4.3.0'
|
||||||
compile "com.google.dagger:dagger:2.11"
|
compile "com.google.dagger:dagger:2.11"
|
||||||
compile 'com.jakewharton.rxbinding2:rxbinding-kotlin:2.0.0'
|
compile 'com.jakewharton.rxbinding2:rxbinding-kotlin:2.0.0'
|
||||||
|
compile 'com.jakewharton.rxbinding2:rxbinding-support-v4-kotlin:2.0.0'
|
||||||
compile 'com.jakewharton.timber:timber:4.5.1'
|
compile 'com.jakewharton.timber:timber:4.5.1'
|
||||||
compile 'com.karumi:dexter:4.1.0'
|
compile 'com.karumi:dexter:4.1.0'
|
||||||
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
|
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import android.content.Intent
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.app.ActionBarDrawerToggle
|
import android.support.v7.app.ActionBarDrawerToggle
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
import android.support.v7.widget.LinearLayoutManager
|
||||||
|
import android.view.Gravity
|
||||||
|
import com.jakewharton.rxbinding2.support.v4.widget.drawerOpen
|
||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
import com.karumi.dexter.Dexter
|
import com.karumi.dexter.Dexter
|
||||||
import com.karumi.dexter.MultiplePermissionsReport
|
import com.karumi.dexter.MultiplePermissionsReport
|
||||||
@@ -27,6 +29,7 @@ class ConversationsActivity : QkActivity<ConversationsViewModel, ConversationsSt
|
|||||||
|
|
||||||
override val viewModelClass = ConversationsViewModel::class
|
override val viewModelClass = ConversationsViewModel::class
|
||||||
override val composeIntent by lazy { compose.clicks() }
|
override val composeIntent by lazy { compose.clicks() }
|
||||||
|
override val drawerOpenIntent by lazy { drawerLayout.drawerOpen(Gravity.START) }
|
||||||
override val archivedIntent by lazy { archived.clicks() }
|
override val archivedIntent by lazy { archived.clicks() }
|
||||||
override val scheduledIntent by lazy { scheduled.clicks() }
|
override val scheduledIntent by lazy { scheduled.clicks() }
|
||||||
override val blockedIntent by lazy { blocked.clicks() }
|
override val blockedIntent by lazy { blocked.clicks() }
|
||||||
@@ -57,6 +60,9 @@ class ConversationsActivity : QkActivity<ConversationsViewModel, ConversationsSt
|
|||||||
if (conversationList.adapter == null && state.conversations?.isValid == true) {
|
if (conversationList.adapter == null && state.conversations?.isValid == true) {
|
||||||
conversationList.adapter = ConversationsAdapter(state.conversations)
|
conversationList.adapter = ConversationsAdapter(state.conversations)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (drawerLayout.isDrawerOpen(Gravity.START) && !state.drawerOpen) drawerLayout.closeDrawer(Gravity.START)
|
||||||
|
else if (!drawerLayout.isDrawerVisible(Gravity.START) && state.drawerOpen) drawerLayout.openDrawer(Gravity.START)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun requestPermissions() {
|
private fun requestPermissions() {
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ import io.realm.OrderedRealmCollection
|
|||||||
|
|
||||||
data class ConversationsState(
|
data class ConversationsState(
|
||||||
val conversations: OrderedRealmCollection<Message>? = null,
|
val conversations: OrderedRealmCollection<Message>? = null,
|
||||||
val refreshing: Boolean = false
|
val refreshing: Boolean = false,
|
||||||
|
val drawerOpen: Boolean = false
|
||||||
)
|
)
|
||||||
@@ -6,6 +6,7 @@ import io.reactivex.Observable
|
|||||||
interface ConversationsView : QkView<ConversationsState> {
|
interface ConversationsView : QkView<ConversationsState> {
|
||||||
|
|
||||||
val composeIntent: Observable<Unit>
|
val composeIntent: Observable<Unit>
|
||||||
|
val drawerOpenIntent: Observable<Boolean>
|
||||||
val archivedIntent: Observable<Unit>
|
val archivedIntent: Observable<Unit>
|
||||||
val scheduledIntent: Observable<Unit>
|
val scheduledIntent: Observable<Unit>
|
||||||
val blockedIntent: Observable<Unit>
|
val blockedIntent: Observable<Unit>
|
||||||
|
|||||||
+24
-5
@@ -32,11 +32,30 @@ class ConversationsViewModel : QkViewModel<ConversationsView, ConversationsState
|
|||||||
override fun bindIntents(view: ConversationsView) {
|
override fun bindIntents(view: ConversationsView) {
|
||||||
super.bindIntents(view)
|
super.bindIntents(view)
|
||||||
|
|
||||||
intents += view.composeIntent.subscribe()
|
intents += view.composeIntent.subscribe {
|
||||||
intents += view.archivedIntent.subscribe()
|
newState { it.copy(drawerOpen = false) }
|
||||||
intents += view.scheduledIntent.subscribe()
|
}
|
||||||
intents += view.blockedIntent.subscribe()
|
|
||||||
intents += view.settingsIntent.subscribe { navigator.showSettings() }
|
intents += view.drawerOpenIntent.filter { it }.subscribe {
|
||||||
|
newState { it.copy(drawerOpen = true) }
|
||||||
|
}
|
||||||
|
|
||||||
|
intents += view.archivedIntent.subscribe {
|
||||||
|
newState { it.copy(drawerOpen = false) }
|
||||||
|
}
|
||||||
|
|
||||||
|
intents += view.scheduledIntent.subscribe {
|
||||||
|
newState { it.copy(drawerOpen = false) }
|
||||||
|
}
|
||||||
|
|
||||||
|
intents += view.blockedIntent.subscribe {
|
||||||
|
newState { it.copy(drawerOpen = false) }
|
||||||
|
}
|
||||||
|
|
||||||
|
intents += view.settingsIntent.subscribe {
|
||||||
|
navigator.showSettings()
|
||||||
|
newState { it.copy(drawerOpen = false) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user