Android/Java - remove method reference from List
I have a array list of method references (object::method) where I insert some methods when the user clicks a button. The problem is that I also need to remove some specific method references at some point. If I use list.remove(object::method) the method is not removed because the lambda object::method has another ID every time I use it. I want each object::method to be removable so I need a way to get the same lambda ID for each object-method-pair. Is there a way to accomplish this or do I have to manually keep track of every ID I added so I can remove it?
From this answer http://stackoverflow.com/a/29082592/2657100 the target type of a method reference or a lambda expression should be a functional interface. Based on that only, runtime will create an instance of a class providing implementation of the given functional interface. Try adding in a list the same method reference twice. You'll see that you'll have two different objects, and calling equals on one another will probably return false. So you will have a hard time managing instances of functional interfaces without an auxiliary structure like an ID or a reflective Method instance, or something like that.
How to unregisterReceiver from an activity
How to convert this segment of Java code to C++? [closed]
Thread stuck busy waiting under some circumstances and not under others
HTTP connection made in Java fails with too many redirects?
Difficulty with Collections.binarySearch
Variable within constructor is returning null?
Display labels of data [deep4j]
Extending a Pane in JavaFX
Java BufferedImage to ByteArrayOutputStream without close ByteArrayOutputStream [duplicate]
Overriding inherited CMD in Dockerfile does not always work?
C# WCF Service and Java Client
How to Start New Activity from ArrayAdapter through button?
How many jars should I add to make the application working?
SOAP - ServerSOAPFaultException is thrown instead of appropriate #WebFault exception
Can't deploy properly
How to manage bitmap memory in android?