Cleaned up MediaStore loaders, preparing for album art loading directly from the file
This commit is contained in:
parent
1edd0742fc
commit
da92636180
23 changed files with 271 additions and 374 deletions
|
|
@ -0,0 +1,35 @@
|
|||
package com.kabouzeid.gramophone.imageloader;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class PhonographImageDownloader extends BaseImageDownloader {
|
||||
public static final String SCHEME_ALBUM = "album://";
|
||||
public static final String SCHEME_SONG = "song://";
|
||||
|
||||
public PhonographImageDownloader(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InputStream getStreamFromOtherSource(String imageUri, Object extra) throws IOException {
|
||||
if (imageUri.startsWith(SCHEME_ALBUM)) {
|
||||
try {
|
||||
int id = Integer.valueOf(imageUri.substring(SCHEME_ALBUM.length()));
|
||||
return getStream(MusicUtil.getAlbumArtUri(id).toString(), extra);
|
||||
} catch (NumberFormatException e) {
|
||||
return super.getStreamFromOtherSource(imageUri, extra);
|
||||
}
|
||||
} else {
|
||||
return super.getStreamFromOtherSource(imageUri, extra);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue