Search in sources :

Example 6 with ImageSize

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;
}
Also used : RemoteViews(android.widget.RemoteViews) Bitmap(android.graphics.Bitmap) ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize) Intent(android.content.Intent)

Example 7 with ImageSize

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);
}
Also used : NonViewAware(com.nostra13.universalimageloader.core.imageaware.NonViewAware)

Example 8 with ImageSize

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);
}
Also used : ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize) DisplayMetrics(android.util.DisplayMetrics)

Example 9 with ImageSize

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);
        }
    });
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) RemoteViews(android.widget.RemoteViews) Bitmap(android.graphics.Bitmap) ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize) View(android.view.View)

Example 10 with ImageSize

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);
}
Also used : Options(android.graphics.BitmapFactory.Options) ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize)

Aggregations

ImageSize (com.nostra13.universalimageloader.core.assist.ImageSize)11 Bitmap (android.graphics.Bitmap)6 Options (android.graphics.BitmapFactory.Options)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 View (android.view.View)2 RemoteViews (android.widget.RemoteViews)2 ImageScaleType (com.nostra13.universalimageloader.core.assist.ImageScaleType)2 File (java.io.File)2 Intent (android.content.Intent)1 Matrix (android.graphics.Matrix)1 DisplayMetrics (android.util.DisplayMetrics)1 LayoutInflater (android.view.LayoutInflater)1 ImageView (android.widget.ImageView)1 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)1 ImageDecodingInfo (com.nostra13.universalimageloader.core.decode.ImageDecodingInfo)1 ImageViewAware (com.nostra13.universalimageloader.core.imageaware.ImageViewAware)1 NonViewAware (com.nostra13.universalimageloader.core.imageaware.NonViewAware)1 SimpleImageLoadingListener (com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener)1