Search in sources :

Example 16 with UpdateListener

use of cn.bmob.v3.listener.UpdateListener in project CoCoin by Nightonke.

the class SetPasswordActivity method buttonClickOperation.

private void buttonClickOperation(boolean longClick, int position) {
    switch(CURRENT_STATE) {
        case NEW_PASSWORD:
            if (CoCoinUtil.ClickButtonDelete(position)) {
                if (longClick) {
                    CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].init();
                    newPassword = "";
                } else {
                    CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].clear(newPassword.length() - 1);
                    if (newPassword.length() != 0)
                        newPassword = newPassword.substring(0, newPassword.length() - 1);
                }
            } else if (CoCoinUtil.ClickButtonCommit(position)) {
            } else {
                CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].set(newPassword.length());
                newPassword += CoCoinUtil.BUTTONS[position];
                if (newPassword.length() == 4) {
                    // finish the new password input
                    CURRENT_STATE = PASSWORD_AGAIN;
                    viewPager.setCurrentItem(PASSWORD_AGAIN, true);
                }
            }
            break;
        case PASSWORD_AGAIN:
            if (CoCoinUtil.ClickButtonDelete(position)) {
                if (longClick) {
                    CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].init();
                    againPassword = "";
                } else {
                    CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].clear(againPassword.length() - 1);
                    if (againPassword.length() != 0)
                        againPassword = againPassword.substring(0, againPassword.length() - 1);
                }
            } else if (CoCoinUtil.ClickButtonCommit(position)) {
            } else {
                CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].set(againPassword.length());
                againPassword += CoCoinUtil.BUTTONS[position];
                if (againPassword.length() == 4) {
                    // if the password again is equal to the new password
                    if (againPassword.equals(newPassword)) {
                        CURRENT_STATE = -1;
                        showToast(2);
                        SettingManager.getInstance().setPassword(newPassword);
                        SettingManager.getInstance().setFirstTime(false);
                        if (SettingManager.getInstance().getLoggenOn()) {
                            User currentUser = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
                            currentUser.setAccountBookPassword(newPassword);
                            currentUser.update(CoCoinApplication.getAppContext(), currentUser.getObjectId(), new UpdateListener() {

                                @Override
                                public void onSuccess() {
                                    Log.d("Saver", "Set password successfully.");
                                }

                                @Override
                                public void onFailure(int code, String msg) {
                                    Log.d("Saver", "Set password failed.");
                                }
                            });
                        }
                        final Handler handler = new Handler();
                        handler.postDelayed(new Runnable() {

                            @Override
                            public void run() {
                                finish();
                            }
                        }, 1000);
                    } else {
                        CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].clear(4);
                        ((PasswordChangeFragment) passwordAdapter.getItem(CURRENT_STATE - 1)).init();
                        CURRENT_STATE = NEW_PASSWORD;
                        viewPager.setCurrentItem(NEW_PASSWORD, true);
                        newPassword = "";
                        againPassword = "";
                        showToast(1);
                    }
                }
            }
            break;
        default:
            break;
    }
}
Also used : User(com.nightonke.saver.model.User) BmobUser(cn.bmob.v3.BmobUser) Handler(android.os.Handler) UpdateListener(cn.bmob.v3.listener.UpdateListener)

Example 17 with UpdateListener

use of cn.bmob.v3.listener.UpdateListener in project expression by happy-yuxuan.

the class MyInfoFragment method uploadImageHead.

// 上传图片到bmob
private void uploadImageHead(String bmString) {
    BitmapDrawable bitmap = (BitmapDrawable) getResources().getDrawable(R.drawable.add_pic);
    String addPicImgString = UtilTools.bitmapToString(getActivity(), bitmap);
    if (!bmString.equals(addPicImgString)) {
        MyUser newUser = new MyUser();
        newUser.setImgHead(bmString);
        BmobUser bmobUser = MyUser.getCurrentUser();
        newUser.update(bmobUser.getObjectId(), new UpdateListener() {

            @Override
            public void done(BmobException e) {
                if (e == null) {
                    L.i("上传头像成功");
                } else {
                    L.i("上传头像失败" + e);
                }
            }
        });
    }
}
Also used : MyUser(com.yuxuan.admin.expression.entity.MyUser) BmobException(cn.bmob.v3.exception.BmobException) BmobUser(cn.bmob.v3.BmobUser) BitmapDrawable(android.graphics.drawable.BitmapDrawable) UpdateListener(cn.bmob.v3.listener.UpdateListener)

Example 18 with UpdateListener

use of cn.bmob.v3.listener.UpdateListener in project expression by happy-yuxuan.

the class KDTeamRegister method regiestTeam.

private void regiestTeam() {
    String team_phone = et_team_teleohone.getText().toString().trim();
    String team_mail = et_team_mail.getText().toString().trim();
    String tname = et_tname.getText().toString().trim();
    if (!TextUtils.isEmpty(team_phone) && !TextUtils.isEmpty(team_mail) && !TextUtils.isEmpty(tname)) {
        if (UtilTools.checkMobileNumber(team_phone) && UtilTools.checkEmail(team_mail)) {
            MyUser u = new MyUser();
            u.setMobilePhoneNumber(team_phone);
            u.setEmail(team_mail);
            u.setTeamFlag(tname);
            BmobUser bmobUser = MyUser.getCurrentUser();
            u.update(bmobUser.getObjectId(), new UpdateListener() {

                @Override
                public void done(BmobException e) {
                    if (e == null) {
                        Toast.makeText(KDTeamRegister.this, "注册成功", Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(KDTeamRegister.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                        L.i(e.getMessage() + e.getErrorCode());
                    }
                }
            });
        } else {
            if (!UtilTools.checkMobileNumber(team_phone)) {
                Toast.makeText(KDTeamRegister.this, "电话格式不正确", Toast.LENGTH_SHORT).show();
            } else if (!UtilTools.checkEmail(team_mail)) {
                Toast.makeText(KDTeamRegister.this, "邮箱格式不正确", Toast.LENGTH_SHORT).show();
            }
        }
    } else {
        Toast.makeText(KDTeamRegister.this, "信息不能为空", Toast.LENGTH_SHORT).show();
    }
}
Also used : MyUser(com.yuxuan.admin.expression.entity.MyUser) BmobException(cn.bmob.v3.exception.BmobException) BmobUser(cn.bmob.v3.BmobUser) UpdateListener(cn.bmob.v3.listener.UpdateListener)

Aggregations

UpdateListener (cn.bmob.v3.listener.UpdateListener)17 BmobUser (cn.bmob.v3.BmobUser)15 BmobException (cn.bmob.v3.exception.BmobException)9 User (com.nightonke.saver.model.User)7 MyUser (com.yuxuan.admin.expression.entity.MyUser)5 Handler (android.os.Handler)3 SaveListener (cn.bmob.v3.listener.SaveListener)3 NonNull (android.support.annotation.NonNull)2 BmobQuery (cn.bmob.v3.BmobQuery)2 BmobFile (cn.bmob.v3.datatype.BmobFile)2 DialogAction (com.afollestad.materialdialogs.DialogAction)2 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)2 File (java.io.File)2 DialogInterface (android.content.DialogInterface)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 AlertDialog (android.support.v7.app.AlertDialog)1 EditText (android.widget.EditText)1 LinearLayout (android.widget.LinearLayout)1 OnClick (butterknife.OnClick)1 DeleteListener (cn.bmob.v3.listener.DeleteListener)1