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 Aug 10, 2020
1 parent 3b555c1 commit ddbbe3b
Show file tree
Hide file tree
Showing 17 changed files with 300 additions and 77 deletions.
5 changes: 3 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 21
versionName "1.9.1"
versionCode 22
versionName "1.9.2"
ndk{abiFilters "armeabi"}
resConfigs"zh"
}
Expand Down Expand Up @@ -53,5 +53,6 @@ dependencies {
implementation 'com.github.fanchen001:Sniffing:1.0.1'
implementation 'com.github.GrenderG:Toasty:1.4.2'
implementation 'com.github.pinguo-zhouwei:EasyBlur:v1.0.0'
implementation 'co.lujun:androidtagview:1.1.7'
}

Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void showSnackbarMsgAction(View view, String msg, String actionMsg, View.

public void showSnackbarMsg(View view, String msg) {
Snackbar snackbar = Snackbar.make(view, msg, Snackbar.LENGTH_LONG);
snackbar.getView().setBackgroundColor(getResources().getColor(R.color.logo_bg));
snackbar.getView().setBackgroundColor(getResources().getColor(R.color.colorAccent));
snackbar.show();
}

Expand Down
38 changes: 38 additions & 0 deletions app/src/main/java/my/project/sakuraproject/bean/AnimeListBean.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package my.project.sakuraproject.bean;

import java.util.List;

public class AnimeListBean {
private String title;
private String url;
Expand All @@ -9,6 +11,42 @@ public class AnimeListBean {
private String lx;
private String bq;
private String img;
private List<String> tagTitles;
private List<String> tagUrls;
private String score;
private String updateTime;

public String getScore() {
return score;
}

public void setScore(String score) {
this.score = score;
}

public String getUpdateTime() {
return updateTime;
}

public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}

public List<String> getTagTitles() {
return tagTitles;
}

public void setTagTitles(List<String> tagTitles) {
this.tagTitles = tagTitles;
}

public List<String> getTagUrls() {
return tagUrls;
}

public void setTagUrls(List<String> tagUrls) {
this.tagUrls = tagUrls;
}

public AnimeListBean() {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package my.project.sakuraproject.custom;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class InsideScrollView extends ScrollView {
public InsideScrollView(@NonNull Context context) {
super(context);
}

public InsideScrollView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}

public InsideScrollView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
//关键点在这
getParent().requestDisallowInterceptTouchEvent(true);
return super.onInterceptTouchEvent(ev);
}
}
26 changes: 26 additions & 0 deletions app/src/main/java/my/project/sakuraproject/custom/MyTextView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package my.project.sakuraproject.custom;

import android.content.Context;
import android.util.AttributeSet;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;

public class MyTextView extends AppCompatTextView {
public MyTextView(Context context) {
super(context);
}

public MyTextView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}

public MyTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}

