You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package com.community.pocket.data.login;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.lifecycle.MutableLiveData;
|
|
|
|
|
|
|
|
import com.community.pocket.R;
|
|
|
|
import com.community.pocket.ui.login.LoginResponse;
|
|
|
|
import com.community.pocket.util.HttpRequest;
|
|
|
|
import com.community.pocket.util.HttpUtil;
|
|
|
|
import com.community.pocket.util.SimpleHttpParse;
|
|
|
|
|
|
|
|
import okhttp3.FormBody;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 登陆请求接口
|
|
|
|
*/
|
|
|
|
public class LoginRequest {
|
|
|
|
private static volatile LoginRequest instance;
|
|
|
|
|
|
|
|
private LoginRequest() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static LoginRequest getInstance() {
|
|
|
|
if (instance == null) {
|
|
|
|
instance = new LoginRequest();
|
|
|
|
}
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
@HttpRequest("/login")
|
|
|
|
public void login(MutableLiveData<LoginResponse> liveData, String username, String password) {
|
|
|
|
|
|
|
|
HttpUtil.getRequest(HttpUtil.Method.POST, new SimpleHttpParse<LoginResponse>(liveData, R.string.register_ok, null).getInterface(LoginResponse.class),
|
|
|
|
new FormBody.Builder()
|
|
|
|
.add("username", username)
|
|
|
|
.add("password", password)
|
|
|
|
.build());
|
|
|
|
}
|
|
|
|
}
|