pull/32/head
kunfei 5 years ago
parent 4c304500d0
commit b2578d8946
  1. 52
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  2. 5
      app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt
  3. 41
      app/src/main/res/layout/item_find_book.xml

@ -125,14 +125,12 @@ class AnalyzeRule(private var book: BaseBook? = null) {
sourceRule.makeUpRule(result)
result?.let {
if (sourceRule.rule.isNotEmpty()) {
when (sourceRule.mode) {
Mode.Js -> result = evalJS(sourceRule.rule, result)
Mode.Json -> result =
getAnalyzeByJSonPath(it).getStringList(sourceRule.rule)
Mode.XPath -> result =
getAnalyzeByXPath(it).getStringList(sourceRule.rule)
Mode.Default -> result = getAnalyzeByJSoup(it).getStringList(sourceRule.rule)
else -> result = sourceRule.rule
result = when (sourceRule.mode) {
Mode.Js -> evalJS(sourceRule.rule, result)
Mode.Json -> getAnalyzeByJSonPath(it).getStringList(sourceRule.rule)
Mode.XPath -> getAnalyzeByXPath(it).getStringList(sourceRule.rule)
Mode.Default -> getAnalyzeByJSoup(it).getStringList(sourceRule.rule)
else -> sourceRule.rule
}
}
if (sourceRule.replaceRegex.isNotEmpty() && result is List<*>) {
@ -196,16 +194,16 @@ class AnalyzeRule(private var book: BaseBook? = null) {
sourceRule.makeUpRule(result)
result?.let {
if (sourceRule.rule.isNotBlank()) {
when (sourceRule.mode) {
Mode.Js -> result = evalJS(sourceRule.rule, it)
Mode.Json -> result = getAnalyzeByJSonPath(it).getString(sourceRule.rule)
Mode.XPath -> result = getAnalyzeByXPath(it).getString(sourceRule.rule)
Mode.Default -> result = if (isUrl) {
result = when (sourceRule.mode) {
Mode.Js -> evalJS(sourceRule.rule, it)
Mode.Json -> getAnalyzeByJSonPath(it).getString(sourceRule.rule)
Mode.XPath -> getAnalyzeByXPath(it).getString(sourceRule.rule)
Mode.Default -> if (isUrl) {
getAnalyzeByJSoup(it).getString0(sourceRule.rule)
} else {
getAnalyzeByJSoup(it).getString(sourceRule.rule)
}
else -> result = sourceRule.rule
else -> sourceRule.rule
}
}
if (sourceRule.replaceRegex.isNotEmpty()) {
@ -236,13 +234,12 @@ class AnalyzeRule(private var book: BaseBook? = null) {
for (sourceRule in ruleList) {
putRule(sourceRule.putMap)
result?.let {
when (sourceRule.mode) {
Mode.Regex -> result =
AnalyzeByRegex.getElement(result.toString(), sourceRule.rule.splitNotBlank("&&"))
Mode.Js -> result = evalJS(sourceRule.rule, it)
Mode.Json -> result = getAnalyzeByJSonPath(it).getObject(sourceRule.rule)
Mode.XPath -> result = getAnalyzeByXPath(it).getElements(sourceRule.rule)
else -> result = getAnalyzeByJSoup(it).getElements(sourceRule.rule)
result = when (sourceRule.mode) {
Mode.Regex -> AnalyzeByRegex.getElement(result.toString(), sourceRule.rule.splitNotBlank("&&"))
Mode.Js -> evalJS(sourceRule.rule, it)
Mode.Json -> getAnalyzeByJSonPath(it).getObject(sourceRule.rule)
Mode.XPath -> getAnalyzeByXPath(it).getElements(sourceRule.rule)
else -> getAnalyzeByJSoup(it).getElements(sourceRule.rule)
}
if (sourceRule.replaceRegex.isNotEmpty()) {
result = replaceRegex(result.toString(), sourceRule)
@ -266,13 +263,12 @@ class AnalyzeRule(private var book: BaseBook? = null) {
for (sourceRule in ruleList) {
putRule(sourceRule.putMap)
result?.let {
when (sourceRule.mode) {
Mode.Regex -> result =
AnalyzeByRegex.getElements(result.toString(), sourceRule.rule.splitNotBlank("&&"))
Mode.Js -> result = evalJS(sourceRule.rule, result)
Mode.Json -> result = getAnalyzeByJSonPath(it).getList(sourceRule.rule)
Mode.XPath -> result = getAnalyzeByXPath(it).getElements(sourceRule.rule)
else -> result = getAnalyzeByJSoup(it).getElements(sourceRule.rule)
result = when (sourceRule.mode) {
Mode.Regex -> AnalyzeByRegex.getElements(result.toString(), sourceRule.rule.splitNotBlank("&&"))
Mode.Js -> evalJS(sourceRule.rule, result)
Mode.Json -> getAnalyzeByJSonPath(it).getList(sourceRule.rule)
Mode.XPath -> getAnalyzeByXPath(it).getElements(sourceRule.rule)
else -> getAnalyzeByJSoup(it).getElements(sourceRule.rule)
}
if (sourceRule.replaceRegex.isNotEmpty()) {
result = replaceRegex(result.toString(), sourceRule)

@ -7,13 +7,12 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.paging.LivePagedListBuilder
import androidx.paging.PagedList
import com.google.android.flexbox.FlexboxLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseFragment
import io.legado.app.data.entities.BookSource
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ThemeStore
import kotlinx.android.synthetic.main.fragment_find_book.*
import kotlinx.android.synthetic.main.view_title_bar.*
@ -34,7 +33,7 @@ class FindBookFragment : BaseFragment(R.layout.fragment_find_book) {
private fun initRecyclerView() {
ATH.applyEdgeEffectColor(rv_find)
rv_find.layoutManager = FlexboxLayoutManager(context)
rv_find.layoutManager = LinearLayoutManager(context)
adapter = FindBookAdapter()
rv_find.adapter = adapter
}

@ -1,10 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tv_name"
android:background="@drawable/shape_radius_10dp"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp">
<LinearLayout
android:id="@+id/ll_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="@+id/tv_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageView
android:id="@+id/iv_status"
android:layout_width="24dp"
android:layout_height="24dp"
tools:ignore="ContentDescription" />
</LinearLayout>
<GridLayout
android:id="@+id/gl_child"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:padding="5dp" />
android:columnCount="3"
android:visibility="gone" />
</LinearLayout>
Loading…
Cancel
Save