修复bug、优化体验

pull/5/head
fengyuecanzhu 4 years ago
parent 423cfcb897
commit 6d770fa296
  1. BIN
      .idea/caches/build_file_checksums.ser
  2. 78
      app/src/androidTest/java/xyz/fycz/myreader/ExampleInstrumentedTest.java
  3. 51
      app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java
  4. 2
      app/src/main/java/xyz/fycz/myreader/webapi/crawler/read/JiuTaoReadCrawler.java
  5. 78
      app/src/test/java/File1.java
  6. 22
      app/src/test/java/Test.java
  7. 2
      app/version_code.properties

File diff suppressed because one or more lines are too long

@ -1,7 +1,15 @@
package xyz.fycz.myreader.util.utils;
import android.content.Context;
import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import okhttp3.*;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.application.TrustAllCerts;
import xyz.fycz.myreader.util.HttpUtil;
import xyz.fycz.myreader.util.StringHelper;
@ -9,8 +17,10 @@ import xyz.fycz.myreader.util.StringHelper;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
public class OkHttpUtils {
@ -23,6 +33,7 @@ public class OkHttpUtils {
public static String getHtml(String url) throws IOException {
return getHtml(url, "utf-8");
}
public static String getHtml(String url, String encodeType) throws IOException {
return getHtml(url, null, encodeType);
}
@ -39,13 +50,13 @@ public class OkHttpUtils {
//.addHeader("Charsert", "utf-8")
.addHeader("Cache-Control", "no-cache")
.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36");
if (cookie != null){
if (cookie != null) {
builder.addHeader("Cookie", cookie);
}
if (requestBody != null) {
builder.post(requestBody);
Log.d("HttpPost URl", url);
}else {
} else {
Log.d("HttpGet URl", url);
}
Request request = builder
@ -54,7 +65,7 @@ public class OkHttpUtils {
Response response = okHttpClient
.newCall(request)
.execute();
ResponseBody body=response.body();
ResponseBody body = response.body();
if (body == null) {
return "";
} else {
@ -85,9 +96,41 @@ public class OkHttpUtils {
Response response = okHttpClient
.newCall(request)
.execute();
if (response.body() == null){
if (response.body() == null) {
return null;
}
return response.body().byteStream();
}
public static String getUpdateInfo() throws IOException, JSONException {
String key = "ryvwiq";
if (App.isApkInDebug(App.getmContext())) {
key = "sgak2h";
}
String url = "https://www.yuque.com/api/docs/" + key + "?book_id=19981967&include_contributors=true&include_hits=true&include_like=true&include_pager=true&include_suggests=true";
String referer = "https://www.yuque.com/books/share/bf61f5fb-6eff-4740-ab38-749300e79306/" + key;
Request.Builder builder = new Request.Builder()
.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4168.3 Safari/537.36")
.addHeader("Content-Type", "application/json")
.addHeader("Referer", referer);
Request request = builder
.url(url)
.build();
Response response = okHttpClient
.newCall(request)
.execute();
ResponseBody body = response.body();
if (body == null) {
return "";
} else {
String bodyStr = new String(body.bytes(), StandardCharsets.UTF_8);
JSONObject jsonObj = new JSONObject(bodyStr);
jsonObj = jsonObj.getJSONObject("data");
String content = jsonObj.getString("content");
Document doc = Jsoup.parse(content);
content = doc.text();
Log.d("Http: UpdateInfo", content);
return content;
}
}
}

@ -18,7 +18,7 @@ import java.util.ArrayList;
public class JiuTaoReadCrawler implements ReadCrawler {
public static final String NAME_SPACE = "https://www.9txs.com";
public static final String NAME_SPACE = "https://www.9txs.org";
public static final String NOVEL_SEARCH = "https://so.9txs.org/www/,searchkey={key}";
public static final String CHARSET = "UTF-8";
public static final String SEARCH_CHARSET = "UTF-8";

@ -0,0 +1,78 @@
/**
* @author fengyue
* @date 2021/5/8 18:49
*/
public class File1 {
private String icon;
private int t;
private String id;
private String name_all;
private String size;
private String time;
private String duan;
private int p_ico;
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public int getT() {
return t;
}
public void setT(int t) {
this.t = t;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName_all() {
return name_all;
}
public void setName_all(String name_all) {
this.name_all = name_all;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getDuan() {
return duan;
}
public void setDuan(String duan) {
this.duan = duan;
}
public int getP_ico() {
return p_ico;
}
public void setP_ico(int p_ico) {
this.p_ico = p_ico;
}
}

File diff suppressed because one or more lines are too long

@ -1,2 +1,2 @@
#Sun Apr 25 18:50:43 CST 2021
#Mon May 03 14:54:05 CST 2021
VERSION_CODE=194

Loading…
Cancel
Save