Java Code Examples for android.support.v7.graphics.Palette#generateAsync()

The following examples show how to use android.support.v7.graphics.Palette#generateAsync() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhotoView.java    From soas with Apache License 2.0 6 votes vote down vote up
/**
 * Generate label background and foreground colors using Palette base on downloaded image colors.
 *
 * @param bitmap Download bitmap.
 */
@Override
public void onBitmapChange(Bitmap bitmap) {
    if (bitmap == null) { return; }

    Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
        @SuppressWarnings("deprecation")
        public void onGenerated(Palette palette) {
            Resources res = getResources();
            int photoNameColorBg = palette.getDarkMutedColor(res.getColor(R.color.list_item_photo_name_bg));
            int photoNameColorFg = palette.getLightMutedColor(res.getColor(R.color.view_photo_name_fg));

            ColorFilter photoNameColorFilter = new LightingColorFilter(photoNameColorBg, 1);
            Drawable photoNameDrawableBg = res.getDrawable(R.drawable.view_photo_name_bg);
            photoNameDrawableBg.setColorFilter(photoNameColorFilter);
            mPhotoName.setBackgroundDrawable(photoNameDrawableBg);

            mPhotoName.setTextColor(photoNameColorFg);
        }
    });
}
 
Example 2
Source File: MusicService.java    From YTPlayer with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("StaticFieldLeak")
@Override
protected void onPostExecute(Void aVoid) {
    if (noInternet) {
        return;
    }
    if (skipSong) {
        if (souncloudFailed)
            Toast.makeText(activity, "Error: Parsing song "+videoTitle, Toast.LENGTH_SHORT).show();
        if (command==1)
            playNext();
        else if (command==2)
            playPrevious();
        return;
    }

    if (bitmapIcon!=null) {
        Palette.generateAsync(bitmapIcon, palette -> {
            Log.e(TAG, "loadVideo: Changing nColor: "+MusicService.nColor +
                    ", ImageUri: "+MusicService.imgUrl);
            nColor = palette.getVibrantColor(activity.getResources().getColor(R.color.light_white));
        });
    }

    setLyricData();

    if (soundCloudPlayBack) {
        ytConfigs.clear();
        ytConfigs.add(new YTConfig("Audio 128 kbit/s",soundCloud.getModel().getStreamUrl(),
                ".mp3",videoTitle,channelTitle,true,soundCloud.getModel().getImageUrl()));
        audioLink = soundCloud.getModel().getStreamUrl();
        continueinMainThread(audioLink);
        return;
    }

    if (!loadedFromData)
        parseVideoNewMethod(YTutils.getYtUrl(videoID),videoTitle);
    else continueinMainThread(audioLink);
    super.onPostExecute(aVoid);
}
 
Example 3
Source File: PlayerActivity2.java    From YTPlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onPostExecute(Void aVoid) {
    Palette.generateAsync(MusicService.bitmapIcon, palette -> {
        MusicService.nColor = palette.getVibrantColor(activity.getResources().getColor(R.color.light_white));

        loadAgain();
        MusicService.rebuildNotification();
    });
    super.onPostExecute(aVoid);
}
 
Example 4
Source File: ArticleDetailFragment.java    From make-your-app-material with Apache License 2.0 5 votes vote down vote up
private void changeUIColors(Bitmap bitmap) {
    Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
        public void onGenerated(Palette palette) {
            int defaultColor = 0xFF333333;
            int darkMutedColor = palette.getDarkMutedColor(defaultColor);
            metaBar.setBackgroundColor(darkMutedColor);
            if (mCollapsingToolbarLayout != null) {
                mCollapsingToolbarLayout.setContentScrimColor(darkMutedColor);
                mCollapsingToolbarLayout.setStatusBarScrimColor(darkMutedColor);
            }
        }
    });
}
 
Example 5
Source File: DetailActivity.java    From RxAndroidBootstrap with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_detail);

    mActionBarSize = getActionBarSize();


    mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);

    image = (ImageView) findViewById(R.id.image);
    ViewCompat.setTransitionName(image, EXTRA_IMAGE);
    collapsingToolbar.setTitle(getIntent().getStringExtra(EXTRA_TITLE));
    bitmapImageViewTarget = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            Palette.generateAsync(bitmap, DetailActivity.this);
            image.setImageBitmap(bitmap);
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
            //place your code here
        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
            //place your code here
        }
    };
    Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(bitmapImageViewTarget);


}
 
