Java Code Examples for cn.bmob.v3.BmobQuery#addWhereEqualTo()

The following examples show how to use cn.bmob.v3.BmobQuery#addWhereEqualTo() . 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: CommentListActivity.java    From stynico with MIT License 6 votes vote down vote up
private void findComments()
{
	BmobQuery<Comment_> query = new BmobQuery<Comment_>();
	// pointer类型
	query.addWhereEqualTo("post", new BmobPointer(weibo));		
	query.include("user,post.author");
	query.findObjects(getActivity(), new FindListener<Comment_>() {

			@Override
			public void onSuccess(List<Comment_> object)
			{
				// TODO Auto-generated method stub
				comments = object;
				adapter.notifyDataSetChanged();
				et_content.setText("");
			}

			@Override
			public void onError(int code, String msg)
			{
				// TODO Auto-generated method stub
				//toast("查询失败:"+msg);
			}
		});}
 
Example 2
Source File: TestActivity.java    From Mobike with Apache License 2.0 6 votes vote down vote up
private void cheackUser() {
    BmobQuery<MyUser> query = new BmobQuery<MyUser>();
    query.addWhereEqualTo("username", "182****2002");
    query.setLimit(1);
    query.findObjects(new FindListener<MyUser>() {
        @Override
        public void done(List<MyUser> list, BmobException e) {
            if (e == null) {
                if (list.size() > 0 && list != null) {
                    Log.d(TAG, "cheackUser: ok");
                } else {
                    Log.d(TAG, "cheackUser: not");
                }
            } else {
                Log.d(TAG, "done: " + e);
            }
        }
    });
}
 
Example 3
Source File: HelpsCommentActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
/**
 * 使用bmob进行消息推送
 *
 * @param myUser
 */
private void bmobpush(MyUser myUser, String comment) {
    String installationId = helps.getUser().getObjectId();
    BmobPushManager bmobPushManager = new BmobPushManager();
    BmobQuery<MyUserInstallation> query = new BmobQuery<MyUserInstallation>();
    query.addWhereEqualTo("uid", installationId);
    bmobPushManager.setQuery(query);
    bmobPushManager.pushMessage(myUser.getUsername() + "评论了你");

    NotifyMsg notifyMsg = new NotifyMsg();
    notifyMsg.setHelps(helps);
    notifyMsg.setUser(helps.getUser());
    notifyMsg.setAuthor(myUser);
    notifyMsg.setStatus(false);
    notifyMsg.setMessage(comment);
    notifyMsg.save(new SaveListener<String>() {
        @Override
        public void done(String s, BmobException e) {

        }
    });
}
 
Example 4
Source File: ShareInfoPresenter.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
public void getFirstPostNotifyBean() {
    BmobQuery<PostNotifyBean> bmobQuery = new BmobQuery<>();
    bmobQuery.addWhereEqualTo("toUser", new BmobPointer(UserManager.getInstance().getCurrentUser()));
    bmobQuery.addWhereEqualTo("readStatus", ConstantUtil.READ_STATUS_READED);
    bmobQuery.order("-createdAt");
    bmobQuery.setLimit(1);
    bmobQuery.include("relatedUser");
    addSubscription(bmobQuery.findObjects(new FindListener<PostNotifyBean>() {
        @Override
        public void done(List<PostNotifyBean> list, BmobException e) {
            if (e == null && list != null && list.size() > 0) {
                RxBusManager.getInstance().post(new UnReadPostNotifyEvent(list.get(0)));
            }
        }
    }));
}
 
Example 5
Source File: UserManager.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
public void refreshUserInfo() {
    List<String> userList = UserDBManager.getInstance().getAllFriendId();
    String currentUserObjectId = getCurrentUserObjectId();
    if (userList != null && userList.size() > 0) {
        for (final String uid :
                userList) {
            BmobQuery<User> query = new BmobQuery<>();

            String lastTime = BaseApplication
                    .getAppComponent()
                    .getSharedPreferences().getString(currentUserObjectId + "&" + uid, null);
            //                                        第一次断网查询用户数据
            query.addWhereGreaterThan("updatedAt", new BmobDate(new Date(TimeUtil.getTime(lastTime))));
            query.addWhereEqualTo("objectId", uid);
            query.findObjects(new FindListener<User>() {
                @Override
                public void done(List<User> list, BmobException e) {
                    if (e == null) {
                        if (list != null && list.size() > 0) {
                            User user = list.get(0);
                            BaseApplication.getAppComponent()
                                    .getSharedPreferences()
                                    .edit().putString(currentUserObjectId + "&" + user.getObjectId(), user.getUpdatedAt())
                                    .apply();
                            UserDBManager.getInstance().addOrUpdateUser(user);
                        }
                    } else {
                        LogUtil.e("断网期间内查询用户失败" + e.toString());
                    }
                }
            });
        }
    }
}
 
Example 6
Source File: SubscribeChannelDetail.java    From VSigner with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 根据channel更新当前界面信息
 * @param channel
 */
private void updateView(Channel channel) {
	mChannelNameTextView.setText(channel.getName());
	mChannelInfoTextView.setText(channel.getInfo());
	mManagerNameTextView.setText(String.format(getString(R.string.user_name_format), 
			channel.getManager().getRealname(), 
			channel.getManager().getUsername()));
	
	showProgressDialog(getString(R.string.server_query_tips));
	BmobQuery<ChannelSubscriber> channelSubscriberQuery = new BmobQuery<ChannelSubscriber>();
	channelSubscriberQuery.addWhereEqualTo(ChannelSubscriber.SUBSCRIBER_KEY, mCurrentUser.getObjectId());
	channelSubscriberQuery.addWhereEqualTo(ChannelSubscriber.CHANNEL_KEY, mChannel.getObjectId());
	channelSubscriberQuery.setLimit(Constants.QUERY_MAX_NUMBER);
	channelSubscriberQuery.order("-" + Constants.UPDATED_AT_KEY);
	channelSubscriberQuery.findObjects(mContext, new FindListener<ChannelSubscriber>() {
		@Override
		public void onSuccess(List<ChannelSubscriber> channelSubscribers) {
			mSubscribeChannelButton.setEnabled(true);
			hideProgressDialog();
			if(channelSubscribers.size() > 0) {
				mSubscribeChannelButton.setText(R.string.already_subscribed);
				mChannelSubscriber = channelSubscribers.get(0);
			} else {
				mSubscribeChannelButton.setText(R.string.subscribe_channel);
			}
		}

		@Override
		public void onError(int arg0, String msg) {
			mSubscribeChannelButton.setEnabled(false);
		}
	});
}
 
Example 7
Source File: MsgManager.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
/**
 * 根据是否是标签和ID值(conversation 或  belongId)和创建时间来查询消息
 *
 * @param isReadedMessage 是否是标签消息
 * @param id              会话id或者是用户ID
 * @param createTime      创建时间
 * @param findListener    找到消息的回调
 */
private void queryMsg(boolean isReadedMessage, String id, Long createTime, FindListener<ChatMessage> findListener) {
    BmobQuery<ChatMessage> query = new BmobQuery<>();
    query.addWhereEqualTo("conversationId", id);
    query.addWhereEqualTo("createTime", createTime);
    if (isReadedMessage) {
        query.addWhereEqualTo("messageType", ChatMessage.MESSAGE_TYPE_READED);
    }
    query.findObjects(findListener);
}
 
Example 8
Source File: UserManager.java    From TestChat with Apache License 2.0 5 votes vote down vote up
public void refreshUserInfo() {
                List<String> userList = UserCacheManager.getInstance().getAllUserId();
                if (userList != null && userList.size() > 0) {
                        for (final String uid :
                                userList) {
                                BmobQuery<User> query = new BmobQuery<>();
                                String lastTime = MessageCacheManager.getInstance().getUserDataLastUpdateTime(uid);
//                                        第一次断网查询用户数据
                                try {
                                        query.addWhereGreaterThan("updatedAt", new BmobDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(lastTime)));
                                        query.addWhereEqualTo("objectId", uid);
                                } catch (ParseException e) {
                                        e.printStackTrace();
                                        LogUtil.e("解析时间错误");
                                }
                                query.findObjects(CustomApplication.getInstance(), new FindListener<User>() {
                                        @Override
                                        public void onSuccess(List<User> list) {
                                                if (list != null && list.size() > 0) {
                                                        User user = list.get(0);
                                                        MessageCacheManager.getInstance().setUserDataLastUpdateTime(uid, user.getUpdatedAt());
                                                        ChatDB.create().addOrUpdateContacts(user);
                                                        UserCacheManager.getInstance().addContact(user);
                                                }
                                        }

                                        @Override
                                        public void onError(int i, String s) {
                                                LogUtil.e("断网期间内查询用户失败" + s + i);
                                        }
                                });
                        }
                }
        }
 
Example 9
Source File: UserManager.java    From TestChat with Apache License 2.0 5 votes vote down vote up
/**
 * 根据用户名查询用户
 *
 * @param name     根据用户名在服务器上查询用户
 * @param listener 回调
 */
public void queryUsers(String name, FindListener<User> listener) {
        BmobQuery<User> query = new BmobQuery<>();
        query.addWhereEqualTo("username", name);
        query.order("createdAt");
        query.findObjects(CustomApplication.getInstance(), listener);
}
 
Example 10
Source File: MsgManager.java    From TestChat with Apache License 2.0 5 votes vote down vote up
private void findReadTag(String conversationId, String createTime, FindListener<ChatMessage> findListener) {
        BmobQuery<ChatMessage> query = new BmobQuery<>();
        query.addWhereEqualTo("conversationId", conversationId);
        query.addWhereEqualTo("createTime", createTime);
        query.addWhereEqualTo("tag", Constant.TAG_ASK_READ);
        query.findObjects(CustomApplication.getInstance(), findListener);
}
 
Example 11
Source File: UserManager.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
/**
 * 根据用户名查询用户
 *
 * @param name     根据用户名在服务器上查询用户
 * @param listener 回调
 */
public Subscription queryUsers(String name, FindListener<User> listener) {
    BmobQuery<User> eq1 = new BmobQuery<>();
    eq1.addWhereEqualTo("username", name);
    BmobQuery<User> eq2 = new BmobQuery<>();
    eq2.addWhereEqualTo("name", name);
    List<BmobQuery<User>> queries = new ArrayList<>();
    queries.add(eq1);
    queries.add(eq2);
    BmobQuery<User> mainQuery = new BmobQuery<>();
    mainQuery.or(queries);
    return mainQuery.findObjects(listener);
}
 
Example 12
Source File: TestFragment.java    From AndroidReview with GNU General Public License v3.0 5 votes vote down vote up
private void loadDataByNet() {
    //加载数据前的布局操作
    preLoadLayout();
    //题库为0证明前面的读取服务器题库数目操作失败,需要重新调用,以保证mTestCount一定有值,并且这个值是服务器上题库的数量
    if (mTestCount == 0) {
        loadTestCountAndData();
    } else {
        BmobQuery<Test> query = new BmobQuery<>();
        //根据打乱的题库 题目id randomList 请求时总是拿出List的第一个元素。 在下一题的时候删除List第一个元素 以保证每次从题库拿出来的题目虽然随机,但不会重复
        query.addWhereEqualTo("testId", mRandomList.get(0));
        query.findObjects(getContext(), new FindListener<Test>() {
            @Override
            public void onSuccess(List<Test> list) {
                mTest = list.get(0);
                //把数据缓存到本地
                SaveCacheAsyncTask savecaheTask = new SaveCacheAsyncTask(getContext(), mTest, CacheHelper.TEST + mRandomList.get(0));
                savecaheTask.execute();
                //显示题目
                showTest();
                //加载完数据后的布局操作
                postLoadLayout();
            }

            @Override
            public void onError(int i, String s) {
                errorLoadLayout();
            }
        });
    }

}
 
