mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Fail fast
This commit is contained in:
parent
b553ee2a76
commit
cc042f2d7a
1 changed files with 12 additions and 6 deletions
|
@ -32,7 +32,6 @@ import androidx.annotation.MainThread
|
||||||
import androidx.annotation.MenuRes
|
import androidx.annotation.MenuRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.google.android.material.appbar.MaterialToolbar
|
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
@ -42,6 +41,7 @@ import androidx.fragment.app.FragmentManager
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.bumptech.glide.util.Util
|
import com.bumptech.glide.util.Util
|
||||||
|
import com.google.android.material.appbar.MaterialToolbar
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.jakewharton.rxbinding3.view.clicks
|
import com.jakewharton.rxbinding3.view.clicks
|
||||||
import im.vector.app.BuildConfig
|
import im.vector.app.BuildConfig
|
||||||
|
@ -82,7 +82,6 @@ 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.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.failure.GlobalError
|
import org.matrix.android.sdk.api.failure.GlobalError
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
@ -596,12 +595,19 @@ abstract class VectorBaseActivity<VB: ViewBinding> : AppCompatActivity(), HasScr
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showSnackbar(message: String, @StringRes withActionTitle: Int?, action: (() -> Unit)?) {
|
fun showSnackbar(message: String, @StringRes withActionTitle: Int?, action: (() -> Unit)?) {
|
||||||
getCoordinatorLayout()?.let {
|
val coordinatorLayout = getCoordinatorLayout()
|
||||||
Snackbar.make(it, message, Snackbar.LENGTH_LONG).apply {
|
if (coordinatorLayout != null) {
|
||||||
|
Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG).apply {
|
||||||
withActionTitle?.let {
|
withActionTitle?.let {
|
||||||
setAction(withActionTitle, { action?.invoke() })
|
setAction(withActionTitle) { action?.invoke() }
|
||||||
}
|
}
|
||||||
}.show()
|
}.show()
|
||||||
|
} else {
|
||||||
|
if (vectorPreferences.failFast()) {
|
||||||
|
error("No CoordinatorLayout to display this snackbar!")
|
||||||
|
} else {
|
||||||
|
Timber.w("No CoordinatorLayout to display this snackbar!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue