Example usage for android.view View getWindowToken

List of usage examples for android.view View getWindowToken

Introduction

In this page you can find the example usage for android.view View getWindowToken.

Prototype

public IBinder getWindowToken() 

Source Link

Document

Retrieve a unique token identifying the window this view is attached to.

Usage

From source file:dev.drsoran.moloko.fragments.base.impl.EditFragmentImpl.java

public void onViewCreated(View view, Bundle savedInstanceState) {
    windowToken = view.getWindowToken();
}

From source file:com.mifos.mifosxdroid.core.MifosBaseFragment.java

public void hideKeyboard(View view) {
    inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
}

From source file:com.fbartnitzek.tasteemall.ui.OnTouchHideKeyboardListener.java

@Override
public boolean onTouch(View v, MotionEvent event) {
    InputMethodManager imm = (InputMethodManager) fragment.getActivity().getApplicationContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    View currentFocus = fragment.getActivity().getCurrentFocus();
    if (currentFocus != null) {
        imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0); //InputMethodManager.HIDE_NOT_ALWAYS also possible
    }// ww  w  . ja v  a  2  s .c om
    return false;
}

From source file:com.gm.goldencity.util.Utils.java

/**
 * Hide keyboard of a View/*from www  .  ja va 2 s .c  o m*/
 *
 * @param context Application context
 * @param view    Edit text or another view that you want hide the keyboard
 */
public static void hideKeyboard(Context context, @NonNull View view) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:com.mobicage.rogerthat.util.ui.UIUtils.java

public static void hideKeyboard(Context context, View view) {
    T.UI();//from  ww  w  .  j a v a 2  s  . com
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm == null)
        L.d("No input method manager");
    else {
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}

From source file:org.onebusaway.android.util.UIUtils.java

/**
 * Closes the soft keyboard//ww  w.j  a  va  2s  .co  m
 */
public static void closeKeyboard(Context context, View v) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}

From source file:com.efithealth.app.activity.BaseActivity.java

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    if (ev.getAction() == MotionEvent.ACTION_DOWN) {
        View view = getCurrentFocus();
        if (isHideInput(view, ev)) {
            HideSoftInput(view.getWindowToken());
        }/*from   w w w.  j av a  2  s.co m*/
    }
    return super.dispatchTouchEvent(ev);
}

From source file:com.lee.sdk.utils.Utils.java

/**
 * Hides the input method.//  w  w  w  .ja  v  a2 s.  co  m
 * 
 * @param context context
 * @param view The currently focused view
 * @return success or not.
 */
public static boolean hideInputMethod(Context context, View view) {
    if (context == null || view == null) {
        return false;
    }

    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        return imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    return false;
}

From source file:org.sufficientlysecure.keychain.ui.base.CryptoOperationFragment.java

public void hideKeyboard() {
    Activity activity = getActivity();//ww w  .j  av a2  s . co  m
    if (activity == null) {
        return;
    }
    InputMethodManager inputManager = (InputMethodManager) activity
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    // check if no view has focus
    View v = activity.getCurrentFocus();
    if (v == null)
        return;

    inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
}

From source file:org.sufficientlysecure.keychain.ui.linked.LinkedIdWizard.java

private void hideKeyboard() {
    InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    // check if no view has focus
    View v = getCurrentFocus();
    if (v == null)
        return;//from w w w .  j  a v  a2 s  . co m

    inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
}