本文整理汇总了Java中com.avos.avoscloud.AVQuery类的典型用法代码示例。如果您正苦于以下问题:Java AVQuery类的具体用法?Java AVQuery怎么用?Java AVQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AVQuery类属于com.avos.avoscloud包,在下文中一共展示了AVQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: countUnreadRequests
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
/**
* 从 server 获取未读消息的数量
*/
public void countUnreadRequests(final CountCallback countCallback) {
AVQuery<AddRequest> addRequestAVQuery = AVObject.getQuery(AddRequest.class);
addRequestAVQuery.setCachePolicy(AVQuery.CachePolicy.NETWORK_ONLY);
addRequestAVQuery.whereEqualTo(AddRequest.TO_USER, HiTalkHelper.getInstance().getCurrentUser());
addRequestAVQuery.whereEqualTo(AddRequest.IS_READ, false);
addRequestAVQuery.countInBackground(new CountCallback() {
@Override
public void done(int i, AVException e) {
if (e == null) {
unreadAddRequestsCount = i;
EaterManager.getInstance().broadcast(new UnReadRequestCountParam().setUnReadCount(i));
}
if (null != countCallback) {
countCallback.done(i, e);
}
}
});
}
示例2: findSendRequests
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
public void findSendRequests(FindCallback findCallback,boolean orderAsc,Map<String,Object> conditions){
AVUser user = HiTalkHelper.getInstance().getCurrentUser();
AVQuery<AddRequest> q = AVObject.getQuery(AddRequest.class);
q.whereEqualTo(AddRequest.FROM_USER, user);
if (conditions != null) {
for (Map.Entry<String,Object> entry : conditions.entrySet()){
q.whereEqualTo(entry.getKey(),entry.getValue());
}
}
if (orderAsc) {
q.orderByAscending(AVObject.CREATED_AT);
} else {
q.orderByDescending(AVObject.CREATED_AT);
}
q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
q.findInBackground(findCallback);
}
示例3: initCurrentAVuser
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
private void initCurrentAVuser(final ActionCallback callback){
if (mCurrentUser == null) {
AVQuery<AVUser> query = AVUser.getQuery();
query.whereEqualTo("objectId",AVUser.getCurrentUser().getObjectId());
query.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
query.getFirstInBackground(new GetCallback<AVUser>() {
@Override
public void done(AVUser avUser, AVException e) {
if (avUser != null){
mCurrentUser = avUser;
callback.onSuccess();
}else {
mCurrentUser = AVUser.getCurrentUser();
callback.onError(0,e.getMessage());
}
}
});
}
}
示例4: runQuerySync
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
public static <T extends AVObject> List<T> runQuerySync(AVQuery<T> avQuery) throws InterruptedException, AVException {
final CountDownLatch lock = new CountDownLatch(1);
final List<T> result = new ArrayList<>();
final AVException[] exceptions = new AVException[1];
avQuery.findInBackground(new FindCallback<T>() {
@Override
public void done(List<T> list, AVException e) {
if (list != null) {
result.addAll(list);
}else {
exceptions[0] = e;
}
lock.countDown();
}
});
lock.await();
if (exceptions[0] != null){
throw exceptions[0];
}
return result;
}
示例5: setUnableToSuggest
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
public static void setUnableToSuggest(String txtUser){
AVQuery<AVObject> query = new AVQuery<>("mUser");
query.whereEqualTo("user_tel", txtUser);
query.getFirstInBackground(new GetCallback<AVObject>() {
@Override
public void done(AVObject avObject, AVException e) {
if (e == null) {
avObject.put("isAbleToSuggest", false);
avObject.saveInBackground();
} else {
Trace.e("设置isAbleToSuggest false失败");
e.printStackTrace();
}
}
});
}
示例6: onCreate
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about_app);
//this.getActionBar().setDisplayHomeAsUpEnabled(true);
submitButton = (Button) findViewById(R.id.button_about_app_submit_user_input);
submitEditText = (EditText) findViewById(R.id.editText_about_app_user_input);
mUserResponseListView = (ListView) findViewById(R.id.listView_user_back);
submitButton.setOnClickListener(buttonListener);
FindCallback<AVObject> findCallback=new FindCallback<AVObject>() {
public void done(List<AVObject> avObjects, AVException e) {
if (e == null) {
Message msg = new Message();
msg.what = 3;
msg.obj = avObjects;
mHandler.sendMessage(msg);
} else {
showError(activity.getString(R.string.network_error));
}
}
};
AVQuery<AVObject> query = new AVQuery<AVObject>("SuggestionByUser");
query.whereEqualTo("UserObjectId", getUserId());
query.findInBackground(findCallback);
}
示例7: getLangCount
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
/**
* 获取各方言词条数
* @param lang
*/
private void getLangCount(final int lang){
AVQuery query=new AVQuery("word");
query.whereEqualTo("lang", lang+"");
query.countInBackground(new CountCallback() {
@Override
public void done(int i, AVException e) {
if(e==null){
langCount[lang - 1] = i;
langCountAdapter.notifyDataSetChanged();
}else {
Log.e("getLangCountError",e.toString());
}
}
});
}
示例8: getNewWords
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
/**
* 获取最新词条
*/
private void getNewWords(){
newWords = new ArrayList<>();
AVQuery<AVObject> query=new AVQuery<>("word");
query.setLimit(21);
query.orderByDescending("updatedAt");
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
if (e == null) {
HashSet<String> set=new HashSet<>();//去重
for (AVObject item : list) {
if(!set.contains(item.getString("name"))){
newWords.add(item);
set.add(item.getString("name"));
}
}
newWordAdapter.notifyDataSetChanged();
refreshLayout.setRefreshing(false);
} else {
Log.e("get new words error",e.toString());
}
}
});
}
示例9: getData
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
/**
* 获取音/视频资源
*/
private void getData(){
AVQuery<AVObject> query=new AVQuery<>("jxh");
// query.whereEqualTo("isVoice",false);
query.setLimit(1000);
query.orderByDescending("viewcount");
query.include("cover");
query.whereExists("cover");
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
if(e==null){
mList= (LinkedList<AVObject>) list;
if(adapter!=null)
adapter.notifyDataSetChanged();
}else {
Log.e("getVoice",e.toString());
}
}
});
}
示例10: onCreate
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_jxh);
AVQuery<AVObject> query=new AVQuery<>("jxh");
query.setLimit(1000);
// query.whereDoesNotExist("coverPic");
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
if(e==null){
for(AVObject item:list){
attachCover(item);
// attachVoice(item);
// item.put("isVoice", isVoice(item));
item.saveInBackground();
}
Log.e("list size",list.size()+"");
}
}
});
}
示例11: uploadStoryFile
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
/**
* 为story添加file
*/
private void uploadStoryFile(){
AVQuery<AVObject> query=new AVQuery<>("story");
query.whereExists("url");
query.whereDoesNotExist("voiceFile");
query.setLimit(1000);
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
if (e == null) {
for (AVObject item : list) {
String url = item.getString("url");
try {
AVFile avFile = AVFile.withAbsoluteLocalPath(item.getString("content") + ".mp3", "sdcard/storyFile/" + url + ".mp3");
item.put("voiceFile", avFile);
item.saveInBackground();
} catch (IOException e1) {
Log.e("upload file error", e1.toString());
}
}
}
}
});
}
示例12: addTimeLong
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
/**
* 为story添加timelong
*/
private void addTimeLong(){
AVQuery<AVObject> query=new AVQuery<>("story");
query.setLimit(1000);
query.whereExists("voiceFile");
query.whereExists("url");
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
if (e == null) {
for (AVObject item : list) {
int timeLong = getTimeLong(item.getString("url"));
item.put("timelong", timeLong);
item.saveInBackground();
}
}
}
});
}
示例13: getComments
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
private void getComments(){
if(comments==null){
comments = new ArrayList<>();
}else {
comments.clear();
}
AVQuery<AVObject> query=new AVQuery<>("storycomment");
query.whereEqualTo("story",story);
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
if(e==null){
for(AVObject item:list){
comments.add(item);
adapter.notifyDataSetChanged();
}
} else {
Log.e("get story comm err",e.toString());
}
}
});
}
示例14: onCreate
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AVQuery<AVObject> query=new AVQuery<>("Other");
query.whereEqualTo("name", "UpdateActivity跳转至的Url");
query.findInBackground(new FindCallback<AVObject>() {
@Override
public void done(List<AVObject> list, AVException e) {
if(e==null){
if (list.size()>0){
String url=list.get(0).getString("url");
Intent intent=new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
finish();
}
}
}
});
//V1.0&V1.1:
// Intent intent=new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.zhagame.com/fangyan"));
// startActivity(intent);
// finish();
}
示例15: getInvitationById
import com.avos.avoscloud.AVQuery; //导入依赖的package包/类
/**
* 通过一个objectid获得一个invitation
*
* @param invitationId
* @return
*/
public Observable<Invitation> getInvitationById(final String invitationId)
{
return Observable.create(new Observable.OnSubscribe<Invitation>()
{
@Override
public void call(Subscriber<? super Invitation> subscriber)
{
AVQuery<Invitation> query = AVObject.getQuery(Invitation.class);
query.include(Invitation.FIELD_ACCEPT_INVITE_USERS);
query.include(Invitation.FIELD_PIC);
query.include(Invitation.FIELD_AUTHOR);
try
{
Invitation invitation = query.get(invitationId);
subscriber.onNext(invitation);
} catch (AVException e)
{
Logger.e(e, "失败");
e.printStackTrace();
subscriber.onError(e);
}
}
});
}