Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.fossify.voicerecorder.views

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import org.fossify.commons.views.MySeekBar

class PlayerSeekBar : MySeekBar {
private var isParentInterceptionDisallowed = false

constructor(context: Context) : super(context)

constructor(context: Context, attrs: AttributeSet) : super(context, attrs)

constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)

override fun onTouchEvent(event: MotionEvent): Boolean {
val action = event.actionMasked
if (action == MotionEvent.ACTION_DOWN) {
setParentInterceptionDisallowed(true)
}

val handled = super.onTouchEvent(event)
if (action == MotionEvent.ACTION_UP && handled) {
performClick()
}

if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL || !handled) {
setParentInterceptionDisallowed(false)
}

return handled
}

override fun performClick() = super.performClick()

override fun onDetachedFromWindow() {
setParentInterceptionDisallowed(false)
super.onDetachedFromWindow()
}

private fun setParentInterceptionDisallowed(disallowed: Boolean) {
if (isParentInterceptionDisallowed != disallowed) {
parent?.requestDisallowInterceptTouchEvent(disallowed)
isParentInterceptionDisallowed = disallowed
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
android:paddingEnd="@dimen/medium_margin"
android:text="00:00" />

<org.fossify.commons.views.MySeekBar
<org.fossify.voicerecorder.views.PlayerSeekBar
android:id="@+id/player_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
Loading