package org.mazhuang.guanggoo.util;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

/**
 * 软键盘操作工具类。
 *
 * @author mazhuang
 * @date 2018 /4/30
 */
public class SoftInputUtil {
    private SoftInputUtil() {}

    /**
     * Show soft input.
     *
     * @param context the context
     */
    public static void showSoftInput(Context context) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
    }

    /**
     * Hide soft input.
     *
     * @param context the context
     */
    public static void hideSoftInput(Context context) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        boolean isOpen = (imm != null && imm.isActive());
        if (isOpen) {
            imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }

    /**
     * Hide soft input from window.
     *
     * @param context the context
     * @param v       the v
     */
    public static void hideSoftInputFromWindow(Context context, View v) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }
    }
}

@@ -505,32 +505,63 @@
 ETHOD_SERVICE);%0A
+        if (imm != null) %7B%0A    
         imm.togg
@@ -603,20 +603,31 @@
 _FORCED,
+ 
 0);%0A
+        %7D%0A
     %7D%0A%0A 

Fix may caused NullPointerException