Android所有文章都配视频讲解Android开发Android

Github最火开源项目-RxjavaUtil

2017-03-06  本文已影响294人  小怪兽打葫芦娃

自定义控件

联网

工具

数据库

源码分析相关面试题

Activity相关面试题

Service相关面试题

与XMPP相关面试题

与性能优化相关面试题

与登录相关面试题

与开发相关面试题

与人事相关面试题

Rxjava快速封装实现的示例工程,包括变换的使用以及与Retrofit联用

开源项目地址:https://github.com/open-android/RxjavaUtils

      <uses-permission android:name="android.permission.INTERNET" />

接口地址:http://api.openweathermap.org/data/2.5/weather?q=shenzhen&mode=json&APPID=6c113432fd84a6e28268af291821db16

    {"coord":{"lon":114.07,"lat":22.55},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"base":"stations","main":{"temp":293.15,"pressure":1018,"humidity":72,"temp_min":293.15,"temp_max":293.15},"visibility":10000,"wind":{"speed":3.69,"deg":116.004},"clouds":{"all":0},"dt":1483538400,"sys":{"type":1,"id":7420,"message":0.0134,"country":"CN","sunrise":1483484686,"sunset":1483523588},"id":1795565,"name":"Shenzhen","cod":200}
    private static final RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(ENDPOINT).setLogLevel(RestAdapter.LogLevel.FULL).build();
    private static final AppApi appService = restAdapter.create(AppApi.class);
    public static Observable<WeatherData> getWeatherData(final String city) {
    return Observable.create(new Observable.OnSubscribe<WeatherData>() {
        @Override
        public void call(Subscriber<? super WeatherData> subscriber) {
            subscriber.onNext(appService.getWeather(city,"json", "6c113432fd84a6e28268af291821db16"));
            subscriber.onCompleted();
        }
    }).subscribeOn(Schedulers.io());
}

欢迎关注微信公众号

微信公众号名称:Android干货程序员

上一篇 下一篇

猜你喜欢

热点阅读