Java Code Examples for com.blankj.utilcode.util.KeyboardUtils#hideSoftInput()

The following examples show how to use com.blankj.utilcode.util.KeyboardUtils#hideSoftInput() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void showEmotionOrOther(MessageBtnType type, boolean show) {

        if (show) {
            KeyboardUtils.hideSoftInput(this);
            inputBackLayout.setVisibility(View.VISIBLE);

            LinearLayout.LayoutParams par = (LinearLayout.LayoutParams) inputBackLayout.getLayoutParams();
            switch (type) {
                case MsgBtnEmotion:
                    int height = chatEmotionFragment.getChatEmotionHeight();
                    par.height = chatEmotionFragment.getChatEmotionHeight();
                    viewPager.setCurrentItem(0);
                    break;
                case MsgBtnOther:
                    par.height = FLUtil.dip2px(mContext, 150);
                    viewPager.setCurrentItem(1);
                    break;
            }
            inputBackLayout.setLayoutParams(par);
        } else {

            inputBackLayout.setVisibility(View.GONE);
        }
    }
 
Example 2
@Override
protected void onDestroy() {
    super.onDestroy();

    ClientManager.chattingUserId = "";
    EventBus.getDefault().unregister(this);
    KeyboardUtils.hideSoftInput(this);

    Socket socket = SocketManager.socket;
    socket.off("__join");
    socket.off("_ice_candidate");
    socket.off("_peers");
    socket.off("_new_peer");
    socket.off("_remove_peer");
    socket.off("_offer");
    socket.off("_answer");
    socket.off("cancelVideoChat");

}
 
Example 3
public void unRegister() {
    isRegister = false;
    KeyboardUtils.hideSoftInput(mActivity);
    keyBoardHeight = 0;
    sendHandlerMsg(0);

    if(keyboardHeightProvider != null){
        keyboardHeightProvider.setKeyboardHeightObserver(null);
        keyboardHeightProvider.close();
    }
}
 
Example 4
private void setBtnType(MessageBtnType btnType) {
    this.btnType = btnType;

    voiceBtn.setImageResource(R.drawable.keyboard_voice);
    emotionBtn.setImageResource(R.drawable.keyboard_emotion);
    addOtherBtn.setImageResource(R.drawable.keyboard_add);

    if (btnType == MessageBtnType.MsgBtnVoice) {

        inputTextMessage.setVisibility(View.GONE);
        sendVoiceBtn.setVisibility(View.VISIBLE);
    } else {
        inputTextMessage.setVisibility(View.VISIBLE);
        sendVoiceBtn.setVisibility(View.GONE);
    }

    switch (btnType){

        case MsgBtnVoice:
            voiceBtn.setImageResource(R.drawable.keyboard_keyboard);
            showEmotionOrOther(btnType, false);
            KeyboardUtils.hideSoftInput(this);
            break;

        case MsgBtnEmotion:
            emotionBtn.setImageResource(R.drawable.keyboard_keyboard);
            showEmotionOrOther(btnType,true);
            break;

        case MsgBtnOther:
            addOtherBtn.setImageResource(R.drawable.keyboard_keyboard);
            showEmotionOrOther(btnType, true);
            break;
        case MsgBtnText:
            showEmotionOrOther(btnType, false);
            break;
    }
}
 
Example 5
Source Project: DanDanPlayForAndroid   File: SearchActivity.java    License: MIT License 5 votes vote down vote up
@OnClick({R.id.return_iv, R.id.subgroup_tv, R.id.type_tv, R.id.search_iv})
public void onViewClicked(View view) {
    KeyboardUtils.hideSoftInput(searchEt);
    switch (view.getId()) {
        case R.id.return_iv:
            if (historyRl.getVisibility() == View.GONE || !isSearch)
                SearchActivity.this.finish();
            else {
                AnimHelper.doHideAnimator(historyRl);
                searchEt.clearFocus();
            }
            break;
        case R.id.subgroup_tv:
            presenter.querySubGroupList();
            break;
        case R.id.type_tv:
            presenter.queryTypeList();
            break;
        case R.id.search_iv:
            String searchText = searchEt.getText().toString().trim();
            if (StringUtils.isEmpty(searchText)) {
                ToastUtils.showShort("请输入搜索条件");
                return;
            }
            search(searchText);
            break;
    }
}
 
Example 6
Source Project: DanDanPlayForAndroid   File: SearchActivity.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
        if (historyRl.getVisibility() == View.GONE || !isSearch)
            SearchActivity.this.finish();
        else {
            AnimHelper.doHideAnimator(historyRl);
            KeyboardUtils.hideSoftInput(searchEt);
            searchEt.clearFocus();
        }
    }
    return true;
}
 
