List of usage examples for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS
int HIDE_NOT_ALWAYS
To view the source code for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.
Click Source Link
From source file:io.v.android.apps.syncslides.NavigateFragment.java
/** * If the user is editing the text field and the text has changed, save the * notes locally and in Syncbase.// ww w. jav a 2s. co m */ public void saveNotes() { final String notes = mNotes.getText().toString(); if (mEditing && (!notes.equals(mSlides.get(mUserSlideNum).getNotes()))) { toast("Saving notes"); mSlides.get(mUserSlideNum).setNotes(notes); mDB.setSlideNotes(mDeckId, mUserSlideNum, notes); } mNotes.clearFocus(); InputMethodManager inputManager = (InputMethodManager) getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (getActivity().getCurrentFocus() != null) { inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } ((PresentationActivity) getActivity()).setUiImmersive(true); }
From source file:de.uni_koblenz_landau.apow.PatientDetailEditFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == android.R.id.home) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(FragmentActivity.INPUT_METHOD_SERVICE); if (getActivity().getCurrentFocus() != null) { inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }//from w w w. j a v a2s . co m NavUtils.navigateUpFromSameTask(getActivity()); return true; } if (id == R.id.patient_detail_edit_action_save) { save(); return true; } if (id == R.id.patient_detail_edit_action_cancel) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(FragmentActivity.INPUT_METHOD_SERVICE); if (getActivity().getCurrentFocus() != null) { inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } NavUtils.navigateUpFromSameTask(getActivity()); return true; } return super.onOptionsItemSelected(item); }
From source file:com.spoiledmilk.ibikecph.search.SearchAutocompleteActivity.java
@Override public void onResume() { super.onResume(); initStrings();//from ww w. ja v a2 s . c om InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE); imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); progressBar.setVisibility(View.INVISIBLE); }
From source file:com.android.together.BaseActivity.java
/** * /* www . j a v a 2 s .c o m*/ */ public void hideKeyboard() { if (getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:com.neighbor.ex.tong.ui.activity.MainActivity2Activity.java
public void hideKeyboard() { InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:io.v.syncslides.NavigateFragment.java
/** * If the user is editing the text field and the text has changed, save the * notes in Syncbase. That will trigger a notification that the slide has * changed and the UI will refresh./* ww w . ja v a 2 s . c om*/ */ public void saveNotes() { final String notes = mNotes.getText().toString(); if (mEditing && (!notes.equals(mSlides.get(mSlideNum).getNotes()))) { try { mSession.setNotes(mSlideNum, notes); } catch (VException e) { handleError("Could not save notes", e); } } mNotes.clearFocus(); mEditing = false; InputMethodManager inputManager = (InputMethodManager) getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (getActivity().getCurrentFocus() != null) { inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } ((PresentationActivity) getActivity()).setUiImmersive(true); }
From source file:com.lastsoft.plog.GamesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_games, container, false); rootView.setTag(TAG);//from ww w. j a v a 2 s .co m // BEGIN_INCLUDE(initializeRecyclerView) mCoordinatorLayout = (CoordinatorLayout) rootView.findViewById(R.id.coordinatorLayout); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView); mRecyclerView.setBackgroundColor(getResources().getColor(R.color.cardview_initial_background)); pullToRefreshView = (SwipeRefreshLayout) rootView.findViewById(R.id.pull_to_refresh_listview); pullToRefreshView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { initDataset(true); } }); RecyclerFastScroller fastScroller = (RecyclerFastScroller) rootView.findViewById(R.id.fastscroller); fastScroller.attachRecyclerView(mRecyclerView); //fastScroller = (VerticalRecyclerViewFastScroller) rootView.findViewById(R.id.fastscroller); // Connect the recycler to the scroller (to let the scroller scroll the list) //fastScroller.setRecyclerView(mRecyclerView, pullToRefreshView); // Connect the scroller to the recycler (to let the recycler scroll the scroller's handle) //mRecyclerView.setOnScrollListener(fastScroller.getOnScrollListener()); addPlayer = (FloatingActionButton) rootView.findViewById(R.id.add_game); if (fromDrawer && playListType != 2) { //fastScroller.setRecyclerView(mRecyclerView, pullToRefreshView); mRecyclerView.setOnScrollListener(new OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); boolean enable = false; boolean firstItemVisiblePull = recyclerView.getChildPosition(recyclerView.getChildAt(0)) == 0; boolean topOfFirstItemVisiblePull = recyclerView.getChildAt(0).getTop() == recyclerView .getChildAt(0).getTop(); ; enable = firstItemVisiblePull && topOfFirstItemVisiblePull; pullToRefreshView.setEnabled(enable); } }); addPlayer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int viewXY[] = new int[2]; v.getLocationOnScreen(viewXY); if (mListener != null) { mListener.onFragmentInteraction("add_game", viewXY[0], viewXY[1]); } } }); } else { if (!fromDrawer) { RelativeLayout gamesLayout = (RelativeLayout) rootView.findViewById(R.id.gamesLayout); final SwipeDismissBehavior<LinearLayout> behavior = new SwipeDismissBehavior(); behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END); behavior.setStartAlphaSwipeDistance(1.0f); behavior.setSensitivity(0.15f); behavior.setListener(new SwipeDismissBehavior.OnDismissListener() { @Override public void onDismiss(final View view) { GamesFragment myFragC1 = (GamesFragment) getFragmentManager().findFragmentByTag("games"); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.remove(myFragC1); transaction.commitAllowingStateLoss(); getFragmentManager().executePendingTransactions(); mActivity.onBackPressed(); } @Override public void onDragStateChanged(int i) { } }); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) gamesLayout .getLayoutParams(); params.setBehavior(behavior); } //fastScroller.setRecyclerView(mRecyclerView, null); pullToRefreshView.setEnabled(false); addPlayer.setVisibility(View.GONE); } mProgress = (LinearLayout) rootView.findViewById(R.id.progressContainer); mText = (TextView) rootView.findViewById(R.id.LoadingText); // LinearLayoutManager is used here, this will layout the elements in a similar fashion // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how // elements are laid out. mLayoutManager = new LinearLayoutManager(mActivity); mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER; if (savedInstanceState != null) { // Restore saved layout manager type. mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER); } setRecyclerViewLayoutManager(mCurrentLayoutManagerType); //mAdapter = new CustomAdapter(mDataset, mDataset_Thumb); mAdapter = new GameAdapter(this, mActivity, mSearchQuery, fromDrawer, playListType, sortType, fragmentName, currentYear); // Set CustomAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); if (mSearch != null) { mSearch.setHint( getString(R.string.filter) + mAdapter.getItemCount() + getString(R.string.filter_games)); } fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin); mRecyclerView.addOnScrollListener(new MyRecyclerScroll() { @Override public void show() { addPlayer.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start(); } @Override public void hide() { addPlayer.animate().translationY(addPlayer.getHeight() + fabMargin) .setInterpolator(new AccelerateInterpolator(2)).start(); } }); if (mSearch != null) { mSearch.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text mSearchQuery = cs.toString(); //initDataset(); mAdapter = new GameAdapter(GamesFragment.this, mActivity, mSearchQuery, fromDrawer, playListType, sortType, fragmentName, currentYear); // Set CustomAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); if (mSearch != null) { mSearch.setHint(getString(R.string.filter) + mAdapter.getItemCount() + getString(R.string.filter_games)); } } @Override public void afterTextChanged(Editable editable) { } }); mCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!mSearch.getText().toString().equals("")) { mSearchQuery = ""; mSearch.setText(mSearchQuery); //mActivity.onBackPressed(); } //fastScroller.scrollHider(); InputMethodManager inputManager = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); mSearch.clearFocus(); mRecyclerView.requestFocus(); initDataset(false); if (mSearch != null) { mSearch.setHint(getString(R.string.filter) + mAdapter.getItemCount() + getString(R.string.filter_games)); } } }); } Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); if (Game.findBaseGames("", sortType, year).size() == 0) { initDataset(false); } else { mText.setVisibility(View.GONE); mProgress.setVisibility(View.GONE); mRecyclerView.setVisibility(View.VISIBLE); } // END_INCLUDE(initializeRecyclerView) return rootView; }
From source file:com.lastsoft.plog.adapter.GameAdapter.java
public void playPopup(View v, final int position) { try {//from w ww. ja va 2 s.co m InputMethodManager inputManager = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception ignored) { } PopupMenu popup = new PopupMenu(mActivity, v); MenuInflater inflater = popup.getMenuInflater(); if (games.get(position).expansionFlag == true) { inflater.inflate(R.menu.game_expansion_overflow, popup.getMenu()); } else { inflater.inflate(R.menu.game_overflow, popup.getMenu()); } if (games.get(position).gameBGGID == null || games.get(position).gameBGGID.equals("")) { popup.getMenu().removeItem(R.id.update_bgg); popup.getMenu().removeItem(R.id.open_bgg); popup.getMenu().removeItem(R.id.add_bgg); } if (games.get(position).gameBoxImage == null || games.get(position).gameBoxImage.equals("")) { popup.getMenu().removeItem(R.id.view_box_photo); } if (games.get(position).taggedToPlay <= 0) { popup.getMenu().removeItem(R.id.remove_bucket_list); } else { popup.getMenu().removeItem(R.id.add_bucket_list); } SharedPreferences app_preferences; app_preferences = PreferenceManager.getDefaultSharedPreferences(mActivity); long currentDefaultPlayer = app_preferences.getLong("defaultPlayer", -1); if (games.get(position).collectionFlag || currentDefaultPlayer == -1) { popup.getMenu().removeItem(R.id.add_bgg); } //check if this game has been played //if so, can't delete if (GamesPerPlay.hasGameBeenPlayed(games.get(position))) { popup.getMenu().removeItem(R.id.delete_game); } popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.delete_game: ((MainActivity) mActivity).deleteGame(games.get(position).getId()); return true; case R.id.add_tenbyten: ((MainActivity) mActivity).addToTenXTen(games.get(position).getId()); return true; case R.id.view_plays: if (games.get(position).expansionFlag == true) { ((MainActivity) mActivity).openPlays(games.get(position).gameName, false, 9, fragmentName, currentYear); } else { ((MainActivity) mActivity).openPlays(games.get(position).gameName, false, 0, fragmentName, currentYear); } return true; case R.id.open_bgg: Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://bgg.cc/boardgame/" + games.get(position).gameBGGID)); mActivity.startActivity(browserIntent); return true; case R.id.update_bgg: mPosition = position; if (games.get(position).expansionFlag == true) { ((MainActivity) mActivity).searchGameViaBGG(games.get(position).gameName, false, true, -1); } else { ((MainActivity) mActivity).searchGameViaBGG(games.get(position).gameName, false, false, -1); } return true; case R.id.add_bgg: mPosition = position; ((MainActivity) mActivity).updateGameViaBGG(games.get(position).gameName, games.get(position).gameBGGID, "", true, false); return true; case R.id.add_box_photo: ((GamesFragment) mFragment).captureBox(games.get(position)); return true; case R.id.view_box_photo: String[] photoParts = games.get(position).gameBoxImage.split("/"); File newFile = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/Plog/", photoParts[photoParts.length - 1]); Uri contentUri = FileProvider.getUriForFile(mActivity.getApplicationContext(), "com.lastsoft.plog.fileprovider", newFile); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(contentUri, "image/*"); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); mActivity.startActivity(intent); return true; case R.id.add_bucket_list: String[] ids = TimeZone.getAvailableIDs(-5 * 60 * 60 * 1000); // if no ids were returned, something is wrong. get out. //if (ids.length == 0) // System.exit(0); // begin output //System.out.println("Current Time"); // create a Eastern Standard Time time zone SimpleTimeZone pdt = new SimpleTimeZone(-5 * 60 * 60 * 1000, ids[0]); // set up rules for daylight savings time pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); // create a GregorianCalendar with the Pacific Daylight time zone // and the current date and time Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime); int i = (int) (calendar.getTime().getTime() / 1000); games.get(position).taggedToPlay = i; games.get(position).save(); Snackbar.make(((GamesFragment) mFragment).mCoordinatorLayout, games.get(position).gameName + mActivity.getString(R.string.added_to_bl), Snackbar.LENGTH_LONG) .setAction(mActivity.getString(R.string.undo), new View.OnClickListener() { @Override public void onClick(View view) { games.get(position).taggedToPlay = 0; games.get(position).save(); if (playListType == 2) { ((MainActivity) mActivity).onFragmentInteraction("refresh_games"); } } }).show(); // Do not forget to show! return true; case R.id.remove_bucket_list: final int taggedToPlay = games.get(position).taggedToPlay; final Game gameToUndo = games.get(position); games.get(position).taggedToPlay = 0; games.get(position).save(); Snackbar.make(((GamesFragment) mFragment).mCoordinatorLayout, games.get(position).gameName + mActivity.getString(R.string.removed_from_bl), Snackbar.LENGTH_LONG) .setAction(mActivity.getString(R.string.undo), new View.OnClickListener() { @Override public void onClick(View view) { gameToUndo.taggedToPlay = taggedToPlay; gameToUndo.save(); if (playListType == 2) { ((MainActivity) mActivity).onFragmentInteraction("refresh_games"); } } }).show(); // Do not forget to show! if (playListType == 2) { ((MainActivity) mActivity).onFragmentInteraction("refresh_games"); } return true; default: return false; } } } ); popup.show(); }
From source file:com.mastercard.masterpasswallet.fragments.addcard.VerifyCardFragment.java
private void hideKeyboard() { // Check if no view has focus: View view = getActivity().getCurrentFocus(); if (view != null) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }// ww w . j a v a 2s. c o m }
From source file:com.umeng.message.example.MainActivity.java
public void hideInputKeyboard() { ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }