forked from liujingxing/rxhttp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlatform.java
More file actions
92 lines (74 loc) · 1.98 KB
/
Platform.java
File metadata and controls
92 lines (74 loc) · 1.98 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package rxhttp;
import android.os.Build;
import android.util.Log;
/**
* User: ljx
* Date: 2019-12-29
* Time: 16:07
*/
public class Platform {
private static final Platform PLATFORM = findPlatform();
public static Platform get() {
return PLATFORM;
}
private Platform() {
}
private static Platform findPlatform() {
try {
Class.forName("android.os.Build");
if (Build.VERSION.SDK_INT != 0) {
return new Android();
}
} catch (ClassNotFoundException ignored) {
}
return new Platform();
}
//是否Android平台
public boolean isAndroid() {
return false;
}
public boolean sdkLessThan(int api) {
return false;
}
public void logi(String tag, String message) {
System.out.println(tag + ": " + message);
}
public void logd(String tag, String message) {
System.out.println(tag + ": " + message);
}
public void loge(String tag, String message) {
System.out.println(tag + ": " + message);
}
public void logd(String tag, String message, Throwable e) {
System.out.println(tag + ": " + message);
}
static final class Android extends Platform {
Android() {
super();
}
@Override
public boolean isAndroid() {
return true;
}
@Override
public boolean sdkLessThan(int api) {
return Build.VERSION.SDK_INT < api;
}
@Override
public void logi(String tag, String message) {
Log.i(tag, message);
}
@Override
public void logd(String tag, String message) {
Log.d(tag, message);
}
@Override
public void loge(String tag, String message) {
Log.e(tag, message);
}
@Override
public void logd(String tag, String message, Throwable e) {
Log.e(tag, message, e);
}
}
}