I am in the process of writing code to access my web service from my android client. At that moment, when I use the modification to return the observed type for various calls. At the moment when I have 4 of them (shown below)
@FormUrlEncoded @POST("/app/{pathto}") Observable<List<EntryItem>> getNewsAndComments(@Path("pathto") String pathto, @FieldMap Map<String, String> fieldnames); @FormUrlEncoded @POST("/app/{pathto}") Observable<message> postComment(@Path("pathto") String pathto, @FieldMap Map<String, String> fieldnames); @FormUrlEncoded @POST("/{pathto}") Call<message> regDevice(@Path("pathto") String pathto ,@FieldMap Map<String, String> fieldnames); @FormUrlEncoded @POST("/app/{pathto}") Observable<Map<String, ArrayList<CantItem>>> getCanteenItems(@Path("path") String path, @FieldMap Map<String,String> fielditems);
I also use the generic RestService factory to create a universal retooling service. I stole this from a blog post I read :).
public static <T> T getRetroFitService(final Class<T> clazz, final String endpoint) { final Retrofit retrofit = new Retrofit.Builder() .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .baseUrl(endpoint) .build(); T service = retrofit.create(clazz); return service; }
In my interface, where I return observable etc. many method calls look the same, so I tried changing this to the next general call
Observable<List<T>>
Unfortunately, the modification does not seem to like it. I was wondering if there is a way around this so that I can make interface calls even more universal, for example by passing my own TypeAdapter to RestServiceFactory? Also, I'm relatively new to modernization and rx-android, so any advice is welcome. Thanks!
source share