Skip to content
This repository was archived by the owner on Jul 18, 2026. It is now read-only.

Commit 30b0be3

Browse files
authored
Merge pull request #302 from misaka10032w/develop
[Improved] 支持播放手势锁
2 parents 31b8f5a + 5136a11 commit 30b0be3

3 files changed

Lines changed: 46 additions & 8 deletions

File tree

app/src/main/java/com/yenaly/han1meviewer/ui/view/video/HJzvdStd.kt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ class HJzvdStd @JvmOverloads constructor(
245245
private lateinit var topBarContainer: LinearLayout
246246
private lateinit var layoutTop: View
247247
private lateinit var layoutBottom: View
248+
private lateinit var gestureLock: ImageView
249+
var gestureLocked = false
248250
var savedProgress: Long = 0L
249251
private lateinit var btnResumeProgress: MaterialButton
250252
private val handler = Handler(Looper.getMainLooper())
@@ -363,6 +365,7 @@ class HJzvdStd @JvmOverloads constructor(
363365
layoutBottom = findViewById(R.id.layout_bottom)
364366
btnResumeProgress = findViewById(R.id.btn_resume_progress)
365367
topBarContainer = findViewById(R.id.top_bar_container)
368+
gestureLock = findViewById(R.id.lock)
366369
textureViewContainer.isHapticFeedbackEnabled = true
367370
tvSpeed.setOnClickListener(this)
368371
tvKeyframe.setOnClickListener(this)
@@ -387,6 +390,9 @@ class HJzvdStd @JvmOverloads constructor(
387390
gotoFullscreen()
388391
}
389392
}
393+
gestureLock.setOnClickListener {
394+
gestureLocked = !gestureLocked
395+
}
390396

391397
}
392398

@@ -486,10 +492,23 @@ class HJzvdStd @JvmOverloads constructor(
486492
}
487493

488494
STATE_PLAYING -> {
489-
if (bottomContainer.isVisible) {
495+
if (gestureLocked) {
496+
post {
497+
gestureLock.isVisible = !gestureLock.isVisible
498+
}
490499
changeUiToPlayingClearSafe()
491500
} else {
492-
changeUiToPlayingShowSafe()
501+
if (bottomContainer.isVisible) {
502+
post {
503+
gestureLock.isVisible = false
504+
}
505+
changeUiToPlayingClearSafe()
506+
} else {
507+
post {
508+
gestureLock.isVisible = true
509+
}
510+
changeUiToPlayingShowSafe()
511+
}
493512
}
494513
}
495514

@@ -545,6 +564,7 @@ class HJzvdStd @JvmOverloads constructor(
545564
btnGoHome.isVisible = true
546565
topBarContainer.isVisible = false
547566
superResolution.isVisible = false
567+
gestureLock.isVisible = false
548568

549569
layoutTop.updatePadding(left = 0, right = 0)
550570
layoutBottom.updatePadding(left = 0, right = 0)
@@ -562,6 +582,7 @@ class HJzvdStd @JvmOverloads constructor(
562582
topBarContainer.isVisible = true
563583
clarity.isVisible = true
564584
superResolution.isVisible = switchPlayerKernel == HMediaKernel.Type.MpvPlayer.name
585+
gestureLock.isVisible = true
565586
val statusBarHeight = statusBarHeight
566587
val navBarHeight = navBarHeight
567588
layoutTop.updatePadding(left = statusBarHeight, right = navBarHeight)
@@ -701,6 +722,9 @@ class HJzvdStd @JvmOverloads constructor(
701722
}
702723

703724
override fun touchActionMove(x: Float, y: Float) {
725+
if (gestureLocked) {
726+
return
727+
}
704728
val deltaX = x - mDownX
705729
var deltaY = y - mDownY
706730
val absDeltaX = deltaX.absoluteValue
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:viewportHeight="1024" android:viewportWidth="1024" android:width="24dp">
2+
3+
<path android:fillColor="?attr/colorPrimary" android:pathData="M512.8,73.1a207.2,207.2 0,0 1,207.2 207.2l-0,61L829,341.3a73.1,73.1 0,0 1,73.1 73.1v438.9a73.1,73.1 0,0 1,-73.1 73.1L195,926.5a73.1,73.1 0,0 1,-73.1 -73.1L121.9,414.5a73.1,73.1 0,0 1,73.1 -73.1h110.5v-61a207.2,207.2 0,0 1,207.2 -207.2zM555.6,536.4h-73.1v195h73.1v-195zM512.8,146.3a134.1,134.1 0,0 0,-134.1 134.1L378.7,341.3h268.2v-61a134.1,134.1 0,0 0,-134.1 -134.1z"/>
4+
5+
</vector>

app/src/main/res/layout/layout_jzvd_with_speed.xml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,21 +264,30 @@
264264

265265
</LinearLayout>
266266

267-
<LinearLayout
267+
<RelativeLayout
268268
android:id="@+id/start_layout"
269-
android:layout_width="wrap_content"
269+
android:layout_width="match_parent"
270270
android:layout_height="wrap_content"
271-
android:layout_centerHorizontal="true"
272-
android:layout_centerVertical="true"
273-
android:layout_gravity="center_vertical">
271+
android:layout_centerVertical="true">
274272

275273
<ImageView
276274
android:id="@+id/start"
277275
android:layout_width="@dimen/jz_start_button_w_h_normal"
278276
android:layout_height="@dimen/jz_start_button_w_h_normal"
277+
android:layout_centerInParent="true"
279278
android:src="@drawable/jz_click_play_selector" />
280-
</LinearLayout>
281279

280+
<ImageView
281+
android:id="@+id/lock"
282+
android:tint="@color/per80_transparent_white"
283+
android:layout_width="30dp"
284+
android:layout_height="30dp"
285+
android:layout_alignParentRight="true"
286+
android:layout_centerVertical="true"
287+
android:layout_marginRight="16dp"
288+
android:visibility="invisible"
289+
android:src="@drawable/ic_baseline_lock_24"/>
290+
</RelativeLayout>
282291

283292
<TextView
284293
android:id="@+id/replay_text"

0 commit comments

Comments
 (0)