pull/32/head
Awesome 6 years ago
parent 3538f958ab
commit 50a50b6ea5
  1. 3
      app/src/main/java/io/legado/app/base/BaseViewModel.kt
  2. 2
      app/src/main/java/io/legado/app/data/api/CommonHttpApi.kt
  3. 1
      app/src/main/java/io/legado/app/data/entities/Book.kt
  4. 4
      app/src/main/java/io/legado/app/data/entities/rule/Rule.kt
  5. 4
      app/src/main/java/io/legado/app/help/http/HttpHelper.kt
  6. 2
      app/src/main/java/io/legado/app/utils/StringExtensions.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

@ -11,4 +11,6 @@ interface CommonHttpApi {
@FormUrlEncoded
@POST
fun post(@Url url: String, @FieldMap map: Map<String, String>): Deferred<String>
}

@ -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

@ -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<BaseRule>,
@ -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"

@ -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<ConnectionSpec>()
specs.add(cs)
specs.add(default)
specs.add(ConnectionSpec.COMPATIBLE_TLS)
specs.add(ConnectionSpec.CLEARTEXT)

@ -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)

Loading…
Cancel
Save