|
|
@ -1,12 +1,11 @@ |
|
|
|
package io.legado.app.ui.book.source.manage |
|
|
|
package io.legado.app.ui.book.source.manage |
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint |
|
|
|
import android.annotation.SuppressLint |
|
|
|
import android.content.Context |
|
|
|
|
|
|
|
import android.hardware.display.DisplayManager |
|
|
|
|
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
import android.view.* |
|
|
|
import android.view.* |
|
|
|
import androidx.activity.viewModels |
|
|
|
import androidx.activity.viewModels |
|
|
|
import androidx.appcompat.app.AlertDialog |
|
|
|
import androidx.appcompat.app.AlertDialog |
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity |
|
|
|
import androidx.appcompat.widget.PopupMenu |
|
|
|
import androidx.appcompat.widget.PopupMenu |
|
|
|
import androidx.appcompat.widget.SearchView |
|
|
|
import androidx.appcompat.widget.SearchView |
|
|
|
import androidx.core.os.bundleOf |
|
|
|
import androidx.core.os.bundleOf |
|
|
@ -70,9 +69,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV |
|
|
|
private var sort = Sort.Default |
|
|
|
private var sort = Sort.Default |
|
|
|
private var sortAscending = true |
|
|
|
private var sortAscending = true |
|
|
|
private var snackBar: Snackbar? = null |
|
|
|
private var snackBar: Snackbar? = null |
|
|
|
private val displayManager by lazy { |
|
|
|
private var isPaused = false |
|
|
|
getSystemService(Context.DISPLAY_SERVICE) as DisplayManager |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private val qrResult = registerForActivityResult(QrCodeResult()) { |
|
|
|
private val qrResult = registerForActivityResult(QrCodeResult()) { |
|
|
|
it ?: return@registerForActivityResult |
|
|
|
it ?: return@registerForActivityResult |
|
|
|
showDialogFragment(ImportBookSourceDialog(it)) |
|
|
|
showDialogFragment(ImportBookSourceDialog(it)) |
|
|
@ -516,7 +513,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV |
|
|
|
delay(300L) |
|
|
|
delay(300L) |
|
|
|
} |
|
|
|
} |
|
|
|
}.collect { |
|
|
|
}.collect { |
|
|
|
if (isScreenOn()) { |
|
|
|
if (SystemUtils.isScreenOn() && !isPaused) { |
|
|
|
if (lastItem == 0) { |
|
|
|
if (lastItem == 0) { |
|
|
|
adapter.notifyItemRangeChanged( |
|
|
|
adapter.notifyItemRangeChanged( |
|
|
|
0, |
|
|
|
0, |
|
|
@ -552,11 +549,14 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun isScreenOn(): Boolean { |
|
|
|
override fun onPause() { |
|
|
|
return displayManager.displays.any { |
|
|
|
super.onPause() |
|
|
|
it ?: return@any false |
|
|
|
isPaused = true |
|
|
|
it.state != Display.STATE_OFF |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onResume() { |
|
|
|
|
|
|
|
super.onResume() |
|
|
|
|
|
|
|
isPaused = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun upCountView() { |
|
|
|
override fun upCountView() { |
|
|
|