Skip to content

Commit

Permalink
feat: 优化宽图、长图缩放计算规则
Browse files Browse the repository at this point in the history
  • Loading branch information
SherlockGougou committed Feb 8, 2023
1 parent da71b59 commit a6a09da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ allprojects {
##### 此处显示的是本框架的最新版本号:
##### ⚠️注意:glide v3版本不再维护,最终版本为v3_4.0.2。建议使用androidx版本。
```
androidx用户 : 使用 androidx-7.1.3
androidx用户 : 使用 androidx-7.1.4
对于glide4.x : 使用 v4_6.1.3
```

Expand All @@ -68,7 +68,7 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
// BigImageViewPager https://github.com/SherlockGougou/BigImageViewPager
implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-7.1.3'
implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-7.1.4'
================================分割线==================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import cc.shinichi.library.tool.common.Print.d
import cc.shinichi.library.tool.ui.PhoneUtil
import java.io.*
import java.util.*
import kotlin.math.max

/**
* @author 工藤
Expand Down Expand Up @@ -166,8 +167,12 @@ object ImageUtil {

fun getImageMaxZoomScale(context: Context, imagePath: String): Float {
val wh = getWidthHeight(imagePath)
val imageWid = wh[0].toFloat()
val imageHei = wh[1].toFloat()
val phoneHei = PhoneUtil.getPhoneHei(context.applicationContext).toFloat()
if (imageWid >= 2560) {
return phoneHei * 4f / imageHei
}
return phoneHei * 2f / imageHei
}

Expand All @@ -182,7 +187,8 @@ object ImageUtil {
val wh = getWidthHeight(imagePath)
val imageWid = wh[0].toFloat()
val imageHei = wh[1].toFloat()
return imageHei / imageWid
val phoneWid = PhoneUtil.getPhoneWid(context.applicationContext).toFloat()
return max(imageHei / imageWid, phoneWid * 2f / imageWid)
}

fun getLongImageDoubleZoomScale(context: Context, imagePath: String): Float {
Expand All @@ -196,7 +202,8 @@ object ImageUtil {
val wh = getWidthHeight(imagePath)
val imageWid = wh[0].toFloat()
val imageHei = wh[1].toFloat()
return imageWid / imageHei
val phoneHei = PhoneUtil.getPhoneHei(context.applicationContext).toFloat()
return max(imageWid / imageHei, phoneHei * 2f / imageHei)
}

fun getWideImageDoubleScale(context: Context, imagePath: String): Float {
Expand Down
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 14
targetSdkVersion 32
versionCode 713
versionName "androidx-7.1.3"
versionCode 714
versionName "androidx-7.1.4"
}
buildTypes {
release {
Expand Down Expand Up @@ -57,6 +57,6 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
// library
// implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-7.1.3'
// implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-7.1.4'
implementation project(':library')
}

0 comments on commit a6a09da

Please sign in to comment.