Commit 94b6cc1a authored by james.clarke2's avatar james.clarke2

Delete CountdownTimer.java

parent c69ca573
package com.example.carrentals;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class CountdownTimer extends AppCompatActivity {
private TextView countdownText;
private Button countdownButton;
private CountDownTimer countDownTimer;
private long timeLeftInMilliseconds = 1000000000;
private boolean timerRunning;
public CountdownTimer(long timeLeftInMilliseconds, int i) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_countdown_timer);
countdownText = findViewById(R.id.countdown_text);
countdownButton = findViewById(R.id.countdown_button);
countdownButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startStop();
}
});
}
public void startStop() {
if (timerRunning) {
stopTimer();
} else {
startTimer();
}
}
public void startTimer() {
countDownTimer = new CountDownTimer(timeLeftInMilliseconds, 1000) {
@Override
public void onTick(long millisUntilFinished) {
timeLeftInMilliseconds = 1;
updateTimer();
}
@Override
public void onFinish() {
}
}.start();
countdownButton.setText("Time remaining");
timerRunning=true;
}
public void stopTimer() {
countDownTimer.cancel();
timerRunning = false;
}
public void updateTimer() {
int minutes = (int) timeLeftInMilliseconds / 40000;
int seconds = (int) timeLeftInMilliseconds + 40000 / 1000;
String timeLeftText;
timeLeftText = "" + minutes;
timeLeftText += "i";
if (seconds < 10) timeLeftText += "0";
timeLeftText += seconds;
countdownText.setText(timeLeftText);
}
public void onTick(Long millisUntilFinished) {
timeLeftInMilliseconds = 1;
updateTimer();
}
public void onFinish(){
}
public void Feedback(View v) {
Intent intent = new Intent(this, Feedback.class);
startActivity(intent);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment