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:com.lastsoft.plog.adapter.GroupAdapter.java
public void groupPopup(View v, final int position) { try {/*from w w w .j a v a 2 s .c o 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(); inflater.inflate(R.menu.group_overflow, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.view_plays: ((MainActivity) mActivity).openPlays(groups.get(position).getId() + "", false, 1, mActivity.getString(R.string.title_players), currentYear); return true; default: return false; } } }); popup.show(); }
From source file:com.near.chimerarevo.fragments.SearchFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);/* w ww . ja v a2 s .co m*/ ((BaseActivity) getActivity()).getToolbar().setTitle(getResources().getString(R.string.action_search)); mJson = new ArrayList<>(); arrayList = new ArrayList<>(); mAdapter = new PostsRecyclerAdapter(getActivity(), arrayList, false); mListView.setHasFixedSize(false); final LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); mListView.setLayoutManager(llm); mListView.setAdapter(mAdapter); mFab.attachToRecyclerView(mListView); mFab.setOnClickListener(this); mListView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); int visibleItemCount = llm.getChildCount(); int totalItemCount = llm.getItemCount(); int pastVisiblesItems = llm.findFirstVisibleItemPosition(); if ((visibleItemCount + pastVisiblesItems) < totalItemCount) { if (Math.abs(dy) > mScrollThreshold) { if (dy > 0) mFab.hide(); else mFab.show(); } } else mFab.show(); } }); if (readOfflineFile()) { clickCounter++; mFab.setEnabled(true); } mBtn.setOnClickListener(this); mText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { if (mText.getText().toString().length() > 0) { InputMethodManager in = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); in.hideSoftInputFromWindow(mText.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); mText.setError(null); mFab.setEnabled(true); performUpdate(); } else { mText.setError(getResources().getString(R.string.error_field_required)); mText.requestFocus(); } } return true; } }); }
From source file:com.bloodtolife.bloodapp.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_comments, container, false); db = new SQLiteHandler(getActivity()); RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.comment_list); mEditText = (EditText) rootView.findViewById(R.id.editText); final Button sendButton = (Button) rootView.findViewById(R.id.send_comment); final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef); mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.comment_item, CommentViewHolder.class, commentsRef) { @Override/*from www . java2 s . c o m*/ protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) { user_ = db.getUserDetails(); viewHolder.commentAuthor.setText(user_.get("name")); GlideUtil.loadProfileIcon(user_.get("profile_pic_url"), viewHolder.commentPhoto); viewHolder.authorRef = user_.get("uid"); viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp())); viewHolder.commentText.setText(comment.getText()); } }; sendButton.setEnabled(false); mEditText.setHint(R.string.new_comment_hint); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); mEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { sendButton.setEnabled(true); } else { sendButton.setEnabled(false); } } }); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear input box and hide keyboard. final Editable commentText = mEditText.getText(); mEditText.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null) { Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show(); } Comment comment = new Comment(user.getDisplayName(), commentText.toString(), ServerValue.TIMESTAMP); commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError error, DatabaseReference firebase) { if (error != null) { Log.w(TAG, "Error posting comment: " + error.getMessage()); Toast.makeText(getActivity(), "Error posting comment.", Toast.LENGTH_SHORT).show(); mEditText.setText(commentText); } } }); } }); mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity())); mCommentsView.setAdapter(mAdapter); return rootView; }
From source file:com.mehmetakiftutuncu.eshotroid.activities.BusListActivity.java
private void showHideKeyboard(boolean show) { InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (inputManager != null && toolbarSearchEditText != null) { if (show) { toolbarSearchEditText.requestFocus(); inputManager.showSoftInput(toolbarSearchEditText, InputMethodManager.SHOW_IMPLICIT); } else {/*from w w w . ja v a 2s . c o m*/ toolbarSearchEditText.clearFocus(); inputManager.hideSoftInputFromWindow(toolbarSearchEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } }
From source file:com.velli.passwordmanager.FragmentLockScreen.java
@Override public void onClick(View v) { if (v.getId() == R.id.pin_lock_ok_button && getView() != null) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getView().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); if (mAction == ACTION_COMPARE_PASSWORD) { checkIfPasswordIsCorrect();// w w w . j a va 2 s . com } else { createNewPassword(); } } }
From source file:com.janardhan.blood2life.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_comments, container, false); Log.d("mPostRef", mPostRef); db = new SQLiteHandler(getActivity()); user_ = db.getUserDetails();/* w w w . java2 s. co m*/ RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.comment_list); mEditText = (EditText) rootView.findViewById(R.id.editText); final Button sendButton = (Button) rootView.findViewById(R.id.send_comment); final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef); mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.comment_item, CommentViewHolder.class, commentsRef) { @Override protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) { String aurth = comment.getAuthor(); viewHolder.commentAuthor.setText(comment.getAuthor()); GlideUtil.loadProfileIcon(comment.getUser_propic(), viewHolder.commentPhoto); viewHolder.authorRef = comment.getUser_id(); viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp())); viewHolder.commentText.setText(comment.getText()); } }; sendButton.setEnabled(false); mEditText.setHint(R.string.new_comment_hint); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); mEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { sendButton.setEnabled(true); } else { sendButton.setEnabled(false); } } }); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear input box and hide keyboard. final Editable commentText = mEditText.getText(); mEditText.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null) { Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show(); } Comment comment = new Comment(user.getDisplayName(), commentText.toString(), ServerValue.TIMESTAMP, user_.get("uid"), user_.get("profile_pic_url")); commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError error, DatabaseReference firebase) { if (error != null) { Log.w(TAG, getString(R.string.error_posting) + error.getMessage()); Toast.makeText(getActivity(), R.string.error_posting, Toast.LENGTH_SHORT).show(); mEditText.setText(commentText); } } }); } }); mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity())); mCommentsView.setAdapter(mAdapter); return rootView; }
From source file:com.sft.fragment.SchoolsFragment.java
private void initData() { searchSchool.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchSchool.setOnEditorActionListener(new OnEditorActionListener() { @Override//w w w . jav a 2s. c o m public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { // ?? ((InputMethodManager) searchSchool.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); // ? LogUtil.print("?"); schoolname = searchSchool.getText().toString().trim(); searchSchool(true); return true; } return false; } }); }
From source file:com.lchtime.safetyexpress.ui.chat.hx.activity.GroupsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.em_fragment_groups); initTitle();//from w w w . j a va2s .c om instance = this; inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getGroupsData(); //grouplist = EMClient.getInstance().groupManager().getAllGroups(); groupListView = (ListView) findViewById(R.id.list); //show group list groupAdapter = new GroupAdapter(this, 1, mGroupList); groupListView.setAdapter(groupAdapter); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); //pull down to refresh swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Thread() { @Override public void run() { try { EMClient.getInstance().groupManager().getJoinedGroupsFromServer(); handler.sendEmptyMessage(0); } catch (HyphenateException e) { e.printStackTrace(); handler.sendEmptyMessage(1); } } }.start(); } }); groupListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == 1) { // create a new group startActivityForResult(new Intent(GroupsActivity.this, NewGroupActivity.class), 0); } else if (position == 2) { // join a public group startActivityForResult( new Intent(GroupsActivity.this, AddContactActivity.class).putExtra("group", "1"), 0); } else { // enter group chat Intent intent = new Intent(GroupsActivity.this, ChatActivity.class); // it is group chat intent.putExtra("chatType", Constant.CHATTYPE_GROUP); intent.putExtra("userId", groupAdapter.getItem(position - 3).sq_group_id); startActivityForResult(intent, 0); } } }); groupListView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); }
From source file:xj.property.fragment.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/* ww w. j ava 2 s .c om*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList, sidebar); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = XjApplication.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(getActivity(), GroupsActivity.class)); } else { User contact = XJContactHelper.selectContact(username); // if(contact.getSort().equals("5")){ // startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", contact.getEmobId())); // }else if(contact.getSort().equals("1")) { // // } Log.i("onion", contact.toString()); // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", contact.getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); }
From source file:com.myapps.upesse.upes_spefest.ui.activity.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.activity_comments, container, false); RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.rvComments); mEditText = (EditText) rootView.findViewById(R.id.etComment); final Button sendButton = (Button) rootView.findViewById(R.id.btnSendComment); final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef); mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.item_comment, CommentViewHolder.class, commentsRef) { @Override/*from w ww. j av a2 s .c om*/ protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) { Author author = comment.getAuthor(); viewHolder.commentAuthor.setText(author.getFull_name()); if (author.getProfile_picture() == null) { viewHolder.commentPhoto.setImageResource(R.drawable.ic_person_outline_black); } else { try { GlideUtil.loadProfileIcon(author.getProfile_picture(), viewHolder.commentPhoto); } catch (Exception e) { } } viewHolder.authorRef = author.getUid(); viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp())); viewHolder.commentText.setText(comment.getText()); } }; sendButton.setEnabled(false); mEditText.setHint(R.string.new_comment_hint); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); mEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { sendButton.setEnabled(true); } else { sendButton.setEnabled(false); } } }); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear input box and hide keyboard. final Editable commentText = mEditText.getText(); mEditText.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null) { Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show(); } Author author = new Author(user.getDisplayName(), user.getPhotoUrl() != null ? user.getPhotoUrl().toString() : null, user.getUid()); Comment comment = new Comment(author, commentText.toString(), ServerValue.TIMESTAMP); commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError error, DatabaseReference firebase) { if (error != null) { Log.w(TAG, "Error posting comment: " + error.getMessage()); Toast.makeText(getActivity(), "Error posting comment.", Toast.LENGTH_SHORT).show(); mEditText.setText(commentText); } } }); } }); mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity())); mCommentsView.setAdapter(mAdapter); return rootView; }