Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
122 views
in Technique[技术] by (71.8m points)

java - If condition in repeated countdown

Hi I am making boxing countdowntimer. And I would like to set on text view "end" after all tasks. But I don't know how to do that. During the round I see that (pic1)

enter image description here

and during the break I see that (pic2)

enter image description here

And how make a condition to see "end" after all tasks because I am using handler function to repeat this for example 2 times and when I set condition " if (!tv1.getText().toString().equals("Przerwa"){ tv3.setText("end") but "end" shows me every single break. Btw. runda means rund and this is= tv1 1/2= tv2 2-3-2=tv3 00:03=tv4 tv means -textview Przerwa means break

timerododliczania = new CountDownTimer(1000, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            btn1.setVisibility(View.INVISIBLE);
            tv2.setText("" + millisUntilFinished / 1000);

        }
        @Override
        public void onFinish() {





            MediaPlayer boksring=MediaPlayer.create(Main3Activity.this,R.raw.rin9 );
            boksring.start();
            int liczbarund = 1;

            tv4.setText(ilo??rund);
            try {
                liczbarund = Integer.parseInt(tv4.getText().toString());
            } catch (Exception ex) {
                Toast.makeText(cntx, "Invalid Integer", Toast.LENGTH_LONG).show();
                return;
            }
            if (liczbarund == 0) {
                return;
            }
            final int[] round_count = {0};
            final int finalNum_rounds = liczbarund;
            final int[] round_count1 = {0};
            final int finalNum_rounds1 = liczbarund;
            final int[] round_count2 = {0};
            final int finalNum_roundsp = liczbarund;
           timerodrundy = new CountDownTimer(d?rundy, 1000) {
                @Override
                public void onTick(long millisUntilFinished) {
                    btn1.setVisibility(View.VISIBLE);
                    tv1.setText("Runda");
                    tv5.setText( (round_count1[0] + 1) + "/" + finalNum_rounds1);
                    mTimeLeftInMillis = millisUntilFinished;
                    updatetext();
                }
                @Override
                public void onFinish() {
                    tv1.setText("Przerwa");
                    MediaPlayer r1=MediaPlayer.create(Main3Activity.this, R.raw.rinknkw);
                    r1.start();
                    if (licz > 1) {
                        round_count[0]++;
                        if (round_count[0] < finalNum_rounds) {

                            Handler handler = new Handler();
                            handler.postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    start();
                                }
                            }, d?przerwy);
                        }
                    }
                    if (!tv2.getText().toString().equals("00:00")){
                        tv3.setText("Koniec");
                    }


                }
            }.
                    start();
            timerodkombosa = new CountDownTimer(d?rundy, 5000) {
                @Override
                public void onTick(long millisUntilFinished) {
                    final Random rand = ThreadLocalRandom.current();
                    tv3.setText(kombosy[new Random().nextInt(kombosy.length)]);
                    int resourceID = R.raw.rin1;

                    switch (tv3.getText().toString()) {
                        case "1-2":
                            resourceID =  R.raw.rin1;
                            break;
                        case "1-1-2":
                            resourceID =  R.raw.rin2;
                            break;
                        case "1-2-3-2":

                            resourceID =  R.raw.rin3;
                            break;
                        case "1-2-5-2":
                            resourceID =  R.raw.rin4;
                            break;
                        case "1-6-3-2":
                            resourceID =  R.raw.rin5;
                            break;
                        case "2-3-2":
                            resourceID =  R.raw.rin6;
                            break;
                    }

                    player = MediaPlayer.create(Main3Activity.this, resourceID);
                    player.start();
                }
                @Override
                public void onFinish() {
                    tv5.setText("");
                    tv3.setText("");
                    
                    if (licz > 1) {

                        round_count1[0]++;
                        if (round_count1[0] < finalNum_rounds1) {
                            Handler handler = new Handler();
                            handler.postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    start();
                                }
                            }, d?przerwy);
                            
                             timerodprzerwy = new CountDownTimer(d?przerwy, 1000) {
                                @Override
                                public void onTick(long millisUntilFinished) {
                                    mTimeLeftInMillis = millisUntilFinished;
                                    updatetext();
                                }
                                @Override
                                public void onFinish() {
                                    MediaPlayer r2=MediaPlayer.create(Main3Activity.this, R.raw.rinnkr);
                                    r2.start();

                                    CountDownTimer countDownTimer= new CountDownTimer(1000,1000) {
                                        @Override
                                        public void onTick(long millisUntilFinished) {
                                          

                                        }

                                        @Override
                                        public void onFinish() {

                                        }
                                    }.start();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...