@Override
public boolean isFocused() {
return true;
}
}
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.2", "番剧详情界面布局修改"));
logsList.add(new LogBean("版本:1.9.1", "修正动漫分类列表"));
logsList.add(new LogBean("版本:1.9.0", "修复一些Bug\n优化番剧详情界面\n内置播放器新增屏幕锁定、快进、后退操作"));
logsList.add(new LogBean("版本:1.8.9","修复解析时弹窗不关闭的问题"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void initList() {
list.add(new SourceBean("customtabs", "GoogleChrome", "mirrored from https://chromium.googlesource.com/custom-tabs-client", "https://github.com/GoogleChrome/custom-tabs-client"));
list.add(new SourceBean("Toasty","GrenderG","The usual Toast, but with steroids","https://github.com/GrenderG/Toasty"));
list.add(new SourceBean("Sniffing","fanchen001","【次元番】使用的,一个基于webview/x5webview的视频嗅探工具,能准确解析绝大多数手机在线视频网站的视频真实链接。","https://github.com/fanchen001/Sniffing"));
list.add(new SourceBean("AndroidTagView","whilu","A TagView library for Android. Customize your own & Drag effect.","https://github.com/whilu/AndroidTagView"));
}

public void initAdapter() {
Expand All @@ -95,7 +96,7 @@ public void initAdapter() {
adapter.setOnItemClickListener((adapter, view, position) -> {
if (Utils.isFastClick()) Utils.viewInChrome(this, list.get(position).getUrl());
});
if (Utils.checkHasNavigationBar(this)) recyclerView.setPadding(0,0,0, Utils.getNavigationBarHeight(this));
if (Utils.checkHasNavigationBar(this)) recyclerView.setPadding(0,0,0, Utils.getNavigationBarHeight(this) - 5);
recyclerView.setAdapter(adapter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
Expand Down Expand Up @@ -47,6 +50,8 @@

import butterknife.BindView;
import butterknife.OnClick;
import co.lujun.androidtagview.TagContainerLayout;
import co.lujun.androidtagview.TagView;
import my.project.sakuraproject.R;
import my.project.sakuraproject.adapter.AnimeDescDetailsAdapter;
import my.project.sakuraproject.adapter.AnimeDescDramaAdapter;
Expand All @@ -57,7 +62,10 @@
import my.project.sakuraproject.bean.AnimeDescListBean;
import my.project.sakuraproject.bean.AnimeDescRecommendBean;
import my.project.sakuraproject.bean.AnimeListBean;
import my.project.sakuraproject.custom.InsideScrollView;
import my.project.sakuraproject.custom.MyTextView;
import my.project.sakuraproject.database.DatabaseUtil;
import my.project.sakuraproject.main.animeList.AnimeListActivity;
import my.project.sakuraproject.main.base.BaseActivity;
import my.project.sakuraproject.main.video.VideoContract;
import my.project.sakuraproject.main.video.VideoPresenter;
Expand All @@ -72,14 +80,6 @@ public class DescActivity extends BaseActivity<DescContract.View, DescPresenter>
Toolbar toolbar;
@BindView(R.id.anime_img)
ImageView animeImg;
@BindView(R.id.sy)
AppCompatTextView sy;
@BindView(R.id.dq)
AppCompatTextView dq;
@BindView(R.id.lx)
AppCompatTextView lx;
@BindView(R.id.bq)
AppCompatTextView bq;
@BindView(R.id.desc)
AppCompatTextView desc;
@BindView(R.id.mSwipe)
Expand Down Expand Up @@ -126,6 +126,14 @@ public class DescActivity extends BaseActivity<DescContract.View, DescPresenter>
@BindView(R.id.bg)
ImageView bg;
private MenuItem favorite;
@BindView(R.id.tag_view)
TagContainerLayout tagContainerLayout;
@BindView(R.id.update_time)
MyTextView update_time;
@BindView(R.id.score_view)
AppCompatTextView score_view;
@BindView(R.id.inside_view)
InsideScrollView scrollView;

@Override
protected DescPresenter createPresenter() {
Expand All @@ -150,10 +158,12 @@ protected void init() {
Slidr.attach(this, Utils.defaultInit());
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) msg.getLayoutParams();
params.setMargins(10, 0, 10, 0);
scrollView.getViewTreeObserver().addOnScrollChangedListener(() -> mSwipe.setEnabled(scrollView.getScrollY() == 0));
getBundle();
initToolbar();
initSwipe();
initAdapter();
initTagClick();
}

@Override
Expand Down Expand Up @@ -245,6 +255,34 @@ private LinearLayoutManager getLinearLayoutManager() {
return linearLayoutManager;
}

private void initTagClick() {
tagContainerLayout.setOnTagClickListener(new TagView.OnTagClickListener() {
@Override
public void onTagClick(int position, String text) {
Bundle bundle = new Bundle();
bundle.putString("title", animeListBean.getTagTitles().get(position));
bundle.putString("url", VideoUtils.getUrl(animeListBean.getTagUrls().get(position)));
bundle.putBoolean("isMovie", animeListBean.getTagUrls().get(position).contains("movie") ? true : false);
startActivity(new Intent(DescActivity.this, AnimeListActivity.class).putExtras(bundle));
}

@Override
public void onTagLongClick(int position, String text) {

}

@Override
public void onSelectedTagDrag(int position, String text) {

}

@Override
public void onTagCrossClick(int position) {

}
});
}

@OnClick(R.id.open_drama)
public void dramaClick() {
if (!mBottomSheetDialog.isShowing()) {
Expand All @@ -257,10 +295,10 @@ public void dramaClick() {
public void openAnimeDesc() {
toolbar.setTitle(Utils.getString(R.string.loading));
animeImg.setImageDrawable(getDrawable(R.drawable.loading));
setTextviewEmpty(sy);
setTextviewEmpty(dq);
setTextviewEmpty(lx);
setTextviewEmpty(bq);
tagContainerLayout.setVisibility(View.GONE);
tagContainerLayout.setTags("");
update_time.setText("");
score_view.setVisibility(View.GONE);
setTextviewEmpty(desc);
mSwipe.setRefreshing(true);
animeDescListBean = new AnimeDescListBean();
Expand Down Expand Up @@ -383,11 +421,12 @@ public void onResourceReady(Bitmap resource, @Nullable Transition<? super Bitmap
});
Utils.setDefaultImage(this, animeListBean.getImg(), animeImg);
toolbar.setTitle(animeListBean.getTitle());
sy.setText(animeListBean.getSy());
dq.setText(animeListBean.getDq());
lx.setText(animeListBean.getLx());
bq.setText(animeListBean.getBq());
tagContainerLayout.setTags(animeListBean.getTagTitles());
tagContainerLayout.setVisibility(View.VISIBLE);
desc.setText(animeListBean.getDesc());
update_time.setText(animeListBean.getUpdateTime());
score_view.setText(animeListBean.getScore()+"分");
score_view.setVisibility(View.VISIBLE);
}

@Override
Expand Down
39 changes: 29 additions & 10 deletions app/src/main/java/my/project/sakuraproject/main/desc/DescModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
Expand All @@ -25,6 +26,7 @@ public class DescModel extends BaseModel implements DescContract.Model {
private String fid;
private String dramaStr;
private AnimeDescListBean animeDescListBean = new AnimeDescListBean();
private AnimeListBean animeListBean = new AnimeListBean();

@Override
public void getData(String url, DescContract.LoadDataCallback callback) {
Expand All @@ -51,20 +53,26 @@ public void onResponse(Call call, Response response) {
DatabaseUtil.addAnime(animeTitle);
fid = DatabaseUtil.getAnimeID(animeTitle);
dramaStr = DatabaseUtil.queryAllIndex(fid);
AnimeListBean bean = new AnimeListBean();
//番剧名称
bean.setTitle(animeTitle);
animeListBean.setTitle(animeTitle);
//番剧简介
bean.setDesc(doc.select("div.info").text());
bean.setSy(doc.select("div.sinfo > span").get(0).text().replaceAll("上映:", "上映: "));
bean.setDq(doc.select("div.sinfo > span").get(1).text().replaceAll("地区:", "地区: "));
bean.setLx(doc.select("div.sinfo > span").get(2).text());
bean.setBq(doc.select("div.sinfo > span").get(4).text());
animeListBean.setDesc(doc.select("div.info").text());
Elements descElements = new Elements();
descElements.addAll(doc.select("div.sinfo > span").get(0).select("a"));
descElements.addAll(doc.select("div.sinfo > span").get(1).select("a"));
descElements.addAll(doc.select("div.sinfo > span").get(2).select("a"));
descElements.addAll(doc.select("div.sinfo > span").get(4).select("a"));
setTags(descElements);
animeListBean.setScore(doc.select("div.score > em").text());
if (doc.select("div.sinfo > p").size() > 1)
animeListBean.setUpdateTime(doc.select("div.sinfo > p").get(1).text().isEmpty() ? Utils.getString(R.string.no_update) : doc.select("div.sinfo > p").get(1).text());
else
animeListBean.setUpdateTime(doc.select("div.sinfo > p").get(0).text().isEmpty() ? Utils.getString(R.string.no_update) : doc.select("div.sinfo > p").get(0).text());
//番剧图片
bean.setImg(doc.select("div.thumb > img").attr("src"));
animeListBean.setImg(doc.select("div.thumb > img").attr("src"));
//番剧地址
bean.setUrl(url);
callback.successDesc(bean);
animeListBean.setUrl(url);
callback.successDesc(animeListBean);
//剧集列表
Elements detail = doc.select("div.movurl > ul > li");
//多季
Expand All @@ -88,6 +96,17 @@ public void onResponse(Call call, Response response) {
});
}

private void setTags(Elements elements) {
List<String> tagTitles = new ArrayList<>();
List<String> tagUrls = new ArrayList<>();
for (int i = 0, size = elements.size(); i < size; i++) {
tagTitles.add(elements.get(i).text().toUpperCase());
tagUrls.add(elements.get(i).attr("href"));
}
animeListBean.setTagTitles(tagTitles);
animeListBean.setTagUrls(tagUrls);
}

private void setPlayData(Elements els) {
List<AnimeDescDetailsBean> animeDescDetailsBeans = new ArrayList<>();
boolean select;
Expand Down
Loading

0 comments on commit ddbbe3b

Please sign in to comment.