Example usage for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS

List of usage examples for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.

Prototype

int HIDE_NOT_ALWAYS

To view the source code for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.

Click Source Link

Document

Flag for #hideSoftInputFromWindow and InputMethodService#requestShowSelf(int) to indicate that the soft input window should normally be hidden, unless it was originally shown with #SHOW_FORCED .

Usage

From source file:io.imoji.sdk.editor.fragment.TagImojiFragment.java

@Override
public void onViewCreated(View v, @Nullable Bundle savedInstanceState) {
    mImojiIv = (ImageView) v.findViewById(R.id.iv_imoji);
    mTagEditor = v.findViewById(R.id.tag_editor);
    mTagEditor.setBackgroundDrawable(createTagDrawable());
    mTagGrid = (GridLayout) v.findViewById(R.id.gl_tagbox);
    mTaggerEt = (EditText) v.findViewById(R.id.et_tag);
    mTaggerEt.setOnEditorActionListener(mKeyActionListener);
    mUploadButton = (ImageButton) v.findViewById(R.id.ib_upload);
    mUploadButton.setOnClickListener(mOnDoneClickListener);
    mProgress = (ProgressBar) v.findViewById(R.id.imoji_progress);

    mToolbar = (Toolbar) v.findViewById(R.id.imoji_toolbar);
    mToolbar.setNavigationIcon(R.drawable.create_back);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override//from   www  .j av a 2 s  . co  m
        public void onClick(View v) {
            if (isResumed()) {
                getFragmentManager().popBackStack();
                mInputMethodManager.hideSoftInputFromWindow(mTaggerEt.getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);

            }
        }
    });

    mClearInputBt = (ImageButton) v.findViewById(R.id.ib_cancel);
    mClearInputBt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mTaggerEt != null) {
                mTaggerEt.getText().clear();
            }
        }
    });

    View toolbarScrim = v.findViewById(R.id.imoji_toolbar_scrim);
    if (Build.VERSION.SDK_INT >= 16) {
        toolbarScrim.setBackground(ScrimUtil.makeCubicGradientScrimDrawable(0x66000000, 8, Gravity.TOP));
    } else {
        toolbarScrim
                .setBackgroundDrawable(ScrimUtil.makeCubicGradientScrimDrawable(0x66000000, 8, Gravity.TOP));
    }

    if (savedInstanceState != null) {
        List<String> tags = savedInstanceState.getStringArrayList(TAGS_BUNDLE_ARG_KEY);
        for (String tag : tags) {
            addTagChip(tag);
        }

        mProgress.setVisibility(
                savedInstanceState.getBoolean(IS_PROCESSING_BUNDLE_ARG_KEY) ? View.VISIBLE : View.GONE);
    }

}

From source file:com.hx.hxchat.activity.ChatHistoryFragment.java

private void initData() {
    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override/*www.ja va  2 s .  c  om*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            EMContact emContact = adapter.getItem(position);
            if (adapter.getItem(position).getUsername().equals(BaseApplication.getApplication().getUserName()))
                Toast.makeText(getActivity(), "??", 0).show();
            else {
                if (EMChatManager.getInstance().isConnected()) {
                    // ??
                    Intent intent = new Intent(getActivity(), ChatActivity.class);
                    if (emContact instanceof EMGroup) {
                        // it is group chat
                        intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
                        intent.putExtra("groupId", ((EMGroup) emContact).getGroupId());
                    } else {
                        // it is single chat
                        intent.putExtra("userId", emContact.getUsername());
                        intent.putExtra("userName", emContact.getNick());

                        // intent.putExtra("userId",
                        // adapter.m_User_s.get(position).getM_name());
                    }
                    startActivity(intent);
                } else {
                    BaseApplication.getApplication().isHxLogined = false;
                    // BaseApplication.getApplication().Hxlogin();
                    Toast.makeText(getActivity(), "???", 0).show();
                }
            }
        }
    });

    // ??
    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;
        }
    });

    listView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            if (vibrator == null)
                vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);

            long[] pattern = { 100, 100 };
            vibrator.vibrate(30);

            String title = "";
            EMContact item = adapter.getItem(position);

            if (item instanceof EMGroup) {
                title = ((EMGroup) item).getGroupName();
            } else {

                title = item.getNick();

            }

            showMyDialog(title, adapter, position);
            return false;
        }
    });
    //      registerForContextMenu(listView);

    if (!CommonUtils.isNetWorkConnected(context)) {
        return;
    }
    // ?

    new GetDataAcyncTask().execute();
    setLoadDataComplete(new isLoadDataListener() {
        @Override
        public void loadStart() {
            onPostExecuting = true;
            if (!progressDialog.isShowing() && !hidden) {
                // progressDialog.show();

            }
        }

        @Override
        public void loadComplete() {
            onPostExecuting = false;
            if (progressDialog.isShowing() && !hidden) {
                // progressDialog.dismiss();

            }
        }

        @Override
        public void progress(int progress) {

        }
    });

}

From source file:com.xxxifan.devbox.core.util.ViewUtils.java

public static void showKeyboard(EditText editor) {
    ((InputMethodManager) editor.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(0,
            InputMethodManager.HIDE_NOT_ALWAYS);
    editor.requestFocus();/*from w w  w  .  j  a  va  2  s.  c  om*/
}

From source file:com.hx.hxchat.activity.ContactlistFragment.java

/**
 * ?/*from w ww .j  a v  a2  s.c  o  m*/
 * 
 * @param activity
 * @param contactList2
 *            Created by Administrator
 */
private void initContactAdapter(FragmentActivity activity, final List<User> contactList) {
    if (contactList == null || sidebar == null)
        return;
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (EMChatManager.getInstance().isConnected()) {
                String username = adapter.getItem(position).getUsername();
                if (Constant.NEW_FRIENDS_USERNAME.equals(username)) {
                    // ?
                    User user = BaseApplication.getApplication().getContactList()
                            .get(Constant.NEW_FRIENDS_USERNAME);
                    user.setUnreadMsgCount(0);
                    startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));

                } else if (Constant.GROUP_USERNAME.equals(username)) {
                    // TODO ??
                    startActivity(new Intent(getActivity(), GroupsActivity.class));

                } else {
                    // demo??
                    // 
                    // TextView tv = (TextView)
                    // view.findViewById(R.id.name); // 
                    String imageHeaderPath = adapter.getItem(position).getAvatar(); // ?
                    startActivity(
                            new Intent(getActivity(), ChatActivity.class).putExtra("path", imageHeaderPath)
                                    .putExtra("userId", adapter.getItem(position).getUsername())
                                    .putExtra("userName", contactList.get(position).getNick()));
                    // startActivity(new Intent(getActivity(),
                    // ChatActivity.class).putExtra("userId",
                    // adapter.getItem(position).getUsername()));
                }
            } else {
                BaseApplication.getApplication().isHxLogined = false;
                //               BaseApplication.getApplication().Hxlogin();
                //               EMChatManager.getInstance().
                Toast.makeText(getActivity(), "??", 0).show();
            }
        }
    });
    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;
        }
    });

    registerForContextMenu(listView);

}

From source file:net.zionsoft.obadiah.ui.activities.SearchActivity.java

private void search(final String query) {
    if (TextUtils.isEmpty(query)) {
        return;/*from   w  w w.ja va 2s  .c  om*/
    }

    final View currentFocus = getCurrentFocus();
    if (currentFocus != null) {
        ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
                .hideSoftInputFromWindow(currentFocus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }

    loadingSpinner.setVisibility(View.VISIBLE);
    searchResultListView.setVisibility(View.GONE);

    recentSearches.saveRecentQuery(query, null);
    bible.searchVerses(nonConfigurationData.currentTranslation, query, new Bible.OnVersesLoadedListener() {
        @Override
        public void onVersesLoaded(List<Verse> verses) {
            if (verses == null) {
                DialogHelper.showDialog(SearchActivity.this, false, R.string.dialog_retry,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                search(query);
                            }
                        }, null);
                return;
            }

            AnimationHelper.fadeOut(loadingSpinner);
            AnimationHelper.fadeIn(searchResultListView);

            searchResultListAdapter.setVerses(verses);
            searchResultListAdapter.notifyDataSetChanged();
            searchResultListView.post(new Runnable() {
                @Override
                public void run() {
                    searchResultListView.setSelection(0);
                }
            });

            nonConfigurationData.verses = verses;

            String text = getResources().getString(R.string.toast_verses_searched, verses.size());
            Toast.makeText(SearchActivity.this, text, Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:com.example.hello.mymap.activity.GroupsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.em_fragment_groups);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from w ww .  ja  va 2  s.  c  o m*/
    title = (TextView) findViewById(R.id.tv_title);
    instance = this;
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    grouplist = EMClient.getInstance().groupManager().getAllGroups();
    cgroupListView = (ListView) findViewById(R.id.list);
    //show group list
    groupAdapter = new GroupAdapter(this, 1, grouplist);

    roomList = EMClient.getInstance().chatroomManager().getAllChatRooms();
    Log.v("saa", roomList.size() + "");
    chatRoomAdapter = new ChatRoomAdapter(this, 1, roomList);

    currentAdapter = groupAdapter;
    cgroupListView.setAdapter(currentAdapter);
    //   searchView= (SearchView) findViewById(R.id.menu_search);
    //      searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
    //         @Override
    //         public void onFocusChange(View view, boolean b) {
    //            Log.v("sasa","jhhh");
    //         }
    //      });
    tablayout = (TabLayout) findViewById(R.id.tb_tabs);
    tablayout.addTab(tablayout.newTab().setText(""));
    tablayout.addTab(tablayout.newTab().setText(""));
    tablayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            if (tab.getPosition() != currentTab) {
                if (tab.getPosition() == 0) {
                    //currentTab=0;
                    currentAdapter = groupAdapter;
                    //cgroupListView.setAdapter(groupAdapter);
                } else if (tab.getPosition() == 1) {
                    //currentTab=1;
                    currentAdapter = chatRoomAdapter;
                }
                cgroupListView.setAdapter(currentAdapter);
                currentTab = tab.getPosition();
            }

        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    });
    currentTab = tablayout.getSelectedTabPosition();
    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);
    //
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            new Thread() {
                @Override
                public void run() {
                    if (currentTab == 0) {
                        try {
                            EMClient.getInstance().groupManager().getJoinedGroupsFromServer();
                        } catch (HyphenateException e) {
                            e.printStackTrace();
                            handler.sendEmptyMessage(1);
                        }
                    }
                    handler.sendEmptyMessage(0);
                }
            }.start();
        }
    });
    cgroupListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //            if (position == 1) {
            //               // ?
            //               startActivityForResult(new Intent(GroupsActivity.this, TestActivity.class), 0);
            //            } else if (position == 2) {
            //               // 
            //               startActivityForResult(new Intent(GroupsActivity.this, TestActivity.class), 0);
            //            } else {
            // ?
            Intent intent = new Intent(GroupsActivity.this, ChatActivity.class);
            // it is group chat
            if (currentTab == 0) {
                intent.putExtra("chatType", Constant.CHATTYPE_GROUP);
                intent.putExtra("userId", groupAdapter.getItem(position).getGroupId());
            } else if (currentTab == 1) {
                intent.putExtra("chatType", Constant.CHATTYPE_CHATROOM);
                intent.putExtra("userId", chatRoomAdapter.getItem(position).getId());
            }

            startActivityForResult(intent, 0);
        }
        //         }
        //
    });
    cgroupListView.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:com.redwoodsystems.android.apps.SearchListFragment.java

