我的项目中出现了以下警告:
对于原始类型'IWeatherCallbackListener'的成员'getWeatherData(T,Boolean,String)'进行了未经检查的调用。
我创建了以下接口 -
public interface IWeatherCallbackListener<T> {
void getWeatherData(T weatherModel, Boolean success, String errorMsg);
}
并按照以下方式进行调用:
public class WeatherConditions {
private static IWeatherApi mWeatherApi;
/**
* @param city
* @param appId
* @param listener
*/
public static void getOpenWeatherData(String city, String appId, IWeatherCallbackListener listener) {
mWeatherApi = ApiService.getRetrofitInstance(BASE_URL_OPEN_WEATHER).create(IWeatherApi.class);
Call<OpenWeatherModel> resForgotPasswordCall = mWeatherApi.getOpenWeatherData(appId, city);
resForgotPasswordCall.enqueue(new Callback<OpenWeatherModel>() {
@Override
public void onResponse(Call<OpenWeatherModel> call, Response<OpenWeatherModel> response) {
if (response.body() != null) {
if (listener != null)
listener.getWeatherData(response.body(), true, "");
}
}
@Override
public void onFailure(Call<OpenWeatherModel> call, Throwable t) {
if (listener != null)
listener.getWeatherData(null, false, t.getMessage());
}
});
}
我已经在我的MainActivity中实现了这个接口,并调用了该方法 -
WeatherConditions.getOpenWeatherData(etCityName.getText().toString(), OPEN_WEATHER_APP_ID, MainActivity.this)
有人能帮忙并解释一下这个警告吗?