mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
make MediaSideScroll extend RelativeLayout
This commit is contained in:
parent
2a2d37e221
commit
16e30e5969
5 changed files with 32 additions and 11 deletions
|
@ -50,7 +50,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
private var storedHideExtendedDetails = false
|
||||
private var storedExtendedDetails = 0
|
||||
|
||||
private lateinit var mediaSideScroll: MediaSideScroll
|
||||
private lateinit var brightnessSideScroll: MediaSideScroll
|
||||
|
||||
lateinit var view: ViewGroup
|
||||
lateinit var medium: Medium
|
||||
|
@ -66,7 +66,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
instant_next_item.parentView = container
|
||||
|
||||
photo_brightness_controller.setOnTouchListener { v, event ->
|
||||
mediaSideScroll.handleBrightnessTouched(event)
|
||||
brightnessSideScroll.handleBrightnessTouched(event)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,8 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mediaSideScroll = MediaSideScroll(activity!!, view.slide_info) {
|
||||
brightnessSideScroll = view.photo_brightness_controller
|
||||
brightnessSideScroll.initialize(activity!!, view.slide_info) {
|
||||
view.apply {
|
||||
if (subsampling_view.isVisible()) {
|
||||
subsampling_view.performClick()
|
||||
|
|
|
@ -54,7 +54,8 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
private var mStoredHideExtendedDetails = false
|
||||
private var mStoredExtendedDetails = 0
|
||||
|
||||
private lateinit var mediaSideScroll: MediaSideScroll
|
||||
private lateinit var brightnessSideScroll: MediaSideScroll
|
||||
private lateinit var volumeSideScroll: MediaSideScroll
|
||||
|
||||
lateinit var medium: Medium
|
||||
|
||||
|
@ -87,7 +88,13 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mediaSideScroll = MediaSideScroll(activity!!, view.slide_info) {
|
||||
brightnessSideScroll = view.video_brightness_controller
|
||||
brightnessSideScroll.initialize(activity!!, view.slide_info) {
|
||||
view.video_holder.performClick()
|
||||
}
|
||||
|
||||
volumeSideScroll = view.video_volume_controller
|
||||
volumeSideScroll.initialize(activity!!, view.slide_info) {
|
||||
view.video_holder.performClick()
|
||||
}
|
||||
}
|
||||
|
@ -145,12 +152,12 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
mView!!.video_holder.setOnClickListener { toggleFullscreen() }
|
||||
|
||||
mView!!.video_volume_controller.setOnTouchListener { v, event ->
|
||||
mediaSideScroll.handleVolumeTouched(event)
|
||||
volumeSideScroll.handleVolumeTouched(event)
|
||||
true
|
||||
}
|
||||
|
||||
mView!!.video_brightness_controller.setOnTouchListener { v, event ->
|
||||
mediaSideScroll.handleBrightnessTouched(event)
|
||||
volumeSideScroll.handleBrightnessTouched(event)
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
package com.simplemobiletools.gallery.helpers
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.media.AudioManager
|
||||
import android.os.Handler
|
||||
import android.provider.Settings
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||
import com.simplemobiletools.gallery.extensions.audioManager
|
||||
|
||||
class MediaSideScroll(val activity: Activity, val slideInfoView: TextView, val callback: () -> Unit) {
|
||||
class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs) {
|
||||
private val SLIDE_INFO_FADE_DELAY = 1000L
|
||||
private var mTouchDownX = 0f
|
||||
private var mTouchDownY = 0f
|
||||
|
@ -23,6 +26,16 @@ class MediaSideScroll(val activity: Activity, val slideInfoView: TextView, val c
|
|||
private var mSlideInfoText = ""
|
||||
private var mSlideInfoFadeHandler = Handler()
|
||||
|
||||
private lateinit var activity: Activity
|
||||
private lateinit var slideInfoView: TextView
|
||||
private lateinit var callback: () -> Unit
|
||||
|
||||
fun initialize(activity: Activity, slideInfoView: TextView, callback: () -> Unit) {
|
||||
this.activity = activity
|
||||
this.slideInfoView = slideInfoView
|
||||
this.callback = callback
|
||||
}
|
||||
|
||||
fun handleVolumeTouched(event: MotionEvent) {
|
||||
when (event.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
android:visibility="gone"
|
||||
tools:text="My image\nAnother line"/>
|
||||
|
||||
<RelativeLayout
|
||||
<com.simplemobiletools.gallery.helpers.MediaSideScroll
|
||||
android:id="@+id/photo_brightness_controller"
|
||||
android:layout_width="@dimen/media_side_slider_width"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
android:layout_centerInParent="true"
|
||||
android:background="@android:color/transparent"/>
|
||||
|
||||
<RelativeLayout
|
||||
<com.simplemobiletools.gallery.helpers.MediaSideScroll
|
||||
android:id="@+id/video_volume_controller"
|
||||
android:layout_width="@dimen/media_side_slider_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"/>
|
||||
|
||||
<RelativeLayout
|
||||
<com.simplemobiletools.gallery.helpers.MediaSideScroll
|
||||
android:id="@+id/video_brightness_controller"
|
||||
android:layout_width="@dimen/media_side_slider_width"
|
||||
android:layout_height="match_parent"/>
|
||||
|
|
Loading…
Reference in a new issue