1
1
package com .lidroid .xutils .view ;
2
2
3
3
import android .content .Context ;
4
- import android .content .res .ColorStateList ;
5
- import android .content .res .XmlResourceParser ;
6
- import android .graphics .Movie ;
7
- import android .graphics .drawable .Drawable ;
8
- import android .view .animation .Animation ;
9
4
import android .view .animation .AnimationUtils ;
10
5
11
6
/**
@@ -19,105 +14,41 @@ public static Object loadRes(ResType type, Context context, int id) {
19
14
if (context == null || id < 1 ) return null ;
20
15
switch (type ) {
21
16
case Animation :
22
- return getAnimation (context , id );
17
+ return AnimationUtils . loadAnimation (context , id );
23
18
case Boolean :
24
- return getBoolean (context , id );
19
+ return context . getResources (). getBoolean (id );
25
20
case Color :
26
- return getColor (context , id );
21
+ return context . getResources (). getColor (id );
27
22
case ColorStateList :
28
- return getColorStateList (context , id );
23
+ return context . getResources (). getColorStateList (id );
29
24
case Dimension :
30
- return getDimension (context , id );
25
+ return context . getResources (). getDimension (id );
31
26
case DimensionPixelOffset :
32
- return getDimensionPixelOffset (context , id );
27
+ return context . getResources (). getDimensionPixelOffset (id );
33
28
case DimensionPixelSize :
34
- return getDimensionPixelSize (context , id );
29
+ return context . getResources (). getDimensionPixelSize (id );
35
30
case Drawable :
36
- return getDrawable (context , id );
31
+ return context . getResources (). getDrawable (id );
37
32
case Integer :
38
- return getInteger (context , id );
33
+ return context . getResources (). getInteger (id );
39
34
case IntArray :
40
- return getIntArray (context , id );
35
+ return context . getResources (). getIntArray (id );
41
36
case Movie :
42
- return getMovie (context , id );
37
+ return context . getResources (). getMovie (id );
43
38
case String :
44
- return getString (context , id );
39
+ return context . getResources (). getString (id );
45
40
case StringArray :
46
- return getStringArray (context , id );
41
+ return context . getResources (). getStringArray (id );
47
42
case Text :
48
- return getText (context , id );
43
+ return context . getResources (). getText (id );
49
44
case TextArray :
50
- return getTextArray (context , id );
45
+ return context . getResources (). getTextArray (id );
51
46
case Xml :
52
- return getXml (context , id );
47
+ return context . getResources (). getXml (id );
53
48
default :
54
49
break ;
55
50
}
56
51
57
52
return null ;
58
53
}
59
-
60
- public static Animation getAnimation (Context context , int id ) {
61
- return AnimationUtils .loadAnimation (context , id );
62
- }
63
-
64
- public static boolean getBoolean (Context context , int id ) {
65
- return context .getResources ().getBoolean (id );
66
- }
67
-
68
- public static int getColor (Context context , int id ) {
69
- return context .getResources ().getColor (id );
70
- }
71
-
72
- public static ColorStateList getColorStateList (Context context , int id ) {
73
- return context .getResources ().getColorStateList (id );
74
- }
75
-
76
- public static float getDimension (Context context , int id ) {
77
- return context .getResources ().getDimension (id );
78
- }
79
-
80
- public static int getDimensionPixelOffset (Context context , int id ) {
81
- return context .getResources ().getDimensionPixelOffset (id );
82
- }
83
-
84
- public static int getDimensionPixelSize (Context context , int id ) {
85
- return context .getResources ().getDimensionPixelSize (id );
86
- }
87
-
88
- public static Drawable getDrawable (Context context , int id ) {
89
- return context .getResources ().getDrawable (id );
90
- }
91
-
92
- public static int getInteger (Context context , int id ) {
93
- return context .getResources ().getInteger (id );
94
- }
95
-
96
- public static int [] getIntArray (Context context , int id ) {
97
- return context .getResources ().getIntArray (id );
98
- }
99
-
100
- public static Movie getMovie (Context context , int id ) {
101
- return context .getResources ().getMovie (id );
102
- }
103
-
104
- public static String getString (Context context , int id ) {
105
- return context .getResources ().getString (id );
106
- }
107
-
108
- public static String [] getStringArray (Context context , int id ) {
109
- return context .getResources ().getStringArray (id );
110
- }
111
-
112
- public static CharSequence getText (Context context , int id ) {
113
- return context .getResources ().getText (id );
114
- }
115
-
116
- public static CharSequence [] getTextArray (Context context , int id ) {
117
- return context .getResources ().getTextArray (id );
118
- }
119
-
120
- public static XmlResourceParser getXml (Context context , int id ) {
121
- return context .getResources ().getXml (id );
122
- }
123
54
}
0 commit comments