我正在开发一个简单的气象应用程序,并尝试通过改造来提取数据。我正在调试代码。
compositedisposable.add(apiservi by ..... 在这里,在调试的第36行“变量不可用”中写入和停止时,我无法提取数据。
-> newConsumer ...显示以下建议。
“匿名新使用者(Ctrl + F1) 检查信息:报告所有匿名类 Java 1.7或更早版本的JVM不支持Lambda语法。 “
如果您想查看GithubLink:https://github.com/rumtblbl/LocationWeatherApp
请帮助我,谢谢。 WeatherCityNameServiceImp.java
package com.example.locationweatherapp.Data.Network.Service;
import android.view.View;
import android.widget.Toast;
import com.example.locationweatherapp.Data.Network.ApiClient;
import com.example.locationweatherapp.Data.Network.ApiInterface;
import com.example.locationweatherapp.Data.Network.Model.WeatherResult;
import com.example.locationweatherapp.Utility.Utils;
import com.squareup.picasso.Picasso;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
public class WeatherCityNameServiceImp implements WeatherCityNameService {
private ApiInterface apiService;
CompositeDisposable compositeDisposable;
@Inject
public WeatherCityNameServiceImp() {
apiService = ApiClient.getClient().create(ApiInterface.class);
compositeDisposable = new CompositeDisposable();
}
@Override
public void weatherCityNameService(String cityName, final ServiceCallBack<WeatherResult> callBack) {
compositeDisposable.add(apiService.weatherCityNameService(cityName, Utils.APP_ID, "metric")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<WeatherResult>() {
@Override
public void accept(WeatherResult weatherResult) throws Exception {
callBack.onResponse(weatherResult);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
callBack.onError(throwable.getMessage());
}
})
);
}
}