Java 8 lambdas aside, most people here are missing that your code will not compile regardless of RetroLambda or any other great tool that you find somewhere to get around the missing lambda function in Android ...
So, take a close look at your code, you even added some comments to the snippet that actually explain to you why you have some compilation errors:
1 You have a method with an empty body :
Observable<List<String>> query(String text);
So, add the method body to it and fix the problem. What do you want to do? You do not know yet? Then add a fictitious or empty body and execute it later:
Observable<List<String>> query(String text) { return Observable.just(Arrays.asList("url1", "url2")); }
2 There is no query
variable in your code . You have a query
method, and the syntax for using the methods requires the use of curly braces:
query("whatever").subscribe(urls -> { for (String url : urls) { System.out.println(url); } });
Now add RetroLambda or use anonymous classes and you're done. Keep in mind that none of this will add much functionality to your code, but will only solve those compilation errors. Now ask yourself what you want to do in your query method and continue.
Note An Observable is a data stream, which basically means that you can get null elements, one element or many; all instances of the specified type. So your code seems to be expecting a stream of list of strings, if what you really want is a stream of strings, then replace Observable<List<String>>
with Observable<String>
.
source share