A few quick comments: 1. You're calling a blocking method from the UI thread. Don't do that. Instead, call the blocking method on a background thread and post the results back to the UI thread when it returns. That's how the code I posted yesterday works. If you want to collect all the results before returning them, modify the listener interface to accept a list of clients, and collect the results on a background thread. You can use a CountDownLatch to wait for all the results to be returned.
2. You have two methods for getting the reachable clients, but you're only calling one of them. If you're worried about verbosity, get rid of the unused method and interface. :-) 3. You're declaring stuff final all over the place, which suggests you don't know which things need to be final. Try to work out which things need to be final and why, it will give you a better understanding of your code. StrictMode is useful for catching problems such as blocking the UI thread: http://developer.android.com/reference/android/os/StrictMode.html Cheers, Michael On 12/05/15 21:54, Daniel Martí wrote: > Ended up using threadpools as you suggested, thanks for the hints! > > This is the end result, which seems to work: > https://github.com/mvdan/libaccesspoint/commit/38a37ac5a482ace1c8196267d604832654075683 > > It's still too verbose in my opinion, but it works and seems correct. > Reminded me of how futures work in a very similar way in Python. > > Comments and criticism welcome if you see anything horrible in that code > :) > > On Tue, May 12, 2015 at 21:49:13 +0200, Daniel Martí wrote: >> This looks promising, thank you Michael! Will test it out :) >
signature.asc
Description: OpenPGP digital signature
_______________________________________________ List info: https://lists.mayfirst.org/mailman/listinfo/guardian-dev To unsubscribe, email: [email protected]
