diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index f0bf61b89..7994ac212 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -143,7 +143,7 @@ class App : Application() { private fun registerActivityLife(){ registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks{ override fun onActivityPaused(activity: Activity) { - ActivityHelp.getInstance().add(activity) + ActivityHelp.add(activity) } override fun onActivityResumed(activity: Activity) { @@ -153,7 +153,7 @@ class App : Application() { } override fun onActivityDestroyed(activity: Activity) { - ActivityHelp.getInstance().remove(activity) + ActivityHelp.remove(activity) } override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle?) { diff --git a/app/src/main/java/io/legado/app/help/ActivityHelp.kt b/app/src/main/java/io/legado/app/help/ActivityHelp.kt index a1e535bfe..709bdd305 100644 --- a/app/src/main/java/io/legado/app/help/ActivityHelp.kt +++ b/app/src/main/java/io/legado/app/help/ActivityHelp.kt @@ -7,26 +7,9 @@ import java.util.* /** * Activity管理器,管理项目中Activity的状态 */ -class ActivityHelp private constructor() { +object ActivityHelp { - companion object { - - private var activities: MutableList> = arrayListOf() - - @Volatile - private var instance: ActivityHelp? = null - - fun getInstance(): ActivityHelp { - if (null == instance) { - synchronized(ActivityHelp::class.java) { - if (null == instance) { - instance = ActivityHelp() - } - } - } - return instance!! - } - } + private var activities: MutableList> = arrayListOf() fun getActivities(): List> { return activities diff --git a/app/src/main/java/io/legado/app/help/ReadBookHelp.kt b/app/src/main/java/io/legado/app/help/ReadBookHelp.kt new file mode 100644 index 000000000..2a79820f7 --- /dev/null +++ b/app/src/main/java/io/legado/app/help/ReadBookHelp.kt @@ -0,0 +1,10 @@ +package io.legado.app.help + +import android.graphics.drawable.Drawable + +object ReadBookHelp { + + var bg: Drawable? = null + + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt b/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt index d64df95e2..587471648 100644 --- a/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt +++ b/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt @@ -46,7 +46,7 @@ class MediaButtonReceiver : BroadcastReceiver() { } private fun readAloud(context: Context) { - ActivityHelp.getInstance().isExist(ReadBookActivity::class.java).let { + ActivityHelp.isExist(ReadBookActivity::class.java).let { if (!it) { context.startActivity() } diff --git a/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt b/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt index bb8ba6cd1..848237a1e 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt @@ -3,15 +3,12 @@ package io.legado.app.ui.widget.page import android.annotation.SuppressLint import android.content.Context import android.graphics.Canvas -import android.graphics.Color import android.util.AttributeSet import android.view.MotionEvent import android.widget.FrameLayout import io.legado.app.R import io.legado.app.ui.widget.page.delegate.CoverPageDelegate import io.legado.app.ui.widget.page.delegate.PageDelegate -import kotlinx.android.synthetic.main.view_book_page.view.* -import org.jetbrains.anko.backgroundColor class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs), PageDelegate.PageInterface { @@ -32,8 +29,6 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att upBg() setWillNotDraw(false) - page_panel.backgroundColor = Color.WHITE - pageDelegate = CoverPageDelegate(this) }