I'm new with retrofit and I want to make my getData method to return a feature object. What is the easiest way to do that?
DataService.java
public class DataService {
private static final String TAG = MainActivity.class.getSimpleName();
private final ApiClient apiClient;
public DataService() {
apiClient = new ApiClientFactory().createApiClient();
}
public List<Feature> getData(){
apiClient.getData().enqueue(new Callback<DataResponse>() {
@Override
public void onResponse(Call<DataResponse> call, Response<DataResponse> response) {
List<Feature> features = response.body().getFeatures();
Log.d(TAG, "Data successfully downloaded");
}
@Override
public void onFailure(Call<DataResponse> call, Throwable t) {
Log.e(TAG, t.toString());
}
});
//I need to return features in getData method
}
}