Example 13
Source File: ProfileActivity.java    From ZhihuDaily with MIT License 5 votes vote down vote up
private void loadMoreData() {
    BmobQuery<DailyStory> query = new BmobQuery<>();
    query.setLimit(pagesize);
    query.setSkip(pageindex * pagesize);
    query.order("-createdAt");
    query.addWhereEqualTo("user", ZhihuApplication.user.getObjectId());
    query.findObjects(getApplicationContext(), new FindListener<DailyStory>() {
        @Override
        public void onSuccess(List<DailyStory> list) {
            if (list != null && list.size() > 0) {
                // 数据去重
                LinkedHashSet<DailyStory> set = new LinkedHashSet<>(list);
                List<DailyStory> dailyStoryList = new ArrayList<>(set);
                mAdapter.addData(dailyStoryList);
                pageindex++;
                isLoading = false;
                if (list.size() < pagesize) {
                    mAdapter.setIsFooterGone(true);
                }
            }

        }

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

        }
    });
}
 
Example 14
Source File: SkinEngine.java    From styT with Apache License 2.0 5 votes vote down vote up
/**
 * 发送反馈信息给开发者
 *
 * @param message 反馈信息
 */
private void sendMessage(String message) {
    BmobPushManager bmobPush = new BmobPushManager();
    BmobQuery<BmobInstallation> query = BmobInstallation.getQuery();
    query.addWhereEqualTo("isDeveloper", true);
    bmobPush.setQuery(query);
    bmobPush.pushMessage(message);

    saveFeedbackMsg(message);
}
 
Example 15
Source File: MsgManager.java    From NewFastFrame with Apache License 2.0 4 votes vote down vote up
private void findInstallation(String uid, FindListener<CustomInstallation> listener) {
    BmobQuery<CustomInstallation> query = new BmobQuery<>();
    query.addWhereEqualTo("uid", uid);
    query.findObjects(listener);
}
 
Example 16
Source File: MsgManager.java    From TestChat with Apache License 2.0 4 votes vote down vote up
public void queryGroupTableMessage(String uid, FindListener<GroupTableMessage> findListener) {
        BmobQuery<GroupTableMessage> query = new BmobQuery<>();
        query.addWhereEqualTo(Constant.TAG_TO_ID, uid);
        query.findObjects(CustomApplication.getInstance(), findListener);
}
 
Example 17
Source File: MsgManager.java    From NewFastFrame with Apache License 2.0 4 votes vote down vote up
public void sendJsonMessage(String installId, String json, PushListener pushListener) {
    BmobQuery<CustomInstallation> query = new BmobQuery<>();
    query.addWhereEqualTo("installationId", installId);
    mPushManager.setQuery(query);
    mPushManager.pushMessage(json, pushListener);
}
 
Example 18
Source File: MsgManager.java    From TestChat with Apache License 2.0 4 votes vote down vote up
private void getUserInstallationId(String toId, final FindListener<CustomInstallation> findListener) {
        BmobQuery<CustomInstallation> query = new BmobQuery<>();
        query.addWhereEqualTo("uid", toId);
        query.findObjects(CustomApplication.getInstance(), findListener);
}
 
Example 19
Source File: MsgManager.java    From NewFastFrame with Apache License 2.0 2 votes vote down vote up
/**
 * 根据用户id到后台服务器去查找用户
 *
 * @param targetId     对方用户ID
 * @param findListener 回调
 */
private void getUserById(String targetId, FindListener<User> findListener) {
    BmobQuery<User> query = new BmobQuery<>();
    query.addWhereEqualTo("objectId", targetId);
    query.findObjects(findListener);
}
 
Example 20
Source File: UserManager.java    From TestChat with Apache License 2.0 2 votes vote down vote up
/**
 * 根据用户ID获取用户信息
 *
 * @param uid          用户ID
 * @param findListener 回调
 */
private void findUserById(String uid, FindListener<User> findListener) {
        BmobQuery<User> query = new BmobQuery<>();
        query.addWhereEqualTo("objectId", uid);
        query.findObjects(CustomApplication.getInstance(), findListener);
}