From 8d573e63b814f74e9d3e641d0ea536f2185b2ede Mon Sep 17 00:00:00 2001 From: JLo'w Date: Mon, 2 May 2016 11:48:08 +0200 Subject: [PATCH] Mise en place de la vidange OK --- PremiereActivite/app/src/main/java/com/example/app_10p5/CarteActivite.java | 2 +- PremiereActivite/app/src/main/java/com/example/app_10p5/MainActivite.java | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/PremiereActivite/app/src/main/java/com/example/app_10p5/CarteActivite.java b/PremiereActivite/app/src/main/java/com/example/app_10p5/CarteActivite.java index a1e81ea..ae1f1f1 100644 --- a/PremiereActivite/app/src/main/java/com/example/app_10p5/CarteActivite.java +++ b/PremiereActivite/app/src/main/java/com/example/app_10p5/CarteActivite.java @@ -51,7 +51,7 @@ public class CarteActivite extends Activity implements ASyncResponse { mAPI = "api/client/recharger"; break; case MainActivite.STATE_VIDANGE: - //pas de paramètre + mParam.put("jeton", getIntent().getStringExtra("token")); mAPI = "api/client/vidange"; break; case MainActivite.STATE_CONNEXION: //Impossible c'est pas géré ici diff --git a/PremiereActivite/app/src/main/java/com/example/app_10p5/MainActivite.java b/PremiereActivite/app/src/main/java/com/example/app_10p5/MainActivite.java index 5b23c9c..d0b2146 100644 --- a/PremiereActivite/app/src/main/java/com/example/app_10p5/MainActivite.java +++ b/PremiereActivite/app/src/main/java/com/example/app_10p5/MainActivite.java @@ -1,10 +1,12 @@ package com.example.app_10p5; import android.content.Intent; +import android.opengl.ETC1; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.FragmentActivity; import android.support.v4.view.ViewPager; +import android.text.InputFilter; import android.view.View; import android.widget.EditText; import android.widget.Toast; @@ -232,6 +234,27 @@ public class MainActivite extends FragmentActivity implements ASyncResponse { } } + public void valideVidange(View v){ + if((mToken != "") && ((System.currentTimeMillis() - mTimeToken) < EXPIRATION)) { + + if((mDroit >= 2)){ + mState = STATE_VIDANGE; + Intent intent = new Intent(this, CarteActivite.class); + intent.putExtra("token", mToken); + intent.putExtra("state", mState); + startActivityForResult(intent, mState); + } + else{ + Toast.makeText(this, "Droit insuffisant.", Toast.LENGTH_LONG).show(); + } + } + else{ + Toast.makeText(this, "Veuillez vous reconnecter.", Toast.LENGTH_LONG).show(); + final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); + viewPager.setCurrentItem(0); + } + } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data){ //TODO: faire des choses avec ca -- libgit2 0.21.2