cn.bmob.v3.BmobUser Java Examples

The following examples show how to use cn.bmob.v3.BmobUser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MeSettingsAty.java    From myapplication with Apache License 2.0 6 votes vote down vote up
private void initView() {
    titleLeftImv = (ImageButton) findViewById(R.id.me_settings_title).findViewById(R.id.title_imv);
    titleTv = (TextView) findViewById(R.id.me_settings_title).findViewById(R.id.title_center_text_tv);

    mAboutRout = (RelativeLayout) findViewById(R.id.settings_about_rout);

    logoutBtn = (Button) findViewById(R.id.settings_logout_btn);

    titleTv.setText("个人设置");
    titleLeftImv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            MeSettingsAty.this.finish();
        }
    });

    appUser = BmobUser.getCurrentUser(AppUser.class);
    if (appUser == null) {
        logoutBtn.setBackgroundColor(Color.parseColor("#616161"));
        logoutBtn.setClickable(false);
    }
}
 
Example #2
Source File: LoginActivity.java    From Pigeon with MIT License 6 votes vote down vote up
@Override
    public void initData() {
        bmobUser = BmobUser.getCurrentUser();
//        if (bmobUser != null) {
//
//            isExist = SPUtils.getBoolean(FamilyConfig.SPEXIST, false);
//
//            if (isExist) {
//                AppManager.getAppManager().finishActivity();
//                nextActivity(MainActivity.class);
//            } else {
//                AppManager.getAppManager().finishActivity();
//                nextActivity(GuideFamilyActivity.class);
//            }
//
//        }
    }
 
Example #3
Source File: ProfileActivity.java    From ZhihuDaily with MIT License 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.logout) {
        BmobUser.logOut(getApplicationContext());
        LoginManager.logout();
        ZhihuApplication.user = null;
        finish();
        overridePendingTransition(R.anim.slide_in_from_right, R.anim.slide_out_to_left);
    }
    if (id == R.id.auto_login) {
        isAutoLogin = !isAutoLogin;
        PreferenceUtil.setPrefBoolean(getApplicationContext(), "isAutoLogin", isAutoLogin);
        Snackbar.make((View) mAppbarLayout.getParent(), isAutoLogin ? "已开启自动登陆" : "已关闭自动登陆", Snackbar.LENGTH_SHORT).show();
        item.setTitle(isAutoLogin ? "关闭自动登陆" : "开启自动登陆");
    }
    if (id == R.id.reset_password) {
        Intent intent = new Intent(getApplicationContext(), EditPasswordDialog.class);
        startActivityForResult(intent, Constant.RESET_PASSWORD);
    }
    return super.onOptionsItemSelected(item);
}
 
Example #4
Source File: PersonFragment.java    From Pigeon with MIT License 6 votes vote down vote up
@Override
public void initData() {
    mCurrentUser = BmobUser.getCurrentUser(User.class);
    BmobFile userPhotoFile = mCurrentUser.getUserPhoto();
    String nick = mCurrentUser.getNick();
    String objectId = mCurrentUser.getObjectId();


    if (!TextUtils.isEmpty(nick)) {
        mTvName.setText(nick);
    }

    if (!TextUtils.isEmpty(objectId)) {
        mTvID.setText("飞鸽号:" + objectId);
    }

    if (userPhotoFile == null) {
        mCivUserPhoto.setImageResource(R.drawable.ic_default);
    } else {
        Picasso.with(getContext()).load(userPhotoFile.getFileUrl()).into(mCivUserPhoto);
    }

}
 
Example #5
Source File: RegisterOrResetActivity.java    From Pigeon with MIT License 6 votes vote down vote up
/**
 * 重置密码
 */
private void resetPassword() {
    if (isTel && isTruePassword) {
        dialog.showDialog();
        BmobUser.resetPasswordBySMSCode(smsCodeString, rePassWordString, new UpdateListener() {
            @Override
            public void done(BmobException e) {
                if (e == null) {
                    dialog.dismissDialog();
                    ToastUtils.showToast(RegisterOrResetActivity.this, "重置密码成功");
                    AppManager.getAppManager().finishActivity();
                } else {
                    dialog.dismissDialog();
                    ToastUtils.showToast(RegisterOrResetActivity.this, e.getMessage());
                }
            }
        });

    } else {
        dialog.dismissDialog();
        ToastUtils.showToast(RegisterOrResetActivity.this, "请检查输入信息");
    }
}
 
Example #6
Source File: BaseActivity.java    From VSigner with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	 // 初始化 Bmob SDK
       // 使用时请将第二个参数Application ID替换成你在Bmob服务器端创建的Application ID
	Bmob.initialize(this, Constants.BmobAPPID);
	
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	//获取当前屏幕宽高
	DisplayMetrics metric = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics(metric);
	mScreenWidth = metric.widthPixels;
	mScreenHeight = metric.heightPixels;
	
	// 初始化数据
	mContext = this;
	mBmobInstallation = BmobInstallation.getCurrentInstallation(this);
	mInstallationId = BmobInstallation.getInstallationId(this);
	mCurrentUser = BmobUser.getCurrentUser(this, User.class);

	setContentView();
	initViews();
	initListeners();
	initData();
}
 
Example #7
Source File: LoginActivity.java    From stynico with MIT License 6 votes vote down vote up
private void lxwLogin(String email, String password)
 {
     MyUser user = new MyUser();
     user.setEmail(email);
     user.setPassword(password);
     BmobUser.loginByAccount(getActivity(), email, password, new LogInListener<MyUser>() {
	@Override
	public void done(MyUser myUser, BmobException e)
	{
		if (myUser != null)
		{
			//Toast.makeText(getActivity(), "用户登录成功", Toast.LENGTH_SHORT).show();
			bindUserIdAndDriverice(myUser);
		}
		else
		{
			mProgressView.setVisibility(View.GONE);
			//mLoginFormView.setVisibility(View.VISIBLE);
			AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
			builder.setMessage("登录失败,可能是邮箱或者密码错误!").create().show();

			//Log.e(TAG, "---login_error----" + e);
		}
	}
});
 }
 
Example #8
Source File: SampleAdapter.java    From styT with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBindItemViewHolder(ItemViewHolder holder, final int headerPosition, final int itemPosition) {
    final Comment weibo = weibos.get(itemPosition);

    MyUser user = BmobUser.getCurrentUser(MyUser.class);
    BmobQuery<Comment> query = new BmobQuery<>();
    //query.addWhereEqualTo("author", user);    // 查询当前用户的所有微博
    query.order("-updatedAt");
    query.include("author");// 希望在查询微博信息的同时也把发布人的信息查询出来,可以使用include方法
    query.setLimit(4);
    query.findObjects(new FindListener<Comment>() {

        @Override
        public void done(List<Comment> object, BmobException e) {
            if (e == null) {
                weibos = object;
                adapter.notifyDataSetChanged();
            } else {

            }
        }

    });
    //adapter = new MyAdapter(getActivity());
    holder.listView.setAdapter(adapter);
}
 
Example #9
Source File: MeAvatarShowerAty.java    From myapplication with Apache License 2.0 6 votes vote down vote up
private void eventDeal() {
    AppUser appUser = BmobUser.getCurrentUser(AppUser.class);
    String avatarUrl = appUser.getUserAvatarUrl();

    Glide.with(MeAvatarShowerAty.this)
            .load(avatarUrl)
            .error(R.drawable.app_icon)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .into(avatarImv);

    photoViewAttacher = new PhotoViewAttacher(avatarImv);
    photoViewAttacher.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            String[] choices = {"保存至本地"};
            //包含多个选项的对话框
            AlertDialog dialog = new AlertDialog.Builder(MeAvatarShowerAty.this)
                    .setItems(choices, onselect).create();
            dialog.show();
            return true;
        }
    });
}
 
Example #10
Source File: PublishActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
private void savePulish(String content, PhontoFiles files) {
    MyUser user = BmobUser.getCurrentUser(MyUser.class);
    BILIBILI helps = new BILIBILI();
    helps.setUser(user);
    helps.setContent(content);
    helps.setState(0);
    helps.setLikeNum(1);
    helps.setPhontofile(files);
    helps.save(new SaveListener<String>() {
        @Override
        public void done(String objectId, BmobException e) {
            if (e == null) {
                finish();
                mProgressDialog.dismiss();
            } else {
                mProgressDialog.dismiss();
            }
        }
    });
}
 
Example #11
Source File: PublishActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
private void saveText(String content) {
    MyUser user = BmobUser.getCurrentUser(MyUser.class);
    BILIBILI helps = new BILIBILI();
    helps.setUser(user);
    helps.setContent(content);
    helps.setState(0);
    helps.setLikeNum(1);
    helps.save(new SaveListener<String>() {
        @Override
        public void done(String objectId, BmobException e) {
            if (e == null) {
                finish();
                mProgressDialog.dismiss();
                //Log.i("bmob", "保存成功");
            } else {
                mProgressDialog.dismiss();
                //Log.i("bmob", "保存失败:" + e.getMessage());
            }
        }
    });
}
 
Example #12
Source File: PublishActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.push_help);

    myUser = BmobUser.getCurrentUser(MyUser.class);
    if (myUser.getAuvter() != null) {

    } else {
        Intent a = new Intent(PublishActivity.this, UserProfileActivity.class);
        startActivity(a);
        finish();
        Toast.makeText(PublishActivity.this, "请上传头像", Toast.LENGTH_SHORT).show();
    }
    xft();
    initView();
    initEmojGridview();
    initEvent();

}
 
Example #13
Source File: MeEditorJobAty.java    From myapplication with Apache License 2.0 6 votes vote down vote up
/**
 * 上传职业job信息
 *
 * @param jobStr job名称
 */
private void uploadJobData(final String jobStr) {
    AppUser newAppUser = new AppUser();
    newAppUser.setUserJob(jobStr);
    AppUser currentAppUser = BmobUser.getCurrentUser(AppUser.class);
    newAppUser.update(currentAppUser.getObjectId(), new UpdateListener() {
        @Override
        public void done(BmobException e) {
            if (e == null) {
                Toast.makeText(MeEditorJobAty.this, "修改成功!", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(MeEditorJobAty.this, "修改失败! " + e.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    Intent intent1 = new Intent();
    intent1.putExtra("MeEditorJobAty.jobStr", jobStr);
    MeEditorJobAty.this.setResult(RESULT_OK, intent1);
    MeEditorJobAty.this.finish();
}
 
Example #14
Source File: MeEditorAreaAty.java    From myapplication with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化界面控件
 */
private void initViews() {
    // 标题栏控件
    titleLeftImv = (ImageButton) findViewById(R.id.title_imv);
    currentAreaRout = (RelativeLayout) findViewById(R.id.me_editor_current_area_rout);
    currentAreaTv = (TextView) findViewById(R.id.me_editor_current_area_tv);
    fullAreaRout = (RelativeLayout) findViewById(R.id.me_editor_full_area_rout);
    fullAreaTv = (TextView) findViewById(R.id.me_editor_full_area_tv);
    wheelLout = (LinearLayout) findViewById(R.id.me_editor_area_wheel);

    mViewProvince = (WheelView) findViewById(R.id.me_editor_province_wheel);
    mViewCity = (WheelView) findViewById(R.id.me_editor_city_wheel);
    mViewDistrict = (WheelView) findViewById(R.id.me_editor_district_wheel);
    mConfirmTv = (TextView) findViewById(R.id.me_editor_area_finish_tv);

    AppUser appUser = BmobUser.getCurrentUser(AppUser.class);
    if (appUser != null) {
        fullAreaTv.setText(appUser.getUserArea());
    } else {
        fullAreaTv.setText("查找位置, 同城交友");
    }
}
 
Example #15
Source File: MeEditorAreaAty.java    From myapplication with Apache License 2.0 6 votes vote down vote up
/**
 * 上传职业job信息
 *
 * @param areaStr job名称
 */
private void uploadAreaData(String areaStr) {
    AppUser newAppUser = new AppUser();
    newAppUser.setUserArea(areaStr);
    AppUser currentAppUser = BmobUser.getCurrentUser(AppUser.class);
    newAppUser.update(currentAppUser.getObjectId(), new UpdateListener() {
        @Override
        public void done(BmobException e) {
            if (e == null) {
                Toast.makeText(MeEditorAreaAty.this, "修改成功, 数据已上传!", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(MeEditorAreaAty.this, "修改失败! " + e.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    Intent intent1 = new Intent();
    intent1.putExtra("MeEditorAreaAty.areaStr", areaStr);
    MeEditorAreaAty.this.setResult(RESULT_OK, intent1);
}
 
Example #16
Source File: WeiboListActivity.java    From stynico with MIT License 6 votes vote down vote up
private void findWeibos_()
{
	nico.styTool.MyUser user = BmobUser.getCurrentUser(this, nico.styTool.MyUser.class);
	BmobQuery<Post_> query = new BmobQuery<Post_>();
	query.addWhereEqualTo("author", user);	// 查询当前用户的所有微博
	query.order("-updatedAt");
	query.include("author");// 希望在查询微博信息的同时也把发布人的信息查询出来,可以使用include方法
	query.findObjects(this, new FindListener<Post_>() {
			@Override
			public void onSuccess(List<Post_> object)
			{
				// TODO Auto-generated method stub
				weibos = object;
				adapter.notifyDataSetChanged();
				//et_content.setText("");
			}

			@Override
			public void onError(int code, String msg)
			{
				// TODO Auto-generated method stub
				//toast("查询失败:"+msg);
			}
		});
}
 
Example #17
Source File: StickerActivity.java    From Pigeon with MIT License 5 votes vote down vote up
@Override
public void initData() {
    //TODO 分页查询
    mCurrentUser= BmobUser.getCurrentUser(User.class);
    stickerQuery = new BmobQuery<>();
    stickerQuery.include("user,family");
    stickerQuery.order("-updatedAt");
    stickerQuery.addWhereEqualTo("user",mCurrentUser);
    stickerQuery.addWhereEqualTo("family",mCurrentUser.getFamily());
    stickerQuery.findObjects(new FindListener<Sticker>() {
        @Override
        public void done(List<Sticker> list, BmobException e) {
            if (e == null) {
                if (list.size()!=0) {
                    stickerAdapter = new StickerAdapter(StickerActivity.this, list);
                    mStickerRv.setLayoutManager(new LinearLayoutManager(StickerActivity.this));
                    mStickerRv.setItemAnimator(new DefaultItemAnimator());
                    mStickerRv.setAdapter(stickerAdapter);
                } else {
                    ToastUtils.showToast(StickerActivity.this, "无数据显示");
                }
            } else {
                ToastUtils.showToast(StickerActivity.this, "FindSticker:" + e.getMessage());
            }
        }
    });


}
 
Example #18
Source File: LoginActivity.java    From Conquer with Apache License 2.0 5 votes vote down vote up
@Override
public void onComplete(Object o) {

    try {
        JSONObject jsonObject = new JSONObject(o.toString());
        String userId = jsonObject.getString("openid");
        String expiresIn= jsonObject.getString("expires_in");
        String accessToken = jsonObject.getString("access_token");
        BmobUser.BmobThirdUserAuth authInfo = new BmobUser.BmobThirdUserAuth("qq", accessToken, expiresIn, userId);
        BmobUser.loginWithAuthData(context, authInfo, new OtherLoginListener() {

            @Override
            public void onSuccess(JSONObject userAuth) {
                L.i("QQ授权成功去校验" + userAuth.toString());
                getQQInfo(userAuth);
            }

            @Override
            public void onFailure(int code, String msg) {
                // TODO Auto-generated method stub
                Log.i("smile", "第三方登陆失败:" + msg);
            }

        });

    } catch (JSONException e) {
        e.printStackTrace();
    }
}
 
Example #19
Source File: MeFeedbackAty.java    From myapplication with Apache License 2.0 5 votes vote down vote up
private void uploadFeedbackDatas(String feedbackStr) {
    AppUser appUser = BmobUser.getCurrentUser(AppUser.class);
    Feedback feedback = new Feedback();

    if (appUser != null) {
        feedback.setUserId(appUser.getObjectId());
        feedback.setFeebackUserName(appUser.getUsername());
        feedback.setFeedbackUserEmail(appUser.getEmail());
        feedback.setFeedbackContent(feedbackStr);
        feedback.save(new SaveListener<String>() {
            @Override
            public void done(String s, BmobException e) {
                if (e == null) {
                    Toast.makeText(MeFeedbackAty.this, "数据上传成功, 感谢你的建议!",
                            Toast.LENGTH_SHORT).show();
                    MeFeedbackAty.this.finish();
                } else {
                    Toast.makeText(MeFeedbackAty.this, "上传数据失败, 请稍后再试!",
                            Toast.LENGTH_SHORT).show();
                }
            }
        });
    } else {
        Toast.makeText(MeFeedbackAty.this, "上传数据失败, 请稍后再试!",
                Toast.LENGTH_SHORT).show();
    }
}
 
Example #20
Source File: FindNotesAty.java    From myapplication with Apache License 2.0 5 votes vote down vote up
private void generateDatas() {
    String currentUserNameStr = (String) BmobUser.getObjectByKey("username");
    Log.i(TAG, "currentUserNameStr >> " + currentUserNameStr);

    BmobQuery<NotesBean> query1 = new BmobQuery<>();
    query1.addWhereLessThanOrEqualTo("createdAt", new BmobDate(new Date()));

    BmobQuery<NotesBean> query2 = new BmobQuery<>();
    query2.addWhereEqualTo("userNameStr", currentUserNameStr);

    List<BmobQuery<NotesBean>> andQuerys = new ArrayList<>();
    andQuerys.add(query1);
    andQuerys.add(query2);

    BmobQuery<NotesBean> notesInfoBmobQuery = new BmobQuery<>();
    notesInfoBmobQuery.and(andQuerys);
    notesInfoBmobQuery.order("-createdAt");  // 按时间降序排列
    // 设定查询缓存策略-CACHE_ELSE_NETWORK: 先从缓存读取数据, 如果没有, 再从网络获取.
    notesInfoBmobQuery.setCachePolicy(BmobQuery.CachePolicy.CACHE_ELSE_NETWORK);
    notesInfoBmobQuery.setMaxCacheAge(TimeUnit.DAYS.toMillis(7));    //此表示缓存一天
    notesInfoBmobQuery.findObjects(new FindListener<NotesBean>() {
        @Override
        public void done(List<NotesBean> list, BmobException e) {
            if (!list.isEmpty()) {
                for (NotesBean notesBean : list) {
                    mDatas.add(notesBean);
                }

                if (!mDatas.isEmpty()) {
                    mMaterialDialog.dismiss();
                    mFindNotesAdapter.notifyDataSetChanged();
                }
            } else {
                mMaterialDialog.dismiss();
                Toast.makeText(FindNotesAty.this, "暂无数据", Toast.LENGTH_SHORT).show();
            }
        }
    });
}
 
Example #21
Source File: ResetPasswordActivity.java    From myapplication with Apache License 2.0 5 votes vote down vote up
/**
 * 重置密码业务逻辑
 */
private void userResetPassword() {
    resetPasswdBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            resetEmailStr = resetEmailEt.getText().toString().trim();

            if ("".equals(resetEmailStr)) {
                resetWarnImv.setVisibility(View.VISIBLE);
                Toast.makeText(ResetPasswordActivity.this, "请输入登录邮箱!", Toast.LENGTH_LONG).show();
            } else {
                resetWarnImv.setVisibility(View.GONE);
                BmobUser.resetPasswordByEmail(resetEmailStr, new UpdateListener() {
                    @Override
                    public void done(BmobException e) {
                        if (e == null) {
                            Toast.makeText(ResetPasswordActivity.this, "重置密码请求成功,请到" + resetEmailStr + "邮箱进行密码重置操作", Toast.LENGTH_LONG).show();
                            ResetPasswordActivity.this.finish();
                        } else {
                            Toast.makeText(ResetPasswordActivity.this, "重置密码失败!" + e.getMessage(), Toast.LENGTH_LONG).show();
                        }
                    }
                });
            }
        }
    });
}
 
Example #22
Source File: EditFamilyActivity.java    From Pigeon with MIT License 5 votes vote down vote up
@Override
public void initData() {
    dialog.showDialog();
    mCurrentUser = BmobUser.getCurrentUser(User.class);
    familyQuery = new BmobQuery<>();
    familyQuery.getObject(mCurrentUser.getFamily().getObjectId(), new QueryListener<Family>() {
        @Override
        public void done(Family family, BmobException e) {
            if (e == null) {
                familyName = family.getFamilyName();
                if (!TextUtils.isEmpty(familyName)) {
                    mEdtFamilyName.setText(familyName);

                    BmobFile familyIconFile = family.getFamilyIcon();

                    if (familyIconFile!=null) {
                        Picasso.with(EditFamilyActivity.this).load(familyIconFile.getFileUrl()).into(mFamilyPhoto);
                    }else {
                        mFamilyPhoto.setImageResource(R.drawable.ic_default);
                    }

                    dialog.dismissDialog();

                } else {
                    dialog.dismissDialog();
                }
            } else {
                dialog.dismissDialog();
                ToastUtils.showToast(EditFamilyActivity.this, "GetFamilyInfo : " + e.getMessage());
            }
        }
    });

}
 
Example #23
Source File: HistoryActivity.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Override
public void setData(List<VideoDaoEntity> list, Boolean isLoadMore) {
    if (list.size()<10){
        adapter.setEnableLoadMore(false);
        footView.setVisibility(View.VISIBLE);
    }else {
        footView.setVisibility(View.GONE);
        adapter.setEnableLoadMore(true);
        adapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
            @Override
            public void onLoadMoreRequested() {
                User user = BmobUser.getCurrentUser(User.class);
                if (user == null){
                    mPresenter.getListFromDb(data.size(),true);
                }else {
                    mPresenter.getListFromNet(data.size(),user.getObjectId(),true);
                }
            }
        },mRecyclerView);
    }
    if (isLoadMore){
        adapter.addData(list);
        adapter.loadMoreComplete();
    }else {
        data.clear();
        data.addAll(list);
        adapter.setNewData(data);
    }
}
 
Example #24
Source File: SettingActivity.java    From Pigeon with MIT License 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_exit:
            BmobUser.logOut();
            SPUtils.putBoolean(FamilyConfig.SPEXIST, false); //设置保存到本地的sp家庭数据
            AppManager.getAppManager().AppExit(this);
            break;
    }

    return super.onOptionsItemSelected(item);
}
 
Example #25
Source File: NewStickerActivity.java    From Pigeon with MIT License 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_ok:
            String contentStr = mEdtContent.getText().toString();
            User user = BmobUser.getCurrentUser(User.class);

            if (!TextUtils.isEmpty(contentStr)){
                Sticker sticker = new Sticker();
                sticker.setContent(contentStr);
                sticker.setUser(user);
                sticker.setFamily(user.getFamily());
                sticker.save(new SaveListener<String>() {
                    @Override
                    public void done(String s, BmobException e) {
                        if (e==null){
                            AppManager.getAppManager().finishActivity();
                            ToastUtils.showToast(NewStickerActivity.this,"新建成功");
                        } else {
                            ToastUtils.showToast(NewStickerActivity.this,"SaveSticker: "+e.getMessage());
                        }
                    }
                });

            }else {
                ToastUtils.showToast(NewStickerActivity.this,"请正确填写信息");
            }

            break;
    }

    return super.onOptionsItemSelected(item);
}
 
Example #26
Source File: EditUsernameDialog.java    From ZhihuDaily with MIT License 5 votes vote down vote up
@Override
protected void initViews(Bundle savedInstanceState) {
    saveBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String newUsername = usernameEt.getText().toString();
            if (TextUtils.isEmpty(newUsername)){
                Snackbar.make((View) saveBtn.getParent(),"用户名不能为空",Snackbar.LENGTH_SHORT).show();
                return;
            }
            final User user = BmobUser.getCurrentUser(getApplicationContext(),User.class);
            user.setUsername(newUsername);
            user.update(getApplicationContext(), user.getObjectId(), new UpdateListener() {
                @Override
                public void onSuccess() {
                    ZhihuApplication.user.setUsername(newUsername);
                    setResult(RESULT_OK);
                    finish();
                }

                @Override
                public void onFailure(int i, String s) {

                }
            });
        }
    });
}
 
