From eeb8799656194a58b6cd63b91132babe3fa05bed Mon Sep 17 00:00:00 2001 From: 670848654 <670848654@qq.com> Date: Fri, 4 Sep 2020 10:39:33 +0800 Subject: [PATCH] update --- app/build.gradle | 4 ++-- .../sakuraproject/application/Sakura.java | 8 ++++++-- .../main/about/AboutActivity.java | 1 + .../main/animeList/AnimeListActivity.java | 5 +++++ .../main/animeList/AnimeListModel.java | 7 +++++-- .../main/animeList/AnimeListPresenter.java | 5 +++++ .../main/animeTopic/AnimeTopicActivity.java | 5 +++++ .../main/animeTopic/AnimeTopicModel.java | 7 +++++-- .../main/animeTopic/AnimeTopicPresenter.java | 5 +++++ .../main/base/BaseLoadDataCallback.java | 4 +++- .../sakuraproject/main/base/BaseModel.java | 11 ++++++++++ .../sakuraproject/main/base/BaseView.java | 2 ++ .../sakuraproject/main/desc/DescActivity.java | 5 +++++ .../sakuraproject/main/desc/DescModel.java | 7 +++++-- .../main/desc/DescPresenter.java | 5 +++++ .../main/favorite/FavoriteActivity.java | 5 +++++ .../main/favorite/FavoritePresenter.java | 5 +++++ .../sakuraproject/main/home/HomeActivity.java | 5 +++++ .../sakuraproject/main/home/HomeModel.java | 15 +++++++------- .../main/home/HomePresenter.java | 5 +++++ .../main/player/PlayerActivity.java | 20 +++++++++++++++++++ .../main/search/SearchActivity.java | 5 +++++ .../main/search/SearchModel.java | 9 ++++++--- .../main/search/SearchPresenter.java | 5 +++++ .../main/setting/user/ApiActivity.java | 5 +++++ .../main/setting/user/ApiPresenter.java | 5 +++++ .../sakuraproject/main/tag/TagActivity.java | 5 +++++ .../sakuraproject/main/tag/TagModel.java | 11 ++++++---- .../sakuraproject/main/tag/TagPresenter.java | 5 +++++ .../main/video/VideoContract.java | 3 ++- .../sakuraproject/main/video/VideoModel.java | 15 ++++++++------ .../main/video/VideoPresenter.java | 5 +++++ .../webview/normal/NormalWebActivity.java | 20 +++++++++++++++++++ .../main/webview/x5/X5WebActivity.java | 20 +++++++++++++++++++ app/src/main/res/values/strings.xml | 6 +++--- 35 files changed, 220 insertions(+), 35 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 459e77e..1037d21 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "my.project.sakuraproject" minSdkVersion 21 targetSdkVersion 29 - versionCode 24 - versionName "1.9.4" + versionCode 25 + versionName "1.9.4_redirection_fix1" ndk{abiFilters "armeabi"} resConfigs"zh" } diff --git a/app/src/main/java/my/project/sakuraproject/application/Sakura.java b/app/src/main/java/my/project/sakuraproject/application/Sakura.java index 10f67a8..25f25e9 100644 --- a/app/src/main/java/my/project/sakuraproject/application/Sakura.java +++ b/app/src/main/java/my/project/sakuraproject/application/Sakura.java @@ -30,7 +30,7 @@ public class Sakura extends Application { private List oList; private static Map destoryMap = new HashMap<>(); public static String DOMAIN; - public static String TAG_API, MOVIE_API, ZT_API, JCB_API, SEARCH_API,REDIRECTED = ""; + public static String TAG_API, MOVIE_API, ZT_API, JCB_API, SEARCH_API; public String error; public JSONObject week = new JSONObject(); @@ -69,7 +69,7 @@ public void onLowMemory() { } public static void setApi() { - TAG_API = Sakura.DOMAIN + "/sitemap/"; + TAG_API = Sakura.DOMAIN + "/sitemap"; MOVIE_API = Sakura.DOMAIN + "/movie/"; ZT_API = Sakura.DOMAIN + "/topic/"; JCB_API = Sakura.DOMAIN + "/37/"; @@ -96,6 +96,10 @@ public void onCoreInitFinished() { } } + public void showToastShortMsg(String msg) { + Toasty.warning(getApplicationContext(), "Load data url\n" + msg, Toast.LENGTH_SHORT, true).show(); + } + public void showToastMsg(String msg){ Toasty.warning(getApplicationContext(), msg, Toast.LENGTH_LONG, true).show(); } diff --git a/app/src/main/java/my/project/sakuraproject/main/about/AboutActivity.java b/app/src/main/java/my/project/sakuraproject/main/about/AboutActivity.java index 842c250..c031443 100644 --- a/app/src/main/java/my/project/sakuraproject/main/about/AboutActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/about/AboutActivity.java @@ -168,6 +168,7 @@ public void showUpdateLogs() { public List createUpdateLogList() { List logsList = new ArrayList(); + logsList.add(new LogBean("版本:1.9.4_redirection_fix1", "再次尝试修复由于网站重定向导致某些获数据取异常的Bug ┐(´д`)┌")); logsList.add(new LogBean("版本:1.9.4", "尝试修复由于网站重定向导致获数据取异常的Bug")); logsList.add(new LogBean("版本:1.9.3", "修复番剧详情加载失败闪退Bug")); logsList.add(new LogBean("版本:1.9.2", "番剧详情界面布局修改")); diff --git a/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListActivity.java b/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListActivity.java index fe650d8..157659b 100644 --- a/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListActivity.java @@ -216,4 +216,9 @@ public void showLoadErrorView(String msg) { public void showEmptyVIew() { adapter.setEmptyView(emptyView); } + + @Override + public void showLog(String url) { + runOnUiThread(() -> application.showToastShortMsg(url)); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListModel.java b/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListModel.java index ea6d650..af887d8 100644 --- a/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListModel.java +++ b/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListModel.java @@ -24,11 +24,12 @@ public class AnimeListModel extends BaseModel implements AnimeListContract.Model @Override public void getData(String url, int page, boolean isMain, boolean isMovie, AnimeListContract.LoadDataCallback callback) { if (page != 1) - url = url.contains(Sakura.DOMAIN) ? url + page + ".html" : Sakura.DOMAIN + url + page + ".html" + Sakura.REDIRECTED; + url = url.contains(Sakura.DOMAIN) ? url + page + ".html" : Sakura.DOMAIN + url + page + ".html"; getHtml(url, isMain, isMovie, callback); } private void getHtml(String url,boolean isMain, boolean isMovie, AnimeListContract.LoadDataCallback callback) { + callback.log(url); new HttpGet(url, new Callback() { @Override public void onFailure(Call call, IOException e) { @@ -39,7 +40,9 @@ public void onFailure(Call call, IOException e) { public void onResponse(Call call, Response response) { try { Document doc = Jsoup.parse(response.body().string()); - if (hasRefresh(doc)) getHtml(url, isMain, isMovie, callback); + if (hasRedirected(doc)) + getHtml(Sakura.DOMAIN + getRedirectedStr(doc), isMain, isMovie, callback); + else if (hasRefresh(doc)) getHtml(url, isMain, isMovie, callback); else { Elements animeList = doc.select("div.lpic > ul > li"); Elements movieList = doc.select("div.imgs > ul > li"); diff --git a/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListPresenter.java b/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListPresenter.java index 7610d25..6cbb579 100644 --- a/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListPresenter.java +++ b/app/src/main/java/my/project/sakuraproject/main/animeList/AnimeListPresenter.java @@ -45,4 +45,9 @@ public void pageCount(int count) { @Override public void error(String msg) { } + + @Override + public void log(String url) { + view.showLog(url); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicActivity.java b/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicActivity.java index 1cb5485..698d3d3 100644 --- a/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicActivity.java @@ -214,4 +214,9 @@ public void showLoadErrorView(String msg) { public void showEmptyVIew() { adapter.setEmptyView(emptyView); } + + @Override + public void showLog(String url) { + runOnUiThread(() -> application.showToastShortMsg(url)); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicModel.java b/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicModel.java index 58f8bf5..1443dbd 100644 --- a/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicModel.java +++ b/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicModel.java @@ -24,11 +24,12 @@ public class AnimeTopicModel extends BaseModel implements AnimeTopicContract.Mod @Override public void getData(String url, int page, boolean isMain, AnimeTopicContract.LoadDataCallback callback) { if (page != 1) - url = url.contains(Sakura.DOMAIN) ? url + page + ".html" : Sakura.DOMAIN + url + page + ".html" + Sakura.REDIRECTED; + url = url.contains(Sakura.DOMAIN) ? url + page + ".html" : Sakura.DOMAIN + url + page + ".html"; getHtml(url, isMain, callback); } private void getHtml(String url, boolean isMain, AnimeTopicContract.LoadDataCallback callback) { + callback.log(url); new HttpGet(url, new Callback() { @Override public void onFailure(Call call, IOException e) { @@ -39,7 +40,9 @@ public void onFailure(Call call, IOException e) { public void onResponse(Call call, Response response) { try { Document doc = Jsoup.parse(response.body().string()); - if (hasRefresh(doc)) getHtml(url, isMain, callback); + if (hasRedirected(doc)) + getHtml(Sakura.DOMAIN + getRedirectedStr(doc), isMain, callback); + else if (hasRefresh(doc)) getHtml(url, isMain, callback); else { Elements animeList = doc.select("div.dnews > ul > li"); if (isMain) { diff --git a/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicPresenter.java b/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicPresenter.java index 7072340..c85674f 100644 --- a/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicPresenter.java +++ b/app/src/main/java/my/project/sakuraproject/main/animeTopic/AnimeTopicPresenter.java @@ -47,4 +47,9 @@ public void pageCount(int count) { @Override public void error(String msg) { } + + @Override + public void log(String url) { + view.showLog(url); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/base/BaseLoadDataCallback.java b/app/src/main/java/my/project/sakuraproject/main/base/BaseLoadDataCallback.java index f6acf3a..4a3b14f 100644 --- a/app/src/main/java/my/project/sakuraproject/main/base/BaseLoadDataCallback.java +++ b/app/src/main/java/my/project/sakuraproject/main/base/BaseLoadDataCallback.java @@ -2,4 +2,6 @@ public interface BaseLoadDataCallback { void error(String msg); -} + + void log(String url); +} \ No newline at end of file diff --git a/app/src/main/java/my/project/sakuraproject/main/base/BaseModel.java b/app/src/main/java/my/project/sakuraproject/main/base/BaseModel.java index 5126afd..b308a24 100644 --- a/app/src/main/java/my/project/sakuraproject/main/base/BaseModel.java +++ b/app/src/main/java/my/project/sakuraproject/main/base/BaseModel.java @@ -8,4 +8,15 @@ public static boolean hasRefresh(Document body) { Element meta = body.select("meta[http-equiv=refresh]").first(); return meta != null; } + + public static boolean hasRedirected(Document body) { + if (body.html().contains("You have verified successfully")) + return true; + else + return false; + } + + public static String getRedirectedStr(Document body) { + return body.select("a").attr("href"); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/base/BaseView.java b/app/src/main/java/my/project/sakuraproject/main/base/BaseView.java index 9bf5d1e..25f19ed 100644 --- a/app/src/main/java/my/project/sakuraproject/main/base/BaseView.java +++ b/app/src/main/java/my/project/sakuraproject/main/base/BaseView.java @@ -7,4 +7,6 @@ public interface BaseView { void showLoadErrorView(String msg); //空布局 void showEmptyVIew(); + + void showLog(String url); } diff --git a/app/src/main/java/my/project/sakuraproject/main/desc/DescActivity.java b/app/src/main/java/my/project/sakuraproject/main/desc/DescActivity.java index 92e1d06..a086ee2 100644 --- a/app/src/main/java/my/project/sakuraproject/main/desc/DescActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/desc/DescActivity.java @@ -488,6 +488,11 @@ public void showEmptyVIew() { errorBg.setVisibility(View.GONE); } + @Override + public void showLog(String url) { + runOnUiThread(() -> application.showToastShortMsg(url)); + } + @Override public void showSuccessMainView(AnimeDescListBean bean) { runOnUiThread(() -> { diff --git a/app/src/main/java/my/project/sakuraproject/main/desc/DescModel.java b/app/src/main/java/my/project/sakuraproject/main/desc/DescModel.java index 0ff6a75..4dc515a 100644 --- a/app/src/main/java/my/project/sakuraproject/main/desc/DescModel.java +++ b/app/src/main/java/my/project/sakuraproject/main/desc/DescModel.java @@ -31,10 +31,11 @@ public class DescModel extends BaseModel implements DescContract.Model { @Override public void getData(String url, DescContract.LoadDataCallback callback) { - getHtml(url + Sakura.REDIRECTED, callback); + getHtml(url, callback); } private void getHtml(String url, DescContract.LoadDataCallback callback) { + callback.log(url); new HttpGet(url, new Callback() { @Override public void onFailure(Call call, IOException e) { @@ -45,7 +46,9 @@ public void onFailure(Call call, IOException e) { public void onResponse(Call call, Response response) { try { Document doc = Jsoup.parse(response.body().string()); - if (hasRefresh(doc)) getHtml(url, callback); + if (hasRedirected(doc)) + getHtml(Sakura.DOMAIN + getRedirectedStr(doc), callback); + else if (hasRefresh(doc)) getHtml(url, callback); else { String animeTitle = doc.select("h1").text(); //是否收藏 diff --git a/app/src/main/java/my/project/sakuraproject/main/desc/DescPresenter.java b/app/src/main/java/my/project/sakuraproject/main/desc/DescPresenter.java index bb055e7..be39926 100644 --- a/app/src/main/java/my/project/sakuraproject/main/desc/DescPresenter.java +++ b/app/src/main/java/my/project/sakuraproject/main/desc/DescPresenter.java @@ -44,4 +44,9 @@ public void isFavorite(boolean favorite) { public void error(String msg) { view.showLoadErrorView(msg); } + + @Override + public void log(String url) { + view.showLog(url); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/favorite/FavoriteActivity.java b/app/src/main/java/my/project/sakuraproject/main/favorite/FavoriteActivity.java index 8d70d8b..76380ee 100644 --- a/app/src/main/java/my/project/sakuraproject/main/favorite/FavoriteActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/favorite/FavoriteActivity.java @@ -152,6 +152,11 @@ public void showEmptyVIew() { adapter.setEmptyView(emptyView); } + @Override + public void showLog(String url) { + + } + @Override public void showSuccessView(List list) { favoriteList = list; diff --git a/app/src/main/java/my/project/sakuraproject/main/favorite/FavoritePresenter.java b/app/src/main/java/my/project/sakuraproject/main/favorite/FavoritePresenter.java index 3d22a5f..971792b 100644 --- a/app/src/main/java/my/project/sakuraproject/main/favorite/FavoritePresenter.java +++ b/app/src/main/java/my/project/sakuraproject/main/favorite/FavoritePresenter.java @@ -34,4 +34,9 @@ public void success(List list) { public void error(String msg) { view.showLoadErrorView(msg); } + + @Override + public void log(String url) { + + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/home/HomeActivity.java b/app/src/main/java/my/project/sakuraproject/main/home/HomeActivity.java index da72dbf..0f4982b 100644 --- a/app/src/main/java/my/project/sakuraproject/main/home/HomeActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/home/HomeActivity.java @@ -308,6 +308,11 @@ public void showLoadErrorView(String msg) { public void showEmptyVIew() { } + @Override + public void showLog(String url) { + runOnUiThread(() -> application.showToastShortMsg(url)); + } + @Override public void showLoadSuccess(LinkedHashMap map) { runOnUiThread(() -> { diff --git a/app/src/main/java/my/project/sakuraproject/main/home/HomeModel.java b/app/src/main/java/my/project/sakuraproject/main/home/HomeModel.java index b6e3905..ccd8dea 100644 --- a/app/src/main/java/my/project/sakuraproject/main/home/HomeModel.java +++ b/app/src/main/java/my/project/sakuraproject/main/home/HomeModel.java @@ -26,11 +26,12 @@ public class HomeModel extends BaseModel implements HomeContract.Model { @Override public void getData(HomeContract.LoadDataCallback callback) { - getHtml(callback); + getHtml(callback, ""); } - private void getHtml(HomeContract.LoadDataCallback callback) { - new HttpGet(Sakura.DOMAIN + Sakura.REDIRECTED, new Callback() { + private void getHtml(HomeContract.LoadDataCallback callback, String RedirectedStr) { + callback.log(Sakura.DOMAIN + RedirectedStr); + new HttpGet(Sakura.DOMAIN + RedirectedStr, new Callback() { @Override public void onFailure(Call call, IOException e) { callback.error(e.getMessage()); @@ -42,12 +43,12 @@ public void onResponse(Call call, Response response) { LinkedHashMap map = new LinkedHashMap(); JSONObject weekObj = new JSONObject(); Document body = Jsoup.parse(response.body().string()); - if (body.html().contains("You have verified successfully")) { - Sakura.REDIRECTED = body.select("a").attr("href").replaceAll("/",""); - getHtml(callback); + if (hasRedirected(body)) { + // 如果有重定向 + getHtml(callback, getRedirectedStr(body)); return; } else { - if (hasRefresh(body)) getHtml(callback); + if (hasRefresh(body)) getHtml(callback, ""); else { setData(body.select("div.tlist > ul"), weekObj, map, callback); } diff --git a/app/src/main/java/my/project/sakuraproject/main/home/HomePresenter.java b/app/src/main/java/my/project/sakuraproject/main/home/HomePresenter.java index 04dd3ee..be3c7af 100644 --- a/app/src/main/java/my/project/sakuraproject/main/home/HomePresenter.java +++ b/app/src/main/java/my/project/sakuraproject/main/home/HomePresenter.java @@ -31,5 +31,10 @@ public void success(LinkedHashMap map) { public void error(String msg) { view.showLoadErrorView(msg); } + + @Override + public void log(String url) { + view.showLog(url); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/player/PlayerActivity.java b/app/src/main/java/my/project/sakuraproject/main/player/PlayerActivity.java index 1a69f74..be4811d 100644 --- a/app/src/main/java/my/project/sakuraproject/main/player/PlayerActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/player/PlayerActivity.java @@ -380,4 +380,24 @@ public void finish() { JzvdStd.releaseAllVideos(); super.finish(); } + + @Override + public void showLoadingView() { + + } + + @Override + public void showLoadErrorView(String msg) { + + } + + @Override + public void showEmptyVIew() { + + } + + @Override + public void showLog(String url) { + runOnUiThread(() -> application.showToastShortMsg(url)); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/search/SearchActivity.java b/app/src/main/java/my/project/sakuraproject/main/search/SearchActivity.java index 001abf1..af95cee 100644 --- a/app/src/main/java/my/project/sakuraproject/main/search/SearchActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/search/SearchActivity.java @@ -216,6 +216,11 @@ public void showEmptyVIew() { adapter.setEmptyView(emptyView); } + @Override + public void showLog(String url) { + runOnUiThread(() -> application.showToastShortMsg(url)); + } + @Override public void showSuccessView(boolean isMain, List list) { runOnUiThread(() -> { diff --git a/app/src/main/java/my/project/sakuraproject/main/search/SearchModel.java b/app/src/main/java/my/project/sakuraproject/main/search/SearchModel.java index b7f081c..4852009 100644 --- a/app/src/main/java/my/project/sakuraproject/main/search/SearchModel.java +++ b/app/src/main/java/my/project/sakuraproject/main/search/SearchModel.java @@ -24,13 +24,14 @@ public class SearchModel extends BaseModel implements SearchContract.Model { @Override public void getData(String url, int page, boolean isMain, SearchContract.LoadDataCallback callback) { if (page != 1) - url = url.contains(Sakura.DOMAIN) ? url + "/?page=" + page: Sakura.DOMAIN + url + "/?page=" + page + Sakura.REDIRECTED.replace("?", "&"); + url = url.contains(Sakura.DOMAIN) ? url + "?page=" + page: Sakura.DOMAIN + url + "?page=" + page ; else - url = url.contains(Sakura.DOMAIN) ? url + Sakura.REDIRECTED : Sakura.DOMAIN + url + Sakura.REDIRECTED; + url = url.contains(Sakura.DOMAIN) ? url : Sakura.DOMAIN + url; getHtml(url, isMain, callback); } private void getHtml(String url, boolean isMain, SearchContract.LoadDataCallback callback) { + callback.log(url); new HttpGet(url, new Callback() { @Override public void onFailure(Call call, IOException e) { @@ -41,7 +42,9 @@ public void onFailure(Call call, IOException e) { public void onResponse(Call call, Response response) { try { Document doc = Jsoup.parse(response.body().string()); - if (hasRefresh(doc)) getHtml(url, isMain, callback); + if (hasRedirected(doc)) + getHtml(Sakura.DOMAIN + getRedirectedStr(doc), isMain, callback); + else if (hasRefresh(doc)) getHtml(url, isMain, callback); else { Elements animeList = doc.select("div.lpic > ul > li"); if (isMain) { diff --git a/app/src/main/java/my/project/sakuraproject/main/search/SearchPresenter.java b/app/src/main/java/my/project/sakuraproject/main/search/SearchPresenter.java index fe18678..0a1a641 100644 --- a/app/src/main/java/my/project/sakuraproject/main/search/SearchPresenter.java +++ b/app/src/main/java/my/project/sakuraproject/main/search/SearchPresenter.java @@ -48,4 +48,9 @@ public void pageCount(int pageCount) { public void error(String msg) { } + + @Override + public void log(String url) { + view.showLog(url); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/setting/user/ApiActivity.java b/app/src/main/java/my/project/sakuraproject/main/setting/user/ApiActivity.java index fe36168..dbccf8c 100644 --- a/app/src/main/java/my/project/sakuraproject/main/setting/user/ApiActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/setting/user/ApiActivity.java @@ -202,6 +202,11 @@ public void showEmptyVIew() { adapter.setEmptyView(emptyView); } + @Override + public void showLog(String url) { + + } + @Override public void showSuccess(List list) { apiList = list; diff --git a/app/src/main/java/my/project/sakuraproject/main/setting/user/ApiPresenter.java b/app/src/main/java/my/project/sakuraproject/main/setting/user/ApiPresenter.java index 4c03ac0..f3f8f78 100644 --- a/app/src/main/java/my/project/sakuraproject/main/setting/user/ApiPresenter.java +++ b/app/src/main/java/my/project/sakuraproject/main/setting/user/ApiPresenter.java @@ -34,4 +34,9 @@ public void success(List list) { public void error(String msg) { view.showLoadErrorView(msg); } + + @Override + public void log(String url) { + + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/tag/TagActivity.java b/app/src/main/java/my/project/sakuraproject/main/tag/TagActivity.java index 5214cfc..c70b8d9 100644 --- a/app/src/main/java/my/project/sakuraproject/main/tag/TagActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/tag/TagActivity.java @@ -138,4 +138,9 @@ public void showLoadErrorView(String msg) { public void showEmptyVIew() { adapter.setEmptyView(emptyView); } + + @Override + public void showLog(String url) { + runOnUiThread(() -> application.showToastShortMsg(url)); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/tag/TagModel.java b/app/src/main/java/my/project/sakuraproject/main/tag/TagModel.java index acd894f..9d8eefa 100644 --- a/app/src/main/java/my/project/sakuraproject/main/tag/TagModel.java +++ b/app/src/main/java/my/project/sakuraproject/main/tag/TagModel.java @@ -28,11 +28,12 @@ public class TagModel extends BaseModel implements TagContract.Model { @Override public void getData(TagContract.LoadDataCallback callback) { - getHtml(callback); + getHtml(callback, ""); } - private void getHtml(TagContract.LoadDataCallback callback) { - new HttpGet(Sakura.TAG_API, new Callback() { + private void getHtml(TagContract.LoadDataCallback callback, String RedirectedStr) { + callback.log(Sakura.TAG_API + RedirectedStr); + new HttpGet(Sakura.TAG_API + RedirectedStr, new Callback() { @Override public void onFailure(Call call, IOException e) { callback.error(e.getMessage()); @@ -42,7 +43,9 @@ public void onFailure(Call call, IOException e) { public void onResponse(Call call, Response response) { try { Document doc = Jsoup.parse(response.body().string()); - if (hasRefresh(doc)) getHtml(callback); + if (hasRedirected(doc)) + getHtml(callback, getRedirectedStr(doc)); + else if (hasRefresh(doc)) getHtml(callback, ""); else { Elements tagTitles = doc.select("div.dtit"); Elements tagItems = doc.select("div.link"); diff --git a/app/src/main/java/my/project/sakuraproject/main/tag/TagPresenter.java b/app/src/main/java/my/project/sakuraproject/main/tag/TagPresenter.java index 164c110..37275ea 100644 --- a/app/src/main/java/my/project/sakuraproject/main/tag/TagPresenter.java +++ b/app/src/main/java/my/project/sakuraproject/main/tag/TagPresenter.java @@ -35,4 +35,9 @@ public void success(List list) { public void error(String msg) { view.showLoadErrorView(msg); } + + @Override + public void log(String url) { + view.showLog(url); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/video/VideoContract.java b/app/src/main/java/my/project/sakuraproject/main/video/VideoContract.java index fe3a992..46d3c66 100644 --- a/app/src/main/java/my/project/sakuraproject/main/video/VideoContract.java +++ b/app/src/main/java/my/project/sakuraproject/main/video/VideoContract.java @@ -4,13 +4,14 @@ import my.project.sakuraproject.bean.AnimeDescDetailsBean; import my.project.sakuraproject.main.base.BaseLoadDataCallback; +import my.project.sakuraproject.main.base.BaseView; public interface VideoContract { interface Model { void getData(String title, String url, LoadDataCallback callback); } - interface View { + interface View extends BaseView { void cancelDialog(); void getVideoSuccess(List list); diff --git a/app/src/main/java/my/project/sakuraproject/main/video/VideoModel.java b/app/src/main/java/my/project/sakuraproject/main/video/VideoModel.java index 35758a3..bb3a456 100644 --- a/app/src/main/java/my/project/sakuraproject/main/video/VideoModel.java +++ b/app/src/main/java/my/project/sakuraproject/main/video/VideoModel.java @@ -22,12 +22,13 @@ public class VideoModel extends BaseModel implements VideoContract.Model { private List videoUrlList = new ArrayList<>(); @Override - public void getData(String title, String HTML_url, VideoContract.LoadDataCallback callback) { - getHtml(title, HTML_url + Sakura.REDIRECTED, callback); + public void getData(String title, String url, VideoContract.LoadDataCallback callback) { + getHtml(title, url, callback); } - private void getHtml(String title, String HTML_url, VideoContract.LoadDataCallback callback) { - new HttpGet(HTML_url, new Callback() { + private void getHtml(String title, String url, VideoContract.LoadDataCallback callback) { + callback.log(url); + new HttpGet(url, new Callback() { @Override public void onFailure(Call call, IOException e) { callback.error(); @@ -36,10 +37,12 @@ public void onFailure(Call call, IOException e) { @Override public void onResponse(Call call, Response response) throws IOException { Document doc = Jsoup.parse(response.body().string()); - if (hasRefresh(doc)) getHtml(title, HTML_url, callback); + if (hasRedirected(doc)) + getHtml(title, Sakura.DOMAIN + getRedirectedStr(doc), callback); + else if (hasRefresh(doc)) getHtml(title, url, callback); else { String fid = DatabaseUtil.getAnimeID(title); - DatabaseUtil.addIndex(fid, HTML_url); + DatabaseUtil.addIndex(fid, url); callback.successDrama(getAllDrama(fid, doc.select("div.movurls > ul > li"))); Elements playList = doc.select("div.playbo > a"); if (playList.size() > 0) { diff --git a/app/src/main/java/my/project/sakuraproject/main/video/VideoPresenter.java b/app/src/main/java/my/project/sakuraproject/main/video/VideoPresenter.java index fb6eaf0..f10c82b 100644 --- a/app/src/main/java/my/project/sakuraproject/main/video/VideoPresenter.java +++ b/app/src/main/java/my/project/sakuraproject/main/video/VideoPresenter.java @@ -54,4 +54,9 @@ public void successDrama(List list) { public void error(String msg) { } + + @Override + public void log(String url) { + view.showLog(url); + } } diff --git a/app/src/main/java/my/project/sakuraproject/main/webview/normal/NormalWebActivity.java b/app/src/main/java/my/project/sakuraproject/main/webview/normal/NormalWebActivity.java index 19ebb09..6975325 100644 --- a/app/src/main/java/my/project/sakuraproject/main/webview/normal/NormalWebActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/webview/normal/NormalWebActivity.java @@ -389,6 +389,26 @@ public void onSniffingError(View webView, String url, int errorCode) { this.finish(); } + @Override + public void showLoadingView() { + + } + + @Override + public void showLoadErrorView(String msg) { + + } + + @Override + public void showEmptyVIew() { + + } + + @Override + public void showLog(String url) { + runOnUiThread(() -> application.showToastShortMsg(url)); + } + /** * 全屏容器界面 */ diff --git a/app/src/main/java/my/project/sakuraproject/main/webview/x5/X5WebActivity.java b/app/src/main/java/my/project/sakuraproject/main/webview/x5/X5WebActivity.java index 362135b..323e9d0 100644 --- a/app/src/main/java/my/project/sakuraproject/main/webview/x5/X5WebActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/webview/x5/X5WebActivity.java @@ -402,6 +402,26 @@ public void onSniffingError(View webView, String url, int errorCode) { this.finish(); } + @Override + public void showLoadingView() { + runOnUiThread(() -> application.showToastShortMsg(url)); + } + + @Override + public void showLoadErrorView(String msg) { + + } + + @Override + public void showEmptyVIew() { + + } + + @Override + public void showLog(String url) { + + } + /** * 全屏容器界面 */ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bc5d802..dae34ee 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -122,7 +122,7 @@ OnePlus 7 Pro\nAndroid 10 当前版本 最后编译日期 - 2020年9月2日 + 2020年9月4日 缓存目录 /SakuraAnime/\n卸载后自行删除此目录 Github @@ -132,8 +132,8 @@ 检测更新 检测更新中… 下载中,请等待 - 连接服务器超时,请重试 - 连接服务器超时,检测更新失败 + 连接Github超时,请重试 + 连接Github超时,检测更新失败 重试 已是最新版本,无需更新 取消