Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
670848654 committed Sep 4, 2020
1 parent 6b85249 commit eeb8799
Show file tree
Hide file tree
Showing 35 changed files with 220 additions and 35 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Sakura extends Application {
private List<Activity> oList;
private static Map<String, Activity> 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();

Expand Down Expand Up @@ -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/";
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", "番剧详情界面布局修改"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ public void pageCount(int count) {
@Override
public void error(String msg) {
}

@Override
public void log(String url) {
view.showLog(url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ public void pageCount(int count) {
@Override
public void error(String msg) {
}

@Override
public void log(String url) {
view.showLog(url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

public interface BaseLoadDataCallback {
void error(String msg);
}

void log(String url);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public interface BaseView {
void showLoadErrorView(String msg);
//空布局
void showEmptyVIew();

void showLog(String url);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
//是否收藏
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public void showEmptyVIew() {
adapter.setEmptyView(emptyView);
}

@Override
public void showLog(String url) {

}

@Override
public void showSuccessView(List<AnimeListBean> list) {
favoriteList = list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ public void success(List<AnimeListBean> list) {
public void error(String msg) {
view.showLoadErrorView(msg);
}

@Override
public void log(String url) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnimeListBean> list) {
runOnUiThread(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ public void pageCount(int pageCount) {
public void error(String msg) {

}

@Override
public void log(String url) {
view.showLog(url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ public void showEmptyVIew() {
adapter.setEmptyView(emptyView);
}

@Override
public void showLog(String url) {

}

@Override
public void showSuccess(List<ApiBean> list) {
apiList = list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ public void success(List<ApiBean> list) {
public void error(String msg) {
view.showLoadErrorView(msg);
}

@Override
public void log(String url) {

}
}
Loading

0 comments on commit eeb8799

Please sign in to comment.