コード例 #1
0
  @OnClick(R.id.comment_sendbtn)
  public void senAction() {
    String infoid = getArguments().getString("infoid");
    String userid = getArguments().getString("userid");
    String commentid = getArguments().getString("commentid");
    String content = editText.getText().toString().trim();
    if (TextUtils.isEmpty(content)) {
      showToast("请输入内容");
      return;
    }
    KeyboardUtil.hideSoftInput(getActivity());

    if (isCompanyCircle) {
      companyZoneCommentSub(infoid, userid, commentid, content);
    } else {
      String infouserid = getArguments().getString("infouserid");
      friendZoneCommentSub(infoid, userid, commentid, content, infouserid);
    }
  }
コード例 #2
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    editText.setHint(getArguments().getString("hint"));
    isCompanyCircle = getArguments().getBoolean("isCompanyCircle");
    mImm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    getView()
        .findViewById(R.id.ly_other)
        .setOnTouchListener(
            new View.OnTouchListener() {
              @Override
              public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                  //                    finish();
                  KeyboardUtil.hideSoftInput(getActivity());
                  if (mComLis != null) {
                    mComLis.onHideCommunityCommentary();
                  }
                  getFragmentManager()
                      .beginTransaction()
                      .remove(CommunityCommentaryFragment.this)
                      .commit();
                  return true;
                }
                return false;
              }
            });
    mRootContainer.setOnInputViewListener(this);

    editText.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
              if (mIsExprShow) {
                mIsExprShow = false;
                mIsSoftKeyboardShow = true;
                mExpressionWidgt.setVisibility(View.GONE);
                mExprBtn.setBackgroundResource(R.drawable.selector_s_chat_expressions);
              }
            }
            return false;
          }
        });
    mSoftKeyboardHeight = PreferencesManager.getSoftKeyboardHeight(getActivity());
    if (mSoftKeyboardHeight > 0) {
      resizeExprArea(Constants.screenWidth);
    } else {
      mSoftKeyboardHeight = Constants.screenHeight / 3;
    }

    /** 测量软键盘所占区域高度 */
    mRootContainer
        .getViewTreeObserver()
        .addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {
              @Override
              public void onGlobalLayout() {
                Rect r = new Rect();
                if (mRootContainer != null) {
                  mRootContainer.getWindowVisibleDisplayFrame(r);
                  int screenHeight = mRootContainer.getHeight();
                  final int screenWidth = mRootContainer.getWidth();
                  if (mOriginalHeight == 0) {
                    mOriginalHeight = screenHeight;
                  } else {
                    if (screenHeight != mOriginalHeight && !isExprAreaResized) {
                      mSoftKeyboardHeight = Math.abs(screenHeight - mOriginalHeight);
                      PreferencesManager.saveSoftKeyboardHeight(getActivity(), mSoftKeyboardHeight);
                      isExprAreaResized = true;
                      mUiHandler.post(
                          new Runnable() {
                            @Override
                            public void run() {
                              resizeExprArea(screenWidth);
                            }
                          });
                    }
                  }
                }
              }
            });
    mExpressionWidgt.setmOnExprItemClickListener(this);
    resizeExprArea(Constants.screenWidth);
    KeyboardUtil.showSoftInput(editText);
  }