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;
          }
        });
  }
  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;
          }
        });
  }
  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);
          }
        });
  }
  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;
          }
        });
  }
  /**
   * 复制景点
   *
   * @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 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) {}
        });
  }