Java Code Examples for com.nostra13.universalimageloader.core.DisplayImageOptions
The following examples show how to use
com.nostra13.universalimageloader.core.DisplayImageOptions. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: fdroidclient Source File: Utils.java License: GNU General Public License v3.0 | 6 votes |
/** * If app has an iconUrl we feed that to UIL, otherwise we ask the PackageManager which will * return the app's icon directly when the app is installed. * We fall back to the placeholder icon otherwise. */ public static void setIconFromRepoOrPM(@NonNull App app, ImageView iv, Context context) { if (app.getIconUrl(iv.getContext()) == null) { try { iv.setImageDrawable(context.getPackageManager().getApplicationIcon(app.packageName)); } catch (PackageManager.NameNotFoundException e) { DisplayImageOptions options = Utils.getRepoAppDisplayImageOptions(); iv.setImageDrawable(options.shouldShowImageForEmptyUri() ? options.getImageForEmptyUri(FDroidApp.getInstance().getResources()) : null); } } else { ImageLoader.getInstance().displayImage( app.getIconUrl(iv.getContext()), iv, Utils.getRepoAppDisplayImageOptions()); } }
Example 2
Source Project: BigApp_WordPress_Android Source File: DialogShare.java License: Apache License 2.0 | 6 votes |
private void setWeiboImage(Platform.ShareParams sp) { try { ImageLoader.getInstance().loadImageSync(imageUrl, new DisplayImageOptions.Builder() .imageScaleType(ImageScaleType.IN_SAMPLE_INT) .bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true) .cacheInMemory(false).cacheOnDisk(true).resetViewBeforeLoading(true) .considerExifParams(true).build()); String path = ImageLoader.getInstance().getDiskCache().get(imageUrl).getPath(); if (TextUtils.isEmpty(path)) { return; } sp.setImagePath(path); } catch (Throwable e) { e.printStackTrace(); } }
Example 3
Source Project: LLApp Source File: ImageLoaders.java License: Apache License 2.0 | 6 votes |
public static void setdailyfineimg(String url, ImageView imageView, ImageLoadingListener listener) { if (dailyfines == null) { dailyfines = new DisplayImageOptions.Builder() .showImageOnLoading(0) .showImageForEmptyUri(0) .showImageOnFail(0) .cacheInMemory(true) // .cacheOnDisk(true) .considerExifParams(true) .bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) .build(); } ImageLoader.getInstance().displayImage(url, imageView, dailyfines, listener); }
Example 4
Source Project: Focus Source File: ImageLoaderManager.java License: GNU General Public License v3.0 | 6 votes |
public static DisplayImageOptions getSubsciptionIconOptions(Context context) { Drawable defaultDrawable; Drawable errorDrawable = context.getResources().getDrawable(R.drawable.loading_error); defaultDrawable = context.getResources().getDrawable(R.drawable.ic_loading); /* if (SkinPreference.getInstance().getSkinName().equals("night")) { defaultDrawable = context.getResources().getDrawable(R.drawable.ic_night_loading); } else { defaultDrawable = context.getResources().getDrawable(R.drawable.ic_day_loading); }*/ DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(defaultDrawable) .showImageForEmptyUri(defaultDrawable) .showImageOnFail(errorDrawable) .cacheInMemory(true) .cacheOnDisk(true) .build(); return options; }
Example 5
Source Project: DevUtils Source File: ImageLoaderUtils.java License: Apache License 2.0 | 6 votes |
/** * 初始化 ImageLoader 加载配置 * @param context {@link Context} */ public static void init(final Context context) { DisplayImageOptions options = DF_OPTIONS; // 针对图片缓存的全局加载配置 ( 主要有线程类、缓存大小、磁盘大小、图片下载与解析、日志方面的配置 ) ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .defaultDisplayImageOptions(options) // 加载 DisplayImageOptions 参数 .threadPriority(Thread.NORM_PRIORITY - 2) // 线程池内加载的数量 .denyCacheImageMultipleSizesInMemory() // 加载同一 URL 图片时 imageView 从小变大时从内存缓存中加载 //.memoryCache(new UsingFreqLimitedMemoryCache(1024 * 1024)) // 通过自己的内存缓存实现 .memoryCacheSize(2 * 1024 * 1024) // 内存缓存最大值 .memoryCacheSizePercentage(13) //.diskCacheSize(50 * 1024 * 1024) // SDCard 缓存最大值 50mb //.discCacheFileNameGenerator(new Md5FileNameGenerator()) // 将保存的时候的 URI 名称用 MD5 加密 //.diskCacheFileCount(100) // 缓存的文件数量 //.memoryCache(new WeakMemoryCache()).diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) .imageDownloader(new BaseImageDownloader(context)) // default .tasksProcessingOrder(QueueProcessingType.LIFO).build(); ImageLoader.getInstance().init(config); }
Example 6
Source Project: GithubTrends Source File: AsyncImageView.java License: Apache License 2.0 | 6 votes |
protected void executeLoadImage() { if (TextUtils.isEmpty(url)) { setImageResource(R.drawable.image_loading_resource); } else { DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.image_loading_resource) .cacheInMemory(true) .cacheOnDisk(true) .displayer(new SimpleBitmapDisplayer()); DisplayImageOptions options = builder.build(); ImageLoader.getInstance().displayImage(url, this, options, imageLoadingListener); } }
Example 7
Source Project: foodie-app Source File: MyMessageFragment.java License: Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(final ViewHolder holder, int position) { // //显示作品图片的配置 // if(holder.mViewType==IS_HEADER){ // return; // }else if (holder.mViewType==IS_NORMAL){ // position=position-1; // } DisplayImageOptions worksImageOptions = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.loading_large) .showImageOnFail(R.drawable.recipe) .cacheInMemory(true) .cacheOnDisk(true) .bitmapConfig(Bitmap.Config.RGB_565) .build(); ImageLoader.getInstance().displayImage(worksList.get(position).getThumbnail(), holder.mWorksImageView, worksImageOptions); holder.mIntroductionView.setText(worksList.get(position).getIntroduction()); holder.mPostTimeView.setText(worksList.get(position).getCreateTime()); }
Example 8
Source Project: mobile-manager-tool Source File: ImageDecodingInfo.java License: MIT License | 6 votes |
public ImageDecodingInfo(String imageKey, String imageUri, String originalImageUri, ImageSize targetSize, ViewScaleType viewScaleType, ImageDownloader downloader, DisplayImageOptions displayOptions) { this.imageKey = imageKey; this.imageUri = imageUri; this.originalImageUri = originalImageUri; this.targetSize = targetSize; this.imageScaleType = displayOptions.getImageScaleType(); this.viewScaleType = viewScaleType; this.downloader = downloader; this.extraForDownloader = displayOptions.getExtraForDownloader(); considerExifParams = displayOptions.isConsiderExifParams(); decodingOptions = new Options(); copyOptions(displayOptions.getDecodingOptions(), decodingOptions); }
Example 9
Source Project: ChatView Source File: App.java License: MIT License | 6 votes |
@Override public void onCreate() { super.onCreate(); // UNIVERSAL IMAGE LOADER SETUP DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .resetViewBeforeLoading(true) .cacheOnDisk(true) .cacheInMemory(true) .imageScaleType(ImageScaleType.EXACTLY) .displayer(new FadeInBitmapDisplayer(300)) .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .defaultDisplayImageOptions(defaultOptions) .memoryCache(new WeakMemoryCache()) .diskCacheSize(100 * 1024 * 1024) .build(); ImageLoader.getInstance().init(config); // END - UNIVERSAL IMAGE LOADER SETUP }
Example 10
Source Project: Social Source File: ImageLoaderTools.java License: Apache License 2.0 | 6 votes |
private static ImageLoader initImageLoader(Context context) { DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .cacheInMemory(true) .cacheOnDisc(true) .showStubImage(R.drawable.image_holder) .showImageForEmptyUri(R.drawable.image_holder) .showImageOnFail(R.drawable.image_holder) .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .defaultDisplayImageOptions(defaultOptions)// .discCacheSize(DISK_CACHE_SIZE_BYTES) .memoryCacheSize(MEMORY_CACHE_SIZE_BYTES) .build(); ImageLoader tmpIL = ImageLoader.getInstance(); tmpIL.init(config); return tmpIL; }
Example 11
Source Project: Social Source File: ImageLoaderTools.java License: Apache License 2.0 | 6 votes |
private static ImageLoader initImageLoader(Context context) { DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .cacheInMemory(true) .cacheOnDisc(true) .showStubImage(R.drawable.image_holder) .showImageForEmptyUri(R.drawable.image_holder) .showImageOnFail(R.drawable.image_holder) .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .defaultDisplayImageOptions(defaultOptions)// .discCacheSize(DISK_CACHE_SIZE_BYTES) .memoryCacheSize(MEMORY_CACHE_SIZE_BYTES) .build(); ImageLoader tmpIL = ImageLoader.getInstance(); tmpIL.init(config); return tmpIL; }
Example 12
Source Project: fresco Source File: SampleUilFactory.java License: MIT License | 6 votes |
public static ImageLoader getImageLoader(Context context) { if (sImageLoader == null) { DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder() .showImageOnLoading(Drawables.sPlaceholderDrawable) .showImageOnFail(Drawables.sErrorDrawable) .cacheInMemory(true) .cacheOnDisk(true) .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .defaultDisplayImageOptions(displayImageOptions) .diskCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE) .memoryCacheSize(ConfigConstants.MAX_MEMORY_CACHE_SIZE) .build(); sImageLoader = ImageLoader.getInstance(); sImageLoader.init(config); } return sImageLoader; }
Example 13
Source Project: tup.dota2recipe Source File: ItemsDetailActivity.java License: Apache License 2.0 | 6 votes |
/** * 绑定视图-物品简单数据信息 * * @param v * @param cItem * @param cImageLoadOptions */ public static void bindItemsItemSimpleView(final View v, final ItemsItem cItem, final DisplayImageOptions cImageLoadOptions) { if (v == null || cItem == null || cImageLoadOptions == null) { return; } ImageLoader.getInstance().displayImage( Utils.getItemsImageUri(cItem.keyName), ((ImageView) v.findViewById(R.id.image_items)), cImageLoadOptions); ((TextView) v.findViewById(R.id.text_items_dname)).setText(cItem.dname); ((TextView) v.findViewById(R.id.text_items_dname_l)).setText(cItem.dname_l); ((TextView) v.findViewById(R.id.text_items_cost)).setText(String.valueOf(cItem.cost)); }
Example 14
Source Project: DroidDLNA Source File: ImageDisplay.java License: GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.image_display); mContext = this; options = new DisplayImageOptions.Builder() .showImageForEmptyUri(R.drawable.ic_empty) .showImageOnFail(R.drawable.ic_error).resetViewBeforeLoading() .cacheOnDisc().imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565) .displayer(new FadeInBitmapDisplayer(300)).build(); initView(); initData(); showImage(mPlayUri); addShake(); }
Example 15
Source Project: VideoMeeting Source File: App.java License: Apache License 2.0 | 6 votes |
private void initLib() { // 初始化日志功能, 开启/关闭 日志输出 L.setLogOpen(AppConstant.LOG_OPEN); // 初始化自定义异常捕获 CrashHandler.getInstance().init(this); // 初始化ImageLoader // 设置图片显示选项 DisplayImageOptions displayOp = new DisplayImageOptions.Builder() .showImageOnLoading(0)// 图片正在加载时显示的背景 .cacheInMemory(true)// 缓存在内存中 .cacheOnDisk(true)// 缓存在磁盘中 .displayer(new FadeInBitmapDisplayer(300))// 显示渐变动画 .bitmapConfig(Bitmap.Config.RGB_565) // 设置图片的解码类型 .considerExifParams(true)// 考虑旋转角 .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( getApplicationContext()).defaultDisplayImageOptions(displayOp) .denyCacheImageMultipleSizesInMemory()// 不解析多种尺寸 .build(); ImageLoader.getInstance().init(config); }
Example 16
Source Project: Android-Universal-Image-Loader-Modify Source File: ImagePagerFragment.java License: Apache License 2.0 | 5 votes |
ImageAdapter(Context context) { inflater = LayoutInflater.from(context); options = new DisplayImageOptions.Builder() .showImageForEmptyUri(R.drawable.ic_empty) .showImageOnFail(R.drawable.ic_error) .resetViewBeforeLoading(true) .cacheOnDisk(true) .imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565) .considerExifParams(true) .displayer(new FadeInBitmapDisplayer(300)) .build(); }
Example 17
Source Project: candybar Source File: ImageConfig.java License: Apache License 2.0 | 5 votes |
public static DisplayImageOptions getWallpaperOptions() { DisplayImageOptions.Builder options = new DisplayImageOptions.Builder(); options.delayBeforeLoading(10) .bitmapConfig(Bitmap.Config.ARGB_8888) .imageScaleType(ImageScaleType.EXACTLY_STRETCHED) .cacheOnDisk(true) .cacheInMemory(false); return options.build(); }
Example 18
Source Project: LLApp Source File: ImageLoaders.java License: Apache License 2.0 | 5 votes |
public static void setheadimg(int dis, String url, ImageView imageView) { if (options == null) { options = new DisplayImageOptions.Builder().showImageOnLoading(0) .showImageForEmptyUri(0).showImageOnFail(0) .cacheInMemory(true).cacheOnDisk(true) .considerExifParams(true) .displayer(new RoundedBitmapDisplayer(dis)).build(); } ImageLoader.getInstance().displayImage(url, imageView, options); }
Example 19
Source Project: JianDan_OkHttpWithVolley Source File: ImageLoadProxy.java License: Apache License 2.0 | 5 votes |
/** * 加载图片列表专用,加载前会重置View * {@link com.nostra13.universalimageloader.core.DisplayImageOptions.Builder#resetViewBeforeLoading} = true * * @param loadingResource * @return */ public static DisplayImageOptions getOptions4PictureList(int loadingResource) { return new DisplayImageOptions.Builder() .cacheInMemory(true) .cacheOnDisk(true) .bitmapConfig(Bitmap.Config.RGB_565) .resetViewBeforeLoading(true) .showImageOnLoading(loadingResource) .showImageForEmptyUri(loadingResource) .showImageOnFail(loadingResource) .build(); }
Example 20
Source Project: mobile-manager-tool Source File: ImageLoadUtil.java License: MIT License | 5 votes |
/** * 构造图片显示的配置选项 * * @param placeHolderImgRes 默认的占位显示图片 * @param emptyUrlImgRes 空链接显示的图片 * @param failedImgRes 加载失败显示的图片 * @param cacheInMemory 是否内存缓存,图片过大,建议不要内存缓存 * @return */ private static DisplayImageOptions constructDisplayOption(String url, int placeHolderImgRes, int emptyUrlImgRes, int failedImgRes, boolean cacheInMemory, BitmapDisplayer displayer) { DisplayImageOptions.Builder bulider = new DisplayImageOptions.Builder(); bulider.cacheOnDisc(true); // 默认开启磁盘缓存 缓存在默认位置 // /sdcard/Android/data/[package_name]/cache bulider.cacheInMemory(cacheInMemory); bulider.resetViewBeforeLoading(true); bulider.bitmapConfig(Bitmap.Config.RGB_565); // bulider.displayer(new FadeInBitmapDisplayer(200));//加载动画 if (displayer != null) { bulider.displayer(displayer); } if (placeHolderImgRes > 0) { bulider.showStubImage(placeHolderImgRes); } if (emptyUrlImgRes > 0) { bulider.showImageForEmptyUri(emptyUrlImgRes); } if (failedImgRes > 0) { bulider.showImageOnFail(failedImgRes); } return bulider.build(); }
Example 21
Source Project: YTPlayer Source File: Utils.java License: GNU General Public License v3.0 | 5 votes |
public static void initImageLoader(Context context) { DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_pulse) .showImageForEmptyUri(R.drawable.ic_pulse) .showImageOnFail(R.drawable.ic_pulse) .imageScaleType(ImageScaleType.IN_SAMPLE_INT) .bitmapConfig(Bitmap.Config.ARGB_8888) .displayer(new FadeInBitmapDisplayer(500)) .handler(new Handler()).build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .memoryCache(new WeakMemoryCache()).defaultDisplayImageOptions(options).memoryCacheSizePercentage(13).build(); ImageLoader.getInstance().init(config); }
Example 22
Source Project: android-open-project-demo Source File: ShowPhotoActivity.java License: Apache License 2.0 | 5 votes |
private void initData() { Intent intent = getIntent(); photoIndex = intent.getIntExtra(INTENT_PHOTO_INDEX, 0); options = new DisplayImageOptions.Builder() .showImageForEmptyUri(R.drawable.loading) .showImageOnFail(R.drawable.loading) .showImageOnLoading(R.drawable.loading) .cacheInMemory(true) .cacheOnDisk(true) .build(); }
Example 23
Source Project: snowdream-books-android Source File: SubjectAdapter.java License: Apache License 2.0 | 5 votes |
public SubjectAdapter(Context context, List<Book> list) { this.context = context; this.list = list; inflater = (LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE); language = Locale.getDefault().getLanguage(); options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_book) .showImageForEmptyUri(R.drawable.ic_book) .showImageOnFail(R.drawable.ic_book) .displayer(new FadeInBitmapDisplayer(500)) .build(); }
Example 24
Source Project: DevUtils Source File: ImageLoaderUtils.java License: Apache License 2.0 | 5 votes |
/** * 获取图片渐变动画加载配置 * @param options {@link DisplayImageOptions} * @param durationMillis 动画持续时间 * @return {@link DisplayImageOptions} */ public static DisplayImageOptions getFadeInBitmapDisplayer(final DisplayImageOptions options, final int durationMillis) { if (options != null) { return getBitmapDisplayerOptions(options, new FadeInBitmapDisplayer(durationMillis)); } return options; }
Example 25
Source Project: BigApp_WordPress_Android Source File: ViewerImageLoader.java License: Apache License 2.0 | 5 votes |
private DisplayImageOptions.Builder getOptions() { return new DisplayImageOptions.Builder() .showImageForEmptyUri(R.drawable.zg_default_pic_beizi_64) .showImageOnFail(R.drawable.zg_default_pic_beizi_64) .showImageOnLoading(R.drawable.zg_default_pic_beizi_64) .imageScaleType(ImageScaleType.IN_SAMPLE_INT) .bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true) .displayer(new FadeInBitmapDisplayer(300)); }
Example 26
Source Project: DevUtils Source File: ImageLoaderUtils.java License: Apache License 2.0 | 5 votes |
/** * 获取圆角图片加载配置 * @param options {@link DisplayImageOptions} * @param cornerRadiusPixels 圆角大小 * @return {@link DisplayImageOptions} */ public static DisplayImageOptions getRoundedBitmapDisplayer(final DisplayImageOptions options, final int cornerRadiusPixels) { if (options != null) { return getBitmapDisplayerOptions(options, new RoundedBitmapDisplayer(cornerRadiusPixels)); } return options; }
Example 27
Source Project: DevUtils Source File: ImageLoaderUtils.java License: Apache License 2.0 | 5 votes |
/** * 获取图片效果加载配置 * @param options {@link DisplayImageOptions} * @param displayer {@link BitmapDisplayer} * @return {@link DisplayImageOptions} */ public static DisplayImageOptions getBitmapDisplayerOptions(final DisplayImageOptions options, final BitmapDisplayer displayer) { if (options != null && displayer != null) { return cloneImageOptions(options).displayer(displayer).build(); } return null; }
Example 28
Source Project: DevUtils Source File: ImageLoaderUtils.java License: Apache License 2.0 | 5 votes |
/** * 图片显示 * @param uri Image Uri * @param imageView ImageView * @param options {@link DisplayImageOptions} */ public static void displayImage(final String uri, final ImageView imageView, final DisplayImageOptions options) { if (imageView != null) { // 判断是否使用自定义图片加载配置 if (options != null) { ImageLoader.getInstance().displayImage(uri, imageView, options); } else { ImageLoader.getInstance().displayImage(uri, imageView); } } }
Example 29
Source Project: SimplifyReader Source File: ImageLoaderHelper.java License: Apache License 2.0 | 5 votes |
public DisplayImageOptions getDisplayOptions(Drawable drawable) { return new DisplayImageOptions.Builder() .showImageOnLoading(drawable) .showImageForEmptyUri(drawable) .showImageOnFail(drawable) .cacheInMemory(true) .bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY) .cacheOnDisk(true) .considerExifParams(true) .build(); }
Example 30
Source Project: Android-Universal-Image-Loader-Modify Source File: ImageListFragment.java License: Apache License 2.0 | 5 votes |
ImageAdapter(Context context) { inflater = LayoutInflater.from(context); options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_stub) .showImageForEmptyUri(R.drawable.ic_empty) .showImageOnFail(R.drawable.ic_error) .cacheInMemory(true) .cacheOnDisk(true) .considerExifParams(true) .displayer(new RoundedVignetteBitmapDisplayer(20,10)) .build(); }