diff --git a/app/src/main/java/ceui/lisa/activities/ImageDetailActivity.java b/app/src/main/java/ceui/lisa/activities/ImageDetailActivity.java index fc119db50..446873356 100644 --- a/app/src/main/java/ceui/lisa/activities/ImageDetailActivity.java +++ b/app/src/main/java/ceui/lisa/activities/ImageDetailActivity.java @@ -21,9 +21,7 @@ import ceui.lisa.helper.PageTransformerHelper; import ceui.lisa.models.IllustsBean; import ceui.lisa.utils.Common; -import ceui.lisa.utils.Params; import ceui.lisa.utils.PixivOperate; -import ceui.loxia.ImageFragment; /** * 图片二级详情 @@ -57,11 +55,7 @@ protected void initView() { baseBind.viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int i) { - if (mIllustsBean.getPage_count() > 1) { - return ImageFragment.Companion.newInstance(mIllustsBean.getMeta_pages().get(i).getImage_urls().getMaxImage()); - } else { - return ImageFragment.Companion.newInstance(mIllustsBean.getMeta_single_page().getOriginal()); - } + return FragmentImageDetail.newInstance(mIllustsBean, i); } @Override diff --git a/app/src/main/java/ceui/lisa/activities/MainActivity.java b/app/src/main/java/ceui/lisa/activities/MainActivity.java index 4d0f77706..5cea5da6a 100644 --- a/app/src/main/java/ceui/lisa/activities/MainActivity.java +++ b/app/src/main/java/ceui/lisa/activities/MainActivity.java @@ -442,11 +442,6 @@ protected void onResume() { initDrawerHeader(); Dev.refreshUser = false; } - - if (Dev.isDev) { - Intent intent = new Intent(mContext, NavActivity.class); - startActivity(intent); - } } @Override diff --git a/app/src/main/java/ceui/lisa/activities/TemplateActivity.java b/app/src/main/java/ceui/lisa/activities/TemplateActivity.java index 33505ead2..40e132963 100644 --- a/app/src/main/java/ceui/lisa/activities/TemplateActivity.java +++ b/app/src/main/java/ceui/lisa/activities/TemplateActivity.java @@ -77,7 +77,6 @@ import ceui.lisa.utils.Local; import ceui.lisa.utils.Params; import ceui.lisa.utils.ReverseResult; -import ceui.loxia.ImageFragment; public class TemplateActivity extends BaseActivity implements ColorPickerDialogListener { @@ -199,7 +198,7 @@ protected Fragment createNewFragment() { case "小说详情": return FragmentNovelHolder.newInstance((NovelBean) intent.getSerializableExtra(Params.CONTENT)); case "图片详情": - return ImageFragment.Companion.newInstance(intent.getStringExtra(Params.URL)); + return FragmentImageDetail.newInstance(intent.getStringExtra(Params.URL)); case "绑定邮箱": return new FragmentEditAccount(); case "编辑个人资料": diff --git a/app/src/main/java/ceui/lisa/activities/VActivity.java b/app/src/main/java/ceui/lisa/activities/VActivity.java index ddb7518b3..dd02bc85d 100644 --- a/app/src/main/java/ceui/lisa/activities/VActivity.java +++ b/app/src/main/java/ceui/lisa/activities/VActivity.java @@ -29,7 +29,6 @@ import ceui.lisa.utils.Common; import ceui.lisa.utils.Params; import ceui.lisa.utils.PixivOperate; -import ceui.loxia.ImageFragment; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; @@ -60,7 +59,7 @@ protected void initView() { public Fragment getItem(int position) { IllustsBean illustsBean = pageData.getList().get(position); if (illustsBean.getId() == 0 || !illustsBean.isVisible()) { - return ImageFragment.Companion.newInstance(illustsBean.getImage_urls().getMaxImage()); + return FragmentImageDetail.newInstance(illustsBean.getImage_urls().getMaxImage()); } else if (illustsBean.isGif()) { return FragmentSingleUgora.newInstance(illustsBean); } else { diff --git a/app/src/main/java/ceui/lisa/fragments/FragmentImageDetail.java b/app/src/main/java/ceui/lisa/fragments/FragmentImageDetail.java index 080982630..e373a98fa 100644 --- a/app/src/main/java/ceui/lisa/fragments/FragmentImageDetail.java +++ b/app/src/main/java/ceui/lisa/fragments/FragmentImageDetail.java @@ -15,6 +15,8 @@ import com.bumptech.glide.request.target.CustomViewTarget; import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.transition.Transition; +import com.davemorrissey.labs.subscaleview.ImageSource; +import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; import java.io.File; @@ -72,31 +74,32 @@ public void initLayout() { @Override protected void initView() { - baseBind.realIllustImage.setOnBitmapLoadListener(new OnBitmapLoadListener() { - @Override - public void onBitmapLoadReady() { - - } - - @Override - public void onBitmapLoaded(int width, int height) { - imageWidth = width; - imageHeight = height; - } - - @Override - public void onBitmapLoadError(Exception e) { - - } - }); - - baseBind.realIllustImage.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { - @Override - public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { - adjustAutoScale(); - } - }); - +// baseBind.realIllustImage.setOnBitmapLoadListener(new OnBitmapLoadListener() { +// @Override +// public void onBitmapLoadReady() { +// +// } +// +// @Override +// public void onBitmapLoaded(int width, int height) { +// imageWidth = width; +// imageHeight = height; +// } +// +// @Override +// public void onBitmapLoadError(Exception e) { +// +// } +// }); +// +// baseBind.realIllustImage.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { +// @Override +// public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { +// adjustAutoScale(); +// } +// }); + baseBind.emptyActionButton.setOnClickListener(v -> loadImage()); + baseBind.bigImage.setDoubleTapZoomDuration(250); //插画二级详情保持屏幕常亮 if (Shaft.sSettings.isIllustDetailKeepScreenOn()) { baseBind.getRoot().setKeepScreenOn(true); @@ -109,6 +112,8 @@ protected void initData() { } private void loadImage() { + baseBind.emptyFrame.setVisibility(View.GONE); + baseBind.progressLayout.getRoot().setVisibility(View.VISIBLE); String imageUrl; if (mIllustsBean == null && !TextUtils.isEmpty(url)) { imageUrl = url; @@ -121,8 +126,12 @@ private void loadImage() { imageUrl = url; } else { if (Shaft.sSettings.isShowOriginalImage()) { + baseBind.bigImage.setMaxScale(4F); + baseBind.bigImage.setDoubleTapZoomScale(2F); imageUrl = IllustDownload.getUrl(mIllustsBean, index, Params.IMAGE_RESOLUTION_ORIGINAL); } else { + baseBind.bigImage.setMaxScale(8F); + baseBind.bigImage.setDoubleTapZoomScale(4F); imageUrl = IllustDownload.getUrl(mIllustsBean, index, Params.IMAGE_RESOLUTION_LARGE); } } @@ -145,25 +154,30 @@ public void onError(long id, Exception e) { .listener(new RequestListener() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - baseBind.progressLayout.donutProgress.setVisibility(View.INVISIBLE); + baseBind.progressLayout.getRoot().setVisibility(View.GONE); + baseBind.emptyFrame.setVisibility(View.VISIBLE); + if (e != null) { + baseBind.emptyTitle.setText(e.getMessage()); + } return false; } @Override public boolean onResourceReady(File resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - baseBind.progressLayout.donutProgress.setVisibility(View.INVISIBLE); + baseBind.progressLayout.getRoot().setVisibility(View.GONE); + baseBind.emptyFrame.setVisibility(View.GONE); Common.showLog("onResourceReady " + resource.getPath()); return false; } }) - .into(new CustomViewTarget(baseBind.realIllustImage) { + .into(new CustomViewTarget(baseBind.bigImage) { @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { } @Override public void onResourceReady(@NonNull File resource, @Nullable Transition transition) { - view.setImageURI(Uri.fromFile(resource)); + baseBind.bigImage.setImage(ImageSource.uri(Uri.fromFile(resource))); } @Override @@ -179,27 +193,27 @@ public void onSaveInstanceState(@NonNull Bundle outState) { outState.putInt("index", index); } - public void adjustAutoScale() { - if (imageWidth <= 0 || imageHeight <= 0) { - return; - } - - int viewWidth = baseBind.realIllustImage.getWidth(); - int viewHeight = baseBind.realIllustImage.getHeight(); - - float scale_w = (float) imageWidth / viewWidth; - float scale_h = (float) imageHeight / viewHeight; - - float scale_init_inner = Math.min(viewWidth / (float) imageWidth, viewHeight / (float) imageHeight); // 内部处理后的初始Scale,minScale() - float scale_init_side = Math.max(scale_w, scale_h); // 初始scale 此时吸附scale较大的一边 - float scale_max = scale_init_inner * scale_init_side; // 最大scale,显示原图级别 - float scale_other_side = scale_max / Math.min(scale_w, scale_h); // 目标scale,吸附另一边 - - if (scale_w > 1.0f && scale_h > 1.0f) { - baseBind.realIllustImage.setMaxScale(scale_max); - } else { - baseBind.realIllustImage.setMaxScale(scale_other_side); - } - baseBind.realIllustImage.setDoubleTapZoomScale(scale_other_side); - } +// public void adjustAutoScale() { +// if (imageWidth <= 0 || imageHeight <= 0) { +// return; +// } +// +// int viewWidth = baseBind.realIllustImage.getWidth(); +// int viewHeight = baseBind.realIllustImage.getHeight(); +// +// float scale_w = (float) imageWidth / viewWidth; +// float scale_h = (float) imageHeight / viewHeight; +// +// float scale_init_inner = Math.min(viewWidth / (float) imageWidth, viewHeight / (float) imageHeight); // 内部处理后的初始Scale,minScale() +// float scale_init_side = Math.max(scale_w, scale_h); // 初始scale 此时吸附scale较大的一边 +// float scale_max = scale_init_inner * scale_init_side; // 最大scale,显示原图级别 +// float scale_other_side = scale_max / Math.min(scale_w, scale_h); // 目标scale,吸附另一边 +// +// if (scale_w > 1.0f && scale_h > 1.0f) { +// baseBind.realIllustImage.setMaxScale(scale_max); +// } else { +// baseBind.realIllustImage.setMaxScale(scale_other_side); +// } +// baseBind.realIllustImage.setDoubleTapZoomScale(scale_other_side); +// } } diff --git a/app/src/main/java/ceui/loxia/ImageFragment.kt b/app/src/main/java/ceui/loxia/ImageFragment.kt index 5266a5b5c..8999ff50c 100644 --- a/app/src/main/java/ceui/loxia/ImageFragment.kt +++ b/app/src/main/java/ceui/loxia/ImageFragment.kt @@ -6,6 +6,7 @@ import androidx.core.os.bundleOf import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import ceui.lisa.R +import ceui.lisa.activities.Shaft import ceui.lisa.core.GlideApp import ceui.lisa.databinding.FragmentImageBinding import ceui.refactor.viewBinding @@ -49,6 +50,11 @@ class ImageFragment : NavFragment(R.layout.fragment_image) { } } } + + //插画二级详情保持屏幕常亮 + if (Shaft.sSettings.isIllustDetailKeepScreenOn) { + binding.root.keepScreenOn = true + } } companion object { diff --git a/app/src/main/res/layout/fragment_image_detail.xml b/app/src/main/res/layout/fragment_image_detail.xml index f3f57c967..5274a27d0 100644 --- a/app/src/main/res/layout/fragment_image_detail.xml +++ b/app/src/main/res/layout/fragment_image_detail.xml @@ -11,14 +11,60 @@ android:background="@color/black" android:layout_height="match_parent"> - + + + + + + + + + +