Skip to content
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

further touchup on kotlin conversion #154

Merged
merged 2 commits into from
Sep 5, 2023

Conversation

avalanchas
Copy link

@avalanchas avalanchas commented Aug 29, 2023

  • use more idiomatic language where possible, let-access, kotlin function calls, safe-access operators where possible
  • fix endless loop during panelstate set
  • method deprecation where possible, no breaking api changes for Java consumers
  • make class "open", wasn't final before, shouldn't be now, even has protected methods
  • remove companion object, unnecessary instance cost
  • touchup javadoc where necessary
  • fix several bugs caused by improper nullity access

demo app now also in working state
@hannesa2 are there any outstanding issues to merge this into master? please let me know, happy to help if I can

use more idiomatic language where possible, let-access, kotlin function calls, safe-access operators where possible
fix endless loop during panelstate set
remove companion object, unnecessary instance cost
touchup javadoc where necessary
fix several bugs caused by improper nullity access
/**
* Default peeking out panel height
*/
private const val DEFAULT_PANEL_HEIGHT = 68 // dp;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this back to companion object

}
}
}

companion object {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add companion object again

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain why? The companion is unnecessary here and adds an instance creation, wasting resources

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a point

@@ -1140,7 +1234,13 @@ class SlidingUpPanelLayout @JvmOverloads constructor(context: Context, attrs: At
setAllChildrenVisible()
}

override fun onViewPositionChanged(changedView: View?, left: Int, top: Int, dx: Int, dy: Int) {
override fun onViewPositionChanged(
Copy link
Owner

@hannesa2 hannesa2 Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This multi-line codestyle everywhere blows code up. I don't like it, but it's ok.

Copy link
Author

@avalanchas avalanchas Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no preference, we can revert that. Sorry I thought I have the kotlin default enabled for the auto-styling in the IDE, but you're saying single line is the default?

Something in the back of my head tells me there was an intention during kotlin language design to unify this better, I should google around a bit to check if there are global standards for this

Copy link
Owner

@hannesa2 hannesa2 Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep not that much attention why, but on my side it mostly use a single line.
I've the flavor in my head of preventing huge files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was able to trim it down by a couple of line :)
please let me know what else can be done to be able to merge this :)

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_toggle -> {
if (sliding_layout.panelState != PanelState.HIDDEN) {
sliding_layout.panelState = PanelState.HIDDEN
if (sliding_layout.getPanelState() != PanelState.HIDDEN) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point to move to getPanelState().
Why not using property access ?

I only get one more additional weak warning

image

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like, that you are no more interested in applying here some more changes.
I will merge it and I'll will revoke some changes from you by myself.
I've no clue, why you removed property access, but I will revoke this

Copy link
Author

@avalanchas avalanchas Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @hannesa2 I'm sorry I have two jobs currently, I am absolutely interested in this still, but I simply did not find time yet! I will look at the merge as soon as I can, please note that the variable panelState internally has a different name, this was causing the endless loop bug before, which I described in my first comment in this PR, it's important to understand which setter vs. field access is called by this method. But as I said, I will have a look at this soon. I'll build it in a clean way so that the IDE doesn't need to show warnings anymore.

Until then I ask for a bit more patience 🥺

@hannesa2 hannesa2 merged commit 6360aa3 into hannesa2:KotlinConversion Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants