mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
#1618 Handle multi window mode lifecycle.
This commit is contained in:
parent
9b85bc3a93
commit
18361d682c
3 changed files with 21 additions and 4 deletions
|
@ -27,7 +27,7 @@ apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.4.0'
|
implementation 'androidx.fragment:fragment-ktx:1.4.1'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
|
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
|
||||||
|
@ -40,7 +40,7 @@ dependencies {
|
||||||
implementation "androidx.browser:browser:1.4.0"
|
implementation "androidx.browser:browser:1.4.0"
|
||||||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
|
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
|
||||||
implementation 'androidx.lifecycle:lifecycle-process:2.4.0'
|
implementation 'androidx.lifecycle:lifecycle-process:2.4.0'
|
||||||
implementation 'androidx.core:core-splashscreen:1.0.0-alpha02'
|
implementation 'androidx.core:core-splashscreen:1.0.0-beta01'
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
|
@ -18,7 +18,7 @@ class InitActivity : AppCompatActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
installSplashScreen().also {
|
installSplashScreen().also {
|
||||||
it.setKeepVisibleCondition {
|
it.setKeepOnScreenCondition() {
|
||||||
// keep showing the splash screen until FeedUtils.offerInitContext(...)
|
// keep showing the splash screen until FeedUtils.offerInitContext(...)
|
||||||
// finishes and UI ready to display
|
// finishes and UI ready to display
|
||||||
FeedUtils.dbHelper != null || FeedUtils.thumbnailLoader != null
|
FeedUtils.dbHelper != null || FeedUtils.thumbnailLoader != null
|
||||||
|
|
|
@ -59,6 +59,14 @@ abstract class Reading : NbActivity(), OnPageChangeListener, OnSeekBarChangeList
|
||||||
private var overlayRangeBotPx = 0f
|
private var overlayRangeBotPx = 0f
|
||||||
private var lastVScrollPos = 0
|
private var lastVScrollPos = 0
|
||||||
|
|
||||||
|
// enabling multi window mode from recent apps on the device
|
||||||
|
// creates a different activity lifecycle compared to a device rotation
|
||||||
|
// resulting in onPause being called when the app is actually on the screen.
|
||||||
|
// calling onPause sets stopLoading as true and content wouldn't be loaded.
|
||||||
|
// track the multi window mode config change and skip stopLoading in first onPause call.
|
||||||
|
// refactor stopLoading mechanism as a cancellation signal tied to the view lifecycle.
|
||||||
|
private var isMultiWindowModeHack = false
|
||||||
|
|
||||||
private val pageHistory = mutableListOf<Story>()
|
private val pageHistory = mutableListOf<Story>()
|
||||||
|
|
||||||
private lateinit var volumeKeyNavigation: VolumeKeyNavigation
|
private lateinit var volumeKeyNavigation: VolumeKeyNavigation
|
||||||
|
@ -143,8 +151,17 @@ abstract class Reading : NbActivity(), OnPageChangeListener, OnSeekBarChangeList
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
stopLoading = true
|
|
||||||
super.onPause()
|
super.onPause()
|
||||||
|
if (isMultiWindowModeHack) {
|
||||||
|
isMultiWindowModeHack = false
|
||||||
|
} else {
|
||||||
|
stopLoading = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMultiWindowModeChanged(isInMultiWindowMode: Boolean, newConfig: Configuration?) {
|
||||||
|
super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig)
|
||||||
|
isMultiWindowModeHack = isInMultiWindowMode
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue