-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOutdatedUtils.java
executable file
·103 lines (92 loc) · 2.76 KB
/
OutdatedUtils.java
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
93
94
95
96
97
98
99
100
101
102
103
package com.youth.xframe.utils;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
import android.view.View;
import com.youth.xframe.XFrame;
/**
* 此类主要是用来放一些系统过时方法的处理
*/
public class XOutdatedUtils {
private XOutdatedUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* setBackgroundDrawable过时方法处理
*
* @param view
* @param drawable
*/
public static void setBackground(@NonNull View view, Drawable drawable) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
view.setBackground(drawable);
else
view.setBackgroundDrawable(drawable);
}
/**
* getDrawable过时方法处理
*
* @param id
* @return
*/
public static Drawable getDrawable(@DrawableRes int id) {
return ContextCompat.getDrawable(XFrame.getContext(), id);
}
/**
* getDrawable过时方法处理
*
* @param id 资源id
* @param theme 指定主题
* @return
*/
public static Drawable getDrawable(@DrawableRes int id,
@Nullable Resources.Theme theme) {
return ResourcesCompat.getDrawable(XFrame.getResources(), id, theme);
}
/**
* getColor过时方法处理
*
* @param id
* @return
*/
public static int getColor(@ColorRes int id) {
return ContextCompat.getColor(XFrame.getContext(), id);
}
/**
* getColor过时方法处理
*
* @param id 资源id
* @param theme 指定主题
* @return
*/
public static int getColor(@ColorRes int id, @Nullable Resources.Theme theme) {
return ResourcesCompat.getColor(XFrame.getResources(), id, theme);
}
/**
* getColorStateList过时方法处理
*
* @param id 资源id
* @return
*/
public static ColorStateList getColorStateList(@ColorRes int id) {
return ContextCompat.getColorStateList(XFrame.getContext(), id);
}
/**
* getColorStateList过时方法处理
*
* @param id 资源id
* @param theme 指定主题
* @return
*/
public static ColorStateList getColorStateList(@ColorRes int id, @Nullable Resources.Theme theme) {
return ResourcesCompat.getColorStateList(XFrame.getResources(), id, theme);
}
}