From 12b860f59de01d68ad10fa2e3206dc843ed44eb3 Mon Sep 17 00:00:00 2001 From: ag2s20150909 Date: Fri, 6 Aug 2021 23:40:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E5=85=B8:=E4=B8=AD=E6=96=87=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=99=BE=E5=BA=A6=E6=B1=89=E8=AF=AD=E5=AD=97=E5=85=B8?= =?UTF-8?q?=EF=BC=8C=E8=8B=B1=E6=96=87=E4=BD=BF=E7=94=A8=E6=B5=B7=E8=AF=8D?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/cronetlib/cronet_api.jar | Bin 69333 -> 69333 bytes app/cronetlib/cronet_impl_common_java.jar | Bin 97267 -> 97267 bytes app/cronetlib/src/cronet_api-src.jar | Bin 44068 -> 44068 bytes .../src/cronet_impl_common_java-src.jar | Bin 22299 -> 22299 bytes .../app/help/http/cronet/CronetInterceptor.kt | 7 ++- .../io/legado/app/ui/dict/DictViewModel.kt | 52 ++++++++++++++++++ 6 files changed, 58 insertions(+), 1 deletion(-) diff --git a/app/cronetlib/cronet_api.jar b/app/cronetlib/cronet_api.jar index d62e993bb5405bcb3ae3bd090dd231196c3254ea..5f322b8f80cba518ec8d548355cbe462d7dfa517 100644 GIT binary patch delta 132 zcmcaQm*whQ7Ks3FW)=|!2vF2ovCwHv9SZ|P9n0kSui}#pn7F1oFtTm5=VUTAHgw=& zFkmobWN2@sCX)=K@npmOVw=w}S^s4L*|L?J@f05bxXmPx delta 133 zcmcaQm*whQ7Ks3FW)=|!2vF2wKJ@Wo9SZ|P9n0kSui}#pn7F1oFtTm5=VUTAGI!u% zFkmobWNlGEFv2F)&C=NwG*YO)^b2voNzvGchqVPD-0x%_Pli gVPrCSCX)=4k@@6>f})$xFj@a)0a>$^oADGM010pj_4%Nzr7Dgtu>30wKCl3oP7>Mf9HFB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s;xu2eaE~UXnbg<1ACHX{ThYX1ANOHl^z5jpscx5Isr~MsMW)bc{1&Tff~)> zG_PDc;hM05pm}vR^`}wpHTlwn{s-4=hpzv)=O6ccUc#?Q_9a(6Q1EX#&9A);<+m_j aH>-{-wP-ua2E6|Pr diff --git a/app/cronetlib/src/cronet_impl_common_java-src.jar b/app/cronetlib/src/cronet_impl_common_java-src.jar index 7d7da6f3313aba503e992b022341e858295453b5..d4e43c622d08a631bd64e038779cc3550ffa0d0c 100644 GIT binary patch delta 558 zcmV+}0@3}Ot^u2_0kCdG4Yz>T^ydKp0MP>g049@x0U47&RSB3c#39+BhRB-Vl**$xsy{P#H|RIF;*{1C;-JsXK*kSUm)YtXV%41vi6!Co`D zLnSbQcn=i5F28^EwAmL31!pKM%;eMnqXJ^AnNnGa1h}x@5u$kzE|wvryg=eOC1t;9 zW|dS%SnG`lG=y)<;=!rmYgC#`OGdSov@fSQbl2g_a{ja+PFclP8CXHJhPlO^5eEnC zDHY#QgP;vHb}Z$B7O*smiwuI7r$xBhv{di~I-jl#adOC>_jt z3RCUIiVBwZa-@lNYln}APu^@eJX)8vvfJ&R40PeSwZNp%Mpev6)%3i@ZEUl7?X`(a z=dvnnnP-2`q@i*DTIV9yn_D;>o#t;7eY?AYf;Ttru~KGEOw?_he{Wc{v-x)^K0FL{JJEZ)<5?d=N92h051{(o^^ w&*Nh8GuzSm15ir?1QY-O00;m803j;WR}wO;0RXe0M{5lPw}995vkz4a0w<&n@&Et; delta 558 zcmV+}0@3}Ot^u2_0kCdG4JI5gKIZ`d0MP>g049@x0U47&RSa^xNR>@(Ha{Q?_k7%QTo)o)?-Vae z10&B5U|AwWrIH)oY#?k*DU~J=RuvqFG$_=lwwMveb>W9bkU5x=YtXV$41viE!Cniw zMI|tUbO#i^F1~*awb@k&6=x_c%#_psqXJTFnR3~P47jl05t3OH&lfS|yh7qQHD$kO zVU<)tSnrJpG=y*J>fUMLD^!|GOGdSov@gdwbXW1qV)isAPTizd8CXTNhMC2k5PJvg zsTJQ+gP;vHb}Z+DR}gYp-2o zx|B_2%RGO1CLN9Y$2w=ZUR}ff;Bb#YJ?J>LdM?_X(!gUDj{9Xp6BH!kQ = MutableLiveData() fun dict(word: String) { + if(isChinese(word)){ + baiduDict(word) + }else{ + haiciDict(word) + } + + } + + /** + * 海词英文词典 + * + * @param word + */ + private fun haiciDict(word: String) { execute { val body = okHttpClient.newCallStrResponse { get("https://apii.dict.cn/mini.php", mapOf(Pair("q", word))) @@ -25,7 +40,44 @@ class DictViewModel(application: Application) : BaseViewModel(application) { }.onError { context.toastOnUi(it.localizedMessage) } + } + + /** + * 百度汉语词典 + * + * @param word + */ + private fun baiduDict(word: String) { + execute { + val body = okHttpClient.newCallStrResponse { + get("https://dict.baidu.com/s", mapOf(Pair("wd", word))) + }.body + val jsoup = Jsoup.parse(body!!) + jsoup.select("script").remove()//移除script + jsoup.select("#word-header").remove()//移除单字的header + jsoup.select("#term-header").remove()//移除词语的header + jsoup.select(".more-button").remove()//移除展示更多 + jsoup.select(".disactive").remove() + jsoup.select("#download-wrapper").remove()//移除下载广告 + jsoup.select("#right-panel").remove()//移除右侧广告 + jsoup.select("#content-panel") + }.onSuccess { + dictHtmlData.postValue(it.html()) + }.onError { + context.toastOnUi(it.localizedMessage) + } + } + + /** + * 判断是否包含汉字 + * @param str + * @return + */ + fun isChinese(str: String): Boolean { + val p = Pattern.compile("[\u4e00-\u9fa5]") + val m = p.matcher(str) + return m.find() } } \ No newline at end of file