<commit_before>package de.otto.roboapp.ui.activities;

import android.graphics.Typeface;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;

import java.util.ArrayList;

import de.otto.roboapp.R;
import de.otto.roboapp.RoboAppController;
import de.otto.roboapp.model.DataModel;
import de.otto.roboapp.model.RacingData;
import de.otto.roboapp.model.RacingState;
import de.otto.roboapp.model.SteeringDirection;
import de.otto.roboapp.ui.activities.base.AbstractUpdatableActivity;
import de.otto.roboapp.ui.components.SpeedLights;

import static de.otto.roboapp.util.ThreadStarter.processInNewThread;


public class SteeringActivity extends AbstractUpdatableActivity {

    TextView speedText;
    ArrayList <ImageView> imageViews = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final RoboAppController roboAppController = (RoboAppController)getApplicationContext();

        // remove title bar, set fullscreen
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_steering);

        SeekBar speedSlider = (SeekBar) findViewById(R.id.ID_Speed_Slider);


        speedSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, final int progress, boolean fromUser) {
                processInNewThread(new Runnable() {
                    @Override
                    public void run() {
                        long targetSpeed = Math.round((progress - 20) * 1.25); //-25 <-> +100
                        System.out.println("slided to " + targetSpeed);
                        roboAppController.steer(targetSpeed);
                    }
                });
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });

        final ImageView t_imageViewLeft = (ImageView) findViewById(R.id.ID_Left);
        t_imageViewLeft.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getX() >= 0 && event.getY() >= 0 && event.getX() < v.getWidth() && event.getY() < v.getHeight()) {
                    if (event.getAction() == MotionEvent.ACTION_DOWN) {
                        processInNewThread(new Runnable() {
                            @Override
                            public void run() {
                                System.out.println("pressed left");
                                roboAppController.steer(SteeringDirection.LEFT);
                            }
                        });
                    } else if (event.getAction() == MotionEvent.ACTION_UP) {
                        processInNewThread(new Runnable() {
                            @Override
                            public void run() {
                                System.out.println("released left");
                                roboAppController.steer(SteeringDirection.NONE);
                            }
                        });
                    }
                }
                return true;
            }
        });

        final ImageView t_imageViewRight = (ImageView) findViewById(R.id.ID_Rigth);
        t_imageViewRight.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                if (event.getX() >= 0 && event.getY() >= 0 && event.getX() < v.getWidth() && event.getY() < v.getHeight()) {
                    if (event.getAction() == MotionEvent.ACTION_DOWN) {
                        processInNewThread(new Runnable() {
                            @Override
                            public void run() {
                                System.out.println("pressed right");
                                roboAppController.steer(SteeringDirection.RIGHT);
                            }
                        });
                    } else if (event.getAction() == MotionEvent.ACTION_UP) {
                        processInNewThread(new Runnable() {
                            @Override
                            public void run() {
                                System.out.println("released right");
                                roboAppController.steer(SteeringDirection.NONE);
                            }
                        });
                    }
                }

                return true;
            }
        });

        displayModel(roboAppController.getDataModel());
    }

    public void displayModel(DataModel dataModel) {

        switch (dataModel.getRacingData().getRacingState()) {
            case COUNTDOWN_RUNNING: {
                final TextView t_textViewTimer = (TextView) findViewById(R.id.CountdownTimer);

                Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Munro.ttf");
                t_textViewTimer.setTypeface(tf);

                new CountDownTimer(3000, 1000) {

                    public void onTick(long millisUntilFinished) {
                        t_textViewTimer.setText(String.valueOf((millisUntilFinished+500)/1000));
                        // String.valueOf(dataModel.getRacingData().getCountdownRemainingTime())
                    }
<commit_msg>countdown zeigt wieder 1 an, ist aber flaky<commit_after>package de.otto.roboapp.ui.activities;

import android.graphics.Typeface;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;

import java.util.ArrayList;

import de.otto.roboapp.R;
import de.otto.roboapp.RoboAppController;
import de.otto.roboapp.model.DataModel;
import de.otto.roboapp.model.RacingData;
import de.otto.roboapp.model.RacingState;
import de.otto.roboapp.model.SteeringDirection;
import de.otto.roboapp.ui.activities.base.AbstractUpdatableActivity;
import de.otto.roboapp.ui.components.SpeedLights;

import static de.otto.roboapp.util.ThreadStarter.processInNewThread;


public class SteeringActivity extends AbstractUpdatableActivity {

    TextView speedText;
    ArrayList <ImageView> imageViews = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final RoboAppController roboAppController = (RoboAppController)getApplicationContext();

        // remove title bar, set fullscreen
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_steering);

        SeekBar speedSlider = (SeekBar) findViewById(R.id.ID_Speed_Slider);


        speedSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, final int progress, boolean fromUser) {
                processInNewThread(new Runnable() {
                    @Override
                    public void run() {
                        long targetSpeed = Math.round((progress - 20) * 1.25); //-25 <-> +100
                        System.out.println("slided to " + targetSpeed);
                        roboAppController.steer(targetSpeed);
                    }
                });
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });

        final ImageView t_imageViewLeft = (ImageView) findViewById(R.id.ID_Left);
        t_imageViewLeft.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getX() >= 0 && event.getY() >= 0 && event.getX() < v.getWidth() && event.getY() < v.getHeight()) {
                    if (event.getAction() == MotionEvent.ACTION_DOWN) {
                        processInNewThread(new Runnable() {
                            @Override
                            public void run() {
                                System.out.println("pressed left");
                                roboAppController.steer(SteeringDirection.LEFT);
                            }
                        });
                    } else if (event.getAction() == MotionEvent.ACTION_UP) {
                        processInNewThread(new Runnable() {
                            @Override
                            public void run() {
                                System.out.println("released left");
                                roboAppController.steer(SteeringDirection.NONE);
                            }
                        });
                    }
                }
                return true;
            }
        });

        final ImageView t_imageViewRight = (ImageView) findViewById(R.id.ID_Rigth);
        t_imageViewRight.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                if (event.getX() >= 0 && event.getY() >= 0 && event.getX() < v.getWidth() && event.getY() < v.getHeight()) {
                    if (event.getAction() == MotionEvent.ACTION_DOWN) {
                        processInNewThread(new Runnable() {
                            @Override
                            public void run() {
                                System.out.println("pressed right");
                                roboAppController.steer(SteeringDirection.RIGHT);
                            }
                        });
                    } else if (event.getAction() == MotionEvent.ACTION_UP) {
                        processInNewThread(new Runnable() {
                            @Override
                            public void run() {
                                System.out.println("released right");
                                roboAppController.steer(SteeringDirection.NONE);
                            }
                        });
                    }
                }

                return true;
            }
        });

        displayModel(roboAppController.getDataModel());
    }

    public void displayModel(DataModel dataModel) {

        switch (dataModel.getRacingData().getRacingState()) {
            case COUNTDOWN_RUNNING: {
                final TextView t_textViewTimer = (TextView) findViewById(R.id.CountdownTimer);

                Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Munro.ttf");
                t_textViewTimer.setTypeface(tf);

                new CountDownTimer(3000, 1000) {

                    public void onTick(long millisUntilFinished) {
                        t_textViewTimer.setText(String.valueOf((millisUntilFinished)/1000));
                        // String.valueOf(dataModel.getRacingData().getCountdownRemainingTime())
                    }

{'fraction_non_alphanumeric': 0.09206240356591805, 'fraction_numerical': 0.00480027430138865, 'mean_word_length': 1.6527967257844476, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3636273', 'n_tokens_mistral': 3073, 'n_tokens_neox': 2853, 'n_words': 497}