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 var initialized: Boolean
fun copyFrom(other: SManga) { fun copyFrom(other: SManga) {
if (other.title != title)
title = other.title
if (other.author != null) if (other.author != null)
author = other.author author = other.author

View File

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