Skip to content

Commit

Permalink
Merge pull request #13 from jmatsu/add_rgb
Browse files Browse the repository at this point in the history
Improve ways to change the color of WaveView
  • Loading branch information
amyu committed Nov 16, 2015
2 parents ec25f85 + 695eb40 commit e647221
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,32 @@ public void setShadowRadius(int radius) {
mWaveView.setShadowRadius(radius);
}

public void setWaveColor(int color){
mWaveView.setWaveColor(color);
/**
* This is an alias to WaveView#setWaveColor(int)
* @see WaveView#setWaveColor(int)
*/
public void setWaveColor(int argbColor){
mWaveView.setWaveColor(argbColor);
}

/**
* WaveView is colored by given rgb color + 0xFF000000
* @param r int [0, 0xFF]
* @param g int [0, 0xFF]
* @param b int [0, 0xFF]
*/
public void setWaveRGBColor(int r, int g, int b) {
mWaveView.setWaveColor(Color.argb(0xFF, r, g, 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,11 @@ public void setShadowRadius(int radius) {
mShadowPaint.setShadowLayer(radius, 0.0f, 2.0f, SHADOW_COLOR);
}

/**
* 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)
*/
public void setWaveColor(int color) {
mPaint.setColor(color);
invalidate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SeekBar;

import java.util.ArrayList;
import java.util.Random;

import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout;

Expand Down Expand Up @@ -42,6 +44,13 @@ private void initView() {

mListview = (ListView) findViewById(R.id.main_list);

findViewById(R.id.button_of_wave_color).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mWaveSwipeRefreshLayout.setWaveColor(0xFF000000+new Random().nextInt(0xFFFFFF)); // Random assign
}
});

((SeekBar) findViewById(R.id.seekbar_of_drop_height)).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
Expand Down
7 changes: 7 additions & 0 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
android:layout_alignParentBottom="true"
/>

<Button
android:id="@+id/button_of_wave_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/seekbar_of_drop_height"
android:text="@string/btn_change_color" />

</RelativeLayout>

</LinearLayout>
2 changes: 2 additions & 0 deletions sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@

<string name="hello_world">Hello world!</string>
<string name="action_refresh">Refresh</string>

<string name="btn_change_color">Change the color</string>
</resources>

0 comments on commit e647221

Please sign in to comment.