Search in sources :

Example 1 with ArtistQuery

use of com.naman14.timber.lastfmapi.models.ArtistQuery in project Timber by naman14.

the class SearchAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
    switch(getItemViewType(i)) {
        case 0:
            Song song = (Song) searchResults.get(i);
            itemHolder.title.setText(song.title);
            itemHolder.songartist.setText(song.albumName);
            ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(song.albumId).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
            setOnPopupMenuListener(itemHolder, i);
            break;
        case 1:
            Album album = (Album) searchResults.get(i);
            itemHolder.albumtitle.setText(album.title);
            itemHolder.albumartist.setText(album.artistName);
            ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(album.id).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
            break;
        case 2:
            Artist artist = (Artist) searchResults.get(i);
            itemHolder.artisttitle.setText(artist.name);
            String albumNmber = TimberUtils.makeLabel(mContext, R.plurals.Nalbums, artist.albumCount);
            String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, artist.songCount);
            itemHolder.albumsongcount.setText(TimberUtils.makeCombinedString(mContext, albumNmber, songCount));
            LastFmClient.getInstance(mContext).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {

                @Override
                public void artistInfoSucess(LastfmArtist artist) {
                    if (artist != null && itemHolder.artistImage != null) {
                        ImageLoader.getInstance().displayImage(artist.mArtwork.get(1).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
                    }
                }

                @Override
                public void artistInfoFailed() {
                }
            });
            break;
        case 10:
            itemHolder.sectionHeader.setText((String) searchResults.get(i));
        case 3:
            break;
    }
}
Also used : LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) Artist(com.naman14.timber.models.Artist) Song(com.naman14.timber.models.Song) ArtistInfoListener(com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) Album(com.naman14.timber.models.Album) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) ArtistQuery(com.naman14.timber.lastfmapi.models.ArtistQuery) LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist)

Example 2 with ArtistQuery

use of com.naman14.timber.lastfmapi.models.ArtistQuery in project Timber by naman14.

the class ArtistDetailFragment method setUpArtistDetails.

private void setUpArtistDetails() {
    final Artist artist = ArtistLoader.getArtist(getActivity(), artistID);
    collapsingToolbarLayout.setTitle(artist.name);
    LastFmClient.getInstance(getActivity()).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {

        @Override
        public void artistInfoSucess(final LastfmArtist artist) {
            if (artist != null) {
                ImageLoader.getInstance().displayImage(artist.mArtwork.get(4).mUrl, artistArt, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).build(), new SimpleImageLoadingListener() {

                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                        largeImageLoaded = true;
                        try {
                            new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {

                                @Override
                                public void onGenerated(Palette palette) {
                                    Palette.Swatch swatch = palette.getVibrantSwatch();
                                    if (swatch != null) {
                                        primaryColor = swatch.getRgb();
                                        collapsingToolbarLayout.setContentScrimColor(primaryColor);
                                        if (getActivity() != null)
                                            ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
                                    } else {
                                        Palette.Swatch swatchMuted = palette.getMutedSwatch();
                                        if (swatchMuted != null) {
                                            primaryColor = swatchMuted.getRgb();
                                            collapsingToolbarLayout.setContentScrimColor(primaryColor);
                                            if (getActivity() != null)
                                                ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
                                        }
                                    }
                                }
                            });
                        } catch (Exception ignored) {
                        }
                    }
                });
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        setBlurredPlaceholder(artist);
                    }
                }, 100);
            }
        }

        @Override
        public void artistInfoFailed() {
        }
    });
}
Also used : LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) Artist(com.naman14.timber.models.Artist) Palette(android.support.v7.graphics.Palette) Handler(android.os.Handler) ImageView(android.widget.ImageView) View(android.view.View) ArtistQuery(com.naman14.timber.lastfmapi.models.ArtistQuery) LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) ArtistInfoListener(com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener)

Example 3 with ArtistQuery

use of com.naman14.timber.lastfmapi.models.ArtistQuery in project Timber by naman14.

