Привет в приведенном ниже коде отправляю метод как получить и получать ответ и хочу отобразить этот ответ, который нужно установить в переменные.
Но я не получаю никакого ответа от data.am, отправляющего метод get с использованиемэтот метод получает ответ. после того, как ответ был успешным, а затем необходимо установить для этого текста значение textviews
API.java:
public interface API {
public static final String BASE_URL="ip address";
@GET("/gateway_schedule")
Call<List<GetScheduler>> getSchedulerData();
}
Scheduler.java:
mPreset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getCCTAndIntensityValuesForPreset();
}
});
private void getCCTAndIntensityValuesForPreset() {
try {
String url = "http://XXXXXXXXXX/";
Retrofit retrofit = null;
Log.d("123", "retrofit");
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.build();
Log.d("123", "build();");
}
API service = retrofit.create(API.class);
Call<List<GetScheduler>> call = (Call<List<GetScheduler>>) service.getSchedulerData();
Log.d("123", "Call<List<GetScheduler>> call = service.getSchedulerData();");
call.enqueue(new Callback<List<GetScheduler>>() {
@Override
public void onResponse(Call<List<GetScheduler>> call, Response<List<GetScheduler>> response) {
if(response!=null&&response.isSuccessful()){
String getLightId=response.body().get(0).getLight_id().toString();
Toast.makeText(getApplicationContext(),"Light Id"+getLightId,Toast.LENGTH_LONG).show();
//String light_id=response.body()
}
}
@Override
public void onFailure(Call<List<GetScheduler>> call, Throwable t) {
}
});
}catch (Exception e) {Log.d("123", "Exception");}
}
Getscheduler.java:
public class GetScheduler {
@SerializedName("light_id")
private String light_id;
@SerializedName("intensity")
private int[] intensity;
@SerializedName("cct")
private int[] cct;
public String getLight_id() {
return light_id;
}
public void setLight_id(String light_id) {
this.light_id = light_id;
}
public int[] getIntensity() {
return intensity;
}
public void setIntensity(int[] intensity) {
this.intensity = intensity;
}
public int[] getCct() {
return cct;
}
public void setCct(int[] cct) {
this.cct = cct;
}
}