Bug fixes

This commit is contained in:
Jay 2019-11-17 22:18:05 -08:00
parent 65804ebb3a
commit 497b573ec5
2 changed files with 13 additions and 11 deletions

View File

@ -23,6 +23,9 @@ interface SManga : Serializable {
var initialized: Boolean
fun copyFrom(other: SManga) {
if (other.title != title)
title = other.title
if (other.author != null)
author = other.author

View File

@ -58,7 +58,7 @@ class MainActivity : BaseActivity() {
private var secondaryDrawer: ViewGroup? = null
private var snackBar:Snackbar? = null
var extraRectForUndo:Rect? = null
var extraViewForUndo:View? = null
private var canDismissSnackBar = false
fun setUndoSnackBar(snackBar: Snackbar?, extraViewToCheck: View? = null) {
@ -68,12 +68,7 @@ class MainActivity : BaseActivity() {
delay(1000)
canDismissSnackBar = true
}
if (extraViewToCheck != null) {
extraRectForUndo = Rect()
extraViewToCheck.getGlobalVisibleRect(extraRectForUndo)
}
else
extraRectForUndo = null
extraViewForUndo = extraViewToCheck
}
private val startScreenId by lazy {
@ -340,18 +335,22 @@ class MainActivity : BaseActivity() {
val sRect = Rect()
snackBar!!.view.getGlobalVisibleRect(sRect)
val extRect:Rect? = if (extraViewForUndo != null) Rect() else null
extraViewForUndo?.getGlobalVisibleRect(extRect)
//This way the snackbar will only be dismissed if
//the user clicks outside it.
if (canDismissSnackBar && !sRect.contains(ev.x.toInt(), ev.y.toInt())
&& (extraRectForUndo == null ||
!extraRectForUndo!!.contains(ev.x.toInt(), ev.y.toInt()))) {
&& (extRect == null ||
!extRect.contains(ev.x.toInt(), ev.y.toInt()))) {
snackBar?.dismiss()
snackBar = null
extraRectForUndo = null
extraViewForUndo = null
}
}
else if (snackBar != null)
else if (snackBar != null) {
snackBar = null
extraViewForUndo = null
}
}
return super.dispatchTouchEvent(ev)
}