質問するログイン新規登録

質問編集履歴

3

変更点のコードを変更箇所に書き換えました。

2020/05/12 14:21

投稿

Jhon_McClane
Jhon_McClane

スコア48

title CHANGED
File without changes
body CHANGED
@@ -195,9 +195,23 @@
195
195
 
196
196
  ```
197
197
  ```ここに言語を入力
198
- 質問箇所
198
+ 変更箇所
199
+ private void showWorkout(Workout workout) {
200
+ countTextView.setText(""+workout.getCount());
201
+ setTextView.setText(""+workout.getSet());
202
+ // progressBar.setProgress(workout.getTick());
203
+ ObjectAnimator animation = ObjectAnimator.ofInt(progressBar,"progress",workout.getTick());
204
+ animation.setDuration(500); // 0.5 secondかけて実行する
205
+ animation.start();
199
- int getTick() { return currentTick; }
206
+ int left = workout.getLeftSecond();
207
+ int minute = left / 60;
208
+ int second = left % 60;
209
+ lefttimeTextView.setText(String.format((minute>0?"%1$02d:":"")+"%2$02d", minute, second));
210
+ }
200
211
 
212
+
213
+ int getTick() { return currentTick; }//書き換え
214
+
201
215
  void start(Listener listener) {
202
216
  this.listener = listener;
203
217
  long millisInFuture = (tick+tickMax*(count*set-1))*1000L/PARTICLE_SIZE;
@@ -208,7 +222,8 @@
208
222
  currentTick++;
209
223
  if(tick < 0) {
210
224
  tick = tickMax -1;//切り替わったときに一秒増えないように調整
211
- currentTick = 1;
225
+ currentTick = 1;//tuiki
226
+
212
227
  if(--count <= 0) {
213
228
  set --;
214
229
  count = countMax;
@@ -219,7 +234,7 @@
219
234
  }
220
235
  @Override
221
236
  public void onFinish() {
222
- currentTick = 0;
237
+ currentTick = 0;//追記
223
238
  tick = 0;
224
239
  count = 0;
225
240
  set = 0;

2

質問箇所の追加

2020/05/12 14:21

投稿

Jhon_McClane
Jhon_McClane

スコア48

title CHANGED
File without changes
body CHANGED
@@ -195,23 +195,40 @@
195
195
 
196
196
  ```
197
197
  ```ここに言語を入力
198
- ※気になるところ
198
+ 質問箇所
199
+ int getTick() { return currentTick; }
200
+
201
+ void start(Listener listener) {
202
+ this.listener = listener;
203
+ long millisInFuture = (tick+tickMax*(count*set-1))*1000L/PARTICLE_SIZE;
199
- mCountDownTimer = new android.os.CountDownTimer(mTimeLeftInMillis, 500) {
204
+ countDownTimer = new CountDownTimer(millisInFuture, 1000L/PARTICLE_SIZE) { //[ms]
200
- @Override
205
+ @Override
201
- public void onTick(long millisUntilFinished) {
206
+ public void onTick(long millisUntilFinished) {
202
- mTimeLeftInMillis = millisUntilFinished;
207
+ tick --;
203
- updateFontText();
208
+ currentTick++;
209
+ if(tick < 0) {
210
+ tick = tickMax -1;//切り替わったときに一秒増えないように調整
204
- progressStatus += 1;
211
+ currentTick = 1;
205
- pb.setProgress(progressStatus);
212
+ if(--count <= 0) {
213
+ set --;
214
+ count = countMax;
206
215
  }
216
+ }
217
+ Workout.this.listener.progress(Workout.this);
207
218
 
219
+ }
208
- @Override
220
+ @Override
209
- public void onFinish() {
221
+ public void onFinish() {
210
- mTimerRunning = false;
222
+ currentTick = 0;
223
+ tick = 0;
224
+ count = 0;
225
+ set = 0;
211
- mButtonStartStop.setText("Start");
226
+ Workout.this.listener.finish(Workout.this);
212
- updateWatchInterface();
227
+ Workout.this.listener = null;
213
- }
228
+ }
214
- }.start();
229
+ }.start();
230
+ listener.start(Workout.this);
231
+ }
215
232
  ```
216
233
 
217
234
 

1

一部修正

2020/05/12 13:39

投稿

Jhon_McClane
Jhon_McClane

スコア48

title CHANGED
File without changes
body CHANGED
@@ -6,7 +6,7 @@
6
6
  拙いコードですが実現に向けての改善すべきところを教えていただけますか。
7
7
 
8
8
  ※気になるところ(下のソースコード)
9
- ここに記述した処理が終わるごとにfor文
9
+ ここに記述した処理を繰り返し前のtimer処理が終わった段階呼びたい
10
10
 
11
11
  ### 該当のソースコード
12
12