use of com.nostra13.universalimageloader.core.DisplayImageOptions in project 9GAG by stormzhang.
the class ImageViewActivity method onCreate.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_imageview);
ButterKnife.inject(this);
setTitle(R.string.view_big_image);
mAttacher = new PhotoViewAttacher(photoView);
mAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
@Override
public void onPhotoTap(View view, float x, float y) {
finish();
}
});
String imageUrl = getIntent().getStringExtra(IMAGE_URL);
DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisc(true).considerExifParams(true).build();
ImageLoader.getInstance().displayImage(imageUrl, photoView, options, new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
progressWheel.setVisibility(View.GONE);
mAttacher.update();
}
}, new ImageLoadingProgressListener() {
@Override
public void onProgressUpdate(String imageUri, View view, int current, int total) {
progressWheel.setProgress(360 * current / total);
}
});
}
use of com.nostra13.universalimageloader.core.DisplayImageOptions 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.DisplayImageOptions 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.DisplayImageOptions 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);
}
}
}
use of com.nostra13.universalimageloader.core.DisplayImageOptions in project NewPipe by TeamNewPipe.
the class VideoItemDetailFragment method initThumbnailViews.
private void initThumbnailViews(final StreamInfo info) {
ImageView videoThumbnailView = (ImageView) activity.findViewById(R.id.detail_thumbnail_view);
ImageView uploaderThumb = (ImageView) activity.findViewById(R.id.detail_uploader_thumbnail_view);
if (info.thumbnail_url != null && !info.thumbnail_url.isEmpty()) {
imageLoader.displayImage(info.thumbnail_url, videoThumbnailView, displayImageOptions, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
ErrorActivity.reportError(getActivity(), failReason.getCause(), null, rootView, ErrorActivity.ErrorInfo.make(ErrorActivity.LOAD_IMAGE, NewPipe.getNameOfService(info.service_id), imageUri, R.string.could_not_load_thumbnails));
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
streamThumbnail = loadedImage;
if (streamThumbnail != null) {
// TODO: Change the thumbnail implementation
// When the thumbnail is not loaded yet, it not passes to the service in time
// so, I can notify the service through a broadcast, but the problem is
// when I click in another video, another thumbnail will be load, and will
// notify again, so I send the videoUrl and compare with the service's url
ActivityCommunicator.getCommunicator().backgroundPlayerThumbnail = streamThumbnail;
Intent intent = new Intent(PopupVideoPlayer.InternalListener.ACTION_UPDATE_THUMB);
intent.putExtra(PopupVideoPlayer.VIDEO_URL, info.webpage_url);
getContext().sendBroadcast(intent);
}
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
} else {
videoThumbnailView.setImageResource(R.drawable.dummy_thumbnail_dark);
}
if (info.uploader_thumbnail_url != null && !info.uploader_thumbnail_url.isEmpty()) {
imageLoader.displayImage(info.uploader_thumbnail_url, uploaderThumb, displayImageOptions, new ImageErrorLoadingListener(activity, rootView, info.service_id));
}
}
Aggregations