diff --git a/app/build.gradle b/app/build.gradle index 1d3aac1..d5c865b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "my.project.sakuraproject" minSdkVersion 21 targetSdkVersion 29 - versionCode 16 - versionName "1.8.6_b" + versionCode 17 + versionName "1.8.7" ndk{abiFilters "armeabi", "armeabi-v7a", "x86"} resConfigs"zh" } diff --git a/app/src/main/java/my/project/sakuraproject/adapter/AnimeDescDetailsAdapter.java b/app/src/main/java/my/project/sakuraproject/adapter/AnimeDescDetailsAdapter.java new file mode 100644 index 0000000..f6f78a2 --- /dev/null +++ b/app/src/main/java/my/project/sakuraproject/adapter/AnimeDescDetailsAdapter.java @@ -0,0 +1,39 @@ +package my.project.sakuraproject.adapter; + +import android.content.Context; +import android.widget.Button; + +import androidx.annotation.Nullable; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; + +import java.util.List; + +import my.project.sakuraproject.R; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; + +/** + * 播放列表适配器 + */ +public class AnimeDescDetailsAdapter extends BaseQuickAdapter { + private Context context; + + public AnimeDescDetailsAdapter(Context context, @Nullable List data) { + super(R.layout.item_desc_details, data); + this.context = context; + } + + @Override + protected void convert(final BaseViewHolder helper, AnimeDescDetailsBean item) { + Button btn = helper.getView(R.id.tag_group); + helper.setText(R.id.tag_group, item.getTitle().replaceAll("第", "").replaceAll("集", "")); + if (item.isSelected()) { + helper.getView(R.id.tag_group).setBackgroundResource(R.drawable.button_selected); + btn.setTextColor(context.getResources().getColor(R.color.tabSelectedTextColor)); + } else { + helper.getView(R.id.tag_group).setBackgroundResource(R.drawable.button_default); + btn.setTextColor(context.getResources().getColor(R.color.text_color_primary)); + } + } +} diff --git a/app/src/main/java/my/project/sakuraproject/adapter/AnimeDescDramaAdapter.java b/app/src/main/java/my/project/sakuraproject/adapter/AnimeDescDramaAdapter.java new file mode 100644 index 0000000..9a7ea49 --- /dev/null +++ b/app/src/main/java/my/project/sakuraproject/adapter/AnimeDescDramaAdapter.java @@ -0,0 +1,39 @@ +package my.project.sakuraproject.adapter; + +import android.content.Context; +import android.widget.Button; + +import androidx.annotation.Nullable; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; + +import java.util.List; + +import my.project.sakuraproject.R; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; + +/** + * 展开播放列表适配器 + */ +public class AnimeDescDramaAdapter extends BaseQuickAdapter { + private Context context; + + public AnimeDescDramaAdapter(Context context, @Nullable List data) { + super(R.layout.item_desc_drama, data); + this.context = context; + } + + @Override + protected void convert(final BaseViewHolder helper, AnimeDescDetailsBean item) { + Button btn = helper.getView(R.id.tag_group); + helper.setText(R.id.tag_group, item.getTitle().replaceAll("第", "").replaceAll("集", "")); + if (item.isSelected()) { + helper.getView(R.id.tag_group).setBackgroundResource(R.drawable.button_selected); + btn.setTextColor(context.getResources().getColor(R.color.tabSelectedTextColor)); + } else { + helper.getView(R.id.tag_group).setBackgroundResource(R.drawable.button_default); + btn.setTextColor(context.getResources().getColor(R.color.text_color_primary)); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/my/project/sakuraproject/adapter/AnimeDescRecommendAdapter.java b/app/src/main/java/my/project/sakuraproject/adapter/AnimeDescRecommendAdapter.java new file mode 100644 index 0000000..fffc741 --- /dev/null +++ b/app/src/main/java/my/project/sakuraproject/adapter/AnimeDescRecommendAdapter.java @@ -0,0 +1,34 @@ +package my.project.sakuraproject.adapter; + +import android.content.Context; + +import androidx.annotation.Nullable; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; + +import java.util.List; + +import my.project.sakuraproject.R; +import my.project.sakuraproject.bean.AnimeDescRecommendBean; +import my.project.sakuraproject.util.Utils; + +/** + * 相关推荐适配器 + */ +public class AnimeDescRecommendAdapter extends BaseQuickAdapter { + private Context context; + + public AnimeDescRecommendAdapter(Context context, @Nullable List data) { + super(R.layout.item_desc_recommend, data); + this.context = context; + } + + @Override + protected void convert(final BaseViewHolder helper, AnimeDescRecommendBean item) { + Utils.setCardDefaultBg(context, helper.getView(R.id.card_view), helper.getView(R.id.title)); + helper.setText(R.id.title, item.getTitle()); + Utils.setDefaultImage(context, item.getImg(), helper.getView(R.id.img)); + Utils.setCardBg(context, item.getImg(), helper.getView(R.id.card_view), helper.getView(R.id.title)); + } +} \ No newline at end of file diff --git a/app/src/main/java/my/project/sakuraproject/adapter/DescAdapter.java b/app/src/main/java/my/project/sakuraproject/adapter/DescAdapter.java deleted file mode 100644 index b1b71e9..0000000 --- a/app/src/main/java/my/project/sakuraproject/adapter/DescAdapter.java +++ /dev/null @@ -1,79 +0,0 @@ -package my.project.sakuraproject.adapter; - -import android.content.Context; -import android.view.View; -import android.widget.Button; - -import com.chad.library.adapter.base.BaseMultiItemQuickAdapter; -import com.chad.library.adapter.base.BaseViewHolder; -import com.chad.library.adapter.base.entity.MultiItemEntity; - -import java.util.List; - -import my.project.sakuraproject.R; -import my.project.sakuraproject.bean.AnimeDescBean; -import my.project.sakuraproject.bean.AnimeHeaderBean; -import my.project.sakuraproject.config.AnimeType; -import my.project.sakuraproject.util.Utils; - -public class DescAdapter extends BaseMultiItemQuickAdapter { - private Context context; - - public DescAdapter(Context context, List data) { - super(data); - this.context = context; - addItemType(AnimeType.TYPE_LEVEL_0, R.layout.item_head); - addItemType(AnimeType.TYPE_LEVEL_1, R.layout.item_btn); - addItemType(AnimeType.TYPE_LEVEL_2, R.layout.item_favorite); - addItemType(AnimeType.TYPE_LEVEL_3, R.layout.item_favorite); - } - - @Override - protected void convert(final BaseViewHolder helper, MultiItemEntity item) { - switch (helper.getItemViewType()) { - case AnimeType.TYPE_LEVEL_0: - final AnimeHeaderBean mainHeaderBean = (AnimeHeaderBean) item; - helper.itemView.setVisibility(View.VISIBLE); - helper.setText(R.id.header, mainHeaderBean.getTitle()).setImageResource(R.id.arrow, mainHeaderBean.isExpanded() ? R.drawable.ic_keyboard_arrow_down_white_48dp : R.drawable.baseline_keyboard_arrow_right_white_48dp); - helper.itemView.setOnClickListener(v -> { - int pos = helper.getAdapterPosition(); - if (mainHeaderBean.isExpanded()) { - collapse(pos); - } else { - expand(pos); - } - }); - break; - case AnimeType.TYPE_LEVEL_1: - final AnimeDescBean animeDescBean = (AnimeDescBean) item; - String title = animeDescBean.getTitle(); - Button btn = helper.getView(R.id.tag_group); - if (animeDescBean.getType().equals("play")) - helper.setText(R.id.tag_group, title.replaceAll("第", "").replaceAll("集", "")); - else - helper.setText(R.id.tag_group, title); - if (animeDescBean.isSelect()) { - helper.getView(R.id.tag_group).setBackgroundResource(R.drawable.button_selected); - btn.setTextColor(context.getResources().getColor(R.color.item_selected_color)); - }else { - helper.getView(R.id.tag_group).setBackgroundResource(R.drawable.button_default); - btn.setTextColor(context.getResources().getColor(R.color.text_color_primary)); - } - break; - case AnimeType.TYPE_LEVEL_2: - Utils.setCardDefaultBg(context, helper.getView(R.id.card_view), helper.getView(R.id.title)); - final AnimeDescBean bean = (AnimeDescBean) item; - helper.setText(R.id.title, bean.getTitle()); - Utils.setDefaultImage(context, bean.getImg(), helper.getView(R.id.img)); - Utils.setCardBg(context, bean.getImg(), helper.getView(R.id.card_view), helper.getView(R.id.title)); - break; - case AnimeType.TYPE_LEVEL_3: - Utils.setCardDefaultBg(context, helper.getView(R.id.card_view), helper.getView(R.id.title)); - final AnimeDescBean ova = (AnimeDescBean) item; - helper.setText(R.id.title, ova.getTitle()); - Utils.setDefaultImage(context, ova.getImg(), helper.getView(R.id.img)); - Utils.setCardBg(context, ova.getImg(), helper.getView(R.id.card_view), helper.getView(R.id.title)); - break; - } - } -} diff --git a/app/src/main/java/my/project/sakuraproject/adapter/DramaAdapter.java b/app/src/main/java/my/project/sakuraproject/adapter/DramaAdapter.java index cab3ce9..53ad3ec 100644 --- a/app/src/main/java/my/project/sakuraproject/adapter/DramaAdapter.java +++ b/app/src/main/java/my/project/sakuraproject/adapter/DramaAdapter.java @@ -11,22 +11,21 @@ import java.util.List; import my.project.sakuraproject.R; -import my.project.sakuraproject.bean.AnimeDescBean; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; -public class DramaAdapter extends BaseQuickAdapter { +public class DramaAdapter extends BaseQuickAdapter { private Context context; - public DramaAdapter(Context context, @Nullable List data) { + public DramaAdapter(Context context, @Nullable List data) { super(R.layout.item_btn, data); this.context = context; } @Override - protected void convert(final BaseViewHolder helper, AnimeDescBean item) { - String title = item.getTitle(); + protected void convert(final BaseViewHolder helper, AnimeDescDetailsBean item) { Button btn = helper.getView(R.id.tag_group); - helper.setText(R.id.tag_group, title.replaceAll("第", "").replaceAll("集", "")); - if (item.isSelect()) { + helper.setText(R.id.tag_group, item.getTitle().replaceAll("第", "").replaceAll("集", "")); + if (item.isSelected()) { helper.getView(R.id.tag_group).setBackgroundResource(R.drawable.button_selected); btn.setTextColor(context.getResources().getColor(R.color.item_selected_color)); } 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 e787dd0..04ad762 100644 --- a/app/src/main/java/my/project/sakuraproject/application/Sakura.java +++ b/app/src/main/java/my/project/sakuraproject/application/Sakura.java @@ -2,6 +2,7 @@ import android.app.Activity; import android.app.Application; +import android.view.View; import android.widget.Toast; import androidx.annotation.ColorRes; @@ -9,6 +10,7 @@ import androidx.appcompat.app.AppCompatDelegate; import com.bumptech.glide.Glide; +import com.google.android.material.snackbar.Snackbar; import com.tencent.smtt.sdk.QbSdk; import org.json.JSONObject; @@ -109,6 +111,14 @@ public void showCustomToastMsg(String msg, @DrawableRes int iconRes, @ColorRes i iconRes, color, Toast.LENGTH_LONG, true, true).show(); } + public void showSnackbarMsgAction(View view, String msg, String actionMsg, View.OnClickListener listener) { + Snackbar.make(view, msg, Snackbar.LENGTH_LONG).setAction(actionMsg, listener).show(); + } + + public void showSnackbarMsg(View view, String msg) { + Snackbar.make(view, msg, Snackbar.LENGTH_LONG).show(); + } + public void addActivity(Activity activity) { if (!oList.contains(activity)) { oList.add(activity); diff --git a/app/src/main/java/my/project/sakuraproject/bean/AnimeDescBean.java b/app/src/main/java/my/project/sakuraproject/bean/AnimeDescBean.java deleted file mode 100644 index 2fc7a76..0000000 --- a/app/src/main/java/my/project/sakuraproject/bean/AnimeDescBean.java +++ /dev/null @@ -1,105 +0,0 @@ -package my.project.sakuraproject.bean; - -import com.chad.library.adapter.base.entity.MultiItemEntity; - -import java.io.Serializable; - -public class AnimeDescBean implements MultiItemEntity, Serializable { - //布局TYPE - private int typeLevel; - //标题 - private String title; - //地址 - private String url; - //type - private String type; - //是否能被选中 - private boolean select; - //图片地址 - private String img; - - /** - * 按钮 - * - * @param typeLevel - * @param select - * @param title - * @param url - * @param type - */ - public AnimeDescBean(int typeLevel, boolean select, String title, String url, String type) { - this.typeLevel = typeLevel; - this.select = select; - this.title = title; - this.url = url; - this.type = type; - } - - /** - * 推荐 - * - * @param typeLevel - * @param title - * @param url - */ - public AnimeDescBean(int typeLevel, String title, String url, String img, String type) { - this.typeLevel = typeLevel; - this.title = title; - this.url = url; - this.img = img; - this.type = type; - } - - public int getTypeLevel() { - return typeLevel; - } - - public void setTypeLevel(int typeLevel) { - this.typeLevel = typeLevel; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public boolean isSelect() { - return select; - } - - public void setSelect(boolean select) { - this.select = select; - } - - public String getImg() { - return img; - } - - public void setImg(String img) { - this.img = img; - } - - @Override - public int getItemType() { - return typeLevel; - } -} diff --git a/app/src/main/java/my/project/sakuraproject/bean/AnimeDescDetailsBean.java b/app/src/main/java/my/project/sakuraproject/bean/AnimeDescDetailsBean.java new file mode 100644 index 0000000..f14c0cf --- /dev/null +++ b/app/src/main/java/my/project/sakuraproject/bean/AnimeDescDetailsBean.java @@ -0,0 +1,42 @@ +package my.project.sakuraproject.bean; + +import java.io.Serializable; + +public class AnimeDescDetailsBean implements Serializable { + // 标题 + private String title; + // 链接 + private String url; + // 是否选中 + private boolean selected; + + public AnimeDescDetailsBean(String title, String url, boolean selected) { + this.title = title; + this.url = url; + this.selected = selected; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public boolean isSelected() { + return selected; + } + + public void setSelected(boolean selected) { + this.selected = selected; + } +} diff --git a/app/src/main/java/my/project/sakuraproject/bean/AnimeDescListBean.java b/app/src/main/java/my/project/sakuraproject/bean/AnimeDescListBean.java new file mode 100644 index 0000000..8dcc84f --- /dev/null +++ b/app/src/main/java/my/project/sakuraproject/bean/AnimeDescListBean.java @@ -0,0 +1,38 @@ +package my.project.sakuraproject.bean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class AnimeDescListBean implements Serializable { + // 播放列表集合 + private List animeDescDetailsBeans = new ArrayList<>(); + // 番剧多季集合 + private List animeDescMultiBeans = new ArrayList<>(); + // 番剧推荐集合 + private List animeDescRecommendBeans = new ArrayList<>(); + + public List getAnimeDescDetailsBeans() { + return animeDescDetailsBeans; + } + + public void setAnimeDescDetailsBeans(List animeDescDetailsBeans) { + this.animeDescDetailsBeans = animeDescDetailsBeans; + } + + public List getAnimeDescMultiBeans() { + return animeDescMultiBeans; + } + + public void setAnimeDescMultiBeans(List animeDescMultiBeans) { + this.animeDescMultiBeans = animeDescMultiBeans; + } + + public List getAnimeDescRecommendBeans() { + return animeDescRecommendBeans; + } + + public void setAnimeDescRecommendBeans(List animeDescRecommendBeans) { + this.animeDescRecommendBeans = animeDescRecommendBeans; + } +} diff --git a/app/src/main/java/my/project/sakuraproject/bean/AnimeDescRecommendBean.java b/app/src/main/java/my/project/sakuraproject/bean/AnimeDescRecommendBean.java new file mode 100644 index 0000000..8ac6409 --- /dev/null +++ b/app/src/main/java/my/project/sakuraproject/bean/AnimeDescRecommendBean.java @@ -0,0 +1,39 @@ +package my.project.sakuraproject.bean; +public class AnimeDescRecommendBean { + // 标题 + private String title; + // 图片 + private String img; + // 链接 + private String url; + + public AnimeDescRecommendBean(String title, String img, String url) { + this.title = title; + this.img = img; + this.url = url; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getImg() { + return img; + } + + public void setImg(String img) { + this.img = img; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/app/src/main/java/my/project/sakuraproject/bean/AnimeHeaderBean.java b/app/src/main/java/my/project/sakuraproject/bean/AnimeHeaderBean.java deleted file mode 100644 index 4501fa6..0000000 --- a/app/src/main/java/my/project/sakuraproject/bean/AnimeHeaderBean.java +++ /dev/null @@ -1,36 +0,0 @@ -package my.project.sakuraproject.bean; - -import com.chad.library.adapter.base.entity.AbstractExpandableItem; -import com.chad.library.adapter.base.entity.MultiItemEntity; - -import java.io.Serializable; - -import my.project.sakuraproject.config.AnimeType; - -public class AnimeHeaderBean extends AbstractExpandableItem implements MultiItemEntity, Serializable { - private String title; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public AnimeHeaderBean(String title) { - this.title = title; - } - - public AnimeHeaderBean() {} - - @Override - public int getLevel() { - return AnimeType.TYPE_LEVEL_0; - } - - @Override - public int getItemType() { - return AnimeType.TYPE_LEVEL_0; - } -} diff --git a/app/src/main/java/my/project/sakuraproject/config/AnimeType.java b/app/src/main/java/my/project/sakuraproject/config/AnimeType.java deleted file mode 100644 index fae35fa..0000000 --- a/app/src/main/java/my/project/sakuraproject/config/AnimeType.java +++ /dev/null @@ -1,12 +0,0 @@ -package my.project.sakuraproject.config; - -public class AnimeType { - //tile - public final static int TYPE_LEVEL_0 = 0; - //按钮 - public final static int TYPE_LEVEL_1 = 1; - //推荐 - public final static int TYPE_LEVEL_2 = 2; - //番剧相关 - public final static int TYPE_LEVEL_3 = 3; -} diff --git a/app/src/main/java/my/project/sakuraproject/custom/MySwipeRefreshLayout.java b/app/src/main/java/my/project/sakuraproject/custom/MySwipeRefreshLayout.java new file mode 100644 index 0000000..29755c3 --- /dev/null +++ b/app/src/main/java/my/project/sakuraproject/custom/MySwipeRefreshLayout.java @@ -0,0 +1,47 @@ +package my.project.sakuraproject.custom; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.ViewConfiguration; + +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +public class MySwipeRefreshLayout extends SwipeRefreshLayout { + private float startX; + private float startY; + private float mTouchSlop; + + public MySwipeRefreshLayout(Context context) { + super(context); + + mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); + } + + public MySwipeRefreshLayout(Context context, AttributeSet attrs) { + super(context, attrs); + + mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + + switch (ev.getAction()){ + case MotionEvent.ACTION_DOWN: + startX = ev.getX(); + startY = ev.getY(); + break; + case MotionEvent.ACTION_MOVE: + float distanceX = Math.abs(ev.getX() - startX); + float distanceY = Math.abs(ev.getY() - startY); + if(distanceX > mTouchSlop && distanceX > distanceY){ //判断为横向滑动 + return false; + } + + break; + } + + return super.onInterceptTouchEvent(ev); + } +} 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 fd5442c..aedb56e 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 @@ -11,11 +11,12 @@ import android.view.MenuItem; import android.view.View; import android.widget.LinearLayout; +import android.widget.RelativeLayout; import android.widget.TextView; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.Toolbar; -import androidx.cardview.widget.CardView; +import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -51,8 +52,6 @@ public class AboutActivity extends BaseActivity { Toolbar toolbar; @BindView(R.id.cache) TextView cache; - @BindView(R.id.open_source) - TextView open_source; @BindView(R.id.version) TextView version; private ProgressDialog p; @@ -60,6 +59,8 @@ public class AboutActivity extends BaseActivity { private Call downCall; @BindView(R.id.footer) LinearLayout footer; + @BindView(R.id.show) + CoordinatorLayout show; @Override protected Presenter createPresenter() { @@ -97,34 +98,36 @@ public void initToolbar() { private void initViews() { LinearLayout.LayoutParams Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, Utils.getNavigationBarHeight(this)); footer.findViewById(R.id.footer).setLayoutParams(Params); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) show.getLayoutParams(); + params.setMargins(0, 0, 0, Utils.getNavigationBarHeight(this) - 5); + show.setLayoutParams(params); version.setText(Utils.getASVersionName()); cache.setText(Environment.getExternalStorageDirectory() + Utils.getString(R.string.cache_text)); - open_source.setOnClickListener(v -> { - if (Utils.isFastClick()) - startActivity(new Intent(AboutActivity.this, OpenSourceActivity.class)); - }); } - @OnClick({R.id.sakura,R.id.github}) - public void openBrowser(CardView cardView) { - switch (cardView.getId()) { + @OnClick({R.id.sakura,R.id.github, R.id.check_update}) + public void openBrowser(RelativeLayout relativeLayout) { + switch (relativeLayout.getId()) { case R.id.sakura: Utils.viewInChrome(this, Sakura.DOMAIN); break; case R.id.github: Utils.viewInChrome(this, Utils.getString(R.string.github_url)); break; + case R.id.check_update: + if (Utils.isFastClick()) checkUpdate(); + break; } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.about_menu, menu); - MenuItem checkUpdateItem = menu.findItem(R.id.check_update); MenuItem updateLogItem = menu.findItem(R.id.update_log); + MenuItem openSourceItem = menu.findItem(R.id.open_source); if (!(Boolean) SharedPreferencesUtils.getParam(this, "darkTheme", false)) { - checkUpdateItem.setIcon(R.drawable.baseline_update_black_48dp); - updateLogItem.setIcon(R.drawable.baseline_log_black_48dp); + updateLogItem.setIcon(R.drawable.baseline_insert_chart_outlined_black_48dp); + openSourceItem.setIcon(R.drawable.baseline_all_inclusive_black_48dp); } return true; } @@ -135,8 +138,8 @@ public boolean onOptionsItemSelected(MenuItem item) { case R.id.update_log: showUpdateLogs(); break; - case R.id.check_update: - if (Utils.isFastClick()) checkUpdate(); + case R.id.open_source: + if (Utils.isFastClick()) startActivity(new Intent(AboutActivity.this,OpenSourceActivity.class)); break; } return super.onOptionsItemSelected(item); @@ -165,6 +168,7 @@ public void showUpdateLogs() { public List createUpdateLogList() { List logsList = new ArrayList(); + logsList.add(new LogBean("版本:1.8.7","部分界面UI改动\n修复番剧详情界面显示问题")); logsList.add(new LogBean("版本:1.8.6_b","修复内置播放器播放完毕后程序崩溃的问题")); logsList.add(new LogBean("版本:1.8.6_a","修复内置播放器使用Exo内核无限加载的问题")); logsList.add(new LogBean("版本:1.8.6","修复一些错误\n修复内置视频播放器存在的一些问题")); @@ -192,7 +196,7 @@ public void checkUpdate() { public void onFailure(Call call, IOException e) { runOnUiThread(() -> { Utils.cancelProDialog(p); - application.showErrorToastMsg( Utils.getString(R.string.ck_network_error)); + application.showSnackbarMsgAction(show, Utils.getString(R.string.ck_network_error_start), Utils.getString(R.string.try_again), v -> checkUpdate()); }); } @@ -205,7 +209,7 @@ public void onResponse(Call call, Response response) throws IOException { if (newVersion.equals(Utils.getASVersionName())) runOnUiThread(() -> { Utils.cancelProDialog(p); - application.showSuccessToastMsg(Utils.getString(R.string.no_new_version)); + application.showSnackbarMsg(show, Utils.getString(R.string.no_new_version)); }); else { downloadUrl = obj.getJSONArray("assets").getJSONObject(0).getString("browser_download_url"); @@ -215,19 +219,9 @@ public void onResponse(Call call, Response response) throws IOException { Utils.findNewVersion(AboutActivity.this, newVersion, body, - (dialog, which) -> { - p = Utils.showProgressDialog(AboutActivity.this); - p.setButton(ProgressDialog.BUTTON_NEGATIVE, Utils.getString(R.string.cancel), (dialog1, which1) -> { - if (null != downCall) - downCall.cancel(); - dialog1.dismiss(); - }); - p.show(); - downNewVersion(downloadUrl); - }, - (dialog, which) -> { - dialog.dismiss(); - }); + (dialog, which) -> download(), + (dialog, which) -> dialog.dismiss() + ); }); } } catch (JSONException e) { @@ -237,6 +231,17 @@ public void onResponse(Call call, Response response) throws IOException { }), 1000); } + public void download() { + p = Utils.showProgressDialog(AboutActivity.this); + p.setButton(ProgressDialog.BUTTON_NEGATIVE, Utils.getString(R.string.page_negative), (dialog1, which1) -> { + if (null != downCall) + downCall.cancel(); + dialog1.dismiss(); + }); + p.show(); + downNewVersion(downloadUrl); + } + /** * 下载apk * @@ -261,7 +266,7 @@ public void onDownloading(final int progress) { public void onDownloadFailed() { runOnUiThread(() -> { Utils.cancelProDialog(p); - application.showErrorToastMsg(Utils.getString(R.string.download_error)); + application.showSnackbarMsgAction(show, Utils.getString(R.string.download_error), Utils.getString(R.string.try_again), v -> download()); }); } }); diff --git a/app/src/main/java/my/project/sakuraproject/main/about/OpenSourceActivity.java b/app/src/main/java/my/project/sakuraproject/main/about/OpenSourceActivity.java index 0983fdc..4e75bfe 100644 --- a/app/src/main/java/my/project/sakuraproject/main/about/OpenSourceActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/about/OpenSourceActivity.java @@ -72,7 +72,7 @@ public void initSwipe() { public void initList() { list.add(new SourceBean("jsoup", "jhy", "jsoup: Java HTML Parser, with best of DOM, CSS, and jquery", "https://github.com/jhy/jsoup")); - list.add(new SourceBean("BaseRecyclerViewAdapterHelper", "CymChad", "BRVAH:Powerful and flexible RecyclerAdapter", "https://github.com/CymChad/BaseRecyclerViewAdapterHelper")); + list.add(new SourceBean("BaseRecyclerView\nAdapterHelper", "CymChad", "BRVAH:Powerful and flexible RecyclerAdapter", "https://github.com/CymChad/BaseRecyclerViewAdapterHelper")); list.add(new SourceBean("Glide", "bumptech", "An image loading and caching library for Android focused on smooth scrolling", "https://github.com/bumptech/glide")); list.add(new SourceBean("EasyPermissions", "googlesamples", "Simplify Android M system permissions", "https://github.com/googlesamples/easypermissions")); list.add(new SourceBean("MaterialEditText", "rengwuxian", "EditText in Material Design", "https://github.com/rengwuxian/MaterialEditText")); 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 2f4dd0e..ddbb716 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 @@ -5,18 +5,22 @@ import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; -import android.os.Handler; import android.util.Patterns; +import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatTextView; import androidx.appcompat.widget.Toolbar; +import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -26,10 +30,10 @@ import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.transition.Transition; import com.chad.library.adapter.base.BaseQuickAdapter; -import com.chad.library.adapter.base.entity.MultiItemEntity; import com.fanchen.sniffing.SniffingUICallback; import com.fanchen.sniffing.SniffingVideo; import com.fanchen.sniffing.web.SniffingUtil; +import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.r0adkll.slidr.Slidr; @@ -37,14 +41,18 @@ import java.util.List; import butterknife.BindView; +import butterknife.OnClick; import jp.wasabeef.blurry.Blurry; import my.project.sakuraproject.R; -import my.project.sakuraproject.adapter.DescAdapter; +import my.project.sakuraproject.adapter.AnimeDescDetailsAdapter; +import my.project.sakuraproject.adapter.AnimeDescDramaAdapter; +import my.project.sakuraproject.adapter.AnimeDescRecommendAdapter; import my.project.sakuraproject.api.Api; import my.project.sakuraproject.application.Sakura; -import my.project.sakuraproject.bean.AnimeDescBean; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; +import my.project.sakuraproject.bean.AnimeDescListBean; +import my.project.sakuraproject.bean.AnimeDescRecommendBean; import my.project.sakuraproject.bean.AnimeListBean; -import my.project.sakuraproject.config.AnimeType; import my.project.sakuraproject.database.DatabaseUtil; import my.project.sakuraproject.main.base.BaseActivity; import my.project.sakuraproject.main.video.VideoContract; @@ -58,17 +66,12 @@ public class DescActivity extends BaseActivity implements DescContract.View, VideoContract.View, SniffingUICallback { @BindView(R.id.toolbar) Toolbar toolbar; - @BindView(R.id.rv_list) - RecyclerView mRecyclerView; @BindView(R.id.anime_img) ImageView animeImg; @BindView(R.id.desc) AppCompatTextView desc; - private DescAdapter adapter; @BindView(R.id.mSwipe) SwipeRefreshLayout mSwipe; - private List multiItemList = new ArrayList<>(); - private List drama = new ArrayList<>(); @BindView(R.id.title_img) ImageView imageView; private String diliUrl, dramaUrl; @@ -82,8 +85,34 @@ public class DescActivity extends BaseActivity private AnimeListBean animeListBean = new AnimeListBean(); private List animeUrlList = new ArrayList(); private boolean mIsLoad = false; - //播放网址 - private String webUrl; + @BindView(R.id.details_list) + RecyclerView detailsRv; + @BindView(R.id.multi_list) + RecyclerView multiRv; + @BindView(R.id.recommend_list) + RecyclerView recommendRv; + @BindView(R.id.error_bg) + RelativeLayout errorBg; + @BindView(R.id.open_drama) + RelativeLayout openDrama; + @BindView(R.id.play_layout) + LinearLayout playLinearLayout; + @BindView(R.id.multi_layout) + LinearLayout multiLinearLayout; + @BindView(R.id.recommend_layout) + LinearLayout recommendLinearLayout; + @BindView(R.id.error_msg) + TextView error_msg; + @BindView(R.id.msg) + CoordinatorLayout msg; + private RecyclerView lineRecyclerView; + private AnimeDescDetailsAdapter animeDescDetailsAdapter; + private AnimeDescRecommendAdapter animeDescRecommendAdapter; + private AnimeDescRecommendAdapter animeDescMultiAdapter; + private AnimeDescListBean animeDescListBean = new AnimeDescListBean(); + private ImageView closeDrama; + private BottomSheetDialog mBottomSheetDialog; + private AnimeDescDramaAdapter animeDescDramaAdapter; @Override protected DescPresenter createPresenter() { @@ -105,6 +134,9 @@ protected void init() { StatusBarUtil.setColorForSwipeBack(this, getResources().getColor(R.color.colorPrimaryDark), 0); StatusBarUtil.setTranslucentForImageView(this, 0, toolbar); Slidr.attach(this, Utils.defaultInit()); + CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) msg.getLayoutParams(); + params.setMargins(0, 0, 0, Utils.getNavigationBarHeight(this) - 5); + msg.setLayoutParams(params); getBundle(); initToolbar(); initFab(); @@ -142,8 +174,6 @@ public void initFab() { public void initSwipe() { mSwipe.setColorSchemeResources(R.color.pink500, R.color.blue500, R.color.purple500); mSwipe.setOnRefreshListener(() -> { - multiItemList.clear(); - adapter.setNewData(multiItemList); mPresenter.loadData(true); }); mSwipe.setRefreshing(true); @@ -151,40 +181,66 @@ public void initSwipe() { @SuppressLint("RestrictedApi") public void initAdapter() { - adapter = new DescAdapter(this, multiItemList); - adapter.openLoadAnimation(); - adapter.setOnItemClickListener((adapter, view, position) -> { + animeDescDetailsAdapter = new AnimeDescDetailsAdapter(this, animeDescListBean.getAnimeDescDetailsBeans()); + animeDescDetailsAdapter.setOnItemClickListener((adapter, view, position) -> { if (!Utils.isFastClick()) return; - final AnimeDescBean bean = (AnimeDescBean) adapter.getItem(position); - switch (bean.getType()) { - case "play": - p = Utils.getProDialog(DescActivity.this, R.string.parsing); - Button v = (Button) adapter.getViewByPosition(mRecyclerView, position, R.id.tag_group); - v.setBackgroundResource(R.drawable.button_selected); - v.setTextColor(getResources().getColor(R.color.item_selected_color)); - bean.setSelect(true); - dramaUrl = VideoUtils.getUrl(bean.getUrl()); - witchTitle = animeTitle + " - " + bean.getTitle(); - videoPresenter = new VideoPresenter(animeListBean.getTitle(), dramaUrl, DescActivity.this); - videoPresenter.loadData(true); - break; - case "multi": - animeTitle = bean.getTitle(); - diliUrl = VideoUtils.getUrl(bean.getUrl()); - animeUrlList.add(diliUrl); - openAnimeDesc(); - break; - case "recommend": - animeTitle = bean.getTitle(); - diliUrl = VideoUtils.getUrl(bean.getUrl()); - animeUrlList.add(diliUrl); - openAnimeDesc(); - break; - } + AnimeDescDetailsBean bean = (AnimeDescDetailsBean) adapter.getItem(position); + playVideo(adapter, position, bean, detailsRv); + }); + detailsRv.setLayoutManager(getLinearLayoutManager()); + detailsRv.setAdapter(animeDescDetailsAdapter); + detailsRv.setNestedScrollingEnabled(false); + + animeDescMultiAdapter = new AnimeDescRecommendAdapter(this, animeDescListBean.getAnimeDescMultiBeans()); + animeDescMultiAdapter.setOnItemClickListener((adapter, view, position) -> { + AnimeDescRecommendBean bean = (AnimeDescRecommendBean) adapter.getItem(position); + animeTitle = bean.getTitle(); + diliUrl = VideoUtils.getUrl(bean.getUrl()); + animeUrlList.add(diliUrl); + openAnimeDesc(); + }); + multiRv.setLayoutManager(getLinearLayoutManager()); + multiRv.setAdapter(animeDescMultiAdapter); + multiRv.setNestedScrollingEnabled(false); + + animeDescRecommendAdapter = new AnimeDescRecommendAdapter(this, animeDescListBean.getAnimeDescRecommendBeans()); + animeDescRecommendAdapter.setOnItemClickListener((adapter, view, position) -> { + AnimeDescRecommendBean bean = (AnimeDescRecommendBean) adapter.getItem(position); + animeTitle = bean.getTitle(); + diliUrl = VideoUtils.getUrl(bean.getUrl()); + animeUrlList.add(diliUrl); + openAnimeDesc(); + }); + recommendRv.setLayoutManager(getLinearLayoutManager()); + recommendRv.setAdapter(animeDescRecommendAdapter); + recommendRv.setNestedScrollingEnabled(false); + + View dramaView = LayoutInflater.from(this).inflate(R.layout.dialog_drama, null); + lineRecyclerView = dramaView.findViewById(R.id.drama_list); + lineRecyclerView.setLayoutManager(new GridLayoutManager(this, 5)); + animeDescDramaAdapter = new AnimeDescDramaAdapter(this, animeDescListBean.getAnimeDescDetailsBeans()); + animeDescDramaAdapter.setOnItemClickListener((adapter, view, position) -> { + if (!Utils.isFastClick()) return; + mBottomSheetDialog.dismiss(); + AnimeDescDetailsBean bean = (AnimeDescDetailsBean) adapter.getItem(position); + playVideo(adapter, position, bean, lineRecyclerView); }); - if (Utils.checkHasNavigationBar(this)) mRecyclerView.setPadding(0,0,0, Utils.getNavigationBarHeight(this) - 5); - mRecyclerView.setAdapter(adapter); - adapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN); + lineRecyclerView.setAdapter(animeDescDramaAdapter); + mBottomSheetDialog = new BottomSheetDialog(this); + mBottomSheetDialog.setContentView(dramaView); + closeDrama = dramaView.findViewById(R.id.close_drama); + closeDrama.setOnClickListener(v-> mBottomSheetDialog.dismiss()); + } + + private LinearLayoutManager getLinearLayoutManager() { + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); + linearLayoutManager.setOrientation(RecyclerView.HORIZONTAL); + return linearLayoutManager; + } + + @OnClick(R.id.open_drama) + public void dramaClick() { + if (!mBottomSheetDialog.isShowing()) mBottomSheetDialog.show(); } @SuppressLint("RestrictedApi") @@ -194,71 +250,54 @@ public void openAnimeDesc() { desc.setText(""); mSwipe.setRefreshing(true); imageView.setImageDrawable(null); - animeListBean = new AnimeListBean(); + animeDescListBean = new AnimeDescListBean(); favorite.setVisibility(View.GONE); mPresenter = new DescPresenter(diliUrl, this); - multiItemList.clear(); - adapter.setNewData(multiItemList); mPresenter.loadData(true); } - public void goToPlay(List list) { - new Handler().postDelayed(() -> { - if (list.size() == 1) oneSource(list); - else multipleSource(list); - }, 200); - } - - /** - * 只有一个播放地址 - * - * @param list - */ - private void oneSource(List list) { - playAnime(VideoUtils.getVideoUrl(list.get(0))); + public void playVideo(BaseQuickAdapter adapter, int position, AnimeDescDetailsBean bean, RecyclerView recyclerView) { + p = Utils.getProDialog(DescActivity.this, R.string.parsing); + Button v = (Button) adapter.getViewByPosition(recyclerView, position, R.id.tag_group); + v.setBackgroundResource(R.drawable.button_selected); + v.setTextColor(getResources().getColor(R.color.item_selected_color)); + bean.setSelected(true); + dramaUrl = VideoUtils.getUrl(bean.getUrl()); + witchTitle = animeTitle + " - " + bean.getTitle(); + animeDescDetailsAdapter.notifyDataSetChanged(); + animeDescDramaAdapter.notifyDataSetChanged(); + videoPresenter = new VideoPresenter(animeTitle, dramaUrl, DescActivity.this); + videoPresenter.loadData(true); } /** - * 多个播放地址 + * 播放视频 * - * @param list + * @param animeUrl */ - private void multipleSource(List list) { - VideoUtils.showMultipleVideoSources(this, - list, - (dialog, index) -> - playAnime(VideoUtils.getVideoUrl(list.get(index))), (dialog, which) -> { - cancelDialog(); - dialog.dismiss(); - }, 0 - ); - } - private void playAnime(String animeUrl) { if (Patterns.WEB_URL.matcher(animeUrl.replace(" ", "")).matches()) { if (animeUrl.contains("jx.618g.com")) { cancelDialog(); - animeUrl = animeUrl.replaceAll("http://jx.618g.com/\\?url=", ""); - VideoUtils.openWebview(true, this, witchTitle, animeTitle, animeUrl, diliUrl, drama); + VideoUtils.openWebview(false, this, witchTitle, animeTitle, animeUrl.replaceAll("http://jx.618g.com/\\?url=", ""), diliUrl, animeDescListBean.getAnimeDescDetailsBeans()); } else if (animeUrl.contains(".mp4") || animeUrl.contains(".m3u8")) { cancelDialog(); switch ((Integer) SharedPreferencesUtils.getParam(getApplicationContext(), "player", 0)) { case 0: //调用播放器 - VideoUtils.openPlayer(true, this, witchTitle, animeUrl, animeTitle, diliUrl, drama); + VideoUtils.openPlayer(true, this, witchTitle, animeUrl, animeTitle, diliUrl, animeDescListBean.getAnimeDescDetailsBeans()); break; case 1: Utils.selectVideoPlayer(this, animeUrl); break; } - } else { - webUrl = animeUrl; - Sakura.getInstance().showToastMsg(Utils.getString(R.string.should_be_used_web)); - SniffingUtil.get().activity(this).referer(webUrl).callback(this).url(webUrl).start(); + }else { + application.showToastMsg(Utils.getString(R.string.should_be_used_web)); + SniffingUtil.get().activity(this).referer(animeUrl).callback(this).url(animeUrl).start(); } - } else { - webUrl = String.format(Api.PARSE_API, animeUrl); - Sakura.getInstance().showToastMsg(Utils.getString(R.string.maybe_can_not_play)); + } else { + String webUrl = String.format(Api.PARSE_API, animeUrl); + application.showToastMsg(Utils.getString(R.string.should_be_used_web)); SniffingUtil.get().activity(this).referer(webUrl).callback(this).url(webUrl).start(); } } @@ -268,8 +307,6 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 0x10 && resultCode == 0x20) { mSwipe.setRefreshing(true); - multiItemList = new ArrayList<>(); - adapter.notifyDataSetChanged(); mPresenter.loadData(true); } } @@ -291,12 +328,10 @@ public void favoriteAnime() { isFavorite = DatabaseUtil.favorite(animeListBean); if (isFavorite) { Glide.with(DescActivity.this).load(R.drawable.baseline_favorite_white_48dp).into(favorite); - application.showCustomToastMsg(Utils.getString(R.string.join_ok), - R.drawable.ic_add_favorite_48dp, R.color.green300); + application.showSnackbarMsg(msg, Utils.getString(R.string.join_ok)); } else { Glide.with(DescActivity.this).load(R.drawable.baseline_favorite_border_white_48dp).into(favorite); - application.showCustomToastMsg(Utils.getString(R.string.join_error), - R.drawable.ic_remove_favorite_48dp, R.color.red300); + application.showSnackbarMsg(msg, Utils.getString(R.string.join_error)); } } @@ -321,6 +356,9 @@ public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition list) { - runOnUiThread(() -> { - if (!mActivityFinish) { - mIsLoad = false; - final GridLayoutManager manager = new GridLayoutManager(DescActivity.this, 15); - manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { - @Override - public int getSpanSize(int position) { - int index = 0; - switch (adapter.getItemViewType(position)) { - case AnimeType.TYPE_LEVEL_0: - index = manager.getSpanCount(); - break; - case AnimeType.TYPE_LEVEL_1: - index = 3; - break; - case AnimeType.TYPE_LEVEL_2: - index = 5; - break; - case AnimeType.TYPE_LEVEL_3: - index = 5; - break; - } - return index; - } - }); - // important! setLayoutManager should be called after setAdapter - mRecyclerView.setLayoutManager(manager); - multiItemList = list; - mSwipe.setRefreshing(false); - setCollapsingToolbar(); - adapter.setNewData(multiItemList); - adapter.expand(0); - } - }); + playLinearLayout.setVisibility(View.GONE); + multiLinearLayout.setVisibility(View.GONE); + recommendLinearLayout.setVisibility(View.GONE); + errorBg.setVisibility(View.GONE); } @Override @@ -397,6 +402,34 @@ public boolean onCreateOptionsMenu(Menu menu) { return true; } + @Override + public void showSuccessMainView(AnimeDescListBean bean) { + runOnUiThread(() -> { + if (!mActivityFinish) { + mIsLoad = false; + setCollapsingToolbar(); + mSwipe.setRefreshing(false); + this.animeDescListBean = bean; + animeDescDetailsAdapter.setNewData(bean.getAnimeDescDetailsBeans()); + if (bean.getAnimeDescMultiBeans().size() > 0) + multiLinearLayout.setVisibility(View.VISIBLE); + else + multiLinearLayout.setVisibility(View.GONE); + animeDescMultiAdapter.setNewData(bean.getAnimeDescMultiBeans()); + animeDescRecommendAdapter.setNewData(bean.getAnimeDescRecommendBeans()); + if (bean.getAnimeDescDetailsBeans().size() > 4) + openDrama.setVisibility(View.VISIBLE); + else + openDrama.setVisibility(View.GONE); + animeDescDramaAdapter.setNewData(bean.getAnimeDescDetailsBeans()); + playLinearLayout.setVisibility(View.VISIBLE); + recommendLinearLayout.setVisibility(View.VISIBLE); + } + }); + } + + + @Override public void showSuccessDescView(AnimeListBean bean) { animeListBean = bean; @@ -435,12 +468,25 @@ public void cancelDialog() { @Override public void getVideoSuccess(List list) { - runOnUiThread(() -> goToPlay(list)); + runOnUiThread(() -> { + if (list.size() == 1) + playAnime(list.get(0)); + else + VideoUtils.showMultipleVideoSources(this, + list, + (dialog, index) -> playAnime(list.get(index)), (dialog, which) -> { + cancelDialog(); + dialog.dismiss(); + }, 1); + }); } @Override public void getVideoEmpty() { - runOnUiThread(() -> VideoUtils.showErrorInfo(DescActivity.this, dramaUrl)); + runOnUiThread(() -> { + application.showToastMsg(Utils.getString(R.string.open_web_view)); + VideoUtils.openDefaultWebview(this, dramaUrl); + }); } @Override @@ -449,8 +495,8 @@ public void getVideoError() { } @Override - public void showSuccessDramaView(List list) { - drama = list; + public void showSuccessDramaView(List list) { + } @Override @@ -486,6 +532,6 @@ public void onSniffingSuccess(View webView, String url, List vide @Override public void onSniffingError(View webView, String url, int errorCode) { Sakura.getInstance().showToastMsg(Utils.getString(R.string.open_web_view)); - VideoUtils.openDefaultWebview(this, webUrl); + VideoUtils.openDefaultWebview(this, url); } } diff --git a/app/src/main/java/my/project/sakuraproject/main/desc/DescContract.java b/app/src/main/java/my/project/sakuraproject/main/desc/DescContract.java index 6410d82..bc52790 100644 --- a/app/src/main/java/my/project/sakuraproject/main/desc/DescContract.java +++ b/app/src/main/java/my/project/sakuraproject/main/desc/DescContract.java @@ -1,9 +1,6 @@ package my.project.sakuraproject.main.desc; -import com.chad.library.adapter.base.entity.MultiItemEntity; - -import java.util.List; - +import my.project.sakuraproject.bean.AnimeDescListBean; import my.project.sakuraproject.bean.AnimeListBean; import my.project.sakuraproject.main.base.BaseLoadDataCallback; import my.project.sakuraproject.main.base.BaseView; @@ -15,7 +12,7 @@ interface Model { } interface View extends BaseView { - void showSuccessMainView(List list); + void showSuccessMainView(AnimeDescListBean bean); void showSuccessDescView(AnimeListBean bean); @@ -23,7 +20,7 @@ interface View extends BaseView { } interface LoadDataCallback extends BaseLoadDataCallback { - void successMain(List list); + void successMain(AnimeDescListBean bean); void successDesc(AnimeListBean bean); 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 ee42693..f15dd5a 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 @@ -1,7 +1,5 @@ package my.project.sakuraproject.main.desc; -import com.chad.library.adapter.base.entity.MultiItemEntity; - import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.select.Elements; @@ -11,10 +9,10 @@ import java.util.List; import my.project.sakuraproject.R; -import my.project.sakuraproject.bean.AnimeDescBean; -import my.project.sakuraproject.bean.AnimeHeaderBean; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; +import my.project.sakuraproject.bean.AnimeDescListBean; +import my.project.sakuraproject.bean.AnimeDescRecommendBean; import my.project.sakuraproject.bean.AnimeListBean; -import my.project.sakuraproject.config.AnimeType; import my.project.sakuraproject.database.DatabaseUtil; import my.project.sakuraproject.main.base.BaseModel; import my.project.sakuraproject.net.HttpGet; @@ -25,8 +23,8 @@ public class DescModel extends BaseModel implements DescContract.Model { private String fid; - private List list; private String dramaStr; + private AnimeDescListBean animeDescListBean = new AnimeDescListBean(); @Override public void getData(String url, DescContract.LoadDataCallback callback) { @@ -46,7 +44,6 @@ public void onResponse(Call call, Response response) { Document doc = Jsoup.parse(response.body().string()); if (hasRefresh(doc)) getHtml(url, callback); else { - list = new ArrayList<>(); String animeTitle = doc.select("h1").text(); //是否收藏 callback.isFavorite(DatabaseUtil.checkFavorite(animeTitle)); @@ -74,7 +71,7 @@ public void onResponse(Call call, Response response) { setPlayData(detail); if (multi.size() > 0) setMulti(multi); if (recommend.size() > 0) setRecommend(recommend); - callback.successMain(list); + callback.successMain(animeDescListBean); } else { callback.error(Utils.getString(R.string.no_playlist_error)); } @@ -88,50 +85,37 @@ public void onResponse(Call call, Response response) { } private void setPlayData(Elements els) { - AnimeHeaderBean animeHeaderBean = new AnimeHeaderBean(Utils.getString(R.string.online)); + List animeDescDetailsBeans = new ArrayList<>(); boolean select; for (int i = 0, size = els.size(); i < size; i++) { String name = els.get(i).select("a").text(); String watchUrl = els.get(i).select("a").attr("href"); if (dramaStr.contains(watchUrl)) select = true; else select = false; - animeHeaderBean.addSubItem( - new AnimeDescBean( - AnimeType.TYPE_LEVEL_1, - select, - name, - watchUrl, - "play") - ); + animeDescDetailsBeans.add(new AnimeDescDetailsBean(name, watchUrl, select)); } - list.add(animeHeaderBean); + animeDescListBean.setAnimeDescDetailsBeans(animeDescDetailsBeans); } private void setMulti(Elements els) { - AnimeHeaderBean animeHeaderBean = new AnimeHeaderBean(Utils.getString(R.string.multi)); + List animeDescMultiBeans = new ArrayList<>(); for (int i = 0, size = els.size(); i < size; i++) { - animeHeaderBean.addSubItem( - new AnimeDescBean( - AnimeType.TYPE_LEVEL_3, - els.get(i).select("p.tname > a").text(), - els.get(i).select("p.tname > a").attr("href"), - els.get(i).select("img").attr("src"), - "multi")); + String title = els.get(i).select("p.tname > a").text(); + String img = els.get(i).select("img").attr("src"); + String url = els.get(i).select("p.tname > a").attr("href"); + animeDescMultiBeans.add(new AnimeDescRecommendBean(title, img, url)); } - list.add(animeHeaderBean); + animeDescListBean.setAnimeDescMultiBeans(animeDescMultiBeans); } private void setRecommend(Elements els) { - AnimeHeaderBean animeHeaderBean = new AnimeHeaderBean(Utils.getString(R.string.recommend)); + List animeDescRecommendBeans = new ArrayList<>(); for (int i = 0, size = els.size(); i < size; i++) { - animeHeaderBean.addSubItem( - new AnimeDescBean( - AnimeType.TYPE_LEVEL_2, - els.get(i).select("h2 > a").text(), - els.get(i).select("h2 > a").attr("href"), - els.get(i).select("img").attr("src"), - "recommend")); + String title = els.get(i).select("h2 > a").text(); + String img = els.get(i).select("img").attr("src"); + String url = els.get(i).select("h2 > a").attr("href"); + animeDescRecommendBeans.add(new AnimeDescRecommendBean(title, img, url)); } - list.add(animeHeaderBean); + animeDescListBean.setAnimeDescRecommendBeans(animeDescRecommendBeans); } } 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 8eb816e..bb055e7 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 @@ -1,9 +1,6 @@ package my.project.sakuraproject.main.desc; -import com.chad.library.adapter.base.entity.MultiItemEntity; - -import java.util.List; - +import my.project.sakuraproject.bean.AnimeDescListBean; import my.project.sakuraproject.bean.AnimeListBean; import my.project.sakuraproject.main.base.BasePresenter; import my.project.sakuraproject.main.base.Presenter; @@ -29,8 +26,8 @@ public void loadData(boolean isMain) { } @Override - public void successMain(List list) { - view.showSuccessMainView(list); + public void successMain(AnimeDescListBean bean) { + view.showSuccessMainView(bean); } @Override 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 32d473b..61eb05d 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 @@ -7,6 +7,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; +import android.util.Log; import android.util.Patterns; import android.view.View; import android.widget.Button; @@ -34,7 +35,7 @@ import my.project.sakuraproject.adapter.DramaAdapter; import my.project.sakuraproject.api.Api; import my.project.sakuraproject.application.Sakura; -import my.project.sakuraproject.bean.AnimeDescBean; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; import my.project.sakuraproject.main.base.BaseActivity; import my.project.sakuraproject.main.base.Presenter; import my.project.sakuraproject.main.video.VideoContract; @@ -50,7 +51,7 @@ public class PlayerActivity extends BaseActivity implements VideoContract.View, private String witchTitle, url, diliUrl; @BindView(R.id.rv_list) RecyclerView recyclerView; - private List list = new ArrayList<>(); + private List list = new ArrayList<>(); private DramaAdapter dramaAdapter; private ProgressDialog p; private String animeTitle; @@ -106,7 +107,7 @@ private void init(Bundle bundle) { //源地址 diliUrl = bundle.getString("dili"); //剧集list - list = (List) bundle.getSerializable("list"); + list = (List) bundle.getSerializable("list"); //禁止冒泡 linearLayout.setOnClickListener(view -> { return; @@ -152,59 +153,20 @@ public void initAdapter() { if (!Utils.isFastClick()) return; setResult(0x20); drawerLayout.closeDrawer(GravityCompat.END); - final AnimeDescBean bean = (AnimeDescBean) adapter.getItem(position); - switch (bean.getType()) { - case "play": - player.onPrepared(); - p = Utils.getProDialog(PlayerActivity.this, R.string.parsing); - Button v = (Button) adapter.getViewByPosition(recyclerView, position, R.id.tag_group); - v.setBackgroundResource(R.drawable.button_selected); - v.setTextColor(getResources().getColor(R.color.item_selected_color)); - bean.setSelect(true); - diliUrl = VideoUtils.getUrl(bean.getUrl()); - witchTitle = animeTitle + " - " + bean.getTitle(); - presenter = new VideoPresenter(animeTitle, diliUrl, PlayerActivity.this); - presenter.loadData(true); - break; - } - + AnimeDescDetailsBean bean = (AnimeDescDetailsBean) adapter.getItem(position); + player.onPrepared(); + p = Utils.getProDialog(PlayerActivity.this, R.string.parsing); + Button v = (Button) adapter.getViewByPosition(recyclerView, position, R.id.tag_group); + v.setBackgroundResource(R.drawable.button_selected); + v.setTextColor(getResources().getColor(R.color.tabSelectedTextColor)); + bean.setSelected(true); + diliUrl = VideoUtils.getUrl(bean.getUrl()); + witchTitle = animeTitle + " - " + bean.getTitle(); + presenter = new VideoPresenter(animeTitle, diliUrl, PlayerActivity.this); + presenter.loadData(true); }); } - public void goToPlay(List list) { - new Handler().postDelayed(() -> { - if (list.size() == 1) oneSource(list); - else multipleSource(list); - }, 200); - } - - /** - * 只有一个播放地址 - * - * @param list - */ - private void oneSource(List list) { - hideNavBar(); - playAnime(VideoUtils.getVideoUrl(list.get(0))); - } - - /** - * 多个播放地址 - * - * @param list - */ - private void multipleSource(List list) { - VideoUtils.showMultipleVideoSources(this, - list, - (dialog, index) -> { - hideNavBar(); - playAnime(VideoUtils.getVideoUrl(list.get(index))); - }, (dialog, which) -> { - cancelDialog(); - dialog.dismiss(); - }, 0); - } - private void playAnime(String animeUrl) { url = animeUrl; if (Patterns.WEB_URL.matcher(animeUrl.replace(" ", "")).matches()) { @@ -233,7 +195,7 @@ private void playAnime(String animeUrl) { } } else { webUrl = String.format(Api.PARSE_API, animeUrl); - Sakura.getInstance().showToastMsg(Utils.getString(R.string.maybe_can_not_play)); + application.showToastMsg(Utils.getString(R.string.should_be_used_web)); SniffingUtil.get().activity(this).referer(webUrl).callback(this).url(webUrl).start(); } } @@ -313,7 +275,16 @@ public void cancelDialog() { public void getVideoSuccess(List list) { runOnUiThread(() -> { hideNavBar(); - goToPlay(list); + Log.e("playUrl", list.toString()); + if (list.size() == 1) + playAnime(list.get(0)); + else + VideoUtils.showMultipleVideoSources(this, + list, + (dialog, index) -> playAnime(list.get(index)), (dialog, which) -> { + cancelDialog(); + dialog.dismiss(); + }, 1); }); } @@ -336,7 +307,7 @@ public void getVideoError() { } @Override - public void showSuccessDramaView(List dramaList) { + public void showSuccessDramaView(List dramaList) { list = dramaList; runOnUiThread(() -> dramaAdapter.setNewData(list)); diff --git a/app/src/main/java/my/project/sakuraproject/main/setting/SettingActivity.java b/app/src/main/java/my/project/sakuraproject/main/setting/SettingActivity.java index 4d6db73..93d79c7 100644 --- a/app/src/main/java/my/project/sakuraproject/main/setting/SettingActivity.java +++ b/app/src/main/java/my/project/sakuraproject/main/setting/SettingActivity.java @@ -202,7 +202,7 @@ public void setDefaultPlayer() { public void setX5State() { AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle("请选择"); + builder.setTitle("请选择内核状态"); builder.setSingleChoiceItems(x5Items, Utils.loadX5() ? 0 : 1, (dialog, which) -> { switch (which){ case 0: 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 f7568cd..fe3a992 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 @@ -2,7 +2,7 @@ import java.util.List; -import my.project.sakuraproject.bean.AnimeDescBean; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; import my.project.sakuraproject.main.base.BaseLoadDataCallback; public interface VideoContract { @@ -19,7 +19,7 @@ interface View { void getVideoError(); - void showSuccessDramaView(List list); + void showSuccessDramaView(List list); void errorDramaView(); } @@ -31,6 +31,6 @@ interface LoadDataCallback extends BaseLoadDataCallback { void empty(); - void successDrama(List list); + void successDrama(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 63beb3f..b2f5914 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 @@ -8,11 +8,11 @@ import java.util.ArrayList; import java.util.List; -import my.project.sakuraproject.bean.AnimeDescBean; -import my.project.sakuraproject.config.AnimeType; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; import my.project.sakuraproject.database.DatabaseUtil; import my.project.sakuraproject.main.base.BaseModel; import my.project.sakuraproject.net.HttpGet; +import my.project.sakuraproject.util.VideoUtils; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Response; @@ -43,7 +43,7 @@ public void onResponse(Call call, Response response) throws IOException { Elements playList = doc.select("div.playbo > a"); if (playList.size() > 0) { for (int i = 0, size = playList.size(); i < size; i++) { - videoUrlList.add(playList.get(i).attr("onClick")); + videoUrlList.add(VideoUtils.getVideoUrl(playList.get(i).attr("onClick"))); } callback.success(videoUrlList); } else { @@ -54,8 +54,8 @@ public void onResponse(Call call, Response response) throws IOException { }); } - private List getAllDrama(String fid, Elements dramaList) { - List list = new ArrayList<>(); + private List getAllDrama(String fid, Elements dramaList) { + List list = new ArrayList<>(); try { String dataBaseDrama = DatabaseUtil.queryAllIndex(fid); String dramaTitle; @@ -64,9 +64,9 @@ private List getAllDrama(String fid, Elements dramaList) { dramaUrl = dramaList.get(i).select("a").attr("href"); dramaTitle = dramaList.get(i).select("a").text(); if (dataBaseDrama.contains(dramaUrl)) - list.add(new AnimeDescBean(AnimeType.TYPE_LEVEL_1, true, dramaTitle, dramaUrl, "play")); + list.add(new AnimeDescDetailsBean(dramaTitle, dramaUrl, true)); else - list.add(new AnimeDescBean(AnimeType.TYPE_LEVEL_1, false, dramaTitle, dramaUrl, "play")); + list.add(new AnimeDescDetailsBean(dramaTitle, dramaUrl, false)); } } catch (Exception e) { e.printStackTrace(); 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 199cc38..fb6eaf0 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 @@ -2,7 +2,7 @@ import java.util.List; -import my.project.sakuraproject.bean.AnimeDescBean; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; import my.project.sakuraproject.main.base.BasePresenter; import my.project.sakuraproject.main.base.Presenter; @@ -43,7 +43,7 @@ public void empty() { } @Override - public void successDrama(List list) { + public void successDrama(List list) { if (list.size() > 0) view.showSuccessDramaView(list); else 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 49e281e..19ebb09 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 @@ -43,7 +43,7 @@ import my.project.sakuraproject.adapter.WebviewAdapter; import my.project.sakuraproject.api.Api; import my.project.sakuraproject.application.Sakura; -import my.project.sakuraproject.bean.AnimeDescBean; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; import my.project.sakuraproject.bean.ApiBean; import my.project.sakuraproject.bean.WebviewBean; import my.project.sakuraproject.database.DatabaseUtil; @@ -66,7 +66,7 @@ public class NormalWebActivity extends BaseActivity implements VideoContract.Vie @BindView(R.id.webview) NormalWebView normalWebView; private ProgressBar pg; - private List dramaList = new ArrayList<>(); + private List dramaList = new ArrayList<>(); private DramaAdapter dramaAdapter; private BottomSheetDialog mBottomSheetDialog; private ProgressDialog p; @@ -141,7 +141,7 @@ public void getBundle() { animeTitle = bundle.getString("title"); url = bundle.getString("url"); diliUrl = bundle.getString("dili"); - dramaList = (List) bundle.getSerializable("list"); + dramaList = (List) bundle.getSerializable("list"); } } @@ -210,21 +210,16 @@ public void initAdapter() { if (!Utils.isFastClick()) return; setResult(0x20); mBottomSheetDialog.dismiss(); - final AnimeDescBean bean = (AnimeDescBean) adapter.getItem(position); - switch (bean.getType()) { - case "play": - p = Utils.getProDialog(NormalWebActivity.this, R.string.parsing); - Button v = (Button) adapter.getViewByPosition(dramaRecyclerView, position, R.id.tag_group); - v.setBackgroundResource(R.drawable.button_selected); - v.setTextColor(getResources().getColor(R.color.item_selected_color)); - bean.setSelect(true); - diliUrl = VideoUtils.getUrl(bean.getUrl()); - witchTitle = animeTitle + " - " + bean.getTitle(); - presenter = new VideoPresenter(animeTitle, diliUrl, NormalWebActivity.this); - presenter.loadData(true); - break; - } - + AnimeDescDetailsBean bean = (AnimeDescDetailsBean) adapter.getItem(position); + p = Utils.getProDialog(NormalWebActivity.this, R.string.parsing); + Button v = (Button) adapter.getViewByPosition(dramaRecyclerView, position, R.id.tag_group); + v.setBackgroundResource(R.drawable.button_selected); + v.setTextColor(getResources().getColor(R.color.tabSelectedTextColor)); + bean.setSelected(true); + diliUrl = VideoUtils.getUrl(bean.getUrl()); + witchTitle = animeTitle + " - " + bean.getTitle(); + presenter = new VideoPresenter(animeTitle, diliUrl, NormalWebActivity.this); + presenter.loadData(true); }); dramaRecyclerView.setAdapter(dramaAdapter); mBottomSheetDialog = new BottomSheetDialog(this); @@ -352,7 +347,7 @@ public void getVideoError() { } @Override - public void showSuccessDramaView(List list) { + public void showSuccessDramaView(List list) { dramaList = list; runOnUiThread(() -> dramaAdapter.setNewData(dramaList)); } @@ -501,7 +496,7 @@ private void playAnime(String animeUrl) { } } else { webUrl = String.format(Api.PARSE_API, animeUrl); - Sakura.getInstance().showToastMsg(Utils.getString(R.string.maybe_can_not_play)); + Sakura.getInstance().showToastMsg(Utils.getString(R.string.should_be_used_web)); SniffingUtil.get().activity(this).referer(webUrl).callback(this).url(webUrl).start(); } } 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 04f9504..362135b 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 @@ -44,7 +44,7 @@ import my.project.sakuraproject.adapter.WebviewAdapter; import my.project.sakuraproject.api.Api; import my.project.sakuraproject.application.Sakura; -import my.project.sakuraproject.bean.AnimeDescBean; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; import my.project.sakuraproject.bean.ApiBean; import my.project.sakuraproject.bean.WebviewBean; import my.project.sakuraproject.database.DatabaseUtil; @@ -69,7 +69,7 @@ public class X5WebActivity extends BaseActivity implements VideoContract.View, S @BindView(R.id.x5_webview) X5WebView x5WebView; private ProgressBar pg; - private List dramaList = new ArrayList<>(); + private List dramaList = new ArrayList<>(); private DramaAdapter dramaAdapter; private BottomSheetDialog mBottomSheetDialog; private ProgressDialog p; @@ -144,7 +144,7 @@ public void getBundle() { animeTitle = bundle.getString("title"); url = bundle.getString("url"); diliUrl = bundle.getString("dili"); - dramaList = (List) bundle.getSerializable("list"); + dramaList = (List) bundle.getSerializable("list"); } } @@ -213,21 +213,15 @@ public void initAdapter() { if (!Utils.isFastClick()) return; setResult(0x20); mBottomSheetDialog.dismiss(); - final AnimeDescBean bean = (AnimeDescBean) adapter.getItem(position); - switch (bean.getType()) { - case "play": - p = Utils.getProDialog(X5WebActivity.this, R.string.parsing); - Button v = (Button) adapter.getViewByPosition(dramaRecyclerView, position, R.id.tag_group); - v.setBackgroundResource(R.drawable.button_selected); - v.setTextColor(getResources().getColor(R.color.item_selected_color)); - bean.setSelect(true); - diliUrl = VideoUtils.getUrl(bean.getUrl()); - witchTitle = animeTitle + " - " + bean.getTitle(); - presenter = new VideoPresenter(animeTitle, diliUrl, X5WebActivity.this); - presenter.loadData(true); - break; - } - + AnimeDescDetailsBean bean = (AnimeDescDetailsBean) adapter.getItem(position); + Button v = (Button) adapter.getViewByPosition(dramaRecyclerView, position, R.id.tag_group); + v.setBackgroundResource(R.drawable.button_selected); + v.setTextColor(getResources().getColor(R.color.tabSelectedTextColor)); + bean.setSelected(true); + diliUrl = VideoUtils.getUrl(bean.getUrl()); + witchTitle = animeTitle + " - " + bean.getTitle(); + presenter = new VideoPresenter(animeTitle, diliUrl, X5WebActivity.this); + presenter.loadData(true); }); dramaRecyclerView.setAdapter(dramaAdapter); mBottomSheetDialog = new BottomSheetDialog(this); @@ -366,7 +360,7 @@ public void getVideoError() { } @Override - public void showSuccessDramaView(List list) { + public void showSuccessDramaView(List list) { dramaList = list; runOnUiThread(() -> dramaAdapter.setNewData(dramaList)); } @@ -515,7 +509,7 @@ private void playAnime(String animeUrl) { } } else { webUrl = String.format(Api.PARSE_API, animeUrl); - Sakura.getInstance().showToastMsg(Utils.getString(R.string.maybe_can_not_play)); + Sakura.getInstance().showToastMsg(Utils.getString(R.string.should_be_used_web)); SniffingUtil.get().activity(this).referer(webUrl).callback(this).url(webUrl).start(); } } diff --git a/app/src/main/java/my/project/sakuraproject/util/VideoUtils.java b/app/src/main/java/my/project/sakuraproject/util/VideoUtils.java index 884901c..aa9d197 100644 --- a/app/src/main/java/my/project/sakuraproject/util/VideoUtils.java +++ b/app/src/main/java/my/project/sakuraproject/util/VideoUtils.java @@ -16,7 +16,7 @@ import my.project.sakuraproject.R; import my.project.sakuraproject.application.Sakura; -import my.project.sakuraproject.bean.AnimeDescBean; +import my.project.sakuraproject.bean.AnimeDescDetailsBean; import my.project.sakuraproject.main.player.PlayerActivity; import my.project.sakuraproject.main.webview.normal.DefaultNormalWebActivity; import my.project.sakuraproject.main.webview.normal.NormalWebActivity; @@ -101,7 +101,7 @@ public static String getVideoUrl(String url) { * @param diliUrl * @param list */ - public static void openPlayer(boolean isDescActivity, Activity activity, String witchTitle, String url, String animeTitle, String diliUrl, List list) { + public static void openPlayer(boolean isDescActivity, Activity activity, String witchTitle, String url, String animeTitle, String diliUrl, List list) { Bundle bundle = new Bundle(); bundle.putString("title", witchTitle); bundle.putString("url", url); @@ -128,7 +128,7 @@ public static void openPlayer(boolean isDescActivity, Activity activity, String * @param diliUrl * @param list */ - public static void openWebview(boolean isDescActivity, Activity activity, String witchTitle, String animeTitle, String url, String diliUrl, List list) { + public static void openWebview(boolean isDescActivity, Activity activity, String witchTitle, String animeTitle, String url, String diliUrl, List list) { Bundle bundle = new Bundle(); bundle.putString("witchTitle", witchTitle); bundle.putString("title", animeTitle); diff --git a/app/src/main/res/drawable-night/button_default.xml b/app/src/main/res/drawable-night/button_default.xml index 59ffb41..e156333 100644 --- a/app/src/main/res/drawable-night/button_default.xml +++ b/app/src/main/res/drawable-night/button_default.xml @@ -1,7 +1,7 @@ - + - - + + - + - - + + - - + android:background="@color/window_bg"> @@ -13,206 +12,297 @@ + android:scrollbars="none"> - - - + android:layout_marginTop="8dp" + android:background="?android:attr/selectableItemBackground" + android:layout_width="match_parent" + android:layout_height="65dp"> + + - - - - + android:layout_centerVertical="true" + android:orientation="vertical"> - + - + + + + + + + + + - - - + android:layout_centerVertical="true" + android:orientation="vertical"> - + + + + - + + + + + + + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:orientation="vertical"> + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + + - - + - + + android:background="?android:attr/selectableItemBackground" + android:clickable="true" + android:layout_width="match_parent" + android:layout_height="65dp"> + + - - - - + android:layout_centerVertical="true" + android:orientation="vertical"> - + - + + + + + + + + + - - - + android:layout_centerVertical="true" + android:orientation="vertical"> - + - + + + + + + + + + - - - + android:layout_centerVertical="true" + android:orientation="vertical"> - + + + + + + + + android:background="?android:attr/selectableItemBackground" + android:layout_width="match_parent" + android:layout_height="65dp"> + + - - - - + android:layout_centerVertical="true" + android:orientation="vertical"> + + + + + + + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_desc.xml b/app/src/main/res/layout/activity_desc.xml index 3891206..14a3e29 100644 --- a/app/src/main/res/layout/activity_desc.xml +++ b/app/src/main/res/layout/activity_desc.xml @@ -110,17 +110,159 @@ app:layout_anchor="@id/appBarLayout" app:layout_anchorGravity="bottom|right" /> - - - + android:layout_height="match_parent"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml index e55e7ec..3cfd479 100644 --- a/app/src/main/res/layout/activity_setting.xml +++ b/app/src/main/res/layout/activity_setting.xml @@ -1,180 +1,198 @@ - - - - +xmlns:app="http://schemas.android.com/apk/res-auto" +android:layout_width="match_parent" +android:layout_height="match_parent" +android:background="@color/window_bg" +android:orientation="vertical"> - + - + - + + + + + + + - + android:layout_centerVertical="true" + android:orientation="vertical"> - - - - - - - + android:layout_height="wrap_content" /> - + + + + + + + + + + android:layout_centerVertical="true" + android:orientation="vertical"> - - - - - - - + android:layout_height="wrap_content" /> - + + + + + + + + + + android:layout_centerVertical="true" + android:orientation="vertical"> - - - - - - - + android:layout_height="wrap_content" /> - - - - - + android:layout_height="wrap_content" /> + + + + + + + - - - + android:layout_centerVertical="true" + android:orientation="vertical"> + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_drama.xml b/app/src/main/res/layout/dialog_drama.xml new file mode 100644 index 0000000..8ab71d7 --- /dev/null +++ b/app/src/main/res/layout/dialog_drama.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_week.xml b/app/src/main/res/layout/fragment_week.xml index 2e35274..c931b5b 100644 --- a/app/src/main/res/layout/fragment_week.xml +++ b/app/src/main/res/layout/fragment_week.xml @@ -5,17 +5,17 @@ + android:layout_centerHorizontal="true" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + android:fadingEdge="none"/> \ No newline at end of file diff --git a/app/src/main/res/layout/item_api.xml b/app/src/main/res/layout/item_api.xml index 67c5340..acf7eb0 100644 --- a/app/src/main/res/layout/item_api.xml +++ b/app/src/main/res/layout/item_api.xml @@ -12,7 +12,7 @@ android:foreground="?android:attr/selectableItemBackground" app:ignore="NamespaceTypo" card_view:cardBackgroundColor="@color/window_bg" - card_view:cardCornerRadius="0dp" + card_view:cardCornerRadius="4dp" card_view:cardElevation="4dp" card_view:cardUseCompatPadding="false"> @@ -33,8 +33,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="9" - android:padding="5dp" - android:text="白玉阁免费解析" + android:padding="15dp" android:textColor="@color/text_color_primary" android:textSize="16sp" /> @@ -60,7 +59,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" - android:padding="5dp" + android:padding="15dp" android:tint="@color/text_color_primary" android:textSize="16sp" /> diff --git a/app/src/main/res/layout/item_desc_details.xml b/app/src/main/res/layout/item_desc_details.xml new file mode 100644 index 0000000..19f9715 --- /dev/null +++ b/app/src/main/res/layout/item_desc_details.xml @@ -0,0 +1,13 @@ +