use of com.nostra13.universalimageloader.core.assist.ImageScaleType in project Android-Universal-Image-Loader by nostra13.
the class BaseImageDecoder method prepareDecodingOptions.
protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
ImageScaleType scaleType = decodingInfo.getImageScaleType();
int scale;
if (scaleType == ImageScaleType.NONE) {
scale = 1;
} else if (scaleType == ImageScaleType.NONE_SAFE) {
scale = ImageSizeUtils.computeMinImageSampleSize(imageSize);
} else {
ImageSize targetSize = decodingInfo.getTargetSize();
boolean powerOf2 = scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2;
scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo.getViewScaleType(), powerOf2);
}
if (scale > 1 && loggingEnabled) {
L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), scale, decodingInfo.getImageKey());
}
Options decodingOptions = decodingInfo.getDecodingOptions();
decodingOptions.inSampleSize = scale;
return decodingOptions;
}
use of com.nostra13.universalimageloader.core.assist.ImageScaleType in project Android-Universal-Image-Loader by nostra13.
the class LoadAndDisplayImageTask method resizeAndSaveImage.
/** Decodes image file into Bitmap, resize it and save it back */
private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException {
// Decode image file, compress and re-save it
boolean saved = false;
File targetFile = configuration.diskCache.get(uri);
if (targetFile != null && targetFile.exists()) {
ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight);
DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options).imageScaleType(ImageScaleType.IN_SAMPLE_INT).build();
ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE, getDownloader(), specialOptions);
Bitmap bmp = decoder.decode(decodingInfo);
if (bmp != null && configuration.processorForDiskCache != null) {
L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey);
bmp = configuration.processorForDiskCache.process(bmp);
if (bmp == null) {
L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey);
}
}
if (bmp != null) {
saved = configuration.diskCache.save(uri, bmp);
bmp.recycle();
}
}
return saved;
}
use of com.nostra13.universalimageloader.core.assist.ImageScaleType in project JamsMusicPlayer by psaravan.
the class PlaylistEditorActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
//Initialize Context and SharedPreferences.
mContext = 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);
//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.
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();
//Attach tabs to the ActionBar.
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
//Add the artists tab.
String artistsLabel = getResources().getString(R.string.artists);
Tab tab = actionBar.newTab();
tab.setText(artistsLabel);
TabListener<ArtistsPickerFragment> artistsTabListener = new TabListener<ArtistsPickerFragment>(this, artistsLabel, ArtistsPickerFragment.class);
tab.setTabListener(artistsTabListener);
actionBar.addTab(tab);
//Add the albums tab.
String albumsLabel = getResources().getString(R.string.albums);
tab = actionBar.newTab();
tab.setText(albumsLabel);
TabListener<AlbumsPickerFragment> albumsTabListener = new TabListener<AlbumsPickerFragment>(this, albumsLabel, AlbumsPickerFragment.class);
tab.setTabListener(albumsTabListener);
actionBar.addTab(tab);
//Add the songs tab.
String songsLabel = getResources().getString(R.string.songs);
tab = actionBar.newTab();
tab.setText(songsLabel);
TabListener<SongsPickerFragment> songsTabListener = new TabListener<SongsPickerFragment>(this, songsLabel, SongsPickerFragment.class);
tab.setTabListener(songsTabListener);
actionBar.addTab(tab);
}
use of com.nostra13.universalimageloader.core.assist.ImageScaleType in project JamsMusicPlayer by psaravan.
the class Common method initDisplayImageOptions.
/**
* Initializes a DisplayImageOptions object. The drawable shown
* while an image is loading is based on the current theme.
*/
public void initDisplayImageOptions() {
//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;
int emptyColorPatch = UIElementsHelper.getEmptyColorPatch(this);
mDisplayImageOptions = null;
mDisplayImageOptions = new DisplayImageOptions.Builder().showImageForEmptyUri(emptyColorPatch).showImageOnFail(emptyColorPatch).showImageOnLoading(emptyColorPatch).cacheInMemory(true).cacheOnDisc(true).decodingOptions(options).imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2).bitmapConfig(Bitmap.Config.ARGB_4444).delayBeforeLoading(400).displayer(new FadeInBitmapDisplayer(200)).build();
}
use of com.nostra13.universalimageloader.core.assist.ImageScaleType in project JamsMusicPlayer by psaravan.
the class MusicLibraryEditorActivity method onCreate.
@SuppressWarnings("unchecked")
@Override
public void onCreate(Bundle savedInstanceState) {
//Initialize Context and SharedPreferences.
mContext = this;
mApp = (Common) mContext.getApplicationContext();
//Retrieve the name/icon of the library from the arguments.
libraryName = getIntent().getExtras().getString("LIBRARY_NAME");
libraryIconName = getIntent().getExtras().getString("LIBRARY_ICON");
if (getIntent().getExtras().getSerializable("SONG_IDS_HASH_SET") != null) {
songDBIdsList = (HashSet<String>) getIntent().getExtras().getSerializable("SONG_IDS_HASH_SET");
}
//Set the UI theme.
if (mApp.getCurrentTheme() == Common.DARK_THEME) {
setTheme(R.style.AppTheme);
} else {
setTheme(R.style.AppThemeLight);
}
super.onCreate(savedInstanceState);
//Initialize the database helper.
dbHelper = new DBAccessHelper(mContext.getApplicationContext());
//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();
//Attach tabs to the ActionBar.
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
//Add the artists tab.
String artistsLabel = getResources().getString(R.string.artists);
Tab tab = actionBar.newTab();
tab.setText(artistsLabel);
TabListener<ArtistsPickerFragment> artistsTabListener = new TabListener<ArtistsPickerFragment>(this, artistsLabel, ArtistsPickerFragment.class);
tab.setTabListener(artistsTabListener);
actionBar.addTab(tab);
//Add the albums tab.
String albumsLabel = getResources().getString(R.string.albums);
tab = actionBar.newTab();
tab.setText(albumsLabel);
TabListener<AlbumsPickerFragment> albumsTabListener = new TabListener<AlbumsPickerFragment>(this, albumsLabel, AlbumsPickerFragment.class);
tab.setTabListener(albumsTabListener);
actionBar.addTab(tab);
//Add the songs tab.
String songsLabel = getResources().getString(R.string.songs);
tab = actionBar.newTab();
tab.setText(songsLabel);
TabListener<SongsPickerFragment> songsTabListener = new TabListener<SongsPickerFragment>(this, songsLabel, SongsPickerFragment.class);
tab.setTabListener(songsTabListener);
actionBar.addTab(tab);
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);
}
}
}
Aggregations