Skip to content

Commit 3093475

Browse files
committed
Added anim duration attribute.
1 parent c1a3a12 commit 3093475

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

app/src/main/res/layout/activity_main.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
android:id="@+id/equalizer_view"
1919
android:layout_width="30dp"
2020
android:layout_height="30dp"
21-
custom:foregroundColor="@color/link_text_material_light"/>
21+
custom:foregroundColor="@color/link_text_material_light"
22+
custom:animDuration="4000"/>
2223

2324
</LinearLayout>

library/src/main/java/es/claucookie/miniequalizerlibrary/EqualizerView.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class EqualizerView extends LinearLayout {
2828
Boolean animating = false;
2929

3030
int foregroundColor;
31+
int duration;
3132

3233
public EqualizerView(Context context) {
3334
super(context);
@@ -53,7 +54,8 @@ private void setAttrs(Context context, AttributeSet attrs) {
5354
0, 0);
5455

5556
try {
56-
foregroundColor = a.getColor(R.styleable.EqualizerView_foregroundColor, Color.BLACK);
57+
foregroundColor = a.getInt(R.styleable.EqualizerView_foregroundColor, Color.BLACK);
58+
duration = a.getInt(R.styleable.EqualizerView_animDuration, 4000);
5759

5860
} finally {
5961
a.recycle();
@@ -114,7 +116,6 @@ public void onGlobalLayout() {
114116
public void animateBars() {
115117
animating = true;
116118
if (playingSet == null) {
117-
int duration = 3000;
118119
ObjectAnimator scaleYbar1 = ObjectAnimator.ofFloat(musicBar1, "scaleY", 0.2f, 0.8f, 0.1f, 0.1f, 0.3f, 0.1f, 0.2f, 0.8f, 0.7f, 0.2f, 0.4f, 0.9f, 0.7f, 0.6f, 0.1f, 0.3f, 0.1f, 0.4f, 0.1f, 0.8f, 0.7f, 0.9f, 0.5f, 0.6f, 0.3f, 0.1f);
119120
scaleYbar1.setRepeatCount(ValueAnimator.INFINITE);
120121
ObjectAnimator scaleYbar2 = ObjectAnimator.ofFloat(musicBar2, "scaleY", 0.2f, 0.5f, 1.0f, 0.5f, 0.3f, 0.1f, 0.2f, 0.3f, 0.5f, 0.1f, 0.6f, 0.5f, 0.3f, 0.7f, 0.8f, 0.9f, 0.3f, 0.1f, 0.5f, 0.3f, 0.6f, 1.0f, 0.6f, 0.7f, 0.4f, 0.1f);
@@ -168,8 +169,5 @@ public Boolean isAnimating() {
168169
return animating;
169170
}
170171

171-
public void setAnimating(Boolean animating) {
172-
this.animating = animating;
173-
}
174172

175173
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<resources>
22
<declare-styleable name="EqualizerView">
33
<attr name="foregroundColor" format="integer" />
4+
<attr name="animDuration" format="integer" />
45
</declare-styleable>
56
</resources>

0 commit comments

Comments
 (0)