public void refreshNumber(
      Answer contract, final TextView answer_number, final int color, final ImageView like_answer) {
    BmobQuery<User> query = new BmobQuery<User>();
    Answer ans = new Answer();
    ans.setObjectId(contract.getObjectId());
    // likes是Post表中的字段,用来存储所有喜欢该帖子的用户
    query.addWhereRelatedTo("likedBy", new BmobPointer(ans));
    query.count(
        context,
        User.class,
        new CountListener() {
          @Override
          public void onSuccess(int count) {
            answer_number.setText(count + "");
            like_answer.setBackgroundResource(color);
            // TODO Auto-generated method stub
            // ShowToast("Barbie has played" + count + "games");
          }

          @Override
          public void onFailure(int code, String msg) {
            // TODO Auto-generated method stub
            // ShowToast("count failure:"+msg);
            ShowToast("亲,断网了呢");
          }
        });
  }
  private void loadDataByNet() {
    BmobQuery<Content> query = new BmobQuery<>();
    query.getObject(
        DetailActivity.this,
        mContent.getObjectId(),
        new GetListener<Content>() {
          @Override
          public void onSuccess(Content content) {
            setData(content);
            // 把数据缓存到本地
            SaveCacheAsyncTask savecaheTask =
                new SaveCacheAsyncTask(
                    DetailActivity.this,
                    content,
                    CacheHelper.CONTENT_CACHE_KEY + mContent.getObjectId());
            savecaheTask.execute();
            mLoadingLayout.setLoadingLayout(LoadingLayout.HIDE_LAYOUT);
            mScrollViewEx.setVisibility(View.VISIBLE);
          }

          @Override
          public void onFailure(int i, String s) {
            if (mLoadingLayout.getState() == LoadingLayout.STATE_REFRESH) {
              mLoadingLayout.setLoadingLayout(LoadingLayout.NETWORK_ERROR);
            }
          }
        });
  }
  private void init() {
    BmobQuery<Task> task = new BmobQuery<Task>();
    String username = "******";
    task.addWhereContains("executor", username);
    task.findObjects(
        this,
        new FindListener<Task>() {
          @Override
          public void onSuccess(List<Task> tasks) {

            PlanListActivity.this.pd.dismiss();
            Toast.makeText(PlanListActivity.this, "查找成功", Toast.LENGTH_SHORT).show();
            if (tasks == null || tasks.size() == 0) {
              startActivity(new Intent(PlanListActivity.this, PlanActivity.class));
            } else {
              PlanListActivity.this.mTask = tasks.get(0);
              loadTask(PlanListActivity.this.mTask);
            }
          }

          @Override
          public void onError(int i, String s) {
            PlanListActivity.this.pd.dismiss();
            startActivity(new Intent(PlanListActivity.this, PlanActivity.class));
            Toast.makeText(PlanListActivity.this, "查找失败" + s, Toast.LENGTH_SHORT).show();
          }
        });
  }
  private void querydata() {
    BmobQuery<NewsdalyComment> query = new BmobQuery<NewsdalyComment>();
    DalyNews dalyNews = new DalyNews();
    String i = getIntent().getStringExtra("id");
    dalyNews.setObjectId(i);
    query.addWhereEqualTo("dalyNews", new BmobPointer(dalyNews));
    query.findObjects(
        this,
        new FindListener<NewsdalyComment>() {

          @Override
          public void onSuccess(List<NewsdalyComment> object) {
            // TODO Auto-generated method stub
            for (NewsdalyComment content : object) {
              String c = content.getComment();
              String name = content.getCommentname();
              TextView tx = new TextView(NewsDaylyActivity.this);
              tx.setTextSize(15);
              tx.setText("用户:" + name + "\n" + c);
              layout_content.addView(tx);
            }
          }

          @Override
          public void onError(int arg0, String arg1) {
            // TODO Auto-generated method stub
            Toast.makeText(NewsDaylyActivity.this, "服务器暂未响应!", Toast.LENGTH_SHORT).show();
          }
        });
  }
  // 聊天对话框显示
  private void identityJudge() {
    BmobQuery<MyUser> query = new BmobQuery<MyUser>();
    // 判断是否有缓存,该方法必须放在查询条件(如果有的话)都设置完之后再来调用才有效,就像这里一样。
    //        boolean isCache = query.hasCachedResult(mycontext, MyUser.class);
    //        if (isCache) {
    //            query.setCachePolicy(BmobQuery.CachePolicy.CACHE_ELSE_NETWORK);    //
    // 如果有缓存的话,则设置策略为CACHE_ELSE_NETWORK
    //        } else {
    //            query.setCachePolicy(BmobQuery.CachePolicy.NETWORK_ELSE_CACHE);    //
    // 如果没有缓存的话,则设置策略为NETWORK_ELSE_CACHE
    //        }
    query.getObject(
        mycontext,
        BmobUser.getCurrentUser(mycontext).getObjectId(),
        new GetListener<MyUser>() {

          @Override
          public void onSuccess(MyUser object) {
            // TODO Auto-generated method stub
            if (object.getType().equals("2")) {
              container_tochat.setVisibility(View.VISIBLE);
              btn_beaugur.setVisibility(View.GONE);
            } else {
              container_tochat.setVisibility(View.GONE);
              //                    btn_beaugur.setVisibility(View.VISIBLE);
            }
          }

          @Override
          public void onFailure(int code, String arg0) {}
        });
  }
  /**
   * 关注路线
   *
   * @param route 路线
   * @param listener 回调监听
   */
  public void followRoute(final Route route, final OnRouteListener listener) {
    User user = UserManager.getInstance(mContext).getUser();
    BmobQuery<Route> query = new BmobQuery<>();
    query.addWhereRelatedTo("followRoutes", new BmobPointer(user));
    query.findObjects(
        mContext,
        new FindListener<Route>() {
          @Override
          public void onSuccess(final List<Route> list) {
            int i = 0;
            for (; i < list.size(); i++) {
              if (route.getObjectId().equals(list.get(i).getObjectId())) {
                break;
              }
            }
            if (i == list.size()) {
              UserManager.getInstance(mContext)
                  .addFollowRoute(
                      route,
                      new UserManager.OnUpdateListener() {
                        @Override
                        public void onSuccess() {
                          int followNum = 0;
                          if (route.getFollowNum() != null) followNum = route.getFollowNum();
                          followNum++;
                          route.setFollowNum(followNum);
                          route.update(
                              mContext,
                              route.getObjectId(),
                              new UpdateListener() {
                                @Override
                                public void onSuccess() {
                                  listener.onSuccess(null);
                                }

                                @Override
                                public void onFailure(int i, String s) {
                                  listener.onError(s);
                                }
                              });
                        }

                        @Override
                        public void onError() {
                          listener.onError(null);
                        }
                      });
            } else {
              listener.onError("您已经关注了该路线");
            }
          }

          @Override
          public void onError(int i, String s) {}
        });
  }
  // 查询符合时间和用户id条件的记录
  public void getData(
      int year_c, int month_c, int jumpYear, int jumpMonth, final Handler handler, String id) {

    String dateString =
        String.valueOf(year_c + jumpYear)
            .concat("-")
            .concat(String.valueOf(month_c + jumpMonth))
            .concat("-")
            .concat("31");
    String dateString2 =
        String.valueOf(year_c + jumpYear)
            .concat("-")
            .concat(String.valueOf(month_c + jumpMonth))
            .concat("-")
            .concat("01");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date date1 = null;
    Date date2 = null;
    try {
      date1 = sdf.parse(dateString);
      date2 = sdf.parse(dateString2);
    } catch (ParseException e) {
    }

    BmobQuery<Sign> my_sign = new BmobQuery<Sign>();
    my_sign.addWhereLessThanOrEqualTo("createdAt", new BmobDate(date1));

    BmobQuery<Sign> my_sign2 = new BmobQuery<Sign>();
    my_sign2.addWhereGreaterThanOrEqualTo("createdAt", new BmobDate(date2));

    BmobQuery<Sign> my_sign3 = new BmobQuery<Sign>();
    my_sign3.addWhereEqualTo("user_id", id);

    List<BmobQuery<Sign>> andQuerys = new ArrayList<BmobQuery<Sign>>();
    andQuerys.add(my_sign);
    andQuerys.add(my_sign2);
    andQuerys.add(my_sign3);

    BmobQuery<Sign> sign = new BmobQuery<Sign>();
    sign.and(andQuerys);
    sign.findObjects(
        this.mContext,
        new FindListener<Sign>() {
          @Override
          public void onSuccess(List<Sign> list) {

            Message message = handler.obtainMessage();
            message.what = 1;
            message.obj = list;
            handler.sendMessage(message);
          }

          @Override
          public void onError(int i, String s) {}
        });
  }
  /**
   * 复制景点
   *
   * @param myDailys 日程列表
   * @param dailys 日程列表
   * @param current 当前位置
   * @param listener 回调
   */
  private void copySight(
      final List<Daily> myDailys,
      final List<Daily> dailys,
      final int current,
      final OnRouteListener listener) {
    BmobQuery<Sight> query = new BmobQuery<>();
    query.addWhereEqualTo("daily", new BmobPointer(dailys.get(current)));
    query.order("index");
    query.findObjects(
        mContext,
        new FindListener<Sight>() {
          @Override
          public void onSuccess(List<Sight> list) {
            List<BmobObject> sights = new ArrayList<>();
            Sight sight;
            for (int i = 0; i < list.size(); i++) {
              sight = new Sight();
              sight.setDaily(myDailys.get(current));
              sight.setName(list.get(i).getName());
              sight.setAddress(list.get(i).getAddress());
              sight.setLongitude(list.get(i).getLongitude());
              sight.setLatitude(list.get(i).getLatitude());
              sight.setDetailUrl(list.get(i).getDetailUrl());
              sight.setUid(list.get(i).getUid());
              sight.setIndex(list.get(i).getIndex());
              sights.add(sight);
            }
            new BmobObject()
                .insertBatch(
                    mContext,
                    sights,
                    new SaveListener() {
                      @Override
                      public void onSuccess() {}

                      @Override
                      public void onFailure(int i, String s) {}
                    });
            if (current + 1 != myDailys.size()) {
              copySight(myDailys, dailys, current + 1, listener);
            } else {
              listener.onSuccess(null);
            }
          }

          @Override
          public void onError(int i, String s) {
            listener.onError(s);
          }
        });
  }
  private void initData() {
    if (null != objectId) {
      BmobQuery<BUser> query = new BmobQuery<>();
      query.getObject(
          this,
          objectId,
          new GetListener<BUser>() {
            @Override
            public void onSuccess(BUser bUser) {
              if (bUser != null) {

                bundle = new Bundle();
                bundle.putSerializable("bUser", bUser);

                if (TextUtils.isEmpty(bUser.getFigureurl())) {
                  ImageLoader.getInstance()
                      .displayImage(
                          bUser.getUserPhoto().getFileUrl(UserInfoActivity.this), iv_userphoto);
                } else {
                  ImageLoader.getInstance().displayImage(bUser.getFigureurl(), iv_userphoto);
                }

                tv_nick.setText(bUser.getNick());
                tv_nick.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/test.ttf"));
                tv_depart.setText(bUser.getDepart());
                tv_depart.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/test.ttf"));

                if (!TextUtils.isEmpty(bUser.getEmail())) {
                  tv_email.setText(bUser.getEmail());
                } else {
                  tv_email.setText("请完善邮箱信息");
                }

                if (!TextUtils.isEmpty(bUser.getMobilePhoneNumber())) {
                  tv_tel.setText(bUser.getMobilePhoneNumber());
                } else {
                  tv_tel.setText("请完善手机号信息");
                }
                tv_name.setText(bUser.getUsername());
              }
            }

            @Override
            public void onFailure(int i, String s) {}
          });
    }
  }
  private void initData() {
    BmobQuery<Transaction> query = new BmobQuery<Transaction>();
    query.addWhereEqualTo("hasdeal", false);
    query.findObjects(
        this,
        new FindListener<Transaction>() {
          @Override
          public void onSuccess(List<Transaction> list) {
            updateView(list);
          }

          @Override
          public void onError(int i, String s) {
            Toast.makeText(NewTransactionActivity.this, s.toString(), Toast.LENGTH_SHORT).show();
          }
        });
  }
  /** 根据用户名查询用户的其他信息 */
  void queryUserInfomation() {
    queryUser = new BmobQuery<>();
    query.addWhereEqualTo("username", MyApplication.getCurrentName());
    queryUser.findObjects(
        view.getContext(),
        new FindListener<User>() {
          @Override
          public void onSuccess(List<User> list) {
            headPictureUrl = list.get(0).getPicture().getFileUrl(view.getContext());

            new LoadUserTask().execute();
          }

          @Override
          public void onError(int i, String s) {}
        });
  }
  private void getData() {
    BmobQuery<Message> query = new BmobQuery<Message>();
    if (TYPE_CHANNEL.equals(currentitemType)) {
      query.addWhereEqualTo(CHANNEL_NAME, currentItemName);
    } else {
      query.addWhereEqualTo(PUSHER_NAME, currentItemName);
    }
    query.addWhereEqualTo("isActivity", false);
    query.order("-createdAt");
    // query.setCachePolicy(BmobQuery.CachePolicy.CACHE_ELSE_NETWORK);    // 先从缓存获取数据,如果没有,再从网络获取。
    query.setLimit(50);
    query.findObjects(
        AppData.getContext(),
        new FindListener<Message>() {
          @Override
          public void onSuccess(List<Message> list) {
            if (list.size() != 0) {
              index_messageList = list;
              freshListView();
            } else {
              Logger.d("频道无信息");
            }
            endRefreshAnimation();
          }

          @Override
          public void onError(int i, String s) {
            // Logger.e("查询失败:" + s);
          }
        });
  }
  /**
   * 添加路线
   *
   * @param route 路线
   * @param listener 回调
   */
  public void addRoute(final Route route, final OnRouteListener listener) {
    BmobQuery<Route> query1 = new BmobQuery<>();
    query1.addWhereEqualTo("name", route.getName());
    BmobQuery<Route> query2 = new BmobQuery<>();
    query2.addWhereEqualTo("creator", UserManager.getInstance(mContext).getUser());
    List<BmobQuery<Route>> andQuerys = new ArrayList<>();
    andQuerys.add(query1);
    andQuerys.add(query2);

    BmobQuery<Route> mainQuery = new BmobQuery<>();
    mainQuery.and(andQuerys);
    mainQuery.findObjects(
        mContext,
        new FindListener<Route>() {
          @Override
          public void onSuccess(List<Route> list) {
            if (list.size() > 0) {
              listener.onError(null);
            } else {
              saveRoute(route, listener);
            }
          }

          @Override
          public void onError(int i, String s) {
            listener.onError(null);
          }
        });
  }
  private void loadData() {
    // data.clear();
    isLoading = true;
    BmobQuery<CommunityItem> query = new BmobQuery<CommunityItem>();
    // query.addWhereEqualTo("CommunityItem", "");
    BmobDate date = new BmobDate(new Date(System.currentTimeMillis()));
    query.addWhereLessThan("createdAt", date);
    query.order("-createdAt");
    query.include("author");
    // 返回50条数据,如果不加上这条语句,默认返回10条数据
    query.setLimit(Constant.NUMBERS_PER_PAGE);
    query.setSkip(Constant.NUMBERS_PER_PAGE * (pageNum++));
    // 执行查询方法
    query.findObjects(
        getContext(),
        new FindListener<CommunityItem>() {
          @Override
          public void onSuccess(List<CommunityItem> list) {
            LogUtil.d(LogUtil.TAG, "onSuccess list size--> " + list.size());
            if (list.size() != 0 && list.get(list.size() - 1) != null) {
              if (isCleared == false) {
                data.clear();
                isCleared = true;
              }
              if (list.size() < Constant.NUMBERS_PER_PAGE) {
                isAllLoaded = true;
                // ToastUtil.show(getContext(), "已加载完所有数据~");
              }
              data.addAll(list);
              putImgData(data);
              mImageLoader.setImgUrls(imgUrls);
              mImageLoader.setAvatarImgUrls(imgUrlsAvatar);
              if (BmobUtil.getCurrentUser(getContext()) != null) {
                data = DatabaseManager.getInstance(getContext()).setFav(data);
              }
              communityListAdapter.setData(data);
              mListView.setOnScrollListener(myScrollListener);
            } else {
              isAllLoaded = true;
              // ToastUtil.show(getContext(), "暂无更多数据~");
              if (list.size() == 0 && data.size() == 0) {
                pageNum--;
                return;
              }
              pageNum--;
            }
            swipeView.setRefreshing(false);
            progressBar.setVisibility(View.GONE);
            isLoading = false;
          }

          @Override
          public void onError(int code, String msg) {
            LogUtil.d(LogUtil.TAG, "onError --> msg -->" + msg + " code -->" + code);
            pageNum--;
            swipeView.setRefreshing(false);
            isLoading = false;
          }
        });
  }
