pull/34/head
kunfei 5 years ago
parent 91ccee8dce
commit de822857d7
  1. 14
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -13,15 +13,15 @@ import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.Bus import io.legado.app.constant.Bus
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.noButton
import io.legado.app.lib.dialogs.yesButton
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.ui.main.bookshelf.BookshelfFragment import io.legado.app.ui.main.bookshelf.BookshelfFragment
import io.legado.app.ui.main.explore.ExploreFragment import io.legado.app.ui.main.explore.ExploreFragment
import io.legado.app.ui.main.my.MyFragment import io.legado.app.ui.main.my.MyFragment
import io.legado.app.ui.main.rss.RssFragment import io.legado.app.ui.main.rss.RssFragment
import io.legado.app.utils.getPrefInt import io.legado.app.utils.*
import io.legado.app.utils.getViewModel
import io.legado.app.utils.observeEvent
import io.legado.app.utils.putPrefInt
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -58,12 +58,18 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
private fun importYueDu() { private fun importYueDu() {
launch { launch {
if (withContext(IO) { App.db.bookDao().allBookCount == 0 }) { if (withContext(IO) { App.db.bookDao().allBookCount == 0 }) {
alert(title = "导入") {
message = "是否导入旧版本数据"
yesButton {
PermissionsCompat.Builder(this@MainActivity) PermissionsCompat.Builder(this@MainActivity)
.addPermissions(*Permissions.Group.STORAGE) .addPermissions(*Permissions.Group.STORAGE)
.rationale(R.string.tip_perm_request_storage) .rationale(R.string.tip_perm_request_storage)
.onGranted { viewModel.restore() } .onGranted { viewModel.restore() }
.request() .request()
} }
noButton { }
}.show().applyTint()
}
} }
} }

Loading…
Cancel
Save