From 3eaca1ec688143d8a2c9412749698697e26e5186 Mon Sep 17 00:00:00 2001 From: FongMi Date: Thu, 31 Aug 2023 23:30:10 +0800 Subject: [PATCH] [mobile] support mange detail - part 1 --- app/src/mobile/AndroidManifest.xml | 29 +-- .../tv/ui/activity/DetailActivity.java | 185 ++++++++++++++++++ .../android/tv/ui/fragment/TypeFragment.java | 5 +- ...activity_manga.xml => activity_detail.xml} | 24 ++- 4 files changed, 221 insertions(+), 22 deletions(-) create mode 100644 app/src/mobile/java/com/fongmi/android/tv/ui/activity/DetailActivity.java rename app/src/mobile/res/layout/{activity_manga.xml => activity_detail.xml} (87%) diff --git a/app/src/mobile/AndroidManifest.xml b/app/src/mobile/AndroidManifest.xml index ee72df966..b06b8275f 100644 --- a/app/src/mobile/AndroidManifest.xml +++ b/app/src/mobile/AndroidManifest.xml @@ -81,14 +81,14 @@ android:screenOrientation="fullUser" /> + android:name=".ui.activity.DetailActivity" + android:configChanges="screenSize|smallestScreenSize|screenLayout" + android:screenOrientation="fullUser" /> + + + android:name=".ui.activity.VideoActivity" + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" + android:excludeFromRecents="true" + android:launchMode="singleTask" + android:resizeableActivity="true" + android:screenOrientation="fullUser" + android:supportsPictureInPicture="true" + android:theme="@style/AppTheme.Detail" /> () { + @Override + public void onChanged(Result result) { + + } + }); + } + + private void getDetail() { + mViewModel.detailContent(getKey(), getId()); + } + + private void setDetail(Result result) { + mBinding.swipeLayout.setRefreshing(false); + Log.e("DDD", new Gson().toJson(result)); + if (result.getList().isEmpty()) setEmpty(); + else setDetail(result.getList().get(0)); + Notify.show(result.getMsg()); + } + + private void setEmpty() { + if (isFromCollect()) { + finish(); + } else { + showEmpty(); + } + } + + private void showEmpty() { + mBinding.swipeLayout.setEnabled(true); + mBinding.progressLayout.showEmpty(); + } + + private void setDetail(Vod item) { + mBinding.progressLayout.showContent(); + mBinding.name.setText(item.getVodName(getName())); + setText(mBinding.site, R.string.detail_site, getSite().getName()); + setText(mBinding.content, 0, Html.fromHtml(item.getVodContent()).toString()); + setText(mBinding.director, R.string.detail_director, Html.fromHtml(item.getVodDirector()).toString()); + ImgUtil.load(item.getVodPic(getPic()), mBinding.pic); + //mFlagAdapter.addAll(item.getVodFlags()); + //checkHistory(item); + //checkFlag(item); + //checkKeepImg(); + } + + private void setText(TextView view, int resId, String text) { + view.setVisibility(text.isEmpty() ? View.GONE : View.VISIBLE); + view.setText(resId > 0 ? getString(resId, text) : text); + view.setTag(text); + } + + @Override + public void onItemClick(Episode item) { + + } +} diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/fragment/TypeFragment.java b/app/src/mobile/java/com/fongmi/android/tv/ui/fragment/TypeFragment.java index 2d67c10c9..a16ddeedb 100644 --- a/app/src/mobile/java/com/fongmi/android/tv/ui/fragment/TypeFragment.java +++ b/app/src/mobile/java/com/fongmi/android/tv/ui/fragment/TypeFragment.java @@ -22,6 +22,7 @@ import com.fongmi.android.tv.bean.Vod; import com.fongmi.android.tv.databinding.FragmentTypeBinding; import com.fongmi.android.tv.model.SiteViewModel; import com.fongmi.android.tv.ui.activity.CollectActivity; +import com.fongmi.android.tv.ui.activity.DetailActivity; import com.fongmi.android.tv.ui.activity.VideoActivity; import com.fongmi.android.tv.ui.adapter.VodAdapter; import com.fongmi.android.tv.ui.base.BaseFragment; @@ -213,8 +214,8 @@ public class TypeFragment extends BaseFragment implements CustomScroller.Callbac mPages.add(Page.get(item.getVodId(), findPosition())); getVideo(item.getVodId(), "1"); } else { - if (!isFolder()) VideoActivity.start(getActivity(), getKey(), item.getVodId(), item.getVodName(), item.getVodPic()); - else VideoActivity.start(getActivity(), getKey(), item.getVodId(), item.getVodName(), item.getVodPic(), item.getVodName()); + if (item.isManga()) DetailActivity.start(getActivity(), getKey(), item.getVodId(), item.getVodName(), item.getVodPic()); + else VideoActivity.start(getActivity(), getKey(), item.getVodId(), item.getVodName(), item.getVodPic(), isFolder() ? item.getVodName() : null); } } diff --git a/app/src/mobile/res/layout/activity_manga.xml b/app/src/mobile/res/layout/activity_detail.xml similarity index 87% rename from app/src/mobile/res/layout/activity_manga.xml rename to app/src/mobile/res/layout/activity_detail.xml index c442e538c..787ef04a9 100644 --- a/app/src/mobile/res/layout/activity_manga.xml +++ b/app/src/mobile/res/layout/activity_detail.xml @@ -2,19 +2,27 @@ + android:layout_height="match_parent" + android:fitsSystemWindows="true"> - + android:layout_height="match_parent"> - + android:layout_marginStart="16dp" + android:layout_marginTop="16dp" + android:layout_marginEnd="16dp" + android:layout_marginBottom="16dp" + android:elevation="4dp" + android:scaleType="centerCrop" + app:shapeAppearance="@style/Vod.Grid" /> - + \ No newline at end of file