pull/32/head
Invinciblelee 6 years ago
parent 22bf800de8
commit 51090b1ca9
  1. 5
      app/src/main/java/io/legado/app/data/entities/SearchBook.kt
  2. 4
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -7,6 +7,7 @@ import androidx.room.Ignore
import androidx.room.Index import androidx.room.Index
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
import com.google.gson.Gson import com.google.gson.Gson
import io.legado.app.utils.GSON
import io.legado.app.utils.fromJson import io.legado.app.utils.fromJson
import kotlinx.android.parcel.IgnoredOnParcel import kotlinx.android.parcel.IgnoredOnParcel
import kotlinx.android.parcel.Parcelize import kotlinx.android.parcel.Parcelize
@ -40,7 +41,7 @@ data class SearchBook(
variableMap = if (TextUtils.isEmpty(variable)) { variableMap = if (TextUtils.isEmpty(variable)) {
HashMap() HashMap()
} else { } else {
Gson().fromJson<HashMap<String, String>>(variable!!) GSON.fromJson<HashMap<String, String>>(variable!!)
} }
} }
} }
@ -48,6 +49,6 @@ data class SearchBook(
override fun putVariable(key: String, value: String) { override fun putVariable(key: String, value: String) {
initVariableMap() initVariableMap()
variableMap?.put(key, value) variableMap?.put(key, value)
variable = Gson().toJson(variableMap) variable = GSON.toJson(variableMap)
} }
} }

@ -1,6 +1,7 @@
package io.legado.app.ui.main package io.legado.app.ui.main
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.MenuItem import android.view.MenuItem
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
@ -24,6 +25,7 @@ import io.legado.app.ui.main.myconfig.MyConfigFragment
import io.legado.app.utils.getCompatColor import io.legado.app.utils.getCompatColor
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -61,7 +63,7 @@ class MainActivity : BaseActivity<MainViewModel>(), BottomNavigationView.OnNavig
} }
private fun importYueDu() { private fun importYueDu() {
launch { launch(IO) {
if (App.db.bookDao().allBookCount == 0) { if (App.db.bookDao().allBookCount == 0) {
launch(Main) { launch(Main) {
PermissionsCompat.Builder(this@MainActivity) PermissionsCompat.Builder(this@MainActivity)

Loading…
Cancel
Save