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

The following examples show how to use cn.bmob.v3.BmobQuery#findObjects() . 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: PreferenceUtil.java    From ZfsoftCampusAssit with Apache License 2.0 6 votes vote down vote up
public static Setting getSettingConfig() {
    Setting setting = get(Setting.class);
    if (setting == null && getLoginUser() != null) {
        BmobQuery<Setting> query = new BmobQuery<>();
        query.addWhereEqualTo("userid", getLoginUser().getUsername());
        query.findObjects(mContext, new FindListener<Setting>() {
            @Override
            public void onSuccess(List<Setting> list) {
                if (!list.isEmpty()) {
                    updateSettingConfig(list.get(0));
                } else {
                    Log.e(tag, "setting config by userid " +
                            getLoginUser().getUsername() + " query results is empty");
                }
            }

            @Override
            public void onError(int i, String s) {
                Log.e(tag, "setting config query results error " + s);
            }
        });
    }
    return setting;
}
 
Example 2
Source File: TomatoUtils.java    From ToDoList with Apache License 2.0 6 votes vote down vote up
/**
     * 返回网络上用户所有的番茄钟列表
     *
     * @param context
     * @param currentUser
     * @throws Exception
     */
    public static void getNetAllTomato(final Context context, User currentUser, final GetTomatoCallBack getTomatoCallBack ) {
        BmobQuery<Tomato> query = new BmobQuery<Tomato>();
        query.addWhereEqualTo("user", currentUser).order("createdAt");
        query.findObjects(new FindListener<Tomato>() {
            @Override
            public void done(List<Tomato> list, BmobException e) {
                if (e==null){
                    Log.i("TomatoUtils", "查询到网络任务个数: " + list.size());
                    // 1.更新本地数据库
//                    if (list.size() > 0) {
//                        ClockDao clockDao = new ClockDao(context);
//                        clockDao.saveAll(list);
//                    }
                    getTomatoCallBack.onSuccess(list);

                } else {
                    Log.i("TomatoUtils", "查询失败:"+e.getMessage());
                    getTomatoCallBack.onError(e.getErrorCode(),e.getMessage());
                }

            }
        });
    }
 
Example 3
Source File: LoginActivity.java    From Swface with Apache License 2.0 6 votes vote down vote up
private void startSearchUser(final String username, final String password) {
	BmobQuery<UserLogin> query = new BmobQuery<>();
	query.addWhereEqualTo("username", username);
	query.setLimit(1);
	query.findObjects(new FindListener<UserLogin>() {
		@Override
		public void done(List<UserLogin> list, BmobException e) {
			if (e == null && !list.isEmpty()) {
				startLogin(list.get(0));
			} else if (e == null) {
				startRegister(username, password);
			} else {
				showNormalDia("温馨提示", "登录失败!请检查网络连接");
				Log.e(TAG, "query.findObjects: ", e);
			}
		}
	});
}
 
Example 4
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 5
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 6
Source File: SubscribedChannelFragment.java    From VSigner with GNU General Public License v2.0 6 votes vote down vote up
public void refreshData() {
	BmobQuery<ChannelSubscriber> channelSubscriberQuery = new BmobQuery<ChannelSubscriber>();
	channelSubscriberQuery.addWhereEqualTo(ChannelSubscriber.SUBSCRIBER_KEY, mCurrentUser.getObjectId());
	channelSubscriberQuery.include(String.format("%1$s,%2$s", 
			ChannelSubscriber.CHANNEL_KEY, 
			ChannelSubscriber.CHANNEL_KEY + "." + Channel.MANAGER_KEY));
	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) {
			mSubscribedChannelAdapter.clear();
			for (ChannelSubscriber channelSubscriber : channelSubscribers) {
				mSubscribedChannelAdapter.add(channelSubscriber.getChannel());
			}
			mPullToRefreshLayout.refreshFinish(PullToRefreshLayout.SUCCEED);
		}
		
		@Override
		public void onError(int arg0, String msg) {
			mPullToRefreshLayout.refreshFinish(PullToRefreshLayout.FAIL);
		}
	});
}
 
Example 7
Source File: OwnChannelFragment.java    From VSigner with GNU General Public License v2.0 6 votes vote down vote up
public void refreshData() {
	BmobQuery<Channel> channelQuery = new BmobQuery<Channel>();
	channelQuery.addWhereEqualTo(Channel.MANAGER_KEY, mCurrentUser.getObjectId());
	channelQuery.include(Channel.MANAGER_KEY);
	channelQuery.setLimit(Constants.QUERY_MAX_NUMBER);
	channelQuery.order("-" + Channel.IS_ACTIVE_KEY + ",-" + Constants.UPDATED_AT_KEY);
	channelQuery.findObjects(mContext, new FindListener<Channel>() {
		@Override
		public void onSuccess(List<Channel> channels) {
			mOwnChannelAdapter.clear();
			mOwnChannelAdapter.addAll(channels);
			mPullToRefreshLayout.refreshFinish(PullToRefreshLayout.SUCCEED);
		}
		
		@Override
		public void onError(int arg0, String msg) {
			mPullToRefreshLayout.refreshFinish(PullToRefreshLayout.FAIL);
		}
	});
}
 
Example 8
Source File: RechargeHistoryActivity.java    From Mobike with Apache License 2.0 6 votes vote down vote up
private void requestData() {
    BmobQuery<RechargeHistoryData> query = new BmobQuery<>("RechargeHistoryData");
    query.order("-updatedAt");
    query.addWhereEqualTo("mMyUser", MyApplication.getInstance().getUser().getObjectId());
    //query.setLimit(4);//最新四条活动信息
    if (isFirstin) {
        mDialog.show();
        isFirstin = false;
    }
    query.findObjects(new FindListener<RechargeHistoryData>() {
        @Override
        public void done(List<RechargeHistoryData> list, BmobException e) {
            if (e == null) {
                mDatas = list;
                showHistory();
            } else {
                ToastUtils.show(RechargeHistoryActivity.this, "暂时没有消息");
                Logger.d(e);
            }
            dismissMyDialog();
        }
    });

}
 
Example 9
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 10
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 11
Source File: TestActivity.java    From Mobike with Apache License 2.0 5 votes vote down vote up
private void query() {
    BmobQuery<RideSummary> bmobQuery = new BmobQuery();
    bmobQuery.addWhereEqualTo("phone", "182****2002");
    bmobQuery.findObjects(new FindListener<RideSummary>() {
        @Override
        public void done(List<RideSummary> list, BmobException e) {
            Logger.d(e);
            if (e == null) {
                Log.d(TAG, "done: ");
            }
        }
    });
}
 
Example 12
Source File: UserManager.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
private void queryOtherBlackList(FindListener<User> listener) {
    BmobQuery<User> query = new BmobQuery<>();
    User user = new User();
    user.setObjectId(UserManager.getInstance().getCurrentUserObjectId());
    query.addWhereRelatedTo(ConstantUtil.COLUMN_NAME_OTHER_BLACKLIST, new BmobPointer(user));
    query.findObjects(listener);
}
 
Example 13
Source File: VideoUpLoadManager.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
public void uploadVideoBean(String url, String title, String playUrl) {
    BmobQuery<VideoUpLoadDataBean> bmobQuery = new BmobQuery<>();
    bmobQuery.addWhereEqualTo("title", title);
    bmobQuery.findObjects(new FindListener<VideoUpLoadDataBean>() {
        @Override
        public void done(List<VideoUpLoadDataBean> list, BmobException e) {
            if (e == null || e.getErrorCode() == 101) {
                if (list != null && list.size() > 0) {
                    VideoUpLoadDataBean item = list.get(0);
                    if (!item.getPlayList().contains(playUrl)) {
                        item.getPlayList().add(playUrl);
                        item.update();
                    }
                } else {
                    VideoUpLoadDataBean videoUpLoadDataBean = new VideoUpLoadDataBean();
                    videoUpLoadDataBean.setUrl(url);
                    List<String> stringList = new ArrayList<>();
                    stringList.add(playUrl);
                    videoUpLoadDataBean.setPlayList(stringList);
                    videoUpLoadDataBean.setTitle(title);
                    videoUpLoadDataBean.save();
                }
            } else {
                CommonLogger.e("bmob上传出错:" + e.getMessage());
            }
        }
    });
}
 
Example 14
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 15
Source File: RankFragment.java    From ToDoList with Apache License 2.0 5 votes vote down vote up
private void getRank(){
    BmobQuery<User> bmobQuery = new BmobQuery<User>();
    bmobQuery.order("total");
    bmobQuery.findObjects(new FindListener<User>() {
        @Override
        public void done(List<User> list, BmobException e) {
            if (e==null){
                Log.i("Rank", "查询到: "+list.size()+" 条数据");
                setListData(list);
                Log.i("Rank", ""+rankList.size());
            }
        }
    });
}
 
