视频串Mvvm框架
Api:
public interface Api { @GET("/foods/getFoods") Observable<FoodEntity> getFoodData(@Query("currentPage") int currentPage,@Query("pageSize") int pageSize); @GET("video/findVideos?&") Observable<ShiEntity> getShiData(@Query("currentPage")int currentPage,@Query("pageSize")int pageSize);
RetrofitManager:
public class RetrofitManager { //私有化构造 private RetrofitManager(){} //声明变量 private static RetrofitManager retrofitManager=null; //对外提供接口 public static RetrofitManager getInstance(){ if(retrofitManager==null){ retrofitManager=new RetrofitManager(); } return retrofitManager; } private Retrofit mretrofit; private Retrofit getRetrofit(){ if(mretrofit==null){ mretrofit=createRetrofit(); } return mretrofit; } public Retrofit createRetrofit(){ OkHttpClient okHttpClient=new OkHttpClient.Builder() .writeTimeout(5, TimeUnit.MINUTES) .connectTimeout(5, TimeUnit.MINUTES) .readTimeout(5,TimeUnit.MINUTES) //日志拦截器 .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) .build(); mretrofit=new Retrofit.Builder() .client(okHttpClient) .baseUrl("http://10.161.9.80:7012") .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .build(); return mretrofit; } }
Mvvm框架:
视频解串
视频实体类:
视频适配器和布局