Commit 6645bb2255dd0b625c0a8c3faab40fd7bf195058
1 parent
f5506a08
Fix some stupid bug with Volley
Showing
5 changed files
with
47 additions
and
10 deletions
Show diff stats
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/EventFragment.java
@@ -99,7 +99,7 @@ public class EventFragment extends FragmentNFC { | @@ -99,7 +99,7 @@ public class EventFragment extends FragmentNFC { | ||
99 | Toast.makeText(getContext(), R.string.payment_consumable_alert_no_selection, Toast.LENGTH_LONG).show(); | 99 | Toast.makeText(getContext(), R.string.payment_consumable_alert_no_selection, Toast.LENGTH_LONG).show(); |
100 | } | 100 | } |
101 | else { | 101 | else { |
102 | - paiementEvent.processNFC(); | 102 | + paiementEvent.processNFC(idCardUser); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/PaiementEvent.java
@@ -66,7 +66,6 @@ public class PaiementEvent extends DialogFragment { | @@ -66,7 +66,6 @@ public class PaiementEvent extends DialogFragment { | ||
66 | .setView(view) | 66 | .setView(view) |
67 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | 67 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { |
68 | public void onClick(DialogInterface dialog, int id) { | 68 | public void onClick(DialogInterface dialog, int id) { |
69 | - VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll("PAYMENT"); | ||
70 | } | 69 | } |
71 | }); | 70 | }); |
72 | // Create the AlertDialog object and return it | 71 | // Create the AlertDialog object and return it |
@@ -76,12 +75,11 @@ public class PaiementEvent extends DialogFragment { | @@ -76,12 +75,11 @@ public class PaiementEvent extends DialogFragment { | ||
76 | } | 75 | } |
77 | 76 | ||
78 | 77 | ||
79 | - public void processNFC() { | 78 | + public void processNFC(String idCardUser) { |
80 | mProgressBar.setVisibility(View.VISIBLE); | 79 | mProgressBar.setVisibility(View.VISIBLE); |
81 | JSONObject jsonObject = new JSONObject(); | 80 | JSONObject jsonObject = new JSONObject(); |
82 | try { | 81 | try { |
83 | - jsonObject.put("participant", 1); | ||
84 | - jsonObject.put("acteur", 2); | 82 | + jsonObject.put("participant", idCardUser); |
85 | jsonObject.put("id", eventId); | 83 | jsonObject.put("id", eventId); |
86 | } catch (JSONException e) { | 84 | } catch (JSONException e) { |
87 | e.printStackTrace(); | 85 | e.printStackTrace(); |
@@ -103,7 +101,27 @@ public class PaiementEvent extends DialogFragment { | @@ -103,7 +101,27 @@ public class PaiementEvent extends DialogFragment { | ||
103 | } | 101 | } |
104 | ); | 102 | ); |
105 | 103 | ||
106 | - jsonObjectRequest.setTag("PAYMENT"); | 104 | + jsonObjectRequest.setTag(PaiementEvent.class); |
107 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | 105 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); |
108 | } | 106 | } |
107 | + | ||
108 | + | ||
109 | + @Override | ||
110 | + public void onCancel(DialogInterface dialog) { | ||
111 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementEvent.class); | ||
112 | + super.onCancel(dialog); | ||
113 | + } | ||
114 | + | ||
115 | + @Override | ||
116 | + public void onStop() { | ||
117 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementEvent.class); | ||
118 | + super.onStop(); | ||
119 | + } | ||
120 | + | ||
121 | + @Override | ||
122 | + public void onPause() { | ||
123 | + super.onPause(); | ||
124 | + dismiss(); | ||
125 | + } | ||
126 | + | ||
109 | } | 127 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java
@@ -32,6 +32,7 @@ import net.plil.clubinfo.etunicorn.data.Consommation; | @@ -32,6 +32,7 @@ import net.plil.clubinfo.etunicorn.data.Consommation; | ||
32 | import net.plil.clubinfo.etunicorn.data.Event; | 32 | import net.plil.clubinfo.etunicorn.data.Event; |
33 | import net.plil.clubinfo.etunicorn.data.Personne; | 33 | import net.plil.clubinfo.etunicorn.data.Personne; |
34 | import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; | 34 | import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; |
35 | +import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | ||
35 | 36 | ||
36 | import java.util.ArrayList; | 37 | import java.util.ArrayList; |
37 | import java.util.List; | 38 | import java.util.List; |
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/PaiementConsommation.java
@@ -17,6 +17,7 @@ import com.android.volley.VolleyError; | @@ -17,6 +17,7 @@ import com.android.volley.VolleyError; | ||
17 | import com.android.volley.toolbox.JsonObjectRequest; | 17 | import com.android.volley.toolbox.JsonObjectRequest; |
18 | 18 | ||
19 | import net.plil.clubinfo.etunicorn.R; | 19 | import net.plil.clubinfo.etunicorn.R; |
20 | +import net.plil.clubinfo.etunicorn.app.event.PaiementEvent; | ||
20 | import net.plil.clubinfo.etunicorn.data.Consommation; | 21 | import net.plil.clubinfo.etunicorn.data.Consommation; |
21 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | 22 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; |
22 | 23 | ||
@@ -71,7 +72,6 @@ public class PaiementConsommation extends DialogFragment { | @@ -71,7 +72,6 @@ public class PaiementConsommation extends DialogFragment { | ||
71 | .setView(view) | 72 | .setView(view) |
72 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | 73 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { |
73 | public void onClick(DialogInterface dialog, int id) { | 74 | public void onClick(DialogInterface dialog, int id) { |
74 | - VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll("PAYMENT"); | ||
75 | } | 75 | } |
76 | }); | 76 | }); |
77 | // Create the AlertDialog object and return it | 77 | // Create the AlertDialog object and return it |
@@ -108,7 +108,25 @@ public class PaiementConsommation extends DialogFragment { | @@ -108,7 +108,25 @@ public class PaiementConsommation extends DialogFragment { | ||
108 | } | 108 | } |
109 | } | 109 | } |
110 | ); | 110 | ); |
111 | - jsonObjectRequest.setTag("PAYMENT"); | 111 | + jsonObjectRequest.setTag(PaiementConsommation.class); |
112 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | 112 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); |
113 | } | 113 | } |
114 | + | ||
115 | + @Override | ||
116 | + public void onCancel(DialogInterface dialog) { | ||
117 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementConsommation.class); | ||
118 | + super.onCancel(dialog); | ||
119 | + } | ||
120 | + | ||
121 | + @Override | ||
122 | + public void onStop() { | ||
123 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementConsommation.class); | ||
124 | + super.onStop(); | ||
125 | + } | ||
126 | + | ||
127 | + @Override | ||
128 | + public void onPause() { | ||
129 | + super.onPause(); | ||
130 | + dismiss(); | ||
131 | + } | ||
114 | } | 132 | } |
app/src/main/res/values-fr/strings.xml
@@ -16,8 +16,8 @@ | @@ -16,8 +16,8 @@ | ||
16 | <string name="valid">OK</string> | 16 | <string name="valid">OK</string> |
17 | <string name="title_activity_main">Etunicorn - Bonjour</string> | 17 | <string name="title_activity_main">Etunicorn - Bonjour</string> |
18 | <string name="payment_consumable">Paiement d\'un Consommable</string> | 18 | <string name="payment_consumable">Paiement d\'un Consommable</string> |
19 | - <string name="payment_refused">Paiement accepté</string> | ||
20 | - <string name="payment_done">Paiement refusé</string> | 19 | + <string name="payment_refused">Paiement refusé</string> |
20 | + <string name="payment_done">Paiement accepté</string> | ||
21 | <string name="payment_consumable_alert_no_selection">Selectionné un produit avant de payer</string> | 21 | <string name="payment_consumable_alert_no_selection">Selectionné un produit avant de payer</string> |
22 | <string name="action_delete">Supprimer</string> | 22 | <string name="action_delete">Supprimer</string> |
23 | <string name="delete">Supprimer</string> | 23 | <string name="delete">Supprimer</string> |