|
|
@@ -11,18 +11,21 @@ import android.net.ConnectivityManager;
|
|
|
import android.net.NetworkInfo;
|
|
|
import android.net.Uri;
|
|
|
import android.os.Environment;
|
|
|
+import android.os.Handler;
|
|
|
import android.os.Looper;
|
|
|
import android.provider.MediaStore;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.view.inputmethod.InputMethodManager;
|
|
|
+import android.widget.EditText;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import com.afollestad.materialdialogs.MaterialDialog;
|
|
|
-import com.core.app.R;
|
|
|
+import com.andreabaccega.formedittext.BuildConfig;
|
|
|
import com.common.data.StringUtil;
|
|
|
-import com.common.file.PropertiesUtil;
|
|
|
import com.core.api.wxapi.ApiPlatform;
|
|
|
import com.core.api.wxapi.ApiUtils;
|
|
|
import com.core.app.MyApplication;
|
|
|
+import com.core.app.R;
|
|
|
import com.umeng.socialize.UMShareListener;
|
|
|
import com.umeng.socialize.bean.SHARE_MEDIA;
|
|
|
|
|
|
@@ -47,21 +50,17 @@ public class CommonUtil {
|
|
|
* @author:Administrator on 2016/2/18 15:12
|
|
|
*/
|
|
|
public static String getAppBaseUrl(Context ct) {
|
|
|
- if (ct==null)return "";
|
|
|
- String baseUrl =getSharedPreferences(ct, "erp_baseurl");
|
|
|
+ if (ct == null) return "";
|
|
|
+ String baseUrl = getSharedPreferences(ct, "erp_baseurl");
|
|
|
return baseUrl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Created by FANGlh on 2017/5/5.
|
|
|
* function:判断是不是发布版本,true:发布版本
|
|
|
*/
|
|
|
public static Boolean isReleaseVersion() {
|
|
|
- if (!StringUtil.isEmpty(PropertiesUtil.readData(MyApplication.getInstance(), "release_version", R.raw.versionconfiguration)) &&
|
|
|
- "true".equals(PropertiesUtil.readData(MyApplication.getInstance(), "release_version", R.raw.versionconfiguration)))
|
|
|
- return true;
|
|
|
- else
|
|
|
- return false;
|
|
|
+ return !BuildConfig.DEBUG;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -212,6 +211,7 @@ public class CommonUtil {
|
|
|
double value = sPreferences.getFloat(key, defValues);
|
|
|
return value;
|
|
|
}
|
|
|
+
|
|
|
// 转换dip为px
|
|
|
public static int convertDip2Px(Context context, int dip) {
|
|
|
float scale = context.getResources().getDisplayMetrics().density;
|
|
|
@@ -328,9 +328,10 @@ public class CommonUtil {
|
|
|
public static String getEmcode() {
|
|
|
boolean isB2b = ApiUtils.getApiModel() instanceof ApiPlatform;
|
|
|
String emcode = isB2b ? CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "b2b_uu") : CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_username");
|
|
|
- if (emcode==null)emcode="";
|
|
|
+ if (emcode == null) emcode = "";
|
|
|
return emcode;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @param :取String[]中首个字符串中的数字 number
|
|
|
* @author: FANGlh 2016-12-6
|
|
|
@@ -413,8 +414,8 @@ public class CommonUtil {
|
|
|
dialog.show();
|
|
|
}
|
|
|
|
|
|
- public static String getUserRole(){
|
|
|
- String userRole= getSharedPreferences(MyApplication.getInstance(),"userRole");
|
|
|
+ public static String getUserRole() {
|
|
|
+ String userRole = getSharedPreferences(MyApplication.getInstance(), "userRole");
|
|
|
return userRole;
|
|
|
}
|
|
|
|
|
|
@@ -471,6 +472,7 @@ public class CommonUtil {
|
|
|
}
|
|
|
return sb.toString();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @return 返回double保留两位小数
|
|
|
* @author: FANGlh 2017-3-30
|
|
|
@@ -493,6 +495,7 @@ public class CommonUtil {
|
|
|
final float scale = context.getResources().getDisplayMetrics().density;
|
|
|
return (int) (dpValue * scale + 0.5f);
|
|
|
}
|
|
|
+
|
|
|
public static boolean isMainThread() {
|
|
|
return Looper.getMainLooper().getThread() == Thread.currentThread();
|
|
|
}
|
|
|
@@ -515,4 +518,60 @@ public class CommonUtil {
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 打开软键盘
|
|
|
+ *
|
|
|
+ * @param mEditText 输入框
|
|
|
+ * @param mContext 上下文
|
|
|
+ */
|
|
|
+ public static void openKeybord(final EditText mEditText, final Context mContext) {
|
|
|
+ if (mContext != null) {
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ InputMethodManager imm = (InputMethodManager) mContext
|
|
|
+ .getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
+ imm.showSoftInput(mEditText, 0);
|
|
|
+// imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
|
|
|
+// InputMethodManager.HIDE_IMPLICIT_ONLY);
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关闭软键盘
|
|
|
+ *
|
|
|
+ * @param mEditText 输入框
|
|
|
+ * @param mContext 上下文
|
|
|
+ */
|
|
|
+ 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);
|
|
|
+// if (imm.isActive(mEditText)){
|
|
|
+ imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+
|
|
|
+// final Activity activity = (Activity) mContext;
|
|
|
+// activity.runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// 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);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|