当前位置: 首页>>代码示例>>Java>>正文


Java AVQuery.setCachePolicy方法代码示例

本文整理汇总了Java中com.avos.avoscloud.AVQuery.setCachePolicy方法的典型用法代码示例。如果您正苦于以下问题:Java AVQuery.setCachePolicy方法的具体用法?Java AVQuery.setCachePolicy怎么用?Java AVQuery.setCachePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.avos.avoscloud.AVQuery的用法示例。


在下文中一共展示了AVQuery.setCachePolicy方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
            }
        }
    });
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:22,代码来源:FriendsManager.java

示例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);
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:18,代码来源:FriendsManager.java

示例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());
                }
            }
        });
    }
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:20,代码来源:HiTalkHelper.java

示例4: findAddRequests

import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
public void findAddRequests(int skip, int limit, FindCallback findCallback) {
    AVUser user = HiTalkHelper.getInstance().getCurrentUser();
    AVQuery<AddRequest> q = AVObject.getQuery(AddRequest.class);
    q.include(AddRequest.FROM_USER);
    q.skip(skip);
    q.limit(limit);
    q.whereEqualTo(AddRequest.TO_USER, user);
    q.orderByDescending(AVObject.CREATED_AT);
    q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
    q.findInBackground(findCallback);
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:12,代码来源:FriendsManager.java

示例5: findFriendsWithCachePolicy

import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
public void findFriendsWithCachePolicy(AVQuery.CachePolicy cachePolicy, FindCallback<AVUser>
        findCallback) {
    AVQuery<AVUser> q = null;
    try {
        q = HiTalkHelper.getInstance().getCurrentUser().followeeQuery(AVUser.class);
    } catch (Exception e) {
    }
    q.setCachePolicy(cachePolicy);
    q.setMaxCacheAge(TimeUnit.MINUTES.toMillis(1));
    q.findInBackground(findCallback);
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:12,代码来源:FriendsManager.java

示例6: fetchUsers

import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
public void fetchUsers(final List<String> ids, final CacheUserCallback cacheUserCallback) {

        Set<String> uncachedIds = new HashSet<String>();
        for (String id : ids) {
            if (!mAvUsersCache.containsKey(id)) {
                uncachedIds.add(id);
            }
        }
        if (uncachedIds.isEmpty()) {
            if (null != cacheUserCallback) {
                cacheUserCallback.done(getUsersFromCache(ids), null);
                return;
            }
        }
        AVQuery<AVUser> q = AVUser.getQuery();
        q.whereContainedIn(OBJECT_ID, uncachedIds);
        q.setLimit(1000);
        q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
        q.findInBackground(new FindCallback<AVUser>() {
            @Override
            public void done(List<AVUser> list, AVException e) {
                if (null == e) {
                    for (AVUser user : list) {
                        mAvUsersCache.put(user.getObjectId(), user);
                    }
                }
                if (null != cacheUserCallback) {
                    cacheUserCallback.done(getUsersFromCache(ids), e);
                }
            }
        });
    }
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:33,代码来源:UserCacheHelper.java

示例7: queryCurrentUser

import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
/**
 * you can get a user carried with full info.
 * @return
 */
public AVUser queryCurrentUser(){
    AVQuery<AVUser> query = AVUser.getQuery();
    query.whereEqualTo("objectId",AVUser.getCurrentUser().getObjectId());
    query.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
    try {
        return query.getFirst();
    } catch (AVException e) {
        NLog.e(TagUtil.makeTag(HiTalkHelper.class),e);
    }
    return getCurrentUser();
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:16,代码来源:HiTalkHelper.java

示例8: findUsers

import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
public static List<AVUser> findUsers(List<String> userIds) throws AVException {
    if (userIds.size() <= 0) {
        return Collections.EMPTY_LIST;
    }
    AVQuery<AVUser> q = AVUser.getQuery();
    q.whereContainedIn("objectId", userIds);
    q.setLimit(1000);
    q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
    return q.find();
}
 
开发者ID:lanixzcj,项目名称:LoveTalkClient,代码行数:11,代码来源:CacheService.java

示例9: countAddRequests

import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
public static int countAddRequests() throws AVException {
	AVQuery<AddRequest> q = AVObject.getQuery(AddRequest.class);
	q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
	q.whereEqualTo(AddRequest.TO_USER, AVUser.getCurrentUser());
	try {
		return q.count();
	} catch (AVException e) {
		if (e.getCode() == AVException.CACHE_MISS) {
			return 0;
		} else {
			throw e;
		}
	}
}
 
开发者ID:lanixzcj,项目名称:LoveTalkClient,代码行数:15,代码来源:AddRequestService.java

示例10: findAddRequests

import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
public static List<AddRequest> findAddRequests() throws AVException {
	AVUser user = AVUser.getCurrentUser();
	AVQuery<AddRequest> q = AVObject.getQuery(AddRequest.class);
	q.include(AddRequest.FROM_USER);
	q.whereEqualTo(AddRequest.TO_USER, user);
	q.orderByDescending("createdAt");
	q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
	return q.find();
}
 
开发者ID:lanixzcj,项目名称:LoveTalkClient,代码行数:10,代码来源:AddRequestService.java

示例11: searchUser

import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
public void searchUser(String searchName, int skip,
					   FindCallback<AVUser> findCallback) {
	AVQuery<AVUser> q = AVUser.getQuery(AVUser.class);
	q.whereContains("username", searchName);
	q.limit(10);
	q.skip(skip);
	AVUser user = AVUser.getCurrentUser();
	List<String> friendIds = getFriendIds();
	friendIds.add(user.getObjectId());
	q.whereNotContainedIn("objectId", friendIds);
	q.orderByDescending("updateAt");
	q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
	q.findInBackground(findCallback);
}
 
开发者ID:lanixzcj,项目名称:LoveTalkClient,代码行数:15,代码来源:AddFriendActivity.java

示例12: initQuery

import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
private void initQuery(AVQuery avQuery){
    avQuery.setMaxCacheAge(30 * 24 * 60 * 60);
    avQuery.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:5,代码来源:BnHelper.java

示例13: loadNotTopicData

import com.avos.avoscloud.AVQuery; //导入方法依赖的package包/类
private void loadNotTopicData(final boolean isRefresh) {
    final AVQuery<AVObject> query = new AVQuery<>("idea");
    query.whereNotEqualTo("tag", 1);
    query.orderByDescending("createdAt");
    query.setLimit(1);
    query.include("user");


    if (!isRefresh) {
        query.whereLessThan("ideaId", mOffset);
    }
    query.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
    query.findInBackground(new FindCallback<AVObject>() {
        @Override
        public void done(List<AVObject> list, AVException e) {
            mSwipeRefreshLayout.setRefreshing(false);
            if (e == null) {
                if (!list.isEmpty()) {
                    for (AVObject object : list) {
                        int id = object.getInt("ideaId");
                        Log.i("id--->", id + "");
                    }


                    mOffset = list.get(list.size() - 1).getInt("ideaId");
                    Log.i("mOffset", mOffset + "");

                    if (isRefresh) {
                        mData.addAll(topicNum, list);
                    } else {
                        mData.addAll(list);
                        mPager++;
                    }
                    mAdapter.notifyDataSetChanged();
                    if (!NetworkUtil.isNetworkConnected(getActivity())) {
                        showToast(getActivity(), "网络错误");
                    }
                } else {
                    showToast(getActivity(), "没有更多数据了");
                }
            } else {
                e.printStackTrace();
                if (e.getCode() == AVException.CACHE_MISS) {

                }
            }
        }
    });
}
 
开发者ID:AndroidCreativeDesign,项目名称:AndroidSharingPlatform,代码行数:50,代码来源:IdeaListFragment.java


注:本文中的com.avos.avoscloud.AVQuery.setCachePolicy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。