Procházet zdrojové kódy

pulled draft for arison 修复draft分支错误

Arison před 9 roky
rodič
revize
a08826b0f9

+ 17 - 5
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/util/CommonUtil.java

@@ -62,14 +62,10 @@ import com.xzjmyk.pm.activity.util.DateFormatUtil;
 import com.xzjmyk.pm.activity.util.TimeUtils;
 import com.xzjmyk.pm.activity.xmpp.listener.ChatMessageListener;
 
-import java.io.ByteArrayInputStream;
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
-import java.lang.ref.SoftReference;
 import java.net.URL;
 import java.net.URLConnection;
 import java.text.SimpleDateFormat;
@@ -234,7 +230,7 @@ public class CommonUtil {
         }
         return val.toLowerCase();
     }
-
+  
     /**
      * @author LiuJie
      * @功能:获取账户的邮箱地址
@@ -483,6 +479,22 @@ public class CommonUtil {
         return value;
     }
 
+    public static void setSharedPreferences(Context ct, String key, float value) {
+        if (key != null) {
+            SharedPreferences sPreferences = ct.getSharedPreferences(AppShareName, Context.MODE_PRIVATE);
+            sPreferences.edit().putFloat(key, value);
+            sPreferences.edit().putFloat(key, value).apply();
+        }
+    }
+
+    public static double getSharedPreferencesfloat(Context ct, String key, float defValues) {
+        if (key == null) {
+            return 0;
+        }
+        SharedPreferences sPreferences = ct.getSharedPreferences(AppShareName, Context.MODE_PRIVATE);
+        double value = sPreferences.getFloat(key, defValues);
+        return value;
+    }
     public static String getStringDate(Long date) {
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String dateString = formatter.format(date);