diff --git a/README.md b/README.md index 31be8b8..4b51cb2 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ allprojects { dependencies { // 添加本框架 BigImageViewPager https://github.com/SherlockGougou/BigImageViewPager // 此处展示的是最新版本 - implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-7.2.7' + implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-7.3.0' // 另外还需要依赖 glide implementation 'com.github.bumptech.glide:glide:4.11.0' diff --git a/gradlew b/gradlew old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/ImagePreview.kt b/library/src/main/java/cc/shinichi/library/ImagePreview.kt index 59bb991..b604ef2 100644 --- a/library/src/main/java/cc/shinichi/library/ImagePreview.kt +++ b/library/src/main/java/cc/shinichi/library/ImagePreview.kt @@ -144,6 +144,8 @@ class ImagePreview { private set var onPageFinishListener: OnPageFinishListener? = null private set + var onPageDragListener: OnPageDragListener? = null + private set // 自定义百分比布局layout id @LayoutRes @@ -387,6 +389,11 @@ class ImagePreview { return this } + fun setOnPageDragListener(onPageDragListener: OnPageDragListener): ImagePreview { + this.onPageDragListener = onPageDragListener + return this + } + private fun setOnOriginProgressListener(onOriginProgressListener: OnOriginProgressListener): ImagePreview { this.onOriginProgressListener = onOriginProgressListener return this diff --git a/library/src/main/java/cc/shinichi/library/bean/ImageInfo.kt b/library/src/main/java/cc/shinichi/library/bean/ImageInfo.kt old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/ImagePreviewActivity.kt b/library/src/main/java/cc/shinichi/library/view/ImagePreviewActivity.kt old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/ImagePreviewAdapter.kt b/library/src/main/java/cc/shinichi/library/view/ImagePreviewAdapter.kt old mode 100755 new mode 100644 index aa2c36f..7bd8b69 --- a/library/src/main/java/cc/shinichi/library/view/ImagePreviewAdapter.kt +++ b/library/src/main/java/cc/shinichi/library/view/ImagePreviewAdapter.kt @@ -153,7 +153,8 @@ class ImagePreviewAdapter(private val activity: AppCompatActivity, imageList: Mu } if (ImagePreview.instance.isEnableDragClose) { - fingerDragHelper.setOnAlphaChangeListener { _, translationY -> + fingerDragHelper.setOnAlphaChangeListener { event, translationY -> + ImagePreview.instance.onPageDragListener?.onDrag(event, translationY) val yAbs = abs(translationY) val percent = yAbs / getPhoneHei(activity.applicationContext) val number = 1.0f - percent diff --git a/library/src/main/java/cc/shinichi/library/view/listener/OnPageDragListener.kt b/library/src/main/java/cc/shinichi/library/view/listener/OnPageDragListener.kt new file mode 100644 index 0000000..b3f6b1a --- /dev/null +++ b/library/src/main/java/cc/shinichi/library/view/listener/OnPageDragListener.kt @@ -0,0 +1,14 @@ +package cc.shinichi.library.view.listener + +import android.view.MotionEvent + +/** + * @author 工藤 + * @email qinglingou@gmail.com + * cc.shinichi.library.view.listener + * create at 2018/12/19 16:23 + * description: 页面拖拽回调 + */ +abstract class OnPageDragListener { + abstract fun onDrag(event: MotionEvent?, translationY: Float) +} \ No newline at end of file diff --git a/library/src/main/java/cc/shinichi/library/view/photoview/CustomGestureDetector.java b/library/src/main/java/cc/shinichi/library/view/photoview/CustomGestureDetector.java old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/subsampling/ImageSource.java b/library/src/main/java/cc/shinichi/library/view/subsampling/ImageSource.java old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/subsampling/ImageViewState.java b/library/src/main/java/cc/shinichi/library/view/subsampling/ImageViewState.java old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/subsampling/SubsamplingScaleImageView.java b/library/src/main/java/cc/shinichi/library/view/subsampling/SubsamplingScaleImageView.java old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/CompatDecoderFactory.java b/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/CompatDecoderFactory.java old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/DecoderFactory.java b/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/DecoderFactory.java old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/ImageDecoder.java b/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/ImageDecoder.java old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/ImageRegionDecoder.java b/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/ImageRegionDecoder.java old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/SkiaImageDecoder.java b/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/SkiaImageDecoder.java old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/SkiaImageRegionDecoder.java b/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/SkiaImageRegionDecoder.java old mode 100755 new mode 100644 diff --git a/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/SkiaPooledImageRegionDecoder.java b/library/src/main/java/cc/shinichi/library/view/subsampling/decoder/SkiaPooledImageRegionDecoder.java old mode 100755 new mode 100644 diff --git a/library/src/main/res/layout/sh_item_photoview.xml b/library/src/main/res/layout/sh_item_photoview.xml old mode 100755 new mode 100644 diff --git a/library/src/main/res/layout/sh_layout_preview.xml b/library/src/main/res/layout/sh_layout_preview.xml old mode 100755 new mode 100644 diff --git a/sample/build.gradle b/sample/build.gradle index 99e3a35..ac156b8 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -8,8 +8,8 @@ android { applicationId "cc.shinichi.bigimageviewpager" minSdkVersion 19 targetSdkVersion 33 - versionCode 727 - versionName "androidx-7.2.7" + versionCode 730 + versionName "androidx-7.3.0" } buildTypes { release { @@ -56,6 +56,6 @@ dependencies { implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0' // library - // implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-7.2.7' + // implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-7.3.0' implementation project(':library') } \ No newline at end of file diff --git a/sample/src/main/java/cc/shinichi/bigimageviewpager/MainActivity.java b/sample/src/main/java/cc/shinichi/bigimageviewpager/MainActivity.java index 442a767..e6fc65a 100644 --- a/sample/src/main/java/cc/shinichi/bigimageviewpager/MainActivity.java +++ b/sample/src/main/java/cc/shinichi/bigimageviewpager/MainActivity.java @@ -5,6 +5,7 @@ import android.os.Build; import android.os.Bundle; import android.util.Log; +import android.view.MotionEvent; import android.view.View; import android.view.Window; import android.widget.CompoundButton; @@ -40,6 +41,7 @@ import cc.shinichi.library.view.listener.OnDownloadClickListener; import cc.shinichi.library.view.listener.OnDownloadListener; import cc.shinichi.library.view.listener.OnOriginProgressListener; +import cc.shinichi.library.view.listener.OnPageDragListener; import cc.shinichi.library.view.listener.OnPageFinishListener; public class MainActivity extends AppCompatActivity { @@ -473,6 +475,13 @@ public void onLayout(@NonNull View parentView) { // 自定义控件事件处理 } }) + // 监听页面拖动(自定义布局可以根据是否拖动进行隐藏或者展示) + .setOnPageDragListener(new OnPageDragListener() { + @Override + public void onDrag(MotionEvent event, float translationY) { + Log.d(TAG, "onDrag: translationY = " + translationY); + } + }) // 开启预览 .start(); } diff --git a/sample/src/main/res/layout/custom_layout_preview.xml b/sample/src/main/res/layout/custom_layout_preview.xml old mode 100755 new mode 100644