pull/21/head
fengyuecanzhu 3 years ago
parent a0849ed889
commit 2aa90ca4a8
  1. 1
      .idea/misc.xml
  2. 55
      app/src/main/java/xyz/fycz/myreader/greendao/entity/Book.java
  3. 10
      app/src/main/java/xyz/fycz/myreader/greendao/entity/Chapter.java
  4. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/JsExtensions.kt
  5. 24
      app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java
  6. 15
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java
  7. 23
      app/src/main/java/xyz/fycz/myreader/ui/adapter/BookcaseAdapter.java
  8. 20
      app/src/main/res/layout/activity_source_debug.xml

@ -23,6 +23,7 @@
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_register.xml" value="0.2796934865900383" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_search_book.xml" value="0.26904376012965964" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_search_word.xml" value="0.144" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_source_debug.xml" value="0.2391304347826087" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/dialog_loading.xml" value="0.1" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/dialog_textview.xml" value="0.1947463768115942" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fingerprint_dialog.xml" value="0.20425724637681159" />

@ -2,6 +2,7 @@ package xyz.fycz.myreader.greendao.entity;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -16,6 +17,8 @@ import org.greenrobot.greendao.annotation.Transient;
import xyz.fycz.myreader.greendao.service.BookService;
import xyz.fycz.myreader.model.third3.analyzeRule.RuleDataInterface;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.utils.GsonExtensionsKt;
import java.io.Serializable;
import java.util.HashMap;
@ -385,17 +388,21 @@ public class Book implements Serializable, RuleDataInterface {
variableMap = new HashMap<>();
}
variableMap.put(key, value);
variable = new Gson().toJson(variableMap);
variable = GsonExtensionsKt.getGSON().toJson(variableMap);
}
@NonNull
public Map<String, String> getVariableMap() {
if (variableMap == null && !TextUtils.isEmpty(variable)) {
variableMap = new Gson().fromJson(variable, MAP_STRING);
variableMap = GsonExtensionsKt.getGSON().fromJson(variable, MAP_STRING);
}
return variableMap;
}
public void setVariableMap(Map<String, String> variableMap) {
this.variableMap = variableMap;
}
public String getVariable() {
return this.variable;
@ -405,6 +412,10 @@ public class Book implements Serializable, RuleDataInterface {
this.variable = variable;
}
public Map<String, String> getCatheMap() {
return catheMap;
}
public void putCathe(String key, String value) {
if (catheMap == null) {
catheMap = new HashMap<>();
@ -419,6 +430,10 @@ public class Book implements Serializable, RuleDataInterface {
return catheMap.get(key);
}
public void setCatheMap(Map<String, String> catheMap) {
this.catheMap = catheMap;
}
public void clearCathe(){
if (catheMap != null) {
catheMap.clear();
@ -436,6 +451,40 @@ public class Book implements Serializable, RuleDataInterface {
@Nullable
@Override
public String getVariable(@NonNull String key) {
return variableMap.get(key);
return getVariableMap().get(key);
}
public Book changeSource(Book newBook){
Book bookTem = (Book) clone();
bookTem.clearCathe();
bookTem.setChapterUrl(newBook.getChapterUrl());
bookTem.setInfoUrl(newBook.getInfoUrl());
bookTem.setSource(newBook.getSource());
if (!StringHelper.isEmpty(newBook.getImgUrl())) {
bookTem.setImgUrl(newBook.getImgUrl());
}
if (!StringHelper.isEmpty(newBook.getType())) {
bookTem.setType(newBook.getType());
}
if (!StringHelper.isEmpty(newBook.getDesc())) {
bookTem.setDesc(newBook.getDesc());
}
if (!StringHelper.isEmpty(newBook.getUpdateDate())) {
bookTem.setUpdateDate(newBook.getUpdateDate());
}
if (!StringHelper.isEmpty(newBook.getWordCount())) {
bookTem.setWordCount(newBook.getWordCount());
}
if (!StringHelper.isEmpty(newBook.getStatus())) {
bookTem.setStatus(newBook.getStatus());
}
if (!StringHelper.isEmpty(newBook.getVariable())) {
bookTem.setVariable(newBook.getVariable());
bookTem.setVariableMap(newBook.getVariableMap());
}
if (newBook.getCatheMap() != null){
bookTem.setCatheMap(newBook.getCatheMap());
}
return bookTem;
}
}

@ -4,6 +4,7 @@ package xyz.fycz.myreader.greendao.entity;
import static xyz.fycz.myreader.common.APPCONST.MAP_STRING;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -18,6 +19,7 @@ import org.greenrobot.greendao.annotation.Transient;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.model.third3.analyzeRule.RuleDataInterface;
import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.GsonExtensionsKt;
import java.io.File;
import java.util.HashMap;
@ -144,18 +146,18 @@ public class Chapter implements RuleDataInterface {
this.end = end;
}
public void putVariable(String key, String value) {
public void putVariable(@NonNull String key, String value) {
if (variableMap == null) {
variableMap = new HashMap<>();
}
variableMap.put(key, value);
variable = new Gson().toJson(variableMap);
variable = GsonExtensionsKt.getGSON().toJson(variableMap);
}
@NonNull
public Map<String, String> getVariableMap() {
if (variableMap == null && !TextUtils.isEmpty(variable)) {
variableMap = new Gson().fromJson(variable, MAP_STRING);
variableMap = GsonExtensionsKt.getGSON().fromJson(variable, MAP_STRING);
}
return variableMap;
}
@ -163,7 +165,7 @@ public class Chapter implements RuleDataInterface {
@Nullable
@Override
public String getVariable(@NonNull String key) {
return variableMap.get(key);
return getVariableMap().get(key);
}
public String getVariable() {

@ -487,7 +487,7 @@ interface JsExtensions {
Debug.log(it.sourceUrl, msg)
} ?: Debug.log(msg)*/
if (App.isDebug()) {
Log.e(TAG, msg)
Log.d(TAG, msg)
}
return msg
}

@ -293,29 +293,7 @@ public class BookDetailedActivity extends BaseActivity {
//换源对话框
mSourceDialog.setOnSourceChangeListener((bean, pos) -> {
Book bookTem = (Book) mBook.clone();
bookTem.clearCathe();
bookTem.setChapterUrl(bean.getChapterUrl());
bookTem.setInfoUrl(bean.getInfoUrl());
bookTem.setSource(bean.getSource());
if (!StringHelper.isEmpty(bean.getImgUrl())) {
bookTem.setImgUrl(bean.getImgUrl());
}
if (!StringHelper.isEmpty(bean.getType())) {
bookTem.setType(bean.getType());
}
if (!StringHelper.isEmpty(bean.getDesc())) {
bookTem.setDesc(bean.getDesc());
}
if (!StringHelper.isEmpty(bean.getUpdateDate())) {
bookTem.setUpdateDate(bean.getUpdateDate());
}
if (!StringHelper.isEmpty(bean.getWordCount())) {
bookTem.setWordCount(bean.getWordCount());
}
if (!StringHelper.isEmpty(bean.getStatus())) {
bookTem.setStatus(bean.getStatus());
}
Book bookTem = mBook.changeSource(bean);
if (isCollected) {
mBookService.updateBook(mBook, bookTem);
}

@ -471,20 +471,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
initBottomMenuClick();
mSourceDialog.setOnSourceChangeListener((bean, pos) -> {
Book bookTem = (Book) mBook.clone();
bookTem.clearCathe();
bookTem.setInfoUrl(bean.getInfoUrl());
bookTem.setChapterUrl(bean.getChapterUrl());
bookTem.setSource(bean.getSource());
if (!StringHelper.isEmpty(bean.getImgUrl())) {
bookTem.setImgUrl(bean.getImgUrl());
}
if (!StringHelper.isEmpty(bean.getType())) {
bookTem.setType(bean.getType());
}
if (!StringHelper.isEmpty(bean.getDesc())) {
bookTem.setDesc(bean.getDesc());
}
Book bookTem = mBook.changeSource(bean);
mBookService.updateBook(mBook, bookTem);
mBook = bookTem;
aBooks = mSourceDialog.getaBooks();

@ -488,28 +488,7 @@ public abstract class BookcaseAdapter extends RecyclerView.Adapter<BookcaseAdapt
this.dialog.dismiss();
SourceExchangeDialog dialog = new SourceExchangeDialog((Activity) mContext, mBook);
dialog.setOnSourceChangeListener((bean, pos) -> {
Book bookTem = (Book) mBook.clone();
bookTem.setChapterUrl(bean.getChapterUrl());
bookTem.setInfoUrl(bean.getInfoUrl());
if (!StringHelper.isEmpty(bean.getImgUrl())) {
bookTem.setImgUrl(bean.getImgUrl());
}
if (!StringHelper.isEmpty(bean.getType())) {
bookTem.setType(bean.getType());
}
if (!StringHelper.isEmpty(bean.getDesc())) {
bookTem.setDesc(bean.getDesc());
}
if (!StringHelper.isEmpty(bean.getUpdateDate())) {
bookTem.setUpdateDate(bean.getUpdateDate());
}
if (!StringHelper.isEmpty(bean.getWordCount())) {
bookTem.setWordCount(bean.getWordCount());
}
if (!StringHelper.isEmpty(bean.getStatus())) {
bookTem.setStatus(bean.getStatus());
}
bookTem.setSource(bean.getSource());
Book bookTem = mBook.changeSource(bean);
mBookService.updateBook(mBook, bookTem);
mBook = bookTem;
list.set(this.pos, mBook);

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@ -37,28 +42,29 @@
</com.google.android.material.tabs.TabLayout>
<RelativeLayout
android:background="#474949"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="#474949">
<xyz.fycz.myreader.widget.codeview.CodeView
android:id="@+id/rv_parse_result"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:visibility="visible"
app:cv_font_size="10"
app:cv_zoom_enable="true"
android:visibility="visible" />
app:cv_zoom_enable="true" />
<xyz.fycz.myreader.widget.codeview.CodeView
android:id="@+id/rv_source_code"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:visibility="gone"
app:cv_font_size="10"
app:cv_zoom_enable="true"
android:visibility="gone" />
app:cv_zoom_enable="true" />
</RelativeLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
Loading…
Cancel
Save