-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert ZoomOutPageTransformer to Kotlin #153
Conversation
WalkthroughThis pull request refactors parts of the codebase from Java to Kotlin. The Java implementations of the Changes
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
app/src/main/java/ai/elimu/vitabu/ui/viewpager/ZoomOutPageTransformer.kt (2)
21-24
: Consider simplifying type conversions.The current implementation involves unnecessary conversions between
Float
andDouble
. Sinceposition
is already aFloat
andMIN_SCALE
is also aFloat
, you could simplify this by keeping everything asFloat
.- val scaleFactor = max( - MIN_SCALE.toDouble(), - (1 - abs(position.toDouble())) - ).toFloat() + val scaleFactor = max( + MIN_SCALE, + (1 - abs(position)) + )
38-40
: Improve the expression formatting.The expression for calculating
view.alpha
spans multiple lines and could be formatted more clearly. Consider using parentheses to make the order of operations more explicit and formatting it in a more readable way.- view.alpha = MIN_ALPHA + - (scaleFactor - MIN_SCALE) / - (1 - MIN_SCALE) * (1 - MIN_ALPHA) + view.alpha = MIN_ALPHA + + ((scaleFactor - MIN_SCALE) / (1 - MIN_SCALE)) * (1 - MIN_ALPHA)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
app/src/main/java/ai/elimu/vitabu/ui/storybook/AudioListener.kt
(1 hunks)app/src/main/java/ai/elimu/vitabu/ui/viewpager/ZoomOutPageTransformer.kt
(1 hunks)app/src/main/java/ai/elimu/vitabu/ui/storybook/AudioListener.java
(0 hunks)app/src/main/java/ai/elimu/vitabu/ui/viewpager/ZoomOutPageTransformer.java
(0 hunks)
💤 Files with no reviewable changes (2)
- app/src/main/java/ai/elimu/vitabu/ui/storybook/AudioListener.java
- app/src/main/java/ai/elimu/vitabu/ui/viewpager/ZoomOutPageTransformer.java
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build (windows-latest, 21)
- GitHub Check: build (windows-latest, 17)
🔇 Additional comments (4)
app/src/main/java/ai/elimu/vitabu/ui/storybook/AudioListener.kt (1)
1-5
: Well-executed conversion to Kotlin!The Java interface has been properly converted to follow Kotlin conventions:
- Removed the redundant
public
modifier as interfaces in Kotlin are public by default- Changed the method declaration from
void onAudioDone();
tofun onAudioDone()
- Maintained the same functional contract while adopting Kotlin's more concise syntax
This conversion is clean and correctly implements the interface in idiomatic Kotlin.
app/src/main/java/ai/elimu/vitabu/ui/viewpager/ZoomOutPageTransformer.kt (3)
11-12
: Good conversion to Kotlin syntax.You've correctly implemented the class declaration and method override using Kotlin conventions. Removing the redundant
public
modifier and adding theoverride
keyword follows best practices.
47-50
: Good use of companion object for constants.You've correctly moved the static constants from Java to a Kotlin companion object and used the
const val
modifier for compile-time constants. This follows Kotlin best practices.
1-7
: Appropriate imports for Kotlin math functions.You've correctly imported Kotlin's math functions (
abs
andmax
) to replace the Java equivalents. This aligns with Kotlin best practices of using standard library functions.
ZoomOutPageTransformer
,AudioListener
to KotlinSummary by CodeRabbit