From 2441f66b21d8191ac81681c6a82c290058ad50c1 Mon Sep 17 00:00:00 2001 From: Alexandre PAQUIER Date: Tue, 5 Mar 2019 16:06:36 +0100 Subject: [PATCH] add branch on project --- .idea/codeStyles/Project.xml | 48 -- .idea/dbnavigator.xml | 456 ------------------ .idea/gradle.xml | 9 +- .idea/misc.xml | 34 +- .../java/com/example/austime/DessinView.java | 155 ++++++ .../com/example/austime/MainActivity.java | 2 +- 6 files changed, 192 insertions(+), 512 deletions(-) delete mode 100644 .idea/dbnavigator.xml create mode 100644 app/src/main/java/com/example/austime/DessinView.java diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index d5ec3da..30aa626 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,29 +1,5 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml deleted file mode 100644 index 2bcafe4..0000000 --- a/.idea/dbnavigator.xml +++ /dev/null @@ -1,456 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 2996d53..7ac24c7 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,11 +3,14 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index 77ef57d..b0c7b20 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,12 +1,38 @@ - + + + + + - - \ No newline at end of file diff --git a/app/src/main/java/com/example/austime/DessinView.java b/app/src/main/java/com/example/austime/DessinView.java new file mode 100644 index 0000000..439ec62 --- /dev/null +++ b/app/src/main/java/com/example/austime/DessinView.java @@ -0,0 +1,155 @@ +package com.example.austime; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.os.AsyncTask; +import android.view.View; + +import java.util.Date; + +public class DessinView extends View { + static Canvas canvas; + Float percent = (float)0.5; + long timeDebut = new Date().getTime(); + long timeFin = new Date().getTime()+100*1000; + + Runnable refresh; + boolean truc = true; + DessinView to; + + public DessinView(Context context) { + super(context); + /*to = this; + //Handler handler = new Handler(Looper.getMainLooper()); + refresh = new Runnable() { + @Override + public void run() { + /*for(int i=0;i<=100;i++) { + percent = (float)((float)i/(float)100); + //invalidate(); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + long timeActu; + while(true){ + + timeActu = new Date().getTime(); + if(timeActu < timeFin) + { + percent = (float)(timeActu-timeDebut)/(timeFin-timeDebut); + } + else + { + percent = (float)1; + } + to.postInvalidate(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }; + refresh.run();*/ + + } + + // Dessinons sur la totalité de l'écran + protected void onDraw(Canvas canvas) { + + onDrawPercent(canvas, percent); + //this.postInvalidateDelayed(1000); + /*if(truc) { + refresh.run(); + truc = false; + }*/ + //AsyncTask ev = new Evolution(canvas); + //ev.execute(canvas); + this.postInvalidateDelayed( 1000 / 60); + + // Nous allons dessiner nos points par rapport à la résolution de l'écran + // int iWidth = canvas.getWidth(); // Largeur + //int iHeight = canvas.getHeight(); // Hauteur + + + // Affecter une couleur + //paint.setColor(getResources().getColor(R.color.colorAccent)); + // Définir l'épaisseur du segment + //paint.setStrokeWidth (2); + // Puis dessiner nos points dans le cavenas + //canvas.drawLine(50, 55, 53, 55, paint); + + } + + public void onDrawPercent(Canvas canvas, float percent){ + //canvas=DessinView.canvas; + /*canvas.restore(); + canvas.save();*/ + Paint myPaint = new Paint(); + + + myPaint.setColor(Color.rgb(0, 0, 255)); + myPaint.setStrokeWidth(5); + //canvas.drawRect(100, 100, 200, 200, myPaint); + canvas.drawLine((float) (canvas.getWidth() * 0.4), (float) (canvas.getHeight() * 0.35), (float) (canvas.getWidth() * 0.4), (float) (canvas.getHeight() * 0.75), myPaint); + canvas.drawLine((float) (canvas.getWidth() * 0.6), (float) (canvas.getHeight() * 0.35), (float) (canvas.getWidth() * 0.6), (float) (canvas.getHeight() * 0.75), myPaint); + + canvas.drawLine((float) (canvas.getWidth() * 0.3), (float) (canvas.getHeight() * 0.75), (float) (canvas.getWidth() * 0.4), (float) (canvas.getHeight() * 0.75), myPaint); + canvas.drawLine((float) (canvas.getWidth() * 0.6), (float) (canvas.getHeight() * 0.75), (float) (canvas.getWidth() * 0.7), (float) (canvas.getHeight() * 0.75), myPaint); + + canvas.drawLine((float) (canvas.getWidth() * 0.3), (float) (canvas.getHeight() * 0.75), (float) (canvas.getWidth() * 0.5), (float) (canvas.getHeight() * 0.85), myPaint); + canvas.drawLine((float) (canvas.getWidth() * 0.7), (float) (canvas.getHeight() * 0.75), (float) (canvas.getWidth() * 0.5), (float) (canvas.getHeight() * 0.85), myPaint); + + + myPaint.setColor(Color.rgb(176, 224, 230)); + canvas.drawRect((float) (canvas.getWidth() * 0.4), (float) (canvas.getHeight() * (0.35+0.35*percent)), (float) (canvas.getWidth() * 0.6), (float) (canvas.getHeight() * 0.70), myPaint); + myPaint.setColor(Color.rgb(0, 0, 255)); + myPaint.setStrokeWidth(10); + canvas.drawLine((float) (canvas.getWidth() * 0.4), (float) (canvas.getHeight() * 0.35), (float) (canvas.getWidth() * 0.6), (float) (canvas.getHeight() * 0.35), myPaint); + canvas.drawLine((float) (canvas.getWidth() * 0.4), (float) (canvas.getHeight() * 0.70), (float) (canvas.getWidth() * 0.6), (float) (canvas.getHeight() * 0.70), myPaint); + /*long timeActu; + + timeActu = new Date().getTime(); + if(timeActu < timeFin) + { + percent = (float)(timeActu-timeDebut)/(timeFin-timeDebut); + } + else + { + percent = (float)1; + }*/ + + } + private class Evolution extends AsyncTask + { + private Canvas canvas; + public Evolution(Canvas c) + { + this.canvas = c; + } + + @Override + protected Void doInBackground(Canvas... canvas) { + for(int i=0;i<=100;i++) + { + //canvas[0].inv + + onDrawPercent(canvas[0],i/100); + /*try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + }*/ + } + return null; + } + } +} + + diff --git a/app/src/main/java/com/example/austime/MainActivity.java b/app/src/main/java/com/example/austime/MainActivity.java index 11cd14f..d0705d8 100644 --- a/app/src/main/java/com/example/austime/MainActivity.java +++ b/app/src/main/java/com/example/austime/MainActivity.java @@ -8,6 +8,6 @@ public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); + setContentView(new DessinView(this)); } } -- GitLab