Android User input to countdown timer - android

I'm working on a countdown timer with user input on how many seconds to count down.
private void showTimer() {
myString = ((EditText)editTextTimer).getText().toString();
int countdownMillis = Integer.parseInt(myString) * 1000;
if (timer != null) {
timer.cancel();
}
timer = new CountDownTimer(countdownMillis, MILLIS_PER_SECOND) {
#Override
public void onTick(long millisUntilFinished) {
((TextView) countdownDisplay).setText("Counting down: " +
millisUntilFinished / MILLIS_PER_SECOND);
((TextView) countdownDisplay).setTextSize(25);
}
#Override
public void onFinish() {
((TextView)countdownDisplay).setText("Time's Up !");
((TextView)countdownDisplay).setTextSize(25);
}
}.start();
}
I'm doing this on a fragment. The problem is the text display of the "Time's Up" after I insert the time and click start. When clicking start again the timer will just start to display and countdown. As well the timer sometimes will skip 1 second.
Example user insert 10.
It will countdown from 10 , 9 , 7, 6, 5, 4, 3, 2, 1 - 8 is missing.
onCreatView
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_countDown, container, false);
countdownDisplay = rootView.findViewById(R.id.txtTimerLeft);
editTextTimer = rootView.findViewById(R.id.txtTimer);
startbutton = rootView.findViewById(R.id.button_start1);
startbutton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
try {
showTimer();
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
});
return rootView;
}
Declaration
View editTextTimer;
View startbutton;
private static final int MILLIS_PER_SECOND = 1000;
int SECONDS_TO_COUNTDOWN;
View countdownDisplay;
private CountDownTimer timer;
String myString;

You are passing SECONDS_TO_COUNTDOWN * MILLIS_PER_SECONDand on first try it would 0, as well you initialize SECONDS_TO_COUNTDOWN it only inside showTimer function. Go that way:
private void showTimer() {
myString = ((EditText)editTextTimer).getText().toString();
int countdownMillis = Integer.parseInt(myString) * 1000;
Do not pass nothing in function and read value from editText. You can remove SECONDS_TO_COUNTDOWN at all. That's it.

Related

Can't stop CountDownTimer

Good day! I try to make countdown timer till date, but I have next problem: when I set date and time - it's work's fine, but when I try to reset timer and then reload application I still saw the previous timer countdown. I have already try everything that I can even imaging.
public class MainActivity extends AppCompatActivity {
TextView tv_days;
TextView tv_hours;
TextView tv_minutes;
TextView tv_seconds;
TextView tv_msg;
ImageButton btnTimer;
ImageButton btnExit;
long total_millisec;
CountDownTimer cdt;
TimerPreference timerPreference;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv_days = (TextView) findViewById(R.id.days);
tv_hours = (TextView) findViewById(R.id.hours);
tv_minutes = (TextView) findViewById(R.id.minutes);
tv_seconds = (TextView) findViewById(R.id.seconds);
tv_msg = (TextView) findViewById(R.id.msg);
btnTimer = (ImageButton) findViewById(R.id.setTimer);
btnExit = (ImageButton) findViewById(R.id.resetTimer);
final Intent setTimer = new Intent(this, ShowActivity.class);
timerPreference = new TimerPreference(this);
total_millisec = timerPreference.getTime();
if(total_millisec != 0){
setTime();
}
View.OnClickListener mainWin = new View.OnClickListener() {
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.setTimer:
startActivity(setTimer);
break;
case R.id.resetTimer:
resetTimer();
break;
}
}
};
btnTimer.setOnClickListener(mainWin);
btnExit.setOnClickListener(mainWin);
}
public void setTime() {
cdt = new CountDownTimer(total_millisec, 1000) {
#Override
public void onTick(long millisUntilFinished) {
timerPreference.setTime(millisUntilFinished);
long days = TimeUnit.MILLISECONDS.toDays(millisUntilFinished);
millisUntilFinished -= TimeUnit.DAYS.toMillis(days);
long hours = TimeUnit.MILLISECONDS.toHours(millisUntilFinished);
millisUntilFinished -= TimeUnit.HOURS.toMillis(hours);
long minutes = TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished);
millisUntilFinished -= TimeUnit.MINUTES.toMillis(minutes);
long seconds = TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished);
setScreenData(String.valueOf(days),
String.valueOf(hours),
String.valueOf(minutes),
String.valueOf(seconds));
}
#Override
public void onFinish() {
Log.e("TIMER:"," FINISH!");
}
};
cdt.start();
}
public void setScreenData(String setD, String setH,String setM, String setS){
tv_days.setText(setD);
tv_hours.setText(setH);
tv_minutes.setText(setM);
tv_seconds.setText(setS);
tv_msg.setText("");
}
private void resetTimer(){
AlertDialog.Builder quitDialog = new AlertDialog.Builder(this);
quitDialog.setTitle("Reset Timer?");
quitDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
});
quitDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
cancelTimer();
recreate();
}
});
quitDialog.show();
}
void cancelTimer() {
if(cdt!=null) {
cdt.cancel();
}
timerPreference.clearPreferences();
}
}
I logged this code for some hours, and I have noticed that even after I cancel timer, clear preferences and reload app, "total_millisec = timerPreference.getTime();" in onCreate still have time information...
Thank you in advance, for any answer.
UDP:
TimerPreference.java
class TimerPreference {
private SharedPreferences prefs;
TimerPreference(Context context){
prefs = context.getSharedPreferences("Timer",Context.MODE_PRIVATE);
}
void setTime(Long time){
prefs.edit().putLong("time", time).apply();
}
Long getTime(){
return prefs.getLong("time", 0);
}
void clearPreferences(){
SharedPreferences.Editor editor = prefs.edit();
editor.clear();
editor.apply();
}
}
UPD2:
I logged code using String.valueOf(timerPreference.getTime()) and get that when I press reset I get "TIME-IN-cancelTimer: 0", than activity reloaded by onrecreate(); and I get "TIME-IN-onCreate: 0", but when I close app and open again - I get "TIME-IN-onCreate: 47025952", so now I almoust sure that the problem is in class TimerPreference...but I still can't find solution.
After hours I have noticed another pattern: if to set time, reset the timer and restart the application - everything works as it should. But if to set the time, restart it, and then reset the timer - after next app start, it again start countdown.
Add timerPreference.setTime(0); after timerPreference.clearPreferences(); in cancelTimer() method.
Try to use editor.commit(); in clearPreferences() method of TimerPreference class

