本文整理汇总了Java中com.nostra13.universalimageloader.core.DisplayImageOptions类的典型用法代码示例。如果您正苦于以下问题:Java DisplayImageOptions类的具体用法?Java DisplayImageOptions怎么用?Java DisplayImageOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DisplayImageOptions类属于com.nostra13.universalimageloader.core包,在下文中一共展示了DisplayImageOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOption
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
/**获取配置
* @param cornerRadiusSize
* @param defaultImageResId
* @return
*/
@SuppressWarnings("deprecation")
private static DisplayImageOptions getOption(int cornerRadiusSize, int defaultImageResId) {
Options options0 = new Options();
options0.inPreferredConfig = Bitmap.Config.RGB_565;
DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder();
if(defaultImageResId > 0) {
try {
builder.showImageForEmptyUri(defaultImageResId)
.showImageOnLoading(defaultImageResId)
.showImageOnFail(defaultImageResId);
} catch (Exception e) {
Log.e(TAG, "getOption try {builder.showImageForEmptyUri(defaultImageResId) ..." +
" >> } catch (Exception e) { \n" + e.getMessage());
}
}
if (cornerRadiusSize > 0) {
builder.displayer(new RoundedBitmapDisplayer(cornerRadiusSize));
}
return builder.cacheInMemory(true).cacheOnDisc(true).decodingOptions(options0).build();
}
示例2: initImageLoader
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void initImageLoader() {
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
this)
.memoryCacheExtraOptions(480, 800)
// default = device screen dimensions
.threadPoolSize(3)
// default
.threadPriority(Thread.NORM_PRIORITY - 1)
// default
.tasksProcessingOrder(QueueProcessingType.FIFO)
// default
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new LruMemoryCache(2 * 1024 * 1024))
.memoryCacheSize(2 * 1024 * 1024).memoryCacheSizePercentage(13) // default
.discCacheSize(50 * 1024 * 1024) // 缓冲大小
.discCacheFileCount(100) // 缓冲文件数目
.discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
.imageDownloader(new BaseImageDownloader(this)) // default
.defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
.writeDebugLogs().build();
// 2.单例ImageLoader类的初始化
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.init(config);
}
示例3: getImageLoader
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
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;
}
示例4: ImageDecodingInfo
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
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);
}
示例5: getCircleOption
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
/**
* 获取一个圆形的配置
*
* @return
*/
public static DisplayImageOptions getCircleOption(Integer strokeColor,
float strokeWidth)
{
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 CircleBitmapDisplayer(strokeColor, strokeWidth))
.build();
return options;
}
示例6: onCreateView
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
.cacheInMemory(true)
.cacheOnDisk(true)
.imageScaleType(ImageScaleType.NONE)
.showImageOnLoading(R.drawable.screenshot_placeholder)
.showImageForEmptyUri(R.drawable.screenshot_placeholder)
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
View rootView = inflater.inflate(R.layout.activity_screenshots_page, container, false);
ImageView screenshotView = (ImageView) rootView.findViewById(R.id.screenshot);
ImageLoader.getInstance().displayImage(screenshotUrl, screenshotView, displayImageOptions);
return rootView;
}
示例7: getDefaultOption
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
/**
* 获取一个默认的配置
*
* @return
*/
public static DisplayImageOptions getDefaultOption()
{
DisplayImageOptions options = new DisplayImageOptions.Builder()
.
// 网络图片下载完成之前的预加载的默认图片
showImageOnLoading(R.mipmap.ic_launcher)
.
// 网络图片下载失败后显示该默认图片
showImageOnFail(R.mipmap.ic_launcher)
.
// 图片的质量
bitmapConfig(Bitmap.Config.RGB_565).cacheInMemory(true)
.cacheOnDisk(true).build();
return options;
}
示例8: CategoryController
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
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();
}
示例9: loadImageAndExtractColour
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
private void loadImageAndExtractColour(@NonNull ImageLoader loader, @NonNull DisplayImageOptions imageOptions, String url) {
loader.loadImage(url, imageOptions, new ImageLoadingAdapter() {
@Override
public void onLoadingComplete(String imageUri, View view, final Bitmap loadedImage) {
if (loadedImage != null) {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
if (palette != null) {
setColorAndAnimateChange(palette.getDominantColor(Color.LTGRAY));
}
}
});
}
}
});
}
示例10: onAfterViews
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
@Override
public void onAfterViews() {
initToolbar();
mContext = this;
mContentResolver = getContentResolver();
mImageLoader = ImageLoader.getInstance();
options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.mipmap.ic_launcher)
.showImageForEmptyUri(R.mipmap.ic_launcher)
.showImageOnFail(R.mipmap.ic_launcher)
.cacheInMemory(false)
.cacheOnDisk(true)
.considerExifParams(true)
.imageScaleType(ImageScaleType.EXACTLY)
.bitmapConfig(Bitmap.Config.RGB_565).build();
initViews();
}
示例11: getDefaultConfig
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
/**
* 获取图片加载器的图片的配置
*
* @param isRound 是否是加载圆形图片
* @param defaultRes 默认图片ID
* @return 返回配置
*/
public static DisplayImageOptions getDefaultConfig(boolean isRound,int defaultRes) {
DisplayImageOptions.Builder builder=new DisplayImageOptions.Builder();
// 设置缓存到内存和SD卡中,设置图片的解码格式
builder.cacheInMemory(true).cacheOnDisk(true).bitmapConfig(Bitmap.Config.RGB_565);
// 考虑JPEG图像EXIF参数(旋转和翻转)
builder.imageScaleType(ImageScaleType.EXACTLY_STRETCHED);
// 设置圆形图片
if (isRound) {
builder.considerExifParams(true).displayer(new RoundedBitmapDisplayer(12));
}
// 设置下载前图片重置复位
builder.resetViewBeforeLoading(true);
// 设置图片下载失败的时候加载默认的图片
if (defaultRes != 0) {
builder.showImageForEmptyUri(defaultRes).showImageOnFail(defaultRes);
}
return builder.build();
}
示例12: getImageLoaderOptions
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
/**
* ImageLoader组件加载图片默认配置
* 显示大量的图片,当我们快速滑动GridView,ListView,希望能停止图片的加载时使用如下设置:
* listView.setOnScrollListener(new PauseOnScrollListener(imageLoader, pauseOnScroll, pauseOnFling));
* gridView.setOnScrollListener(new PauseOnScrollListener(imageLoader, pauseOnScroll, pauseOnFling));
*
* @param loadingId
* @param failId
* @param cacheOnMemory
* @param cacheOnDinsk
* @return
*/
public static DisplayImageOptions getImageLoaderOptions(int loadingId, int failId, boolean cacheOnMemory, boolean cacheOnDinsk) {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(loadingId) //如果不需要设置则传0,设置该值刷新的时候会有闪烁现象
.showImageForEmptyUri(failId) // 设置图片Uri为空或是错误的时候显示的图片
.showImageOnFail(failId) // 设置图片加载或解码过程中发生错误显示的图片
.cacheInMemory(cacheOnMemory) // default 设置下载的图片是否缓存在内存中
.cacheOnDisk(cacheOnDinsk) // default 设置下载的图片是否缓存在SD卡中
.bitmapConfig(Bitmap.Config.RGB_565) // default 设置图片的解码类型
// .resetViewBeforeLoading(true) // default 设置图片在加载前是否重置、复位
// .delayBeforeLoading(1000) // 下载前的延迟时间
// .preProcessor(...)
// .postProcessor(...)
// .extraForDownloader(...)
// .considerExifParams(false) // default
// .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default 设置图片以如何的编码方式显示
// .bitmapConfig(Bitmap.Config.RGB_565) // default 设置图片的解码类型
// .decodingOptions(...) // 图片的解码设置
// .displayer(new SimpleBitmapDisplayer()) // default 还可以设置圆角图片new RoundedBitmapDisplayer(20)
// .handler(new Handler()) // default
.build();
return options;
}
示例13: onBindViewHolder
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
@Override
public void onBindViewHolder(ItemHolder itemHolder, int i) {
Song localItem = arraylist.get(i);
itemHolder.title.setText(localItem.title);
itemHolder.artist.setText(localItem.artistName);
if (MusicPlayer.getCurrentAudioId() == localItem.id) {
itemHolder.title.setTextColor(Config.accentColor(mContext, ateKey));
if (MusicPlayer.isPlaying()) {
itemHolder.visualizer.setColor(Config.accentColor(mContext, ateKey));
itemHolder.visualizer.setVisibility(View.VISIBLE);
}
} else {
itemHolder.title.setTextColor(Config.textColorPrimary(mContext, ateKey));
itemHolder.visualizer.setVisibility(View.GONE);
}
ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.albumId).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build());
setOnPopupMenuListener(itemHolder, i);
}
示例14: onBindViewHolder
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
@Override
public void onBindViewHolder(ItemHolder itemHolder, int i) {
Album localItem = arraylist.get(i);
itemHolder.title.setText(localItem.title);
String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount);
itemHolder.details.setText(songCount);
ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.id).toString(), itemHolder.albumArt,
new DisplayImageOptions.Builder().cacheInMemory(true)
.showImageOnFail(R.drawable.ic_empty_music2)
.resetViewBeforeLoading(true)
.build());
if (TimberUtils.isLollipop())
itemHolder.albumArt.setTransitionName("transition_album_art" + i);
}
示例15: onBindViewHolder
import com.nostra13.universalimageloader.core.DisplayImageOptions; //导入依赖的package包/类
@Override
public void onBindViewHolder(ItemHolder itemHolder, int i) {
if (getItemViewType(i) == 0) {
//nothing
setUpAlbums(itemHolder.albumsRecyclerView);
} else {
Song localItem = arraylist.get(i);
itemHolder.title.setText(localItem.title);
itemHolder.album.setText(localItem.albumName);
ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.albumId).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build());
setOnPopupMenuListener(itemHolder, i - 1);
}
}