Skip to content

Commit 82bc487

Browse files
committed
Simplified BaseImageDownloader.getStreamFromDrawable()
1 parent cf81669 commit 82bc487

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

library/src/com/nostra13/universalimageloader/core/download/BaseImageDownloader.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,14 @@
1717

1818
import android.content.ContentResolver;
1919
import android.content.Context;
20-
import android.graphics.Bitmap;
21-
import android.graphics.Bitmap.CompressFormat;
22-
import android.graphics.drawable.BitmapDrawable;
2320
import android.net.Uri;
2421
import android.provider.ContactsContract;
22+
2523
import com.nostra13.universalimageloader.core.DisplayImageOptions;
2624
import com.nostra13.universalimageloader.core.assist.ContentLengthInputStream;
2725
import com.nostra13.universalimageloader.utils.IoUtils;
2826

2927
import java.io.BufferedInputStream;
30-
import java.io.ByteArrayInputStream;
31-
import java.io.ByteArrayOutputStream;
3228
import java.io.File;
3329
import java.io.FileInputStream;
3430
import java.io.FileNotFoundException;
@@ -59,7 +55,7 @@ public class BaseImageDownloader implements ImageDownloader {
5955

6056
protected static final int MAX_REDIRECT_COUNT = 5;
6157

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/";
6359

6460
private static final String ERROR_UNSUPPORTED_SCHEME = "UIL doesn't support scheme(protocol) by default [%s]. "
6561
+ "You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))";
@@ -207,12 +203,7 @@ protected InputStream getStreamFromAssets(String imageUri, Object extra) throws
207203
protected InputStream getStreamFromDrawable(String imageUri, Object extra) {
208204
String drawableIdString = Scheme.DRAWABLE.crop(imageUri);
209205
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);
216207
}
217208

218209
/**

0 commit comments

Comments
 (0)