|
|
@@ -22,7 +22,9 @@ import android.text.style.AbsoluteSizeSpan;
|
|
|
import android.text.style.ForegroundColorSpan;
|
|
|
import android.util.DisplayMetrics;
|
|
|
import android.util.TypedValue;
|
|
|
+import android.view.Gravity;
|
|
|
import android.view.KeyEvent;
|
|
|
+import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.view.WindowManager;
|
|
|
@@ -97,8 +99,8 @@ public class CommonUtil {
|
|
|
InputMethodManager imm = (InputMethodManager) mContext
|
|
|
.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
imm.showSoftInput(mEditText, 0);
|
|
|
-// imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
|
|
|
-// InputMethodManager.HIDE_IMPLICIT_ONLY);
|
|
|
+ // imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
|
|
|
+ // InputMethodManager.HIDE_IMPLICIT_ONLY);
|
|
|
}
|
|
|
}, 100);
|
|
|
}
|
|
|
@@ -112,14 +114,14 @@ public class CommonUtil {
|
|
|
*/
|
|
|
public static void closeKeybord(final EditText mEditText, final Context mContext) {
|
|
|
if (mContext != null) {
|
|
|
-// mEditText.postDelayed(new Runnable() {
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// InputMethodManager imm = (InputMethodManager) mContext
|
|
|
-// .getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
-// imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
|
|
|
-// }
|
|
|
-// }, 100);
|
|
|
+ // mEditText.postDelayed(new Runnable() {
|
|
|
+ // @Override
|
|
|
+ // public void run() {
|
|
|
+ // InputMethodManager imm = (InputMethodManager) mContext
|
|
|
+ // .getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
+ // imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
|
|
|
+ // }
|
|
|
+ // }, 100);
|
|
|
|
|
|
final Activity activity = (Activity) mContext;
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
@@ -128,13 +130,14 @@ public class CommonUtil {
|
|
|
InputMethodManager mInputKeyBoard = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
if (activity.getCurrentFocus() != null) {
|
|
|
mInputKeyBoard.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
|
|
-// activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
|
|
+ // activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 判断double是否是整数
|
|
|
*
|
|
|
@@ -420,7 +423,7 @@ public class CommonUtil {
|
|
|
String result = "";
|
|
|
if (!TextUtils.isEmpty(s)) {
|
|
|
Pattern pattern = Pattern.compile("\\s*|\t|\r|\n");
|
|
|
-// Pattern pattern = Pattern.compile("\r|\n");
|
|
|
+ // Pattern pattern = Pattern.compile("\r|\n");
|
|
|
Matcher matcher = pattern.matcher(s);
|
|
|
result = matcher.replaceAll("");
|
|
|
}
|
|
|
@@ -474,13 +477,38 @@ public class CommonUtil {
|
|
|
* @param content
|
|
|
*/
|
|
|
public static void toastNoRepeat(Context context, String content) {
|
|
|
+ // if (content != null) {
|
|
|
+ // Toast toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
|
|
|
+ // toast.setGravity(Gravity.CENTER, 0, 0); // 可以调整位置
|
|
|
+ // if (!content.equals(oldMsg)) {
|
|
|
+ // toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
|
|
|
+ // time = System.currentTimeMillis();
|
|
|
+ // } else {
|
|
|
+ // if ((System.currentTimeMillis() - time) > 3000) {
|
|
|
+ // toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
|
|
|
+ // time = System.currentTimeMillis();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // oldMsg = content;
|
|
|
+ // toast.show();
|
|
|
+ // }
|
|
|
+
|
|
|
if (content != null) {
|
|
|
+ View toastLayout = LayoutInflater.from(context).inflate(R.layout.custom_toast, null);
|
|
|
+ TextView text = toastLayout.findViewById(R.id.tv_text);
|
|
|
+ text.setText(content);
|
|
|
+
|
|
|
+ Toast customToast = new Toast(context);
|
|
|
+ customToast.setGravity(Gravity.BOTTOM, 0, 0);
|
|
|
+ customToast.setDuration(Toast.LENGTH_LONG);
|
|
|
+ customToast.setView(toastLayout);
|
|
|
+
|
|
|
if (!content.equals(oldMsg)) {
|
|
|
- Toast.makeText(context, content, Toast.LENGTH_LONG).show();
|
|
|
+ customToast.show();
|
|
|
time = System.currentTimeMillis();
|
|
|
} else {
|
|
|
if ((System.currentTimeMillis() - time) > 3000) {
|
|
|
- Toast.makeText(context, content, Toast.LENGTH_LONG).show();
|
|
|
+ customToast.show();
|
|
|
time = System.currentTimeMillis();
|
|
|
}
|
|
|
}
|
|
|
@@ -488,6 +516,7 @@ public class CommonUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 访问出错的提示
|
|
|
*
|
|
|
@@ -589,7 +618,7 @@ public class CommonUtil {
|
|
|
errorStr = new String(volleyError.networkResponse.data);
|
|
|
}
|
|
|
}
|
|
|
- MyLog.d("aaa","响应失败:" + errorStr);
|
|
|
+ MyLog.d("aaa", "响应失败:" + errorStr);
|
|
|
//振动提示
|
|
|
makeNotice();
|
|
|
/*MediaPlayer mp = new MediaPlayer();
|
|
|
@@ -778,9 +807,9 @@ public class CommonUtil {
|
|
|
// 添加矩形View到布局中
|
|
|
ViewGroup decorView = (ViewGroup) context.getWindow().getDecorView();
|
|
|
decorView.addView(rectView);
|
|
|
-// ViewGroup rootView = ((ViewGroup) context.findViewById(android.R.id.content));
|
|
|
-// rootView.setFitsSystemWindows(true);
|
|
|
-// rootView.setClipToPadding(true);
|
|
|
+ // ViewGroup rootView = ((ViewGroup) context.findViewById(android.R.id.content));
|
|
|
+ // rootView.setFitsSystemWindows(true);
|
|
|
+ // rootView.setClipToPadding(true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -801,8 +830,8 @@ public class CommonUtil {
|
|
|
//定义一种颜色span
|
|
|
int valueColor = context.getResources().getColor(color);
|
|
|
ForegroundColorSpan colorSpan = new ForegroundColorSpan(valueColor);
|
|
|
-// AbsoluteSizeSpan sizeSpan = new AbsoluteSizeSpan(size, true);
|
|
|
-// spanValue.setSpan(sizeSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
+ // AbsoluteSizeSpan sizeSpan = new AbsoluteSizeSpan(size, true);
|
|
|
+ // spanValue.setSpan(sizeSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
spanValue.setSpan(colorSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
return spanValue;
|