|
17 | 17 |
|
18 | 18 | import android.content.ContentResolver;
|
19 | 19 | import android.content.Context;
|
20 |
| -import android.graphics.Bitmap; |
21 |
| -import android.graphics.Bitmap.CompressFormat; |
22 |
| -import android.graphics.drawable.BitmapDrawable; |
23 | 20 | import android.net.Uri;
|
24 | 21 | import android.provider.ContactsContract;
|
| 22 | + |
25 | 23 | import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
26 | 24 | import com.nostra13.universalimageloader.core.assist.ContentLengthInputStream;
|
27 | 25 | import com.nostra13.universalimageloader.utils.IoUtils;
|
28 | 26 |
|
29 | 27 | import java.io.BufferedInputStream;
|
30 |
| -import java.io.ByteArrayInputStream; |
31 |
| -import java.io.ByteArrayOutputStream; |
32 | 28 | import java.io.File;
|
33 | 29 | import java.io.FileInputStream;
|
34 | 30 | import java.io.FileNotFoundException;
|
@@ -59,7 +55,7 @@ public class BaseImageDownloader implements ImageDownloader {
|
59 | 55 |
|
60 | 56 | protected static final int MAX_REDIRECT_COUNT = 5;
|
61 | 57 |
|
62 |
| - protected static final String CONTENT_CONTACTS_URI_PREFIX = "content://com.android.contacts/"; |
| 58 | + protected static final String CONTENT_CONTACTS_URI_PREFIX = "content://com.android.contacts/"; |
63 | 59 |
|
64 | 60 | private static final String ERROR_UNSUPPORTED_SCHEME = "UIL doesn't support scheme(protocol) by default [%s]. "
|
65 | 61 | + "You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))";
|
@@ -207,12 +203,7 @@ protected InputStream getStreamFromAssets(String imageUri, Object extra) throws
|
207 | 203 | protected InputStream getStreamFromDrawable(String imageUri, Object extra) {
|
208 | 204 | String drawableIdString = Scheme.DRAWABLE.crop(imageUri);
|
209 | 205 | int drawableId = Integer.parseInt(drawableIdString);
|
210 |
| - BitmapDrawable drawable = (BitmapDrawable) context.getResources().getDrawable(drawableId); |
211 |
| - Bitmap bitmap = drawable.getBitmap(); |
212 |
| - |
213 |
| - ByteArrayOutputStream os = new ByteArrayOutputStream(); |
214 |
| - bitmap.compress(CompressFormat.PNG, 0, os); |
215 |
| - return new ByteArrayInputStream(os.toByteArray()); |
| 206 | + return context.getResources().openRawResource(drawableId); |
216 | 207 | }
|
217 | 208 |
|
218 | 209 | /**
|
|
0 commit comments