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 17, 2022
1 parent d6dfd12 commit 489e9cb
Show file tree
Hide file tree
Showing 24 changed files with 200 additions and 293 deletions.
11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'

android {
compileSdkVersion 30
compileSdkVersion 32
defaultConfig {
applicationId "my.project.sakuraproject"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 32
versionCode 48
versionName "2.3.8_1"
ndk{abiFilters "arm64-v8a", "x86_64"}
Expand Down Expand Up @@ -37,14 +37,15 @@ allprojects {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.compose.material3:material3:1.0.0-alpha15'
implementation files('src/libs/nanohttpd-2.3.1.jar')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.palette:palette:1.0.0'
implementation 'com.google.android.material:material:1.4.0-alpha01'
implementation 'com.google.android.material:material:1.5.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
// implementation 'androidx.navigation:navigation-fragment:2.3.0'
// implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.30'
implementation 'pub.devrel:easypermissions:3.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
android:name=".main.start.StartActivity"
android:configChanges="screenLayout|orientation|screenSize|smallestScreenSize|keyboardHidden|uiMode"
android:label="@string/app_name"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@style/startTheme">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,13 @@
import java.util.List;

public class AnimeDescListBean implements Serializable {
// 播放列表集合
// private List<AnimeDescDetailsBean> animeDescDetailsBeans = new ArrayList<>();
// 番剧多季集合
private List<AnimeDescRecommendBean> animeDescMultiBeans = new ArrayList<>();
// 番剧推荐集合
private List<AnimeDescRecommendBean> animeDescRecommendBeans = new ArrayList<>();
// 用于imomoe多个播放地址
// private List<List<AnimeDescDetailsBean>> multipleAnimeDescDetailsBeans;

// 播放列表集合
private List<AnimeDramasBean> animeDramasBeans = new ArrayList<>();

/*public List<AnimeDescDetailsBean> getAnimeDescDetailsBeans() {
return animeDescDetailsBeans;
}
public void setAnimeDescDetailsBeans(List<AnimeDescDetailsBean> animeDescDetailsBeans) {
this.animeDescDetailsBeans = animeDescDetailsBeans;
}*/

public List<AnimeDramasBean> getAnimeDramasBeans() {
return animeDramasBeans;
}
Expand All @@ -48,12 +35,4 @@ public List<AnimeDescRecommendBean> getAnimeDescRecommendBeans() {
public void setAnimeDescRecommendBeans(List<AnimeDescRecommendBean> animeDescRecommendBeans) {
this.animeDescRecommendBeans = animeDescRecommendBeans;
}

/*public List<List<AnimeDescDetailsBean>> getMultipleAnimeDescDetailsBeans() {
return multipleAnimeDescDetailsBeans;
}
public void setMultipleAnimeDescDetailsBeans(List<List<AnimeDescDetailsBean>> multipleAnimeDescDetailsBeans) {
this.multipleAnimeDescDetailsBeans = multipleAnimeDescDetailsBeans;
}*/
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package my.project.sakuraproject.main.about;

import android.content.Intent;
import android.graphics.Typeface;
import android.os.Environment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -128,20 +126,13 @@ public boolean onOptionsItemSelected(MenuItem item) {
public void showUpdateLogs() {
AlertDialog alertDialog;
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DialogStyle);
builder.setTitle(Utils.getString(R.string.update_log));
View view = LayoutInflater.from(this).inflate(R.layout.dialog_update_log, null);
RecyclerView logs = view.findViewById(R.id.rv_list);
logs.setLayoutManager(new LinearLayoutManager(this));
LogAdapter logAdapter = new LogAdapter(createUpdateLogList());
logs.setAdapter(logAdapter);
builder.setPositiveButton(Utils.getString(R.string.page_positive), null);
TextView title = new TextView(this);
title.setText(Utils.getString(R.string.update_log));
title.setPadding(30,30,30,30);
title.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
title.setGravity(Gravity.LEFT);
title.setTextSize(18);
title.setTextColor(getResources().getColor(R.color.text_color_primary));
builder.setCustomTitle(title);
alertDialog = builder.setView(view).create();
alertDialog.show();
}
Expand Down
103 changes: 41 additions & 62 deletions app/src/main/java/my/project/sakuraproject/main/desc/DescActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.ImageView;
Expand All @@ -18,7 +17,6 @@

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import androidx.core.widget.NestedScrollView;
import androidx.recyclerview.widget.GridLayoutManager;
Expand All @@ -38,12 +36,12 @@
import com.bumptech.glide.request.transition.DrawableCrossFadeFactory;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ctetin.expandabletextviewlibrary.ExpandableTextView;
import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.textfield.TextInputLayout;
import com.r0adkll.slidr.Slidr;
import com.r0adkll.slidr.model.SlidrInterface;

Expand Down Expand Up @@ -135,8 +133,6 @@ public class DescActivity extends BaseActivity<DescContract.View, DescPresenter>
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;
Expand All @@ -150,8 +146,6 @@ public class DescActivity extends BaseActivity<DescContract.View, DescPresenter>
LinearLayout desc_view;
@BindView(R.id.bg)
ImageView bg;
@BindView(R.id.favorite)
MaterialButton favorite;
@BindView(R.id.tag_view)
TagContainerLayout tagContainerLayout;
@BindView(R.id.update_time)
Expand All @@ -164,8 +158,8 @@ public class DescActivity extends BaseActivity<DescContract.View, DescPresenter>
private int clickIndex; // 当前点击剧集
// 番剧ID
private String animeId;
@BindView(R.id.download)
FloatingActionButton downloadView;
@BindView(R.id.to_back)
FloatingActionButton toBackView;
private SlidrInterface slidrInterface;
// 下载
private String savePath; // 下载保存路劲
Expand All @@ -186,6 +180,9 @@ public class DescActivity extends BaseActivity<DescContract.View, DescPresenter>
private List<String> dramaTitles;
private ArrayAdapter dramaTitlesApter;

@BindView(R.id.bottomAppBar)
BottomAppBar bottomAppBar;

@Override
protected DescPresenter createPresenter() {
return new DescPresenter(sakuraUrl, this);
Expand All @@ -207,12 +204,10 @@ protected void init() {
StatusBarUtil.setColorForSwipeBack(this, getResources().getColor(R.color.colorPrimaryDark), 0);
if (isDarkTheme) bg.setVisibility(View.GONE);
slidrInterface = 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));
desc.setNeedExpend(true);
getBundle();
initFab();
initBottomAppBar();
initSwipe();
initAdapter();
initTagClick();
Expand All @@ -232,15 +227,23 @@ public void getBundle() {
}
}

public void initFab() {
if (Utils.checkHasNavigationBar(this)) {
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) downloadView.getLayoutParams();
params.setMargins(Utils.dpToPx(this, 16),
Utils.dpToPx(this, 16),
Utils.dpToPx(this, 16),
Utils.getNavigationBarHeight(this) + 15);
downloadView.setLayoutParams(params);
}
public void initBottomAppBar() {
bottomAppBar.setOnMenuItemClickListener(item -> {
switch (item.getItemId()) {
case R.id.favorite:
favoriteAnime();
break;
case R.id.download:
checkHasDownload();
downloadBottomSheetDialog.getBehavior().setState(BottomSheetBehavior.STATE_EXPANDED);
downloadBottomSheetDialog.show();
break;
case R.id.browser:
Utils.viewInChrome(this, BaseModel.getDomain(isImomoe) + sakuraUrl);
break;
}
return true;
});
}

public void initSwipe() {
Expand Down Expand Up @@ -443,21 +446,16 @@ public void dramaClick() {
}
}

@OnClick({R.id.browser})
public void openBrowser() {
Utils.viewInChrome(this, BaseModel.getDomain(isImomoe) + sakuraUrl);
}

@SuppressLint("RestrictedApi")
public void openAnimeDesc() {
downloadView.setVisibility(View.GONE);
// downloadView.setVisibility(View.GONE);
animeImg.setImageDrawable(getDrawable(isDarkTheme ? R.drawable.loading_night : R.drawable.loading_light));
hideView(tagContainerLayout);
tagContainerLayout.setTags("");
hideView(score_view);
setTextviewEmpty(desc);
animeDescListBean = new AnimeDescListBean();
hideView(favorite);
hideViewInvisible(bottomAppBar);
bg.setImageDrawable(getResources().getDrawable(R.drawable.default_bg));
mPresenter = new DescPresenter(sakuraUrl, this);
mPresenter.loadData(true);
Expand Down Expand Up @@ -517,9 +515,9 @@ public void onBackPressed() {

public void favoriteAnime() {
isFavorite = DatabaseUtil.favorite(animeListBean, animeId);
favorite.setIcon(ContextCompat.getDrawable(this, isFavorite ? R.drawable.baseline_favorite_white_48dp : R.drawable.baseline_favorite_border_white_48dp));
favorite.setText(isFavorite ? Utils.getString(R.string.has_favorite) : Utils.getString(R.string.favorite));
application.showSnackbarMsg(msg, isFavorite ? Utils.getString(R.string.join_ok) : Utils.getString(R.string.join_error));
bottomAppBar.getMenu().getItem(0).setIcon(ContextCompat.getDrawable(this, isFavorite ? R.drawable.baseline_favorite_white_48dp : R.drawable.baseline_favorite_border_white_48dp));
bottomAppBar.getMenu().getItem(0).setTitle(isFavorite ? Utils.getString(R.string.has_favorite) : Utils.getString(R.string.favorite));
application.showSnackbarMsg(bottomAppBar, isFavorite ? Utils.getString(R.string.join_ok) : Utils.getString(R.string.join_error));
EventBus.getDefault().post(new Refresh(1));
}

Expand Down Expand Up @@ -563,18 +561,8 @@ public void setCollapsingToolbar() {
}
}

/*@OnClick(R.id.spinner)
public void showMenu() {
showPopupMenu();
}*/

@OnClick(R.id.favorite)
public void setFavorite() {
favoriteAnime();
}

@OnClick(R.id.exit)
public void exit() {
@OnClick(R.id.to_back)
public void back() {
finish();
}

Expand All @@ -590,8 +578,8 @@ public void showLoadingView() {
public void showLoadErrorView(String msg) {
runOnUiThread(() -> {
if (!mActivityFinish) {
downloadView.setVisibility(View.GONE);
mSwipe.setRefreshing(false);
hideViewInvisible(bottomAppBar);
hideView(desc_view);
hideView(playLinearLayout);
hideView(multiLinearLayout);
Expand All @@ -601,6 +589,10 @@ public void showLoadErrorView(String msg) {
}
});
}
private void hideViewInvisible(View view) {
Utils.fadeOut(view);
view.setVisibility(View.INVISIBLE);
}

private void hideView(View view) {
Utils.fadeOut(view);
Expand All @@ -615,8 +607,7 @@ private void showView(View view) {
@Override
public void showEmptyVIew() {
mSwipe.setRefreshing(true);
downloadView.setVisibility(View.GONE);
hideView(favorite);
hideViewInvisible(bottomAppBar);
hideView(desc_view);
hideView(playLinearLayout);
hideView(multiLinearLayout);
Expand All @@ -635,7 +626,6 @@ public void showSuccessMainView(AnimeDescListBean bean) {
if (!mActivityFinish) {
/*if (!isImomoe)
downloadView.setVisibility(View.VISIBLE);*/
downloadView.setVisibility(View.VISIBLE);
setCollapsingToolbar();
mSwipe.setRefreshing(false);
if (isFavorite) DatabaseUtil.updateFavorite(animeListBean, animeId);
Expand All @@ -655,6 +645,7 @@ public void showSuccessMainView(AnimeDescListBean bean) {
hideView(multiLinearLayout);
animeDescMultiAdapter.setNewData(bean.getAnimeDescMultiBeans());
animeDescRecommendAdapter.setNewData(bean.getAnimeDescRecommendBeans());
showView(bottomAppBar);
showView(desc_view);
showView(playLinearLayout);
showView(recommendLinearLayout);
Expand Down Expand Up @@ -707,11 +698,8 @@ public void showSuccessFavorite(boolean is) {
isFavorite = is;
runOnUiThread(() -> {
if (!mActivityFinish) {
if (!favorite.isShown()) {
favorite.setIcon(ContextCompat.getDrawable(this, isFavorite ? R.drawable.baseline_favorite_white_48dp : R.drawable.baseline_favorite_border_white_48dp));
favorite.setText(isFavorite ? Utils.getString(R.string.has_favorite) : Utils.getString(R.string.favorite));
showView(favorite);
}
bottomAppBar.getMenu().getItem(0).setIcon(ContextCompat.getDrawable(this, isFavorite ? R.drawable.baseline_favorite_white_48dp : R.drawable.baseline_favorite_border_white_48dp));
bottomAppBar.getMenu().getItem(0).setTitle(isFavorite ? Utils.getString(R.string.has_favorite) : Utils.getString(R.string.favorite));
}
});
}
Expand All @@ -723,6 +711,7 @@ public void showEmptyDram(String msg) {
mSwipe.setRefreshing(false);
setCollapsingToolbar();
showView(desc_view);
showView(bottomAppBar);
hideView(playLinearLayout);
hideView(multiLinearLayout);
hideView(recommendLinearLayout);
Expand Down Expand Up @@ -820,16 +809,6 @@ public void onEvent(Event event) {
}

/****************************************** 下载相关 ******************************************/
/**
* 显示downloadBottomSheetDialog
*/
@OnClick(R.id.download)
public void download() {
checkHasDownload();
downloadBottomSheetDialog.getBehavior().setState(BottomSheetBehavior.STATE_EXPANDED);
downloadBottomSheetDialog.show();
}

/**
* 下载配置
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import android.widget.TextView;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatCheckBox;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
Expand All @@ -24,6 +23,7 @@
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.task.DownloadTask;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.android.material.checkbox.MaterialCheckBox;
import com.r0adkll.slidr.Slidr;

import org.greenrobot.eventbus.EventBus;
Expand Down Expand Up @@ -192,7 +192,8 @@ private void showDeleteDataDialog(DownloadDataBean bean, int position) {
AlertDialog alertDialog;
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DialogStyle);
View view = LayoutInflater.from(this).inflate(R.layout.dialog_remove_download, null);
AppCompatCheckBox checkBox = view.findViewById(R.id.remove_file_select);
MaterialCheckBox checkBox = view.findViewById(R.id.remove_file_select);
builder.setTitle(Utils.getString(R.string.other_operation));
builder.setPositiveButton(Utils.getString(R.string.page_positive), (dialog, which) -> deleteData(checkBox.isChecked(), bean, position));
builder.setNegativeButton(Utils.getString(R.string.page_negative), (dialog, which) -> dialog.dismiss());
alertDialog = builder.setView(view).create();
Expand Down
Loading

0 comments on commit 489e9cb

Please sign in to comment.