Example 7
@OnClick({R.id.update_api_key_tv, R.id.update_quota_tv, R.id.search_tv})
public void onViewClicked(View view) {
    switch (view.getId()) {
        case R.id.update_api_key_tv:
            new CommonEditTextDialog(this, CommonEditTextDialog.SAVE_SHOOTER_API_SECRET, data -> {
                AppConfig.getInstance().setShooterApiSecret(data[0]);
                updateApiSecretStatus();
            }).show();
            break;
        case R.id.update_quota_tv:
            if (isApiSecretExist) {
                presenter.updateQuota();
            } else {
                ToastUtils.showShort("请先设置API密钥");
            }
            break;
        case R.id.search_tv:
            KeyboardUtils.hideSoftInput(searchSubtitleEt);
            if (isApiSecretExist) {
                String text = searchSubtitleEt.getText().toString();
                if (!TextUtils.isEmpty(text)) {
                    mPage = 0;
                    presenter.searchSubtitle(text, mPage);
                } else {
                    ToastUtils.showShort("搜索内容不能为空");
                }
            } else {
                ToastUtils.showShort("请先设置API密钥");
            }
            break;
    }
}
 
Example 8
@Override
public void onWidgetClick(View view) {
    switch (view.getId()) {
        case R.id.btn_hide_soft_input:
            KeyboardUtils.hideSoftInput(this);
            break;
        case R.id.btn_show_soft_input:
            KeyboardUtils.showSoftInput((EditText) findViewById(R.id.et));
            break;
        case R.id.btn_toggle_soft_input:
            KeyboardUtils.toggleSoftInput();
            break;
    }
}
 
Example 9
@Override
public boolean onTouchEvent(MotionEvent event) {

    KeyboardUtils.hideSoftInput(this);
    return super.onTouchEvent(event);
}
 
Example 10
Source Project: DanDanPlayForAndroid   File: DanmuBlockView.java    License: MIT License 4 votes vote down vote up
@Override
public void onClick(View v) {
    int id = v.getId();
    if (id == R.id.block_view_cancel_iv){
        if (listener != null)
            listener.onCloseView();
    }else if (id == R.id.add_block_bt){
        String blockText = blockEt.getText().toString().trim();
        if (TextUtils.isEmpty(blockText)){
            Toast.makeText(getContext(), "屏蔽关键字不能为空", Toast.LENGTH_LONG).show();
        }else if (blockList.contains(blockText)){
            Toast.makeText(getContext(), "当前关键字已屏蔽", Toast.LENGTH_LONG).show();
        }else if (traverseBlock(blockText)){
            Toast.makeText(getContext(), "当前关键字已在屏蔽范围内", Toast.LENGTH_LONG).show();
        }else {
            Toast.makeText(getContext(), "添加屏蔽成功", Toast.LENGTH_LONG).show();
            blockEt.setText("");
            KeyboardUtils.hideSoftInput(blockEt);

            if (blockText.endsWith(";")){
                blockText = blockText.substring(0, blockText.length() - 1);
            }
            if (blockText.startsWith(";")){
                blockText = blockText.substring(1);
            }
            String[] blockData;
            if (listener != null){
                if (blockText.contains(";")){
                    blockData = blockText.split(";");
                }else {
                    blockData = new String[]{blockText};
                }

                //添加到显示界面
                blockList.addAll(Arrays.asList(blockData));
                labelsView.setLabels(blockList);
                if (listener != null)
                    listener.addBlock(Arrays.asList(blockData));
            }

        }
    }else if (id == R.id.delete_block_bt){
        List<String> selectLabelList = labelsView.getSelectLabelDatas();
        if (selectLabelList.size() == 0){
            ToastUtils.showShort("未选中屏蔽数据");
            return;
        }
        for (String text : selectLabelList){
            blockList.remove(text);
        }
        labelsView.setLabels(blockList);
        if (listener != null){
            listener.removeBlock(selectLabelList);
        }
    }
}
 
Example 11
Source Project: AndroidUtilCode   File: FloatEditText.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void onDetachedFromWindow() {
    KeyboardUtils.hideSoftInput(this);
    super.onDetachedFromWindow();
}
 
Example 12
Source Project: AndroidUtilCode   File: SearchEditText.java    License: Apache License 2.0 4 votes vote down vote up
public void reset() {
    mStartSearchText = "";
    setText("");
    KeyboardUtils.hideSoftInput(this);
}
 
Example 13
Source Project: AndroidUtilCode   File: SearchEditText.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void onDetachedFromWindow() {
    removeCallbacks(mAction);
    KeyboardUtils.hideSoftInput(this);
    super.onDetachedFromWindow();
}