From 53724a8c254ba6b346afd0afd47a558fc7c626e0 Mon Sep 17 00:00:00 2001
From: CeuiLiSA <32817377+CeuiLiSA@users.noreply.github.com>
Date: Wed, 24 Jun 2020 14:17:41 +0800
Subject: [PATCH] =?UTF-8?q?=E5=BC=83=E7=94=A8datachannel=EF=BC=8C=E4=BD=BF?=
=?UTF-8?q?=E7=94=A8Container=EF=BC=88UUID=20+=20HashMap=EF=BC=89=E4=BD=9C?=
=?UTF-8?q?=E4=B8=BA=E4=BC=A0=E5=80=BC=E4=B8=AD=E9=97=B4=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/build.gradle | 4 +-
app/src/main/AndroidManifest.xml | 2 +-
.../ceui/lisa/activities/MainActivity.java | 4 +-
.../java/ceui/lisa/activities/VActivity.java | 67 +++
.../java/ceui/lisa/adapters/IAdapter.java | 31 +-
.../lisa/adapters/IAdapterWithHeadView.java | 46 +-
.../java/ceui/lisa/adapters/IllustHeader.java | 30 +-
.../java/ceui/lisa/adapters/NovelHeader.java | 4 -
.../main/java/ceui/lisa/core/Container.java | 63 +++
.../main/java/ceui/lisa/core/PageData.java | 33 ++
.../ceui/lisa/fragments/FragmentEvent.java | 28 +-
.../ceui/lisa/fragments/FragmentHistory.java | 24 +-
.../ceui/lisa/fragments/FragmentIllust.java | 41 ++
.../ceui/lisa/fragments/FragmentImage.java | 27 +-
.../FragmentLikeIllustHorizontal.java | 24 +-
.../lisa/fragments/FragmentMultiDownld.java | 25 +-
.../lisa/fragments/FragmentSingleIllust2.java | 457 ++++++++++++++++++
app/src/main/java/ceui/lisa/utils/Params.java | 2 +
.../java/ceui/lisa/utils/PixivOperate.java | 52 +-
.../main/res/layout/activity_view_pager.xml | 3 +-
app/src/main/res/layout/fragment_illust.xml | 33 +-
21 files changed, 874 insertions(+), 126 deletions(-)
create mode 100644 app/src/main/java/ceui/lisa/activities/VActivity.java
create mode 100644 app/src/main/java/ceui/lisa/core/Container.java
create mode 100644 app/src/main/java/ceui/lisa/core/PageData.java
create mode 100644 app/src/main/java/ceui/lisa/fragments/FragmentIllust.java
create mode 100644 app/src/main/java/ceui/lisa/fragments/FragmentSingleIllust2.java
diff --git a/app/build.gradle b/app/build.gradle
index 2a6968e82..b72c1dbd7 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -12,8 +12,8 @@ android {
applicationId "ceui.lisa.pixiv"
minSdkVersion 21
targetSdkVersion 28
- versionCode 96
- versionName "1.9.6"
+ versionCode 97
+ versionName "1.9.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index fdad7d756..3df16d522 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -45,7 +45,6 @@
android:scheme="https" />
-
@@ -104,6 +103,7 @@
+
\ No newline at end of file
diff --git a/app/src/main/java/ceui/lisa/activities/MainActivity.java b/app/src/main/java/ceui/lisa/activities/MainActivity.java
index 0f881ffeb..e8c82d9a8 100644
--- a/app/src/main/java/ceui/lisa/activities/MainActivity.java
+++ b/app/src/main/java/ceui/lisa/activities/MainActivity.java
@@ -27,9 +27,6 @@
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
-import com.blankj.utilcode.util.AppUtils;
-import com.blankj.utilcode.util.DeviceUtils;
-import com.blankj.utilcode.util.RomUtils;
import com.bumptech.glide.Glide;
import com.google.android.material.navigation.NavigationView;
import com.tbruyelle.rxpermissions2.RxPermissions;
@@ -319,5 +316,6 @@ protected void onResume() {
initDrawerHeader();
Dev.refreshUser = false;
}
+// Container.get().clear();
}
}
diff --git a/app/src/main/java/ceui/lisa/activities/VActivity.java b/app/src/main/java/ceui/lisa/activities/VActivity.java
new file mode 100644
index 000000000..c6c0ccfb1
--- /dev/null
+++ b/app/src/main/java/ceui/lisa/activities/VActivity.java
@@ -0,0 +1,67 @@
+package ceui.lisa.activities;
+
+import android.os.Bundle;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentStatePagerAdapter;
+
+
+import ceui.lisa.R;
+import ceui.lisa.core.PageData;
+import ceui.lisa.databinding.ActivityViewPagerBinding;
+import ceui.lisa.fragments.FragmentIllust;
+import ceui.lisa.core.Container;
+import ceui.lisa.fragments.FragmentSingleIllust2;
+import ceui.lisa.utils.Params;
+
+public class VActivity extends BaseActivity {
+
+ private String pageUUID = "";
+ private int index = 0;
+
+ @Override
+ protected void initBundle(Bundle bundle) {
+ pageUUID = bundle.getString(Params.PAGE_UUID);
+ index = bundle.getInt(Params.POSITION);
+ }
+
+ @Override
+ protected int initLayout() {
+ return R.layout.activity_view_pager;
+ }
+
+ @Override
+ protected void initView() {
+ PageData pageData = Container.get().getPage(pageUUID);
+ if (pageData != null) {
+ final int pageSize = pageData.getIllustList() == null ? 0 : pageData.getIllustList().size();
+ baseBind.viewPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager(), 0) {
+ @NonNull
+ @Override
+ public Fragment getItem(int position) {
+// return FragmentIllust.newInstance(pageData.getIllustList().get(position));
+ return FragmentSingleIllust2.newInstance(pageData.getIllustList().get(position));
+ }
+
+ @Override
+ public int getCount() {
+ return pageSize;
+ }
+ });
+ if (index < pageSize) {
+ baseBind.viewPager.setCurrentItem(index);
+ }
+ }
+ }
+
+ @Override
+ protected void initData() {
+
+ }
+
+ @Override
+ public boolean hideStatusBar() {
+ return true;
+ }
+}
diff --git a/app/src/main/java/ceui/lisa/adapters/IAdapter.java b/app/src/main/java/ceui/lisa/adapters/IAdapter.java
index 27ecbd28f..0e69d2fa2 100644
--- a/app/src/main/java/ceui/lisa/adapters/IAdapter.java
+++ b/app/src/main/java/ceui/lisa/adapters/IAdapter.java
@@ -1,6 +1,5 @@
package ceui.lisa.adapters;
-import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
@@ -11,7 +10,6 @@
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
-import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
@@ -21,28 +19,24 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import ceui.lisa.R;
import ceui.lisa.activities.Shaft;
import ceui.lisa.activities.TemplateActivity;
-import ceui.lisa.activities.ViewPagerActivity;
+import ceui.lisa.activities.VActivity;
+import ceui.lisa.core.PageData;
import ceui.lisa.databinding.RecyIllustStaggerBinding;
import ceui.lisa.dialogs.MuteDialog;
import ceui.lisa.fragments.FragmentLikeIllust;
-import ceui.lisa.http.NullCtrl;
-import ceui.lisa.http.Retro;
import ceui.lisa.interfaces.MultiDownload;
import ceui.lisa.interfaces.OnItemClickListener;
-import ceui.lisa.model.ListIllust;
import ceui.lisa.models.IllustsBean;
import ceui.lisa.utils.Common;
-import ceui.lisa.utils.DataChannel;
+import ceui.lisa.core.Container;
import ceui.lisa.utils.GlideUtil;
import ceui.lisa.utils.Params;
import ceui.lisa.utils.PixivOperate;
-import io.reactivex.Scheduler;
-import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.schedulers.Schedulers;
import jp.wasabeef.glide.transformations.BlurTransformation;
import static ceui.lisa.activities.Shaft.sUserModel;
@@ -101,7 +95,7 @@ public void onClick(View v) {
bindView.baseBind.likeButton.setImageTintList(
ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.not_bookmarked)));
} else {
- getRelated(target, position);
+// getRelated(target, position);
bindView.baseBind.likeButton.setImageTintList(
ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.has_bookmarked)));
}
@@ -112,7 +106,7 @@ public void onClick(View v) {
@Override
public boolean onLongClick(View v) {
if (!target.isIs_bookmarked()) {
- getRelated(target, position);
+// getRelated(target, position);
Intent intent = new Intent(mContext, TemplateActivity.class);
intent.putExtra(Params.ILLUST_ID, target.getId());
intent.putExtra(TemplateActivity.EXTRA_FRAGMENT, "按标签收藏");
@@ -200,12 +194,15 @@ private void handleClick() {
setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(View v, int position, int viewType) {
- DataChannel.get().setIllustList(allIllust);
- Intent intent = new Intent(mContext, ViewPagerActivity.class);
- intent.putExtra("position", position);
+ final String uuid = UUID.randomUUID().toString();
+ final List tempList = new ArrayList<>(allIllust);
+ final PageData pageData = new PageData(uuid, tempList);
+ Container.get().addPage(pageData);
+
+ Intent intent = new Intent(mContext, VActivity.class);
+ intent.putExtra(Params.POSITION, position);
+ intent.putExtra(Params.PAGE_UUID, uuid);
mContext.startActivity(intent);
-// ((Activity)mContext).overridePendingTransition(R.anim.zoom_enter,
-// R.anim.zoom_exit);
}
});
}
diff --git a/app/src/main/java/ceui/lisa/adapters/IAdapterWithHeadView.java b/app/src/main/java/ceui/lisa/adapters/IAdapterWithHeadView.java
index 0c9ae82af..09ae5c6b8 100644
--- a/app/src/main/java/ceui/lisa/adapters/IAdapterWithHeadView.java
+++ b/app/src/main/java/ceui/lisa/adapters/IAdapterWithHeadView.java
@@ -57,29 +57,29 @@ public void setHeadData(List illustsBeans) {
}
}
- @Override
- public void getRelated(IllustsBean illust, int position) {
- Retro.getAppApi().relatedIllust(sUserModel.getResponse().getAccess_token(), illust.getId())
- .subscribeOn(Schedulers.newThread())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(new NullCtrl() {
- @Override
- public void success(ListIllust listIllust) {
- if (listIllust.getIllusts() != null) {
- final int realP = position + 1;
- if (listIllust.getIllusts().size() >= 6) {
- List related = new ArrayList<>();
- for (int i = 0; i < 6; i++) {
- related.add(listIllust.getIllusts().get(i));
- }
- allIllust.addAll(realP, related);
- notifyItemRangeInserted(realP, related.size());
- notifyItemRangeChanged(realP, allIllust.size() - realP);
- }
- }
- }
- });
- }
+// @Override
+// public void getRelated(IllustsBean illust, int position) {
+// Retro.getAppApi().relatedIllust(sUserModel.getResponse().getAccess_token(), illust.getId())
+// .subscribeOn(Schedulers.newThread())
+// .observeOn(AndroidSchedulers.mainThread())
+// .subscribe(new NullCtrl() {
+// @Override
+// public void success(ListIllust listIllust) {
+// if (listIllust.getIllusts() != null) {
+// final int realP = position + 1;
+// if (listIllust.getIllusts().size() >= 6) {
+// List related = new ArrayList<>();
+// for (int i = 0; i < 6; i++) {
+// related.add(listIllust.getIllusts().get(i));
+// }
+// allIllust.addAll(realP, related);
+// notifyItemRangeInserted(realP, related.size());
+// notifyItemRangeChanged(realP, allIllust.size() - realP);
+// }
+// }
+// }
+// });
+// }
@Override
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
diff --git a/app/src/main/java/ceui/lisa/adapters/IllustHeader.java b/app/src/main/java/ceui/lisa/adapters/IllustHeader.java
index 42d6140cf..56d08def8 100644
--- a/app/src/main/java/ceui/lisa/adapters/IllustHeader.java
+++ b/app/src/main/java/ceui/lisa/adapters/IllustHeader.java
@@ -6,21 +6,20 @@
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
-import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.PagerSnapHelper;
-import androidx.recyclerview.widget.RecyclerView;
+import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import ceui.lisa.activities.RankActivity;
-import ceui.lisa.activities.ViewPagerActivity;
-import ceui.lisa.adapters.RAdapter;
-import ceui.lisa.adapters.ViewHolder;
+import ceui.lisa.activities.VActivity;
+import ceui.lisa.core.PageData;
import ceui.lisa.databinding.RecyRecmdHeaderBinding;
import ceui.lisa.models.IllustsBean;
-import ceui.lisa.utils.DataChannel;
+import ceui.lisa.core.Container;
import ceui.lisa.utils.DensityUtil;
+import ceui.lisa.utils.Params;
import ceui.lisa.view.LinearItemHorizontalDecoration;
public class IllustHeader extends ViewHolder {
@@ -36,10 +35,21 @@ public void show(Context context, List illustsBeans) {
baseBind.topRela.startAnimation(animation);
RAdapter adapter = new RAdapter(illustsBeans, context);
adapter.setOnItemClickListener((v, position, viewType) -> {
- DataChannel.get().setIllustList(illustsBeans);
- Intent intent = new Intent(context, ViewPagerActivity.class);
- intent.putExtra("position", position);
+ final String uuid = UUID.randomUUID().toString();
+ final List tempList = new ArrayList<>(illustsBeans);
+ final PageData pageData = new PageData(uuid, tempList);
+ Container.get().addPage(pageData);
+
+ Intent intent = new Intent(context, VActivity.class);
+ intent.putExtra(Params.POSITION, position);
+ intent.putExtra(Params.PAGE_UUID, uuid);
context.startActivity(intent);
+
+
+// DataChannel.get().setIllustList(illustsBeans);
+// Intent intent = new Intent(context, ViewPagerActivity.class);
+// intent.putExtra("position", position);
+// context.startActivity(intent);
});
baseBind.ranking.setAdapter(adapter);
}
diff --git a/app/src/main/java/ceui/lisa/adapters/NovelHeader.java b/app/src/main/java/ceui/lisa/adapters/NovelHeader.java
index 4ebc42cd7..3bb7ee450 100644
--- a/app/src/main/java/ceui/lisa/adapters/NovelHeader.java
+++ b/app/src/main/java/ceui/lisa/adapters/NovelHeader.java
@@ -6,18 +6,14 @@
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
-import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import java.util.List;
import ceui.lisa.activities.RankActivity;
import ceui.lisa.activities.TemplateActivity;
-import ceui.lisa.activities.ViewPagerActivity;
import ceui.lisa.databinding.RecyRecmdHeaderBinding;
-import ceui.lisa.models.IllustsBean;
import ceui.lisa.models.NovelBean;
-import ceui.lisa.utils.DataChannel;
import ceui.lisa.utils.DensityUtil;
import ceui.lisa.utils.Params;
import ceui.lisa.view.LinearItemHorizontalDecoration;
diff --git a/app/src/main/java/ceui/lisa/core/Container.java b/app/src/main/java/ceui/lisa/core/Container.java
new file mode 100644
index 000000000..2c7527234
--- /dev/null
+++ b/app/src/main/java/ceui/lisa/core/Container.java
@@ -0,0 +1,63 @@
+package ceui.lisa.core;
+
+import android.text.TextUtils;
+
+import java.util.HashMap;
+
+import ceui.lisa.utils.Common;
+
+public class Container {
+
+ private HashMap pages = new HashMap<>();
+
+ public void addPage(PageData pageData) {
+ if (pageData == null) {
+ return;
+ }
+
+ if (TextUtils.isEmpty(pageData.getUuid())) {
+ return;
+ }
+
+ if (pages == null) {
+ pages = new HashMap<>();
+ }
+
+ pages.put(pageData.getUuid(), pageData);
+ Common.showLog("Container addPage " + pageData.getUuid());
+ }
+
+ public PageData getPage(String uuid) {
+ Common.showLog("Container getPage " + uuid);
+ if (TextUtils.isEmpty(uuid)) {
+ return null;
+ }
+
+ if (pages == null || pages.size() == 0) {
+ return null;
+ }
+
+ return pages.get(uuid);
+ }
+
+ public void clear() {
+ Common.showLog("Container clear ");
+ if (pages == null) {
+ pages = new HashMap<>();
+ return;
+ }
+ if (pages.size() != 0) {
+ pages.clear();
+ }
+ }
+
+ private Container(){}
+
+ private static class SingleTonHolder{
+ private static Container INSTANCE = new Container();
+ }
+
+ public static Container get(){
+ return SingleTonHolder.INSTANCE;
+ }
+}
diff --git a/app/src/main/java/ceui/lisa/core/PageData.java b/app/src/main/java/ceui/lisa/core/PageData.java
new file mode 100644
index 000000000..28b90aace
--- /dev/null
+++ b/app/src/main/java/ceui/lisa/core/PageData.java
@@ -0,0 +1,33 @@
+package ceui.lisa.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ceui.lisa.models.IllustsBean;
+
+public class PageData {
+
+ private String uuid = "";
+ private List illustList = new ArrayList<>();
+
+ public PageData(String uuid, List illustList) {
+ this.uuid = uuid;
+ this.illustList = illustList;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public List getIllustList() {
+ return illustList;
+ }
+
+ public void setIllustList(List illustList) {
+ this.illustList = illustList;
+ }
+}
diff --git a/app/src/main/java/ceui/lisa/fragments/FragmentEvent.java b/app/src/main/java/ceui/lisa/fragments/FragmentEvent.java
index b6ed887c5..d654f93c4 100644
--- a/app/src/main/java/ceui/lisa/fragments/FragmentEvent.java
+++ b/app/src/main/java/ceui/lisa/fragments/FragmentEvent.java
@@ -17,14 +17,19 @@
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
import ceui.lisa.R;
import ceui.lisa.activities.Shaft;
import ceui.lisa.activities.TemplateActivity;
import ceui.lisa.activities.UserActivity;
-import ceui.lisa.activities.ViewPagerActivity;
+import ceui.lisa.activities.VActivity;
import ceui.lisa.adapters.BaseAdapter;
import ceui.lisa.adapters.EventAdapter;
import ceui.lisa.adapters.IAdapter;
+import ceui.lisa.core.PageData;
import ceui.lisa.core.RemoteRepo;
import ceui.lisa.databinding.FragmentBaseListBinding;
import ceui.lisa.download.IllustDownload;
@@ -32,7 +37,7 @@
import ceui.lisa.interfaces.OnItemClickListener;
import ceui.lisa.model.ListIllust;
import ceui.lisa.models.IllustsBean;
-import ceui.lisa.utils.DataChannel;
+import ceui.lisa.core.Container;
import ceui.lisa.utils.Params;
import ceui.lisa.utils.PixivOperate;
import ceui.lisa.utils.ShareIllust;
@@ -52,10 +57,21 @@ public class FragmentEvent extends NetListFragment tempList = new ArrayList<>(allItems);
+ final PageData pageData = new PageData(uuid, tempList);
+ Container.get().addPage(pageData);
+
+ Intent intent = new Intent(mContext, VActivity.class);
+ intent.putExtra(Params.POSITION, position);
+ intent.putExtra(Params.PAGE_UUID, uuid);
+ mContext.startActivity(intent);
+
+
+// DataChannel.get().setIllustList(allItems);
+// Intent intent = new Intent(mContext, ViewPagerActivity.class);
+// intent.putExtra("position", position);
+// startActivity(intent);
} else if (viewType == 1) {
Intent intent = new Intent(mContext, UserActivity.class);
intent.putExtra(Params.USER_ID, allItems.get(position).getUser().getId());
diff --git a/app/src/main/java/ceui/lisa/fragments/FragmentHistory.java b/app/src/main/java/ceui/lisa/fragments/FragmentHistory.java
index afa578aed..01a2b7a23 100644
--- a/app/src/main/java/ceui/lisa/fragments/FragmentHistory.java
+++ b/app/src/main/java/ceui/lisa/fragments/FragmentHistory.java
@@ -8,16 +8,19 @@
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
+import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import ceui.lisa.R;
import ceui.lisa.activities.Shaft;
import ceui.lisa.activities.UserActivity;
-import ceui.lisa.activities.ViewPagerActivity;
+import ceui.lisa.activities.VActivity;
import ceui.lisa.adapters.BaseAdapter;
import ceui.lisa.adapters.HistoryAdapter;
import ceui.lisa.core.BaseRepo;
import ceui.lisa.core.LocalRepo;
+import ceui.lisa.core.PageData;
import ceui.lisa.database.AppDatabase;
import ceui.lisa.database.IllustHistoryEntity;
import ceui.lisa.databinding.FragmentBaseListBinding;
@@ -25,7 +28,7 @@
import ceui.lisa.interfaces.OnItemClickListener;
import ceui.lisa.models.IllustsBean;
import ceui.lisa.utils.Common;
-import ceui.lisa.utils.DataChannel;
+import ceui.lisa.core.Container;
import ceui.lisa.utils.Params;
import ceui.lisa.viewmodel.BaseModel;
import ceui.lisa.viewmodel.HistoryModel;
@@ -41,10 +44,21 @@ public BaseAdapter adapter() {
public void onItemClick(View v, int position, int viewType) {
Common.showLog(className + position + " " + allItems.size());
if (viewType == 0) {
- DataChannel.get().setIllustList(((HistoryModel)mModel).getAll());
- Intent intent = new Intent(mContext, ViewPagerActivity.class);
- intent.putExtra("position", position);
+ final String uuid = UUID.randomUUID().toString();
+ final List tempList = new ArrayList<>(((HistoryModel)mModel).getAll());
+ final PageData pageData = new PageData(uuid, tempList);
+ Container.get().addPage(pageData);
+
+ Intent intent = new Intent(mContext, VActivity.class);
+ intent.putExtra(Params.POSITION, position);
+ intent.putExtra(Params.PAGE_UUID, uuid);
mContext.startActivity(intent);
+
+
+// DataChannel.get().setIllustList(((HistoryModel)mModel).getAll());
+// Intent intent = new Intent(mContext, ViewPagerActivity.class);
+// intent.putExtra("position", position);
+// mContext.startActivity(intent);
} else if (viewType == 1) {
Intent intent = new Intent(mContext, UserActivity.class);
intent.putExtra(Params.USER_ID, (int) v.getTag());
diff --git a/app/src/main/java/ceui/lisa/fragments/FragmentIllust.java b/app/src/main/java/ceui/lisa/fragments/FragmentIllust.java
new file mode 100644
index 000000000..4373d7044
--- /dev/null
+++ b/app/src/main/java/ceui/lisa/fragments/FragmentIllust.java
@@ -0,0 +1,41 @@
+package ceui.lisa.fragments;
+
+import android.os.Bundle;
+import android.view.View;
+
+import ceui.lisa.R;
+import ceui.lisa.databinding.FragmentIllustBinding;
+import ceui.lisa.models.IllustsBean;
+import ceui.lisa.utils.Common;
+import ceui.lisa.utils.Params;
+
+public class FragmentIllust extends BaseFragment {
+
+ private IllustsBean illust;
+
+ public static FragmentIllust newInstance(IllustsBean illustsBean) {
+ Bundle args = new Bundle();
+ args.putSerializable(Params.CONTENT, illustsBean);
+ FragmentIllust fragment = new FragmentIllust();
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void initBundle(Bundle bundle) {
+ illust = (IllustsBean) bundle.getSerializable(Params.CONTENT);
+ }
+
+ @Override
+ public void initLayout() {
+ mLayoutID = R.layout.fragment_illust;
+ }
+
+ @Override
+ public void initView(View view) {
+ if (illust != null) {
+ baseBind.illustTitle.setText(illust.getTitle());
+ Common.showLog(className + illust.getTitle());
+ }
+ }
+}
diff --git a/app/src/main/java/ceui/lisa/fragments/FragmentImage.java b/app/src/main/java/ceui/lisa/fragments/FragmentImage.java
index ae95d31b4..ae4640302 100644
--- a/app/src/main/java/ceui/lisa/fragments/FragmentImage.java
+++ b/app/src/main/java/ceui/lisa/fragments/FragmentImage.java
@@ -6,13 +6,17 @@
import com.bumptech.glide.Glide;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
import ceui.lisa.R;
-import ceui.lisa.activities.ViewPagerActivity;
+import ceui.lisa.activities.VActivity;
+import ceui.lisa.core.PageData;
import ceui.lisa.databinding.FragmentImageBinding;
import ceui.lisa.models.IllustsBean;
-import ceui.lisa.utils.DataChannel;
+import ceui.lisa.core.Container;
import ceui.lisa.utils.GlideUtil;
import ceui.lisa.utils.Params;
@@ -49,10 +53,21 @@ public void initView(View view) {
baseBind.illustImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View pView) {
- DataChannel.get().setIllustList(Collections.singletonList(mIllustsBean));
- Intent intent = new Intent(mContext, ViewPagerActivity.class);
- intent.putExtra("position", 0);
- startActivity(intent);
+ final String uuid = UUID.randomUUID().toString();
+ final List tempList = new ArrayList<>(Collections.singletonList(mIllustsBean));
+ final PageData pageData = new PageData(uuid, tempList);
+ Container.get().addPage(pageData);
+
+ Intent intent = new Intent(mContext, VActivity.class);
+ intent.putExtra(Params.POSITION, 0);
+ intent.putExtra(Params.PAGE_UUID, uuid);
+ mContext.startActivity(intent);
+
+
+// DataChannel.get().setIllustList(Collections.singletonList(mIllustsBean));
+// Intent intent = new Intent(mContext, ViewPagerActivity.class);
+// intent.putExtra("position", 0);
+// startActivity(intent);
}
});
}
diff --git a/app/src/main/java/ceui/lisa/fragments/FragmentLikeIllustHorizontal.java b/app/src/main/java/ceui/lisa/fragments/FragmentLikeIllustHorizontal.java
index 633cc0b5e..f1283237c 100644
--- a/app/src/main/java/ceui/lisa/fragments/FragmentLikeIllustHorizontal.java
+++ b/app/src/main/java/ceui/lisa/fragments/FragmentLikeIllustHorizontal.java
@@ -12,11 +12,13 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import ceui.lisa.R;
import ceui.lisa.activities.TemplateActivity;
-import ceui.lisa.activities.ViewPagerActivity;
+import ceui.lisa.activities.VActivity;
import ceui.lisa.adapters.LAdapter;
+import ceui.lisa.core.PageData;
import ceui.lisa.databinding.FragmentLikeIllustHorizontalBinding;
import ceui.lisa.http.NullCtrl;
import ceui.lisa.http.Retro;
@@ -24,7 +26,7 @@
import ceui.lisa.model.ListIllust;
import ceui.lisa.models.IllustsBean;
import ceui.lisa.models.UserDetailResponse;
-import ceui.lisa.utils.DataChannel;
+import ceui.lisa.core.Container;
import ceui.lisa.utils.DensityUtil;
import ceui.lisa.utils.Params;
import ceui.lisa.view.LinearItemHorizontalDecoration;
@@ -88,10 +90,20 @@ public void initView(View view) {
mAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(View v, int position, int viewType) {
- DataChannel.get().setIllustList(allItems);
- Intent intent = new Intent(mContext, ViewPagerActivity.class);
- intent.putExtra("position", position);
- startActivity(intent);
+ final String uuid = UUID.randomUUID().toString();
+ final List tempList = new ArrayList<>(allItems);
+ final PageData pageData = new PageData(uuid, tempList);
+ Container.get().addPage(pageData);
+
+ Intent intent = new Intent(mContext, VActivity.class);
+ intent.putExtra(Params.POSITION, position);
+ intent.putExtra(Params.PAGE_UUID, uuid);
+ mContext.startActivity(intent);
+
+// DataChannel.get().setIllustList(allItems);
+// Intent intent = new Intent(mContext, ViewPagerActivity.class);
+// intent.putExtra("position", position);
+// startActivity(intent);
}
});
baseBind.recyclerView.setAdapter(mAdapter);
diff --git a/app/src/main/java/ceui/lisa/fragments/FragmentMultiDownld.java b/app/src/main/java/ceui/lisa/fragments/FragmentMultiDownld.java
index 8414005ed..0a29c8847 100644
--- a/app/src/main/java/ceui/lisa/fragments/FragmentMultiDownld.java
+++ b/app/src/main/java/ceui/lisa/fragments/FragmentMultiDownld.java
@@ -9,14 +9,17 @@
import androidx.recyclerview.widget.GridLayoutManager;
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import ceui.lisa.R;
-import ceui.lisa.activities.ViewPagerActivity;
+import ceui.lisa.activities.VActivity;
import ceui.lisa.adapters.BaseAdapter;
import ceui.lisa.adapters.MultiDownldAdapter;
import ceui.lisa.core.BaseRepo;
import ceui.lisa.core.LocalRepo;
+import ceui.lisa.core.PageData;
import ceui.lisa.databinding.FragmentMultiDownloadBinding;
import ceui.lisa.databinding.RecyMultiDownloadBinding;
import ceui.lisa.download.IllustDownload;
@@ -25,9 +28,11 @@
import ceui.lisa.interfaces.OnItemClickListener;
import ceui.lisa.models.IllustsBean;
import ceui.lisa.utils.Common;
+import ceui.lisa.core.Container;
import ceui.lisa.utils.DataChannel;
import ceui.lisa.utils.DensityUtil;
import ceui.lisa.utils.Dev;
+import ceui.lisa.utils.Params;
import ceui.lisa.view.DownloadItemDecoration;
import gdut.bsx.share2.FileUtil;
import gdut.bsx.share2.Share2;
@@ -119,10 +124,20 @@ public BaseAdapter adapter() {
adapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(View v, int position, int viewType) {
- DataChannel.get().setIllustList(allItems);
- Intent intent = new Intent(mContext, ViewPagerActivity.class);
- intent.putExtra("position", position);
- startActivity(intent);
+ final String uuid = UUID.randomUUID().toString();
+ final List tempList = new ArrayList<>(allItems);
+ final PageData pageData = new PageData(uuid, tempList);
+ Container.get().addPage(pageData);
+
+ Intent intent = new Intent(mContext, VActivity.class);
+ intent.putExtra(Params.POSITION, position);
+ intent.putExtra(Params.PAGE_UUID, uuid);
+ mContext.startActivity(intent);
+
+// DataChannel.get().setIllustList(allItems);
+// Intent intent = new Intent(mContext, ViewPagerActivity.class);
+// intent.putExtra("position", position);
+// startActivity(intent);
}
});
adapter.setCallback(new Callback() {
diff --git a/app/src/main/java/ceui/lisa/fragments/FragmentSingleIllust2.java b/app/src/main/java/ceui/lisa/fragments/FragmentSingleIllust2.java
new file mode 100644
index 000000000..eb47abf16
--- /dev/null
+++ b/app/src/main/java/ceui/lisa/fragments/FragmentSingleIllust2.java
@@ -0,0 +1,457 @@
+package ceui.lisa.fragments;
+
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.TextUtils;
+import android.text.style.ForegroundColorSpan;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.appcompat.widget.Toolbar;
+import androidx.core.app.ActivityOptionsCompat;
+import androidx.lifecycle.ViewModelProvider;
+
+import com.bumptech.glide.Glide;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.scwang.smartrefresh.layout.footer.FalsifyFooter;
+import com.scwang.smartrefresh.layout.header.FalsifyHeader;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import ceui.lisa.R;
+import ceui.lisa.activities.ImageDetailActivity;
+import ceui.lisa.activities.SearchActivity;
+import ceui.lisa.activities.Shaft;
+import ceui.lisa.activities.TemplateActivity;
+import ceui.lisa.activities.UserActivity;
+import ceui.lisa.adapters.IllustDetailAdapter;
+import ceui.lisa.databinding.FragmentSingleIllustBinding;
+import ceui.lisa.dialogs.MuteDialog;
+import ceui.lisa.download.FileCreator;
+import ceui.lisa.download.GifCreate;
+import ceui.lisa.download.IllustDownload;
+import ceui.lisa.interfaces.OnItemClickListener;
+import ceui.lisa.models.IllustsBean;
+import ceui.lisa.utils.Channel;
+import ceui.lisa.utils.Common;
+import ceui.lisa.utils.DensityUtil;
+import ceui.lisa.utils.GlideUtil;
+import ceui.lisa.utils.Params;
+import ceui.lisa.utils.PixivOperate;
+import ceui.lisa.utils.ShareIllust;
+import ceui.lisa.view.LinearItemDecorationNoLRTB;
+import ceui.lisa.view.ScrollChange;
+import ceui.lisa.viewmodel.Dust;
+import jp.wasabeef.glide.transformations.BlurTransformation;
+import me.next.tagview.TagCloudView;
+
+import static ceui.lisa.activities.Shaft.sUserModel;
+import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
+import static com.bumptech.glide.request.RequestOptions.bitmapTransform;
+
+/**
+ * 插画详情
+ */
+public class FragmentSingleIllust2 extends BaseFragment {
+
+ private IllustsBean illust;
+ private IllustDetailAdapter mDetailAdapter;
+
+ public static FragmentSingleIllust2 newInstance(IllustsBean illust) {
+ Bundle args = new Bundle();
+ args.putSerializable(Params.CONTENT, illust);
+ FragmentSingleIllust2 fragment = new FragmentSingleIllust2();
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void initBundle(Bundle bundle) {
+ illust = (IllustsBean) bundle.getSerializable(Params.CONTENT);
+ }
+
+ @Override
+ public void initLayout() {
+ mLayoutID = R.layout.fragment_single_illust;
+ }
+
+ private void loadImage() {
+ int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+ switch (currentNightMode) {
+ case Configuration.UI_MODE_NIGHT_NO:
+ case Configuration.UI_MODE_NIGHT_UNDEFINED:
+ Glide.with(mContext)
+ .load(GlideUtil.getSquare(illust))
+ .apply(bitmapTransform(new BlurTransformation(25, 3)))
+ .transition(withCrossFade())
+ .into(baseBind.bgImage);
+ break;
+ case Configuration.UI_MODE_NIGHT_YES:
+ baseBind.bgImage.setImageResource(R.color.black);
+ break;
+ }
+
+
+ mDetailAdapter = new IllustDetailAdapter(illust, mActivity);
+ mDetailAdapter.setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(View v, int position, int viewType) {
+ if (viewType == 0) {
+ Intent intent = new Intent(mContext, ImageDetailActivity.class);
+ intent.putExtra("illust", illust);
+ intent.putExtra("dataType", "二级详情");
+ intent.putExtra("index", position);
+ if (Shaft.sSettings.isFirstImageSize()) {
+ mActivity.startActivity(intent);
+ } else {
+ if (mDetailAdapter.getHasLoad().get(position)) {
+ Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(mActivity,
+ v, "big_image_" + position).toBundle();
+ startActivity(intent, bundle);
+ } else {
+ mActivity.startActivity(intent);
+ }
+ }
+ } else if (viewType == 1) {
+
+ }
+ }
+ });
+ baseBind.recyclerView.setAdapter(mDetailAdapter);
+ }
+
+ @Override
+ void initData() {
+ if (illust != null) {
+ loadImage();
+ }
+ }
+
+ @Override
+ public void initView(View view) {
+ if (illust == null || illust.getId() == 0) {
+ return;
+ }
+
+ baseBind.refreshLayout.setEnableLoadMore(true);
+ baseBind.refreshLayout.setRefreshHeader(new FalsifyHeader(mContext));
+ baseBind.refreshLayout.setRefreshFooter(new FalsifyFooter(mContext));
+ baseBind.toolbar.setTitle(illust.getTitle() + " ");
+ baseBind.toolbar.setNavigationOnClickListener(v -> mActivity.finish());
+
+ baseBind.toolbar.inflateMenu(R.menu.share);
+ baseBind.toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem menuItem) {
+ if (menuItem.getItemId() == R.id.action_share) {
+ new ShareIllust(mContext, illust) {
+ @Override
+ public void onPrepare() {
+
+ }
+ }.execute();
+ return true;
+ } else if (menuItem.getItemId() == R.id.action_dislike) {
+ MuteDialog muteDialog = MuteDialog.newInstance(illust);
+ muteDialog.show(getChildFragmentManager(), "MuteDialog");
+ } else if (menuItem.getItemId() == R.id.action_preview) {
+ Intent intent = new Intent(mContext, TemplateActivity.class);
+ intent.putExtra(TemplateActivity.EXTRA_FRAGMENT, "开发者预览");
+ startActivity(intent);
+ }
+ return false;
+ }
+ });
+
+ baseBind.download.setOnClickListener(v -> {
+ if (illust.isGif()) {
+ GifCreate.createGif(illust);
+ } else {
+ if (illust.getPage_count() == 1) {
+ IllustDownload.downloadIllust(mActivity, illust);
+ } else {
+ IllustDownload.downloadAllIllust(mActivity, illust);
+ }
+ }
+ });
+ File file = FileCreator.createIllustFile(illust);
+ if (file.exists()) {
+ baseBind.download.setImageResource(R.drawable.ic_has_download);
+ }
+ baseBind.userName.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ Common.copy(mContext, String.valueOf(illust.getUser().getName()));
+ return true;
+ }
+ });
+ baseBind.related.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(mContext, TemplateActivity.class);
+ intent.putExtra(TemplateActivity.EXTRA_FRAGMENT, "相关作品");
+ intent.putExtra(Params.ILLUST_ID, illust.getId());
+ intent.putExtra(Params.ILLUST_TITLE, illust.getTitle());
+ startActivity(intent);
+ }
+ });
+ baseBind.comment.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(mContext, TemplateActivity.class);
+ intent.putExtra(TemplateActivity.EXTRA_FRAGMENT, "相关评论");
+ intent.putExtra(Params.ILLUST_ID, illust.getId());
+ intent.putExtra(Params.ILLUST_TITLE, illust.getTitle());
+ startActivity(intent);
+ }
+ });
+ baseBind.illustLike.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Intent intent = new Intent(mContext, TemplateActivity.class);
+ intent.putExtra(Params.CONTENT, illust);
+ intent.putExtra(TemplateActivity.EXTRA_FRAGMENT, "喜欢这个作品的用户");
+ startActivity(intent);
+ }
+ });
+ if (illust.isIs_bookmarked()) {
+ baseBind.postLike.setImageResource(R.drawable.ic_favorite_accent_24dp);
+ } else {
+ baseBind.postLike.setImageResource(R.drawable.ic_favorite_black_24dp);
+ }
+ baseBind.postLike.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (illust.isIs_bookmarked()) {
+ baseBind.postLike.setImageResource(R.drawable.ic_favorite_black_24dp);
+ } else {
+ baseBind.postLike.setImageResource(R.drawable.ic_favorite_accent_24dp);
+ }
+ PixivOperate.postLike(illust, sUserModel, FragmentLikeIllust.TYPE_PUBLUC);
+ }
+ });
+ baseBind.postLike.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ if (!illust.isIs_bookmarked()) {
+ Intent intent = new Intent(mContext, TemplateActivity.class);
+ intent.putExtra(Params.ILLUST_ID, illust.getId());
+ intent.putExtra(TemplateActivity.EXTRA_FRAGMENT, "按标签收藏");
+ startActivity(intent);
+ }
+ return true;
+ }
+ });
+ baseBind.userHead.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(mContext, UserActivity.class);
+ intent.putExtra(Params.USER_ID, illust.getUser().getId());
+ startActivity(intent);
+ }
+ });
+ baseBind.userName.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(mContext, UserActivity.class);
+ intent.putExtra(Params.USER_ID, illust.getUser().getId());
+ startActivity(intent);
+ }
+ });
+
+ baseBind.follow.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (illust.getUser().isIs_followed()) {
+ baseBind.follow.setText("+ 关注");
+ PixivOperate.postUnFollowUser(illust.getUser().getId());
+ illust.getUser().setIs_followed(false);
+ } else {
+ baseBind.follow.setText("取消关注");
+ PixivOperate.postFollowUser(illust.getUser().getId(), FragmentLikeIllust.TYPE_PUBLUC);
+ illust.getUser().setIs_followed(true);
+ }
+ }
+ });
+
+ baseBind.follow.setOnLongClickListener(v1 -> {
+ if (illust.getUser().isIs_followed()) {
+
+ } else {
+ baseBind.follow.setText("取消关注");
+ illust.getUser().setIs_followed(true);
+ PixivOperate.postFollowUser(illust.getUser().getId(), FragmentLikeIllust.TYPE_PRIVATE);
+ }
+ return true;
+ });
+
+ Glide.with(mContext)
+ .load(GlideUtil.getMediumImg(illust.getUser().getProfile_image_urls().getMedium()))
+ .into(baseBind.userHead);
+
+ baseBind.userName.setText(illust.getUser().getName());
+
+ SpannableString sizeString = new SpannableString(String.format("尺寸:%s",
+ illust.getSize()));
+ sizeString.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.colorPrimary)),
+ 3, illust.getSize().length() + 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ baseBind.illustPx.setText(sizeString);
+ List tags = new ArrayList<>();
+ for (int i = 0; i < illust.getTags().size(); i++) {
+ String temp = illust.getTags().get(i).getName();
+ if (!TextUtils.isEmpty(illust.getTags().get(i).getTranslated_name())) {
+ temp = temp + "/" + illust.getTags().get(i).getTranslated_name();
+ }
+ tags.add(temp);
+ }
+ baseBind.illustTag.setOnTagClickListener(new TagCloudView.OnTagClickListener() {
+ @Override
+ public void onTagClick(int position) {
+ Intent intent = new Intent(mContext, SearchActivity.class);
+ intent.putExtra(Params.KEY_WORD, illust.getTags().get(position).getName());
+ intent.putExtra(Params.INDEX, 0);
+ startActivity(intent);
+ }
+ });
+ baseBind.illustTag.setTags(tags);
+ if (!TextUtils.isEmpty(illust.getCaption())) {
+ baseBind.description.setVisibility(View.VISIBLE);
+ baseBind.description.setHtml(illust.getCaption());
+ } else {
+ baseBind.description.setVisibility(View.GONE);
+ }
+ baseBind.illustDate.setText(illust.getCreate_date().substring(0, 16));
+ baseBind.illustView.setText(String.valueOf(illust.getTotal_view()));
+ baseBind.illustLike.setText(String.valueOf(illust.getTotal_bookmarks()));
+
+ ScrollChange layoutManager = new ScrollChange(mContext);
+ baseBind.recyclerView.setLayoutManager(layoutManager);
+ baseBind.recyclerView.setNestedScrollingEnabled(true);
+ baseBind.recyclerView.addItemDecoration(new LinearItemDecorationNoLRTB(DensityUtil.dp2px(1.0f)));
+
+ if (illust.getUser().isIs_followed()) {
+ baseBind.follow.setText("取消关注");
+ } else {
+ baseBind.follow.setText("+ 关注");
+ }
+
+
+ SpannableString userString = new SpannableString(String.format("用户ID:%s",
+ String.valueOf(illust.getUser().getId())));
+ userString.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.colorPrimary)),
+ 5, String.valueOf(illust.getUser().getId()).length() + 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ baseBind.userId.setText(userString);
+ baseBind.userId.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Common.copy(mContext, String.valueOf(illust.getUser().getId()));
+ }
+ });
+ SpannableString illustString = new SpannableString(String.format("作品ID:%s",
+ String.valueOf(illust.getId())));
+ illustString.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.colorPrimary)),
+ 5, String.valueOf(illust.getId()).length() + 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ baseBind.illustId.setText(illustString);
+ baseBind.illustId.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Common.copy(mContext, String.valueOf(illust.getId()));
+ }
+ });
+ if (illust.getPage_count() == 1) {
+ baseBind.pSize.setVisibility(View.GONE);
+ baseBind.darkBlank.setVisibility(View.INVISIBLE);
+ baseBind.seeAll.setVisibility(View.INVISIBLE);
+ baseBind.illustList.open();
+ } else {
+ baseBind.pSize.setVisibility(View.VISIBLE);
+ baseBind.pSize.setText(illust.getPage_count() + "P");
+ baseBind.darkBlank.setVisibility(View.VISIBLE);
+ baseBind.seeAll.setVisibility(View.VISIBLE);
+ baseBind.illustList.close();
+ baseBind.seeAll.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (baseBind.illustList.isExpand()) {
+ baseBind.illustList.close();
+ baseBind.seeAll.setText("点击展开");
+ } else {
+ baseBind.illustList.open();
+ baseBind.seeAll.setText("点击折叠");
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ //如果是GIF,停止播放
+ if (illust != null && "ugoira".equals(illust.getType()) && mDetailAdapter != null) {
+ mDetailAdapter.nowStopGif();
+ }
+ }
+
+ @Override
+ public void vertical() {
+ //竖屏
+ ViewGroup.LayoutParams headParams = baseBind.head.getLayoutParams();
+ headParams.height = Shaft.statusHeight + Shaft.toolbarHeight;
+ baseBind.head.setLayoutParams(headParams);
+ baseBind.toolbar.setPadding(0, Shaft.statusHeight, 0, 0);
+ }
+
+ @Override
+ public void horizon() {
+ //横屏
+ ViewGroup.LayoutParams headParams = baseBind.head.getLayoutParams();
+ headParams.height = Shaft.statusHeight * 3 / 5 + Shaft.toolbarHeight;
+ baseBind.head.setLayoutParams(headParams);
+ }
+
+ @Override
+ public void setUserVisibleHint(boolean isVisibleToUser) {
+ super.setUserVisibleHint(isVisibleToUser);
+ if (illust != null) {
+ if (isVisibleToUser) {
+ if ("ugoira".equals(illust.getType()) && mDetailAdapter != null) {
+ mDetailAdapter.nowPlayGif();
+ }
+ } else {
+ if ("ugoira".equals(illust.getType()) && mDetailAdapter != null) {
+ mDetailAdapter.nowStopGif();
+ }
+ }
+ }
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onMessageEvent(Channel event) {
+ if (event.getReceiver().contains("FragmentSingleIllust starIllust")) {
+ illust.setIs_bookmarked(true);
+ ((FloatingActionButton) parentView.findViewById(R.id.post_like))
+ .setImageResource(R.drawable.ic_favorite_accent_24dp);
+ }
+
+ if (event.getReceiver().equals("FragmentSingleIllust download finish")) {
+ if ((int) event.getObject() == illust.getId()) {
+ baseBind.download.setImageResource(R.drawable.ic_has_download);
+ }
+ }
+ }
+
+ @Override
+ public boolean eventBusEnable() {
+ return true;
+ }
+}
diff --git a/app/src/main/java/ceui/lisa/utils/Params.java b/app/src/main/java/ceui/lisa/utils/Params.java
index eb25533c9..8dc1e2418 100644
--- a/app/src/main/java/ceui/lisa/utils/Params.java
+++ b/app/src/main/java/ceui/lisa/utils/Params.java
@@ -34,6 +34,8 @@ public class Params {
public static final String NOVEL_KEY = "pixiv_shaft_novel_";
public static final String USER_KEY = "pixiv_shaft_local_user";
public static final String SECRET_PWD_KEY= "pixiv_secret_password:";
+ public static final String PAGE_UUID = "page_uuid";
+ public static final String POSITION = "position";
public static final String IMAGE_UNKNOWN = "https://s.pximg.net/common/images/limit_unknown_360.png";
public static final String HEAD_UNKNOWN = "https://s.pximg.net/common/images/no_profile.png";
diff --git a/app/src/main/java/ceui/lisa/utils/PixivOperate.java b/app/src/main/java/ceui/lisa/utils/PixivOperate.java
index 754e4a0a4..7dd100f09 100644
--- a/app/src/main/java/ceui/lisa/utils/PixivOperate.java
+++ b/app/src/main/java/ceui/lisa/utils/PixivOperate.java
@@ -7,11 +7,15 @@
import android.widget.Button;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.UUID;
import ceui.lisa.R;
import ceui.lisa.activities.Shaft;
-import ceui.lisa.activities.ViewPagerActivity;
+import ceui.lisa.activities.VActivity;
+import ceui.lisa.core.Container;
+import ceui.lisa.core.PageData;
import ceui.lisa.database.AppDatabase;
import ceui.lisa.database.IllustHistoryEntity;
import ceui.lisa.database.SearchEntity;
@@ -157,12 +161,25 @@ public static void getIllustByID(UserModel userModel, int illustID, Context cont
public void onNext(IllustSearchResponse illustSearchResponse) {
if (illustSearchResponse != null) {
if (illustSearchResponse.getIllust() != null) {
- List tempList = new ArrayList<>();
- tempList.add(illustSearchResponse.getIllust());
- DataChannel.get().setIllustList(tempList);
- Intent intent = new Intent(context, ViewPagerActivity.class);
- intent.putExtra("position", 0);
+ final String uuid = UUID.randomUUID().toString();
+ final List tempList = new ArrayList<>(
+ Collections.singletonList(illustSearchResponse.getIllust())
+ );
+ final PageData pageData = new PageData(uuid, tempList);
+ Container.get().addPage(pageData);
+
+ Intent intent = new Intent(context, VActivity.class);
+ intent.putExtra(Params.POSITION, 0);
+ intent.putExtra(Params.PAGE_UUID, uuid);
context.startActivity(intent);
+
+
+// List tempList = new ArrayList<>();
+// tempList.add(illustSearchResponse.getIllust());
+// DataChannel.get().setIllustList(tempList);
+// Intent intent = new Intent(context, ViewPagerActivity.class);
+// intent.putExtra("position", 0);
+// context.startActivity(intent);
} else {
Common.showToast("illustSearchResponse.getIllust() 为空");
}
@@ -183,12 +200,25 @@ public static void getIllustByID(UserModel userModel, int illustID, Context cont
public void onNext(IllustSearchResponse illustSearchResponse) {
if (illustSearchResponse != null) {
if (illustSearchResponse.getIllust() != null) {
- List tempList = new ArrayList<>();
- tempList.add(illustSearchResponse.getIllust());
- DataChannel.get().setIllustList(tempList);
- Intent intent = new Intent(context, ViewPagerActivity.class);
- intent.putExtra("position", 0);
+ final String uuid = UUID.randomUUID().toString();
+ final List tempList = Collections.singletonList(
+ illustSearchResponse.getIllust()
+ );
+ final PageData pageData = new PageData(uuid, tempList);
+ Container.get().addPage(pageData);
+
+ Intent intent = new Intent(context, VActivity.class);
+ intent.putExtra(Params.POSITION, 0);
+ intent.putExtra(Params.PAGE_UUID, uuid);
context.startActivity(intent);
+
+
+// List tempList = new ArrayList<>();
+// tempList.add(illustSearchResponse.getIllust());
+// DataChannel.get().setIllustList(tempList);
+// Intent intent = new Intent(context, ViewPagerActivity.class);
+// intent.putExtra("position", 0);
+// context.startActivity(intent);
if (callback != null) {
callback.doSomething(null);
}
diff --git a/app/src/main/res/layout/activity_view_pager.xml b/app/src/main/res/layout/activity_view_pager.xml
index 7b5b27f65..a26e84224 100644
--- a/app/src/main/res/layout/activity_view_pager.xml
+++ b/app/src/main/res/layout/activity_view_pager.xml
@@ -1,6 +1,5 @@
-
+
diff --git a/app/src/main/res/layout/fragment_illust.xml b/app/src/main/res/layout/fragment_illust.xml
index 133b4ef6f..b36fc4875 100644
--- a/app/src/main/res/layout/fragment_illust.xml
+++ b/app/src/main/res/layout/fragment_illust.xml
@@ -10,34 +10,17 @@
android:layout_height="match_parent">
-
+
-
+
-
-
-
-
-
-
-
-
-