-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70b3041
commit ad14bac
Showing
5 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
.../it/sephiroth/android/library/uigestures/demo/fragments/UIPanGestureRecognizerFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package it.sephiroth.android.library.uigestures.demo.fragments | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import it.sephiroth.android.library.uigestures.UIGestureRecognizer | ||
import it.sephiroth.android.library.uigestures.UIPanGestureRecognizer | ||
import it.sephiroth.android.library.uigestures.demo.R | ||
import kotlinx.android.synthetic.main.content_uipangesturerecognizer.* | ||
import timber.log.Timber | ||
import java.lang.ref.WeakReference | ||
|
||
class UIPanGestureRecognizerFragment(recognizer: WeakReference<UIGestureRecognizer>) : | ||
IRecognizerFragment<UIPanGestureRecognizer>(recognizer) { | ||
|
||
override fun getRecognizerStatus(): String? { | ||
getRecognizer()?.let { | ||
return "scroll: ${it.scrollX}, ${it.scrollY}, touches: ${it.numberOfTouches}" | ||
} | ||
return null | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
Timber.i("onCreate") | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return inflater.inflate(R.layout.content_uipangesturerecognizer, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
getRecognizer()?.let { | ||
numberPicker1.value = it.minimumNumberOfTouches | ||
numberPicker2.value = it.maximumNumberOfTouches | ||
} | ||
|
||
numberPicker1.setListener { | ||
getRecognizer()?.minimumNumberOfTouches = it | ||
} | ||
|
||
numberPicker2.setListener { | ||
getRecognizer()?.maximumNumberOfTouches = it | ||
} | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
fun newInstance(recognizer: UIGestureRecognizer) = | ||
UIPanGestureRecognizerFragment(WeakReference(recognizer)) | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
app/src/main/res/layout/content_uipangesturerecognizer.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior" | ||
app:layout_constraintTop_toBottomOf="@+id/recognizerSpinner" | ||
tools:context=".TapActivity" | ||
tools:showIn="@layout/activity_tap"> | ||
|
||
|
||
<com.michaelmuenzer.android.scrollablennumberpicker.ScrollableNumberPicker | ||
android:id="@+id/numberPicker1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="16dp" | ||
app:layout_constraintStart_toStartOf="@+id/guideline3" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:snp_maxValue="5" | ||
app:snp_minValue="1" | ||
app:snp_scrollEnabled="true" | ||
app:snp_value="1" /> | ||
|
||
<TextView | ||
android:id="@+id/textView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="8dp" | ||
android:text="Minimum Touches" | ||
app:layout_constraintBottom_toBottomOf="@+id/numberPicker1" | ||
app:layout_constraintEnd_toStartOf="@+id/guideline3" | ||
app:layout_constraintTop_toTopOf="@+id/numberPicker1" /> | ||
|
||
<com.michaelmuenzer.android.scrollablennumberpicker.ScrollableNumberPicker | ||
android:id="@+id/numberPicker2" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="16dp" | ||
app:layout_constraintStart_toStartOf="@+id/guideline3" | ||
app:layout_constraintTop_toBottomOf="@+id/numberPicker1" | ||
app:snp_maxValue="5" | ||
app:snp_minValue="1" | ||
app:snp_scrollEnabled="true" | ||
app:snp_value="1" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="8dp" | ||
android:text="Maximum Touches" | ||
app:layout_constraintBottom_toBottomOf="@+id/numberPicker2" | ||
app:layout_constraintEnd_toStartOf="@+id/guideline3" | ||
app:layout_constraintTop_toTopOf="@+id/numberPicker2" /> | ||
|
||
<androidx.constraintlayout.widget.Guideline | ||
android:id="@+id/guideline3" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
app:layout_constraintGuide_percent="0.5" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters