Java Code Examples for cn.bmob.v3.BmobUser#getCurrentUser()

The following examples show how to use cn.bmob.v3.BmobUser#getCurrentUser() . 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: WeatherActivity.java    From Pigeon with MIT License 6 votes vote down vote up
private void updateUserLocation(String city) {
    User mCurrentUser = BmobUser.getCurrentUser(User.class);
    if (mCurrentUser != null) {
        // 允许用户使用应用
        User user = new User();
        user.setLocation(city);
        user.update(mCurrentUser.getObjectId(), new UpdateListener() {
            @Override
            public void done(BmobException e) {
                if (e == null) {

                } else {
                    ToastUtils.showToast(WeatherActivity.this, "Error:" + e.getMessage());
                }
            }
        });
    } else {
        //缓存用户对象为空时, 可打开用户注册界面…
        ToastUtils.showToast(WeatherActivity.this, "no cache");
    }

}
 
Example 2
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 3
Source File: SettingsActivity.java    From Aurora with Apache License 2.0 6 votes vote down vote up
@Override
public void initData(Bundle savedInstanceState) {
    initToolBar();
    switchFlow.setChecked((Boolean) SharedPreferencesUtils.getParam(this, Constants.SETTING_FLOW, true));
    switchWifi.setChecked((Boolean) SharedPreferencesUtils.getParam(this, Constants.SETTING_WIFI, true));
    boolean splashchecked = (Boolean) SharedPreferencesUtils.getParam(this, Constants.SETTING_SPLASH, false);
    boolean flutterchecked = (Boolean) SharedPreferencesUtils.getParam(this, Constants.SETTING_FLUTTER, false);
    switchSplash.setChecked(splashchecked);
    tvSplashOpen.setText(splashchecked?"开":"关");
    mSwitchFlutter.setChecked(flutterchecked);
    mTvFlutterOpen.setText(flutterchecked?"开":"关");
    tvVersionName.setText("当前版本" + DeviceUtils.getVersionName(this));
    if (BmobUser.getCurrentUser() == null) {
        ctlLogout.setVisibility(View.GONE);
    }
}
 
Example 4
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 5
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 6
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 7
Source File: FollowButton.java    From Aurora with Apache License 2.0 6 votes vote down vote up
private void refreshView() {
    Cache cache = ArmsUtils.obtainAppComponentFromContext(FollowButton.this.getContext()).extras();
    List<MyAttentionEntity> entities = CommonUtils.getFollowedInfo(mContext);
    if (entities != null && BmobUser.getCurrentUser() != null) {
        boolean isFollowed = false;
        for (MyAttentionEntity entity : entities) {
            if (entity.getId() == this.attention.getId()) {
                isFollowed = true;
            }
        }
        if (isFollowed) {
            setState(FOLLOWED);
        } else {
            setState(UNFOLLOWED);
        }
    }
}
 
Example 8
Source File: ProfileActivity.java    From ZhihuDaily with MIT License 5 votes vote down vote up
@Override
protected void initVariables() {
    super.initVariables();
    ZhihuApplication.user = BmobUser.getCurrentUser(getApplicationContext(), User.class);
    isColorTheme = PreferenceUtil.getPrefBoolean(getApplicationContext(), "isColorTheme", true);
    isAutoLogin = PreferenceUtil.getPrefBoolean(getApplicationContext(), "isAutoLogin", false);
}
 
Example 9
Source File: RobotChatActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
private void initDatas() {
    mDatas = new ArrayList<>();
    RobotChat robotChat = new RobotChat();
    robotChat.setMsg("Hello");
    robotChat.setDate(new Date(System.currentTimeMillis()));
    robotChat.setType(RobotChat.ChatType.INCOMING);
    mDatas.add(robotChat);

    MyUser user = BmobUser.getCurrentUser(MyUser.class);
    adapter = new RobotChatAdapter(this, mDatas, user);
    listView.setAdapter(adapter);
}
 
Example 10
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 11
Source File: UserProfileActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.lxw_user_profile);
    myUser = BmobUser.getCurrentUser(MyUser.class);
    user = new MyUser();
    initView();
    initEvent();
    initData();
}
 
Example 12
Source File: CommentListActivity_.java    From styT with Apache License 2.0 5 votes vote down vote up
private void publishComment(String content) {
    nico.styTool.MyUser user = BmobUser.getCurrentUser(nico.styTool.MyUser.class);
    if (user == null) {
        Intent intent = new Intent(CommentListActivity_.this, nico.styTool.app_th.class);
        startActivity(intent);
        //toast("发表评论前请先登陆");
        return;
    } else if (TextUtils.isEmpty(content)) {
        //toast("发表评论不能为空");
        return;
    }
    final Comment_ comment = new Comment_();
    comment.setContent(content);
    comment.setPost(weibo);
    comment.setSignature(android.os.Build.MODEL + System.getProperty("line.separator"));
    comment.setUser(user);
    comment.save(new SaveListener<String>() {

        @Override
        public void done(String objectId, BmobException e) {
            if (e == null) {
                findComments();
                et_content.setText("");
                //toast("评论成功");
            } else {

            }
        }
    });
}
 
Example 13
Source File: BaseFragment.java    From VSigner with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setRetainInstance(true);
	
	mContext = this.getActivity();
	mCurrentUser = BmobUser.getCurrentUser(mContext, User.class);
	mInflater = LayoutInflater.from(getActivity());
	mBaseActivity = (BaseActivity) getActivity();
}
 
Example 14
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 15
Source File: MessageActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.lxw_message);
    numPage = 0;
    myUser = BmobUser.getCurrentUser(MyUser.class);
    initView();
    initData();
    initEvent();

}
 
Example 16
Source File: WeatherActivity.java    From Pigeon with MIT License 4 votes vote down vote up
private void initWeatherNumber() {
    BmobQuery<User> queryNumber = new BmobQuery();

    User mCurrentUser = BmobUser.getCurrentUser(User.class);

    if (mCurrentUser != null) {
        Family family = mCurrentUser.getFamily();

        if (family != null) {
            queryNumber.addWhereEqualTo("family", family);
            queryNumber.findObjects(new FindListener<User>() {
                @Override
                public void done(List<User> list, BmobException e) {
                    if (e == null) {
                        if (list != null) {
                            mAdapter = new WeatherNumberAdapter(list, WeatherActivity.this);
                            mRvList.setAdapter(mAdapter);
                            mRvList.setLayoutManager(new LinearLayoutManager(WeatherActivity.this));
                            dialog.dismissDialog();
                        } else {
                            dialog.dismissDialog();
                            ToastUtils.showToast(WeatherActivity.this, "无数据显示");
                        }
                    } else {
                        dialog.dismissDialog();
                        ToastUtils.showToast(WeatherActivity.this, "查询成员异常:" + e.getMessage());
                    }
                }
            });


        } else {
            dialog.dismissDialog();
            ToastUtils.showToast(WeatherActivity.this, "未查询到家庭");
        }

    } else {
        dialog.dismissDialog();
        ToastUtils.showToast(WeatherActivity.this, "未查询到家庭");
    }
}
 
Example 17
Source File: FourthFragment.java    From myapplication with Apache License 2.0 4 votes vote down vote up
private void fillDatas() {
    AppUser appUser = BmobUser.getCurrentUser(AppUser.class);
    if (appUser == null) {
        meNickNameTv.setText("未登录, 请点击登录");
        meMessageTv.setText("这位童鞋很懒, 什么都没留下...");
        meAvatarImv.setImageResource(R.drawable.app_icon);
    } else {
        meNickNameTv.setText(appUser.getUserNickName());

        if ("".equals(appUser.getUserMessage()) || null == appUser.getUserMessage()) {
            meMessageTv.setText("这位童鞋很懒, 什么都没留下...");
        } else {
            meMessageTv.setText(appUser.getUserMessage());
        }

        Log.i(LOG, "appUser.getUserAvatarUrl() = " + appUser.getUserAvatarUrl());

        if ("".equals(appUser.getUserAvatarUrl()) || null == appUser.getUserAvatarUrl()) {
            meAvatarImv.setImageResource(R.drawable.app_icon);
        } else {
            Glide.with(FourthFragment.this)
                    .load(appUser.getUserAvatarUrl())
                    .error(R.drawable.app_icon)
                    .centerCrop()
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .into(meAvatarImv);
        }
    }

    // 自动更新检测
    BmobUpdateAgent.setUpdateListener(new BmobUpdateListener() {
        @Override
        public void onUpdateReturned(int updateStatus, UpdateResponse updateResponse) {
            switch (updateStatus) {
                case UpdateStatus.Yes:
                    Log.i("LOG", "YYYYYYYY");
                    break;
                case UpdateStatus.No:
                    Log.i("LOG", "NNNNNNNNN");
                    Toast.makeText(getActivity(), "已是最新版本", Toast.LENGTH_SHORT).show();
                    break;
                case UpdateStatus.TimeOut:
                    Log.i("LOG", "TTTTTTTTT");
                    Toast.makeText(getActivity(), "连接超时,请稍后再试",
                            Toast.LENGTH_SHORT).show();
                    break;
                default:
                    Log.i("LOG", "FFFFFFFFF");
                    Toast.makeText(getActivity(), "连接超时,请稍后再试",
                            Toast.LENGTH_SHORT).show();
                    break;
            }
        }
    });
}
 
Example 18
Source File: ThirdFragment.java    From myapplication with Apache License 2.0 4 votes vote down vote up
/**
 * 事件处理: gridview item的点击事件
 */
private void dealEvents() {
    final AppUser currentAppUser = BmobUser.getCurrentUser(AppUser.class);

    nineGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
                case 0:
                    if (currentAppUser != null) {
                        startActivity(new Intent(getActivity(), FindNotesAty.class));
                    } else {
                        Toast.makeText(getActivity(),
                                "请先登录!",
                                Toast.LENGTH_SHORT).show();
                    }

                    break;
                case 1:
                    startActivity(new Intent(getActivity(), FindHowOldAct.class));
                    break;
                case 2:
                    startActivity(new Intent(getActivity(), FindGankAty.class));
                    break;
                case 3:
                    startActivity(new Intent(getActivity(), FindMeiziAty.class));
                    break;
                case 4:
                    startActivity(new Intent(getActivity(), CaptureActivity.class));
                    break;
                case 5:
                    startActivity(new Intent(getActivity(), FindVideoAty.class));
                    break;
                case 6:
                    startActivity(new Intent(getActivity(), FindWeatherAty.class));
                    break;
                case 7:
                    startActivity(new Intent(getActivity(), FindMapAroundAty.class));
                    break;
                case 8:
                    startActivity(new Intent(getActivity(), FindIndexMusicAty.class));
                    break;
            }
        }
    });
}
 
Example 19
Source File: UserManager.java    From TestChat with Apache License 2.0 2 votes vote down vote up
/**
 * 如果没有自定义用户实体类extend BmobUser
 * 默认返回BmobUser类型的用户实体
 * 获取当前用户
 *
 * @return 当前用户
 */
public User getCurrentUser() {
        return BmobUser.getCurrentUser(CustomApplication.getInstance(), User.class);
}
 
Example 20
Source File: MainActivityDrawerLayout.java    From MyHearts with Apache License 2.0 2 votes vote down vote up
/**
 * 初始化布局控件
 */
public void initView() {

    BmobUpdateAgent.setUpdateOnlyWifi(false);  //判断是否是wifi网络
    BmobUpdateAgent.update(this); //检测是否有更新

    MyUser myUser = BmobUser.getCurrentUser(MyUser.class);

    //  EventBus.getDefault().register(this);
    if (myUser != null) {
        EventBus.getDefault().post(new LoginEvent(myUser));
        Log.d("SplashActivity", "myUser:" + myUser);
    }

    boolean isLogin = getIntent().getBooleanExtra(Contants.IS_COME_FROM_LOGIN, false);
    if (isLogin) {  //登录状态
        PreferencesUtils.putBoolean(this, Contants.IS_LOGIN, true);
    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);


    //  mDragLayout = (MyDragLayout) findViewById(R.id.qq_slidding);

    mIvLive = (ImageView) findViewById(R.id.img_live);

    mFrameLayout = (FrameLayout) findViewById(R.id.container);

    mRadioHome = (RadioButton) findViewById(R.id.rbTabHome);
    mRadioAdvisory = (RadioButton) findViewById(R.id.rbTabAdvisory);
    mRadioLord = (RadioButton) findViewById(R.id.rbTabLord);
    mRadioThoughts = (RadioButton) findViewById(R.id.rbTabThoughts);
    mRadioLive = (RadioButton) findViewById(R.id.rbTabMall);
    mRadioHome.setChecked(true);

    initLeftDrawer();

    initAnimation();


    initFragment();

    addFragment();
    initRadio();

    mIvImg.setOnClickListener(this);

    registerMessageReceiver();  // used for receive msg

}