diff --git a/app/src/main/java/io/legado/app/base/BaseViewModel.kt b/app/src/main/java/io/legado/app/base/BaseViewModel.kt index 74bc4bfc2..03b17ad49 100644 --- a/app/src/main/java/io/legado/app/base/BaseViewModel.kt +++ b/app/src/main/java/io/legado/app/base/BaseViewModel.kt @@ -3,9 +3,10 @@ package io.legado.app.base import android.app.Application import androidx.lifecycle.AndroidViewModel import kotlinx.coroutines.* +import org.jetbrains.anko.AnkoLogger import kotlin.coroutines.CoroutineContext -open class BaseViewModel(application: Application) : AndroidViewModel(application), CoroutineScope { +open class BaseViewModel(application: Application) : AndroidViewModel(application), CoroutineScope, AnkoLogger { override val coroutineContext: CoroutineContext get() = Dispatchers.Main diff --git a/app/src/main/java/io/legado/app/data/api/CommonHttpApi.kt b/app/src/main/java/io/legado/app/data/api/CommonHttpApi.kt index 08e06f52f..51d468469 100644 --- a/app/src/main/java/io/legado/app/data/api/CommonHttpApi.kt +++ b/app/src/main/java/io/legado/app/data/api/CommonHttpApi.kt @@ -11,4 +11,6 @@ interface CommonHttpApi { @FormUrlEncoded @POST fun post(@Url url: String, @FieldMap map: Map): Deferred + + } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index 1efd170c3..9981c1da7 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -3,7 +3,6 @@ package io.legado.app.data.entities import android.os.Parcelable import androidx.room.* import io.legado.app.constant.AppConst.NOT_AVAILABLE -import io.legado.app.utils.strim import kotlinx.android.parcel.Parcelize @Parcelize diff --git a/app/src/main/java/io/legado/app/data/entities/rule/Rule.kt b/app/src/main/java/io/legado/app/data/entities/rule/Rule.kt index 7b3810802..4caf219f0 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/Rule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/Rule.kt @@ -1,7 +1,7 @@ package io.legado.app.data.entities.rule import io.legado.app.utils.splitNotBlank -import io.legado.app.utils.strim +import io.legado.app.utils.safeTrim data class Rule ( var selectors: List, @@ -45,7 +45,7 @@ data class Rule ( if (line.contains("@@")) { val temp = line.split("@@") baseRule.selector = temp[0].trim() - baseRule.attr = temp[1].strim() ?: "text" // 写了 @@ 但是后面空白的也默认为 text + baseRule.attr = temp[1].safeTrim() ?: "text" // 写了 @@ 但是后面空白的也默认为 text } else { baseRule.selector = line baseRule.attr = "text" diff --git a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt index 2c481aeca..81602c87e 100644 --- a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt +++ b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt @@ -28,12 +28,12 @@ object HttpHelper { } private fun getOkHttpClient(): OkHttpClient { - val cs = ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) + val default = ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) .tlsVersions(TlsVersion.TLS_1_2) .build() val specs = ArrayList() - specs.add(cs) + specs.add(default) specs.add(ConnectionSpec.COMPATIBLE_TLS) specs.add(ConnectionSpec.CLEARTEXT) diff --git a/app/src/main/java/io/legado/app/utils/StringExtensions.kt b/app/src/main/java/io/legado/app/utils/StringExtensions.kt index 227dff7ec..477ff0d19 100644 --- a/app/src/main/java/io/legado/app/utils/StringExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/StringExtensions.kt @@ -1,7 +1,7 @@ package io.legado.app.utils // import org.apache.commons.text.StringEscapeUtils -fun String?.strim() = if (this.isNullOrBlank()) null else this.trim() +fun String?.safeTrim() = if (this.isNullOrBlank()) null else this.trim() fun String.isAbsUrl() = this.startsWith("http://", true) || this.startsWith("https://", true)