private void dismissKeyboard() {
    if (this.getActivity().getCurrentFocus() != null
            && this.getActivity().getCurrentFocus() instanceof EditText) {
        InputMethodManager inputManager = (InputMethodManager) this.getActivity()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(this.getActivity().getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    }/*w  w  w. ja  v  a 2 s  . c  o  m*/
}

From source file:com.shengtao.chat.chatUI.activity.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    //T??home???appcrash
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;//from ww w .  j a  va2 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();
    //?
    query = (EditText) getView().findViewById(R.id.query);
    query.setHint(R.string.search);
    clearSearch = (ImageButton) getView().findViewById(R.id.search_clear);
    query.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s);
            if (s.length() > 0) {
                clearSearch.setVisibility(View.VISIBLE);
            } else {
                clearSearch.setVisibility(View.INVISIBLE);
            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable s) {
        }
    });
    clearSearch.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            query.getText().clear();
            hideSoftKeyboard();
        }
    });

    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList);
    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 = UIApplication.getContext().getContactList().get(Constant.NEW_FRIENDS_USERNAME);
                user.setUnreadMsgCount(0);
                startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
            } else {
                // demo??
                startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId",
                        adapter.getItem(position).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);

    progressBar = (View) getView().findViewById(R.id.progress_bar);

    contactSyncListener = new HXContactSyncListener();
    HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener);

    blackListSyncListener = new HXBlackListSyncListener();
    HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener);

    if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) {
        progressBar.setVisibility(View.VISIBLE);
    } else {
        progressBar.setVisibility(View.GONE);
    }
}

From source file:org.ymegane.android.approom.AppDisplayFragment.java

private void initSearchView(MenuItem item) {
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
    searchView.setQueryHint(getString(R.string.search_hint));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override//from   w  w  w  .  jav  a  2  s  .c om
        public boolean onQueryTextSubmit(String s) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            updateSearchResult(s);
            return true;
        }
    });
    searchView.setOnCloseListener(new SearchView.OnCloseListener() {
        @Override
        public boolean onClose() {
            updateSearchResult(null);
            return false;
        }
    });
    searchView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
            }
        }
    });
}

From source file:com.hybris.mobile.activity.LoginActivity.java

@Override
public void onReceiveResult(RESTLoaderResponse restLoaderResponse, WebserviceMethodEnums webserviceEnumMethod) {

    if (restLoaderResponse.getCode() == RESTLoaderResponse.SUCCESS) {

        switch (webserviceEnumMethod) {
        case METHOD_LOGIN:
            Hybris.setUserOnline(true);/* ww w  . j  a  v  a  2s .c  o  m*/
            Hybris.setUsername(mEmailView.getText().toString());

            if (getCurrentFocus() != null) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
            }

            showMessage(getString(R.string.login_successful));

            // Redirection to the right intent
            if (getIntent().hasExtra(DataConstants.INTENT_DESTINATION)) {
                new CheckDataBeforeLaunchingIntentTask().execute();
            } else {
                finish();
            }
            break;
        case METHOD_REQUEST_PASSWORD:
            showMessage(getString(R.string.new_password_sent));
            break;

        default:
            break;
        }
    } else if (restLoaderResponse.getCode() == RESTLoaderResponse.ERROR) {
        switch (webserviceEnumMethod) {
        case METHOD_LOGIN:
            showMessage(getString(R.string.error_login));
            break;

        default:
            break;
        }
    }
}