Example 6
Source File: CoverAdapter.java    From example with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(final CoverHolder holder, int position) {

    holder.thumb.setImageResource(coverItems.get(position).getThumbnail());
    holder.title.setText(coverItems.get(position).getTilte());

    Palette.generateAsync(BitmapFactory.decodeResource(context.getResources(), coverItems.get(position).getThumbnail()), new Palette.PaletteAsyncListener() {
        @Override
        public void onGenerated(Palette palette) {
            Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
            Log.d("tag", "test ->body " + vibrantSwatch.getBodyTextColor() + ",title" + vibrantSwatch.getTitleTextColor());
            holder.containerText.setBackgroundColor(vibrantSwatch.getTitleTextColor());
        }
    });
}
 
Example 7
Source File: CardPresenter.java    From Amphitheatre with Apache License 2.0 5 votes vote down vote up
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
    Drawable bitmapDrawable = new BitmapDrawable(mCardView.getContext().getResources(), bitmap);
    mCardView.setMainImage(bitmapDrawable);

    Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
        @Override
        public void onGenerated(Palette palette) {
            if (Enums.PalettePresenterType.valueOf(mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_VISIBLE, "")) == Enums.PalettePresenterType.ALLCARDS) {
                Utils.animateColorChange(
                        mCardView.findViewById(R.id.info_field),
                        mCardView.getContext().getResources().getColor(R.color.lb_basic_card_info_bg_color),
                        Utils.getPaletteColor(
                                palette,
                                mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_UNSELECTED, ""),
                                mCardView.getContext().getResources().getColor(R.color.lb_basic_card_info_bg_color))
                );
            }
            if (Enums.PalettePresenterType.valueOf(mSharedPrefs.getString(Constants.PALETTE_TITLE_VISIBLE, "")) == Enums.PalettePresenterType.ALLCARDS) {
                ((TextView)mCardView.findViewById(R.id.title_text)).setTextColor(
                        Utils.getPaletteColor(
                                palette,
                                mSharedPrefs.getString(Constants.PALETTE_TITLE_UNSELECTED, ""),
                                mCardView.getContext().getResources().getColor(R.color.lb_basic_card_title_text_color))
                );
            }
            if (Enums.PalettePresenterType.valueOf(mSharedPrefs.getString(Constants.PALETTE_CONTENT_VISIBLE, "")) == Enums.PalettePresenterType.ALLCARDS) {
                ((TextView)mCardView.findViewById(R.id.content_text)).setTextColor(
                        Utils.getPaletteColor(
                                palette,
                                mSharedPrefs.getString(Constants.PALETTE_CONTENT_UNSELECTED, ""),
                                mCardView.getContext().getResources().getColor(R.color.lb_basic_card_content_text_color))
                );
            }
        }
    });
}
 
Example 8
Source File: ShotDetail.java    From COCOFramework with Apache License 2.0 5 votes vote down vote up
private void colorize(Bitmap photo) {
    Palette.generateAsync(photo, new Palette.PaletteAsyncListener() {
        @Override
        public void onGenerated(Palette palette) {
            applyPalette(palette);
        }
    });
}
 
Example 9
Source File: DetailActivity.java    From MVPAndroidBootstrap with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_detail);

    mActionBarSize = getActionBarSize();

    if (!TOOLBAR_IS_STICKY) {
        toolbar.setBackgroundColor(Color.TRANSPARENT);
    }

    image = (ImageView) findViewById(R.id.image);
    ViewCompat.setTransitionName(image, EXTRA_IMAGE);
    titleTextView.setText(getIntent().getStringExtra(EXTRA_TITLE));
    bitmapImageViewTarget = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            Palette.generateAsync(bitmap, DetailActivity.this);
            image.setImageBitmap(bitmap);
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {

        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {

        }
    };
    Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(bitmapImageViewTarget);

    setTitle(null);
    mScollView.setScrollViewCallbacks(this);

    ScrollUtils.addOnGlobalLayoutListener(mScollView, new Runnable() {
        @Override
        public void run() {
            mScollView.scrollTo(0, mFlexibleSpaceImageHeight - mActionBarSize);
            mScollView.scrollTo(0, 1);
        }
    });

}
 
