Commit c1841aa98d61a008f23cda6e5e1e6314a0016204
1 parent
517f580e
Can create Personne
Showing
2 changed files
with
27 additions
and
3 deletions
Show diff stats
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/CreatePersonne.java
... | ... | @@ -18,6 +18,7 @@ import android.widget.ProgressBar; |
18 | 18 | import android.widget.Spinner; |
19 | 19 | import android.widget.Toast; |
20 | 20 | |
21 | +import com.android.volley.AuthFailureError; | |
21 | 22 | import com.android.volley.Request; |
22 | 23 | import com.android.volley.Response; |
23 | 24 | import com.android.volley.VolleyError; |
... | ... | @@ -26,6 +27,7 @@ import com.android.volley.toolbox.JsonObjectRequest; |
26 | 27 | import com.google.gson.Gson; |
27 | 28 | |
28 | 29 | import net.plil.clubinfo.etunicorn.R; |
30 | +import net.plil.clubinfo.etunicorn.app.MainActivity; | |
29 | 31 | import net.plil.clubinfo.etunicorn.data.Role; |
30 | 32 | import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; |
31 | 33 | import net.plil.clubinfo.etunicorn.utils.JsonConverter; |
... | ... | @@ -38,8 +40,10 @@ import org.json.JSONObject; |
38 | 40 | import java.text.SimpleDateFormat; |
39 | 41 | import java.util.ArrayList; |
40 | 42 | import java.util.Calendar; |
43 | +import java.util.HashMap; | |
41 | 44 | import java.util.List; |
42 | 45 | import java.util.Locale; |
46 | +import java.util.Map; | |
43 | 47 | |
44 | 48 | |
45 | 49 | public class CreatePersonne extends DialogFragment { |
... | ... | @@ -122,7 +126,7 @@ public class CreatePersonne extends DialogFragment { |
122 | 126 | try { |
123 | 127 | jsonObject.put("login", mLogin.getText().toString()); |
124 | 128 | jsonObject.put("carte", mCarte.getText().toString()); |
125 | - jsonObject.put("role", mRole.getSelectedItem()); | |
129 | + jsonObject.put("role", JsonConverter.convertToJSONObject(mRole.getSelectedItem())); | |
126 | 130 | if (!mNaissance.getSelectedItem().equals(getString(R.string.create_personne_naissance))) |
127 | 131 | jsonObject.put("naissance", mNaissance.getSelectedItem()); |
128 | 132 | } catch (JSONException e) { |
... | ... | @@ -143,9 +147,18 @@ public class CreatePersonne extends DialogFragment { |
143 | 147 | mCarteInput.setVisibility(View.VISIBLE); |
144 | 148 | mNaissance.setVisibility(View.VISIBLE); |
145 | 149 | mRole.setVisibility(View.VISIBLE); |
150 | + if (error.networkResponse != null) | |
151 | + Toast.makeText(getContext(), ConvertBytesToString.bytesToStringVolLey(error.networkResponse.data), Toast.LENGTH_LONG).show(); | |
146 | 152 | } |
147 | 153 | } |
148 | - ); | |
154 | + ) | |
155 | + { | |
156 | + @Override | |
157 | + public Map<String, String> getHeaders() throws AuthFailureError { | |
158 | + Map<String, String> headers = new HashMap<String, String>(); | |
159 | + headers.put("Authorization", MainActivity.session.getToken()); | |
160 | + return headers; | |
161 | + }}; | |
149 | 162 | jsonObjectRequest.setTag(CreatePersonne.class); |
150 | 163 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); |
151 | 164 | } | ... | ... |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/DeletePersonne.java
... | ... | @@ -11,18 +11,23 @@ import android.widget.Button; |
11 | 11 | import android.widget.ProgressBar; |
12 | 12 | import android.widget.Toast; |
13 | 13 | |
14 | +import com.android.volley.AuthFailureError; | |
14 | 15 | import com.android.volley.Request; |
15 | 16 | import com.android.volley.Response; |
16 | 17 | import com.android.volley.VolleyError; |
17 | 18 | import com.android.volley.toolbox.JsonObjectRequest; |
18 | 19 | |
19 | 20 | import net.plil.clubinfo.etunicorn.R; |
21 | +import net.plil.clubinfo.etunicorn.app.MainActivity; | |
20 | 22 | import net.plil.clubinfo.etunicorn.data.Event; |
21 | 23 | import net.plil.clubinfo.etunicorn.data.Personne; |
22 | 24 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; |
23 | 25 | |
24 | 26 | import org.json.JSONObject; |
25 | 27 | |
28 | +import java.util.HashMap; | |
29 | +import java.util.Map; | |
30 | + | |
26 | 31 | |
27 | 32 | public class DeletePersonne extends DialogFragment { |
28 | 33 | |
... | ... | @@ -89,7 +94,13 @@ public class DeletePersonne extends DialogFragment { |
89 | 94 | Toast.makeText(getContext(), R.string.delete_refused, Toast.LENGTH_LONG).show(); |
90 | 95 | } |
91 | 96 | } |
92 | - ); | |
97 | + ){ | |
98 | + @Override | |
99 | + public Map<String, String> getHeaders() throws AuthFailureError { | |
100 | + Map<String, String> headers = new HashMap<String, String>(); | |
101 | + headers.put("Authorization", MainActivity.session.getToken()); | |
102 | + return headers; | |
103 | + }}; | |
93 | 104 | jsonObjectRequest.setTag(DeletePersonne.class); |
94 | 105 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); |
95 | 106 | } | ... | ... |