|
|
@ -26,13 +26,14 @@ import io.legado.app.ui.main.rss.RssFragment |
|
|
|
import io.legado.app.ui.widget.dialog.TextDialog |
|
|
|
import io.legado.app.ui.widget.dialog.TextDialog |
|
|
|
import io.legado.app.utils.* |
|
|
|
import io.legado.app.utils.* |
|
|
|
import kotlinx.android.synthetic.main.activity_main.* |
|
|
|
import kotlinx.android.synthetic.main.activity_main.* |
|
|
|
|
|
|
|
import org.jetbrains.anko.toast |
|
|
|
|
|
|
|
|
|
|
|
class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main), |
|
|
|
class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main), |
|
|
|
BottomNavigationView.OnNavigationItemSelectedListener, |
|
|
|
BottomNavigationView.OnNavigationItemSelectedListener, |
|
|
|
ViewPager.OnPageChangeListener by ViewPager.SimpleOnPageChangeListener() { |
|
|
|
ViewPager.OnPageChangeListener by ViewPager.SimpleOnPageChangeListener() { |
|
|
|
override val viewModel: MainViewModel |
|
|
|
override val viewModel: MainViewModel |
|
|
|
get() = getViewModel(MainViewModel::class.java) |
|
|
|
get() = getViewModel(MainViewModel::class.java) |
|
|
|
|
|
|
|
private var exitTime: Long = 0 |
|
|
|
private var pagePosition = 0 |
|
|
|
private var pagePosition = 0 |
|
|
|
private val fragmentId = arrayOf(0, 1, 2, 3) |
|
|
|
private val fragmentId = arrayOf(0, 1, 2, 3) |
|
|
|
private val fragmentMap = mapOf<Int, Fragment>( |
|
|
|
private val fragmentMap = mapOf<Int, Fragment>( |
|
|
@ -105,9 +106,15 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main), |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
if (!BaseReadAloudService.pause) { |
|
|
|
if (!BaseReadAloudService.pause) { |
|
|
|
|
|
|
|
if (System.currentTimeMillis() - exitTime > 2000) { |
|
|
|
|
|
|
|
toast(R.string.double_click_exit) |
|
|
|
|
|
|
|
exitTime = System.currentTimeMillis() |
|
|
|
|
|
|
|
} else { |
|
|
|
moveTaskToBack(true) |
|
|
|
moveTaskToBack(true) |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -121,6 +128,15 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun finish() { |
|
|
|
|
|
|
|
if (System.currentTimeMillis() - exitTime > 2000) { |
|
|
|
|
|
|
|
toast(R.string.double_click_exit) |
|
|
|
|
|
|
|
exitTime = System.currentTimeMillis() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
super.finish() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onDestroy() { |
|
|
|
override fun onDestroy() { |
|
|
|
super.onDestroy() |
|
|
|
super.onDestroy() |
|
|
|
ReadAloud.stop(this) |
|
|
|
ReadAloud.stop(this) |
|
|
|