Example 10
Source File: MyWatchFaceService.java    From android-codelab-watchface with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(SurfaceHolder holder) {
    super.onCreate(holder);

    setWatchFaceStyle(new WatchFaceStyle.Builder(MyWatchFaceService.this)
            .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT)
            .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
            .setShowSystemUiTime(false)
            .build());

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(Color.BLACK);

    /*
     * Toggle the backgroundResIds to see
     * the change of colors due to palette doing its magic.
     */
    final int backgroundResId = R.drawable.custom_background;
    //final int backgroundResId = R.drawable.custom_background2;

    mBackgroundBitmap = BitmapFactory.decodeResource(getResources(), backgroundResId);
    mHandPaint = new Paint();
    mHandPaint.setColor(Color.WHITE);
    mHandPaint.setStrokeWidth(STROKE_WIDTH);
    mHandPaint.setAntiAlias(true);
    mHandPaint.setStrokeCap(Paint.Cap.ROUND);
    mHandPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, Color.BLACK);
    mHandPaint.setStyle(Paint.Style.STROKE);

    Palette.generateAsync(mBackgroundBitmap, new Palette.PaletteAsyncListener() {
        @Override
        public void onGenerated(Palette palette) {
            /*
             * Sometimes, palette is unable to generate a color palette
             * so we need to check that we have one.
             */
            if (palette != null) {
                mWatchHandColor = palette.getVibrantColor(Color.WHITE);
                mWatchHandShadowColor = palette.getDarkMutedColor(Color.BLACK);
                setWatchHandColor();
            }
        }
    });

    mTime = new Time();
}
 
Example 11
Source File: MovieDetailActivity.java    From Material-Movies with Apache License 2.0 4 votes vote down vote up
@Override
public void showFilmCover(Bitmap bitmap) {

    mCoverImageView.setImageBitmap(bitmap);
    Palette.generateAsync(bitmap, this);
}
 
Example 12
Source File: MyWatchFaceService.java    From io2015-codelabs with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(SurfaceHolder holder) {
    super.onCreate(holder);

    setWatchFaceStyle(new WatchFaceStyle.Builder(MyWatchFaceService.this)
            .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT)
            .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
            .setShowSystemUiTime(false)
            .build());

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(Color.BLACK);

    /*
     * Toggle the backgroundResIds to see
     * the change of colors due to palette doing its magic.
     */
    final int backgroundResId = R.drawable.custom_background;
    //final int backgroundResId = R.drawable.custom_background2;

    mBackgroundBitmap = BitmapFactory.decodeResource(getResources(), backgroundResId);
    mHandPaint = new Paint();
    mHandPaint.setColor(Color.WHITE);
    mHandPaint.setStrokeWidth(STROKE_WIDTH);
    mHandPaint.setAntiAlias(true);
    mHandPaint.setStrokeCap(Paint.Cap.ROUND);
    mHandPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, Color.BLACK);
    mHandPaint.setStyle(Paint.Style.STROKE);

    Palette.generateAsync(mBackgroundBitmap, new Palette.PaletteAsyncListener() {
        @Override
        public void onGenerated(Palette palette) {
            /*
             * Sometimes, palette is unable to generate a color palette
             * so we need to check that we have one.
             */
            if (palette != null) {
                mWatchHandColor = palette.getVibrantColor(Color.WHITE);
                mWatchHandShadowColor = palette.getDarkMutedColor(Color.BLACK);
                setWatchHandColor();
            }
        }
    });

    mTime = new Time();
}
 
