首先导入依赖:
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'//Retrofit2所需要的包
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'//ConverterFactory的Gson依赖包
compile 'com.squareup.retrofit2:converter-scalars:2.0.0-beta4'//ConverterFactory的String依赖包
compile 'com.facebook.fresco:fresco:0.11.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
1、API
public interface Api {
public static String HOST = "http://120.27.23.105/user/";
}
2、ServiceApi
public interface ServiceSApi {
//登录
@GET("{login}")
Flowable<LoginBean> getLogin(@Path("login") String login, @Query("mobile") String mob,@Query("password") String pw);
//注册
@GET("{reg}")
Flowable<RegisterBean> getReg(@Path("reg") String login,@Query("mobile")String mob,@Query("password")String pw);
//个人详情
@GET("{getUserInfo}")
Flowable<UserBean> getUser(@Path("getUserInfo") String login,@Query("uid")String id);
}