CategoryController(final Activity activity, LoaderManager loaderManager, View itemView) { super(itemView); this.activity = activity; this.loaderManager = loaderManager; appCardsAdapter = new AppPreviewAdapter(activity); viewAll = (Button) itemView.findViewById(R.id.button); viewAll.setOnClickListener(onViewAll); heading = (TextView) itemView.findViewById(R.id.name); image = (FeatureImage) itemView.findViewById(R.id.category_image); background = (FrameLayout) itemView.findViewById(R.id.category_background); RecyclerView appCards = (RecyclerView) itemView.findViewById(R.id.app_cards); appCards.setAdapter(appCardsAdapter); appCards.addItemDecoration(new ItemDecorator(activity)); displayImageOptions = new DisplayImageOptions.Builder() .cacheInMemory(true) .imageScaleType(ImageScaleType.NONE) .displayer(new FadeInBitmapDisplayer(100, true, true, false)) .bitmapConfig(Bitmap.Config.RGB_565) .build(); }
/** * 图片显示配置 * * @return */ public static DisplayImageOptions getImageLoaderOptions() { BitmapFactory.Options op = new BitmapFactory.Options(); op.inSampleSize = 4; DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_account_circle) .showImageForEmptyUri(R.drawable.ic_account_circle) .showImageOnFail(R.drawable.ic_account_circle) .bitmapConfig(Bitmap.Config.RGB_565) .cacheInMemory(true) .cacheOnDisk(true) .decodingOptions(op) .displayer(new FadeInBitmapDisplayer(animTime)) // 设置动画淡入效果 .build(); return options; }
/** * 图片显示配置 * * @return */ public static DisplayImageOptions getImageLoaderOptions(int defaultIconId) { BitmapFactory.Options op = new BitmapFactory.Options(); op.inSampleSize = 4; DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(defaultIconId) .showImageForEmptyUri(defaultIconId) .showImageOnFail(defaultIconId) .bitmapConfig(Bitmap.Config.RGB_565) .cacheInMemory(true) .cacheOnDisk(true) .displayer(new FadeInBitmapDisplayer(animTime)) // 设置动画淡入效果 .decodingOptions(op) .build(); return options; }
/** * 图片显示配置 * * @return */ public static DisplayImageOptions getImageLoaderOptions(int loadingImgId, int emptyUriImgId, int failImgId) { BitmapFactory.Options op = new BitmapFactory.Options(); op.inSampleSize = 4; DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(loadingImgId) .showImageForEmptyUri(emptyUriImgId) .showImageOnFail(failImgId) .bitmapConfig(Bitmap.Config.RGB_565) .cacheInMemory(true) .cacheOnDisk(true) .displayer(new FadeInBitmapDisplayer(animTime)) // 设置动画淡入效果 .decodingOptions(op) .build(); return options; }
public WallpapersAdapter(@NonNull Context context, @NonNull List<Wallpaper> wallpapers, boolean isFavoriteMode, boolean isSearchMode) { mContext = context; mWallpapers = wallpapers; mIsFavoriteMode = isFavoriteMode; WallpaperBoardApplication.sIsClickable = true; if (isSearchMode) { mWallpapersAll = new ArrayList<>(); mWallpapersAll.addAll(mWallpapers); } mOptions = ImageConfig.getRawDefaultImageOptions(); mOptions.resetViewBeforeLoading(true); mOptions.cacheInMemory(true); mOptions.cacheOnDisk(true); mOptions.displayer(new FadeInBitmapDisplayer(700)); }
/** * 获取一个渐显图片的配置 * * @return */ public static DisplayImageOptions getFadeInOption(int durationMillis, boolean animateFromNetwork, boolean animateFromDisk, boolean animateFromMemory) { DisplayImageOptions options = new DisplayImageOptions.Builder() . // 网络图片下载完成之前的预加载的默认图片 showImageOnLoading(R.mipmap.ic_launcher) . // 网络图片下载失败后显示该默认图片 showImageOnFail(R.mipmap.ic_launcher) . // 图片的质量 bitmapConfig(Bitmap.Config.RGB_565) .cacheInMemory(true) .cacheOnDisk(true) .displayer( new FadeInBitmapDisplayer(durationMillis, animateFromNetwork, animateFromDisk, animateFromMemory)).build(); return options; }
/** * 为ImageView设置图片 * * @param viewId * @return */ public ViewHolder setImageByUrl(int viewId, String url) { ImageView iv = getView(viewId); DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.mipmap.ic_launcher) .showImageOnFail(R.mipmap.ic_launcher) // 设置图片质量 .bitmapConfig(Bitmap.Config.RGB_565) // 设置内存缓存 .cacheInMemory(true) // 设置磁盘缓存 .cacheOnDisk(true) // 设置图片特效 .displayer(new FadeInBitmapDisplayer(300)).build(); ImageLoader.getInstance().displayImage(url,iv, ImageLoaderUtil.getFadeInOption(200,true,true,true)); return this; }
private void initImageLoader() { ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this) .threadPoolSize(5) .threadPriority(Thread.NORM_PRIORITY - 2) .denyCacheImageMultipleSizesInMemory() .memoryCache(new LruMemoryCache(2 * 1024)) .memoryCacheSize(2 * 1024) .defaultDisplayImageOptions(new DisplayImageOptions.Builder() .showImageForEmptyUri(R.drawable.no_photo_group) .showImageOnFail(R.drawable.no_photo_group) .resetViewBeforeLoading(true) .displayer(new FadeInBitmapDisplayer(300)).build()) .tasksProcessingOrder(QueueProcessingType.LIFO).build(); ImageLoader.getInstance().init(config); com.nostra13.universalimageloader.utils.L.writeLogs(false); }
public RequestAdapter(@NonNull Context context, @NonNull List<Request> requests, int spanCount) { mContext = context; mRequests = requests; mTextColorSecondary = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorSecondary); mTextColorAccent = ColorHelper.getAttributeColor(mContext, R.attr.colorAccent); mSelectedItems = new SparseBooleanArray(); mShowShadow = (spanCount == 1); mShowPremiumRequest = Preferences.get(mContext).isPremiumRequestEnabled(); mOptions = ImageConfig.getRawDefaultImageOptions(); mOptions.resetViewBeforeLoading(true); mOptions.cacheInMemory(true); mOptions.cacheOnDisk(false); mOptions.showImageOnFail(R.drawable.ic_app_default); mOptions.displayer(new FadeInBitmapDisplayer(700)); }
public DisplayImageOptions getDisplayOptions() { DisplayImageOptions options; options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.loading) // 设置图片在下载期间显示的图片 .showImageForEmptyUri(R.drawable.load_fail)// 设置图片Uri为空或是错误的时候显示的图片 .showImageOnFail(R.drawable.loading) // 设置图片加载/解码过程中错误时候显示的图片 .cacheInMemory(true)// 设置下载的图片是否缓存在内存中 .cacheOnDisk(true) //外存缓存 .cacheOnDisc(true)// 设置下载的图片是否缓存在SD卡中 .considerExifParams(true) // 是否考虑JPEG图像EXIF参数(旋转,翻转) .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)// 设置图片以如何的编码方式显示 .bitmapConfig(Bitmap.Config.RGB_565)// 设置图片的解码类型// // .delayBeforeLoading(int delayInMillis)//int // delayInMillis为你设置的下载前的延迟时间 // 设置图片加入缓存前,对bitmap进行设置 // .preProcessor(BitmapProcessor preProcessor) .resetViewBeforeLoading(true)// 设置图片在下载前是否重置,复位 // .displayer(new RoundedBitmapDisplayer(20))// 是否设置为圆角,弧度为多少 .displayer(new FadeInBitmapDisplayer(50))// 是否图片加载好后渐入的动画时间 .build();// 构建完成 return options; }
/** * 初始化 * * @param context */ private UILKit(Context context) { File cacheDir = getDiskCacheDir(context, "img"); ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context) .threadPriority(Thread.NORM_PRIORITY - 2) .denyCacheImageMultipleSizesInMemory() .memoryCacheSize(10 * 1024 * 1024) .diskCache(new UnlimitedDiskCache(cacheDir)) .diskCacheFileNameGenerator(new Md5FileNameGenerator()) .diskCacheSize(50 * 1024 * 1024) // 50 MiB .tasksProcessingOrder(QueueProcessingType.LIFO); ImageLoader.getInstance().init(config.build()); picOptions = new DisplayImageOptions.Builder() .imageScaleType(ImageScaleType.EXACTLY) .cacheOnDisk(false).cacheInMemory(false) .resetViewBeforeLoading(true) .displayer(new FadeInBitmapDisplayer(500)).build(); }
private static DisplayImageOptions getDisplayImageOptionsFactory(int resId) { if (mOptionsMap.containsKey(resId)) { return mOptionsMap.get(resId); } DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder(); builder.imageScaleType(ImageScaleType.EXACTLY).cacheOnDisk(true) .cacheInMemory(true).bitmapConfig(Bitmap.Config.RGB_565) .displayer(new FadeInBitmapDisplayer(300)); if (resId != 0) { builder.showImageOnFail(resId).showImageForEmptyUri(resId) .showImageOnLoading(resId); } mOptions = builder.build(); mOptionsMap.put(resId, mOptions); return mOptions; }
@Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { if (imageUri.equals(view.getTag())) { L.e(String.valueOf(view.getTag())); ((ImageView)view).setImageBitmap(loadedImage); return; } if (loadedImage != null) { ImageView imageView = (ImageView) view; boolean firstDisplay = !displayedImages.contains(imageUri); if (firstDisplay) { FadeInBitmapDisplayer.animate(imageView, 500); displayedImages.add(imageUri); } } }
public MessageChatAdapter(Context context,List<BmobMsg> msgList) { super(context, msgList); currentObjectId = BmobUserManager.getInstance(context).getCurrentUserObjectId(); options = new DisplayImageOptions.Builder() .showImageForEmptyUri(R.drawable.ic_launcher) .showImageOnFail(R.drawable.ic_launcher) .resetViewBeforeLoading(true) .cacheOnDisc(true) .cacheInMemory(true) .imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565) .considerExifParams(true) .displayer(new FadeInBitmapDisplayer(300)) .build(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_img_page); options = new DisplayImageOptions.Builder() .resetViewBeforeLoading(true) .cacheOnDisc(true) .imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565) .considerExifParams(true) .displayer(new FadeInBitmapDisplayer(0)) .build(); url=getIntent().getStringExtra("url"); initView(); initData(); }
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); }
public MessageChatAdapter(Context context,List<BmobMsg> msgList) { // TODO Auto-generated constructor stub super(context, msgList); currentObjectId = BmobUserManager.getInstance(context).getCurrentUserObjectId(); options = new DisplayImageOptions.Builder() .showImageForEmptyUri(R.drawable.ic_launcher) .showImageOnFail(R.drawable.ic_launcher) .resetViewBeforeLoading(true) .cacheOnDisc(true) .cacheInMemory(true) .imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565) .considerExifParams(true) .displayer(new FadeInBitmapDisplayer(300)) .build(); }
@SuppressWarnings("deprecation") private DisplayImageOptions getDisplayOptions() { DisplayImageOptions options; options = new DisplayImageOptions.Builder().showImageOnLoading(R.mipmap.ic_launcher) // 设置图片在下载期间显示的图片 .showImageForEmptyUri(R.mipmap.ic_launcher)// 设置图片Uri为空或是错误的时候显示的图片 .showImageOnFail(R.mipmap.ic_launcher) // 设置图片加载/解码过程中错误时候显示的图片 .cacheInMemory(true)// 设置下载的图片是否缓存在内存中 .cacheOnDisc(true)// 设置下载的图片是否缓存在SD卡中 .considerExifParams(true) // 是否考虑JPEG图像EXIF参数(旋转,翻转) .imageScaleType(ImageScaleType.IN_SAMPLE_INT)// 设置图片以如何的编码方式显示 .bitmapConfig(Bitmap.Config.RGB_565)// 设置图片的解码类型// // .delayBeforeLoading(int delayInMillis)//int // delayInMillis为你设置的下载前的延迟时间 // 设置图片加入缓存前,对bitmap进行设置 // .preProcessor(BitmapProcessor preProcessor) .resetViewBeforeLoading(true)// 设置图片在下载前是否重置,复位 .displayer(new RoundedBitmapDisplayer(20))// 是否设置为圆角,弧度为多少 .displayer(new FadeInBitmapDisplayer(100))// 是否图片加载好后渐入的动画时间 .build();// 构建完成 return options; }
/** * ����loader ��options �� config * @param context */ public static void initImageLoader(Context context) { DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.default_face) .showImageForEmptyUri(R.drawable.default_face) .showImageOnFail(R.drawable.default_face).cacheInMemory(true) .considerExifParams(true) .displayer(new FadeInBitmapDisplayer(300, true, true, true)) .imageScaleType(ImageScaleType.EXACTLY_STRETCHED) .bitmapConfig(Bitmap.Config.RGB_565).build(); ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder( context).defaultDisplayImageOptions(defaultOptions) .memoryCache(new WeakMemoryCache()); ImageLoaderConfiguration config = builder.build(); ImageLoader.getInstance().init(config); }
/** * 初始化UniversalImageLoader */ private void configUniversalImageLoader() { DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .cacheInMemory().cacheOnDisc() .bitmapConfig(Bitmap.Config.RGB_565) .displayer(new FadeInBitmapDisplayer(500)) .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this). diskCacheFileCount(500) .diskCacheSize(50 * 1024 * 1024). imageDownloader(new BaseImageDownloader(this, 10 * 1000, 20 * 1000)) .memoryCacheSize((int) Runtime.getRuntime().maxMemory() / 8) .defaultDisplayImageOptions(defaultOptions).build(); ImageLoader.getInstance().init(config); }
private DisplayImageOptions getDisplayOptions() { DisplayImageOptions options; options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.logo) // 设置图片在下载期间显示的图片 .showImageForEmptyUri(R.drawable.logo)// 设置图片Uri为空或是错误的时候显示的图片 .showImageOnFail(R.drawable.logo) // 设置图片加载/解码过程中错误时候显示的图片 .cacheInMemory(true)// 设置下载的图片是否缓存在内存中 .cacheOnDisc(true)// 设置下载的图片是否缓存在SD卡中 .considerExifParams(true) // 是否考虑JPEG图像EXIF参数(旋转,翻转) .imageScaleType(ImageScaleType.IN_SAMPLE_INT)// 设置图片以如何的编码方式显示 .bitmapConfig(Bitmap.Config.RGB_565)// 设置图片的解码类型// // .delayBeforeLoading(int delayInMillis)//int // delayInMillis为你设置的下载前的延迟时间 // 设置图片加入缓存前,对bitmap进行设置 // .preProcessor(BitmapProcessor preProcessor) .resetViewBeforeLoading(true)// 设置图片在下载前是否重置,复位 .displayer(new RoundedBitmapDisplayer(20))// 是否设置为圆角,弧度为多少 .displayer(new FadeInBitmapDisplayer(100))// 是否图片加载好后渐入的动画时间 .build();// 构建完成 return options; }
public static DisplayImageOptions getDefaultOptions() { DisplayImageOptions options; options = new DisplayImageOptions.Builder() // .showImageOnLoading(R.drawable.empty_photo) // 设置图片在下载期间显示的图片 .showImageForEmptyUri(R.drawable.empty_photo)// 设置图片Uri为空或是错误的时候显示的图片 .showImageOnFail(R.drawable.empty_photo) // 设置图片加载/解码过程中错误时候显示的图片 .cacheInMemory(true)// 设置下载的图片是否缓存在内存中 .cacheOnDisc(true)// 设置下载的图片是否缓存在SD卡中 .considerExifParams(true) // 是否考虑JPEG图像EXIF参数(旋转,翻转) .imageScaleType(ImageScaleType.IN_SAMPLE_INT)// 设置图片以如何的编码方式显示 .bitmapConfig(Bitmap.Config.RGB_565)// 设置图片的解码类型// // .delayBeforeLoading(100)//int // delayInMillis为你设置的下载前的延迟时间 // 设置图片加入缓存前,对bitmap进行设置 // .preProcessor(BitmapProcessor preProcessor) .resetViewBeforeLoading(true)// 设置图片在下载前是否重置,复位 // .displayer(new RoundedBitmapDisplayer(20))//是否设置为圆角,弧度为多少 .displayer(new FadeInBitmapDisplayer(300))// 是否图片加载好后渐入的动画时间 .build();// 构建完成 return options; }
@Override public void onCreate() { super.onCreate(); DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .cacheInMemory(true) .cacheOnDisk(true) .displayer(new FadeInBitmapDisplayer(200, true, false, false)) .imageScaleType(ImageScaleType.EXACTLY) // default .resetViewBeforeLoading(true) .considerExifParams(true) .build(); // Create global configuration and initialize ImageLoader with this configuration ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .defaultDisplayImageOptions(defaultOptions) .memoryCache(new WeakMemoryCache()) .build(); ImageLoader.getInstance().init(config); }
public MapInfoWindowAdapter(LayoutInflater inflater, AbstractMapFragment<? extends MapModel> callback) { mInflater = inflater; mCallback = callback; mImageLoader = ImageLoader.getInstance(); @SuppressWarnings("deprecation") ImageLoaderConfiguration configs = new ImageLoaderConfiguration.Builder( inflater.getContext()).memoryCacheSize(5 * 1024 * 1024) .discCacheSize(5 * 1024 * 1024).build(); mImageLoader.init(configs); mOptions = new DisplayImageOptions.Builder() .showImageForEmptyUri(R.mipmap.ic_launcher) .showImageOnFail(R.mipmap.ic_launcher) .resetViewBeforeLoading(true).cacheOnDisc(true) .cacheInMemory(true) .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) .bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true) .displayer(new FadeInBitmapDisplayer(300)).build(); }
private void initImageLoader() { if (!ImageLoader.getInstance().isInited()) { DisplayImageOptions.Builder displayBuilder = new DisplayImageOptions.Builder(); displayBuilder.cacheInMemory(true); displayBuilder.cacheOnDisk(true); displayBuilder.showImageOnLoading(com.ns.mutiphotochoser.R.drawable.default_photo); displayBuilder.showImageForEmptyUri(com.ns.mutiphotochoser.R.drawable.default_photo); displayBuilder.considerExifParams(true); displayBuilder.bitmapConfig(Bitmap.Config.RGB_565); displayBuilder.imageScaleType(ImageScaleType.EXACTLY); displayBuilder.displayer(new FadeInBitmapDisplayer(300)); ImageLoaderConfiguration.Builder loaderBuilder = new ImageLoaderConfiguration.Builder(getApplication()); loaderBuilder.defaultDisplayImageOptions(displayBuilder.build()); loaderBuilder.memoryCacheSize(getMemoryCacheSize()); try { File cacheDir = new File(getExternalCacheDir() + File.separator + CacheConstant.IMAGE_CACHE_DIRECTORY); loaderBuilder.diskCache(new LruDiscCache(cacheDir, DefaultConfigurationFactory.createFileNameGenerator(), 500 * 1024 * 1024)); } catch (IOException e) { e.printStackTrace(); } ImageLoader.getInstance().init(loaderBuilder.build()); } }
@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(); }
/** * 新闻列表中用到的图片加载配置 * */ public static DisplayImageOptions getListOptions() { DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.small_image_holder_listpage)// 设置图片在下载期间显示的图片 .showImageForEmptyUri(R.drawable.small_image_holder_listpage)// 设置图片Uri为空或是错误的时候显示的图片 .showImageOnFail(R.drawable.small_image_holder_listpage)// 设置图片加载/解码过程中错误时候显示的图片 .cacheInMemory(true) .cacheOnDisc(true) .considerExifParams(true) .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)// 设置图片以如何的编码方式显示 .bitmapConfig(Bitmap.Config.RGB_565)// 设置图片的解码类型 .resetViewBeforeLoading(true)// 设置图片在下载前是否重置,复位 .displayer(new RoundedBitmapDisplayer(20))//是否设置为圆角,弧度为多少 .displayer(new FadeInBitmapDisplayer(100)) .build(); return options; }
public static DisplayImageOptions getOptions() { return new DisplayImageOptions.Builder() // // 设置图片在下载期间显示的图片 .showImageOnLoading(R.drawable.ic_default_image) // // 设置图片Uri为空或是错误的时候显示的图片 .showImageForEmptyUri(R.drawable.ic_default_image) // // 设置图片加载/解码过程中错误时候显示的图片 .showImageOnFail(R.drawable.image_not_exist) .cacheInMemory(true)// 设置下载的图片是否缓存在内存中 .cacheOnDisk(true)// 设置下载的图片是否缓存在SD卡中 .considerExifParams(true) .imageScaleType(ImageScaleType.EXACTLY)// 设置图片以如何的编码方式显示 .bitmapConfig(Bitmap.Config.RGB_565)// 设置图片的解码类型 .considerExifParams(true) .resetViewBeforeLoading(true)// 设置图片在下载前是否重置,复位 // .displayer(new RoundedBitmapDisplayer(20))//是否设置为圆角,弧度为多少 .displayer(new FadeInBitmapDisplayer(100))// 淡入 .build(); }
/** 图片加载配置 */ public static DisplayImageOptions getImagesOptions() { DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_images_default) .showImageForEmptyUri(R.drawable.ic_images_default) .showImageOnFail(R.drawable.ic_images_default) .resetViewBeforeLoading(true) .cacheInMemory(true) .cacheOnDisc(true) .considerExifParams(true) .imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.ARGB_8888) // .displayer(new RoundedBitmapDisplayer(200)) .displayer(new FadeInBitmapDisplayer(800))// 淡入 .build(); return options; }
ImageAdapter(ImagePagerFragment fragment, List<Parcelable> titledPhotos) { this.options = new DisplayImageOptions.Builder() .showImageForEmptyUri(R.drawable.ic_empty) .showImageOnFail(R.drawable.ic_error) //.resetViewBeforeLoading(true) .cacheOnDisk(true) .cacheInMemory(false) .imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565) .considerExifParams(true) .displayer(new FadeInBitmapDisplayer(300)) .build(); this.fragment = fragment; this.mImagesURLArray = titledPhotos; }
public ImageElementAdapter(Activity activity, List<ImageElement> imageItems,ImageListFragment imageListFragment) { this.activity = activity; this.imageItems = imageItems; inflater = (LayoutInflater) this.activity.getApplicationContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); //this.currentContext = this.activity.getApplicationContext(); this.imageListFragment = imageListFragment; this.options = new DisplayImageOptions.Builder() .cacheInMemory(true) .displayer(new FadeInBitmapDisplayer(700)) .showImageOnLoading(R.color.golden_brown) .showImageForEmptyUri(R.color.golden_brown) .cacheOnDisk(true) .considerExifParams(true) .build(); }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = (LinearLayout) inflater.inflate(rowID, null); } // set value to item DistributorObj obj = (DistributorObj) getItem(position); TextView name = (TextView) convertView.findViewById(R.id.base_title); name.setText(obj.getName()); ImageView icon = (ImageView) convertView.findViewById(R.id.base_icon); DisplayImageOptions options = new DisplayImageOptions.Builder() .cacheInMemory(true).cacheOnDisc(true) .displayer(new FadeInBitmapDisplayer(1000)) .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2).build(); TextView records = (TextView) convertView.findViewById(R.id.base_item_records); records.setText(Integer.toString(obj.getRecords())); imageLoader.displayImage(obj.getIcon(), icon, options); return convertView; }
private void initiImageLoader() { DisplayImageOptions options = new DisplayImageOptions.Builder() .bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY) .cacheOnDisc(true) .displayer(new FadeInBitmapDisplayer(200)) .showImageOnLoading(R.drawable.ic_launcher) .build(); File cacheDir; if(Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED){ cacheDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES); }else{ cacheDir = getCacheDir(); } ImageLoaderConfiguration.Builder configBuilder = new ImageLoaderConfiguration.Builder(mContext) .threadPoolSize(2) .memoryCache(new WeakMemoryCache()) .denyCacheImageMultipleSizesInMemory() .discCache(new UnlimitedDiscCache(cacheDir)) .defaultDisplayImageOptions(options); if(BuildConfig.DEBUG){ configBuilder.writeDebugLogs(); } ImageLoader.getInstance().init(configBuilder.build()); }
public static void initImageLoader(Context context) { UnlimitedDiscCache localUnlimitedDiscCache = new UnlimitedDiscCache( new File(GlobalConfig.getFirstStoragePath() + "cache"), new File(context.getCacheDir() + File.separator + "imgs")); DisplayImageOptions localDisplayImageOptions = new DisplayImageOptions.Builder() .resetViewBeforeLoading(true) .cacheOnDisk(true) .cacheInMemory(true) .bitmapConfig(Bitmap.Config.RGB_565) .resetViewBeforeLoading(true) .displayer(new FadeInBitmapDisplayer(250)).build(); ImageLoaderConfiguration localImageLoaderConfiguration = new ImageLoaderConfiguration.Builder(context) .diskCache(localUnlimitedDiscCache) .defaultDisplayImageOptions(localDisplayImageOptions).build(); ImageLoader.getInstance().init(localImageLoaderConfiguration); }
@Override public void onCreate() { super.onCreate(); Crashlytics.start(this); // Do init here FlowAsyncClient.init(getApplicationContext()); DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .cacheInMemory(true) .cacheOnDisc(true) .displayer(new FadeInBitmapDisplayer(500)) .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .defaultDisplayImageOptions(defaultOptions) .build(); ImageLoader.getInstance().init(config); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (preferences != null) { mIsUserLoggedIn = preferences.getBoolean(IS_USER_LOGGED_IN_KEY, false); } getMixpanel(); }
public static ImageLoader getImageLoader(Context context){ try { if (ImageLoader.getInstance().isInited()) { return ImageLoader.getInstance(); } DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.loading) .showImageForEmptyUri(R.drawable.loading) .showImageOnFail(R.drawable.loading) .cacheInMemory(true) .cacheOnDisk(true) .displayer(new FadeInBitmapDisplayer(1000)) .bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY) .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .memoryCacheExtraOptions(480, 320) .diskCacheExtraOptions(480, 320, null) .defaultDisplayImageOptions(defaultOptions).build(); ImageLoader.getInstance().init(config); return ImageLoader.getInstance(); } catch (Exception ex) { Log.e("ImageLoaderHelper", "Error loading image: " + ex); return null; } }
@Override public void onLoadingComplete(final String imageUri, View view, Bitmap loadedImage) { if (loadedImage != null) { final ImageView imageView = (ImageView) view; boolean firstDisplay = !displayedImages.contains(imageUri); if (firstDisplay) { CodeUtils.runOnUIThread(new Runnable() { @Override public void run() { FadeInBitmapDisplayer.animate(imageView, 500); displayedImages.add(imageUri); } }); } } }
@Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { if (loadedImage != null) { ImageView imageView = (ImageView) view; imageView.setLayoutParams(new RelativeLayout.LayoutParams(500, 500)); imageView.setScaleType(ScaleType.FIT_START); imageView.setImageBitmap(loadedImage); boolean firstDisplay = !displayedImages.contains(imageUri); if (firstDisplay) { FadeInBitmapDisplayer.animate(imageView, 500); displayedImages.add(imageUri); } } }