Fixed requesting permissions off main thread

This commit is contained in:
Viktor De Pasquale 2019-05-02 16:20:30 +02:00 committed by topjohnwu
parent 7fee82f731
commit 09d531557d

View File

@ -1,6 +1,7 @@
package com.topjohnwu.magisk.ui.base package com.topjohnwu.magisk.ui.base
import android.app.Activity import android.app.Activity
import com.skoumal.teanity.extensions.doOnSubscribeUi
import com.skoumal.teanity.viewmodel.LoadingViewModel import com.skoumal.teanity.viewmodel.LoadingViewModel
import com.topjohnwu.magisk.model.events.BackPressEvent import com.topjohnwu.magisk.model.events.BackPressEvent
import com.topjohnwu.magisk.model.events.PermissionEvent import com.topjohnwu.magisk.model.events.PermissionEvent
@ -22,7 +23,7 @@ abstract class MagiskViewModel : LoadingViewModel(), Event.AutoListener {
fun withPermissions(vararg permissions: String): Observable<Boolean> { fun withPermissions(vararg permissions: String): Observable<Boolean> {
val subject = PublishSubject.create<Boolean>() val subject = PublishSubject.create<Boolean>()
return subject.doOnSubscribe { PermissionEvent(permissions.toList(), subject).publish() } return subject.doOnSubscribeUi { PermissionEvent(permissions.toList(), subject).publish() }
} }
fun back() = BackPressEvent().publish() fun back() = BackPressEvent().publish()