Skip to content

Commit

Permalink
Added the distouch the main view.
Browse files Browse the repository at this point in the history
  • Loading branch information
pokk committed Mar 26, 2018
1 parent 640a28b commit e20dadd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ proj_name=parallaxsidemenu
proj_libname=parallaxsidemenu
proj_group=com.devrapid.jieyi
proj_artifactid=parallaxsidemenu
proj_version=0.0.5
proj_version=0.0.6
proj_description=A Parallax Menu.
proj_websiteurl=https://github.com/pokk/ParallaxSideMenu
proj_issuetrackerurl=https://github.com/pokk/ParallaxSideMenu/issues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.devrapid.parallaxsidemenu

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup

Expand All @@ -14,6 +15,8 @@ open class ParallaxMain @JvmOverloads constructor(
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ViewGroup(context, attrs, defStyleAttr) {
var touchDisable = false

var realActivity: View? = null
set(value) {
if (field != value) removeView(field)
Expand Down Expand Up @@ -41,4 +44,8 @@ open class ParallaxMain @JvmOverloads constructor(
val height = b - t
realActivity?.layout(0, 0, width, height)
}

override fun onInterceptTouchEvent(ev: MotionEvent?) = touchDisable

fun isTouchDisabled() = touchDisable
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ open class ParallaxMenu @JvmOverloads constructor(
this@ParallaxMenu.apply { x = 0.toFloat() }
}

override fun onAnimationStart(animation: Animator?) {}
override fun onAnimationStart(animation: Animator?) {
(mainView as ParallaxMain).touchDisable = true
}
override fun onAnimationCancel(animation: Animator?) {}
})
}
Expand All @@ -87,6 +89,7 @@ open class ParallaxMenu @JvmOverloads constructor(
override fun onAnimationRepeat(animation: Animator?) {}
override fun onAnimationEnd(animation: Animator?) {
x = (-measuredWidth).toFloat()
(mainView as ParallaxMain).touchDisable = false
}

override fun onAnimationStart(animation: Animator?) {}
Expand Down
17 changes: 17 additions & 0 deletions sample/src/main/res/layout/menu_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<com.devrapid.parallaxsidemenu.ParallaxMenuItem
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif-smallcaps"
android:paddingBottom="16dp"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold"
tools:text="collection"/>

0 comments on commit e20dadd

Please sign in to comment.