Search in sources :

Example 1 with DisplayImageOptions

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);
        }
    });
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) ImageLoadingProgressListener(com.nostra13.universalimageloader.core.assist.ImageLoadingProgressListener) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) InjectView(butterknife.InjectView) PhotoView(uk.co.senab.photoview.PhotoView) View(android.view.View) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 2 with DisplayImageOptions

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);
}
Also used : DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) SpannableString(android.text.SpannableString) Tab(android.app.ActionBar.Tab) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) BitmapFactory(android.graphics.BitmapFactory) ActionBar(android.app.ActionBar)

Example 3 with DisplayImageOptions

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();
}
Also used : DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) BitmapFactory(android.graphics.BitmapFactory)

Example 4 with DisplayImageOptions

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);
        }
    }
}
Also used : DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) DBAccessHelper(com.jams.music.player.DBHelpers.DBAccessHelper) SpannableString(android.text.SpannableString) View(android.view.View) Tab(android.app.ActionBar.Tab) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) BitmapFactory(android.graphics.BitmapFactory) ActionBar(android.app.ActionBar) TypedValue(android.util.TypedValue)

Example 5 with DisplayImageOptions

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));
    }
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) ImageErrorLoadingListener(org.schabi.newpipe.ImageErrorLoadingListener) Intent(android.content.Intent) ImageView(android.widget.ImageView) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)21 ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)15 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)9 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)7 File (java.io.File)7 Bitmap (android.graphics.Bitmap)4 BitmapFactory (android.graphics.BitmapFactory)4 View (android.view.View)4 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)4 UnlimitedDiscCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache)3 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)3 ImageSize (com.nostra13.universalimageloader.core.assist.ImageSize)3 ActionBar (android.app.ActionBar)2 Tab (android.app.ActionBar.Tab)2 Intent (android.content.Intent)2 SpannableString (android.text.SpannableString)2 TypedValue (android.util.TypedValue)2 ImageView (android.widget.ImageView)2 DBAccessHelper (com.jams.music.player.DBHelpers.DBAccessHelper)2 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)2