Ejemplo n.º 1
0
 /** 绑定点击事件 */
 private void bindListeners() {
   container_menu.setOnClickListener(this);
   btn_set_mode_voice.setOnClickListener(this);
   buttonSetModeKeyboard.setOnClickListener(this);
   btnMore.setOnClickListener(this);
   mEditTextContent.setOnClickListener(this);
   mEditTextContent.addTextChangedListener(new MyTextWatcher());
 }
Ejemplo n.º 2
0
  public void handlerUI(RefreshType type) {
    switch (type) {
      case ADAPTERSELECTLAST:
        adapter.refreshSelectLast();
        break;
      case ADAPTERDATACHANGE:
        adapter.notifyDataSetChanged();
        break;
      case CLEAREDITTEXT:
        mEditTextContent.setText("");
        break;
      case SETRESULT:
        setResult(RESULT_OK);
        break;
      case NEWMSG:
        {
          if (adapter == null) {
            return;
          }
          runOnUiThread(
              new Runnable() {
                public void run() {
                  adapter.refreshSelectLast();
                }
              });
          break;
        }
      case CHATUI:
        {
          if (adapter == null) {
            return;
          }

          runOnUiThread(
              new Runnable() {
                public void run() {
                  adapter.refresh();
                }
              });
        }
    }
  }
Ejemplo n.º 3
0
  /**
   * 点击事件逻辑
   *
   * @param v
   */
  public void widgetClick(View v) {
    switch (v.getId()) {

        // 清空聊天记录按钮
      case R.id.container_menu:
        {
          String st5 = getResources().getString(R.string.Whether_to_empty_all_chats);
          startActivityForResult(
              new Intent(this, AlertDialog.class)
                  .putExtra("titleIsCancel", true)
                  .putExtra("msg", st5)
                  .putExtra("cancel", true),
              REQUEST_CODE_EMPTY_HISTORY);
          break;
        }

      case R.id.btn_set_mode_voice:
        {
          // 点击录音部分视图显示状态变化
          hideKeyboard();
          edittext_layout.setVisibility(View.GONE);
          more.setVisibility(View.GONE);
          v.setVisibility(View.GONE);
          buttonSetModeKeyboard.setVisibility(View.VISIBLE);
          buttonSend.setVisibility(View.GONE);
          btnMore.setVisibility(View.VISIBLE);
          buttonPressToSpeak.setVisibility(View.VISIBLE);
          iv_emoticons_normal.setVisibility(View.VISIBLE);
          iv_emoticons_checked.setVisibility(View.INVISIBLE);
          btnContainer.setVisibility(View.VISIBLE);
          emojiIconContainer.setVisibility(View.GONE);
          break;
        }

      case R.id.btn_set_mode_keyboard:
        {
          // 点击键盘按钮图标显示状态变化
          edittext_layout.setVisibility(View.VISIBLE);
          more.setVisibility(View.GONE);
          v.setVisibility(View.GONE);
          buttonSetModeVoice.setVisibility(View.VISIBLE);
          mEditTextContent.requestFocus();
          buttonPressToSpeak.setVisibility(View.GONE);
          if (TextUtils.isEmpty(mEditTextContent.getText())) {
            btnMore.setVisibility(View.VISIBLE);
            buttonSend.setVisibility(View.GONE);
          } else {
            btnMore.setVisibility(View.GONE);
            buttonSend.setVisibility(View.VISIBLE);
          }
          break;
        }

      case R.id.btn_more:
        {
          // 点击更多按钮
          if (more.getVisibility() == View.GONE) {
            hideKeyboard();
            more.setVisibility(View.VISIBLE);
            btnContainer.setVisibility(View.VISIBLE);
            alarmPreview_layout.setVisibility(View.GONE);
            emojiIconContainer.setVisibility(View.GONE);
          } else if (emojiIconContainer.getVisibility() == View.VISIBLE) {
            emojiIconContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.VISIBLE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
          } else if (alarmPreview_layout.getVisibility() == View.VISIBLE) {
            alarmPreview_layout.setVisibility(View.GONE);
            btnContainer.setVisibility(View.VISIBLE);
          } else {
            more.setVisibility(View.GONE);
          }
          break;
        }

      case R.id.et_sendmessage:
        {
          listView.setSelection(listView.getCount() - 1);
          if (more.getVisibility() == View.VISIBLE) {
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
          }
          break;
        }

      default:
        break;
    }
  }