Search in sources :

Example 16 with DisplayImageOptions

use of com.nostra13.universalimageloader.core.DisplayImageOptions 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 17 with DisplayImageOptions

use of com.nostra13.universalimageloader.core.DisplayImageOptions in project howabout-android by recomio.

the class HowaboutApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    // initialze universal image loader.
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheInMemory().cacheOnDisc().build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).defaultDisplayImageOptions(defaultOptions).build();
    ImageLoader.getInstance().init(config);
    // saved playlist.
    String prefsName = getString(R.string.prefs_name);
    SharedPreferences prefs = getSharedPreferences(prefsName, 0);
    String trackListJson = prefs.getString("trackListJson", null);
    // initialize playlistAdapter to use globally.
    if (trackListJson == null) {
        playlistAdapter = new MusicPlaylistAdapter(this);
    } else {
        Gson gson = new Gson();
        TrackList trackList = gson.fromJson(trackListJson, TrackList.class);
        playlistAdapter = new MusicPlaylistAdapter(this, trackList);
    }
    MusicPlayerService.setPlaylistAdapter(playlistAdapter);
}
Also used : SharedPreferences(android.content.SharedPreferences) MusicPlaylistAdapter(io.recom.howabout.category.music.adapter.MusicPlaylistAdapter) TrackList(io.recom.howabout.category.music.model.TrackList) Gson(com.google.gson.Gson) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 18 with DisplayImageOptions

use of com.nostra13.universalimageloader.core.DisplayImageOptions in project JamsMusicPlayer by psaravan.

the class BlacklistManagerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    //Initialize Context and SharedPreferences.
    mContext = this;
    mActivity = this;
    mApp = (Common) this.getApplicationContext();
    sharedPreferences = mContext.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
    //Set the UI theme.
    if (mApp.getCurrentTheme() == Common.DARK_THEME) {
        setTheme(R.style.AppTheme);
    } else {
        setTheme(R.style.AppThemeLight);
    }
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        getWindow().setBackgroundDrawable(UIElementsHelper.getGeneralActionBarBackground(mContext));
        int topPadding = Common.getStatusBarHeight(mContext);
        View activityView = (View) findViewById(android.R.id.content);
        //Calculate ActionBar height
        TypedValue tv = new TypedValue();
        int actionBarHeight = 0;
        if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
            actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
        }
        if (activityView != null) {
            activityView.setPadding(0, topPadding + actionBarHeight, 0, 0);
        }
    }
    //Retrieve the actionbar.
    actionBar = getActionBar();
    //Create a set of options to optimize the bitmap memory usage.
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    options.inJustDecodeBounds = false;
    options.inPurgeable = true;
    //Display Image Options.
    int defaultArt = UIElementsHelper.getIcon(mContext, "default_album_art_padded");
    displayImageOptions = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.default_album_art).showImageOnFail(R.drawable.default_album_art).showStubImage(R.drawable.transparent_drawable).cacheInMemory(false).cacheOnDisc(true).decodingOptions(options).imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.RGB_565).displayer(new FadeInBitmapDisplayer(400)).delayBeforeLoading(100).build();
    //Retrieve a list of blacklisted songs.
    AsyncGetAllSongIdsBlacklistStatusTask task = new AsyncGetAllSongIdsBlacklistStatusTask();
    task.execute();
}
Also used : DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) BitmapFactory(android.graphics.BitmapFactory) View(android.view.View) TypedValue(android.util.TypedValue)

Example 19 with DisplayImageOptions

use of com.nostra13.universalimageloader.core.DisplayImageOptions in project QuickAndroid by ImKarl.

the class QAImageLoaderConfig method getConfig.

/**
     * 获取加载配置
     * @param context
     * @param imageOnLoadingRes 加载中显示的图片
     * @param imageOnFailRes 加载失败显示的图片
     * @return
     */
public static ImageLoaderConfiguration getConfig(Context context, int imageOnLoadingRes, int imageOnFailRes) {
    DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(// 加载中
    imageOnLoadingRes).showImageForEmptyUri(// 图片Uri为空或是错误的时候显示的图片
    imageOnFailRes).showImageOnFail(// resource or drawable
    imageOnFailRes).resetViewBeforeLoading(// default
    false).delayBeforeLoading(// 加载前延迟时长
    50).cacheInMemory(// default = false 是否使用内存缓存
    true).cacheOnDisk(// default = false 是否使用文件缓存
    true).considerExifParams(// default = false
    false).imageScaleType(// default
    ImageScaleType.IN_SAMPLE_POWER_OF_2).bitmapConfig(// default
    Bitmap.Config.ARGB_8888).displayer(// default = new SimpleBitmapDisplayer()
    new FadeInBitmapDisplayer(100)).build();
    File cacheDir = new File(QAFileManager.getUsableDir(context.getPackageName()));
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(// default 线程池大小
    3).threadPriority(// default 线程优先级
    Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory().memoryCache(// 内存缓存
    new LruMemoryCache(8 * 1024 * 1024)).diskCache(// default 磁盘缓存
    new UnlimitedDiskCache(cacheDir)).diskCacheSize(// 磁盘缓存大小
    30 * 1024 * 1024).diskCacheFileNameGenerator(// default 磁盘缓存文件名
    new HashCodeFileNameGenerator()).imageDownloader(// default 图片下载器
    new BaseImageDownloader(context)).imageDecoder(// default 图片解码器
    new BaseImageDecoder(QACore.isDebug())).defaultDisplayImageOptions(// default=DisplayImageOptions.createSimple() 图片显示选项
    options).build();
    return config;
}
Also used : UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) HashCodeFileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) BaseImageDownloader(com.nostra13.universalimageloader.core.download.BaseImageDownloader) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) BaseImageDecoder(com.nostra13.universalimageloader.core.decode.BaseImageDecoder)

Example 20 with DisplayImageOptions

use of com.nostra13.universalimageloader.core.DisplayImageOptions in project StickerCamera by Skykai521.

the class App method initImageLoader.

private void initImageLoader() {
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheInMemory(false).imageScaleType(ImageScaleType.EXACTLY).cacheOnDisk(true).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).threadPriority(Thread.NORM_PRIORITY - 2).defaultDisplayImageOptions(defaultOptions).denyCacheImageMultipleSizesInMemory().diskCacheFileNameGenerator(new Md5FileNameGenerator()).diskCache(new UnlimitedDiskCache(StorageUtils.getOwnCacheDirectory(this, AppConstants.APP_IMAGE))).diskCacheSize(100 * 1024 * 1024).tasksProcessingOrder(QueueProcessingType.LIFO).memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024).threadPoolSize(3).build();
    ImageLoader.getInstance().init(config);
}
Also used : UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Aggregations

DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)21 ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)15 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)9 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)7 File (java.io.File)7 Bitmap (android.graphics.Bitmap)4 BitmapFactory (android.graphics.BitmapFactory)4 View (android.view.View)4 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)4 UnlimitedDiscCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache)3 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)3 ImageSize (com.nostra13.universalimageloader.core.assist.ImageSize)3 ActionBar (android.app.ActionBar)2 Tab (android.app.ActionBar.Tab)2 Intent (android.content.Intent)2 SpannableString (android.text.SpannableString)2 TypedValue (android.util.TypedValue)2 ImageView (android.widget.ImageView)2 DBAccessHelper (com.jams.music.player.DBHelpers.DBAccessHelper)2 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)2