Example #27
Source File: TestActivity.java    From Mobike with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);
    ButterKnife.bind(this);
    mUser = BmobUser.getCurrentUser(MyUser.class);
    Log.d(TAG, "onCreate: " + mUser.toString());
    //  mLoadingPageView.show();
}
 
Example #28
Source File: CheckLoginAspect.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Around("methodAnnotated()")//在连接点进行方法替换
public void aroundJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
    BmobUser user = BmobUser.getCurrentUser();
    if (null == user) {
        TRouter.go(Constants.LOGIN);
        return;
    }
    joinPoint.proceed();//执行原方法
}
 
Example #29
Source File: HistoryActivity.java    From Aurora with Apache License 2.0 5 votes vote down vote up
private void deleteVideoHistory(VideoDaoEntity daoEntity,int position) {
    if (BmobUser.getCurrentUser()==null){
        mPresenter.deleteFromDb(daoEntity,position);
    }else {
        mPresenter.deleteFromNet(daoEntity,position);
    }
}
 
Example #30
Source File: ClockFragment.java    From ToDoList with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = getActivity();
    if(NetWorkUtils.isNetworkConnected(getContext())) {
        try{
            if (User.getCurrentUser(User.class) != null){
                currentUser = BmobUser.getCurrentUser(User.class);
            }
        } catch (Exception e){
            e.printStackTrace();
        }
    }

}