doum
6 天以前 2b287056e2f59518888d05a1bbc7e5a55fbd84d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.doumee.keyCabinet.utils;
 
import android.text.TextUtils;
 
import com.doumee.lib_coremodel.util.SpUtil;
 
/**
 * 手环机日志
 */
public class BraceletLogUtils {
    private static final String LOG_KEY = "bracelet_log";
    public static Long COUNT = 0L;
    public static Long OUT_COUNT = 0L;
    public static Long lastTime = 0L;
 
    public static void saveLog(String msg){
        String time = TimeUtils.getNowDate();
        String text = SpUtil.getString(LOG_KEY);
        if(TextUtils.isEmpty(text)){
            text = "";
        }
        text+= time + ":"+msg+"    #";
        COUNT++;
        SpUtil.saveString(LOG_KEY,text);
 
    }
 
    /**
     * 取出所有记录
     * @return
     */
    public static String getAllLog(){
        OUT_COUNT = COUNT;
        String text = SpUtil.getString(LOG_KEY);
        SpUtil.saveString(LOG_KEY,"");
        COUNT = 0L;
        return text;
    }
 
    public static void backLog(String msg){
        String text = SpUtil.getString(LOG_KEY);
        if(TextUtils.isEmpty(text)){
            text = "";
        }
        text = msg + text;
        COUNT += OUT_COUNT;
        OUT_COUNT = 0L;
        SpUtil.saveString(LOG_KEY,text);
    }
}