Commit 86ba2e512b78c9dc44554408335c7689e6a2967e

Authored by JLo'w
1 parent 05269735

XOR du cancer

PremiereActivite/app/src/main/java/com/example/app_10p5/NFCFragment.java
... ... @@ -37,27 +37,27 @@ public class NFCFragment extends Fragment {
37 37 Bundle b = getArguments();
38 38  
39 39 try {
  40 + mParam.put("jeton", URLEncoder.encode(b.getString("token"), "UTF-8"));
40 41 switch (b.getInt("state")) {
41 42 case MainActivite.STATE_COMMANDE:
42   - //TODO: XOR du cancer
43   - //mParam.put("quantite", String.valueOf(getIntent().getIntExtra("quantite", -1)));
44   - mParam.put("montant", URLEncoder.encode(String.valueOf(b.getFloat("montant")), "UTF-8"));
45   - mParam.put("jeton", URLEncoder.encode(b.getString("token"), "UTF-8"));
  43 + if(b.getInt("quantite") != 0){
  44 + mParam.put("quantite", URLEncoder.encode(String.valueOf(b.getInt("quantite")), "UTF-8"));
  45 + }
  46 + else{
  47 + mParam.put("montant", URLEncoder.encode(String.valueOf(b.getFloat("montant")), "UTF-8"));
  48 +
  49 + }
46 50 mAPI = "api/client/payer";
47 51 break;
48 52 case MainActivite.STATE_CREATION_COMPTE:
49 53 mParam.put("solde", URLEncoder.encode(String.valueOf(b.getFloat("montant")), "UTF-8"));
50   - mParam.put("jeton", URLEncoder.encode(b.getString("token"), "UTF-8"));
51 54 mAPI = "api/client/ajouter";
52 55 break;
53 56 case MainActivite.STATE_RECHARGEMENT:
54   - System.out.println("bite");
55 57 mParam.put("montant", URLEncoder.encode(String.valueOf(b.getFloat("montant")), "UTF-8"));
56   - mParam.put("jeton", URLEncoder.encode(b.getString("token"), "UTF-8"));
57 58 mAPI = "api/client/recharger";
58 59 break;
59 60 case MainActivite.STATE_VIDANGE:
60   - mParam.put("jeton", URLEncoder.encode(b.getString("token"), "UTF-8"));
61 61 mAPI = "api/client/vidange";
62 62 break;
63 63 case MainActivite.STATE_CONNEXION: //Impossible c'est pas géré ici
... ... @@ -68,6 +68,7 @@ public class NFCFragment extends Fragment {
68 68 }
69 69 catch (Throwable t){
70 70 System.out.println("Exception: " + t.toString());
  71 + Snackbar.make(getActivity().findViewById(R.id.coordinator), "WTF, le cancer est dans l'application!! " + t.toString(), Snackbar.LENGTH_INDEFINITE).show();
71 72 }
72 73  
73 74 return ret;
... ...