Java Code Examples for cn.bmob.v3.BmobQuery

The following examples show how to use cn.bmob.v3.BmobQuery. These examples are extracted from open source projects. 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 Project: BitkyShop   Author: bitkylin   File: OrderActivity.java    License: MIT License 6 votes vote down vote up
private void queryDefaultAddressFromBmob() {
  BmobQuery<ReceiveAddress> bmobQuery = new BmobQuery<>();
  bmobQuery.addWhereEqualTo("userObjectId", order.getUserObjectId());
  bmobQuery.addWhereEqualTo("isDefault", true);
  bmobQuery.setLimit(50);
  bmobQuery.findObjects(new FindListener<ReceiveAddress>() {

    @Override public void done(List<ReceiveAddress> list, BmobException e) {
      if (e != null) {
        toastUtil.show(e.getMessage());
        return;
      }
      if (list.size() > 0) {
        receiveAddress = list.get(0);
        name.setText(receiveAddress.getName());
        phone.setText(receiveAddress.getPhone());
        address.setText(receiveAddress.getAddress());
      }
    }
  });
}
 
Example #2
Source Project: styT   Author: stytooldex   File: Update.java    License: Apache License 2.0 6 votes vote down vote up
private void xft() {

        BmobQuery<i_a> query = new BmobQuery<>();
        query.getObject("03bf357e85", new QueryListener<i_a>() {

            @Override
            public void done(i_a movie, BmobException e) {
                if (e == null) {
                    String s = movie.getContent();
                    String sr = nico.styTool.Constant.a_mi + "\n" + nico.styTool.Constant.a_miui;
                    if (s.equals(sr)) {

                    } else {
                        nico.styTool.ToastUtil.show(Update.this, "版本不一致,请更新", Toast.LENGTH_SHORT);
                        finish();
                    }
                } else {

                }
            }
        });
    }
 
Example #3
Source Project: styT   Author: stytooldex   File: PublishActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void xft() {

        BmobQuery<i_a> query = new BmobQuery<>();
        query.getObject("03bf357e85", new QueryListener<i_a>() {

            @Override
            public void done(i_a movie, BmobException e) {
                if (e == null) {
                    String s = movie.getContent();
                    String sr = nico.styTool.Constant.a_mi + "\n" + nico.styTool.Constant.a_miui;
                    if (s.equals(sr)) {

                    } else {
                        nico.styTool.ToastUtil.show(PublishActivity.this, "版本不一致,请更新", Toast.LENGTH_SHORT);
                        finish();
                    }
                } else {
                    finish();
                }
            }
        });
    }
 
Example #4
Source Project: styT   Author: stytooldex   File: HelpsCommentActivity.java    License: 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 #5
Source Project: ZfsoftCampusAssit   Author: hjw541988478   File: PreferenceUtil.java    License: 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 #6
Source Project: styT   Author: stytooldex   File: Compat3.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询微博
 */
private void findWeibos() {
    BmobQuery<Post_> query = new BmobQuery<Post_>();
    query.order("-updatedAt");
    query.include("author");// 希望在查询微博信息的同时也把发布人的信息查询出来,可以使用include方法
    query.findObjects(new FindListener<Post_>() {
        @Override
        public void done(List<Post_> object, BmobException e) {
            if (e == null) {
                weibos = object;
                adapter.notifyDataSetChanged();
            } else {
                //loge(e);
            }
        }

    });

}
 
Example #7
Source Project: VSigner   Author: vell001   File: SubscribedChannelFragment.java    License: 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 #8
Source Project: styT   Author: stytooldex   File: CommentListActivity_.java    License: Apache License 2.0 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(new FindListener<Comment_>() {

        @Override
        public void done(List<Comment_> object, BmobException e) {
            if (e == null) {
                comments = object;
                adapter.notifyDataSetChanged();
                et_content.setText("");
            } else {
                //loge(e);
            }
        }

    });

}
 
Example #9
Source Project: Mobike   Author: yiwent   File: TestActivity.java    License: 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 #10
Source Project: VSigner   Author: vell001   File: OwnChannelFragment.java    License: 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 #11
Source Project: BitkyShop   Author: bitkylin   File: OrderActivity.java    License: MIT License 6 votes vote down vote up
/**
 *
 */
private void queryCurrentOrderFromBmob() {
  BmobQuery<Order> bmobQuery = new BmobQuery<>();
  bmobQuery.addWhereEqualTo("objectId", order.getObjectId());
  bmobQuery.findObjects(new FindListener<Order>() {

    @Override public void done(List<Order> list, BmobException e) {
      if (e != null) {
        toastUtil.show(e.getMessage());
        return;
      }
      if (list.size() > 0) {
        order = list.get(0);
        initOrder(order);
      }
    }
  });
}
 
Example #12
Source Project: ZfsoftCampusAssit   Author: hjw541988478   File: BmobCourseDataSource.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void getLocalWeekTimetableCourses(int currentWeekNo, final LoadCoursesCallback callback) {
    BmobQuery<Course> weekCourseQuery = new BmobQuery<>();
    weekCourseQuery.addWhereContains(
            CoursePersistenceContract.CourseTimetableEntry.COLUMN_NAME_WEEKS, String.valueOf(currentWeekNo));
    weekCourseQuery.findObjects(mContext, new FindListener<Course>() {
        @Override
        public void onSuccess(List<Course> list) {
            callback.onCoursesLoaded(list);
        }

        @Override
        public void onError(int i, String s) {
            callback.onDataError();
        }
    });
}
 
Example #13
Source Project: BitkyShop   Author: bitkylin   File: SearchActivity.java    License: MIT License 6 votes vote down vote up
private void searchCommodity() {
  ((InputMethodManager) context.getSystemService(
      Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(searchEdittext.getWindowToken(),
      InputMethodManager.HIDE_NOT_ALWAYS);
  String msg = searchEdittext.getText().toString().trim();
  if (msg.equals("")) {
    toastUtil.show("请输入要搜索的商品");
    return;
  }
  BmobQuery<Commodity> bmobQuery = new BmobQuery<>();
  bmobQuery.addWhereEqualTo("categorySub", msg);
  KLog.d(msg);
  bmobQuery.findObjects(new FindListener<Commodity>() {
    @Override public void done(List<Commodity> list, BmobException e) {
      if (e != null) {
        KLog.d(e.getMessage());
      }
      if (list != null) {
        KLog.d(list.size());
      }
    }
  });
}
 
Example #14
Source Project: NewFastFrame   Author: HelloChenJinJun   File: ShareInfoPresenter.java    License: 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 #15
Source Project: WliveTV   Author: wanliyang1990   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
public void queryData()
{
    BmobQuery<LiveBean> bmobQuery = new BmobQuery<LiveBean>();
    bmobQuery.findObjects(this, new FindListener<LiveBean>() {
        @Override
        public void onSuccess(List<LiveBean> list) {
            System.out.println(list.size());
            adapter.updateDatas(list);
        }

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

        }
    });
}
 
Example #16
Source Project: stynico   Author: stytooldex   File: lua_web.java    License: MIT License 6 votes vote down vote up
/**
    * 初始化网路数据:
    */
   private void initWebView()
   {
BmobQuery<o> query = new BmobQuery<o>();
query.getObject(lua_web.this, "957aaf7e08", new GetListener<o>() {

	@Override
	public void onSuccess(o object)
	{

	    wv_web.loadUrl(object.getContent());
	    wv_web.setWebViewClient(new MyWebViewClient());
	    wv_web.setDownloadListener(new MyDownLoadListener());
	}
	
	@Override
	public void onFailure(int code, String msg)
	{
	}
    });}
 
Example #17
Source Project: stynico   Author: stytooldex   File: LoginF.java    License: MIT License 6 votes vote down vote up
private void findWeibos()
  {
//MyUser user = BmobUser.getCurrentUser(LoginF.this, MyUser.class);
BmobQuery<Login> query = new BmobQuery<Login>();
//query.addWhereEqualTo("author", user);	// 查询当前用户的所有微博
query.order("-updatedAt");
query.include("author");// 希望在查询微博信息的同时也把发布人的信息查询出来,可以使用include方法
query.findObjects(LoginF.this, new FindListener<Login>() {
		@Override
		public void onSuccess(List<Login> object)
		{
			// TODO Auto-generated method stub
			weibos = object;
			adapter.notifyDataSetChanged();
			//  mProgressDialog.dismiss();
		}

		@Override
		public void onError(int code, String msg)
		{
			// TODO Auto-generated method stub
			//   toast("查询失败:" + msg);
		}
	});
//mProgressDialog = ProgressDialog.show(getActivity(), null, getResources().getString(R.string.del_));
  }
 
Example #18
Source Project: stynico   Author: stytooldex   File: WeiboListActivity.java    License: 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 #19
Source Project: stynico   Author: stytooldex   File: CommentListActivity.java    License: 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 #20
Source Project: AndroidReview   Author: envyfan   File: ReviewFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * “单元”列表下拉刷新具体实现
 */
private void putToRefreshByUnit() {
    //初始化Bmob查询类
    BmobQuery<Unit> query = new BmobQuery<>();
    //执行查询,查询单元表 取出所有单元
    query.findObjects(getContext(), new FindListener<Unit>() {
        @Override
        public void onSuccess(final List<Unit> unitList) {
            //根据查询的所有单元,请求所有的知识点数据
            requestPointByUnits(unitList);
        }
        @Override
        public void onError(int i, String s) {
            toastError(mLoadingLayout, getContext());
        }
    });

}
 
Example #21
Source Project: BitkyShop   Author: bitkylin   File: HomeFragment.java    License: MIT License 6 votes vote down vote up
/**
 * 广告栏Slider数据初始化
 */
private void getBmobSliderData() {
    BmobQuery<Commodity> bmobQuery = new BmobQuery<>();
    bmobQuery.addWhereEqualTo("AD", "true").setLimit(5).findObjects(new FindListener<Commodity>() {
        @Override
        public void done(List<Commodity> list, BmobException e) {
            if (e != null) {
                KLog.d(TAG, "异常内容:" + e.getMessage());
            } else if (list.size() > 0) {
                KLog.d(TAG, "list.size():" + list.size());
                mTextSliderViews = new ArrayList<>();
                for (Commodity commodity : list) {
                    mTextSliderViews.add(
                        buildTextSlider(commodity.getCoverPhotoUrl(), commodity.getName(), 0));
                }
                KLog.d(TAG, "mTextSliderViews.size():" + mTextSliderViews.size());

                if (mSliderLayout != null) initSlider();
            }
        }
    });
}
 
Example #22
Source Project: Aurora   Author: Zweihui   File: HistoryModel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Observable<List<VideoDaoEntity>> getListFromNet(int start, String userid) {
    return Observable.create((ObservableOnSubscribe<List<VideoDaoEntity>>) emitter -> {

        BmobQuery<VideoDaoEntity> query = new BmobQuery<VideoDaoEntity>();
        query.addWhereEqualTo("userId", userid);
        query.setLimit(10);
        query.order("-updatedAt");
        query.setSkip(start);
        query.findObjects(new FindListener<VideoDaoEntity>() {
            @Override
            public void done(List<VideoDaoEntity> list, BmobException e) {
                List<VideoDaoEntity> infolist = new ArrayList<VideoDaoEntity>();
                if (!StringUtils.isEmpty(list)) {
                    for (VideoDaoEntity entity1 : list) {
                        entity1.setVideo(mGson.fromJson(entity1.getBody(), VideoListInfo.Video.VideoData.class));
                        infolist.add(entity1);
                    }
                }
                emitter.onNext(infolist);
            }
        });
    });
}
 
Example #23
Source Project: Aurora   Author: Zweihui   File: AttentionModel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Observable<List<MyAttentionEntity>> getMyAttentionList(String userid) {
    return Observable.create((ObservableOnSubscribe<List<MyAttentionEntity>>) emitter -> {

        BmobQuery<MyAttentionEntity> query = new BmobQuery<MyAttentionEntity>();
        query.addWhereEqualTo("userId", userid);
        query.order("-createdAt");
        query.findObjects(new FindListener<MyAttentionEntity>() {
            @Override
            public void done(List<MyAttentionEntity> list, BmobException e) {
                if (list!=null)
                    emitter.onNext(list);
            }
        });
    });
}
 
Example #24
Source Project: Mobike   Author: yiwent   File: MyTripsActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void requestData() {
    mDialog.show();
    if (mQuery == null) {
        mQuery = new BmobQuery<>("MyTripsData");
        mQuery.addWhereEqualTo("mMyUser", MyApplication.getInstance().getUser().getObjectId());
        mQuery.order("-updatedAt");
    }
    mQuery.findObjects(new FindListener<MyTripsData>() {
        @Override
        public void done(List<MyTripsData> list, BmobException e) {
            if (e == null) {
                mData = list;
                showMyTrips();
            } else {
                ToastUtils.show(MyTripsActivity.this, "暂时没有骑行记录");
                Logger.d(e);
            }
            dismissMyDialog();
        }
    });
}
 
Example #25
Source Project: Mobike   Author: yiwent   File: LastTenTripHistoryActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void requestData() {
    mDialog.show();
    if (mQuery == null) {
        mQuery = new BmobQuery<>("MyTripsData");
        mQuery.setLimit(10);
        mQuery.addWhereEqualTo("mMyUser", MyApplication.
                getInstance().getUser().getObjectId());
        mQuery.order("-updatedAt");
    }
    mQuery.findObjects(new FindListener<MyTripsData>() {
        @Override
        public void done(List<MyTripsData> list, BmobException e) {
            if (e == null) {
                mData = list;
                showMyTrips();
            } else {
                ToastUtils.show(LastTenTripHistoryActivity.this, "暂时没有骑行记录");
                Logger.d(e);
            }
            dismissMyDialog();
        }
    });
}
 
Example #26
Source Project: Mobike   Author: yiwent   File: RechargeHistoryActivity.java    License: 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 #27
Source Project: Mobike   Author: yiwent   File: LoginActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void RegOK() {
    mDialog.show();
    mPhone = mEtPhone.getText().toString().trim().replace("\\s*", "");// TODO: 2017/6/21  测试后删除
    BmobQuery<MyUser> query = new BmobQuery<MyUser>();
    query.addWhereEqualTo("username", mPhone);
    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");
                    toLogin();
                } else {
                    Log.d(TAG, "cheackUser: notRegister");
                    toRegister();
                }
            } else {
                Log.d(TAG, "done: " + e);
                DismissMyDialog();
            }
        }
    });
}
 
