コード例 #1
0
 @Override
 public void onExprItemClick(String exprInfo, boolean isDel) {
   SpannableString ss;
   int textSize = (int) editText.getTextSize();
   if (isDel) {
     HashMap<String, Integer> mExprFilenameIdData =
         XWExpressionManager.getInstance().getmExprInfoIdValuesCN(getActivity());
     ss =
         XWExpressionUtil.generateSpanComment(
             getActivity().getApplicationContext(),
             XWExpressionUtil.deleteOneWord(editText.getText().toString(), mExprFilenameIdData),
             textSize);
   } else {
     String content = editText.getText() + exprInfo;
     ss =
         XWExpressionUtil.generateSpanComment(
             getActivity().getApplicationContext(), content, textSize);
   }
   editText.setText(ss);
   editText.setSelection(ss.length());
 }
コード例 #2
0
 /**
  * 控制表情区和软键盘的显示
  *
  * @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);
   }
 }
コード例 #3
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);
    }
  }
コード例 #4
0
 @Override
 public void onShowInputView() {
   editText.setHint("");
 }
コード例 #5
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);
  }