Search in sources :

Example 11 with MaterialDrawableBuilder

use of net.steamcrafted.materialiconlib.MaterialDrawableBuilder in project Timber by naman14.

the class Timber5 method updateShuffleState.

@Override
public void updateShuffleState() {
    if (shuffle != null && getActivity() != null) {
        MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(getActivity()).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setSizeDp(30);
        if (MusicPlayer.getShuffleMode() == 0) {
            builder.setColor(Color.WHITE);
        } else
            builder.setColor(accentColor);
        shuffle.setImageDrawable(builder.build());
        shuffle.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                MusicPlayer.cycleShuffle();
                updateShuffleState();
                updateRepeatState();
            }
        });
    }
}
Also used : ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder)

Example 12 with MaterialDrawableBuilder

use of net.steamcrafted.materialiconlib.MaterialDrawableBuilder in project Timber by naman14.

the class AlbumDetailFragment method setAlbumart.

private void setAlbumart() {
    ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(albumID).toString(), albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build(), new ImageLoadingListener() {

        @Override
        public void onLoadingStarted(String imageUri, View view) {
        }

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            loadFailed = true;
            MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(context).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
            ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
            fab.setImageDrawable(builder.build());
        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            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);
                            }
                        }
                        MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(getActivity()).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setSizeDp(30);
                        if (primaryColor != -1) {
                            builder.setColor(TimberUtils.getBlackWhiteColor(primaryColor));
                            ATEUtils.setFabBackgroundTint(fab, primaryColor);
                            fab.setImageDrawable(builder.build());
                        } else {
                            if (context != null) {
                                ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
                                builder.setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
                                fab.setImageDrawable(builder.build());
                            }
                        }
                    }
                });
            } catch (Exception ignored) {
            }
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
        }
    });
}
Also used : Palette(android.support.v7.graphics.Palette) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder) 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) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder) Bitmap(android.graphics.Bitmap) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Aggregations

View (android.view.View)12 MaterialDrawableBuilder (net.steamcrafted.materialiconlib.MaterialDrawableBuilder)12 ImageView (android.widget.ImageView)9 RecyclerView (android.support.v7.widget.RecyclerView)7 TextView (android.widget.TextView)5 TimelyView (com.naman14.timber.timely.TimelyView)2 CircleImageView (com.naman14.timber.widgets.CircleImageView)2 MaterialIconView (net.steamcrafted.materialiconlib.MaterialIconView)2 Bitmap (android.graphics.Bitmap)1 Handler (android.os.Handler)1 Palette (android.support.v7.graphics.Palette)1 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)1 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)1 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)1