Commit 416cacce4590eca08949461cd6a3a6c03fc39899
1 parent
dffd5cf2
全屏预览页面简单跳转
Showing
10 changed files
with
126 additions
and
29 deletions
app/strike/src/main/java/com/cnlive/strike/imgutil/ImgActivity.java
| ... | ... | @@ -11,11 +11,13 @@ import android.os.Message; |
| 11 | 11 | import android.view.View; |
| 12 | 12 | import android.widget.ImageView; |
| 13 | 13 | |
| 14 | +import com.alibaba.android.arouter.launcher.ARouter; | |
| 14 | 15 | import com.bumptech.glide.Glide; |
| 15 | 16 | import com.bumptech.glide.load.DecodeFormat; |
| 16 | 17 | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| 17 | 18 | import com.bumptech.glide.request.RequestOptions; |
| 18 | 19 | import com.bumptech.glide.request.transition.ViewPropertyTransition; |
| 20 | +import com.cnlive.core.activity.PreviewImageActivity; | |
| 19 | 21 | import com.cnlive.core.imageload.callback.ImageDownLoadCallBack; |
| 20 | 22 | import com.cnlive.core.imageload.config.PriorityMode; |
| 21 | 23 | import com.cnlive.core.imageload.config.ScaleMode; |
| ... | ... | @@ -28,6 +30,7 @@ import com.cnlive.cloud.R; |
| 28 | 30 | import com.cnlive.cloud.user.auth.UserService; |
| 29 | 31 | |
| 30 | 32 | import java.util.ArrayList; |
| 33 | +import java.util.List; | |
| 31 | 34 | |
| 32 | 35 | public class ImgActivity extends AppCompatActivity { |
| 33 | 36 | |
| ... | ... | @@ -88,6 +91,16 @@ public class ImgActivity extends AppCompatActivity { |
| 88 | 91 | iv_test11 = findViewById(R.id.iv_test11); |
| 89 | 92 | |
| 90 | 93 | findViewById(R.id.simpla_see).setOnClickListener(view -> startActivity(new Intent(this,SimplePrevActivity.class))); |
| 94 | + findViewById(R.id.pre_btn).setOnClickListener(view -> { | |
| 95 | + ArrayList<String> list = new ArrayList<>(); | |
| 96 | + list.add("https://b-ssl.duitang.com/uploads/item/201505/09/20150509221719_kyNrM.jpeg"); | |
| 97 | + list.add("https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1035013881,3985887911&fm=26&gp=0.gif"); | |
| 98 | + list.add("https://b-ssl.duitang.com/uploads/item/201505/11/20150511122951_MAwVZ.jpeg"); | |
| 99 | + list.add("https://b-ssl.duitang.com/uploads/item/201704/23/20170423205828_BhNSv.jpeg"); | |
| 100 | + ARouter.getInstance().build("/preview/PreviewImageActivity") | |
| 101 | + .withStringArrayList("paths", list) | |
| 102 | + .navigation(this); | |
| 103 | + }); | |
| 91 | 104 | } |
| 92 | 105 | |
| 93 | 106 | ... | ... |
app/strike/src/main/java/com/cnlive/strike/imgutil/SimplePrevActivity.java
| ... | ... | @@ -18,7 +18,6 @@ import com.cnlive.core.imagepreview.PhotoLoader; |
| 18 | 18 | import com.cnlive.core.imagepreview.ViewerStatus; |
| 19 | 19 | import com.cnlive.core.imagepreview.listener.OnBrowseStatusListener; |
| 20 | 20 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
| 21 | -import com.cnlive.core.libs.base.util.GlideUtil; | |
| 22 | 21 | |
| 23 | 22 | import java.util.ArrayList; |
| 24 | 23 | import java.util.List; |
| ... | ... | @@ -89,7 +88,7 @@ public class SimplePrevActivity extends BaseActivity { |
| 89 | 88 | public void onBrowseStatus(int status) { |
| 90 | 89 | //可以根据状态去设置状态栏颜色 |
| 91 | 90 | if(status == ViewerStatus.STATUS_BEGIN_OPEN){ |
| 92 | - | |
| 91 | + setStatusBarColor(R.color.black,0); | |
| 93 | 92 | }else if(status == ViewerStatus.STATUS_SILENCE){ |
| 94 | 93 | |
| 95 | 94 | } | ... | ... |
app/strike/src/main/res/layout/activity_img.xml
| ... | ... | @@ -14,7 +14,13 @@ |
| 14 | 14 | android:id="@+id/simpla_see" |
| 15 | 15 | android:layout_width="wrap_content" |
| 16 | 16 | android:layout_height="wrap_content" |
| 17 | - android:text="简单预览" /> | |
| 17 | + android:text="网格展示以及预览" /> | |
| 18 | + | |
| 19 | + <Button | |
| 20 | + android:id="@+id/pre_btn" | |
| 21 | + android:layout_width="wrap_content" | |
| 22 | + android:layout_height="wrap_content" | |
| 23 | + android:text="全屏预览" /> | |
| 18 | 24 | |
| 19 | 25 | <TextView |
| 20 | 26 | android:layout_width="wrap_content" | ... | ... |
core/imageload/build.gradle
| ... | ... | @@ -28,6 +28,7 @@ dependencies { |
| 28 | 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) |
| 29 | 29 | implementation 'cn.bertsir.zbarLibary:zbarlibary:1.3.3' |
| 30 | 30 | implementation 'com.cnlive.libs:largeimage:1.0.1' |
| 31 | + implementation 'com.github.chrisbanes:PhotoView:2.1.4' | |
| 31 | 32 | implementation "com.cnlive.libs:mediapicker:$rootProject.libMediaPicker" |
| 32 | 33 | implementation project(path: ':cloud:user') |
| 33 | 34 | implementation project(path: ':core:app_qr') | ... | ... |
core/imageload/src/main/AndroidManifest.xml
| ... | ... | @@ -3,23 +3,25 @@ |
| 3 | 3 | package="com.cnlive.core.imageload"> |
| 4 | 4 | |
| 5 | 5 | <application> |
| 6 | + <activity android:name="com.cnlive.core.activity.PreviewImageActivity"></activity> | |
| 6 | 7 | <activity |
| 7 | - android:name=".preview.PreviewImageViewActivity" | |
| 8 | - android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation" | |
| 9 | - android:launchMode="singleTop" | |
| 10 | - android:theme="@style/Theme.AppCompat.NoActionBar"/> | |
| 11 | - <activity | |
| 12 | - android:name=".preview.DataProcessingActivity" | |
| 13 | - android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | |
| 14 | - android:launchMode="singleTop" | |
| 15 | - android:theme="@style/ProcessHtmlDialogActivityTheme"> | |
| 16 | - <intent-filter> | |
| 17 | - <action android:name="com.cnlive.strike.moudle.preview.ui.DataProcessingActivity" /> | |
| 18 | - <category android:name="android.intent.category.DEFAULT" /> | |
| 19 | - <!-- 文字类型 --> | |
| 20 | - <data android:mimeType="text/plain" /> | |
| 21 | - </intent-filter> | |
| 22 | - </activity> | |
| 8 | + android:name=".preview.PreviewImageViewActivity" | |
| 9 | + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation" | |
| 10 | + android:launchMode="singleTop" | |
| 11 | + android:theme="@style/Theme.AppCompat.NoActionBar" /> | |
| 12 | + <activity | |
| 13 | + android:name=".preview.DataProcessingActivity" | |
| 14 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | |
| 15 | + android:launchMode="singleTop" | |
| 16 | + android:theme="@style/ProcessHtmlDialogActivityTheme"> | |
| 17 | + <intent-filter> | |
| 18 | + <action android:name="com.cnlive.strike.moudle.preview.ui.DataProcessingActivity" /> | |
| 19 | + | |
| 20 | + <category android:name="android.intent.category.DEFAULT" /> | |
| 21 | + <!-- 文字类型 --> | |
| 22 | + <data android:mimeType="text/plain" /> | |
| 23 | + </intent-filter> | |
| 24 | + </activity> | |
| 23 | 25 | </application> |
| 24 | 26 | |
| 25 | 27 | </manifest> |
| 26 | 28 | \ No newline at end of file | ... | ... |
core/imageload/src/main/java/com/cnlive/core/activity/PreviewImageActivity.java
0 → 100644
| 1 | +package com.cnlive.core.activity; | |
| 2 | + | |
| 3 | +import android.widget.ImageView; | |
| 4 | + | |
| 5 | +import com.alibaba.android.arouter.facade.annotation.Route; | |
| 6 | +import com.cnlive.core.imageload.R; | |
| 7 | +import com.cnlive.core.imagepreview.ImagePreView; | |
| 8 | +import com.cnlive.core.imagepreview.PhotoLoader; | |
| 9 | +import com.cnlive.core.imagepreview.listener.OnItemClickListener; | |
| 10 | +import com.cnlive.core.libs.base.frame.activity.BaseActivity; | |
| 11 | + | |
| 12 | +import java.util.ArrayList; | |
| 13 | +import java.util.Arrays; | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +@Route(path = "/preview/PreviewImageActivity") | |
| 17 | +public class PreviewImageActivity extends BaseActivity { | |
| 18 | + | |
| 19 | + private ImagePreView preView; | |
| 20 | + private List<String> list = new ArrayList<>(); | |
| 21 | + | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + protected int getViewLayoutId() { | |
| 25 | + return R.layout.activity_preview_image; | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + protected void initView() { | |
| 30 | + preView = findViewById(R.id.image_pre); | |
| 31 | + //设置为黑色预览 | |
| 32 | + setStatusBarColor(R.color.black,0); | |
| 33 | + | |
| 34 | + list = getIntent().getStringArrayListExtra("paths"); | |
| 35 | + | |
| 36 | + | |
| 37 | +// list.add("https://b-ssl.duitang.com/uploads/item/201706/30/20170630181644_j4mh5.jpeg"); | |
| 38 | + preView.overlayStatusBar(false) | |
| 39 | + .imageData(list) | |
| 40 | + .imageLoader(new PhotoLoader()); | |
| 41 | + | |
| 42 | + preView.watch(0); | |
| 43 | + preView.setOnItemClickListener(new OnItemClickListener() { | |
| 44 | + @Override | |
| 45 | + public boolean onItemClick(int position, ImageView imageView) { | |
| 46 | + finish(); | |
| 47 | + return false; | |
| 48 | + } | |
| 49 | + }); | |
| 50 | + | |
| 51 | +// preView.getCurrentItem().getImageView().setOnClickListener(view -> finish()); | |
| 52 | + } | |
| 53 | +} | ... | ... |
core/imageload/src/main/java/com/cnlive/core/imagepreview/ImageDrawee.java
| ... | ... | @@ -8,9 +8,9 @@ import android.widget.FrameLayout; |
| 8 | 8 | import android.widget.ImageView; |
| 9 | 9 | |
| 10 | 10 | import com.cnlive.core.imagepreview.indexui.ProgressUI; |
| 11 | +import com.github.chrisbanes.photoview.PhotoView; | |
| 11 | 12 | |
| 12 | 13 | import androidx.annotation.NonNull; |
| 13 | -import uk.co.senab.photoview.PhotoView; | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * created by hanyayun |
| ... | ... | @@ -95,6 +95,17 @@ public class ImageDrawee extends FrameLayout { |
| 95 | 95 | if (obj == null) { |
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | + | |
| 99 | +// if (obj instanceof Drawable || obj instanceof Bitmap || obj instanceof Integer || obj instanceof String) { | |
| 100 | +// ImageLoader.with(getContext()) | |
| 101 | +// .url((String) obj) | |
| 102 | +// .scale(ScaleMode.CENTER_CROP) | |
| 103 | +// .into(imageView); | |
| 104 | +//// Glide.with(getContext()).load(obj).into(imageView); | |
| 105 | +// } else { | |
| 106 | +// Log.e("ImageDrawee", "Unable to identify picture resources."); | |
| 107 | +// } | |
| 108 | + | |
| 98 | 109 | if (obj instanceof Drawable) { |
| 99 | 110 | imageView.setImageDrawable((Drawable) obj); |
| 100 | 111 | } else if (obj instanceof Bitmap) { | ... | ... |
core/imageload/src/main/java/com/cnlive/core/imagepreview/ImagePreView.java
| ... | ... | @@ -622,10 +622,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL |
| 622 | 622 | return mViewStatus; |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - //////////////////////////////////////////////////////////////////////////////////////////////// | |
| 626 | - //// 拖拽相关 | |
| 627 | - //////////////////////////////////////////////////////////////////////////////////////////////// | |
| 628 | - | |
| 625 | + // 拖拽相关 | |
| 629 | 626 | @Override |
| 630 | 627 | public boolean onInterceptTouchEvent(MotionEvent ev) { |
| 631 | 628 | boolean isIntercept = super.onInterceptTouchEvent(ev); | ... | ... |
core/imageload/src/main/java/com/cnlive/core/imagepreview/indexui/DefaultIndexUI.java
| ... | ... | @@ -29,9 +29,10 @@ public class DefaultIndexUI extends IndexUI { |
| 29 | 29 | FrameLayout.LayoutParams.WRAP_CONTENT, |
| 30 | 30 | FrameLayout.LayoutParams.WRAP_CONTENT); |
| 31 | 31 | textParams.setMargins(0, |
| 32 | - Utils.dp2px(context, overlayStatusBar ? Utils.getStatusBarHeight(context) + 5 : 5), | |
| 33 | - 0, 0); | |
| 34 | - textParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; | |
| 32 | +// Utils.dp2px(context, overlayStatusBar ? Utils.getStatusBarHeight(context) + 5 : 5), | |
| 33 | + 0, 0, Utils.dp2px(context,20)); | |
| 34 | + //改变索引位置 | |
| 35 | + textParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; | |
| 35 | 36 | indexView.setLayoutParams(textParams); |
| 36 | 37 | indexView.setIncludeFontPadding(false); |
| 37 | 38 | indexView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); |
| ... | ... | @@ -41,11 +42,11 @@ public class DefaultIndexUI extends IndexUI { |
| 41 | 42 | |
| 42 | 43 | @Override |
| 43 | 44 | public void init(int position, int length) { |
| 44 | - ((TextView) getIndexView()).setText((position + 1) + "/" + length); | |
| 45 | + ((TextView) getIndexView()).setText((position + 1) + " / " + length); | |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | @Override |
| 48 | 49 | public void handleItemChanged(int position, int length) { |
| 49 | - ((TextView) getIndexView()).setText((position + 1) + "/" + length); | |
| 50 | + ((TextView) getIndexView()).setText((position + 1) + " / " + length); | |
| 50 | 51 | } |
| 51 | 52 | } | ... | ... |
core/imageload/src/main/res/layout/activity_preview_image.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 4 | + xmlns:tools="http://schemas.android.com/tools" | |
| 5 | + android:layout_width="match_parent" | |
| 6 | + android:layout_height="match_parent" | |
| 7 | + tools:context="com.cnlive.core.activity.PreviewImageActivity"> | |
| 8 | + | |
| 9 | + <com.cnlive.core.imagepreview.ImagePreView | |
| 10 | + android:id="@+id/image_pre" | |
| 11 | + android:layout_width="match_parent" | |
| 12 | + android:layout_height="wrap_content"/> | |
| 13 | + | |
| 14 | +</LinearLayout> | ... | ... |