mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Update after Ganfra's review
This commit is contained in:
parent
be9a91e3fe
commit
4654e39417
3 changed files with 20 additions and 21 deletions
|
@ -84,6 +84,7 @@ import im.vector.app.receivers.DebugReceiver
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
|
import org.matrix.android.sdk.api.extensions.tryThis
|
||||||
import org.matrix.android.sdk.api.failure.GlobalError
|
import org.matrix.android.sdk.api.failure.GlobalError
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import kotlin.system.measureTimeMillis
|
import kotlin.system.measureTimeMillis
|
||||||
|
@ -345,12 +346,26 @@ abstract class VectorBaseActivity : AppCompatActivity(), HasScreenInjector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected var postResumeScheduledAction: Runnable? = null
|
private val postResumeScheduledActions = mutableListOf<() -> Unit>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedule action to be done in the next call of onPostResume()
|
||||||
|
* It fixes bug observed on Android 6 (API 23)
|
||||||
|
*/
|
||||||
|
protected fun doOnPostResume(action: () -> Unit) {
|
||||||
|
synchronized(postResumeScheduledActions) {
|
||||||
|
postResumeScheduledActions.add(action)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPostResume() {
|
override fun onPostResume() {
|
||||||
super.onPostResume()
|
super.onPostResume()
|
||||||
postResumeScheduledAction?.run()
|
synchronized(postResumeScheduledActions) {
|
||||||
postResumeScheduledAction = null
|
postResumeScheduledActions.forEach {
|
||||||
|
tryThis { it.invoke() }
|
||||||
|
}
|
||||||
|
postResumeScheduledActions.clear()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
|
|
@ -49,10 +49,8 @@ import im.vector.app.features.userdirectory.UserDirectorySharedAction
|
||||||
import im.vector.app.features.userdirectory.UserDirectorySharedActionViewModel
|
import im.vector.app.features.userdirectory.UserDirectorySharedActionViewModel
|
||||||
import im.vector.app.features.userdirectory.UserDirectoryViewModel
|
import im.vector.app.features.userdirectory.UserDirectoryViewModel
|
||||||
import kotlinx.android.synthetic.main.activity.*
|
import kotlinx.android.synthetic.main.activity.*
|
||||||
import org.matrix.android.sdk.api.extensions.tryThis
|
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
import org.matrix.android.sdk.api.session.room.failure.CreateRoomFailure
|
import org.matrix.android.sdk.api.session.room.failure.CreateRoomFailure
|
||||||
import timber.log.Timber
|
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -115,13 +113,7 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() {
|
||||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
||||||
if (allGranted(grantResults)) {
|
if (allGranted(grantResults)) {
|
||||||
if (requestCode == PERMISSION_REQUEST_CODE_READ_CONTACTS) {
|
if (requestCode == PERMISSION_REQUEST_CODE_READ_CONTACTS) {
|
||||||
try {
|
doOnPostResume { addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java) }
|
||||||
addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java)
|
|
||||||
} catch (throwable: Throwable) {
|
|
||||||
Timber.w(throwable)
|
|
||||||
// Bug on API23
|
|
||||||
postResumeScheduledAction = Runnable { tryThis { addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java) } }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,7 @@ import im.vector.app.features.userdirectory.UserDirectorySharedActionViewModel
|
||||||
import im.vector.app.features.userdirectory.UserDirectoryViewModel
|
import im.vector.app.features.userdirectory.UserDirectoryViewModel
|
||||||
import kotlinx.android.parcel.Parcelize
|
import kotlinx.android.parcel.Parcelize
|
||||||
import kotlinx.android.synthetic.main.activity.*
|
import kotlinx.android.synthetic.main.activity.*
|
||||||
import org.matrix.android.sdk.api.extensions.tryThis
|
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
import timber.log.Timber
|
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -116,13 +114,7 @@ class InviteUsersToRoomActivity : SimpleFragmentActivity() {
|
||||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
||||||
if (allGranted(grantResults)) {
|
if (allGranted(grantResults)) {
|
||||||
if (requestCode == PERMISSION_REQUEST_CODE_READ_CONTACTS) {
|
if (requestCode == PERMISSION_REQUEST_CODE_READ_CONTACTS) {
|
||||||
try {
|
doOnPostResume { addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java) }
|
||||||
addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java)
|
|
||||||
} catch (throwable: Throwable) {
|
|
||||||
Timber.w(throwable)
|
|
||||||
// Bug on API23
|
|
||||||
postResumeScheduledAction = Runnable { tryThis { addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java) } }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue