package com.apg.library.corehelper;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;

/**
 * Created by X-tivity on 1/26/2017 AD.
 */

public class InputServiceHelper {

    InputServiceHelper() {

    }

    private InputMethodManager getInputMethodManager(Context context) {
        return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    }

    public void hideKeyboard(Activity activity){

        //android.R.id.content ( http://stackoverflow.com/a/12887919/2077479 )
        View rootView = activity.findViewById(android.R.id.content).getRootView();
        getInputMethodManager(activity)
                .hideSoftInputFromWindow(rootView.getWindowToken(), 0);
    }

    public void hideKeyboard(Activity activity, View root){

        getInputMethodManager(activity)
                .hideSoftInputFromWindow(root.getWindowToken(), 0);
    }


    public void toggleKeyboard(Activity activity){

        getInputMethodManager(activity)
                .toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
    }

    public void showKeyboard(EditText edt) {
        getInputMethodManager(edt.getContext())
                .showSoftInput(edt, InputMethodManager.SHOW_IMPLICIT);
    }

    public void showKeyboard(Activity activity, final EditText editText){

        if (!editText.hasFocus()) {
            editText.requestFocus();
        }

        editText.post(() -> getInputMethodManager(activity)
                .showSoftInput(editText, InputMethodManager.SHOW_FORCED));
    }
}

@@ -59,16 +59,43 @@
 tivity;%0A
+import android.app.Dialog;%0A
 import a
@@ -902,19 +902,91 @@
 ty, 
-View root)%7B
+Dialog dialog)%7B%0A%0A        View rootView = dialog.findViewById(android.R.id.content);
 %0A%0A  
@@ -1068,16 +1068,196 @@
 dow(root
+View.getWindowToken(), 0);%0A    %7D%0A%0A    public void hideKeyboard(Activity activity, View view)%7B%0A%0A        getInputMethodManager(activity)%0A                .hideSoftInputFromWindow(view
 .getWind

add another input helper method