Example usage for android.view.inputmethod InputMethodManager isAcceptingText

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

Introduction

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

Prototype

public boolean isAcceptingText() 

Source Link

Document

Return true if the currently served view is accepting full text edits.

Usage

From source file:Main.java

public static void dismissKeyBoard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isAcceptingText()) { // verify if the soft keyboard is open
        imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
    }//from  ww  w .  j  a  v  a2 s.c  o  m
}

From source file:Main.java

public static void dismissKeyboard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE);
    if (imm.isAcceptingText()) { // verify if the soft keyboard is open
        imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
    }/*ww w.  j  av  a  2s .c o  m*/
}

From source file:com.raulh82vlc.MoviesFinder.ui.activities.MoviesListActivity.java

public void clearSearchFocus() {
    if (mSearchView != null) {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isAcceptingText()) {
            imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0);
            mSearchView.clearFocus();/*  ww w  . j a v  a  2s.  co  m*/
        }
    }
}

From source file:org.akvo.rsr.up.ProjectListActivity.java

private void hideSoftKeyBoard() {
    InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);

    if (imm.isAcceptingText()) { // verify if the soft keyboard is open                      
        imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
    }/*from w ww .  java2 s.c  o m*/
}

From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java

private void exitEditTagsMode() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ((ImageButton) getActivity().findViewById(R.id.edit_tags_btn))
                .setImageResource(R.drawable.ic_done_anim);
        Drawable editIcon = ((ImageButton) getActivity().findViewById(R.id.edit_tags_btn)).getDrawable();
        ((Animatable) editIcon).start();
    } else/*from   w  ww .  j a  va 2  s  .com*/
        ((ImageButton) getActivity().findViewById(R.id.edit_tags_btn)).setImageResource(R.drawable.ic_edit);

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

    EditText songTV = (EditText) getActivity().findViewById(R.id.song);
    EditText artistTV = ((EditText) getActivity().findViewById(R.id.artist));
    EditText newLyrics = (EditText) getActivity().findViewById(R.id.edit_lyrics);

    songTV.setInputType(InputType.TYPE_NULL);
    artistTV.setInputType(InputType.TYPE_NULL);
    songTV.setBackgroundColor(Color.TRANSPARENT);
    artistTV.setBackgroundColor(Color.TRANSPARENT);

    String txt = mLrcThread == null ? null : mLyrics.getText();
    if (txt == null)
        txt = "";

    File musicFile = Id3Reader.getFile(getActivity(), mLyrics.getOriginalArtist(), mLyrics.getOriginalTrack());

    if (!mLyrics.getArtist().equals(artistTV.getText().toString())
            || !mLyrics.getTitle().equals(songTV.getText().toString())
            || !Html.fromHtml(txt).toString().equals(newLyrics.getText().toString())) {
        mLyrics.setArtist(artistTV.getText().toString());
        mLyrics.setTitle(songTV.getText().toString());
        mLyrics.setText(newLyrics.getText().toString().replaceAll("\n", "<br/>"));
        if (PermissionsChecker.requestPermission(getActivity(), "android.permission.WRITE_EXTERNAL_STORAGE", 0,
                Id3Writer.REQUEST_CODE))
            new Id3Writer(this).execute(mLyrics, musicFile);
    } else
        new Id3Writer(this).onPreExecute();
}