use of com.nostra13.universalimageloader.core.assist.ImageSize in project JamsMusicPlayer by psaravan.
the class StackRemoteViewsFactory method getViewAt.
@Override
public RemoteViews getViewAt(int position) {
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.large_widget_listview_layout);
if (position <= getCount()) {
try {
if (mApp.getService().getPlaybackIndecesList() != null && mApp.getService().getPlaybackIndecesList().size() != 0) {
if (cursor.getCount() > mApp.getService().getPlaybackIndecesList().get(position)) {
cursor.moveToPosition(mApp.getService().getPlaybackIndecesList().get(position));
} else {
return null;
}
} else {
return null;
}
} catch (Exception e) {
return null;
}
//Set the song title, album, and artist fields.
String songTitle = cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_TITLE));
String songAlbumArtPath = cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH));
ImageSize imageSize = new ImageSize(100, 100);
//Set the duration of the song.
long songDurationInMillis = 0;
try {
songDurationInMillis = Long.parseLong(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_DURATION)));
} catch (Exception e) {
songDurationInMillis = 0;
}
rv.setTextViewText(R.id.widget_listview_song_name, songTitle);
rv.setTextViewText(R.id.widget_listview_duration, convertMillisToMinsSecs(songDurationInMillis));
if (mWidgetColor.equals("LIGHT")) {
rv.setTextColor(R.id.widget_listview_song_name, Color.BLACK);
rv.setTextColor(R.id.widget_listview_duration, Color.BLACK);
}
Bitmap bitmap = mApp.getImageLoader().loadImageSync(songAlbumArtPath, imageSize, displayImageOptions);
rv.setImageViewBitmap(R.id.widget_listview_thumbnail, bitmap);
}
/* This intent latches itself onto the pendingIntentTemplate from
* LargeWidgetProvider.java and adds the extra "INDEX" argument to it. */
Intent fillInIntent = new Intent();
fillInIntent.putExtra("INDEX", position);
rv.setOnClickFillInIntent(R.id.widget_listview_layout, fillInIntent);
return rv;
}
use of com.nostra13.universalimageloader.core.assist.ImageSize in project Android-Universal-Image-Loader by nostra13.
the class ImageLoader method loadImage.
/**
* Adds load image task to execution pool. Image will be returned with
* {@link ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)} callback}.
* <br />
* <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method call
*
* @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
* @param targetImageSize Minimal size for {@link Bitmap} which will be returned in
* {@linkplain ImageLoadingListener#onLoadingComplete(String, android.view.View,
* android.graphics.Bitmap)} callback}. Downloaded image will be decoded
* and scaled to {@link Bitmap} of the size which is <b>equal or larger</b> (usually a bit
* larger) than incoming targetImageSize.
* @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
* decoding and displaying. If <b>null</b> - default display image options
* {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
* from configuration} will be used.<br />
* @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires
* events on UI thread if this method is called on UI thread.
* @param progressListener {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener
* Listener} for image loading progress. Listener fires events on UI thread if this method
* is called on UI thread. Caching on disk should be enabled in
* {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions options} to make
* this listener work.
* @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
*/
public void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options, ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
checkConfiguration();
if (targetImageSize == null) {
targetImageSize = configuration.getMaxImageSize();
}
if (options == null) {
options = configuration.defaultDisplayImageOptions;
}
NonViewAware imageAware = new NonViewAware(uri, targetImageSize, ViewScaleType.CROP);
displayImage(uri, imageAware, options, listener, progressListener);
}
use of com.nostra13.universalimageloader.core.assist.ImageSize in project Android-Universal-Image-Loader by nostra13.
the class ImageLoaderConfiguration method getMaxImageSize.
ImageSize getMaxImageSize() {
DisplayMetrics displayMetrics = resources.getDisplayMetrics();
int width = maxImageWidthForMemoryCache;
if (width <= 0) {
width = displayMetrics.widthPixels;
}
int height = maxImageHeightForMemoryCache;
if (height <= 0) {
height = displayMetrics.heightPixels;
}
return new ImageSize(width, height);
}
use of com.nostra13.universalimageloader.core.assist.ImageSize in project Android-Universal-Image-Loader by nostra13.
the class UILWidgetProvider method updateAppWidget.
static void updateAppWidget(Context context, final AppWidgetManager appWidgetManager, final int appWidgetId) {
final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
// 70 - approximate size of ImageView in widget
ImageSize minImageSize = new ImageSize(70, 70);
ImageLoader.getInstance().loadImage(IMAGES[0], minImageSize, displayOptions, new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
views.setImageViewBitmap(R.id.image_left, loadedImage);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
});
ImageLoader.getInstance().loadImage(IMAGES[1], minImageSize, displayOptions, new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
views.setImageViewBitmap(R.id.image_right, loadedImage);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
});
}
use of com.nostra13.universalimageloader.core.assist.ImageSize in project Android-Universal-Image-Loader by nostra13.
the class BaseImageDecoder method defineImageSizeAndRotation.
protected ImageFileInfo defineImageSizeAndRotation(InputStream imageStream, ImageDecodingInfo decodingInfo) throws IOException {
Options options = new Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(imageStream, null, options);
ExifInfo exif;
String imageUri = decodingInfo.getImageUri();
if (decodingInfo.shouldConsiderExifParams() && canDefineExifParams(imageUri, options.outMimeType)) {
exif = defineExifOrientation(imageUri);
} else {
exif = new ExifInfo();
}
return new ImageFileInfo(new ImageSize(options.outWidth, options.outHeight, exif.rotation), exif);
}
Aggregations