pull/34/head
kunfei 5 years ago
parent 91ccee8dce
commit de822857d7
  1. 24
      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,11 +58,17 @@ 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 }) {
PermissionsCompat.Builder(this@MainActivity) alert(title = "导入") {
.addPermissions(*Permissions.Group.STORAGE) message = "是否导入旧版本数据"
.rationale(R.string.tip_perm_request_storage) yesButton {
.onGranted { viewModel.restore() } PermissionsCompat.Builder(this@MainActivity)
.request() .addPermissions(*Permissions.Group.STORAGE)
.rationale(R.string.tip_perm_request_storage)
.onGranted { viewModel.restore() }
.request()
}
noButton { }
}.show().applyTint()
} }
} }
} }

Loading…
Cancel
Save