Countdown timer that that increases speed after button press

I am trying to create a countdown timer that will increases its speed after a button press I uses the counter also to adjust a progress bar.
Right now I am adjusting the speed (increasing) after the button is pressed but it does not start from the beginning. For example, when I start my program the timer start from the beginning and decreases progressively, which is fine. However, when I press the button the counter does not start from the beginning like this:
I want just to make it run faster after each button press, not to decrease the length.
this is my code:
mTrueBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//is the user right? if pressing True button
if(isMathProblemTrue == 1){
//user is correct
Toast.makeText(MainActivity.this,"Correct!",Toast.LENGTH_SHORT).show();
generateMathProblem();
timer_length *= 0.8;
timer_interval *= 0.8;
Log.d(TAG,"time length:"+timer_length);
Log.d(TAG,"time interval:"+timer_interval);
mCountDownTimer.cancel();
createNStartTimer();
//restartTimer();
}else{
//user is incorrect
transferUserToStartScreen();
//reset the timer
mCountDownTimer.cancel(); // cancel
}
}
});
private void createNStartTimer() {
mCountDownTimer = new CountDownTimer(timer_length,timer_interval) {
#Override
public void onTick(long millisUntilFinished) {
Log.d(TAG,"Mil until finish:"+millisUntilFinished);
int progress = (int) (millisUntilFinished/100);
mProgressBar.setProgress(progress);
}
#Override
public void onFinish() {
mProgressBar.setProgress(0);
transferUserToStartScreen();
}
}.start();
}
create 2 global constants outside the functions
int totalMillisUntilFinished = 0;
bool firstTime = true;
we initialize the totalMillisUntilFinished when onTick is called for the time, so update your your onTick function:
private void createNStartTimer() {
firstTime = true;
mCountDownTimer = new CountDownTimer(timer_length,timer_interval) {
#Override
public void onTick(long millisUntilFinished) {
if(firstTime){totalMillisUntilFinished = millisUntilFinished; firstTime = false;}
Log.d(TAG,"Mil until finish:"+millisUntilFinished);
int progress = (int) (millisUntilFinished*100/totalMillisUntilFinished);
mProgressBar.setProgress(progress);
}
Personally, I use Handlers and Runnables, which I would definitely suggest looking into instead.

Change textColor of textswitcher/viewswitcher based on int value?

I have a countdown timer starting at 60000 milliseconds and want to change the text color from Color.BLUE to Color.RED once the time is at and below 10000 milliseconds. I've tried the following without any success; attempted to setTextColor of TextSwitcher and add IF statement that would change color based on int value timerState.. I can't figure out how to make it work besides possibly stopping the timer and creating another one once the millisecondsUntilFinished hits 10000 which actually lead to my second issue where:
I click on an imageButton that initiates a dialog fragment (PauseFragment) and calling cancel() on my CountDownTimer via timerCDT.cancel(). I ran into some nullpointer issues hence the if statements checking for null in my code, but now once the PauseFragment dismisses my new timer starts back at 60000 rather than where it last left off. I was hoping that long timerState = 60000 would get updated to whatever millisUntilFinished is everytime onTick() was called but I'm not sure where I went wrong!
Therefore, can someone please assist me with changing TextSwitcher text color dynamically and assist in figuring out why my CountDownTimer isn't starting at the expected value. Any assistance is greatly appreciated.
THANKS in advance!
public class GameActivity extends FragmentActivity implements PauseFragment.FragmentCommunicator,{
public static long timerState = 60000;
public static boolean isTimerOn = false;
private String modeChoice = ModesActivity.mode;
private TextSwitcher timerTextSwitcher;
CountDownTimer timerCDT;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//...more code
timerTextSwitcher = (TextSwitcher) findViewById(R.id.timerTextSwitcher);
timerTextSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
public View makeView() {
// Create a new TextView and set properties
TextView textView = new TextView(getApplicationContext());
textView.setLayoutParams(new TextSwitcher.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
textView.setTextSize(20);
textView.setTextColor(Color.BLUE);
if (timerState < 10001) {
textView.setTextColor(Color.RED);
}
return textView;
}
});
// Declare the animations and initialize them
Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right);
// set the animation type to textSwitcher
timerTextSwitcher.setInAnimation(in);
timerTextSwitcher.setInAnimation(out);
}
timerCDT = new CountDownTimer(timerState, 1000) {
public void onTick(long millisUntilFinished) {
isTimerOn = true;
timerTextSwitcher.setText(String.valueOf(millisUntilFinished / 1000));
timerState = millisUntilFinished;
}
//TODO: assign highscores for players to beat
public void onFinish() {
timerTextSwitcher.post(new Runnable() {
#Override
public void run() {
createToast("GAME OVER!");
}
});
isTimerOn = false;
DialogFragment endDialog = new EndGameFragment();
endDialog.show(getSupportFragmentManager(), "EndGameDialogFragment");
}
};
timerCDT.start();
#Override
public void onPause() {
super.onPause();
Bundle args = new Bundle();
args.putInt(ARG_SCORE, scoreINT);
args.putLong(ARG_TIMER, timerState);
args.putString(GameActivity.ARG_MODE, modeChoice);
if (timerCDT != null) {
timerCDT.cancel();
}
else{
createToastExtended("onPause() - timerCDT is null; attempt to cancel");
}
}
//.!.other fun code here.!.
#Override
protected void onStop() {
super.onStop();
if (timerCDT != null) {
timerCDT.cancel();
}
else{
createToastExtended("onStop() - timerCDT is null; attempt to cancel");
}
}
//Player Response information
#Override
public void pauseFragmentResponse() {
if (timerCDT != null) {
timerCDT.start();
}
else{
createToastExtended("pauseFragmenResponse() - timerCDT is null; attempt to start");
}
}
public void pauseStartFrag(View view) {
DialogFragment dialog = new PauseFragment();
if (timerCDT != null) {
timerCDT.cancel();
}
else{
createToastExtended("pauseStartFrag() - timerCDT is null;attempt to cancel");
}
dialog.show(getSupportFragmentManager(), "PauseDialogFragment");
}
// Code for PauseFragment
//TODO: remove unuses imports on all files within project;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
public class PauseFragment extends DialogFragment {
public static boolean isPaused = false;
public FragmentCommunicator fComm;
#Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
fComm = (FragmentCommunicator) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement FragmentCommunicator");
}
}
#Override
public void onDetach() {
super.onDetach();
fComm = null;
}
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
isPaused = true;
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(R.layout.fragment_pause, null))
.setMessage(R.string.dialog_pause)
.setPositiveButton(R.string.action_main_menu, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent i4 = new Intent(getActivity(), StartActivity.class);
startActivity(i4);
}
})
.setNeutralButton(R.string.action_restart, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent i4 = new Intent(getActivity(), ModesActivity.class);
startActivity(i4); }
})
.setNegativeButton(R.string.action_resume, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
fComm.pauseFragmentResponse();
dismiss();
}
});
// Create the AlertDialog object and return it
return builder.create();
}
#Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
isPaused = false;
}
public interface FragmentCommunicator {
public void pauseFragmentResponse();
}
}
Lastly, Idk if it's of any help but I also tried starting the CountDownTimer timerCDT without the FragmentCommunicator interface but the system couldn't find the timer? If someone could shine light on why this happened I'd appreciate it as well.
Seriously, one last thing, if the timer is for a game and needs to be stopped and updated frequently, is it best to use CountDownTimer, TimerTask, a newThread that implements Runnable or a handler or some sort? I've tried them all but as I add components and features to the app I need more and more flexibility with changing the time and not quite sure if I'm headed down the right path. Hope this post isn't too vague. Please let me know if I need to separate into multiple posts or something...
Thanks as always!
just had a look on the developer website here http://developer.android.com/reference/android/os/CountDownTimer.html and it looks like you should probably be placing that if statement in the onTick method, so for every tick you do the check.
EDIT
ok this works perfectly for me
private TextSwitcher TextSw;
private TextView TextSwTextView;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(com.game.test.R.layout.sample);
TextSw = (TextSwitcher) findViewById(R.id.TextSwitchView);
TextSw.setFactory(new ViewSwitcher.ViewFactory()
{
public View makeView()
{
// Create a new TextView and set properties
TextView textView = new TextView(getApplicationContext());
textView.setLayoutParams(new TextSwitcher.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
textView.setTextSize(20);
textView.setTextColor(Color.BLUE);
return textView;
}
});
mtimer = new CountDownTimer(60000, 1000)
{
public void onTick(long millisUntilFinished)
{
TextSwTextView = (TextView) TextSw.getChildAt(0);
if(millisUntilFinished < 10001)
TextSwTextView.setTextColor(Color.RED);
TextSwTextView.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish()
{
TextSwTextView.setText("done!");
}
}.start();
}
so the above is a simple version of yours, the text that is displaying the timer will change to Red when the timer hit 1000. You should be able to build this into yours.
But the main thing you have to do here is to check how much the timer has left in the in the onTick method and also change the text color in here to - see above
This thread helped me solve my problem more easily:
https://groups.google.com/forum/#!topic/android-developers/jdlUp_RlP2w
Your get a handle on the textviews within the textSwitcher like this:
TextView t1 = (TextView) mSwitcher.getChildAt(0);
TextView t2 = (TextView) mSwitcher.getChildAt(1);
Then you set whatever color you need based on your code logic.
TextView t1, t2;
textSwitcher = (TextSwitcher) findViewById(R.id.textView99);
textSwitcher.setInAnimation(this, R.anim.slide_in_right);
textSwitcher.setOutAnimation(this, R.anim.slide_out_left);
t1 = new TextView(this);
t2 = new TextView(this);
t1.setTextSize(20);
t2.setTextSize(20);
textSwitcher.addView(t1);
textSwitcher.addView(t2);

Android GridView first button not working

I am having weird problems with Android GridView. I create a 3x4 grid and insert buttons into that grid. I want the background of the button to change when the user clicks that button. And this is working just fine for all buttons except the first one (the one with index 0 - top left). OnClick event listener doesn't fire at all for that button no matter what I do.
Here is the code where I create the view:
public View getView(int position, View convertView, ViewGroup parent) {
Button imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes
Log.w("NOVO", "narejena nova celica");
imageView = new Button(mContext);
imageView.setPadding(8, 8, 8, 8);
} else {
Log.w("STARO", "stara celica");
imageView = (Button) convertView;
}
imageView.setEnabled(true);
int visina = parent.getHeight();
int sirina = parent.getWidth();
float dip = mContext.getResources().getDisplayMetrics().density;
float margin = 10*dip;
int view_height = (int)(visina - 3*margin)/4;
int view_width = (int)(sirina - 2*margin)/3;
int view_dim = 0;
if (view_height <= view_width)
view_dim = view_height;
else
view_dim = view_width;
imageView.setLayoutParams(new GridView.LayoutParams(view_dim, view_dim));
imageView.setId(position);
imageView.setOnClickListener(celice.get(position));
/*imageView.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
//Toast toast = Toast.makeText(mContext, v.getId() + "bla", Toast.LENGTH_SHORT);
//toast.show();
celice.get(v.getId()).celicaVisible(4000);
}});*/
celice.get(position).id = position;
celice.get(position).setButton(imageView);
return imageView;
}
If I replace
imageView = (Button) convertView;
with
imageView = new Button(mContext);
then the onClick() gets fired but the background still doesn't change. All the other buttons are working as expected.
And here is the custom class "Celica" that takes care of the actual work - changing the background...
public class Celica implements OnClickListener {
public boolean odkrit;
public boolean najden;
public int id;
public Drawable slikca1, slikca2;
public Celica par;
private Timer tim;
public Button but;
public Context con;
static int buttonsVisible = 0;
Celica(Drawable s1, Drawable s2) {
this.slikca1 = s1;
this.slikca2 = s2;
}
void celicaVisible(int millis) {
if (odkrit)
return;
Log.w("TEST", "prizganih " + buttonsVisible);
if (buttonsVisible >= 2)
return;
odkrit = true;
buttonsVisible++;
tim = new Timer();
tim.schedule(new timerDone(), millis);
((Activity)con).runOnUiThread(new Runnable() {
#Override
public void run() {
but.setBackground(slikca2);
}
});
}
void setButton(Button b) {
but = b;
((Activity)con).runOnUiThread(new Runnable() {
#Override
public void run() {
but.setBackground(slikca1);
}
});
}
class timerDone extends TimerTask {
#Override
public void run() {
if (!najden) {
odkrit = false;
((Activity)con).runOnUiThread(new Runnable() {
#Override
public void run() {
but.setBackground(slikca1);
}
});
}
buttonsVisible--;
tim.cancel();
}
}
#Override
public void onClick(View v) {
celicaVisible(4000);
}
}
In Android, ID of any View must be non zero and non negative number. means View ID should be > 0. and there is problem, when you are setting ID to the Button like
imageView.setId(position)
here ID of a button will be zero when position is zero(means first item). may be due to this, First Button's OnClickListener is not getting fired...try setting a ID that is greater than zero to Button and try once...
you can write like
imageView.setId(position+1) to ensure ID > 0
I actually figured it out. Everything works if I use the view that gets provided by the onClick() method instead of saving the actual button at the creation of the Celica object.
So basically adding:
but = (Button) v;
to the onClick() method solved the problem.

