Last active
March 8, 2022 03:44
-
-
Save flyer88/5d7129fc2ca9010ff6109a81157fbafa to your computer and use it in GitHub Desktop.
如何实现 RxJava 的链式调用 -- map 方法的实现
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Api{ | |
void queryPhoto(String query,QueryCallback QueryCallback); | |
interface QueryCallback{ | |
void onQuerySuccess(List<Photo> photoList); | |
void onQueryFailed(Exception e); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PhotoUtils{ | |
Api mApi; | |
public void handlePhotoSync(){ | |
mApi.queryPhoto("flyer", new Api.QueryCallback() { | |
@Override | |
public void onQuerySuccess(List<Photo> photoList) { | |
Photo photo = getBestPhoto(photoList); | |
String imgUrl = photo.getUrl(); | |
} | |
@Override | |
public void onQueryFailed(Exception e) { | |
ToastUtils.show(e); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
=================================
异步里面还有异步方法,
flatMap
待续=================================