packagecom.example.myapplication.data;importandroid.util.Log;importcom.example.myapplication.data.model.LoggedInUser;importcom.example.myapplication.data.model.Token;importcom.google.gson.Gson;importcom.squareup.okhttp.FormEncodingBuilder;importcom.squareup.okhttp.OkHttpClient;importcom.squareup.okhttp.Request;importcom.squareup.okhttp.RequestBody;importcom.squareup.okhttp.Response;importjava.io.IOException;/*** Class that handles authentication w/ login credentials and retrieves user information.*/
public classLoginDataSource{publicLoginDataSource() {
}public Resultlogin(String username, String password) {try{//TODO: handle loggedInUser authentication//Demo中这个地方直接返回fakeUser,我在这里加入了用户验证过程
HttpLogin httpLogin = new HttpLogin("http://local.me/api/login",username,password);
Thread t1= new Thread(newRunnable() {public voidrun() {
httpLogin.login();
}
});<