Skip to content

Commit 9341c15

Browse files
committed
update ResLoader
1 parent 569ec6c commit 9341c15

File tree

1 file changed

+16
-85
lines changed

1 file changed

+16
-85
lines changed
Lines changed: 16 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
package com.lidroid.xutils.view;
22

33
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;
94
import android.view.animation.AnimationUtils;
105

116
/**
@@ -19,105 +14,41 @@ public static Object loadRes(ResType type, Context context, int id) {
1914
if (context == null || id < 1) return null;
2015
switch (type) {
2116
case Animation:
22-
return getAnimation(context, id);
17+
return AnimationUtils.loadAnimation(context, id);
2318
case Boolean:
24-
return getBoolean(context, id);
19+
return context.getResources().getBoolean(id);
2520
case Color:
26-
return getColor(context, id);
21+
return context.getResources().getColor(id);
2722
case ColorStateList:
28-
return getColorStateList(context, id);
23+
return context.getResources().getColorStateList(id);
2924
case Dimension:
30-
return getDimension(context, id);
25+
return context.getResources().getDimension(id);
3126
case DimensionPixelOffset:
32-
return getDimensionPixelOffset(context, id);
27+
return context.getResources().getDimensionPixelOffset(id);
3328
case DimensionPixelSize:
34-
return getDimensionPixelSize(context, id);
29+
return context.getResources().getDimensionPixelSize(id);
3530
case Drawable:
36-
return getDrawable(context, id);
31+
return context.getResources().getDrawable(id);
3732
case Integer:
38-
return getInteger(context, id);
33+
return context.getResources().getInteger(id);
3934
case IntArray:
40-
return getIntArray(context, id);
35+
return context.getResources().getIntArray(id);
4136
case Movie:
42-
return getMovie(context, id);
37+
return context.getResources().getMovie(id);
4338
case String:
44-
return getString(context, id);
39+
return context.getResources().getString(id);
4540
case StringArray:
46-
return getStringArray(context, id);
41+
return context.getResources().getStringArray(id);
4742
case Text:
48-
return getText(context, id);
43+
return context.getResources().getText(id);
4944
case TextArray:
50-
return getTextArray(context, id);
45+
return context.getResources().getTextArray(id);
5146
case Xml:
52-
return getXml(context, id);
47+
return context.getResources().getXml(id);
5348
default:
5449
break;
5550
}
5651

5752
return null;
5853
}
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-
}
12354
}

0 commit comments

Comments
 (0)