package com.uet.beman.common;

import android.app.Activity;
import android.content.res.Resources;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;

/**
 * Created by PhanDuy on 4/5/2015.
 */
public class BM_Utils {

    private static BM_Utils instance = new BM_Utils();

    public static BM_Utils getInstance() {
        return instance;
    }

    private BM_Utils() {
    }

    public static void hideSoftKeyboard(Activity activity) {
        InputMethodManager inputMethodManager = (InputMethodManager)  activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
    }

    public static void updateNameReferences(TextView textView, Resources resources, int id, String text) {
        String res = String.format(resources.getString(id), text);
        textView.setText(res);
    }

    public static void updateNameReferences(TextView textView, Resources resources, int id, String text1, String text2) {
        String res = String.format(resources.getString(id), text1, text2);
        textView.setText(res);
    }
}

@@ -91,16 +91,42 @@
 ources;%0A
+import android.view.View;%0A
 import a
@@ -622,16 +622,96 @@
 RVICE);%0A
+        View view = activity.getCurrentFocus();%0A        if (view != null) %7B%0A    
         
@@ -757,34 +757,12 @@
 dow(
-activity.getCurrentFocus()
+view
 .get
@@ -780,16 +780,27 @@
 (), 0);%0A
+        %7D%0A%0A
     %7D%0A%0A 

fix error when press OK with unfocused EditText in FragmentInfo