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.soramitsu.iroha.view.activity.MainActivity.java

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    Log.d(TAG, "dispatchTouchEvent: ");
    inputMethodManager.hideSoftInputFromWindow(binding.container.getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);
    binding.container.requestFocus();//from   w  w  w .j a v  a 2  s. c o  m
    return super.dispatchTouchEvent(ev);
}

From source file:com.xabber.android.ui.activity.ChatActivity.java

public static void hideKeyboard(Activity activity) {
    // Check if no view has focus:
    View view = activity.getCurrentFocus();
    if (view != null) {
        InputMethodManager inputManager = (InputMethodManager) activity
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }/*from  ww w .  ja v a2s  . co m*/
}

From source file:com.efithealth.app.activity.BaseActivity.java

private void HideSoftInput(IBinder token) {
    if (token != null) {
        InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        manager.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS);
    }//from   ww  w .java 2s .c o m
}

From source file:com.wenwen.chatuidemo.activity.ContactSickFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    contactList = new ArrayList<MyUser1>();
    // ?contactlist
    getContactList();// w  ww . j a v a2s  . c om
    // adapter
    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            startActivity(new Intent(getActivity(), SickInfo.class).putExtra("uid",
                    contactList.get(position).getAccount_id()));
        }
    });
    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;
        }
    });

}

From source file:net.survivalpad.android.ArticleEditActivity.java

@Override
protected void onResume() {
    super.onResume();
    mDb = new DbManager(this, DbManager.FILE_NAME, null).getWritableDatabase();

    /* IME?? *//*w ww . ja  v a  2 s  .c  o m*/
    sHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            View view = getCurrentFocus();
            if (view != null) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            }
        }
    }, 50);
}

From source file:com.dmbstream.android.activity.SearchResultsActivity.java

private void search() {
    if (inputMethodManager != null) {
        inputMethodManager.hideSoftInputFromWindow(searchBox.getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    }/*w  ww. j a  va  2  s  . co m*/
    query = searchBox.getText().toString();
    if (query.length() > 0) {
        refresh();
    }
}

From source file:com.example.reabar.wimc.Fragments.CarScreenFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_car_screen, container, false);

    TextView text = (TextView) view.findViewById(R.id.deleteTextView);
    Button addUserButton = (Button) view.findViewById(R.id.addUserButton);

    Typeface english = Typeface.createFromAsset(getActivity().getAssets(), "KOMIKAX_.ttf"); // create a typeface from the raw ttf
    Typeface hebrew = Typeface.createFromAsset(getActivity().getAssets(), "OpenSansHebrew-Bold.ttf"); // create a typeface from the raw ttf
    if (Locale.getDefault().getDisplayLanguage().equals("")) {
        addUserButton.setTypeface(hebrew);
        text.setTypeface(hebrew);// w  w  w.  ja va  2 s. co m
    } else {
        addUserButton.setTypeface(english);
        text.setTypeface(english);
    }

    if (sharedUsersList == null) {
        sharedUsersList = new ArrayList<>();
    }

    if (sharedUsersList.isEmpty()) {
        text.setVisibility(View.GONE);
    }

    TextView licenseTextView = (TextView) view.findViewById(R.id.cars_list_row_car_license);
    licenseTextView.setText(carLicense);
    TextView modelCompanyTextView = (TextView) view.findViewById(R.id.cars_list_row_car_model_company);
    modelCompanyTextView.setText(modelCompany);

    list = (ListView) view.findViewById(R.id.listSharedUsersID);
    adapter = new MyUsersCarAdapter();
    list.setAdapter(adapter);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            car.removeCarUser(sharedUsersList.get(position));
            adapter.notifyDataSetChanged();
            Toast.makeText(MyApplication.getAppActivity(), "User removed successfully", Toast.LENGTH_SHORT)
                    .show();
        }
    });

    emailSharedInput = (EditText) view.findViewById(R.id.emailSharedinput);
    addUserButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            //hide keyboard after click
            InputMethodManager inputManager = (InputMethodManager) getContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);

            if (emailSharedInput.getText().toString().matches("")) {
                Toast.makeText(MyApplication.getAppActivity(), "You must enter email of the shared user",
                        Toast.LENGTH_SHORT).show();
            } else {
                //addUser user to car by email
                final String userEmail = emailSharedInput.getText().toString();
                //car.setCarUser(userEmail, true);
                //car.setNewCarUser(userEmail);
                Model.getInstance().setCarUser(car, userEmail);
                emailSharedInput.setText("");
                adapter.notifyDataSetChanged();
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                //sharedUsersList.add(userEmail);
                Object[] data = new Object[] { car };
                fragmentCommunicator.passData(data, "CarScreenFragment");
            }
        }
    });

    return view;
}

From source file:click.kobaken.rxirohaandroid_sample.view.activity.MainActivity.java

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    inputMethodManager.hideSoftInputFromWindow(binding.container.getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);
    binding.container.requestFocus();//w  ww . ja  v  a  2 s.com
    return super.dispatchTouchEvent(ev);
}

From source file:com.anykey.balala.activity.BaseActivity.java

protected void hideSoftInputView() {
    if (getCurrentFocus() != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    }/*  w w w .  j  av  a 2 s  . c  o m*/
}

From source file:cn.xcom.helper.chat.ui.RobotsActivity.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.em_fragment_robots);
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mListView = (ListView) findViewById(R.id.list);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_orange_light,
            android.R.color.holo_red_light);
    progressBar = findViewById(R.id.progress_bar);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override//  ww w  .  ja  v a  2s.  c o m
        public void onRefresh() {
            getRobotNamesFromServer();
        }
    });
    Map<String, RobotUser> robotMap = DemoHelper.getInstance().getRobotList();
    if (robotMap != null) {
        robotList.addAll(robotMap.values());
    } else {
        progressBar.setVisibility(View.VISIBLE);
        getRobotNamesFromServer();
    }
    adapter = new RobotAdapter(this, 1, robotList);
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            RobotUser user = (RobotUser) parent.getItemAtPosition(position);
            Intent intent = new Intent();
            intent.setClass(RobotsActivity.this, ChatActivity.class);
            intent.putExtra("userId", user.getUsername());
            startActivity(intent);
        }
    });
    mListView.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;
        }
    });
}