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

get View of dialog List item #29

Closed
mubtadasyed opened this issue Apr 30, 2017 · 8 comments
Closed

get View of dialog List item #29

mubtadasyed opened this issue Apr 30, 2017 · 8 comments

Comments

@mubtadasyed
Copy link

Hi, I want to show popup menu when a user longClick on any dialog list item, to show popup menu I need the view of that list item, how can I get that? kindly help.

@mradzinski
Copy link
Contributor

mradzinski commented May 2, 2017

DialogsList.setOnDialogLongClickListener should give you a Dialog instance of the dialog the user is pressing. So, having that instance already you should invoke DialogsList.getLayoutManager to get the LinearLayoutManager instance held by the RecyclerView that DialogsList extends from. Once you have the reference to that LayoutManager it's easy, you should invoke LayoutManager.findViewByPosition which will return the view you are looking for.

@mubtadasyed
Copy link
Author

How can I get the position of that dialog instance, as dialog adapter does not have that method? kindly help!

@mradzinski
Copy link
Contributor

mradzinski commented May 2, 2017

DialogsListAdapter doesn't seem to provide a getter for the list of items you need, so you either keep track of your actions (by having a secondary list of DIALOG synchronized with the one held inside the DialogsListAdapter) or fork this repo and add a getItems() method on the DialogsListAdapter class. Having that list of DIALOG you'll be able to call List.indexOf to get the position.

Check the code of DialogsListAdapter and read the RecyclerView.adapter and LinearLayoutManager official documentation. All you need is in there, you just need to think how to use it.

@mubtadasyed
Copy link
Author

Thanks, it worked!

@mradzinski
Copy link
Contributor

I already created a PR to allow the users to retrieve the current position of a certain dialog. As soon as it gets merged (if it is) you can get back to relay on the official implementation of this library.

@troy379
Copy link
Contributor

troy379 commented May 3, 2017

Hi @mubtadasyed !
Starting from version 0.2.1 you can use OnMessageViewClickListener and OnMessageViewLongClickListener, which has the same behavior as previous listeners, but also returns view. Hope it helps you.

Best regards, Alexander.

@troy379 troy379 closed this as completed May 3, 2017
@mradzinski
Copy link
Contributor

mradzinski commented May 3, 2017

Hey @troy379, the main reason for creating the PR was because providing listeners can be very limiting for the developer. For example, how does the developer implement a swipe to delete functionality based on those listeners? IMHO, having the possibility to retrieve the view itself (through RecyclerView and RecyclerView.Adapter methods) is much more flexible than providing a listener itself.

@bevzaanton
Copy link
Contributor

#32 merged. Thanks @mradzinski

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

No branches or pull requests

4 participants