diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index d5ec3da8f44f11e4b0ad38eb912abce9a83b1457..30aa626c23142d59e94cc76327172301f159b618 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 2bcafe497b758978dcf38cc8305a3ba3997f3e4c..0000000000000000000000000000000000000000 --- 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 2996d531255e06fae876df257e8237225a4906b7..7ac24c777f8adde6bd57c01c1bfa1cf0143f3d77 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,11 +3,14 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index 77ef57d6180860f4f964bb8a02f027e7a59edd05..b0c7b20c87d2e5afd25686dcaa9ee52b675d4978 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 0000000000000000000000000000000000000000..439ec62fca16bed25e23a19f3ac9e3da662bfcab --- /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 11cd14f7de472575d748eff4a41eeeb8d5982146..d0705d8b99ecb3de100c1218ed41f43d3d12e724 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)); } }