65 lines
2.2 KiB
Java
65 lines
2.2 KiB
Java
package com.ubt.jimu.utils;
|
|
|
|
import android.app.Activity;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.inputmethod.InputMethodManager;
|
|
import android.widget.EditText;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class InputMethod {
|
|
public static void a(Activity activity) {
|
|
try {
|
|
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService("input_method");
|
|
if (inputMethodManager.isActive()) {
|
|
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 2);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static boolean b(Activity activity, View view) {
|
|
if (view == null || !(view instanceof EditText)) {
|
|
return false;
|
|
}
|
|
try {
|
|
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService("input_method");
|
|
if (inputMethodManager.isActive()) {
|
|
return inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 2);
|
|
}
|
|
return false;
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static void c(Activity activity, View view) {
|
|
try {
|
|
((InputMethodManager) activity.getSystemService("input_method")).showSoftInput(view, 2);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static void a(Activity activity, View view) {
|
|
try {
|
|
((InputMethodManager) activity.getSystemService("input_method")).hideSoftInputFromWindow(view.getWindowToken(), 0);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static boolean a(View view, MotionEvent motionEvent) {
|
|
if (view == null || !(view instanceof EditText)) {
|
|
return false;
|
|
}
|
|
int[] iArr = {0, 0};
|
|
view.getLocationInWindow(iArr);
|
|
int i = iArr[0];
|
|
int i2 = iArr[1];
|
|
return motionEvent.getX() <= ((float) i) || motionEvent.getX() >= ((float) (view.getWidth() + i)) || motionEvent.getY() <= ((float) i2) || motionEvent.getY() >= ((float) (view.getHeight() + i2));
|
|
}
|
|
}
|