Skip to content

Commit

Permalink
release: 7.3.0.增加页面拖拽回调
Browse files Browse the repository at this point in the history
release: 7.3.0.增加页面拖拽回调
  • Loading branch information
SherlockGougou committed Dec 20, 2023
1 parent 11f8158 commit d0f719f
Show file tree
Hide file tree
Showing 23 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Empty file modified gradlew
100755 → 100644
Empty file.
7 changes: 7 additions & 0 deletions library/src/main/java/cc/shinichi/library/ImagePreview.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ class ImagePreview {
private set
var onPageFinishListener: OnPageFinishListener? = null
private set
var onPageDragListener: OnPageDragListener? = null
private set

// 自定义百分比布局layout id
@LayoutRes
Expand Down Expand Up @@ -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
Expand Down
Empty file modified library/src/main/java/cc/shinichi/library/bean/ImageInfo.kt
100755 → 100644
Empty file.
Empty file.
3 changes: 2 additions & 1 deletion library/src/main/java/cc/shinichi/library/view/ImagePreviewAdapter.kt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cc.shinichi.library.view.listener

import android.view.MotionEvent

/**
* @author 工藤
* @email [email protected]
* cc.shinichi.library.view.listener
* create at 2018/12/19 16:23
* description: 页面拖拽回调
*/
abstract class OnPageDragListener {
abstract fun onDrag(event: MotionEvent?, translationY: Float)
}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified library/src/main/res/layout/sh_item_photoview.xml
100755 → 100644
Empty file.
Empty file modified library/src/main/res/layout/sh_layout_preview.xml
100755 → 100644
Empty file.
6 changes: 3 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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')
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
}
Expand Down
Empty file modified sample/src/main/res/layout/custom_layout_preview.xml
100755 → 100644
Empty file.

0 comments on commit d0f719f

Please sign in to comment.