本文整理汇总了Java中com.avos.avoscloud.AVQuery.whereStartsWith方法的典型用法代码示例。如果您正苦于以下问题:Java AVQuery.whereStartsWith方法的具体用法?Java AVQuery.whereStartsWith怎么用?Java AVQuery.whereStartsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.avos.avoscloud.AVQuery
的用法示例。
在下文中一共展示了AVQuery.whereStartsWith方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkFriendAdded
import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
private void checkFriendAdded(final String friendId) {
AVQuery<AVObject> queryUserId1 = new AVQuery<>(Constants.TABLE_NAME_FRIEND);
queryUserId1.whereStartsWith(Constants.KEY_USER_ID, userId);
AVQuery<AVObject> queryUserId2 = new AVQuery<>(Constants.TABLE_NAME_FRIEND);
queryUserId2.whereEndsWith(Constants.KEY_USER_ID, userId);
AVQuery<AVObject> queryFriendId1 = new AVQuery<>(Constants.TABLE_NAME_FRIEND);
queryFriendId1.whereStartsWith(Constants.KEY_FRIEND_ID, friendId);
AVQuery<AVObject> queryFriendId2 = new AVQuery<>(Constants.TABLE_NAME_FRIEND);
queryFriendId2.whereEndsWith(Constants.KEY_FRIEND_ID, friendId);
AVQuery<AVObject> query = AVQuery.and(Arrays.asList(queryUserId1, queryUserId2, queryFriendId1, queryFriendId2));
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
if (list.isEmpty()) {
Log.d(TAG, "username is not added!");
addFriend(friendId);
} else {
Log.e(TAG, "username is already added!");
ToastUtil.showToastShort(FriendActivity.this, "username is already added!");
}
}
});
}
示例2: getRelativeWord
import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
/**
* 获取当前输入的关键词的相关关键词
*/
private void getRelativeWord(){
AVQuery<AVObject> query=new AVQuery<>("word");
if(currentLang!=LANG_ALL)
query.whereEqualTo("lang",currentLang+"");
query.whereStartsWith("name", tv_search.getText().toString());
query.setLimit(10);
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
if(e==null){
relativeWordList.clear();
for(AVObject item:list){
if(!relativeWordList.contains(item.getString("name")))//解决重复字问题
relativeWordList.add(item.getString("name"));
}
getAutoCompleteWord();
// Log.e("result length", list.size() + "");//5
// Log.e("relative length",relativeWordList.size()+"");//5
// Log.e("auto length",autoCompleteWord.size()+"");//5
// Log.e("auto list",autoCompleteWord.toString());
}
else {
Log.e("get relative word error",e.toString());
}
}
});
}
示例3: queryFriends
import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
private void queryFriends() {
showRefreshDialog();
AVQuery<AVObject> query = new AVQuery<>(Constants.TABLE_NAME_FRIEND);
query.whereStartsWith(Constants.KEY_USER_ID, userId);
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
if (e == null) {
// List<String> friendIds = new ArrayList<>();
Set<String> friendIds = new HashSet<String>();
for (AVObject object : list) {
String friendId = object.getString(Constants.KEY_FRIEND_ID);
friendIds.add(friendId);
Log.d(TAG, "friendId --> " + friendId);
}
friendIds.add(userId);
mAdapter.setData(new ArrayList<String>(friendIds));
// mAdapter.setData(friendIds);
mAdapter.notifyDataSetChanged();
Log.d(TAG, "refresh finish!");
// ToastUtil.showToastShort(FriendActivity.this, "refresh finish!");
} else {
ToastUtil.showToastShort(FriendActivity.this, "refresh failed!");
}
closeRefreshDialog();
}
});
}
示例4: confirmAdd
import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
private void confirmAdd(String username) {
if (username.length() == 0) {
ToastUtil.showToastShort(this, "username can not be empty!");
return;
}
AVQuery<AVObject> query1 = new AVQuery<>(Constants.TABLE_NAME_USER);
query1.whereStartsWith(Constants.KEY_USERNAME, username);
AVQuery<AVObject> query2 = new AVQuery<>(Constants.TABLE_NAME_USER);
query2.whereEndsWith(Constants.KEY_USERNAME, username);
AVQuery<AVObject> query = AVQuery.and(Arrays.asList(query1, query2));
// query.whereMatches(Constants.KEY_USERNAME, username);
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
if (e != null) {
Log.e(TAG, "error!");
ToastUtil.showToastShort(FriendActivity.this, "query error!");
} else if (list.isEmpty()) {
Log.e(TAG, "username is not exist!");
ToastUtil.showToastShort(FriendActivity.this, "username is not exist!");
} else {
AVObject avObject = list.get(0);
String friendId = avObject.getObjectId();
checkFriendAdded(friendId);
// addFriend(friendId);
}
}
});
}
示例5: refresh
import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
private void refresh() {
showRefreshDialog();
final Set<String> ownerIds = new HashSet<>();
ownerIds.add(userId);
AVQuery<AVObject> query = new AVQuery<>(Constants.TABLE_NAME_FRIEND);
query.whereStartsWith(Constants.KEY_USER_ID, userId);
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
for (AVObject object : list) {
String friendId = object.getString(Constants.KEY_FRIEND_ID);
ownerIds.add(friendId);
}
AVUtil.queryShareByIds(ownerIds, new AVUtil.QueryShareCallback() {
@Override
public void onQuerySuccess(List<Share> shares) {
mFragment.refresh(shares);
// ToastUtil.showToastShort(HomeActivity.this, "refresh finish!");
Log.d(TAG, "refresh finish!");
closeRefreshDialog();
}
@Override
public void onQueryFailed() {
ToastUtil.showToastShort(HomeActivity.this, "refresh failed!");
closeRefreshDialog();
}
@Override
public void onQueryEmpty() {
ToastUtil.showToastShort(HomeActivity.this, "no data!");
closeRefreshDialog();
}
});
}
});
}