use of cn.nicolite.palm300heroes.model.bean.User in project Palm300Heroes by nicolite.
the class LoginActivity method login.
private void login(final String username, String password) {
ToastUtils.showToastShort("登录中...");
BmobUser bmobUser = new User();
bmobUser.setPassword(password);
if (username.contains("@")) {
BmobModel.userLoginByEmail(username, password, new LogInListener<User>() {
@Override
public void done(User user, BmobException e) {
if (e == null) {
ToastUtils.showToastShort("登录成功");
Intent intent = new Intent();
intent.putExtra("user_data", user);
LoginActivity.this.setResult(1, intent);
finish();
} else {
ToastUtils.showToastShort("登录失败,邮箱或者密码不正确!");
}
}
});
} else {
BmobModel.userLoginByUsername(username, password, new SaveListener<User>() {
@Override
public void done(User user, BmobException e) {
if (e == null) {
ToastUtils.showToastShort("登录成功");
Intent intent = new Intent();
intent.putExtra("user_data", user);
LoginActivity.this.setResult(1, intent);
finish();
} else {
ToastUtils.showToastShort("登录失败:用户名或者密码不正确!");
}
}
});
}
}
use of cn.nicolite.palm300heroes.model.bean.User in project Palm300Heroes by nicolite.
the class MoreFragment method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 200 && resultCode == 1) {
User user = (User) data.getSerializableExtra("user_data");
setUserInfo(user);
}
if (requestCode == 100 && resultCode == 2) {
User currentUser = BmobUser.getCurrentUser(User.class);
setUserInfo(currentUser);
}
if (requestCode == 100 && resultCode == 3) {
User currentUser = BmobUser.getCurrentUser(User.class);
setUserInfo(currentUser);
}
}
use of cn.nicolite.palm300heroes.model.bean.User in project Palm300Heroes by nicolite.
the class MoreFragment method onViewClick.
@OnClick({ R.id.theme_music, R.id.update, R.id.help, R.id.about, R.id.share, R.id.joinqq, R.id.user_root_view })
public void onViewClick(View view) {
switch(view.getId()) {
case R.id.theme_music:
// Intent intent = new Intent(getActivity(), WebViewActivity.class);
// Bundle bundle = new Bundle();
// bundle.putInt("type", WebViewActivity.TYPE_THEME_MUSIC);
// bundle.putString("url", Constants.MISSEVAN_PLAYLIST_URL);
// bundle.putString("title", "主题曲");
// intent.putExtras(bundle);
// startActivity(intent);
Intent intent = new Intent(getActivity(), ContainerActivity.class);
Bundle bundle = new Bundle();
bundle.putString("title", "主题曲");
bundle.putInt("type", ContainerActivity.TYPE_THEME_MUSIC);
intent.putExtras(bundle);
startActivity(intent);
break;
case R.id.update:
Beta.checkUpgrade();
break;
case R.id.help:
Intent help = new Intent(getActivity(), HelpActivity.class);
startActivity(help);
break;
case R.id.about:
Intent about = new Intent(getActivity(), AboutActivity.class);
startActivity(about);
break;
case R.id.share:
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_TEXT, "掌上300英雄\n" + getString(R.string.mainPage));
share.setType("text/plain");
startActivity(share);
break;
case R.id.joinqq:
joinQQGroup("wRl6tmw4JNr0iufx47gR2WXCqKyWPIXC");
break;
case R.id.user_root_view:
User currentUser = BmobUser.getCurrentUser(User.class);
if (currentUser == null) {
Intent login = new Intent(getActivity(), LoginActivity.class);
startActivityForResult(login, 200);
} else {
Intent userInfo = new Intent(getActivity(), UserInfoActivity.class);
userInfo.putExtra("user_data", currentUser);
startActivityForResult(userInfo, 100);
}
break;
}
}
use of cn.nicolite.palm300heroes.model.bean.User in project Palm300Heroes by nicolite.
the class MoreFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_more_old, container, false);
unbinder = ButterKnife.bind(this, view);
toolbar.setTitle("");
toolbarTitle.setText("更多");
for (int i = 0; i < viewList.size(); i++) {
View itemView = viewList.get(i);
ImageView menuImg = (ImageView) itemView.findViewById(R.id.menu_img);
TextView menuText = (TextView) itemView.findViewById(R.id.menu_text);
menuImg.setImageResource(menuImgs[i]);
menuText.setText(menuTexts[i]);
}
User currentUser = BmobUser.getCurrentUser(User.class);
setUserInfo(currentUser);
return view;
}
use of cn.nicolite.palm300heroes.model.bean.User in project Palm300Heroes by nicolite.
the class BmobModel method updateUserInfo.
/**
* 更新用户信息
* @param user 带有用户信息的bean
*/
public static void updateUserInfo(User user, UpdateListener updateListener) {
User currentUser = BmobUser.getCurrentUser(User.class);
user.update(currentUser.getObjectId(), updateListener);
}
Aggregations