diff --git a/README.md b/README.md
index f311532..b89b33e 100755
--- a/README.md
+++ b/README.md
@@ -48,11 +48,11 @@ https://github.com/user-attachments/assets/070caa63-8e9f-4b11-9240-4cb56440d3c2
}
```
#### Step 2. 在你app的build.gradle中添加依赖:
-当前最新版本为:```androidx-8.1.1```
+当前最新版本为:```androidx-8.1.2```
```
dependencies {
// 本框架
- implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-8.1.1'
+ implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-8.1.2'
// glide
implementation 'com.github.bumptech.glide:glide:4.16.0'
diff --git a/library/build.gradle b/library/build.gradle
index 5fd09e0..2687cde 100755
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -17,8 +17,8 @@ android {
}
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_17
- targetCompatibility JavaVersion.VERSION_17
+ sourceCompatibility JavaVersion.VERSION_11
+ targetCompatibility JavaVersion.VERSION_11
}
}
diff --git a/library/src/main/java/cc/shinichi/library/glide/ImageLoader.kt b/library/src/main/java/cc/shinichi/library/glide/ImageLoader.kt
index 72cc07a..26e2e9f 100755
--- a/library/src/main/java/cc/shinichi/library/glide/ImageLoader.kt
+++ b/library/src/main/java/cc/shinichi/library/glide/ImageLoader.kt
@@ -34,8 +34,7 @@ object ImageLoader {
val safeKey = safeKeyGenerator.getSafeKey(dataCacheKey)
SLog.d(TAG, "safeKey = $safeKey")
val file = File(context.cacheDir, DiskCache.Factory.DEFAULT_DISK_CACHE_DIR)
- val diskLruCache =
- DiskLruCache.open(file, 1, 1, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE.toLong())
+ val diskLruCache = DiskLruCache.open(file, 1, 1, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE.toLong())
val value = diskLruCache[safeKey]
return value?.getFile(0)
} catch (e: Exception) {
diff --git a/library/src/main/java/cc/shinichi/library/view/ImagePreviewFragment.kt b/library/src/main/java/cc/shinichi/library/view/ImagePreviewFragment.kt
index 105b6d2..d209bcd 100644
--- a/library/src/main/java/cc/shinichi/library/view/ImagePreviewFragment.kt
+++ b/library/src/main/java/cc/shinichi/library/view/ImagePreviewFragment.kt
@@ -23,6 +23,7 @@ import androidx.fragment.app.Fragment
import androidx.media3.common.MediaItem
import androidx.media3.common.Player
import androidx.media3.common.VideoSize
+import androidx.media3.common.util.UnstableApi
import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.ui.PlayerView
import cc.shinichi.library.ImagePreview
@@ -123,6 +124,7 @@ class ImagePreviewFragment : Fragment() {
return view
}
+ @UnstableApi
private fun initData() {
SLog.d(TAG, "initData: position = $position")
val type = imageInfo.type
@@ -148,9 +150,17 @@ class ImagePreviewFragment : Fragment() {
dragCloseView.setOnAlphaChangeListener(object : DragCloseView.onAlphaChangedListener {
override fun onTranslationYChanged(event: MotionEvent?, translationY: Float) {
if (translationY > 0) {
- ImagePreview.instance.onPageDragListener?.onDrag(imagePreviewActivity, imagePreviewActivity.parentView, event, translationY)
+ ImagePreview.instance.onPageDragListener?.onDrag(
+ imagePreviewActivity,
+ imagePreviewActivity.parentView,
+ event,
+ translationY
+ )
} else {
- ImagePreview.instance.onPageDragListener?.onDragEnd(imagePreviewActivity, imagePreviewActivity.parentView)
+ ImagePreview.instance.onPageDragListener?.onDragEnd(
+ imagePreviewActivity,
+ imagePreviewActivity.parentView
+ )
}
val yAbs = abs(translationY)
val percent = yAbs / phoneHei
@@ -309,6 +319,7 @@ class ImagePreviewFragment : Fragment() {
}
}
+ @UnstableApi
private fun initVideoType() {
// 视频类型,隐藏图片
imageStatic.visibility = View.GONE
@@ -325,7 +336,10 @@ class ImagePreviewFragment : Fragment() {
exoPlayer?.addListener(object : Player.Listener {
override fun onVideoSizeChanged(videoSize: VideoSize) {
super.onVideoSizeChanged(videoSize)
- SLog.d(TAG, "onVideoSizeChanged: videoSize = ${videoSize.width} * ${videoSize.height}")
+ SLog.d(
+ TAG,
+ "onVideoSizeChanged: videoSize = ${videoSize.width} * ${videoSize.height}"
+ )
}
override fun onIsPlayingChanged(isPlaying: Boolean) {
@@ -344,6 +358,7 @@ class ImagePreviewFragment : Fragment() {
if (playbackState == Player.STATE_READY) {
// 底部控制器处理
setProgress(exoPlayer!!)
+ videoView.hideController()
} else if (playbackState == Player.STATE_ENDED) {
// 播放结束
exoPlayer?.pause()
@@ -359,6 +374,7 @@ class ImagePreviewFragment : Fragment() {
})
}
videoView.player = exoPlayer
+
val mediaItem = MediaItem.fromUri(imageInfo.originUrl)
exoPlayer?.setMediaItem(mediaItem)
exoPlayer?.prepare()
@@ -536,7 +552,9 @@ class ImagePreviewFragment : Fragment() {
0,
0,
0,
- UIUtil.dp2px(imagePreviewActivity, 70f) + PhoneUtil.getNavBarHeight(imagePreviewActivity)
+ UIUtil.dp2px(imagePreviewActivity, 70f) + PhoneUtil.getNavBarHeight(
+ imagePreviewActivity
+ )
)
}
llControllerContainer.layoutParams = layoutParams
@@ -622,7 +640,8 @@ class ImagePreviewFragment : Fragment() {
// glide加载失败,使用http下载后再次加载
Thread {
val fileFullName = System.currentTimeMillis().toString()
- val saveDir = getAvailableCacheDir(imagePreviewActivity)?.absolutePath + File.separator + "image/"
+ val saveDir =
+ getAvailableCacheDir(imagePreviewActivity)?.absolutePath + File.separator + "image/"
val downloadFile = downloadFile(url, fileFullName, saveDir)
Handler(Looper.getMainLooper()).post {
if (downloadFile != null && downloadFile.exists() && downloadFile.length() > 0) {
@@ -719,7 +738,8 @@ class ImagePreviewFragment : Fragment() {
val isWideImage = ImageUtil.isWideImage(imagePath)
if (isLongImage) {
// 长图,高/宽>=3
- imageStatic.maxScale = ImageUtil.getLongImageMaxZoomScale(imagePreviewActivity, imagePath)
+ imageStatic.maxScale =
+ ImageUtil.getLongImageMaxZoomScale(imagePreviewActivity, imagePath)
imageStatic.setDoubleTapZoomScale(
ImageUtil.getLongImageDoubleZoomScale(
imagePreviewActivity,
@@ -742,7 +762,8 @@ class ImagePreviewFragment : Fragment() {
}
} else if (isWideImage) {
// 宽图,宽/高>=3
- imageStatic.maxScale = ImageUtil.getWideImageMaxZoomScale(imagePreviewActivity, imagePath)
+ imageStatic.maxScale =
+ ImageUtil.getWideImageMaxZoomScale(imagePreviewActivity, imagePath)
imageStatic.setDoubleTapZoomScale(
ImageUtil.getWideImageDoubleScale(
imagePreviewActivity,
@@ -751,7 +772,8 @@ class ImagePreviewFragment : Fragment() {
)
} else {
// 普通图片,其他
- imageStatic.maxScale = ImageUtil.getStandardImageMaxZoomScale(imagePreviewActivity, imagePath)
+ imageStatic.maxScale =
+ ImageUtil.getStandardImageMaxZoomScale(imagePreviewActivity, imagePath)
imageStatic.setDoubleTapZoomScale(
ImageUtil.getStandardImageDoubleScale(
imagePreviewActivity,
diff --git a/library/src/main/res/drawable-xhdpi/icon_change_orientation.png b/library/src/main/res/drawable-xhdpi/icon_change_orientation.png
new file mode 100644
index 0000000..76cc08b
Binary files /dev/null and b/library/src/main/res/drawable-xhdpi/icon_change_orientation.png differ
diff --git a/library/src/main/res/drawable-xxhdpi/icon_change_orientation.png b/library/src/main/res/drawable-xxhdpi/icon_change_orientation.png
new file mode 100644
index 0000000..a0765a3
Binary files /dev/null and b/library/src/main/res/drawable-xxhdpi/icon_change_orientation.png differ
diff --git a/library/src/main/res/layout/sh_item_photoview.xml b/library/src/main/res/layout/sh_item_photoview.xml
index 4e647cb..1eeffcf 100755
--- a/library/src/main/res/layout/sh_item_photoview.xml
+++ b/library/src/main/res/layout/sh_item_photoview.xml
@@ -29,6 +29,7 @@
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ app:show_timeout="1500"
app:controller_layout_id="@layout/sh_media_controller" />
diff --git a/sample/build.gradle b/sample/build.gradle
index 200552f..432a4a1 100755
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -23,8 +23,8 @@ android {
applicationId "cc.shinichi.bigimageviewpager"
minSdkVersion 24
targetSdkVersion 34
- versionCode 811
- versionName "androidx-8.1.1"
+ versionCode 812
+ versionName "androidx-8.1.2"
signingConfig signingConfigs.debug
multiDexEnabled true
}
@@ -35,8 +35,8 @@ android {
}
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_17
- targetCompatibility JavaVersion.VERSION_17
+ sourceCompatibility JavaVersion.VERSION_11
+ targetCompatibility JavaVersion.VERSION_11
}
sourceSets {
main {
@@ -79,6 +79,6 @@ dependencies {
implementation "androidx.media3:media3-ui:1.4.1"
// library
- // implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-8.1.1'
+ // implementation 'com.github.SherlockGougou:BigImageViewPager:androidx-8.1.2'
implementation project(':library')
}
\ No newline at end of file
diff --git a/sample/src/main/res/layout/custom_layout_preview.xml b/sample/src/main/res/layout/custom_layout_preview.xml
index f10353e..23009cb 100755
--- a/sample/src/main/res/layout/custom_layout_preview.xml
+++ b/sample/src/main/res/layout/custom_layout_preview.xml
@@ -68,77 +68,84 @@
-
-
+ android:layout_height="match_parent">
-
-
-
+ app:layout_constraintTop_toTopOf="parent" />
-
-
-
+ android:layout_height="wrap_content"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+
+
+
+
+
+
+
+