Example 16
Source File: MyRedPocketActivity.java    From Mobike with Apache License 2.0 4 votes vote down vote up
private void initView() {
    myUser = MyApplication.getInstance().getUser();
    mTitleRed.setOnLeftButtonClickListener(new TabTitleView.OnLeftButtonClickListener() {
        @Override
        public void onClick() {
            finish();
        }
    });
    mTitleRed.setOnRightTextViewClickListener(new TabTitleView.OnRightButtonClickListener() {
        @Override
        public void onClick() {
            startActivity(new Intent(MyRedPocketActivity.this,RedPocketDetailActivity.class));
        }
    });
    mTvPockey.setText("0.0元");
    mDialog.show();
    if (myUser != null){
        BmobQuery<MyRedPocketData> query = new BmobQuery<MyRedPocketData>();
        query.addWhereEqualTo("mMyUser",MyApplication.getInstance().getUser());
        query.addWhereEqualTo("isvalid", true);
        query.findObjects(new FindListener<MyRedPocketData>() {
            @Override
            public void done(List<MyRedPocketData> list, BmobException e) {
                if (e == null&&list!=null) {
                    Float total=0.00f;
                  for (int i=0;i<list.size();i++){
                      total+=Float.parseFloat(list.get(i).getMoney());
                      Logger.d(list.get(i));
                  }
                    mTvPockey.setText(total+"");
                } else {
                    mTvPockey.setText("0.0");
                }
                if (Float.parseFloat(mTvPockey.getText().toString())>10.00f){
                    mBtTakemoney.setBackgroundResource(R.color.red);
                    mBtTakemoney.setClickable(true);
                }else {
                    mBtTakemoney.setBackgroundResource(R.color.gray);
                    mBtTakemoney.setClickable(false);
                }
                if (mDialog!=null&&mDialog.isShowing())mDialog.dismiss();
            }
        });
    }

}
 
Example 17
Source File: MsgManager.java    From NewFastFrame with Apache License 2.0 4 votes vote down vote up
public void getCommentBean(String commentId, FindListener<PublicCommentBean> findListener) {
    BmobQuery<PublicCommentBean> bmobQuery = new BmobQuery<>();
    bmobQuery.addWhereEqualTo("objectId", commentId);
    bmobQuery.findObjects(findListener);
}
 
Example 18
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 19
Source File: ClockDao.java    From ToDoList with Apache License 2.0 4 votes vote down vote up
public HashMap getAmount() {
        HashMap<String, Integer> results = new HashMap<>();

//        String[] projection = {
//                _ID,
//                COLUMN_NAME_END_TIME,
//                COLUMN_NAME_DURATION
//        };
//
//        Cursor cursor = db.query(
//                TABLE_NAME,                     // The table to query
//                projection,                       // The columns to return
//                null,                        // The columns for the WHERE clause
//                null,                    // The values for the WHERE clause
//                null,                            // don't group the rows
//                null,                            // don't filter by row groups
//                null                             // don't sort order
//        );
//
//        int duration = 0;
//        int times  = 0;
//
//        try {
//            while (cursor.moveToNext()) {
//                if (!cursor.isNull(cursor.getColumnIndex(COLUMN_NAME_END_TIME))) {
//                    times++;
//                    duration += cursor.getInt(cursor.getColumnIndex(COLUMN_NAME_DURATION));
//                }
//            }
//        } finally {
//            cursor.close();
//        }

        user = User.getCurrentUser(User.class);
        BmobQuery<Clock> bmobQuery = new BmobQuery<Clock>();
        bmobQuery.addWhereEqualTo("user", user);
        bmobQuery.findObjects(new FindListener<Clock>() {
            @Override
            public void done(List<Clock> list, BmobException e) {
                if (e==null){
                    Log.i("Clock", "查询到: " +list.size()+" 条数据");
                    for (Clock clock : list){
                        if (clock.getEnd_time()!=null){
                            allTimes++;
                            allDuration += clock.getDuration();
                        }
                    }
                    Log.i("Clock", "番茄钟个数:" + allTimes);
                    Log.i("Clock", "累计时间: " + allDuration);
                } else {

                }
            }
        });

        results.put("times", allTimes);
        results.put("duration", allDuration);

        return results;
    }
 
Example 20
Source File: MsgManager.java    From TestChat with Apache License 2.0 4 votes vote down vote up
public void queryAllGroupTableMessage(String groupId, FindListener<GroupTableMessage> findListener) {
        BmobQuery<GroupTableMessage> query = new BmobQuery<>();
        query.addWhereEqualTo("groupId", groupId);
        query.findObjects(CustomApplication.getInstance(), findListener);
}