Closed
Bug 1186529
Opened 9 years ago
Closed 9 years ago
Replace RecyclerViewItemClickListener.OnClickListener with RecyclerViewClickSupport
Categories
(Firefox for Android Graveyard :: General, defect)
Firefox for Android Graveyard
General
Tracking
(firefox42 fixed)
RESOLVED
FIXED
Firefox 42
Tracking | Status | |
---|---|---|
firefox42 | --- | fixed |
People
(Reporter: jonalmeida, Assigned: jonalmeida)
References
Details
Attachments
(2 files, 2 obsolete files)
5.69 KB,
patch
|
Details | Diff | Splinter Review | |
40 bytes,
text/x-review-board-request
|
jonalmeida
:
review+
|
Details |
We don't always need to implement onLongClick for every RecyclerView; sometimes we only want onClick. For later reference, comments from Sebastian: "I wrote RecyclerViewItemClickListener for a specific use case where I needed to listen for normal clicks and long clicks. I thought about later uses cases where you just want to click handler and don't care about long clicks but I didn't want to write code that isn't used. Maybe it makes sense to refactor RecyclerViewItemClickListener to handle these use cases without implementing empty methods. But that's something we can look at in a follow-up bug."
Assignee | ||
Comment 1•9 years ago
|
||
Sebastian, while typing out this bug I thought of a solution that might work: Make two interfaces in RecyclerViewItemClickListener, OnClickListener and OnLongClickListener. Would only require minor refactoring since the current OnClickListener is used in a lot of places for now. What do you think?
Flags: needinfo?(s.kaspari)
Comment 2•9 years ago
|
||
(In reply to Jonathan Almeida [:jonalmeida] from comment #1) > Sebastian, while typing out this bug I thought of a solution that might > work: Make two interfaces in RecyclerViewItemClickListener, OnClickListener > and OnLongClickListener. Would only require minor refactoring since the > current OnClickListener is used in a lot of places for now. > > What do you think? Sounds good! :)
Flags: needinfo?(s.kaspari)
Assignee | ||
Comment 3•9 years ago
|
||
I have a patch for this already (attached), but I won't submit it for review until bug 1184211 lands since it too needs to be changed.
Assignee: nobody → jalmeida
Comment 4•9 years ago
|
||
Interesting article and probably nicer approach then using a GestureDetector like I did: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
Assignee | ||
Comment 5•9 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=bc44c526feb6
Assignee | ||
Comment 6•9 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=456b5ad5923d
Assignee | ||
Comment 7•9 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=fa9ef5ec1a51
Assignee | ||
Comment 8•9 years ago
|
||
I tried out the click listener in that article is pretty easy to use. I replaced our current one with it and tested it out, our home panels and search bar still work as normal.
Assignee | ||
Comment 9•9 years ago
|
||
Bug 1186529 - Remove mandatory onLongClick in RecyclerViewItemClickListener.OnClickListener r?sebastian
Attachment #8644164 -
Flags: review?(s.kaspari)
Assignee | ||
Comment 10•9 years ago
|
||
Bug 1186529 - Adding ItemClickSupport for RecyclerView click handling r?sebastian
Attachment #8644165 -
Flags: review?(s.kaspari)
Assignee | ||
Comment 11•9 years ago
|
||
Bug 1186529 - Replacing OnClickListener with ItemClickSupport in PanelRecyclerView r?sebastian
Attachment #8644166 -
Flags: review?(s.kaspari)
Assignee | ||
Comment 12•9 years ago
|
||
https://reviewboard.mozilla.org/r/15237/#review13643 ::: mobile/android/base/home/ItemClickSupport.java:68 (Diff revision 1) > + public static ItemClickSupport removeFrom(RecyclerView view) { Just wanted to point out, I haven't found a reason to use removeFrom anywhere in our usages, but I may be mistaken.
Assignee | ||
Comment 13•9 years ago
|
||
https://reviewboard.mozilla.org/r/15237/#review13643 If everything looks good and we decide to stay with this ClickListener, I'll fold all these commits into one.
Comment 14•9 years ago
|
||
Comment on attachment 8644164 [details] MozReview Request: Bug 1186529 - Adding RecyclerViewClickSupport for click handling r?sebastian https://reviewboard.mozilla.org/r/15239/#review13661 I'm ignoring this patch as we are probably going for the new approach.
Attachment #8644164 -
Flags: review?(s.kaspari)
Comment 15•9 years ago
|
||
Comment on attachment 8644165 [details] MozReview Request: Bug 1186529 - Adding ItemClickSupport for RecyclerView click handling r?sebastian https://reviewboard.mozilla.org/r/15241/#review13663 There are some small things that I'd change but overall this is already r+. ::: mobile/android/base/home/ItemClickSupport.java:68 (Diff revision 1) > + public static ItemClickSupport removeFrom(RecyclerView view) { I agree that we don't have a usecase for removeFrom() and we probably won't have any in the near future. Feel free to minimize the class to what we actually need. ::: mobile/android/base/home/ItemClickSupport.java:13 (Diff revision 1) > +public class ItemClickSupport { We should explain in a comment what this class is good for (like the previous implementation did). Maybe we should rename it to make its usecase more clear? e.g. something like RecyclerViewItemClickSupport ... that's pretty long and confusing. Can you come up with something better? Let's also add a comment mentioning which article inspired this code. ::: mobile/android/base/home/ItemClickSupport.java:92 (Diff revision 1) > + Let's get rid of these empty lines. ::: mobile/android/base/home/SearchEngineBar.java:24 (Diff revision 1) > - implements RecyclerViewItemClickListener.OnClickListener { > +// implements RecyclerViewItemClickListener.OnClickListener { This comment should be gone in the final patch. :) ::: mobile/android/base/home/SearchEngineBar.java:73 (Diff revision 1) > + mItemClickSupport.setOnItemClickListener(this); We don't need the class member here, do we? Let's use the fancy chaining API: ItemClickSupport .addTo(this) .setOnItemClickListener(this); ::: mobile/android/base/resources/values/ids.xml:12 (Diff revision 1) > + <item type="id" name="item_click_support" /> If we are going to rename the class then maybe let's rename this one too.
Attachment #8644165 -
Flags: review?(s.kaspari) → review+
Comment 16•9 years ago
|
||
Comment on attachment 8644165 [details] MozReview Request: Bug 1186529 - Adding ItemClickSupport for RecyclerView click handling r?sebastian https://reviewboard.mozilla.org/r/15241/#review13665 ::: mobile/android/base/moz.build:329 (Diff revision 1) > + 'home/ItemClickSupport.java', This class is pretty much generic. We could move it to the widget package maybe.
Attachment #8644165 -
Flags: review+
Comment 17•9 years ago
|
||
Comment on attachment 8644166 [details] MozReview Request: Bug 1186529 - Replacing OnClickListener with ItemClickSupport in PanelRecyclerView r?sebastian https://reviewboard.mozilla.org/r/15243/#review13667 I see this patch already fixes some of the points mentioned when reviewing patch 2. :) ::: mobile/android/base/home/PanelRecyclerView.java:152 (Diff revision 1) > + NIT: Additional empty line?
Attachment #8644166 -
Flags: review?(s.kaspari) → review+
Assignee | ||
Comment 18•9 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f503e70eab9b
Assignee | ||
Updated•9 years ago
|
Summary: Remove mandatory onLongClick in RecyclerViewItemClickListener.OnClickListener → Replace RecyclerViewItemClickListener.OnClickListener with RecyclerViewClickSupport
Assignee | ||
Comment 19•9 years ago
|
||
https://reviewboard.mozilla.org/r/15241/#review13663 > We should explain in a comment what this class is good for (like the previous implementation did). > > Maybe we should rename it to make its usecase more clear? e.g. something like RecyclerViewItemClickSupport ... that's pretty long and confusing. Can you come up with something better? > > Let's also add a comment mentioning which article inspired this code. I decided to rename it to RecyclerViewClickSupport; a little long but I think it works.
Assignee | ||
Comment 20•9 years ago
|
||
Comment on attachment 8644164 [details] MozReview Request: Bug 1186529 - Adding RecyclerViewClickSupport for click handling r?sebastian Bug 1186529 - Adding RecyclerViewClickSupport for click handling r?sebastian
Attachment #8644164 -
Attachment description: MozReview Request: Bug 1186529 - Remove mandatory onLongClick in RecyclerViewItemClickListener.OnClickListener r?sebastian → MozReview Request: Bug 1186529 - Adding RecyclerViewClickSupport for click handling r?sebastian
Attachment #8644164 -
Flags: review?(s.kaspari)
Assignee | ||
Updated•9 years ago
|
Attachment #8644165 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Attachment #8644166 -
Attachment is obsolete: true
Assignee | ||
Comment 21•9 years ago
|
||
Comment on attachment 8644164 [details] MozReview Request: Bug 1186529 - Adding RecyclerViewClickSupport for click handling r?sebastian This is r+ with nits fixed. I lost sebastian's r+ when folding all my changesets into one. ¯\_(ツ)_/¯
Attachment #8644164 -
Flags: review?(s.kaspari) → review+
Comment 22•9 years ago
|
||
(In reply to Jonathan Almeida (:jonalmeida) from comment #19) > I decided to rename it to RecyclerViewClickSupport; a little long but I > think it works. Perfect!
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 23•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/c9b41f67d832
Keywords: checkin-needed
Comment 24•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/c9b41f67d832
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox42:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 42
Updated•3 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•