pull/48/head
kunfei 5 years ago
parent d65fc4bfa4
commit 16cc02b4e0
  1. 4
      app/src/main/AndroidManifest.xml
  2. 6
      app/src/main/java/io/legado/app/help/ActivityHelp.kt
  3. 38
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -38,7 +38,9 @@
android:resource="@xml/shortcuts" android:resource="@xml/shortcuts"
android:launchMode="singleTask" /> android:launchMode="singleTask" />
</activity> </activity>
<activity android:name=".ui.main.MainActivity" /> <activity
android:name=".ui.main.MainActivity"
android:launchMode="singleTop" />
<activity <activity
android:name=".ui.book.read.ReadBookActivity" android:name=".ui.book.read.ReadBookActivity"
android:configChanges="locale|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout" android:configChanges="locale|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"

@ -1,6 +1,7 @@
package io.legado.app.help package io.legado.app.help
import android.app.Activity import android.app.Activity
import io.legado.app.utils.LogUtils
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
import java.util.* import java.util.*
@ -11,6 +12,11 @@ object ActivityHelp {
private val activities: MutableList<WeakReference<Activity>> = arrayListOf() private val activities: MutableList<WeakReference<Activity>> = arrayListOf()
fun size(): Int {
LogUtils.d("xxxx", activities.size.toString())
return activities.size
}
/** /**
* 判断指定Activity是否存在 * 判断指定Activity是否存在
*/ */

@ -12,6 +12,7 @@ import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.Bus import io.legado.app.constant.Bus
import io.legado.app.help.ActivityHelp
import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
@ -103,22 +104,12 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
return super.onKeyUp(keyCode, event) return super.onKeyUp(keyCode, event)
} }
private inner class TabFragmentPageAdapter internal constructor(fm: FragmentManager) : override fun finish() {
FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { if (ActivityHelp.size() > 1) {
moveTaskToBack(true)
override fun getItem(position: Int): Fragment { } else {
return when (position) { super.finish()
0 -> BookshelfFragment()
1 -> ExploreFragment()
2 -> RssFragment()
else -> MyFragment()
}
}
override fun getCount(): Int {
return 4
} }
} }
override fun observeLiveBus() { override fun observeLiveBus() {
@ -127,3 +118,20 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
} }
} }
} }
private class TabFragmentPageAdapter internal constructor(fm: FragmentManager) :
FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
override fun getItem(position: Int): Fragment {
return when (position) {
0 -> BookshelfFragment()
1 -> ExploreFragment()
2 -> RssFragment()
else -> MyFragment()
}
}
override fun getCount(): Int {
return 4
}
}

Loading…
Cancel
Save