|
@@ -78,6 +78,10 @@ public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBindi
|
|
|
@Override
|
|
|
protected void initView() {
|
|
|
viewBinding.toolbarInclude.toolbar.setBackgroundColor(Color.TRANSPARENT);
|
|
|
+ updateSpeedText();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateSpeedText() {
|
|
|
viewBinding.tvSpeed.setText(String.valueOf(currentBeatRate));
|
|
|
}
|
|
|
|
|
@@ -182,6 +186,8 @@ public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBindi
|
|
|
|
|
|
private void initListener() {
|
|
|
viewBinding.ivBeatValue.setOnClickListener(this);
|
|
|
+ viewBinding.ivAdd.setOnClickListener(this);
|
|
|
+ viewBinding.ivReduce.setOnClickListener(this);
|
|
|
viewBinding.tvPlay.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
@@ -225,7 +231,7 @@ public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBindi
|
|
|
currentBeatRate = MetronomeConfig.MAX_PLAY_RATE;
|
|
|
}
|
|
|
lastProgress = newProgress;
|
|
|
- viewBinding.tvSpeed.setText(String.valueOf(currentBeatRate));
|
|
|
+ updateSpeedText();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -306,5 +312,42 @@ public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBindi
|
|
|
selectSymbols();
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ if (id == R.id.iv_reduce) {
|
|
|
+ //减速
|
|
|
+ if (currentBeatRate != MetronomeConfig.MIN_PLAY_RATE) {
|
|
|
+ currentBeatRate -= 1;
|
|
|
+ updateSpeedText();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (id == R.id.iv_add) {
|
|
|
+ //加速
|
|
|
+ if (currentBeatRate != MetronomeConfig.MAX_PLAY_RATE) {
|
|
|
+ currentBeatRate += 1;
|
|
|
+ updateSpeedText();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateAnim(int value) {
|
|
|
+ int progress = viewBinding.cirSeekbar.getProgress();
|
|
|
+ if (value > 0) {
|
|
|
+ progress += (value * MetronomeConfig.PLAY_RATE_UNIT);
|
|
|
+ Log.i("pq", "progress:" + progress);
|
|
|
+ progress = progress % MetronomeConfig.MAX_RATE_PROGRESS;
|
|
|
+ Log.i("pq", "progress:" + progress);
|
|
|
+ viewBinding.cirSeekbar.setProgress(progress);
|
|
|
+ } else {
|
|
|
+ progress += (value * MetronomeConfig.PLAY_RATE_UNIT);
|
|
|
+ if (progress < 0) {
|
|
|
+ viewBinding.cirSeekbar.setProgress(MetronomeConfig.MAX_RATE_PROGRESS + progress);
|
|
|
+ } else {
|
|
|
+ Log.i("pq", "progress:" + progress);
|
|
|
+ viewBinding.cirSeekbar.setProgress(progress);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|