Beispiel #15
0
  public void serachDate() {
    // 查找Person表里面id为6b6c11c537的数据
    BmobQuery<Person> bmobQuery = new BmobQuery<Person>();
    bmobQuery.getObject(
        this,
        "f36c5e3a36",
        new GetListener<Person>() {
          @Override
          public void onSuccess(Person object) {
            ToastUtils.setToastLong(MainActivity.this, "查询成功" + object.getName());
          }

          @Override
          public void onFailure(int code, String msg) {
            ToastUtils.setToastLong(MainActivity.this, "查询失败:" + msg);
          }
        });
  }
Beispiel #16
0
  /** 查询出所有赞了的人 */
  public void queryAllPrasieUsers() {
    BmobQuery<User> query = new BmobQuery<User>();
    // likes是Post表中的字段,用来存储所有喜欢该帖子的用户
    query.addWhereRelatedTo("likes", new BmobPointer(post));
    query.findObjects(
        context,
        new FindListener<User>() {
          @Override
          public void onSuccess(List<User> object) {
            for (User user : object) {
              Log.i(TAG, "user=" + user.getObjectId());
            }
            praiseUsers = object;
          }

          @Override
          public void onError(int code, String msg) {}
        });
  }
  // 获取评论
  private void getComment() {
    BmobQuery<Comment> query = new BmobQuery<Comment>();
    query.addWhereRelatedTo("comment", new BmobPointer(good));
    query.include("user,touser");
    query.order("-createdAt");
    query.findObjects(
        getApplicationContext(),
        new FindListener<Comment>() {

          @Override
          public void onSuccess(List<Comment> list) {
            data.addAll(list);
            adapter.notifyDataSetChanged();
          }

          @Override
          public void onError(int arg0, String arg1) {}
        });
  }
  public void submit(View v) {
    String sno = msno.getText().toString();
    final String password = mpassword.getText().toString();

    if (sno.equals("") || password.equals("")) {
      return;
    }

    String bql = "select password from Student where sNo =? "; // ²éѯËùÓеÄÓÎÏ·µÃ·Ö¼Ç¼
    BmobQuery<Student> query = new BmobQuery<Student>();
    query.setSQL(bql);
    query.setPreparedParams(new Object[] {sno});
    query.doSQLQuery(
        LoginActivity.this,
        new SQLQueryListener<Student>() {

          @Override
          public void done(BmobQueryResult<Student> result, BmobException e) {
            if (e == null) {
              List<Student> list = result.getResults();
              if (list != null && list.size() > 0) {
                for (Student s : list) {
                  System.out.println(s.toString());
                  //							toast(s.toString());
                  if (password.equals(s.getPassword())) {
                    toast("µÇ½³É¹¦");
                  } else {
                    toast("ÕʺŻòÃÜÂë´íÎó");
                  }
                }
              } else {
                toast("ÕʺŲ»´æÔÚ");
                Log.i("smile", "²éѯ³É¹¦£¬ÎÞÊý¾Ý·µ»Ø");
              }
            } else {
              toast("´íÎóÂ룺" + e.getErrorCode() + "£¬´íÎóÃèÊö£º" + e.getMessage());
              System.out.println("´íÎóÂ룺" + e.getErrorCode() + "£¬´íÎóÃèÊö£º" + e.getMessage());
              Log.i("smile", "´íÎóÂ룺" + e.getErrorCode() + "£¬´íÎóÃèÊö£º" + e.getMessage());
            }
          }
        });
  }
Beispiel #19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dstu);
    imageview = (ImageView) findViewById(R.id.stuimage);
    stuname = (TextView) findViewById(R.id.stuname);
    stusex = (TextView) findViewById(R.id.stusex);
    stuphone = (TextView) findViewById(R.id.stuphone);
    stuaddress = (TextView) findViewById(R.id.stuaddress);
    sturole = (TextView) findViewById(R.id.sturole);
    stuintro = (TextView) findViewById(R.id.stuintro);
    stuid = (TextView) findViewById(R.id.stuid);
    Intent intent = getIntent();
    String id = intent.getStringExtra("id");
    BmobQuery<Student> query = new BmobQuery<Student>();
    query.getObject(
        DstuActivity.this,
        id,
        new GetListener<Student>() {
          @Override
          public void onFailure(int arg0, String arg1) {
            // 班级中没有该学生
          }

          @Override
          public void onSuccess(Student arg0) {
            if (arg0.getIcon() != null) {
              // 下载头像
              arg0.getIcon().loadImage(DstuActivity.this, imageview);
            }
            // 加载基本信息
            stuname.setText("姓名:" + arg0.getUsername());
            String sex = arg0.isSex() ? "男" : "女";
            stusex.setText("性别:" + sex);
            stuid.setText("学号:" + arg0.getStudentId());
            stuaddress.setText("籍贯:" + arg0.getAddress());
            stuphone.setText(arg0.getPhone());
            stuintro.setText("个人简介:\n" + arg0.getIntro());
            sturole.setText("角色:" + (arg0.getRole() == 0 ? "普通用户" : "管理员"));
          }
        });
  }
Beispiel #20
0
  @Override
  public void initData(Bundle savedInstanceState) {
    super.initData(savedInstanceState);
    setPageName("周边");
    setActionBarName("周边的小伙伴");
    initMap();
    gqzBitmap = BitmapHelp.getBitmapUtils(this);
    user = BmobUser.getCurrentUser(this, BUser.class);
    if (user != null) {
      BmobQuery<BUser> bmobQuery = new BmobQuery<BUser>();
      bmobQuery.addWhereNear("gpsAdd", user.getGpsAdd());
      bmobQuery.setLimit(10); // 获取最接近用户地点的10条数据
      bmobQuery.findObjects(
          this,
          new FindListener<BUser>() {

            @Override
            public void onSuccess(List<BUser> lists) {
              users = lists;
              imgs = new ArrayList<RoundedCornerImageView>();
              for (int i = 0; i < lists.size(); i++) {
                RoundedCornerImageView imageView = new RoundedCornerImageView(getBaseContext());
                imageView.setLayoutParams(new LayoutParams(80, 80));
                gqzBitmap.display(imageView, users.get(i).getUrl_head());
                imgs.add(imageView);
              }
              MapUtil.startLocation();
            }

            @Override
            public void onError(int arg0, String arg1) {
              GQZInject.toast(arg1);
            }
          });
    } else {
      map.setMyLocationEnabled(true); // 关闭定位图层
      MapUtil.startLocation();
      GQZInject.toast("请先登录");
    }
  }
  private void loaddate() {
    isLoading = true;
    MyUser myUser = BmobUser.getCurrentUser(MessageActivity.this, MyUser.class);
    BmobQuery<ReplyBean> Query = new BmobQuery<ReplyBean>();
    Query.order("-createdAt");
    Query.setSkip(page);
    Query.addWhereEqualTo("userid", new BmobPointer(myUser));
    Query.include("userid,replyid,detailsid");
    Query.findObjects(
        MessageActivity.this,
        new FindListener<ReplyBean>() {
          @Override
          public void onSuccess(List<ReplyBean> object) {
            replyBeans.addAll(object);
            if (object.size() == endpage) {
              page = page + endpage;
            } else {
              flag = false;
            }
            messageAdapter.notifyDataSetChanged();
            isLoading = false;
          }

          @Override
          public void onError(int code, String msg) {
            // TODO Auto-generated method stub
            ErrorReport.RrrorCode(code, MessageActivity.this);
            isLoading = false;
          }
        });
  }
  private void initdata() {
    isLoading = true;
    MyUser myUser = BmobUser.getCurrentUser(MessageActivity.this, MyUser.class);
    BmobQuery<ReplyBean> reply = new BmobQuery<>();
    reply.setLimit(endpage);
    reply.order("-createdAt");
    reply.addWhereEqualTo("userid", new BmobPointer(myUser));
    reply.include("userid,replyid,detailsid");
    reply.findObjects(
        MessageActivity.this,
        new FindListener<ReplyBean>() {
          @Override
          public void onSuccess(List<ReplyBean> list) {

            replyBeans.clear();
            replyBeans.addAll(list);
            messageAdapter.notifyDataSetChanged();
            swipeLayout.setRefreshing(false);
            isLoading = false;
          }

          @Override
          public void onError(int i, String s) {
            ErrorReport.RrrorCode(i, MessageActivity.this);
            swipeLayout.setRefreshing(false);
            isLoading = false;
          }
        });
  }
  /**
   * 路线收藏
   *
   * @param route 路线
   * @param listener 回调
   */
  public void collect(final Route route, final OnRouteListener listener) {
    User user = UserManager.getInstance(mContext).getUser();
    BmobQuery<Route> query = new BmobQuery<>();
    query.addWhereRelatedTo("collectRoutes", new BmobPointer(user));
    query.findObjects(
        mContext,
        new FindListener<Route>() {
          @Override
          public void onSuccess(final List<Route> list) {
            int i = 0;
            for (; i < list.size(); i++) {
              if (route.getObjectId().equals(list.get(i).getObjectId())) {
                break;
              }
            }
            if (i == list.size()) {
              UserManager.getInstance(mContext)
                  .addCollectRoute(
                      route,
                      new UserManager.OnUpdateListener() {
                        @Override
                        public void onSuccess() {
                          listener.onSuccess(null);
                        }

                        @Override
                        public void onError() {
                          listener.onError(null);
                        }
                      });
            } else {
              listener.onError("您已经收藏了该路线");
            }
          }

          @Override
          public void onError(int i, String s) {}
        });
  }
  /** 判断记录是否为空并且查询数据 */
  void judgeAndquery() {
    query = new BmobQuery<DemandObject>();
    al = new ArrayList<>();
    query.addWhereEqualTo("publishMan", MyApplication.getCurrentName());
    query.count(
        view.getContext(),
        DemandObject.class,
        new CountListener() {
          @Override
          public void onSuccess(int i) {
            if (i > 0) {
              querydata();
            } else {
              progressDialog.dismiss();
              Toast.makeText(view.getContext(), "你还没有捐赠物品,赶紧去捐赠物品吧☺", Toast.LENGTH_LONG).show();
              swipeLayout.setRefreshing(false);
            }
          }

          @Override
          public void onFailure(int i, String s) {}
        });
  }
  private void judgeAugur() {
    BmobQuery<MyUser> query = new BmobQuery<MyUser>();
    query.setCachePolicy(BmobQuery.CachePolicy.CACHE_THEN_NETWORK);
    query.getObject(
        mycontext,
        BmobUser.getCurrentUser(mycontext).getObjectId(),
        new GetListener<MyUser>() {

          @Override
          public void onSuccess(MyUser object) {
            // TODO Auto-generated method stub
            if (object.getType().equals("2")) {
              // 不能重复申请成为大师
              mycontext.toast("您已经是大师,不能重复申请");
              Log.e("datas", "MeFragment 判断type" + object.getType());
              btn_beaugur.setClickable(false);
            }
          }

          @Override
          public void onFailure(int code, String arg0) {}
        });
    initDatas();
  }
  public void queryAll(View view) {
    BmobQuery<Student> query = new BmobQuery<Student>();

    query.findObjects(
        LoginActivity.this,
        new FindListener<Student>() {

          @Override
          public void onSuccess(List<Student> feedbacks) {
            AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
            builder.setTitle("Query");
            String str = "";

            for (Student feedback : feedbacks) {
              str += feedback.getsNo() + ":" + feedback.getPassword() + "\n";
            }
            builder.setMessage(str);
            builder.create().show();
          }

          @Override
          public void onError(int arg0, String arg1) {}
        });
  }
  void querydata() {
    query.findObjects(
        view.getContext(),
        new FindListener<DemandObject>() {
          @Override
          public void onSuccess(List<DemandObject> list) {
            for (DemandObject demandObject : list) {
              HashMap<String, Object> map = new HashMap<String, Object>();
              map.put("goodname", demandObject.getGoodName());
              // map.put("picture",demandObject.getHeadPicture());
              map.put("descreption", demandObject.getDescreption());
              map.put("time", dealTime(demandObject.getCreatedAt()));

              al.add(map);
            }

            new LoadDemands().execute();
          }

          @Override
          public void onError(int i, String s) {}
        });
  }
  // 从网络中抓取数据,更新UI
  private void updateFromNet() {
    // 查询多条数据
    BmobQuery<Augur> query = new BmobQuery<Augur>();
    datas = new ArrayList<>();
    query.include("augur_pointer");
    // 判断是否有缓存,该方法必须放在查询条件(如果有的话)都设置完之后再来调用才有效,就像这里一样。
    boolean isCache = query.hasCachedResult(mycontext, Augur.class);
    if (isCache) {
      query.setCachePolicy(
          BmobQuery.CachePolicy.CACHE_ELSE_NETWORK); // 如果有缓存的话,则设置策略为CACHE_ELSE_NETWORK
    } else {
      query.setCachePolicy(
          BmobQuery.CachePolicy.NETWORK_ELSE_CACHE); // 如果没有缓存的话,则设置策略为NETWORK_ELSE_CACHE
    }
    query.findObjects(
        mycontext,
        new FindListener<Augur>() {
          @Override
          public void onSuccess(List<Augur> object) {
            // TODO Auto-generated method stub
            for (Augur augurbean : object) {
              datas.add(augurbean);
            }
            mAdapter.setMdatas(datas);
            mHandler.sendEmptyMessage(0);
            mSwipeLayout.setRefreshing(false);
          }

          @Override
          public void onError(int code, String msg) {
            // TODO Auto-generated method stub
            mHandler.sendEmptyMessage(0);
            if (mSwipeLayout != null) mSwipeLayout.setRefreshing(false);
          }
        });
  }
  public void refreshData(String keyWord) {
    mSearchedChannelAdapter.clear();
    if (isSearchingName || isSearchingInfo || StrUtil.isEmpty(keyWord)) {
      return;
    }
    // 按频道名搜索
    isSearchingName = true;
    BmobQuery<Channel> channelNameQuery = new BmobQuery<Channel>();
    channelNameQuery.addWhereContains(Channel.NAME_KEY, keyWord);
    channelNameQuery.include(Channel.MANAGER_KEY);
    channelNameQuery.setLimit(10);
    channelNameQuery.order("-" + Channel.IS_ACTIVE_KEY + ",-" + Constants.UPDATED_AT_KEY);
    channelNameQuery.findObjects(
        mContext,
        new FindListener<Channel>() {
          @Override
          public void onSuccess(List<Channel> channels) {
            mSearchedChannelAdapter.addAll(channels);
            isSearchingName = false;
          }

          @Override
          public void onError(int arg0, String msg) {
            ShowToast(getString(R.string.server_query_error_tips) + ": " + msg);
            isSearchingName = false;
          }
        });

    // 按频道信息搜索
    isSearchingInfo = true;
    BmobQuery<Channel> channelInfoQuery = new BmobQuery<Channel>();
    channelInfoQuery.addWhereContains(Channel.INFO_KEY, keyWord);
    channelInfoQuery.include(Channel.MANAGER_KEY);
    channelInfoQuery.setLimit(10);
    channelInfoQuery.order("-" + Channel.IS_ACTIVE_KEY + ",-" + Constants.UPDATED_AT_KEY);
    channelInfoQuery.findObjects(
        mContext,
        new FindListener<Channel>() {
          @Override
          public void onSuccess(List<Channel> channels) {
            for (Channel channel : channels) {
              if (!mSearchedChannelAdapter.contains(channel)) {
                mSearchedChannelAdapter.add(channel);
              }
            }
            isSearchingInfo = false;
          }

          @Override
          public void onError(int arg0, String msg) {
            ShowToast(getString(R.string.server_query_error_tips) + ": " + msg);
            isSearchingInfo = false;
          }
        });
  }
  @Override
  public View bindView(int arg0, View convertView, ViewGroup arg2) {
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.item_friendsstatus, null);
    }

    final String[] islike = new String[1]; // 用来记录是否赞过这条微博
    islike[0] = "false";
    final Blog blog = getList().get(arg0);
    final Context context = convertView.getContext();
    TextView brief = ViewHolder.get(convertView, R.id.edittext);
    TextView time = ViewHolder.get(convertView, R.id.time);
    final TextView name = ViewHolder.get(convertView, R.id.name);
    final TextView num = ViewHolder.get(convertView, R.id.num);
    final RoundImageView head = ViewHolder.get(convertView, R.id.head);
    ImageView photo = ViewHolder.get(convertView, R.id.photo);
    final ImageView like = ViewHolder.get(convertView, R.id.like);
    final User user = BmobUser.getCurrentUser(context, User.class);
    like.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            if (islike[0].equals("false")) {
              // 将当前用户添加到Blog表中的likes字段值中,表明当前用户喜欢该帖子
              BmobRelation relation = new BmobRelation();
              // 将当前用户添加到多对多关联中
              relation.add(user);
              // 多对多关联指向`blog`的`likes`字段
              blog.setLikes(relation);
              blog.update(
                  context,
                  new UpdateListener() {

                    @Override
                    public void onSuccess() {
                      likesnum++;
                      islike[0] = "true";
                      num.setText(likesnum + "");
                    }

                    @Override
                    public void onFailure(int arg0, String arg1) {}
                  });
            } else {
              showTag("你已赞过这条动态!", Effects.standard, R.id.friends_status);
            }
          }
        });

    String photouri = blog.getPhoto().getFileUrl(convertView.getContext());
    if (photouri != null && !photouri.equals("")) {
      ImageLoader.getInstance().displayImage(photouri, photo, ImageLoadOptions.getOptions());
    } else {
      photo.setImageResource(R.drawable.defalutimage);
    }

    // 因为无法直接get到user的头像,所以需要到网络去拿
    String uID = blog.getAuthor().getObjectId();

    BmobQuery<User> query = new BmobQuery<User>();
    query.getObject(
        convertView.getContext(),
        uID,
        new GetListener<User>() {

          @Override
          public void onFailure(int arg0, String arg1) {}

          @Override
          public void onSuccess(User arg0) {
            headuri = arg0.getAvatar();
            if (headuri != null && !headuri.equals("")) {
              ImageLoader.getInstance().displayImage(headuri, head, ImageLoadOptions.getOptions());
            } else {
              head.setImageResource(R.drawable.default_head);
            }
            name.setText(arg0.getUsername());
          }
        });
    // 查询喜欢这个帖子的所有用户,因此查询的是用户表
    BmobQuery<User> query2 = new BmobQuery<User>();
    // likes是Blog表中的字段,用来存储所有喜欢该帖子的用户
    query2.addWhereRelatedTo("likes", new BmobPointer(blog));
    query2.findObjects(
        convertView.getContext(),
        new FindListener<User>() {

          @Override
          public void onSuccess(List<User> object) {
            likesnum = object.size();
            num.setText(likesnum + "");
            for (int i = 0; i < object.size(); i++) {
              if (object.get(i).getObjectId().equals(user.getObjectId())) {
                islike[0] = "true";
                like.setImageResource(R.drawable.youlike);
              }
            }
          }

          @Override
          public void onError(int code, String msg) {}
        });
    brief.setText(blog.getBrief());
    time.setText(blog.getCreatedAt());
    return convertView;
  }