本文整理匯總了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);
}
}