|
@@ -13,13 +13,17 @@ import android.widget.EditText;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.common.library.cache.Cache;
|
|
|
import com.common.library.okhttp.callback.Callback;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.ynstkz.shitu.android.R;
|
|
|
import com.ynstkz.shitu.android.base.TitleBarActivity;
|
|
|
import com.ynstkz.shitu.android.bean.LoginBean;
|
|
|
+import com.ynstkz.shitu.android.bean.UserBean;
|
|
|
import com.ynstkz.shitu.android.data.RequestGroup;
|
|
|
+import com.ynstkz.shitu.android.data.SharedPreferencesUtils;
|
|
|
import com.ynstkz.shitu.android.event.LocationChangedEvent;
|
|
|
+import com.ynstkz.shitu.android.event.LoginEvent;
|
|
|
import com.ynstkz.shitu.android.event.RegisterSuccessEvent;
|
|
|
import com.ynstkz.shitu.android.utils.StatusBarUtil;
|
|
|
|
|
@@ -135,12 +139,31 @@ public class LoginActivity extends TitleBarActivity {
|
|
|
|
|
|
@Override
|
|
|
public void onError(Call call, Exception e, int id) {
|
|
|
-
|
|
|
+ showToast(getString(R.string.error_msg));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onResponse(Object response, int id) {
|
|
|
-
|
|
|
+ LoginBean loginBean = (LoginBean)response;
|
|
|
+ if(loginBean != null){
|
|
|
+ if("200".equals(loginBean.getCode())){
|
|
|
+ if(loginBean.getData() != null){
|
|
|
+
|
|
|
+ SharedPreferencesUtils.setLogin(true);
|
|
|
+ EventBus.getDefault().post(new LoginEvent());
|
|
|
+ showToast(loginBean.getMsg());
|
|
|
+
|
|
|
+ UserBean userBean = new UserBean();
|
|
|
+ userBean.setUserName(loginBean.getData().getUserName());
|
|
|
+ userBean.setUserId(loginBean.getData().getUserId()+"");
|
|
|
+ userBean.setToken(loginBean.getData().getToken());
|
|
|
+ Cache.put("UserBean", userBean);
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ showToast(loginBean.getMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|