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

Convert comment touch listener to a lambda #11075

Merged

Conversation

Isira-Seneviratne
Copy link
Member

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • Convert the CommentTextOnTouchListener class to a lambda in CommentInfoItemHolder.

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

@github-actions github-actions bot added the size/medium PRs with less than 250 changed lines label May 15, 2024
Copy link

sonarcloud bot commented May 15, 2024

@@ -128,7 +131,26 @@ public void updateFromItem(final InfoItem infoItem,
textEllipsizer.ellipsize();

//noinspection ClickableViewAccessibility
itemContentView.setOnTouchListener(CommentTextOnTouchListener.INSTANCE);
itemContentView.setOnTouchListener((v, event) -> {
Copy link
Member

Choose a reason for hiding this comment

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

I can remember times when a change just like this one would be discouraged for performance reasons because it instantiates the lambda every time that a CommentInfoItemHolder is created, and not only once. But I doubt anyone would give such advice anymore nowadays. 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

The Android compiler automatically converts lambdas to singletons if possible: https://jakewharton.com/androids-java-8-support/

Copy link
Member

Choose a reason for hiding this comment

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

@Isira-Seneviratne Ohh, that's really cool, thanks for sharing!

@Isira-Seneviratne Isira-Seneviratne merged commit 3e3d1fd into TeamNewPipe:dev May 25, 2024
7 checks passed
@Isira-Seneviratne Isira-Seneviratne deleted the Comment-touch-lambda branch May 25, 2024 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/medium PRs with less than 250 changed lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants