Java Code Examples for cn.bmob.v3.listener.FindListener

The following examples show how to use cn.bmob.v3.listener.FindListener. 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: ToDoList   Author: LeeLulin   File: TomatoUtils.java    License: 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 #2
Source Project: styT   Author: stytooldex   File: SampleAdapter.java    License: 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 #3
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 #4
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 #5
Source Project: NewFastFrame   Author: HelloChenJinJun   File: RandomData.java    License: Apache License 2.0 6 votes vote down vote up
public static void initRandomAvatar() {
    if (avatarList.size() > 0) {
        avatarList.clear();
    }
    MsgManager.getInstance().getAllDefaultAvatarFromServer(new FindListener<String>() {
        @Override
        public void done(List<String> list, BmobException e) {
            if (e == null) {
                if (list != null && list.size() > 0) {
                    LogUtil.e("获取到默认头像数据拉");
                    for (String url :
                            list) {
                        LogUtil.e(url);
                    }
                    avatarList.addAll(list);
                } else {
                    LogUtil.e("从服务器上获取的到的默认的头像数据为空");
                }
            } else {
                LogUtil.e("从服务器上获取的到的默认的头像数据失败" + e.toString());
            }
        }

    });
}
 
Example #6
Source Project: NewFastFrame   Author: HelloChenJinJun   File: RandomData.java    License: Apache License 2.0 6 votes vote down vote up
public static void initRandomWallPaper() {
    MsgManager.getInstance().getAllDefaultWallPaperFromServer(new FindListener<String>() {
        @Override
        public void done(List<String> list, BmobException e) {
            if (e == null) {
                if (list != null && list.size() > 0) {
                    LogUtil.e("获取到默认背景数据拉");
                    for (String url :
                            list) {
                        LogUtil.e(url);
                    }
                    wallPaperList.addAll(list);
                } else {
                    LogUtil.e("从服务器上获取的到的默认的背景数据为空");
                }
            } else {
                LogUtil.e("从服务器上获取的到的默认的背景数据失败" + e.toString());
            }
        }
    });

}
 
Example #7
Source Project: NewFastFrame   Author: HelloChenJinJun   File: RandomData.java    License: Apache License 2.0 6 votes vote down vote up
public static void initTitleWallPaper() {
    MsgManager.getInstance().getAllDefaultTitleWallPaperFromServer(new FindListener<String>() {
        @Override
        public void done(List<String> list, BmobException e) {
            if (e == null) {
                if (list != null && list.size() > 0) {
                    LogUtil.e("获取到默认背景数据拉");
                    for (String url :
                            list) {
                        LogUtil.e(url);
                    }
                    titleWallPaper.addAll(list);
                } else {
                    LogUtil.e("从服务器上获取的到的默认的背景数据为空");
                }
            } else {
                LogUtil.e("从服务器上获取的到的默认的背景数据失败" + e.toString());
            }
        }

    });
}
 
Example #8
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 #9
Source Project: NewFastFrame   Author: HelloChenJinJun   File: ChatNotificationManager.java    License: Apache License 2.0 6 votes vote down vote up
private void realSendGroupMessageNotification(String name, GroupChatMessage groupChatMessage, Context context) {
    UserManager.getInstance().findUserById(groupChatMessage.getBelongId(), new FindListener<User>() {
        @Override
        public void done(List<User> list, BmobException e) {
            if (list != null && list.size() > 0) {
                if (groupChatMessage.getContentType().equals(ConstantUtil.TAG_MSG_TYPE_IMAGE)) {
                    showNotification(ConstantUtil.NOTIFICATION_TAG_MESSAGE, context, name, R.mipmap.ic_launcher, list.get(0).getName() + ":[图片]", HomeActivity.class);
                } else if (groupChatMessage.getContentType().equals(ConstantUtil.TAG_MSG_TYPE_LOCATION)) {
                    showNotification(ConstantUtil.NOTIFICATION_TAG_MESSAGE, context, name, R.mipmap.ic_launcher, list.get(0).getName() + ":[位置]", HomeActivity.class);
                } else if (groupChatMessage.getContentType().equals(ConstantUtil.TAG_MSG_TYPE_VOICE)) {
                    showNotification(ConstantUtil.NOTIFICATION_TAG_MESSAGE, context, name, R.mipmap.ic_launcher, list.get(0).getName() + ":[语音]", HomeActivity.class);
                } else {
                    showNotification(ConstantUtil.NOTIFICATION_TAG_MESSAGE, context, name, R.mipmap.ic_launcher, list.get(0).getName() + ":" + FaceTextUtil.toSpannableString(context, groupChatMessage.getContent()), HomeActivity.class);
                }
            }
        }
    });
}
 
