Ejemplo n.º 1
0
 private void setSelectCourse(int position) {
   selectSubjectName = mSubjectModels.get(position).getSubjectName();
   selectSubjectId = mSubjectModels.get(position).getSubjectId();
   AVQuery<AVUser> mAvQuery = AVUser.getQuery();
   mAvQuery.whereEqualTo(
       "username",
       ShareTools.getInstance().readUserInfo(LoginInitMemory.this).get(ShareTools.USER_NAME));
   mAvQuery.findInBackground(
       new FindCallback<AVUser>() {
         @Override
         public void done(List<AVUser> arg0, AVException arg1) {
           // TODO Auto-generated method stub
           if (arg1 == null) {
             if (arg0 != null && !arg0.isEmpty()) {
               Message message = Message.obtain();
               message.what = 1000;
               message.obj = arg0.get(0);
               mHandler.sendMessage(message);
             } else {
               Toast.makeText(LoginInitMemory.this, "用户为空", Toast.LENGTH_SHORT).show();
             }
           } else {
             Log.e("ShareTools", arg1.getMessage());
           }
         }
       });
 }
Ejemplo n.º 2
0
 public static List<AVUser> searchUser(String searchName, int skip) throws AVException {
   AVQuery<AVUser> q = AVUser.getQuery(AVUser.class);
   q.whereContains(User.USERNAME, searchName);
   q.limit(Constant.PAGE_SIZE);
   q.skip(skip);
   AVUser user = AVUser.getCurrentUser();
   List<String> friendIds = new ArrayList<String>(CacheService.getFriendIds());
   friendIds.add(user.getObjectId());
   q.whereNotContainedIn(Constant.OBJECT_ID, friendIds);
   q.orderByDescending(Constant.UPDATED_AT);
   q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
   List<AVUser> users = q.find();
   CacheService.registerUsers(users);
   return users;
 }
Ejemplo n.º 3
0
 public static AVUser findUser(String id) throws AVException {
   AVQuery<AVUser> q = AVUser.getQuery(AVUser.class);
   q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
   return q.get(id);
 }