package com.example.andy.myapplication;

import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

public class MainActivity extends AppCompatActivity {
    TextView textview;

    @Override
    protected void onCreate(Bundle readdInstanceState) {
        super.onCreate(readdInstanceState);
        setContentView(R.layout.activity_main);
        textview = findViewById(R.id.textview);
        Date today = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("HH:MM");
        textview.setText(formatter.format(today));
        blink();



    }

    private void blink() {
        final Handler hander=new Handler();
        new Thread(new Runnable() {
            @Override
            public void run() {

                try {

                    Thread.sleep(550);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }


                hander.post(new Runnable() {
                    @Override
                    public void run() {
                        if(textview.getVisibility() == View.VISIBLE){
                            textview.setVisibility(View.INVISIBLE);
                        }else{
                            textview.setVisibility(View.VISIBLE);
                        }
                        blink();
                    }
                });
            }
        }).start();
    }

}
