List of usage examples for android.view View getWindowToken
public IBinder getWindowToken()
From source file:com.easemob.helpdeskdemo.ui.SatisfactionActivity.java
@Override public boolean dispatchTouchEvent(MotionEvent ev) { // Edittext /*from www .ja va2 s .c o m*/ if (ev.getAction() == MotionEvent.ACTION_DOWN) { View v = getCurrentFocus(); if (isShouldHideInput(v, ev)) { InputMethodManager inputManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); if (inputManager != null) { inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0); } } return super.dispatchTouchEvent(ev); } // ????TouchEvent if (getWindow().superDispatchTouchEvent(ev)) { return true; } return onTouchEvent(ev); }
From source file:ua.com.spacetv.mycookbook.dialogs.FragDialog.java
/** * Hide software keyboard/*from w ww. j a va 2s. c om*/ * * @param v - View */ private void hideKeyboard(View v) { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); }
From source file:com.kaytat.simpleprotocolplayer.MainActivity.java
private void hideKb() { InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); View v = getCurrentFocus(); if (v != null) { inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }/*from ww w.j a va 2s . c o m*/ }
From source file:org.comixwall.pffw.Login.java
private void processLogin() { if (controller.isLoggedin()) { // Reset the cache upon login FragmentManager fm = getActivity().getSupportFragmentManager(); fm.beginTransaction().remove(fm.findFragmentByTag("cache")).commit(); MainActivity.cache = new Cache(); fm.beginTransaction().add(MainActivity.cache, "cache").commit(); // Reset saved timestamp of last notification lastNotificationTimestamp = 0;//from w ww.ja v a 2s .c o m // Enable drawer and toggle button ((MainActivity) getActivity()).drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); ((MainActivity) getActivity()).toggle.setDrawerIndicatorEnabled(true); // Recreate menu items, the fragment is Dashboard now getActivity().invalidateOptionsMenu(); try { // Hide the soft keyboard View view = getActivity().getCurrentFocus(); if (view != null) { InputMethodManager imm = (InputMethodManager) getContext() .getSystemService(Activity.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } } catch (Exception ignored) { } // Send the token to the system upon each login, so the app can get notifications FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(getActivity(), new OnSuccessListener<InstanceIdResult>() { @Override public void onSuccess(InstanceIdResult instanceIdResult) { token = instanceIdResult.getToken(); // Controller sends the token before the next command it executes, and lowers this sendToken flag sendToken = true; } }); ((MainActivity) getActivity()).showFirstFragment(); } }
From source file:com.google.samples.apps.topeka.widget.quiz.AbsQuizView.java
private CheckableFab getSubmitButton() { if (null == mSubmitAnswer) { mSubmitAnswer = (CheckableFab) getLayoutInflater().inflate(R.layout.answer_submit, this, false); mSubmitAnswer.hide();//w ww . j ava 2 s . c o m mSubmitAnswer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { submitAnswer(v); if (mInputMethodManager.isAcceptingText()) { mInputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0); } mSubmitAnswer.setEnabled(false); } }); } return mSubmitAnswer; }
From source file:net.clcworld.thermometer.TakeTemperatureReadingActivity.java
public void hideKeyboard(View view) { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:com.gao.im.ui.CCPActivityBase.java
/** * //from w w w .j ava2 s. co m */ public void displaySoftKeyboard() { final FragmentActivity activity = mActionBarActivity; // Display the soft keyboard InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null) { View localView = activity.getCurrentFocus(); if (localView != null && localView.getWindowToken() != null) { inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); } } }
From source file:sg.fxl.topeka.widget.quiz.AbsQuizView.java
private CheckableFab getSubmitButton() { if (null == submitAnswer) { submitAnswer = (CheckableFab) getLayoutInflater().inflate(R.layout.answer_submit, this, false); submitAnswer.hide();/*w w w. java2 s. c om*/ submitAnswer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { submitAnswer(v); if (inputMethodManager.isAcceptingText()) { inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0); } submitAnswer.setEnabled(false); } }); } return submitAnswer; }
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 www .j a v a 2s . c om*/ } 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:de.msal.shoutemo.fragments.ChatFragment.java
private void hideKeyboard() { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); // check if no view has focus: View view = getActivity().getCurrentFocus(); if (view != null) { inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }/*w w w . j a v a 2 s .c om*/ }