How to wait application until countDownTimer finish

Similar query: wait until all threads finish their work in java
Hello,
I'm developing android application that contains some kind of count down timer. My problem is, that I have multiple count down timers, that sets text of TextView and have to work separately (first count down timer has to wait until the second one is finished etc.)
See code:
MyCountDownTimer.java
public class MyCountdownTimer extends CountDownTimer {
TextView tv;
// default constructor
public MyCountdownTimer (long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
// constructor
public MyCountdownTimer(int hours, int mins, int secs,
long countDownInterval, TextView tv) {
super(3600000 * hours + 60000 * mins + secs * 1000, countDownInterval);
this.tv = tv;
// all other settings
}
// when finished, set text of textview to done
#Override
public void onFinish() {
tv.setText("done!");
}
// when working periodically update text of text view to value of time left
#Override
public void onTick(long millisUntilFinished) {
tv.setText(/*function setting text of TextView based on time left*/);
}
}
Timer.java
public class Timer extends Fragment {
Button bStart;
Button bStop;
TextView tvShowTime;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.timer, container, false);
}
public void onStart() {
super.onStart();
bStart = (Button) getView().findViewById(R.id.bTimerStart);
bStop = (Button) getView().findViewById(R.id.bTimerStop);
tvShowTime = (TextView) getView().findViewById(R.id.showTime);
// setting on button start click
bStart.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
timerStart();
}
});
// setting on button stop click
bStop.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
timerStop();
}
});
}
private void timerStart() {
bStart.setClickable(false);
int repeat = 2;
int hour, mins, secs;
for (int i = 0; i < 2 * repeat; i++) {
if (i % 2 == 0) {
// setting working count down timer values
mins = 1;
} else {
// setting resting count down timer values
secs = 30;
}
timerCount = new MyCountdownTimer(hours, mins, secs, REFRESH_RATE,
tvShowTime);
timerCount.start();
//////////////////////////////////////////////////
// HERE I WANT TO WAIT UNTIL COUNTDOWN IS DONE //
// ATM SECOND, THIRD AND FOURTH COUNT DOWN //
// TIMER IS STARTED //
//////////////////////////////////////////////////
}
}
-- EDIT --
At the end I did 2 CountDownTimers where first one calls in onFinish() second one and second one calls the first one until repeat = 0;
In final it was the best sotution for me. Anyway thanks for help, #Triode's answer helped me a lot
Start your SECOND, THIRD AND FOURTH COUNT DOWN TIMER in onFinish() of Your MyCountdownTimer
I think you have to put down the timerStop() method implementation and do not try to hide it,you need answer but you don't want others to benifit :s

Categories

Resources