Example 13
Source File: MainActivity.java    From BLEMeshChat with Mozilla Public License 2.0 4 votes vote down vote up
@Override
    public void onMessageSelected(View identictionView, View usernameView, int messageId, int peerId) {
        // Create new fragment to add (Fragment B)
        Peer peer = mClient.getDataStore().getPeerById(peerId);
        if (peer == null) {
            Log.w(TAG, "Could not lookup peer. Cannot show profile");
            return;
        }

        setTitle(peer.getAlias());

//        identictionView.setTransitionName(getString(R.string.identicon_transition_name));
//        usernameView.setTransitionName(getString(R.string.username_transition_name));

        Fragment profileFragment = ProfileFragment.createForPeer(mClient.getDataStore(), peer);

//        final TransitionSet sharedElementTransition = new TransitionSet();
//        sharedElementTransition.addTransition(new ChangeBounds());
//        sharedElementTransition.addTransition(new ChangeTransform());
//        sharedElementTransition.setInterpolator(new AccelerateDecelerateInterpolator());
//        sharedElementTransition.setDuration(200);

        final TransitionSet slideTransition = new TransitionSet();
        slideTransition.addTransition(new Slide());
        slideTransition.setInterpolator(new AccelerateDecelerateInterpolator());
        slideTransition.setDuration(300);

        profileFragment.setEnterTransition(slideTransition);
        profileFragment.setReturnTransition(slideTransition);
//        profileFragment.setSharedElementEnterTransition(sharedElementTransition);
        profileFragment.setAllowEnterTransitionOverlap(false);
        profileFragment.setAllowReturnTransitionOverlap(false);

        // Message fragment performs an exit when Profile is added, and an enter when profile is popped
//        getFragmentManager().findFragmentByTag("messaging").setReenterTransition(slideTransition);
//        getFragmentManager().findFragmentByTag("messaging").setExitTransition(slideTransition);
//        getFragmentManager().findFragmentByTag("messaging").setSharedElementEnterTransition(sharedElementTransition);

        getSupportFragmentManager().beginTransaction()
                .replace(R.id.container, profileFragment)
                .addToBackStack("profile")
//                .addSharedElement(identictionView, getString(R.string.identicon_transition_name))
//                .addSharedElement(usernameView, getString(R.string.username_transition_name))
                .commit();

        Bitmap bitmap = Notification.loadBitmapFromView(identictionView, 100, 100);
        Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
            public void onGenerated(Palette p) {
                mPalette = p;
                tintSystemBars(getResources().getColor(R.color.primary), getResources().getColor(R.color.primaryDark),
                        p.getVibrantColor(R.color.primary), p.getDarkVibrantColor(R.color.primaryDark));

            }
        });

        // Hack animate the drawer icon
        ValueAnimator drawerAnimator = ValueAnimator.ofFloat(0, 1f);
        drawerAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                mDrawerToggle.onDrawerSlide(null, (Float) animation.getAnimatedValue());
            }
        });
        drawerAnimator.start();
    }
 
Example 14
Source File: TvShowsCardPresenter.java    From Amphitheatre with Apache License 2.0 4 votes vote down vote up
private void setFocusState(final ImageCardView cardView, final boolean isFocused, View view) {
    final Drawable mainImage = ((ImageView)view.findViewById(R.id.main_image)).getDrawable();

    if (isFocused) {
        ((TextView)cardView.findViewById(R.id.title_text)).setMaxLines(4);
    }
    else {
        ((TextView)cardView.findViewById(R.id.title_text)).setMaxLines(1);
    }

    if (mainImage != null) {
        Palette.generateAsync(((BitmapDrawable) mainImage).getBitmap(), new Palette.PaletteAsyncListener() {

            @Override
            public void onGenerated(Palette palette) {

                if (isFocused) {
                    Utils.animateColorChange(
                            cardView.findViewById(R.id.info_field),
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_UNSELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_info_bg_color)),
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_SELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_info_bg_color))
                    );

                    ((TextView) cardView.findViewById(R.id.title_text)).setTextColor(
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_TITLE_SELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_title_text_color))
                    );

                    ((TextView) cardView.findViewById(R.id.content_text)).setTextColor(
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_CONTENT_SELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_content_text_color))
                    );
                } else {
                    Utils.animateColorChange(
                            cardView.findViewById(R.id.info_field),
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_SELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_info_bg_color)),
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_UNSELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_info_bg_color))
                    );

                    ((TextView) cardView.findViewById(R.id.title_text)).setTextColor(
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_TITLE_UNSELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_title_text_color))
                    );

                    ((TextView) cardView.findViewById(R.id.content_text)).setTextColor(
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_CONTENT_UNSELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_content_text_color))
                    );
                }
            }
        });
    }
}
 
Example 15
Source File: CardPresenter.java    From Amphitheatre with Apache License 2.0 4 votes vote down vote up
private void setFocusState(final ImageCardView cardView, final boolean isFocused, View view) {
    final Drawable mainImage = ((ImageView)view.findViewById(R.id.main_image)).getDrawable();

    if (isFocused) {
        ((TextView)cardView.findViewById(R.id.title_text)).setMaxLines(4);
    }
    else {
        ((TextView)cardView.findViewById(R.id.title_text)).setMaxLines(1);
    }

    if (mainImage != null) {
        Palette.generateAsync(((BitmapDrawable) mainImage).getBitmap(), new Palette.PaletteAsyncListener() {

            @Override
            public void onGenerated(Palette palette) {

                if (isFocused) {
                    Utils.animateColorChange(
                            cardView.findViewById(R.id.info_field),
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_UNSELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_info_bg_color)),
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_SELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_info_bg_color))
                    );

                    ((TextView)cardView.findViewById(R.id.title_text)).setTextColor(
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_TITLE_SELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_title_text_color))
                    );

                    ((TextView)cardView.findViewById(R.id.content_text)).setTextColor(
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_CONTENT_SELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_content_text_color))
                    );
                }
                else {
                    Utils.animateColorChange(
                            cardView.findViewById(R.id.info_field),
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_SELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_info_bg_color)),
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_UNSELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_info_bg_color))
                    );

                    ((TextView)cardView.findViewById(R.id.title_text)).setTextColor(
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_TITLE_UNSELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_title_text_color))
                    );

                    ((TextView)cardView.findViewById(R.id.content_text)).setTextColor(
                            Utils.getPaletteColor(
                                    palette,
                                    mSharedPrefs.getString(Constants.PALETTE_CONTENT_UNSELECTED, ""),
                                    mContext.getResources().getColor(R.color.lb_basic_card_content_text_color))
                    );
                }
            }
        });
    }
}
 
Example 16
Source File: OpenNotification.java    From HeadsUp with GNU General Public License v2.0 4 votes vote down vote up
public void load(@NonNull Context context) {
    mLoadedTimestamp = SystemClock.elapsedRealtime();
    mMine = TextUtils.equals(getPackageName(), PackageUtils.getName(context));
    mActions = Action.makeFor(mNotification);
    mNumber = mNotification.number;

    // Load the brand color.
    try {
        String packageName = getPackageName();
        Drawable appIcon = context.getPackageManager().getApplicationIcon(packageName);

        final Bitmap bitmap = Bitmap.createBitmap(
                appIcon.getMinimumWidth(),
                appIcon.getMinimumHeight(),
                Bitmap.Config.ARGB_4444);
        appIcon.draw(new Canvas(bitmap));
        AsyncTask.stop(mPaletteWorker);
        mPaletteWorker = Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
            @Override
            public void onGenerated(Palette palette) {
                mBrandColor = palette.getVibrantColor(Color.WHITE);
                notifyListeners(EVENT_BRAND_COLOR);
                bitmap.recycle();
            }
        });
    } catch (PackageManager.NameNotFoundException e) { /* do nothing */ }

    // Load notification icon.
    AsyncTask.stop(mIconWorker);
    mIconWorker = IconFactory.generateAsync(context, this, mIconCallback);

    // Load all other things, such as title text, message text
    // and more and more.
    new Extractor().loadTexts(context, this);
    messageText = ensureNotEmpty(messageText);
    messageBigText = ensureNotEmpty(messageBigText);

    messageTextOrigin = messageText;
    messageBigTextOrigin = messageBigText;
    messageTextLinesOrigin = messageTextLines == null ? null : messageTextLines.clone();

    // Initially load emoticons.
    if (mEmoticonsEnabled) {
        mEmoticonsEnabled = false;
        setEmoticonsEnabled(true);
    }
}