Skip to content

Commit

Permalink
Merge pull request #21 from recruit-lifestyle/Bug-#19
Browse files Browse the repository at this point in the history
Fixed #19 bug that set the Alpha value
  • Loading branch information
amyu committed Feb 6, 2016
2 parents 4eb1b0a + f359aaa commit b5c252b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ private void createWaveView() {
layoutWaveView();
}


private void layoutWaveView(){
private void layoutWaveView() {
if (mWaveView == null) {
return;
}
Expand All @@ -214,8 +213,8 @@ private void layoutWaveView(){

final int circleWidth = mCircleView.getMeasuredWidth();
final int circleHeight = mCircleView.getMeasuredHeight();
mCircleView.layout((thisWidth - circleWidth) / 2, -circleHeight + mTopOffset, (thisWidth + circleWidth) / 2,
mTopOffset);
mCircleView.layout((thisWidth - circleWidth) / 2, -circleHeight + mTopOffset,
(thisWidth + circleWidth) / 2, mTopOffset);
final int childRight = thisWidth - getPaddingRight();
final int childBottom = thisHeight - getPaddingBottom();
mWaveView.layout(getPaddingLeft(), mTopOffset + getPaddingTop(), childRight, childBottom);
Expand Down Expand Up @@ -670,14 +669,20 @@ public void setShadowRadius(int radius) {

/**
* This is an alias to WaveView#setWaveColor(int)
*
* @see WaveView#setWaveColor(int)
*/
public void setWaveColor(int argbColor){
mWaveView.setWaveColor(argbColor);
public void setWaveColor(int argbColor) {
int alpha = 0xFF & (argbColor >> 24);
int red = 0xFF & ( argbColor >> 16);
int blue = 0xFF & (argbColor >> 0 );
int green = 0xFF & (argbColor >> 8 );
setWaveARGBColor(alpha, red, green, blue);
}

/**
* WaveView is colored by given rgb color + 0xFF000000
*
* @param r int [0, 0xFF]
* @param g int [0, 0xFF]
* @param b int [0, 0xFF]
Expand All @@ -688,14 +693,19 @@ public void setWaveRGBColor(int r, int g, int b) {

/**
* This is an alias to WaveView#setWaveARGBColor(int)
*
* @param a int [0, 0xFF]
* @param r int [0, 0xFF]
* @param g int [0, 0xFF]
* @param b int [0, 0xFF]
* @see WaveView#setWaveARGBColor(int, int, int, int)
*/
public void setWaveARGBColor(int a, int r, int g, int b) {
mWaveView.setWaveARGBColor(a, r, g, b);
setWaveRGBColor(r, g, b);
if (a == 0xFF) {
return;
}
mWaveView.setAlpha((float) a / 255f);
}

private static int makeMeasureSpecExactly(int length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* @author amyu
*
* 波と落ちる円を描画するView
* 波と落ちる円を描画するView
*/
public class WaveView extends View implements ViewTreeObserver.OnPreDrawListener {

Expand Down Expand Up @@ -464,10 +464,10 @@ public void expandPhase(float move1, float move2, float move3) {
Math.max(BEGIN_PHASE_POINTS[2][1] + move1 - move2, APPEAR_PHASE_POINTS[2][1]) + move3,
EXPAND_PHASE_POINTS[2][1]));
mWavePath.cubicTo(mWidth * Math.min(
Math.max(BEGIN_PHASE_POINTS[3][0] - move2, APPEAR_PHASE_POINTS[3][0]) + move3,
EXPAND_PHASE_POINTS[3][0]), mWidth * Math.min(
Math.min(BEGIN_PHASE_POINTS[3][1] + move1 + move2, APPEAR_PHASE_POINTS[3][1]) + move3,
EXPAND_PHASE_POINTS[3][1]),
Math.max(BEGIN_PHASE_POINTS[3][0] - move2, APPEAR_PHASE_POINTS[3][0]) + move3,
EXPAND_PHASE_POINTS[3][0]), mWidth * Math.min(
Math.min(BEGIN_PHASE_POINTS[3][1] + move1 + move2, APPEAR_PHASE_POINTS[3][1]) + move3,
EXPAND_PHASE_POINTS[3][1]),
mWidth * Math.max(BEGIN_PHASE_POINTS[4][0] - move2, EXPAND_PHASE_POINTS[4][0]),
mWidth * Math.min(
Math.min(BEGIN_PHASE_POINTS[4][1] + move1 + move2, APPEAR_PHASE_POINTS[4][1]) + move3,
Expand All @@ -490,10 +490,10 @@ public void expandPhase(float move1, float move2, float move3) {
Math.max(BEGIN_PHASE_POINTS[2][1] + move1 - move2, APPEAR_PHASE_POINTS[2][1]) + move3,
EXPAND_PHASE_POINTS[2][1]));
mWavePath.cubicTo(mWidth - mWidth * Math.min(
Math.min(BEGIN_PHASE_POINTS[1][0] + move2, APPEAR_PHASE_POINTS[1][0]) + move3,
EXPAND_PHASE_POINTS[1][0]), mWidth * Math.max(
Math.max(BEGIN_PHASE_POINTS[1][1] + move1 - move2, APPEAR_PHASE_POINTS[1][1]) - move3,
EXPAND_PHASE_POINTS[1][1]), mWidth - mWidth * EXPAND_PHASE_POINTS[0][0],
Math.min(BEGIN_PHASE_POINTS[1][0] + move2, APPEAR_PHASE_POINTS[1][0]) + move3,
EXPAND_PHASE_POINTS[1][0]), mWidth * Math.max(
Math.max(BEGIN_PHASE_POINTS[1][1] + move1 - move2, APPEAR_PHASE_POINTS[1][1]) - move3,
EXPAND_PHASE_POINTS[1][1]), mWidth - mWidth * EXPAND_PHASE_POINTS[0][0],
mWidth * EXPAND_PHASE_POINTS[0][1], mWidth, 0);
mCurrentCircleCenterY = mWidth * Math.min(
Math.min(BEGIN_PHASE_POINTS[3][1] + move1 + move2, APPEAR_PHASE_POINTS[3][1]) + move3,
Expand All @@ -519,7 +519,7 @@ private void updateMaxDropHeight(int height) {
public void startDropAnimation() {
// show dropBubble again
mDisappearCircleAnimator = ValueAnimator.ofFloat(1.f, 1.f);
mDisappearCircleAnimator.setDuration(1);
mDisappearCircleAnimator.setDuration(1);
mDisappearCircleAnimator.start();

mDropCircleAnimator = ValueAnimator.ofFloat(500 * (mWidth / 1440.f), mMaxDropHeight);
Expand Down Expand Up @@ -642,6 +642,7 @@ public void setShadowRadius(int radius) {

/**
* WaveView is colored by given color (including alpha)
*
* @param color ARGB color. WaveView will be colored by Black if rgb color is provided.
* @see Paint#setColor(int)
*/
Expand All @@ -650,8 +651,8 @@ public void setWaveColor(int color) {
invalidate();
}

public void setWaveARGBColor(int a, int r, int g, int b){
mPaint.setARGB(a,r,g,b);
public void setWaveARGBColor(int a, int r, int g, int b) {
mPaint.setARGB(a, r, g, b);
invalidate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void initView() {
mWaveSwipeRefreshLayout = (WaveSwipeRefreshLayout) findViewById(R.id.main_swipe);
mWaveSwipeRefreshLayout.setColorSchemeColors(Color.WHITE, Color.WHITE);
mWaveSwipeRefreshLayout.setOnRefreshListener(this);
mWaveSwipeRefreshLayout.setWaveColor(0x00000000);
mWaveSwipeRefreshLayout.setWaveColor(Color.argb(100,255,0,0));

//mWaveSwipeRefreshLayout.setMaxDropHeight(1500);

Expand Down

0 comments on commit b5c252b

Please sign in to comment.