use of com.fafu.zhengxianyou.livingincampus.bean.MyUser in project LivingInCampus by DulCoder.
the class UserFragment method logOff.
/**
* 退出登录相关
*/
private void logOff() {
MyUser user = new MyUser();
user.logOut();
loginReg.setClickable(true);
logout.setVisibility(View.GONE);
myIcon.setImageResource(R.drawable.overcast);
myId.setText("未登录");
MyApplication.editor.remove("icon");
editor.remove("nickName");
editor.commit();
Config.setMyIcon(null);
Config.setNickName(null);
}
use of com.fafu.zhengxianyou.livingincampus.bean.MyUser in project LivingInCampus by DulCoder.
the class AddCommunityFragment method publish.
/**
* 发布信息的相关逻辑
*/
private void publish() {
icon = Config.getMyIcon();
nickname = Config.getNickName();
if (icon != null && nickname != null) {
// 判断是否登录
content = etCommunity.getText().toString();
if (TextUtils.isEmpty(content)) {
Utils.toast(mContext, "输入不能为空");
} else if (content.length() > 140) {
Utils.toast(mContext, "内容字数不能大于140");
} else {
Date date = new Date();
DateFormat format = DateFormat.getDateTimeInstance();
// 获取当前时间
datetime = format.format(date);
MyUser user = BmobUser.getCurrentUser(MyUser.class);
final CommunityItem communityItem = new CommunityItem();
communityItem.setMyIcon(icon);
communityItem.setNickName(nickname);
communityItem.setDatetime(datetime);
communityItem.setContent(content);
communityItem.setAuthor(user);
communityItem.save(new SaveListener<String>() {
@Override
public void done(String s, BmobException e) {
if (e != null) {
Utils.toast(mContext, e.getErrorCode() + e.getMessage());
} else {
getFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.community_container, CommunityFragment.newInstance()).commit();
}
}
});
}
} else {
Utils.toast(mContext, "请登录");
}
}
use of com.fafu.zhengxianyou.livingincampus.bean.MyUser in project LivingInCampus by DulCoder.
the class LoginFragment method login.
private void login() {
name = et_login.getText().toString();
password = et_password.getText().toString();
final MyUser user = new MyUser();
user.setUsername(name);
user.setPassword(password);
user.login(new SaveListener<MyUser>() {
@Override
public void done(MyUser myUser, BmobException e) {
try {
if (e == null) {
MyApplication.editor.putBoolean("isChecked", cb_choice.isChecked());
if (cb_choice.isChecked()) {
editor.putString("name", name);
editor.putString("password", password);
}
String icon = myUser.getMyIcon();
String nickName = myUser.getNickName();
editor.putString("icon", icon);
editor.putString("nickName", nickName);
editor.commit();
getActivity().finish();
} else {
Log.e("err1", e.getErrorCode() + "" + e.getMessage());
}
} catch (Exception exception) {
Log.e("err", exception.getMessage() + "");
Utils.toast(mContext, "正在登录");
}
}
});
}
use of com.fafu.zhengxianyou.livingincampus.bean.MyUser in project LivingInCampus by DulCoder.
the class RegisterFragment method register.
/**
* 注册相关逻辑
*/
private void register(String login, String password, String nickName, String myIcon) {
MyUser user = new MyUser();
email = et_email.getText().toString();
user.setEmail(email);
user.setNickName(nickName);
user.setMyIcon(myIcon);
user.setUsername(login);
user.setPassword(password);
try {
user.signUp(new SaveListener<MyUser>() {
@Override
public void done(MyUser myUser, BmobException e) {
if (e == null) {
toast("注册成功");
goBack();
} else {
int error = e.getErrorCode();
toast("e" + error);
}
}
});
} catch (Exception exception) {
Log.e("ERROR", exception.getMessage());
}
}
Aggregations