Search code examples
androidandroid-graphview

JJOE64 Android graphview reset function


I've been trying to make a "realtime" graph using the reset function to reset the data, trying to prepare myself for using an external dataset. Here's the code;

 class MyTimerTask extends TimerTask {


    int y = 0;



    public void run() {
        Random Rn = new Random();
        int loopy = 0;
        int testvoor2 = Rn.nextInt(5)+1;


        testarraylist.add(testvoor2);



        tempServo2.resetData(new DataPoint[] {
        for (Integer object: testarraylist){

            new Datapoint(object,loopy);
            loopy = loopy + 1;


        };


        });


        String testvoor = Integer.toString(Rn.nextInt(100)+1);
        Log.d("temperatuur", testvoor);



    }
}

As you can see using an for loop in this function doesnt work, and the only alternative I can think of using an case to call different versions of the reset functions on basis of the length of the array list. However this seems so incredibly work intensive (not too mention the incredible spaghetti code) that I'm skeptical that there isnt an easier way.

Thanks in advance


Solution

  • Found out the problem wasnt in this part of the code but it was a threading problem.