/**
  * 控制表情区和软键盘的显示
  *
  * @param isShowKeyboard
  * @param isSwitch
  */
 private void controlKeyboardOrExpr(boolean isShowKeyboard, boolean isSwitch) {
   if (isSwitch) {
     if (!isShowKeyboard) {
       mIsExprShow = true;
       mIsSoftKeyboardShow = false;
       mImm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
       mUiHandler.postDelayed(
           new Runnable() {
             @Override
             public void run() {
               mExpressionWidgt.setVisibility(View.VISIBLE);
             }
           },
           100);
       mExprBtn.setBackgroundResource(R.drawable.selector_s_chat_keyboard);
     } else {
       mIsExprShow = false;
       mIsSoftKeyboardShow = true;
       mExpressionWidgt.setVisibility(View.GONE);
       mExprBtn.setBackgroundResource(R.drawable.selector_s_chat_expressions);
       mImm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
     }
   } else {
     if (isShowKeyboard) {
       mIsExprShow = false;
       mIsSoftKeyboardShow = true;
       mExpressionWidgt.setVisibility(View.GONE);
       mImm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
     } else {
       if (mIsSoftKeyboardShow) {
         mIsSoftKeyboardShow = false;
         mImm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
       } else {
         mIsExprShow = false;
         mExpressionWidgt.setVisibility(View.GONE);
       }
     }
     mExprBtn.setBackgroundResource(R.drawable.selector_s_chat_expressions);
   }
 }
  @Override
  public void onClick(View v) {
    TextView txtManageLabel, txtBrowseLabel, txtRefreshLabel, txtSearchLabel;
    txtManageLabel = (TextView) findViewById(R.id.txt_manage_label);
    txtBrowseLabel = (TextView) findViewById(R.id.txt_browse_label);
    txtRefreshLabel = (TextView) findViewById(R.id.txt_refresh_label);
    txtSearchLabel = (TextView) findViewById(R.id.txt_search_label);
    txtSearch.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            new AsyncTask<String, Void, ArrayList<RssItem>>() {
              @Override
              protected ArrayList<RssItem> doInBackground(String... params) {
                return dbQuery.searchRssItem(params[0]);
              }

              @Override
              protected void onPostExecute(ArrayList<RssItem> result) {
                rssList.clear();
                rssList.addAll(result);
                rssAdapter.config().notifyDataSetChanged();
              }
            }.execute(s.toString());
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {}
        });
    txtSearch.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) return true;
            return false;
          }
        });
    switch (v.getId()) {
      case R.id.btn_manage:
        startActivityForResult(
            new Intent(RssReaderActivity.this, RssManageActivity.class), REQ_RSS_MANAGE);
        break;

      case R.id.btn_browse:
        rssProvider = dbQuery.getRssProviderList(null);
        int length = rssProvider.getProviderNames().length;
        if (length == 0) break;

        String[] providers = new String[length + 1];
        providers[0] = "All";
        for (int i = 0; i < length; i++) providers[i + 1] = rssProvider.getProviderNames()[i];
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder
            .setTitle(R.string.rss_choose_provider)
            .setItems(
                providers,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int item) {
                    if (item == 0) {
                      loadData(null, true, false, false);
                      return;
                    }
                    loadData(rssProvider.getProviderNames()[item - 1], false, false, false);
                    curProvider = item - 1;
                    updateListView();
                  }
                });
        builder.create().show();
        break;

      case R.id.btn_refresh:
        if (curProvider == -1) loadData(null, true, true, true);
        else
          loadData(
              dbQuery.getRssProviderList(null).getProviderNames()[curProvider], false, true, true);
        break;

      case R.id.btn_search:
        if (txtSearchLabel.getText().toString().equals(getString(R.string.btn_search_text))) {
          btnManage.setVisibility(View.GONE);
          txtManageLabel.setVisibility(View.GONE);
          btnBrowse.setVisibility(View.GONE);
          txtBrowseLabel.setVisibility(View.GONE);
          btnRefresh.setVisibility(View.GONE);
          txtRefreshLabel.setVisibility(View.GONE);
          btnSearch.setBackgroundResource(R.drawable.btn_done_background);
          txtSearchLabel.setText(R.string.btn_done_text);
          txtSearch.setVisibility(View.VISIBLE);
          txtSearch.requestFocus();
        } else {
          btnManage.setVisibility(View.VISIBLE);
          txtManageLabel.setVisibility(View.VISIBLE);
          btnBrowse.setVisibility(View.VISIBLE);
          txtBrowseLabel.setVisibility(View.VISIBLE);
          btnRefresh.setVisibility(View.VISIBLE);
          txtRefreshLabel.setVisibility(View.VISIBLE);
          btnSearch.setBackgroundResource(R.drawable.btn_search_background);
          txtSearchLabel.setText(R.string.btn_search_text);
          txtSearch.setVisibility(View.GONE);
          txtSearch.setText("");
          loadData(null, true, false, false);
        }
        break;
      default:
        break;
    }
  }
 @Override
 public void onHideInputView() {
   if (!mIsExprShow && mExprBtn != null) {
     mExprBtn.setBackgroundResource(R.drawable.selector_s_chat_expressions);
   }
 }