Example #10
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 #11
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 #12
Source Project: NewFastFrame   Author: HelloChenJinJun   File: CommentDetailPresenter.java    License: Apache License 2.0 6 votes vote down vote up
public void getCommentListDetailData(PublicCommentBean bean ,final boolean isRefresh) {
    if (isRefresh) {
        iView.showLoading("正在加载数据.........");
    }
    CommentDetailBean commentDetailBean=gson.fromJson(bean.getContent(),CommentDetailBean.class);
    String[] uidList = commentDetailBean.getPublicId().split("&");
    String replyUid;
    if (uidList[0].equals(bean.getUser().getObjectId())) {
        replyUid = uidList[1];
    } else {
        replyUid = uidList[0];
    }
    UserManager.getInstance().findUserById(replyUid, new FindListener<User>() {
        @Override
        public void done(List<User> list, BmobException e) {
            if (e == null) {
                iView.updateData(commentDetailBean.getConversationList()
                        .get(commentDetailBean.getPublicId()));
                iView.hideLoading();
            }else {
                iView.showError(e.toString(), () -> getCommentListDetailData(bean, isRefresh));
            }
        }
    });
}
 
Example #13
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 #14
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 #15
Source Project: NewFastFrame   Author: HelloChenJinJun   File: NewFriendAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void convert(BaseWrappedViewHolder holder, ChatMessageEntity data, boolean isSwipeItem) {
        UserManager.getInstance().findUserById(data.getBelongId(), new FindListener<User>() {
                @Override
                public void done(List<User> list, BmobException e) {
                        if (list != null && list.size() > 0) {
                                holder.setImageUrl(R.id.iv_new_friend_item_avatar, list.get(0).getAvatar())
                                        .setText(R.id.tv_new_friend_item_name, list.get(0).getName());
                        }
                }
        });
        if (data.getReadStatus()==ConstantUtil.READ_STATUS_READED) {
                holder.setVisible(R.id.tv_new_friend_item_agree, true);
                holder.setVisible(R.id.btn_new_friend_item_agree, false);
        } else if (data.getReadStatus()==ConstantUtil.READ_STATUS_READED) {
                holder.setVisible(R.id.btn_new_friend_item_agree, false);
                holder.setVisible(R.id.tv_new_friend_item_agree, true);
        }
        holder.setOnItemChildClickListener(R.id.btn_new_friend_item_agree);
}
 
Example #16
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 #17
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 #18
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 #19
Source Project: Swface   Author: tony-Shx   File: LoginActivity.java    License: 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 #20
Source Project: TestChat   Author: HelloChenJinJun   File: RandomData.java    License: Apache License 2.0 6 votes vote down vote up
public static void initRandomAvatar() {
        if (avatarList.size() > 0) {
                avatarList.clear();
        }
        MsgManager.getInstance().getAllDefaultAvatarFromServer(new FindListener<String>() {
                @Override
                public void onSuccess(List<String> list) {
                        if (list != null && list.size() > 0) {
                                LogUtil.e("获取到默认头像数据拉");
                                for (String url :
                                        list) {
                                        LogUtil.e(url);
                                }
                                avatarList.addAll(list);
                        } else {
                                LogUtil.e("从服务器上获取的到的默认的头像数据为空");
                        }
                }

                @Override
                public void onError(int i, String s) {
                        LogUtil.e("从服务器上获取的到的默认的头像数据失败" + s + i);
                }
        });
}
 
Example #21
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 #22
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 #23
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 #24
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 #25
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 #26
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 #27
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 #28
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 #29
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 #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());
                }

            }
        });
    }