I have no idea why that crashes for some people...
This commit is contained in:
parent
7dbf951d5a
commit
7228817c68
1 changed files with 31 additions and 25 deletions
|
@ -53,6 +53,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
import com.google.android.material.internal.ViewUtils
|
import com.google.android.material.internal.ViewUtils
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import nl.joery.animatedbottombar.AnimatedBottomBar
|
import nl.joery.animatedbottombar.AnimatedBottomBar
|
||||||
import java.io.*
|
import java.io.*
|
||||||
|
@ -783,35 +784,40 @@ fun toast(string: String?) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun snackString(s: String?, activity: Activity? = null, clipboard: String? = null) {
|
fun snackString(s: String?, activity: Activity? = null, clipboard: String? = null) {
|
||||||
if (s != null) {
|
try { //I have no idea why this sometimes crashes for some people...
|
||||||
(activity ?: currActivity())?.apply {
|
if (s != null) {
|
||||||
runOnUiThread {
|
(activity ?: currActivity())?.apply {
|
||||||
val snackBar = Snackbar.make(
|
runOnUiThread {
|
||||||
window.decorView.findViewById(android.R.id.content),
|
val snackBar = Snackbar.make(
|
||||||
s,
|
window.decorView.findViewById(android.R.id.content),
|
||||||
Snackbar.LENGTH_SHORT
|
s,
|
||||||
)
|
Snackbar.LENGTH_SHORT
|
||||||
snackBar.view.apply {
|
)
|
||||||
updateLayoutParams<FrameLayout.LayoutParams> {
|
snackBar.view.apply {
|
||||||
gravity = (Gravity.CENTER_HORIZONTAL or Gravity.BOTTOM)
|
updateLayoutParams<FrameLayout.LayoutParams> {
|
||||||
width = WRAP_CONTENT
|
gravity = (Gravity.CENTER_HORIZONTAL or Gravity.BOTTOM)
|
||||||
}
|
width = WRAP_CONTENT
|
||||||
translationY = -(navBarHeight.dp + 32f)
|
}
|
||||||
translationZ = 32f
|
translationY = -(navBarHeight.dp + 32f)
|
||||||
updatePadding(16f.px, right = 16f.px)
|
translationZ = 32f
|
||||||
setOnClickListener {
|
updatePadding(16f.px, right = 16f.px)
|
||||||
snackBar.dismiss()
|
setOnClickListener {
|
||||||
}
|
snackBar.dismiss()
|
||||||
setOnLongClickListener {
|
}
|
||||||
copyToClipboard(clipboard ?: s, false)
|
setOnLongClickListener {
|
||||||
toast(getString(R.string.copied_to_clipboard))
|
copyToClipboard(clipboard ?: s, false)
|
||||||
true
|
toast(getString(R.string.copied_to_clipboard))
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
snackBar.show()
|
||||||
}
|
}
|
||||||
snackBar.show()
|
|
||||||
}
|
}
|
||||||
|
logger(s)
|
||||||
}
|
}
|
||||||
logger(s)
|
} catch (e: Exception) {
|
||||||
|
logger(e.stackTraceToString())
|
||||||
|
FirebaseCrashlytics.getInstance().recordException(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue