private void performSearch(String keyWords) {
   navi.setSearchViewText(keyWords);
   if (!Utils.isNull(keyWords)) {
     showWaitDialog("正在搜索...", true);
     Utils.hideInputManager(SearchOnlineMusicActivity.this);
     new MusicNetwork2(this, REQUEST_SEARCH_MUSIC).searchOnlineMusic(keyWords);
   }
 }
  @SuppressWarnings("unchecked")
  @Override
  public void networkCallback(Object jsonResult, int httpCode, int requestTag) {
    if (mActivity == null) return;
    JsonData<ListJsonData> jResult = (JsonData<ListJsonData>) jsonResult;

    if (httpCode == HttpStatus.SC_FORBIDDEN) {
      ((AppApplication) mActivity.getApplication()).userNotLogin();
      return;
    }

    if (httpCode != HttpStatus.SC_OK) {
      Log.e("Volley", "HTTP Code " + httpCode + " catched in callback!!");
      String toastString;
      if (httpCode == HttpStatus.SC_CONFLICT) {
        toastString = mActivity.getString(R.string.parse_data_failed);
      } else if (httpCode == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
        toastString = getString(R.string.error_occur_retry_later);
      } else toastString = mActivity.getString(R.string.connect_to_server_failed);
      ToastTools.toastWithFrequencyLimited(mActivity, toastString, Toast.LENGTH_SHORT, true);
      return;
    }
    Log.d("Volley", "JsonData apiVersion: " + jResult.getApiVersion());

    if (jResult.getCode() != Constants.CODE_SUCCESS) {
      Log.e("Volley", jResult.getMessage() == null ? "" : jResult.getMessage());
      ToastTools.toastWithFrequencyLimited(
          mActivity, jResult.getMessage(), Toast.LENGTH_SHORT, true);
      return;
    }

    if (jResult.getData().size() == 0) {
      isNoMorePosts = true;
      //		ToastTools.toast(getActivity(), getString(R.string.no_more_message_notice),
      // Toast.LENGTH_SHORT).show();
      return;
    }

    if (requestTag == REQUEST_LATEST_COMMENTED_AND_LIKES) {
      List<PostMessage> msgs = jResult.getData().getPostMsgList();
      mMsgAdapter.clearAllComments();

      if (!Utils.isListEmpty(msgs)) msgPosts.addAll(msgs);
      handleMsgPost();
    } else if (requestTag == REQUEST_PREVIOUS_COMMENTED_AND_LIKES) {
      List<PostMessage> msgs = jResult.getData().getPostMsgList();
      if (!Utils.isListEmpty(msgs)) msgPosts.addAll(msgs);

      handleMsgPost();
    }
  }
  private void handleMsgPost() {
    if (Utils.isListEmpty(msgPosts)) return;

    //		Collections.sort(msgPosts, mComparator);

    nextPage++;

    mMsgAdapter.appendPostsToTail(msgPosts);

    showMoreCachedResultsFromAdapter();
    // the server may return less than required item
    //		if (msgPosts.size() < Constants.MESSAGE_REQUEST_NUM_FROM_INTERNET) isNoMorePosts = true;
  }
  @SuppressWarnings("unchecked")
  @Override
  public void networkCallback(Object jsonResult, int httpCode, int requestTag) {
    JsonData<ListJsonData> jResult = (JsonData<ListJsonData>) jsonResult;

    dismissWaitDialog();
    if (httpCode == HttpStatus.SC_FORBIDDEN) {
      ((AppApplication) getApplication()).userNotLogin();
      return;
    }

    if (httpCode != HttpStatus.SC_OK) {
      Log.e("Volley", "HTTP Code " + httpCode + " catched in callback!!");
      String toastString;
      if (httpCode == HttpStatus.SC_CONFLICT) {
        toastString = getString(R.string.parse_data_failed);
      } else if (httpCode == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
        toastString = getString(R.string.error_occur_retry_later);
      } else toastString = getString(R.string.connect_to_server_failed);
      ToastTools.toastWithFrequencyLimited(
          SearchOnlineMusicActivity.this, toastString, Toast.LENGTH_SHORT, true);
      return;
    }

    if (jResult.getCode() != Constants.CODE_SUCCESS) {
      Log.e("Volley", jResult.getMessage() == null ? "" : jResult.getMessage());
      ToastTools.toastWithFrequencyLimited(
          SearchOnlineMusicActivity.this, jResult.getMessage(), Toast.LENGTH_SHORT, true);
      return;
    }

    if (requestTag == REQUEST_SEARCH_MUSIC) {
      List<Music> musics = jResult.getData().getMusicList();

      mChooseMusicLocalAdapter =
          new ChooseMusicOnlineAdapter(SearchOnlineMusicActivity.this, musics);
      mChooseMusicLocalAdapter.setMusicListener(this);
      mListView.setAdapter(mChooseMusicLocalAdapter);
      if (!Utils.isListEmpty(musics)) {
        noMusicLayout.setVisibility(View.GONE);
        mListView.setVisibility(View.VISIBLE);
      } else {
        noMusicLayout.setVisibility(View.VISIBLE);
      }

      mListView.requestFocus();
    } else if (requestTag == REQUEST_GET_REMOTE_MUSIC_URL) {
      Log.d("MusicUrl", jResult.getData().getMusicList().get(0).getMusicUrl());
    }
  }
  private void init() {
    navi.setSearchViewVisible(true);
    navi.setBackTvVisible("", false);
    navi.setBackBtnParamers();
    navi.setSearchViewLeftBg(R.drawable.search_button_icon);
    navi.setSearchViewHintText(R.string.search_you_like_music);
    navi.setOnEditorActionListener(
        new OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
              inputKeyword = mSearchEt.getText().toString().trim();

              performSearch(inputKeyword);
            }
            return false;
          }
        });

    mListView = (ListView) findViewById(R.id.fragment_choose_music_onlie_search_result_lv);
    startSearchTv = (TextView) findViewById(R.id.fragment_choose_music_online_search);
    noMusicLayout = (RelativeLayout) findViewById(R.id.no_music_resource);

    hotMusicLayout = (LinearLayout) findViewById(R.id.search_tags);
    hotMusicLayout.setVisibility(View.GONE);

    mChooseMusicLocalAdapter = new ChooseMusicOnlineAdapter(this, null);
    mChooseMusicLocalAdapter.setMusicListener(this);
    mListView.setAdapter(mChooseMusicLocalAdapter);

    startSearchTv.setOnClickListener(this);

    inputKeyword = getIntent().getStringExtra("keyword");
    if (Utils.isNull(inputKeyword) == false) {
      navi.setSearchViewText(inputKeyword);
      performSearch(inputKeyword);
    }

    footerView = View.inflate(this, R.layout.listview_footer, null);
    TextView textView = (TextView) footerView.findViewById(R.id.listview_footer_text);
    textView.setText("没有更多消息了...");
  }
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (Utils.isNetworkConnected(getActivity())) {
      Intent intent = new Intent(getActivity(), PostDetailActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      if (position < 0) {
        return;
      }

      if (view == footerView) {
        return;
      }

      PostMessage post = (PostMessage) parent.getAdapter().getItem(position);
      intent.putExtra("postId", post.getPostId());
      intent.putExtra("requestFrom", getPageName());
      intent.putExtra("l1DestFloor", post.getPostMsgFloorNum());
      startActivity(intent);
    } else {
      ToastTools.toast(getActivity(), "请先连接网络喵~", Toast.LENGTH_SHORT, true);
    }
  }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   isUserAVisitor = Utils.isUserAVisitor(getActivity());
   user = ((AppApplication) getActivity().getApplication()).getUserInfo();
 }