List of usage examples for android.view View getWindowToken
public IBinder getWindowToken()
From source file:Main.java
public static void hideSoftInput(Activity activity) { View currentFocus = activity.getCurrentFocus(); if (currentFocus != null) { IBinder windowToken = currentFocus.getWindowToken(); if (windowToken != null) { InputMethodManager manager = (InputMethodManager) (activity .getSystemService(Context.INPUT_METHOD_SERVICE)); if (manager != null) { manager.hideSoftInputFromWindow(windowToken, InputMethodManager.HIDE_NOT_ALWAYS); }/*from w w w .ja v a 2s .com*/ } } }
From source file:Main.java
/** * Request to hide the soft input window from the context of the window that * is currently accepting input.//from w ww . j av a 2s. com * * @param activity * The currently activity, which shows the view receives soft * keyboard input. */ public static void hideKeyboard(Activity activity) { if (null == activity) { return; } InputMethodManager im = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); View v = activity.getCurrentFocus(); if (v != null) { im.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:Main.java
/** * Hide input method.//from w w w . java 2s .c om * * @param activity */ public static void hideInputMethod(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); View currentFocus = activity.getCurrentFocus(); if (currentFocus != null) { imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:Main.java
public static void animateColorChange(View view, int fromColor, int toColor, int duration, Animator.AnimatorListener listener) { if (view.getWindowToken() == null) { return;/*from w w w . j a v a2 s .com*/ } AnimatorSet animation = new AnimatorSet(); ObjectAnimator colorAnimator = ObjectAnimator.ofInt(view, COLOR_PROPERTY, fromColor, toColor); colorAnimator.setEvaluator(new ArgbEvaluator()); colorAnimator.setDuration(duration); if (listener != null) animation.addListener(listener); animation.play(colorAnimator); animation.start(); }
From source file:Main.java
public static void hideSoftKeyboard(Activity activity) { if (activity != null) { InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Activity.INPUT_METHOD_SERVICE); View view = activity.getCurrentFocus(); if (view != null) inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); }// w w w .ja v a2 s. c o m }
From source file:Main.java
public static Animator createCircularHideAnimator(final View view, @Nullable Animator.AnimatorListener listener) { if (view.getWindowToken() == null || view.getVisibility() == View.INVISIBLE) return null; // get the center for the clipping circle int cx = (view.getLeft() + view.getRight()) / 2; int cy = (view.getTop() + view.getBottom()) / 2; // get the initial radius for the clipping circle int initialRadius = view.getWidth(); // create the animation (the final radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0); anim.addListener(new AnimatorListenerAdapter() { @Override//from w w w .j a va 2s . co m public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(View.INVISIBLE); } }); if (listener != null) { anim.addListener(listener); } return anim; }
From source file:Main.java
public static void scaleHide(final View view, final Runnable rWhenEnd) { if (view.getWindowToken() == null) { view.setVisibility(View.INVISIBLE); if (rWhenEnd != null) { rWhenEnd.run();//from www. j a v a 2 s .com } return; } ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0f); AnimatorSet set = new AnimatorSet(); set.playTogether(scaleX, scaleY); set.setDuration(DURATION_SHORT); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.INVISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } } @Override public void onAnimationCancel(Animator animation) { view.setVisibility(View.INVISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); }
From source file:Main.java
public static void hideSoftKeyBoard(InputMethodManager imm, View... views) { if (views != null && imm != null) { for (View view : views) { if (view != null) { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }//from ww w . j a va2s .co m } } }
From source file:Main.java
public static void hideKeyboard(Activity activity) { InputMethodManager inputManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); // check if no view has focus: View v = activity.getCurrentFocus(); if (v == null) return;/* www. jav a 2 s. c om*/ inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0); }
From source file:Main.java
public static void hideSoftInput(Context context, View focusView) { InputMethodManager imm = from(context); if (imm.isActive()) { IBinder token = focusView.getWindowToken(); imm.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS); }//from w ww.j a va 2 s. c om }