the class ArtistAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
    final Artist localItem = arraylist.get(i);
    itemHolder.name.setText(localItem.name);
    String albumNmber = TimberUtils.makeLabel(mContext, R.plurals.Nalbums, localItem.albumCount);
    String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount);
    itemHolder.albums.setText(TimberUtils.makeCombinedString(mContext, albumNmber, songCount));
    LastFmClient.getInstance(mContext).getArtistInfo(new ArtistQuery(localItem.name), new ArtistInfoListener() {

        @Override
        public void artistInfoSucess(LastfmArtist artist) {
            if (artist != null && artist.mArtwork != null) {
                if (isGrid) {
                    ImageLoader.getInstance().displayImage(artist.mArtwork.get(2).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build(), new SimpleImageLoadingListener() {

                        @Override
                        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                            if (isGrid && loadedImage != null) {
                                new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {

                                    @Override
                                    public void onGenerated(Palette palette) {
                                        int color = palette.getVibrantColor(Color.parseColor("#66000000"));
                                        itemHolder.footer.setBackgroundColor(color);
                                        Palette.Swatch swatch = palette.getVibrantSwatch();
                                        int textColor;
                                        if (swatch != null) {
                                            textColor = getOpaqueColor(swatch.getTitleTextColor());
                                        } else
                                            textColor = Color.parseColor("#ffffff");
                                        itemHolder.name.setTextColor(textColor);
                                        itemHolder.albums.setTextColor(textColor);
                                    }
                                });
                            }
                        }

                        @Override
                        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                            if (isGrid) {
                                itemHolder.footer.setBackgroundColor(0);
                                if (mContext != null) {
                                    int textColorPrimary = Config.textColorPrimary(mContext, Helpers.getATEKey(mContext));
                                    itemHolder.name.setTextColor(textColorPrimary);
                                    itemHolder.albums.setTextColor(textColorPrimary);
                                }
                            }
                        }
                    });
                } else {
                    ImageLoader.getInstance().displayImage(artist.mArtwork.get(1).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
                }
            }
        }

        @Override
        public void artistInfoFailed() {
        }
    });
    if (TimberUtils.isLollipop())
        itemHolder.artistImage.setTransitionName("transition_artist_art" + i);
}
Also used : LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) Artist(com.naman14.timber.models.Artist) Palette(android.support.v7.graphics.Palette) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ArtistQuery(com.naman14.timber.lastfmapi.models.ArtistQuery) LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) ArtistInfoListener(com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)

Example 4 with ArtistQuery

use of com.naman14.timber.lastfmapi.models.ArtistQuery in project Timber by naman14.

the class ArtistBioFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_artist_bio, container, false);
    Artist artist = ArtistLoader.getArtist(getActivity(), artistID);
    LastFmClient.getInstance(getActivity()).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {

        @Override
        public void artistInfoSucess(LastfmArtist artist) {
        }

        @Override
        public void artistInfoFailed() {
        }
    });
    final MultiViewPager pager = (MultiViewPager) rootView.findViewById(R.id.tagspager);
    final FragmentStatePagerAdapter adapter = new FragmentStatePagerAdapter(getActivity().getSupportFragmentManager()) {

        @Override
        public int getCount() {
            return 20;
        }

        @Override
        public Fragment getItem(int position) {
            return ArtistTagFragment.newInstance(position);
        }
    };
    pager.setAdapter(adapter);
    return rootView;
}
Also used : LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) Artist(com.naman14.timber.models.Artist) FragmentStatePagerAdapter(android.support.v4.app.FragmentStatePagerAdapter) ArtistInfoListener(com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener) MultiViewPager(com.naman14.timber.widgets.MultiViewPager) View(android.view.View) ArtistQuery(com.naman14.timber.lastfmapi.models.ArtistQuery) LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist)

Example 5 with ArtistQuery

use of com.naman14.timber.lastfmapi.models.ArtistQuery in project Timber by naman14.

the class SimilarArtistFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_similar_artists, container, false);
    Artist artist = ArtistLoader.getArtist(getActivity(), artistID);
    LastFmClient.getInstance(getActivity()).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {

        @Override
        public void artistInfoSucess(LastfmArtist artist) {
        }

        @Override
        public void artistInfoFailed() {
        }
    });
    return rootView;
}
Also used : LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) Artist(com.naman14.timber.models.Artist) ArtistInfoListener(com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener) View(android.view.View) ArtistQuery(com.naman14.timber.lastfmapi.models.ArtistQuery) LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist)

Aggregations

ArtistInfoListener (com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener)5 ArtistQuery (com.naman14.timber.lastfmapi.models.ArtistQuery)5 LastfmArtist (com.naman14.timber.lastfmapi.models.LastfmArtist)5 Artist (com.naman14.timber.models.Artist)5 View (android.view.View)4 Bitmap (android.graphics.Bitmap)2 Palette (android.support.v7.graphics.Palette)2 ImageView (android.widget.ImageView)2 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)2 SimpleImageLoadingListener (com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener)2 Handler (android.os.Handler)1 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)1 RecyclerView (android.support.v7.widget.RecyclerView)1 TextView (android.widget.TextView)1 Album (com.naman14.timber.models.Album)1 Song (com.naman14.timber.models.Song)1 MultiViewPager (com.naman14.timber.widgets.MultiViewPager)1 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)1 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)1