|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
package io.legado.app.ui.main |
|
|
|
|
|
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.util.Log |
|
|
|
|
import android.view.MenuItem |
|
|
|
|
import androidx.fragment.app.Fragment |
|
|
|
|
import androidx.fragment.app.FragmentManager |
|
|
|
@ -26,8 +25,8 @@ import io.legado.app.utils.getCompatColor |
|
|
|
|
import io.legado.app.utils.getViewModel |
|
|
|
|
import kotlinx.android.synthetic.main.activity_main.* |
|
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
|
import kotlinx.coroutines.Dispatchers.Main |
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
|
|
|
|
|
|
class MainActivity : BaseActivity<MainViewModel>(), BottomNavigationView.OnNavigationItemSelectedListener, |
|
|
|
|
ViewPager.OnPageChangeListener { |
|
|
|
@ -63,9 +62,8 @@ class MainActivity : BaseActivity<MainViewModel>(), BottomNavigationView.OnNavig |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun importYueDu() { |
|
|
|
|
launch(IO) { |
|
|
|
|
if (App.db.bookDao().allBookCount == 0) { |
|
|
|
|
launch(Main) { |
|
|
|
|
launch { |
|
|
|
|
if (withContext(IO) { App.db.bookDao().allBookCount == 0 }) { |
|
|
|
|
PermissionsCompat.Builder(this@MainActivity) |
|
|
|
|
.addPermissions(*Permissions.Group.STORAGE) |
|
|
|
|
.rationale(R.string.tip_perm_request_storage) |
|
|
|
@ -74,7 +72,6 @@ class MainActivity : BaseActivity<MainViewModel>(), BottomNavigationView.OnNavig |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onPageScrollStateChanged(state: Int) { |
|
|
|
|
|
|
|
|
|