Skip to content

Commit

Permalink
Update PaletteImageView.java
Browse files Browse the repository at this point in the history
  • Loading branch information
lin18 authored Oct 23, 2019
1 parent 81f9c39 commit 2ffb12d
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ private void init(Context context, AttributeSet attrs) {

mPaintShadow = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaintShadow.setDither(true);
mPaintShadow.setAntiAlias(true);
mPaintShadow.setColor(Color.WHITE);
setLayerType(LAYER_TYPE_SOFTWARE, null);
setBackgroundColor(getResources().getColor(android.R.color.transparent));
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
Expand Down Expand Up @@ -119,14 +121,15 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
zipBitmap(mImgId, mBitmap, mOnMeasureHeightMode);
mRectFShadow = new RectF(mPadding, mPadding, getWidth() - mPadding, getHeight() - mPadding);
mRoundRectF = new RectF(0, 0, getWidth() - mPadding * 2, getHeight() - mPadding * 2);
mRoundBitmap = createRoundConerImage(mRealBitmap,mRadius);
//mRoundBitmap = createRoundConerImage(mRealBitmap,mRadius);

}

@Override
protected void onDraw(Canvas canvas) {
if (mRealBitmap != null ) {
canvas.drawRoundRect(mRectFShadow, mRadius, mRadius, mPaintShadow);
mRoundBitmap = createRoundConerImage(mRealBitmap, mRadius);
if (mRoundBitmap != null)canvas.drawBitmap(mRoundBitmap, mPadding, mPadding, null);
if (mMainColor != -1) mAsyncTask.cancel(true);
}
Expand Down Expand Up @@ -263,6 +266,7 @@ public void onGenerated(Palette palette) {
if (palette != null) {
mPalette = palette;
mMainColor = palette.getDominantSwatch().getRgb();
mPaintShadow.setColor(mMainColor);
mHandler.sendEmptyMessage(MSG);
if (mListener != null) mListener.onComplete(mInstance);
} else {
Expand Down Expand Up @@ -344,4 +348,4 @@ public void handleMessage(Message msg) {
}
}
}
}
}

0 comments on commit 2ffb12d

Please sign in to comment.