Example #28
Source Project: Mobike   Author: yiwent   File: MyCouponsActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void requesData() {
    mDialog.show();
    if (mQuery == null) {
        mQuery = new BmobQuery<>("MyCouponsData");
        mQuery.setLimit(10);
        mQuery.addWhereEqualTo("mMyUser", MyApplication.getInstance().getUser().getObjectId());
        mQuery.order("-updatedAt");
    }
    mQuery.findObjects(new FindListener<MyCouponsData>() {
        @Override
        public void done(List<MyCouponsData> list, BmobException e) {
            if (e == null) {
                mData = list;
                showCoupons();
            } else {
                ToastUtils.show(MyCouponsActivity.this, "暂时没有优惠信息");
                Logger.d(e);
            }
            dismissMyDialog();
        }
    });
}
 
Example #29
Source Project: VSigner   Author: vell001   File: ShowSignerActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void refreshData() {
	BmobQuery<ChannelSigner> channelQuery = new BmobQuery<ChannelSigner>();
	channelQuery.addWhereEqualTo(ChannelSigner.CHANNEL_KEY, mChannel.getObjectId());
	channelQuery.addWhereGreaterThanOrEqualTo(ChannelSigner.SIGN_DATE_KEY, mChannel.getStartSignDate());
	channelQuery.include(String.format("%1$s,%2$s", 
			ChannelSigner.SIGNER_KEY,
			ChannelSigner.CHANNEL_KEY));
	channelQuery.setLimit(Constants.QUERY_MAX_NUMBER);
	channelQuery.order(ChannelSigner.SIGNER_KEY);
	channelQuery.findObjects(mContext, new FindListener<ChannelSigner>() {
		@Override
		public void onSuccess(List<ChannelSigner> channelSigners) {
			mChannelSignerAdapter.clear();
			mChannelSignerAdapter.addAll(channelSigners);
			mPullToRefreshLayout.refreshFinish(PullToRefreshLayout.SUCCEED);
		}
		
		@Override
		public void onError(int arg0, String msg) {
			mPullToRefreshLayout.refreshFinish(PullToRefreshLayout.FAIL);
		}
	});
}
 
Example #30
Source Project: ToDoList   Author: LeeLulin   File: ToDoUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
     * 返回网络上用户所有的任务
     *
     * @param context
     * @param currentUser
     * @throws Exception
     */
    public static void getNetAllTodos(final Context context, User currentUser, final GetTodosCallBack getTodosCallBack) {
        BmobQuery<Todos> query = new BmobQuery<Todos>();
        query.addWhereEqualTo("user", currentUser).order("bmobDate");
        // 这个查询也包括了用户的已经过时的任务
        query.findObjects(new FindListener<Todos>() {
            @Override
            public void done(List<Todos> list, BmobException e) {
                if (e==null){
                    Log.i("ToDoUtils", "查询到网络任务个数: " + list.size());
                    // 1.更新本地数据库
                    if (list.size() > 0) {
//                        ToDoDao toDoDao = new ToDoDao(context);
//                        toDoDao.saveAll(list);
                        // 2.筛选大于当后时间的
                        List<Todos> listTodo = new ArrayList<Todos>();
                        long curTime = System.currentTimeMillis();
                        for (Todos todos : listTodo) {
                            if (todos.getRemindTime() >= curTime) {
                                listTodo.add(todos);
                            }
                        }
                    }
                    getTodosCallBack.onSuccess(list);

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

            }
        });
    }