Example usage for android.view.inputmethod InputMethodManager isActive

List of usage examples for android.view.inputmethod InputMethodManager isActive

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager isActive.

Prototype

public boolean isActive() 

Source Link

Document

Return true if any view is currently active in the input method.

Usage

From source file:org.wdd.app.android.catgirl.views.ActionSheet.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        View focusView = getActivity().getCurrentFocus();
        if (focusView != null) {
            imm.hideSoftInputFromWindow(focusView.getWindowToken(), 0);
        }//from   w w w.j av  a2  s  .c  o  m
    }

    mView = createView();
    mGroup = (ViewGroup) getActivity().getWindow().getDecorView();

    createItems();

    mGroup.addView(mView);
    mBg.startAnimation(createAlphaInAnimation());
    mPanel.startAnimation(createTranslationInAnimation());
    return super.onCreateView(inflater, container, savedInstanceState);
}

From source file:com.smartcodeunited.demo.bluetooth.activity.BaseActivity.java

/**
 * Hide the input method// www. j a  v  a2s . c om
 */
public void hideInputMethod(View view) {
    InputMethodManager m = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    if (getCurrentFocus() != null && m.isActive()) {
        if (view == null) {
            view = getCurrentFocus();
        }
        m.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }
}

From source file:org.tigase.messenger.phone.pro.conversations.chat.ChatItemFragment.java

public void closeIME() {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        imm.hideSoftInputFromWindow(message.getApplicationWindowToken(), 0);
    }//from   w ww . j ava  2  s. c o  m
}

From source file:com.radicaldynamic.groupinform.application.Collect.java

public void hideSoftKeyboard(View c) {
    InputMethodManager inputManager = (InputMethodManager) getBaseContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    if (viewToken != null) {
        inputManager.hideSoftInputFromWindow(viewToken, 0);
    }//w ww  . j  a va2s. c o  m
    viewToken = null;

    if (c != null) {
        if (inputManager.isActive()) {
            inputManager.hideSoftInputFromWindow(c.getApplicationWindowToken(), 0);
        }
    }
}

From source file:com.aosijia.dragonbutler.ui.widget.ActionSheet.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        View focusView = getActivity().getCurrentFocus();
        if (focusView != null) {
            imm.hideSoftInputFromWindow(focusView.getWindowToken(), 0);
        }//from  ww w. ja  va2s. com
    }

    mAttrs = readAttribute();

    mView = createView();
    mGroup = (ViewGroup) getActivity().getWindow().getDecorView();

    createItems();

    mGroup.addView(mView);
    mBg.startAnimation(createAlphaInAnimation());
    mPanel.startAnimation(createTranslationInAnimation());
    return super.onCreateView(inflater, container, savedInstanceState);
}

From source file:kr.wdream.storyshop.AndroidUtilities.java

public static void hideKeyboard(View view) {
    if (view == null) {
        return;//from ww w.j  ava2  s.  c o  m
    }
    try {
        InputMethodManager imm = (InputMethodManager) view.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (!imm.isActive()) {
            return;
        }
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}

From source file:com.novemser.voicetest.ui.MainActivity.java

public void sendMessage(View view) {
    msg = mMsg.getText().toString();/*from ww w  . j  a  v  a  2s . c  o m*/
    if (TextUtils.isEmpty(msg)) {
        Toast.makeText(this, getResources().getText(R.string.noTextWarning), Toast.LENGTH_LONG).show();
        return;
    }

    ChatMessage to = new ChatMessage(ChatMessage.Type.OUTPUT, msg);
    to.setDate(new Date());
    mDatas.add(to);

    mAdapter.notifyDataSetChanged();
    mChatView.setSelection(mDatas.size() - 1);

    mMsg.setText("");

    // 
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    // InputMethodManager
    if (imm.isActive()) {
        // ?
        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
        // ?????
    }

    understander.understandText(msg, textUnderstanderListener);
}

From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java

@Nullable
@Override//from ww  w . j  a  v  a  2s .  c  o  m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        View focusView = getActivity().getCurrentFocus();
        if (focusView != null) {
            imm.hideSoftInputFromWindow(focusView.getWindowToken(), 0);
        }
    }

    actionSheetView = createRoot();
    decor = (ViewGroup) getActivity().getWindow().getDecorView();

    attachItems();

    decor.addView(actionSheetView);

    backgroundLayer.startAnimation(createAlphaInAnimation());
    sheetContainer.startAnimation(createTranslationInAnimation());
    return super.onCreateView(inflater, container, savedInstanceState);
}

From source file:com.ferdi2005.secondgram.AndroidUtilities.java

public static void hideKeyboard(View view) {
    if (view == null) {
        return;/*from  w w  w  .java  2  s  .c om*/
    }
    try {
        InputMethodManager imm = (InputMethodManager) view.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (!imm.isActive()) {
            return;
        }
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    } catch (Exception e) {
        FileLog.e(e);
    }
}

From source file:edu.cmu.cylab.starslinger.view.MessagesFragment.java

public void updateKeypad() {
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (mRecip == null) {
        // if soft input open, close it...
        View focus = getActivity().getCurrentFocus();
        if (focus != null) {
            imm.hideSoftInputFromWindow(focus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }//from ww w  .  j  a v  a 2 s  .  c  o m
    } else {
        // if soft input open, gain the focus...
        if (imm.isActive() && mEditTextMessage != null) {
            mEditTextMessage.requestFocus();
        }
    }
}