-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added custom predictive back gesture layer (#329)
- Loading branch information
Showing
11 changed files
with
198 additions
and
14 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
29 changes: 29 additions & 0 deletions
29
app/src/main/java/app/simple/inure/decorations/transitions/CustomTransition.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,29 @@ | ||
package app.simple.inure.decorations.transitions | ||
|
||
import android.animation.Animator | ||
import android.animation.ObjectAnimator | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.transition.Transition | ||
import androidx.transition.TransitionValues | ||
|
||
class CustomTransition : Transition() { | ||
override fun captureStartValues(transitionValues: TransitionValues) { | ||
transitionValues.values["custom:transition:alpha"] = transitionValues.view.alpha | ||
} | ||
|
||
override fun captureEndValues(transitionValues: TransitionValues) { | ||
transitionValues.values["custom:transition:alpha"] = 1f | ||
} | ||
|
||
override fun createAnimator( | ||
sceneRoot: ViewGroup, | ||
startValues: TransitionValues?, | ||
endValues: TransitionValues? | ||
): Animator? { | ||
val view = endValues?.view ?: return null | ||
val startAlpha = startValues?.values?.get("custom:transition:alpha") as? Float ?: 0f | ||
val endAlpha = endValues.values["custom:transition:alpha"] as Float | ||
return ObjectAnimator.ofFloat(view, View.ALPHA, startAlpha, endAlpha) | ||
} | ||
} |
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
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
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,27 @@ | ||
package app.simple.inure.math | ||
|
||
object Range { | ||
fun Float.mapRange(fromMin: Float, fromMax: Float, toMin: Float, toMax: Float): Float { | ||
return (this - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin | ||
} | ||
|
||
fun Float.mapRange(fromMin: Int, fromMax: Int, toMin: Int, toMax: Int): Float { | ||
return (this - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin | ||
} | ||
|
||
fun Double.mapRange(fromMin: Double, fromMax: Double, toMin: Double, toMax: Double): Double { | ||
return (this - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin | ||
} | ||
|
||
fun Int.mapRange(fromMin: Int, fromMax: Int, toMin: Int, toMax: Int): Int { | ||
return ((this - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin).toInt() | ||
} | ||
|
||
fun Long.mapRange(fromMin: Long, fromMax: Long, toMin: Long, toMax: Long): Long { | ||
return ((this - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin).toLong() | ||
} | ||
|
||
fun Float.normalize(min: Float, max: Float): Float { | ||
return (this - min) / (max - min) | ||
} | ||
} |
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
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