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

Swipeable autoclose #3093

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

ThomasH99
Copy link
Contributor

Added support necessary to close an already open SwipeableContainer as soon as another one starts opening.

Copy link
Collaborator

@codenameone codenameone left a comment

Choose a reason for hiding this comment

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

Thanks!
Looks great just a couple of cosmetic changes to make usage possible without overriding.

@@ -383,6 +383,8 @@ public void actionPerformed(ActionEvent evt) {
}

if (initialX != -1) {
if (getPreviouslyOpened() != null && getPreviouslyOpened() != SwipeableContainer.this && getPreviouslyOpened().isOpen())
getPreviouslyOpened().close();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add curly brackets around the statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, yes, sure

public SwipeableContainer getPreviouslyOpened() {
return null;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a field and a setter, also include text in the @return tag otherwise the Javadoc looks weird

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my use case (and I believe most other), a field and setter doesn't make sense: I have a long list of SwipeableContainers and keep track of which is opened in the Form (I overwrite openToLeft, openToRight and close() to store/remove an open Swipeable). For a local field (like 'openSwipeable') to make sense, every SwipeableContainer would need to get that set.

I assume there might be a better overall way to smoothly close any already opened Swpeiable, but here I went for minimal impact to the existing code.

(NB. My first attempt was to override openToLeft/openToRight to close the previously opened Swipeable, but since they only get called once Swipeable is completely opened, it didn't look right).

If you still think it makes sense, I can add these since it won't break anything, at worst it could lead a developer down a wrong path at first :-)

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.

2 participants