Commit 3dc52ca94ce78bfcc520d867b5d995fe97144f6b

Authored by badetitou
1 parent b7f2b9a4

Cleaning code 2.0

Showing 24 changed files with 317 additions and 306 deletions   Show diff stats
.idea/inspectionProfiles/Project_Default.xml 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +<component name="InspectionProjectProfileManager">
  2 + <profile version="1.0">
  3 + <option name="myName" value="Project Default" />
  4 + <inspection_tool class="AndroidLintInflateParams" enabled="false" level="WARNING" enabled_by_default="false" />
  5 + <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
  6 + <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
  7 + <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
  8 + </inspection_tool>
  9 + </profile>
  10 +</component>
0 \ No newline at end of file 11 \ No newline at end of file
.idea/inspectionProfiles/profiles_settings.xml 0 → 100644
@@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
  1 +<component name="InspectionProjectProfileManager">
  2 + <settings>
  3 + <option name="PROJECT_PROFILE" value="Project Default" />
  4 + <option name="USE_PROJECT_PROFILE" value="true" />
  5 + <version value="1.0" />
  6 + </settings>
  7 +</component>
0 \ No newline at end of file 8 \ No newline at end of file
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/CreateEvent.java
@@ -4,6 +4,7 @@ import android.app.DatePickerDialog; @@ -4,6 +4,7 @@ import android.app.DatePickerDialog;
4 import android.app.Dialog; 4 import android.app.Dialog;
5 import android.content.DialogInterface; 5 import android.content.DialogInterface;
6 import android.os.Bundle; 6 import android.os.Bundle;
  7 +import android.support.annotation.NonNull;
7 import android.support.design.widget.TextInputLayout; 8 import android.support.design.widget.TextInputLayout;
8 import android.support.v4.app.DialogFragment; 9 import android.support.v4.app.DialogFragment;
9 import android.support.v7.app.AlertDialog; 10 import android.support.v7.app.AlertDialog;
@@ -49,14 +50,23 @@ public class CreateEvent extends DialogFragment { @@ -49,14 +50,23 @@ public class CreateEvent extends DialogFragment {
49 50
50 TextInputLayout mPriceInput; 51 TextInputLayout mPriceInput;
51 TextInputLayout mNameInput; 52 TextInputLayout mNameInput;
52 - 53 + ProgressBar mProgressBar;
53 private String[] arraySpinnerDate; 54 private String[] arraySpinnerDate;
54 private ArrayAdapter<String> adapterDate; 55 private ArrayAdapter<String> adapterDate;
  56 + DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
55 57
56 - ProgressBar mProgressBar;  
57 - 58 + @Override
  59 + public void onDateSet(DatePicker view, int year, int monthOfYear,
  60 + int dayOfMonth) {
  61 + myCalendar.set(Calendar.YEAR, year);
  62 + myCalendar.set(Calendar.MONTH, monthOfYear);
  63 + myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
  64 + updateLabel();
  65 + }
  66 + };
58 67
59 @Override 68 @Override
  69 + @NonNull
60 public Dialog onCreateDialog(Bundle savedInstanceState) { 70 public Dialog onCreateDialog(Bundle savedInstanceState) {
61 // Use the Builder class for convenient dialog construction 71 // Use the Builder class for convenient dialog construction
62 LayoutInflater inflater = getActivity().getLayoutInflater(); 72 LayoutInflater inflater = getActivity().getLayoutInflater();
@@ -66,7 +76,7 @@ public class CreateEvent extends DialogFragment { @@ -66,7 +76,7 @@ public class CreateEvent extends DialogFragment {
66 mDate = (Spinner) view.findViewById(R.id.create_event_date); 76 mDate = (Spinner) view.findViewById(R.id.create_event_date);
67 mPriceInput = (TextInputLayout) view.findViewById(R.id.create_event_price_input); 77 mPriceInput = (TextInputLayout) view.findViewById(R.id.create_event_price_input);
68 mNameInput = (TextInputLayout) view.findViewById(R.id.create_event_name_input); 78 mNameInput = (TextInputLayout) view.findViewById(R.id.create_event_name_input);
69 - arraySpinnerDate = new String[] { 79 + arraySpinnerDate = new String[]{
70 getString(R.string.create_event_date_input) 80 getString(R.string.create_event_date_input)
71 }; 81 };
72 adapterDate = new ArrayAdapter<>(getActivity(), 82 adapterDate = new ArrayAdapter<>(getActivity(),
@@ -87,7 +97,7 @@ public class CreateEvent extends DialogFragment { @@ -87,7 +97,7 @@ public class CreateEvent extends DialogFragment {
87 mDate.setOnTouchListener(new View.OnTouchListener() { 97 mDate.setOnTouchListener(new View.OnTouchListener() {
88 @Override 98 @Override
89 public boolean onTouch(View v, MotionEvent event) { 99 public boolean onTouch(View v, MotionEvent event) {
90 - if(event.getAction() == MotionEvent.ACTION_UP) { 100 + if (event.getAction() == MotionEvent.ACTION_UP) {
91 new DatePickerDialog(getContext(), date, myCalendar 101 new DatePickerDialog(getContext(), date, myCalendar
92 .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), 102 .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
93 myCalendar.get(Calendar.DAY_OF_MONTH)).show(); 103 myCalendar.get(Calendar.DAY_OF_MONTH)).show();
@@ -110,7 +120,7 @@ public class CreateEvent extends DialogFragment { @@ -110,7 +120,7 @@ public class CreateEvent extends DialogFragment {
110 } else { 120 } else {
111 mPriceInput.setError(null); 121 mPriceInput.setError(null);
112 } 122 }
113 - if (mName.getText().toString().isEmpty()){ 123 + if (mName.getText().toString().isEmpty()) {
114 mNameInput.setError(getString(R.string.error_create_event_input_nom)); 124 mNameInput.setError(getString(R.string.error_create_event_input_nom));
115 testDateInputOk = false; 125 testDateInputOk = false;
116 } else { 126 } else {
@@ -130,10 +140,10 @@ public class CreateEvent extends DialogFragment { @@ -130,10 +140,10 @@ public class CreateEvent extends DialogFragment {
130 jsonObject.put("nom", mName.getText().toString()); 140 jsonObject.put("nom", mName.getText().toString());
131 jsonObject.put("prix", Double.parseDouble(mPrice.getText().toString())); 141 jsonObject.put("prix", Double.parseDouble(mPrice.getText().toString()));
132 jsonObject.put("date", mDate.getAdapter().getItem(0)); 142 jsonObject.put("date", mDate.getAdapter().getItem(0));
133 - } catch (JSONException e){ 143 + } catch (JSONException e) {
134 e.printStackTrace(); 144 e.printStackTrace();
135 } 145 }
136 - JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/evenement" ,jsonObject , new Response.Listener<JSONObject>() { 146 + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/evenement", jsonObject, new Response.Listener<JSONObject>() {
137 @Override 147 @Override
138 public void onResponse(JSONObject response) { 148 public void onResponse(JSONObject response) {
139 mProgressBar.setVisibility(View.GONE); 149 mProgressBar.setVisibility(View.GONE);
@@ -149,13 +159,14 @@ public class CreateEvent extends DialogFragment { @@ -149,13 +159,14 @@ public class CreateEvent extends DialogFragment {
149 Toast.makeText(getContext(), error.getMessage(), Toast.LENGTH_LONG).show(); 159 Toast.makeText(getContext(), error.getMessage(), Toast.LENGTH_LONG).show();
150 } 160 }
151 } 161 }
152 - ){ 162 + ) {
153 @Override 163 @Override
154 public Map<String, String> getHeaders() throws AuthFailureError { 164 public Map<String, String> getHeaders() throws AuthFailureError {
155 - Map<String, String> headers = new HashMap<String, String>(); 165 + Map<String, String> headers = new HashMap<>();
156 headers.put("Authorization", MainActivity.session.getToken()); 166 headers.put("Authorization", MainActivity.session.getToken());
157 return headers; 167 return headers;
158 - }}; 168 + }
  169 + };
159 jsonObjectRequest.setTag(CreateEvent.class); 170 jsonObjectRequest.setTag(CreateEvent.class);
160 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 171 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
161 } 172 }
@@ -174,18 +185,6 @@ public class CreateEvent extends DialogFragment { @@ -174,18 +185,6 @@ public class CreateEvent extends DialogFragment {
174 super.onStop(); 185 super.onStop();
175 } 186 }
176 187
177 - DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {  
178 -  
179 - @Override  
180 - public void onDateSet(DatePicker view, int year, int monthOfYear,  
181 - int dayOfMonth) {  
182 - myCalendar.set(Calendar.YEAR, year);  
183 - myCalendar.set(Calendar.MONTH, monthOfYear);  
184 - myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);  
185 - updateLabel();  
186 - }  
187 - };  
188 -  
189 private void updateLabel() { 188 private void updateLabel() {
190 String myFormat = "yyyy-MM-dd"; //In which you need put here 189 String myFormat = "yyyy-MM-dd"; //In which you need put here
191 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE); 190 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE);
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/DeleteEvent.java
@@ -3,6 +3,7 @@ package net.plil.clubinfo.etunicorn.app.event; @@ -3,6 +3,7 @@ package net.plil.clubinfo.etunicorn.app.event;
3 import android.app.Dialog; 3 import android.app.Dialog;
4 import android.content.DialogInterface; 4 import android.content.DialogInterface;
5 import android.os.Bundle; 5 import android.os.Bundle;
  6 +import android.support.annotation.NonNull;
6 import android.support.v4.app.DialogFragment; 7 import android.support.v4.app.DialogFragment;
7 import android.support.v7.app.AlertDialog; 8 import android.support.v7.app.AlertDialog;
8 import android.view.LayoutInflater; 9 import android.view.LayoutInflater;
@@ -19,7 +20,6 @@ import com.android.volley.toolbox.JsonObjectRequest; @@ -19,7 +20,6 @@ import com.android.volley.toolbox.JsonObjectRequest;
19 20
20 import net.plil.clubinfo.etunicorn.R; 21 import net.plil.clubinfo.etunicorn.R;
21 import net.plil.clubinfo.etunicorn.app.MainActivity; 22 import net.plil.clubinfo.etunicorn.app.MainActivity;
22 -import net.plil.clubinfo.etunicorn.data.Consommation;  
23 import net.plil.clubinfo.etunicorn.data.Event; 23 import net.plil.clubinfo.etunicorn.data.Event;
24 import net.plil.clubinfo.etunicorn.utils.VolleyUtils; 24 import net.plil.clubinfo.etunicorn.utils.VolleyUtils;
25 25
@@ -33,7 +33,8 @@ public class DeleteEvent extends DialogFragment { @@ -33,7 +33,8 @@ public class DeleteEvent extends DialogFragment {
33 33
34 ProgressBar mProgressBar; 34 ProgressBar mProgressBar;
35 35
36 - public DeleteEvent(){} 36 + public DeleteEvent() {
  37 + }
37 38
38 /** 39 /**
39 * Create a new instance of MyDialogFragment, providing "num" 40 * Create a new instance of MyDialogFragment, providing "num"
@@ -52,13 +53,16 @@ public class DeleteEvent extends DialogFragment { @@ -52,13 +53,16 @@ public class DeleteEvent extends DialogFragment {
52 53
53 54
54 @Override 55 @Override
  56 + @NonNull
55 public Dialog onCreateDialog(Bundle savedInstanceState) { 57 public Dialog onCreateDialog(Bundle savedInstanceState) {
56 // Use the Builder class for convenient dialog construction 58 // Use the Builder class for convenient dialog construction
57 LayoutInflater inflater = getActivity().getLayoutInflater(); 59 LayoutInflater inflater = getActivity().getLayoutInflater();
58 View view = inflater.inflate(R.layout.fragment_delete_event, null); 60 View view = inflater.inflate(R.layout.fragment_delete_event, null);
59 61
60 mProgressBar = (ProgressBar) view.findViewById(R.id.delete_event_progress_bar); 62 mProgressBar = (ProgressBar) view.findViewById(R.id.delete_event_progress_bar);
  63 +
61 final Event event = (Event) getArguments().getSerializable("evenement"); 64 final Event event = (Event) getArguments().getSerializable("evenement");
  65 + assert event != null;
62 66
63 67
64 AlertDialog dialog = new AlertDialog.Builder(getActivity()) 68 AlertDialog dialog = new AlertDialog.Builder(getActivity())
@@ -94,18 +98,20 @@ public class DeleteEvent extends DialogFragment { @@ -94,18 +98,20 @@ public class DeleteEvent extends DialogFragment {
94 Toast.makeText(getContext(), R.string.delete_refused, Toast.LENGTH_LONG).show(); 98 Toast.makeText(getContext(), R.string.delete_refused, Toast.LENGTH_LONG).show();
95 } 99 }
96 } 100 }
97 - ){ 101 + ) {
98 @Override 102 @Override
99 public Map<String, String> getHeaders() throws AuthFailureError { 103 public Map<String, String> getHeaders() throws AuthFailureError {
100 - Map<String, String> headers = new HashMap<String, String>(); 104 + Map<String, String> headers = new HashMap<>();
101 headers.put("Authorization", MainActivity.session.getToken()); 105 headers.put("Authorization", MainActivity.session.getToken());
102 return headers; 106 return headers;
103 - }}; 107 + }
  108 + };
104 jsonObjectRequest.setTag(DeleteEvent.class); 109 jsonObjectRequest.setTag(DeleteEvent.class);
105 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 110 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
106 } 111 }
107 }); 112 });
108 - }}); 113 + }
  114 + });
109 return dialog; 115 return dialog;
110 } 116 }
111 117
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/EventFragment.java
@@ -54,7 +54,7 @@ public class EventFragment extends Fragment implements NFCSupport { @@ -54,7 +54,7 @@ public class EventFragment extends Fragment implements NFCSupport {
54 recyclerView.setLayoutManager(new LinearLayoutManager(context)); 54 recyclerView.setLayoutManager(new LinearLayoutManager(context));
55 55
56 List<Event> events = new ArrayList<>(); 56 List<Event> events = new ArrayList<>();
57 - for (int i = 0; i< 150; ++i) { 57 + for (int i = 0; i < 150; ++i) {
58 Event ev = new Event(); 58 Event ev = new Event();
59 ev.setNomEvent("Hello " + i); 59 ev.setNomEvent("Hello " + i);
60 ev.setPrice(15.52); 60 ev.setPrice(15.52);
@@ -96,10 +96,9 @@ public class EventFragment extends Fragment implements NFCSupport { @@ -96,10 +96,9 @@ public class EventFragment extends Fragment implements NFCSupport {
96 @Override 96 @Override
97 public void processNFC(String idCardUser) { 97 public void processNFC(String idCardUser) {
98 PaiementEvent paiementEvent = (PaiementEvent) getFragmentManager().findFragmentByTag("paiementEvent"); 98 PaiementEvent paiementEvent = (PaiementEvent) getFragmentManager().findFragmentByTag("paiementEvent");
99 - if (paiementEvent == null){ 99 + if (paiementEvent == null) {
100 Toast.makeText(getContext(), R.string.payment_consumable_alert_no_selection, Toast.LENGTH_LONG).show(); 100 Toast.makeText(getContext(), R.string.payment_consumable_alert_no_selection, Toast.LENGTH_LONG).show();
101 - }  
102 - else { 101 + } else {
103 paiementEvent.processNFC(idCardUser); 102 paiementEvent.processNFC(idCardUser);
104 } 103 }
105 } 104 }
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/ModifyEvent.java
@@ -4,6 +4,7 @@ import android.app.DatePickerDialog; @@ -4,6 +4,7 @@ import android.app.DatePickerDialog;
4 import android.app.Dialog; 4 import android.app.Dialog;
5 import android.content.DialogInterface; 5 import android.content.DialogInterface;
6 import android.os.Bundle; 6 import android.os.Bundle;
  7 +import android.support.annotation.NonNull;
7 import android.support.design.widget.TextInputLayout; 8 import android.support.design.widget.TextInputLayout;
8 import android.support.v4.app.DialogFragment; 9 import android.support.v4.app.DialogFragment;
9 import android.support.v7.app.AlertDialog; 10 import android.support.v7.app.AlertDialog;
@@ -42,16 +43,25 @@ import java.util.Map; @@ -42,16 +43,25 @@ import java.util.Map;
42 public class ModifyEvent extends DialogFragment { 43 public class ModifyEvent extends DialogFragment {
43 44
44 Calendar myCalendar = Calendar.getInstance(); 45 Calendar myCalendar = Calendar.getInstance();
45 - private String[] arraySpinnerDate;  
46 - private ArrayAdapter<String> adapterDate;  
47 -  
48 EditText mNom; 46 EditText mNom;
49 EditText mPrice; 47 EditText mPrice;
50 Spinner mDate; 48 Spinner mDate;
51 ProgressBar mProgressBar; 49 ProgressBar mProgressBar;
52 -  
53 TextInputLayout mNomInput; 50 TextInputLayout mNomInput;
54 TextInputLayout mPriceInput; 51 TextInputLayout mPriceInput;
  52 + private String[] arraySpinnerDate;
  53 + private ArrayAdapter<String> adapterDate;
  54 + DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
  55 +
  56 + @Override
  57 + public void onDateSet(DatePicker view, int year, int monthOfYear,
  58 + int dayOfMonth) {
  59 + myCalendar.set(Calendar.YEAR, year);
  60 + myCalendar.set(Calendar.MONTH, monthOfYear);
  61 + myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
  62 + updateLabel();
  63 + }
  64 + };
55 65
56 public static ModifyEvent newInstance(Event event) { 66 public static ModifyEvent newInstance(Event event) {
57 ModifyEvent f = new ModifyEvent(); 67 ModifyEvent f = new ModifyEvent();
@@ -64,8 +74,8 @@ public class ModifyEvent extends DialogFragment { @@ -64,8 +74,8 @@ public class ModifyEvent extends DialogFragment {
64 return f; 74 return f;
65 } 75 }
66 76
67 -  
68 @Override 77 @Override
  78 + @NonNull
69 public Dialog onCreateDialog(Bundle savedInstanceState) { 79 public Dialog onCreateDialog(Bundle savedInstanceState) {
70 // Use the Builder class for convenient dialog construction 80 // Use the Builder class for convenient dialog construction
71 LayoutInflater inflater = getActivity().getLayoutInflater(); 81 LayoutInflater inflater = getActivity().getLayoutInflater();
@@ -79,10 +89,11 @@ public class ModifyEvent extends DialogFragment { @@ -79,10 +89,11 @@ public class ModifyEvent extends DialogFragment {
79 89
80 90
81 final Event event = (Event) getArguments().getSerializable("event"); 91 final Event event = (Event) getArguments().getSerializable("event");
  92 + assert event != null;
82 93
83 String myFormat = "yyyy-MM-dd"; //In which you need put here 94 String myFormat = "yyyy-MM-dd"; //In which you need put here
84 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE); 95 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE);
85 - arraySpinnerDate = new String[] { 96 + arraySpinnerDate = new String[]{
86 sdf.format(event.getDate().getTime()) 97 sdf.format(event.getDate().getTime())
87 }; 98 };
88 adapterDate = new ArrayAdapter<>(getActivity(), 99 adapterDate = new ArrayAdapter<>(getActivity(),
@@ -90,7 +101,7 @@ public class ModifyEvent extends DialogFragment { @@ -90,7 +101,7 @@ public class ModifyEvent extends DialogFragment {
90 mDate.setAdapter(adapterDate); 101 mDate.setAdapter(adapterDate);
91 102
92 mNom.setText(event.getNomEvent()); 103 mNom.setText(event.getNomEvent());
93 - mPrice.setText(String.format(Locale.US, "%.2f", event.getPrice())); 104 + mPrice.setText(String.format(Locale.US, "%.2f", event.getPrice()));
94 105
95 AlertDialog dialog = new AlertDialog.Builder(getActivity()) 106 AlertDialog dialog = new AlertDialog.Builder(getActivity())
96 .setTitle(R.string.modify) 107 .setTitle(R.string.modify)
@@ -105,7 +116,7 @@ public class ModifyEvent extends DialogFragment { @@ -105,7 +116,7 @@ public class ModifyEvent extends DialogFragment {
105 mDate.setOnTouchListener(new View.OnTouchListener() { 116 mDate.setOnTouchListener(new View.OnTouchListener() {
106 @Override 117 @Override
107 public boolean onTouch(View v, MotionEvent event) { 118 public boolean onTouch(View v, MotionEvent event) {
108 - if(event.getAction() == MotionEvent.ACTION_UP) { 119 + if (event.getAction() == MotionEvent.ACTION_UP) {
109 new DatePickerDialog(getContext(), date, myCalendar 120 new DatePickerDialog(getContext(), date, myCalendar
110 .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), 121 .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
111 myCalendar.get(Calendar.DAY_OF_MONTH)).show(); 122 myCalendar.get(Calendar.DAY_OF_MONTH)).show();
@@ -131,10 +142,10 @@ public class ModifyEvent extends DialogFragment { @@ -131,10 +142,10 @@ public class ModifyEvent extends DialogFragment {
131 if (!mPrice.getText().toString().isEmpty()) 142 if (!mPrice.getText().toString().isEmpty())
132 jsonObject.put("prix", Double.parseDouble(mPrice.getText().toString())); 143 jsonObject.put("prix", Double.parseDouble(mPrice.getText().toString()));
133 jsonObject.put("date", mDate.getSelectedItem()); 144 jsonObject.put("date", mDate.getSelectedItem());
134 - } catch (JSONException e){ 145 + } catch (JSONException e) {
135 e.printStackTrace(); 146 e.printStackTrace();
136 } 147 }
137 - JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/evenement/" + event.getIdEvent() ,jsonObject , new Response.Listener<JSONObject>() { 148 + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/evenement/" + event.getIdEvent(), jsonObject, new Response.Listener<JSONObject>() {
138 @Override 149 @Override
139 public void onResponse(JSONObject response) { 150 public void onResponse(JSONObject response) {
140 mProgressBar.setVisibility(View.GONE); 151 mProgressBar.setVisibility(View.GONE);
@@ -153,13 +164,14 @@ public class ModifyEvent extends DialogFragment { @@ -153,13 +164,14 @@ public class ModifyEvent extends DialogFragment {
153 164
154 } 165 }
155 } 166 }
156 - ){ 167 + ) {
157 @Override 168 @Override
158 public Map<String, String> getHeaders() throws AuthFailureError { 169 public Map<String, String> getHeaders() throws AuthFailureError {
159 - Map<String, String> headers = new HashMap<String, String>(); 170 + Map<String, String> headers = new HashMap<>();
160 headers.put("Authorization", MainActivity.session.getToken()); 171 headers.put("Authorization", MainActivity.session.getToken());
161 return headers; 172 return headers;
162 - }}; 173 + }
  174 + };
163 jsonObjectRequest.setTag(ModifyEvent.class); 175 jsonObjectRequest.setTag(ModifyEvent.class);
164 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 176 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
165 } 177 }
@@ -177,18 +189,6 @@ public class ModifyEvent extends DialogFragment { @@ -177,18 +189,6 @@ public class ModifyEvent extends DialogFragment {
177 super.onStop(); 189 super.onStop();
178 } 190 }
179 191
180 - DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {  
181 -  
182 - @Override  
183 - public void onDateSet(DatePicker view, int year, int monthOfYear,  
184 - int dayOfMonth) {  
185 - myCalendar.set(Calendar.YEAR, year);  
186 - myCalendar.set(Calendar.MONTH, monthOfYear);  
187 - myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);  
188 - updateLabel();  
189 - }  
190 - };  
191 -  
192 private void updateLabel() { 192 private void updateLabel() {
193 String myFormat = "yyyy-MM-dd"; //In which you need put here 193 String myFormat = "yyyy-MM-dd"; //In which you need put here
194 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE); 194 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE);
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/MyEventRecyclerViewAdapter.java
@@ -17,13 +17,13 @@ import java.util.List; @@ -17,13 +17,13 @@ import java.util.List;
17 import java.util.Locale; 17 import java.util.Locale;
18 18
19 19
20 -public class MyEventRecyclerViewAdapter extends RecyclerView.Adapter<MyEventRecyclerViewAdapter.ViewHolder> { 20 +class MyEventRecyclerViewAdapter extends RecyclerView.Adapter<MyEventRecyclerViewAdapter.ViewHolder> {
21 21
22 private final List<Event> mEvents; 22 private final List<Event> mEvents;
23 private final EventFragment.OnListFragmentInteractionListener mListener; 23 private final EventFragment.OnListFragmentInteractionListener mListener;
24 private final Context context; 24 private final Context context;
25 25
26 - public MyEventRecyclerViewAdapter(List<Event> items, EventFragment.OnListFragmentInteractionListener listener, Context context) { 26 + MyEventRecyclerViewAdapter(List<Event> items, EventFragment.OnListFragmentInteractionListener listener, Context context) {
27 mEvents = items; 27 mEvents = items;
28 mListener = listener; 28 mListener = listener;
29 this.context = context; 29 this.context = context;
@@ -89,13 +89,13 @@ public class MyEventRecyclerViewAdapter extends RecyclerView.Adapter&lt;MyEventRecy @@ -89,13 +89,13 @@ public class MyEventRecyclerViewAdapter extends RecyclerView.Adapter&lt;MyEventRecy
89 89
90 class ViewHolder extends RecyclerView.ViewHolder { 90 class ViewHolder extends RecyclerView.ViewHolder {
91 final View mView; 91 final View mView;
92 - int mId;  
93 final TextView mContentView; 92 final TextView mContentView;
94 final TextView mPriceView; 93 final TextView mPriceView;
95 final TextView mButtonView; 94 final TextView mButtonView;
  95 + int mId;
96 Event mItem; 96 Event mItem;
97 97
98 - public ViewHolder(View view) { 98 + ViewHolder(View view) {
99 super(view); 99 super(view);
100 mView = view; 100 mView = view;
101 mContentView = (TextView) view.findViewById(R.id.event_name); 101 mContentView = (TextView) view.findViewById(R.id.event_name);
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/PaiementEvent.java
@@ -3,6 +3,7 @@ package net.plil.clubinfo.etunicorn.app.event; @@ -3,6 +3,7 @@ package net.plil.clubinfo.etunicorn.app.event;
3 import android.app.Dialog; 3 import android.app.Dialog;
4 import android.content.DialogInterface; 4 import android.content.DialogInterface;
5 import android.os.Bundle; 5 import android.os.Bundle;
  6 +import android.support.annotation.NonNull;
6 import android.support.v4.app.DialogFragment; 7 import android.support.v4.app.DialogFragment;
7 import android.support.v7.app.AlertDialog; 8 import android.support.v7.app.AlertDialog;
8 import android.view.LayoutInflater; 9 import android.view.LayoutInflater;
@@ -38,7 +39,8 @@ public class PaiementEvent extends DialogFragment implements NFCSupport { @@ -38,7 +39,8 @@ public class PaiementEvent extends DialogFragment implements NFCSupport {
38 TextView mPaiementEventPrice; 39 TextView mPaiementEventPrice;
39 int eventId; 40 int eventId;
40 41
41 - public PaiementEvent(){} 42 + public PaiementEvent() {
  43 + }
42 44
43 public static PaiementEvent newInstance(Event event) { 45 public static PaiementEvent newInstance(Event event) {
44 PaiementEvent f = new PaiementEvent(); 46 PaiementEvent f = new PaiementEvent();
@@ -50,6 +52,7 @@ public class PaiementEvent extends DialogFragment implements NFCSupport { @@ -50,6 +52,7 @@ public class PaiementEvent extends DialogFragment implements NFCSupport {
50 52
51 53
52 @Override 54 @Override
  55 + @NonNull
53 public Dialog onCreateDialog(Bundle savedInstanceState) { 56 public Dialog onCreateDialog(Bundle savedInstanceState) {
54 // Use the Builder class for convenient dialog construction 57 // Use the Builder class for convenient dialog construction
55 LayoutInflater inflater = getActivity().getLayoutInflater(); 58 LayoutInflater inflater = getActivity().getLayoutInflater();
@@ -60,6 +63,8 @@ public class PaiementEvent extends DialogFragment implements NFCSupport { @@ -60,6 +63,8 @@ public class PaiementEvent extends DialogFragment implements NFCSupport {
60 63
61 64
62 Event event = (Event) getArguments().getSerializable("event"); 65 Event event = (Event) getArguments().getSerializable("event");
  66 + assert event != null;
  67 +
63 mPaiementEventName.setText(event.getNomEvent()); 68 mPaiementEventName.setText(event.getNomEvent());
64 mPaiementEventPrice.setText(String.format(Locale.US, "%.2f €", event.getPrice())); 69 mPaiementEventPrice.setText(String.format(Locale.US, "%.2f €", event.getPrice()));
65 70
@@ -74,7 +79,7 @@ public class PaiementEvent extends DialogFragment implements NFCSupport { @@ -74,7 +79,7 @@ public class PaiementEvent extends DialogFragment implements NFCSupport {
74 VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementEvent.class); 79 VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementEvent.class);
75 } 80 }
76 }); 81 });
77 - Dialog dialog = builder.create(); 82 + Dialog dialog = builder.create();
78 dialog.setCanceledOnTouchOutside(false); 83 dialog.setCanceledOnTouchOutside(false);
79 return dialog; 84 return dialog;
80 } 85 }
@@ -103,20 +108,20 @@ public class PaiementEvent extends DialogFragment implements NFCSupport { @@ -103,20 +108,20 @@ public class PaiementEvent extends DialogFragment implements NFCSupport {
103 Toast.makeText(getContext(), R.string.payment_refused, Toast.LENGTH_LONG).show(); 108 Toast.makeText(getContext(), R.string.payment_refused, Toast.LENGTH_LONG).show();
104 } 109 }
105 } 110 }
106 - ){ 111 + ) {
107 @Override 112 @Override
108 public Map<String, String> getHeaders() throws AuthFailureError { 113 public Map<String, String> getHeaders() throws AuthFailureError {
109 - Map<String, String> headers = new HashMap<String, String>(); 114 + Map<String, String> headers = new HashMap<>();
110 headers.put("Authorization", MainActivity.session.getToken()); 115 headers.put("Authorization", MainActivity.session.getToken());
111 return headers; 116 return headers;
112 - }}; 117 + }
  118 + };
113 119
114 jsonObjectRequest.setTag(PaiementEvent.class); 120 jsonObjectRequest.setTag(PaiementEvent.class);
115 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 121 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
116 } 122 }
117 123
118 124
119 -  
120 @Override 125 @Override
121 public void onStop() { 126 public void onStop() {
122 VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementEvent.class); 127 VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementEvent.class);
app/src/main/java/net/plil/clubinfo/etunicorn/app/LoginActivity.java
@@ -4,10 +4,9 @@ import android.animation.Animator; @@ -4,10 +4,9 @@ import android.animation.Animator;
4 import android.animation.AnimatorListenerAdapter; 4 import android.animation.AnimatorListenerAdapter;
5 import android.annotation.TargetApi; 5 import android.annotation.TargetApi;
6 import android.content.Intent; 6 import android.content.Intent;
7 -import android.support.v7.app.AppCompatActivity;  
8 -  
9 import android.os.Build; 7 import android.os.Build;
10 import android.os.Bundle; 8 import android.os.Bundle;
  9 +import android.support.v7.app.AppCompatActivity;
11 import android.view.KeyEvent; 10 import android.view.KeyEvent;
12 import android.view.View; 11 import android.view.View;
13 import android.view.View.OnClickListener; 12 import android.view.View.OnClickListener;
@@ -37,16 +36,6 @@ import org.json.JSONObject; @@ -37,16 +36,6 @@ import org.json.JSONObject;
37 */ 36 */
38 public class LoginActivity extends AppCompatActivity { 37 public class LoginActivity extends AppCompatActivity {
39 38
40 - /**  
41 - * Id to identity READ_CONTACTS permission request.  
42 - */  
43 - private static final int REQUEST_READ_CONTACTS = 0;  
44 -  
45 - /**  
46 - * Keep track of the login task to ensure we can cancel it if requested.  
47 - */  
48 -  
49 - // UI references.  
50 private EditText mUsernameView; 39 private EditText mUsernameView;
51 private EditText mPasswordView; 40 private EditText mPasswordView;
52 private View mProgressView; 41 private View mProgressView;
@@ -146,14 +135,14 @@ public class LoginActivity extends AppCompatActivity { @@ -146,14 +135,14 @@ public class LoginActivity extends AppCompatActivity {
146 * @param username The username of the person 135 * @param username The username of the person
147 * @param password The password of the person 136 * @param password The password of the person
148 */ 137 */
149 - private void tryLogin (String username, String password){ 138 + private void tryLogin(String username, String password) {
150 User user = new User(); 139 User user = new User();
151 user.setPassword(password); 140 user.setPassword(password);
152 user.setLogin(username); 141 user.setLogin(username);
153 JsonObjectRequest jsonObjectRequest = null; 142 JsonObjectRequest jsonObjectRequest = null;
154 try { 143 try {
155 144
156 - jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/login" , new JSONObject(JsonConverter.getConverter().toJson(user)), new Response.Listener<JSONObject>() { 145 + jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/login", new JSONObject(JsonConverter.getConverter().toJson(user)), new Response.Listener<JSONObject>() {
157 @Override 146 @Override
158 public void onResponse(JSONObject response) { 147 public void onResponse(JSONObject response) {
159 showProgress(false); 148 showProgress(false);
app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java
@@ -2,11 +2,9 @@ package net.plil.clubinfo.etunicorn.app; @@ -2,11 +2,9 @@ package net.plil.clubinfo.etunicorn.app;
2 2
3 import android.app.PendingIntent; 3 import android.app.PendingIntent;
4 import android.content.Intent; 4 import android.content.Intent;
5 -import android.net.Uri;  
6 import android.nfc.NfcAdapter; 5 import android.nfc.NfcAdapter;
7 import android.nfc.Tag; 6 import android.nfc.Tag;
8 import android.os.Bundle; 7 import android.os.Bundle;
9 -import android.support.design.widget.AppBarLayout;  
10 import android.support.design.widget.TabLayout; 8 import android.support.design.widget.TabLayout;
11 import android.support.v4.app.Fragment; 9 import android.support.v4.app.Fragment;
12 import android.support.v4.app.FragmentManager; 10 import android.support.v4.app.FragmentManager;
@@ -18,12 +16,12 @@ import android.view.Menu; @@ -18,12 +16,12 @@ import android.view.Menu;
18 import android.view.MenuItem; 16 import android.view.MenuItem;
19 17
20 import net.plil.clubinfo.etunicorn.R; 18 import net.plil.clubinfo.etunicorn.R;
  19 +import net.plil.clubinfo.etunicorn.app.consommation.FragmentConsommation;
  20 +import net.plil.clubinfo.etunicorn.app.consommation.PaiementConsommation;
21 import net.plil.clubinfo.etunicorn.app.credit.Crediter; 21 import net.plil.clubinfo.etunicorn.app.credit.Crediter;
22 import net.plil.clubinfo.etunicorn.app.debit.Debiter; 22 import net.plil.clubinfo.etunicorn.app.debit.Debiter;
23 import net.plil.clubinfo.etunicorn.app.event.EventFragment; 23 import net.plil.clubinfo.etunicorn.app.event.EventFragment;
24 import net.plil.clubinfo.etunicorn.app.event.PaiementEvent; 24 import net.plil.clubinfo.etunicorn.app.event.PaiementEvent;
25 -import net.plil.clubinfo.etunicorn.app.consommation.FragmentConsommation;  
26 -import net.plil.clubinfo.etunicorn.app.consommation.PaiementConsommation;  
27 import net.plil.clubinfo.etunicorn.app.personne.PersonOverviewFragment; 25 import net.plil.clubinfo.etunicorn.app.personne.PersonOverviewFragment;
28 import net.plil.clubinfo.etunicorn.app.personne.PersonneFragment; 26 import net.plil.clubinfo.etunicorn.app.personne.PersonneFragment;
29 import net.plil.clubinfo.etunicorn.data.Consommation; 27 import net.plil.clubinfo.etunicorn.data.Consommation;
@@ -36,9 +34,11 @@ import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; @@ -36,9 +34,11 @@ import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString;
36 public class MainActivity extends AppCompatActivity 34 public class MainActivity extends AppCompatActivity
37 implements FragmentConsommation.OnListFragmentInteractionListener, 35 implements FragmentConsommation.OnListFragmentInteractionListener,
38 EventFragment.OnListFragmentInteractionListener, 36 EventFragment.OnListFragmentInteractionListener,
39 - PersonneFragment.OnListFragmentInteractionListener  
40 -{ 37 + PersonneFragment.OnListFragmentInteractionListener {
41 38
  39 + public static Session session;
  40 + NfcAdapter mAdapter;
  41 + PendingIntent mPendingIntent;
42 /** 42 /**
43 * The {@link android.support.v4.view.PagerAdapter} that will provide 43 * The {@link android.support.v4.view.PagerAdapter} that will provide
44 * fragments for each of the sections. We use a 44 * fragments for each of the sections. We use a
@@ -47,21 +47,11 @@ public class MainActivity extends AppCompatActivity @@ -47,21 +47,11 @@ public class MainActivity extends AppCompatActivity
47 * may be best to switch to a 47 * may be best to switch to a
48 * {@link android.support.v4.app.FragmentStatePagerAdapter}. 48 * {@link android.support.v4.app.FragmentStatePagerAdapter}.
49 */ 49 */
50 - private SectionsPagerAdapter mSectionsPagerAdapter;  
51 -  
52 private int nbPages = 0; 50 private int nbPages = 0;
53 -  
54 /** 51 /**
55 * The {@link ViewPager} that will host the section contents. 52 * The {@link ViewPager} that will host the section contents.
56 */ 53 */
57 private ViewPager mViewPager; 54 private ViewPager mViewPager;
58 - private Toolbar toolbar;  
59 - private AppBarLayout appBarLayout;  
60 -  
61 - public static Session session;  
62 -  
63 - NfcAdapter mAdapter;  
64 - PendingIntent mPendingIntent;  
65 55
66 @Override 56 @Override
67 protected void onCreate(Bundle savedInstanceState) { 57 protected void onCreate(Bundle savedInstanceState) {
@@ -69,35 +59,37 @@ public class MainActivity extends AppCompatActivity @@ -69,35 +59,37 @@ public class MainActivity extends AppCompatActivity
69 59
70 Intent intent = this.getIntent(); 60 Intent intent = this.getIntent();
71 session = (Session) intent.getSerializableExtra("session"); 61 session = (Session) intent.getSerializableExtra("session");
72 - if (session.getPersonne().getRole().getNom().equals("admin")){  
73 - nbPages = 5;  
74 - Action.CONSOMATION.setValue(2);  
75 - Action.EVENT.setValue(3);  
76 - Action.PERSONNE.setValue(4);  
77 - } else if (session.getPersonne().getRole().getNom().equals("bde")){  
78 - nbPages = 4;  
79 - Action.CONSOMATION.setValue(-1);  
80 - Action.EVENT.setValue(2);  
81 - Action.PERSONNE.setValue(3);  
82 - } else if (session.getPersonne().getRole().getNom().equals("bar")){  
83 - nbPages = 3;  
84 - Action.CONSOMATION.setValue(2);  
85 - Action.EVENT.setValue(-1);  
86 - Action.PERSONNE.setValue(-1);  
87 - } else {  
88 - nbPages = 2; 62 + switch (session.getPersonne().getRole().getNom()) {
  63 + case "admin":
  64 + nbPages = 5;
  65 + Action.CONSOMATION.setValue(2);
  66 + Action.EVENT.setValue(3);
  67 + Action.PERSONNE.setValue(4);
  68 + break;
  69 + case "bde":
  70 + nbPages = 4;
  71 + Action.CONSOMATION.setValue(-1);
  72 + Action.EVENT.setValue(2);
  73 + Action.PERSONNE.setValue(3);
  74 + break;
  75 + case "bar":
  76 + nbPages = 3;
  77 + Action.CONSOMATION.setValue(2);
  78 + Action.EVENT.setValue(-1);
  79 + Action.PERSONNE.setValue(-1);
  80 + break;
  81 + default:
  82 + nbPages = 2;
89 } 83 }
90 -  
91 // config other stuff 84 // config other stuff
92 setContentView(R.layout.activity_main); 85 setContentView(R.layout.activity_main);
93 86
94 - appBarLayout = (AppBarLayout) findViewById(R.id.appbar);  
95 - toolbar = (Toolbar) findViewById(R.id.toolbar); 87 + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
96 setSupportActionBar(toolbar); 88 setSupportActionBar(toolbar);
97 89
98 // Create the adapter that will return a fragment for each of the three 90 // Create the adapter that will return a fragment for each of the three
99 // primary sections of the activity. 91 // primary sections of the activity.
100 - mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); 92 + SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
101 93
102 // Set up the ViewPager with the sections adapter. 94 // Set up the ViewPager with the sections adapter.
103 mViewPager = (ViewPager) findViewById(R.id.container); 95 mViewPager = (ViewPager) findViewById(R.id.container);
@@ -150,13 +142,13 @@ public class MainActivity extends AppCompatActivity @@ -150,13 +142,13 @@ public class MainActivity extends AppCompatActivity
150 } 142 }
151 143
152 @Override 144 @Override
153 - public void onResume(){ 145 + public void onResume() {
154 super.onResume(); 146 super.onResume();
155 mAdapter.enableForegroundDispatch(this, mPendingIntent, null, null); 147 mAdapter.enableForegroundDispatch(this, mPendingIntent, null, null);
156 } 148 }
157 149
158 @Override 150 @Override
159 - public void onPause(){ 151 + public void onPause() {
160 super.onPause(); 152 super.onPause();
161 if (mAdapter != null) { 153 if (mAdapter != null) {
162 mAdapter.disableForegroundDispatch(this); 154 mAdapter.disableForegroundDispatch(this);
@@ -183,13 +175,31 @@ public class MainActivity extends AppCompatActivity @@ -183,13 +175,31 @@ public class MainActivity extends AppCompatActivity
183 175
184 } 176 }
185 177
  178 + private enum Action {
  179 + DEBITER(0), CREDITER(1), CONSOMATION(2), EVENT(3), PERSONNE(4);
  180 +
  181 + private int value;
  182 +
  183 + Action(int value) {
  184 + this.value = value;
  185 + }
  186 +
  187 + public int getValue() {
  188 + return value;
  189 + }
  190 +
  191 + public void setValue(int value) {
  192 + this.value = value;
  193 + }
  194 + }
  195 +
186 /** 196 /**
187 * A {@link FragmentPagerAdapter} that returns a fragment corresponding to 197 * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
188 * one of the sections/tabs/pages. 198 * one of the sections/tabs/pages.
189 */ 199 */
190 public class SectionsPagerAdapter extends FragmentPagerAdapter { 200 public class SectionsPagerAdapter extends FragmentPagerAdapter {
191 201
192 - public SectionsPagerAdapter(FragmentManager fm) { 202 + SectionsPagerAdapter(FragmentManager fm) {
193 super(fm); 203 super(fm);
194 } 204 }
195 205
@@ -216,34 +226,17 @@ public class MainActivity extends AppCompatActivity @@ -216,34 +226,17 @@ public class MainActivity extends AppCompatActivity
216 226
217 @Override 227 @Override
218 public CharSequence getPageTitle(int position) { 228 public CharSequence getPageTitle(int position) {
219 - if(position == Action.DEBITER.getValue()) 229 + if (position == Action.DEBITER.getValue())
220 return "Debiter"; 230 return "Debiter";
221 else if (position == Action.CREDITER.getValue()) 231 else if (position == Action.CREDITER.getValue())
222 return "Crediter"; 232 return "Crediter";
223 else if (position == Action.CONSOMATION.getValue()) 233 else if (position == Action.CONSOMATION.getValue())
224 return "Consommation"; 234 return "Consommation";
225 - else if(position == Action.EVENT.getValue()) 235 + else if (position == Action.EVENT.getValue())
226 return getString(R.string.event); 236 return getString(R.string.event);
227 - else if(position == Action.PERSONNE.getValue()) 237 + else if (position == Action.PERSONNE.getValue())
228 return getString(R.string.personne); 238 return getString(R.string.personne);
229 return null; 239 return null;
230 } 240 }
231 } 241 }
232 -  
233 - private enum Action {  
234 - DEBITER(0), CREDITER(1), CONSOMATION(2), EVENT(3), PERSONNE(4);  
235 -  
236 - private int value;  
237 - Action(int value) {  
238 - this.value = value;  
239 - }  
240 -  
241 - public int getValue() {  
242 - return value;  
243 - }  
244 -  
245 - public void setValue(int value) {  
246 - this.value = value;  
247 - }  
248 - }  
249 } 242 }
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/ConsommationRecyclerViewAdapter.java
1 package net.plil.clubinfo.etunicorn.app.consommation; 1 package net.plil.clubinfo.etunicorn.app.consommation;
2 2
3 -import android.app.Activity;  
4 import android.content.Context; 3 import android.content.Context;
5 import android.support.v7.app.AppCompatActivity; 4 import android.support.v7.app.AppCompatActivity;
6 import android.support.v7.widget.PopupMenu; 5 import android.support.v7.widget.PopupMenu;
7 import android.support.v7.widget.RecyclerView; 6 import android.support.v7.widget.RecyclerView;
8 -import android.view.ContextMenu;  
9 import android.view.LayoutInflater; 7 import android.view.LayoutInflater;
10 import android.view.MenuItem; 8 import android.view.MenuItem;
11 import android.view.View; 9 import android.view.View;
@@ -19,13 +17,13 @@ import java.util.List; @@ -19,13 +17,13 @@ import java.util.List;
19 import java.util.Locale; 17 import java.util.Locale;
20 18
21 19
22 -public class ConsommationRecyclerViewAdapter extends RecyclerView.Adapter<ConsommationRecyclerViewAdapter.ViewHolder> { 20 +class ConsommationRecyclerViewAdapter extends RecyclerView.Adapter<ConsommationRecyclerViewAdapter.ViewHolder> {
23 21
24 private final List<Consommation> mValues; 22 private final List<Consommation> mValues;
25 private final FragmentConsommation.OnListFragmentInteractionListener mListener; 23 private final FragmentConsommation.OnListFragmentInteractionListener mListener;
26 private final Context context; 24 private final Context context;
27 25
28 - public ConsommationRecyclerViewAdapter(List<Consommation> items, FragmentConsommation.OnListFragmentInteractionListener listener, Context context) { 26 + ConsommationRecyclerViewAdapter(List<Consommation> items, FragmentConsommation.OnListFragmentInteractionListener listener, Context context) {
29 mValues = items; 27 mValues = items;
30 mListener = listener; 28 mListener = listener;
31 this.context = context; 29 this.context = context;
@@ -44,7 +42,7 @@ public class ConsommationRecyclerViewAdapter extends RecyclerView.Adapter&lt;Consom @@ -44,7 +42,7 @@ public class ConsommationRecyclerViewAdapter extends RecyclerView.Adapter&lt;Consom
44 holder.mItem = mValues.get(position); 42 holder.mItem = mValues.get(position);
45 holder.mIdView.setText(String.format(Locale.US, "%d", mValues.get(position).getIdConsomation())); 43 holder.mIdView.setText(String.format(Locale.US, "%d", mValues.get(position).getIdConsomation()));
46 holder.mContentView.setText(mValues.get(position).getNomConsomation()); 44 holder.mContentView.setText(mValues.get(position).getNomConsomation());
47 - holder.mPriceView.setText(String.format(Locale.US, "%.2f",mValues.get(position).getPrix())); 45 + holder.mPriceView.setText(String.format(Locale.US, "%.2f", mValues.get(position).getPrix()));
48 46
49 holder.mView.setOnClickListener(new View.OnClickListener() { 47 holder.mView.setOnClickListener(new View.OnClickListener() {
50 @Override 48 @Override
@@ -89,15 +87,15 @@ public class ConsommationRecyclerViewAdapter extends RecyclerView.Adapter&lt;Consom @@ -89,15 +87,15 @@ public class ConsommationRecyclerViewAdapter extends RecyclerView.Adapter&lt;Consom
89 return mValues.size(); 87 return mValues.size();
90 } 88 }
91 89
92 - public class ViewHolder extends RecyclerView.ViewHolder {  
93 - public final View mView;  
94 - public final TextView mIdView;  
95 - public final TextView mContentView;  
96 - public final TextView mPriceView;  
97 - public final TextView mButtonMenu;  
98 - public Consommation mItem; 90 + class ViewHolder extends RecyclerView.ViewHolder {
  91 + final View mView;
  92 + final TextView mIdView;
  93 + final TextView mContentView;
  94 + final TextView mPriceView;
  95 + final TextView mButtonMenu;
  96 + Consommation mItem;
99 97
100 - public ViewHolder(View view) { 98 + ViewHolder(View view) {
101 super(view); 99 super(view);
102 mView = view; 100 mView = view;
103 mIdView = (TextView) view.findViewById(R.id.consomation_id); 101 mIdView = (TextView) view.findViewById(R.id.consomation_id);
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/CreateConsommation.java
@@ -3,11 +3,10 @@ package net.plil.clubinfo.etunicorn.app.consommation; @@ -3,11 +3,10 @@ package net.plil.clubinfo.etunicorn.app.consommation;
3 import android.app.Dialog; 3 import android.app.Dialog;
4 import android.content.DialogInterface; 4 import android.content.DialogInterface;
5 import android.os.Bundle; 5 import android.os.Bundle;
  6 +import android.support.annotation.NonNull;
6 import android.support.design.widget.TextInputLayout; 7 import android.support.design.widget.TextInputLayout;
7 import android.support.v4.app.DialogFragment; 8 import android.support.v4.app.DialogFragment;
8 import android.support.v7.app.AlertDialog; 9 import android.support.v7.app.AlertDialog;
9 -import android.text.Editable;  
10 -import android.text.TextWatcher;  
11 import android.view.LayoutInflater; 10 import android.view.LayoutInflater;
12 import android.view.View; 11 import android.view.View;
13 import android.widget.Button; 12 import android.widget.Button;
@@ -41,6 +40,7 @@ public class CreateConsommation extends DialogFragment { @@ -41,6 +40,7 @@ public class CreateConsommation extends DialogFragment {
41 40
42 41
43 @Override 42 @Override
  43 + @NonNull
44 public Dialog onCreateDialog(Bundle savedInstanceState) { 44 public Dialog onCreateDialog(Bundle savedInstanceState) {
45 // Use the Builder class for convenient dialog construction 45 // Use the Builder class for convenient dialog construction
46 LayoutInflater inflater = getActivity().getLayoutInflater(); 46 LayoutInflater inflater = getActivity().getLayoutInflater();
@@ -75,7 +75,7 @@ public class CreateConsommation extends DialogFragment { @@ -75,7 +75,7 @@ public class CreateConsommation extends DialogFragment {
75 } else { 75 } else {
76 mPriceInput.setError(null); 76 mPriceInput.setError(null);
77 } 77 }
78 - if (mNomConsomation.getText().toString().isEmpty()){ 78 + if (mNomConsomation.getText().toString().isEmpty()) {
79 mNomInput.setError(getString(R.string.error_create_consomation_input_nom)); 79 mNomInput.setError(getString(R.string.error_create_consomation_input_nom));
80 testDateInputOk = false; 80 testDateInputOk = false;
81 } else { 81 } else {
@@ -107,13 +107,14 @@ public class CreateConsommation extends DialogFragment { @@ -107,13 +107,14 @@ public class CreateConsommation extends DialogFragment {
107 dismiss(); 107 dismiss();
108 } 108 }
109 } 109 }
110 - ){ 110 + ) {
111 @Override 111 @Override
112 public Map<String, String> getHeaders() throws AuthFailureError { 112 public Map<String, String> getHeaders() throws AuthFailureError {
113 - Map<String, String> headers = new HashMap<String, String>(); 113 + Map<String, String> headers = new HashMap<>();
114 headers.put("Authorization", MainActivity.session.getToken()); 114 headers.put("Authorization", MainActivity.session.getToken());
115 return headers; 115 return headers;
116 - }}; 116 + }
  117 + };
117 jsonObjectRequest.setTag(CreateConsommation.class); 118 jsonObjectRequest.setTag(CreateConsommation.class);
118 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 119 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
119 } 120 }
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/DeleteConsommation.java
@@ -3,13 +3,13 @@ package net.plil.clubinfo.etunicorn.app.consommation; @@ -3,13 +3,13 @@ package net.plil.clubinfo.etunicorn.app.consommation;
3 import android.app.Dialog; 3 import android.app.Dialog;
4 import android.content.DialogInterface; 4 import android.content.DialogInterface;
5 import android.os.Bundle; 5 import android.os.Bundle;
  6 +import android.support.annotation.NonNull;
6 import android.support.v4.app.DialogFragment; 7 import android.support.v4.app.DialogFragment;
7 import android.support.v7.app.AlertDialog; 8 import android.support.v7.app.AlertDialog;
8 import android.view.LayoutInflater; 9 import android.view.LayoutInflater;
9 import android.view.View; 10 import android.view.View;
10 import android.widget.Button; 11 import android.widget.Button;
11 import android.widget.ProgressBar; 12 import android.widget.ProgressBar;
12 -import android.widget.TextView;  
13 import android.widget.Toast; 13 import android.widget.Toast;
14 14
15 import com.android.volley.AuthFailureError; 15 import com.android.volley.AuthFailureError;
@@ -23,11 +23,9 @@ import net.plil.clubinfo.etunicorn.app.MainActivity; @@ -23,11 +23,9 @@ import net.plil.clubinfo.etunicorn.app.MainActivity;
23 import net.plil.clubinfo.etunicorn.data.Consommation; 23 import net.plil.clubinfo.etunicorn.data.Consommation;
24 import net.plil.clubinfo.etunicorn.utils.VolleyUtils; 24 import net.plil.clubinfo.etunicorn.utils.VolleyUtils;
25 25
26 -import org.json.JSONException;  
27 import org.json.JSONObject; 26 import org.json.JSONObject;
28 27
29 import java.util.HashMap; 28 import java.util.HashMap;
30 -import java.util.Locale;  
31 import java.util.Map; 29 import java.util.Map;
32 30
33 31
@@ -35,7 +33,8 @@ public class DeleteConsommation extends DialogFragment { @@ -35,7 +33,8 @@ public class DeleteConsommation extends DialogFragment {
35 33
36 ProgressBar mProgressBar; 34 ProgressBar mProgressBar;
37 35
38 - public DeleteConsommation(){} 36 + public DeleteConsommation() {
  37 + }
39 38
40 /** 39 /**
41 * Create a new instance of MyDialogFragment, providing "num" 40 * Create a new instance of MyDialogFragment, providing "num"
@@ -54,13 +53,16 @@ public class DeleteConsommation extends DialogFragment { @@ -54,13 +53,16 @@ public class DeleteConsommation extends DialogFragment {
54 53
55 54
56 @Override 55 @Override
  56 + @NonNull
57 public Dialog onCreateDialog(Bundle savedInstanceState) { 57 public Dialog onCreateDialog(Bundle savedInstanceState) {
58 // Use the Builder class for convenient dialog construction 58 // Use the Builder class for convenient dialog construction
59 LayoutInflater inflater = getActivity().getLayoutInflater(); 59 LayoutInflater inflater = getActivity().getLayoutInflater();
60 View view = inflater.inflate(R.layout.fragment_delete_consomation, null); 60 View view = inflater.inflate(R.layout.fragment_delete_consomation, null);
61 61
62 mProgressBar = (ProgressBar) view.findViewById(R.id.delete_consommation_progress_bar); 62 mProgressBar = (ProgressBar) view.findViewById(R.id.delete_consommation_progress_bar);
  63 +
63 final Consommation consommation = (Consommation) getArguments().getSerializable("consommation"); 64 final Consommation consommation = (Consommation) getArguments().getSerializable("consommation");
  65 + assert consommation != null;
64 66
65 67
66 AlertDialog dialog = new AlertDialog.Builder(getActivity()) 68 AlertDialog dialog = new AlertDialog.Builder(getActivity())
@@ -94,13 +96,14 @@ public class DeleteConsommation extends DialogFragment { @@ -94,13 +96,14 @@ public class DeleteConsommation extends DialogFragment {
94 Toast.makeText(getContext(), R.string.delete_refused, Toast.LENGTH_LONG).show(); 96 Toast.makeText(getContext(), R.string.delete_refused, Toast.LENGTH_LONG).show();
95 } 97 }
96 } 98 }
97 - ){ 99 + ) {
98 @Override 100 @Override
99 public Map<String, String> getHeaders() throws AuthFailureError { 101 public Map<String, String> getHeaders() throws AuthFailureError {
100 - Map<String, String> headers = new HashMap<String, String>(); 102 + Map<String, String> headers = new HashMap<>();
101 headers.put("Authorization", MainActivity.session.getToken()); 103 headers.put("Authorization", MainActivity.session.getToken());
102 return headers; 104 return headers;
103 - }}; 105 + }
  106 + };
104 jsonObjectRequest.setTag(DeleteConsommation.class); 107 jsonObjectRequest.setTag(DeleteConsommation.class);
105 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 108 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
106 } 109 }
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/FragmentConsommation.java
@@ -60,14 +60,14 @@ public class FragmentConsommation extends Fragment implements NFCSupport { @@ -60,14 +60,14 @@ public class FragmentConsommation extends Fragment implements NFCSupport {
60 c1.setNomConsomation("Hello"); 60 c1.setNomConsomation("Hello");
61 c1.setPrix(12.5); 61 c1.setPrix(12.5);
62 consommationList.add(c1); 62 consommationList.add(c1);
63 - for (int i = 0; i< 100; ++i){ 63 + for (int i = 0; i < 100; ++i) {
64 c1 = new Consommation(); 64 c1 = new Consommation();
65 c1.setIdConsomation(i); 65 c1.setIdConsomation(i);
66 c1.setNomConsomation("World"); 66 c1.setNomConsomation("World");
67 c1.setPrix(42.407); 67 c1.setPrix(42.407);
68 consommationList.add(c1); 68 consommationList.add(c1);
69 } 69 }
70 - recyclerView.setAdapter(new ConsommationRecyclerViewAdapter(consommationList, mListener, this.getActivity())); 70 + recyclerView.setAdapter(new ConsommationRecyclerViewAdapter(consommationList, mListener, this.getActivity()));
71 71
72 FloatingActionButton fAB = (FloatingActionButton) view.findViewById(R.id.consomation_add); 72 FloatingActionButton fAB = (FloatingActionButton) view.findViewById(R.id.consomation_add);
73 fAB.setOnClickListener(new View.OnClickListener() { 73 fAB.setOnClickListener(new View.OnClickListener() {
@@ -102,10 +102,9 @@ public class FragmentConsommation extends Fragment implements NFCSupport { @@ -102,10 +102,9 @@ public class FragmentConsommation extends Fragment implements NFCSupport {
102 @Override 102 @Override
103 public void processNFC(String idCardUser) { 103 public void processNFC(String idCardUser) {
104 PaiementConsommation paiementConsommation = (PaiementConsommation) getFragmentManager().findFragmentByTag("paiementConsommation"); 104 PaiementConsommation paiementConsommation = (PaiementConsommation) getFragmentManager().findFragmentByTag("paiementConsommation");
105 - if (paiementConsommation == null){ 105 + if (paiementConsommation == null) {
106 Toast.makeText(getContext(), R.string.payment_consumable_alert_no_selection, Toast.LENGTH_LONG).show(); 106 Toast.makeText(getContext(), R.string.payment_consumable_alert_no_selection, Toast.LENGTH_LONG).show();
107 - }  
108 - else { 107 + } else {
109 paiementConsommation.processNFC(idCardUser); 108 paiementConsommation.processNFC(idCardUser);
110 } 109 }
111 } 110 }
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/ModifyConsommation.java
@@ -3,6 +3,7 @@ package net.plil.clubinfo.etunicorn.app.consommation; @@ -3,6 +3,7 @@ package net.plil.clubinfo.etunicorn.app.consommation;
3 import android.app.Dialog; 3 import android.app.Dialog;
4 import android.content.DialogInterface; 4 import android.content.DialogInterface;
5 import android.os.Bundle; 5 import android.os.Bundle;
  6 +import android.support.annotation.NonNull;
6 import android.support.design.widget.TextInputLayout; 7 import android.support.design.widget.TextInputLayout;
7 import android.support.v4.app.DialogFragment; 8 import android.support.v4.app.DialogFragment;
8 import android.support.v7.app.AlertDialog; 9 import android.support.v7.app.AlertDialog;
@@ -53,6 +54,7 @@ public class ModifyConsommation extends DialogFragment { @@ -53,6 +54,7 @@ public class ModifyConsommation extends DialogFragment {
53 54
54 55
55 @Override 56 @Override
  57 + @NonNull
56 public Dialog onCreateDialog(Bundle savedInstanceState) { 58 public Dialog onCreateDialog(Bundle savedInstanceState) {
57 // Use the Builder class for convenient dialog construction 59 // Use the Builder class for convenient dialog construction
58 final LayoutInflater inflater = getActivity().getLayoutInflater(); 60 final LayoutInflater inflater = getActivity().getLayoutInflater();
@@ -64,9 +66,10 @@ public class ModifyConsommation extends DialogFragment { @@ -64,9 +66,10 @@ public class ModifyConsommation extends DialogFragment {
64 mPriceInput = (TextInputLayout) view.findViewById(R.id.modify_consommation_input_price); 66 mPriceInput = (TextInputLayout) view.findViewById(R.id.modify_consommation_input_price);
65 67
66 final Consommation consommation = (Consommation) getArguments().getSerializable("consommation"); 68 final Consommation consommation = (Consommation) getArguments().getSerializable("consommation");
  69 + assert consommation != null;
67 70
68 mNomConsomation.setText(consommation.getNomConsomation()); 71 mNomConsomation.setText(consommation.getNomConsomation());
69 - mPrice.setText(String.format(Locale.US,"%.2f", consommation.getPrix())); 72 + mPrice.setText(String.format(Locale.US, "%.2f", consommation.getPrix()));
70 73
71 AlertDialog dialog = new AlertDialog.Builder(getActivity()) 74 AlertDialog dialog = new AlertDialog.Builder(getActivity())
72 .setTitle(R.string.modify) 75 .setTitle(R.string.modify)
@@ -87,13 +90,13 @@ public class ModifyConsommation extends DialogFragment { @@ -87,13 +90,13 @@ public class ModifyConsommation extends DialogFragment {
87 @Override 90 @Override
88 public void onClick(View v) { 91 public void onClick(View v) {
89 boolean inputOk = true; 92 boolean inputOk = true;
90 - if (mPrice.getText().toString().isEmpty()){ 93 + if (mPrice.getText().toString().isEmpty()) {
91 inputOk = false; 94 inputOk = false;
92 mPriceInput.setError(getString(R.string.error_modify_consommation_input_price)); 95 mPriceInput.setError(getString(R.string.error_modify_consommation_input_price));
93 } else { 96 } else {
94 mPriceInput.setError(null); 97 mPriceInput.setError(null);
95 } 98 }
96 - if (mNomConsomation.getText().toString().isEmpty()){ 99 + if (mNomConsomation.getText().toString().isEmpty()) {
97 inputOk = false; 100 inputOk = false;
98 mNomInput.setError(getString(R.string.error_modify_consommation_input_nom)); 101 mNomInput.setError(getString(R.string.error_modify_consommation_input_nom));
99 } else { 102 } else {
@@ -125,19 +128,21 @@ public class ModifyConsommation extends DialogFragment { @@ -125,19 +128,21 @@ public class ModifyConsommation extends DialogFragment {
125 Toast.makeText(getContext(), R.string.modify_refused, Toast.LENGTH_LONG).show(); 128 Toast.makeText(getContext(), R.string.modify_refused, Toast.LENGTH_LONG).show();
126 } 129 }
127 } 130 }
128 - ){ 131 + ) {
129 @Override 132 @Override
130 public Map<String, String> getHeaders() throws AuthFailureError { 133 public Map<String, String> getHeaders() throws AuthFailureError {
131 - Map<String, String> headers = new HashMap<String, String>(); 134 + Map<String, String> headers = new HashMap<>();
132 headers.put("Authorization", MainActivity.session.getToken()); 135 headers.put("Authorization", MainActivity.session.getToken());
133 return headers; 136 return headers;
134 - }}; 137 + }
  138 + };
135 jsonObjectRequest.setTag(ModifyConsommation.class); 139 jsonObjectRequest.setTag(ModifyConsommation.class);
136 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 140 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
137 } 141 }
138 } 142 }
139 }); 143 });
140 - }}); 144 + }
  145 + });
141 dialog.setCanceledOnTouchOutside(false); 146 dialog.setCanceledOnTouchOutside(false);
142 return dialog; 147 return dialog;
143 } 148 }
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/PaiementConsommation.java
@@ -3,9 +3,9 @@ package net.plil.clubinfo.etunicorn.app.consommation; @@ -3,9 +3,9 @@ package net.plil.clubinfo.etunicorn.app.consommation;
3 import android.app.Dialog; 3 import android.app.Dialog;
4 import android.content.DialogInterface; 4 import android.content.DialogInterface;
5 import android.os.Bundle; 5 import android.os.Bundle;
  6 +import android.support.annotation.NonNull;
6 import android.support.v4.app.DialogFragment; 7 import android.support.v4.app.DialogFragment;
7 import android.support.v7.app.AlertDialog; 8 import android.support.v7.app.AlertDialog;
8 -import android.view.KeyEvent;  
9 import android.view.LayoutInflater; 9 import android.view.LayoutInflater;
10 import android.view.View; 10 import android.view.View;
11 import android.widget.ProgressBar; 11 import android.widget.ProgressBar;
@@ -21,7 +21,6 @@ import com.android.volley.toolbox.JsonObjectRequest; @@ -21,7 +21,6 @@ import com.android.volley.toolbox.JsonObjectRequest;
21 import net.plil.clubinfo.etunicorn.R; 21 import net.plil.clubinfo.etunicorn.R;
22 import net.plil.clubinfo.etunicorn.app.MainActivity; 22 import net.plil.clubinfo.etunicorn.app.MainActivity;
23 import net.plil.clubinfo.etunicorn.app.NFCSupport; 23 import net.plil.clubinfo.etunicorn.app.NFCSupport;
24 -import net.plil.clubinfo.etunicorn.app.event.PaiementEvent;  
25 import net.plil.clubinfo.etunicorn.data.Consommation; 24 import net.plil.clubinfo.etunicorn.data.Consommation;
26 import net.plil.clubinfo.etunicorn.utils.VolleyUtils; 25 import net.plil.clubinfo.etunicorn.utils.VolleyUtils;
27 26
@@ -40,7 +39,8 @@ public class PaiementConsommation extends DialogFragment implements NFCSupport { @@ -40,7 +39,8 @@ public class PaiementConsommation extends DialogFragment implements NFCSupport {
40 TextView mPaiementConsommationPrice; 39 TextView mPaiementConsommationPrice;
41 int consommationId; 40 int consommationId;
42 41
43 - public PaiementConsommation(){} 42 + public PaiementConsommation() {
  43 + }
44 44
45 /** 45 /**
46 * Create a new instance of MyDialogFragment, providing "num" 46 * Create a new instance of MyDialogFragment, providing "num"
@@ -57,6 +57,7 @@ public class PaiementConsommation extends DialogFragment implements NFCSupport { @@ -57,6 +57,7 @@ public class PaiementConsommation extends DialogFragment implements NFCSupport {
57 57
58 58
59 @Override 59 @Override
  60 + @NonNull
60 public Dialog onCreateDialog(Bundle savedInstanceState) { 61 public Dialog onCreateDialog(Bundle savedInstanceState) {
61 // Use the Builder class for convenient dialog construction 62 // Use the Builder class for convenient dialog construction
62 LayoutInflater inflater = getActivity().getLayoutInflater(); 63 LayoutInflater inflater = getActivity().getLayoutInflater();
@@ -67,6 +68,8 @@ public class PaiementConsommation extends DialogFragment implements NFCSupport { @@ -67,6 +68,8 @@ public class PaiementConsommation extends DialogFragment implements NFCSupport {
67 68
68 69
69 Consommation consommation = (Consommation) getArguments().getSerializable("consommation"); 70 Consommation consommation = (Consommation) getArguments().getSerializable("consommation");
  71 + assert consommation != null;
  72 +
70 mPaiementConsommationName.setText(consommation.getNomConsomation()); 73 mPaiementConsommationName.setText(consommation.getNomConsomation());
71 mPaiementConsommationPrice.setText(String.format(Locale.FRANCE, "%.2f €", consommation.getPrix())); 74 mPaiementConsommationPrice.setText(String.format(Locale.FRANCE, "%.2f €", consommation.getPrix()));
72 75
@@ -82,7 +85,7 @@ public class PaiementConsommation extends DialogFragment implements NFCSupport { @@ -82,7 +85,7 @@ public class PaiementConsommation extends DialogFragment implements NFCSupport {
82 } 85 }
83 }); 86 });
84 87
85 - Dialog dialog = builder.create(); 88 + Dialog dialog = builder.create();
86 dialog.setCanceledOnTouchOutside(false); 89 dialog.setCanceledOnTouchOutside(false);
87 return dialog; 90 return dialog;
88 } 91 }
@@ -112,13 +115,14 @@ public class PaiementConsommation extends DialogFragment implements NFCSupport { @@ -112,13 +115,14 @@ public class PaiementConsommation extends DialogFragment implements NFCSupport {
112 Toast.makeText(getContext(), R.string.payment_refused, Toast.LENGTH_LONG).show(); 115 Toast.makeText(getContext(), R.string.payment_refused, Toast.LENGTH_LONG).show();
113 } 116 }
114 } 117 }
115 - ){ 118 + ) {
116 @Override 119 @Override
117 public Map<String, String> getHeaders() throws AuthFailureError { 120 public Map<String, String> getHeaders() throws AuthFailureError {
118 - Map<String, String> headers = new HashMap<String, String>(); 121 + Map<String, String> headers = new HashMap<>();
119 headers.put("Authorization", MainActivity.session.getToken()); 122 headers.put("Authorization", MainActivity.session.getToken());
120 return headers; 123 return headers;
121 - }}; 124 + }
  125 + };
122 jsonObjectRequest.setTag(PaiementConsommation.class); 126 jsonObjectRequest.setTag(PaiementConsommation.class);
123 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 127 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
124 } 128 }
app/src/main/java/net/plil/clubinfo/etunicorn/app/credit/Crediter.java
@@ -29,7 +29,7 @@ import org.json.JSONObject; @@ -29,7 +29,7 @@ import org.json.JSONObject;
29 import java.util.HashMap; 29 import java.util.HashMap;
30 import java.util.Map; 30 import java.util.Map;
31 31
32 -public class Crediter extends Fragment implements NFCSupport{ 32 +public class Crediter extends Fragment implements NFCSupport {
33 33
34 private EditText mMoneyEditText; 34 private EditText mMoneyEditText;
35 private ProgressBar mProgressBar; 35 private ProgressBar mProgressBar;
@@ -70,7 +70,7 @@ public class Crediter extends Fragment implements NFCSupport{ @@ -70,7 +70,7 @@ public class Crediter extends Fragment implements NFCSupport{
70 70
71 @Override 71 @Override
72 public void processNFC(String idCardUser) { 72 public void processNFC(String idCardUser) {
73 - if(mMoneyEditText.getText().toString().isEmpty()){ 73 + if (mMoneyEditText.getText().toString().isEmpty()) {
74 mMoneyEditText.setError(getString(R.string.error_enter_debit)); 74 mMoneyEditText.setError(getString(R.string.error_enter_debit));
75 return; 75 return;
76 } 76 }
@@ -82,10 +82,10 @@ public class Crediter extends Fragment implements NFCSupport{ @@ -82,10 +82,10 @@ public class Crediter extends Fragment implements NFCSupport{
82 p.setCarte(idCardUser); 82 p.setCarte(idCardUser);
83 jsonObject.put("participant", p); 83 jsonObject.put("participant", p);
84 jsonObject.put("prix", Double.parseDouble(mMoneyEditText.getText().toString())); 84 jsonObject.put("prix", Double.parseDouble(mMoneyEditText.getText().toString()));
85 - } catch (JSONException e){ 85 + } catch (JSONException e) {
86 e.printStackTrace(); 86 e.printStackTrace();
87 } 87 }
88 - JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/transaction/debit" ,jsonObject , new Response.Listener<JSONObject>() { 88 + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/transaction/debit", jsonObject, new Response.Listener<JSONObject>() {
89 @Override 89 @Override
90 public void onResponse(JSONObject response) { 90 public void onResponse(JSONObject response) {
91 mProgressBar.setVisibility(View.GONE); 91 mProgressBar.setVisibility(View.GONE);
@@ -101,13 +101,14 @@ public class Crediter extends Fragment implements NFCSupport{ @@ -101,13 +101,14 @@ public class Crediter extends Fragment implements NFCSupport{
101 Snackbar.make(coordinatorLayout, error.getMessage(), Snackbar.LENGTH_LONG).show(); 101 Snackbar.make(coordinatorLayout, error.getMessage(), Snackbar.LENGTH_LONG).show();
102 } 102 }
103 } 103 }
104 - ){ 104 + ) {
105 @Override 105 @Override
106 public Map<String, String> getHeaders() throws AuthFailureError { 106 public Map<String, String> getHeaders() throws AuthFailureError {
107 - Map<String, String> headers = new HashMap<String, String>(); 107 + Map<String, String> headers = new HashMap<>();
108 headers.put("Authorization", MainActivity.session.getToken()); 108 headers.put("Authorization", MainActivity.session.getToken());
109 return headers; 109 return headers;
110 - }}; 110 + }
  111 + };
111 jsonObjectRequest.setTag(Crediter.class); 112 jsonObjectRequest.setTag(Crediter.class);
112 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 113 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
113 } 114 }
app/src/main/java/net/plil/clubinfo/etunicorn/app/debit/Debiter.java
@@ -74,7 +74,7 @@ public class Debiter extends Fragment implements NFCSupport { @@ -74,7 +74,7 @@ public class Debiter extends Fragment implements NFCSupport {
74 74
75 @Override 75 @Override
76 public void processNFC(String iDCardUser) { 76 public void processNFC(String iDCardUser) {
77 - if(mMoneyEditText.getText().toString().isEmpty()){ 77 + if (mMoneyEditText.getText().toString().isEmpty()) {
78 mMoneyEditText.setError(getString(R.string.error_enter_debit)); 78 mMoneyEditText.setError(getString(R.string.error_enter_debit));
79 return; 79 return;
80 } 80 }
@@ -88,10 +88,10 @@ public class Debiter extends Fragment implements NFCSupport { @@ -88,10 +88,10 @@ public class Debiter extends Fragment implements NFCSupport {
88 jsonObject.put("participant", p); 88 jsonObject.put("participant", p);
89 jsonObject.put("prix", -Double.parseDouble(mMoneyEditText.getText().toString())); 89 jsonObject.put("prix", -Double.parseDouble(mMoneyEditText.getText().toString()));
90 mMoneyEditText.setError(null); 90 mMoneyEditText.setError(null);
91 - } catch (JSONException e){ 91 + } catch (JSONException e) {
92 e.printStackTrace(); 92 e.printStackTrace();
93 } 93 }
94 - JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/transaction/credit" ,jsonObject , new Response.Listener<JSONObject>() { 94 + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/transaction/credit", jsonObject, new Response.Listener<JSONObject>() {
95 @Override 95 @Override
96 public void onResponse(JSONObject response) { 96 public void onResponse(JSONObject response) {
97 mProgressBar.setVisibility(View.GONE); 97 mProgressBar.setVisibility(View.GONE);
@@ -108,14 +108,14 @@ public class Debiter extends Fragment implements NFCSupport { @@ -108,14 +108,14 @@ public class Debiter extends Fragment implements NFCSupport {
108 Snackbar.make(coordinatorLayout, error.getMessage(), Snackbar.LENGTH_LONG).show(); 108 Snackbar.make(coordinatorLayout, error.getMessage(), Snackbar.LENGTH_LONG).show();
109 109
110 } 110 }
111 - })  
112 - { 111 + }) {
113 @Override 112 @Override
114 public Map<String, String> getHeaders() throws AuthFailureError { 113 public Map<String, String> getHeaders() throws AuthFailureError {
115 - Map<String, String> headers = new HashMap<String, String>(); 114 + Map<String, String> headers = new HashMap<>();
116 headers.put("Authorization", MainActivity.session.getToken()); 115 headers.put("Authorization", MainActivity.session.getToken());
117 return headers; 116 return headers;
118 - }}; 117 + }
  118 + };
119 jsonObjectRequest.setTag(Debiter.class); 119 jsonObjectRequest.setTag(Debiter.class);
120 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 120 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
121 } 121 }
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/CreatePersonne.java
@@ -4,6 +4,7 @@ import android.app.DatePickerDialog; @@ -4,6 +4,7 @@ import android.app.DatePickerDialog;
4 import android.app.Dialog; 4 import android.app.Dialog;
5 import android.content.DialogInterface; 5 import android.content.DialogInterface;
6 import android.os.Bundle; 6 import android.os.Bundle;
  7 +import android.support.annotation.NonNull;
7 import android.support.design.widget.TextInputLayout; 8 import android.support.design.widget.TextInputLayout;
8 import android.support.v4.app.DialogFragment; 9 import android.support.v4.app.DialogFragment;
9 import android.support.v7.app.AlertDialog; 10 import android.support.v7.app.AlertDialog;
@@ -26,8 +27,8 @@ import com.android.volley.toolbox.JsonArrayRequest; @@ -26,8 +27,8 @@ import com.android.volley.toolbox.JsonArrayRequest;
26 import com.android.volley.toolbox.JsonObjectRequest; 27 import com.android.volley.toolbox.JsonObjectRequest;
27 28
28 import net.plil.clubinfo.etunicorn.R; 29 import net.plil.clubinfo.etunicorn.R;
29 -import net.plil.clubinfo.etunicorn.app.NFCSupport;  
30 import net.plil.clubinfo.etunicorn.app.MainActivity; 30 import net.plil.clubinfo.etunicorn.app.MainActivity;
  31 +import net.plil.clubinfo.etunicorn.app.NFCSupport;
31 import net.plil.clubinfo.etunicorn.data.Role; 32 import net.plil.clubinfo.etunicorn.data.Role;
32 import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; 33 import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString;
33 import net.plil.clubinfo.etunicorn.utils.JsonConverter; 34 import net.plil.clubinfo.etunicorn.utils.JsonConverter;
@@ -48,30 +49,35 @@ import java.util.Map; @@ -48,30 +49,35 @@ import java.util.Map;
48 49
49 public class CreatePersonne extends DialogFragment implements NFCSupport { 50 public class CreatePersonne extends DialogFragment implements NFCSupport {
50 51
51 - private DialogInterface.OnDismissListener onDismissListener;  
52 -  
53 Calendar myCalendar = Calendar.getInstance(); 52 Calendar myCalendar = Calendar.getInstance();
54 -  
55 - 53 + TextInputLayout mLoginInput;
  54 + TextInputLayout mCarteInput;
  55 + private DialogInterface.OnDismissListener onDismissListener;
56 private EditText mLogin; 56 private EditText mLogin;
57 private EditText mCarte; 57 private EditText mCarte;
58 private Spinner mNaissance; 58 private Spinner mNaissance;
59 private Spinner mRole; 59 private Spinner mRole;
60 private ProgressBar mProgressBar; 60 private ProgressBar mProgressBar;
61 -  
62 - TextInputLayout mLoginInput;  
63 - TextInputLayout mCarteInput;  
64 -  
65 private String[] arraySpinnerNaissance; 61 private String[] arraySpinnerNaissance;
66 private ArrayAdapter<String> adapterNaissance; 62 private ArrayAdapter<String> adapterNaissance;
  63 + DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
67 64
  65 + @Override
  66 + public void onDateSet(DatePicker view, int year, int monthOfYear,
  67 + int dayOfMonth) {
  68 + myCalendar.set(Calendar.YEAR, year);
  69 + myCalendar.set(Calendar.MONTH, monthOfYear);
  70 + myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
  71 + updateLabel();
  72 + }
  73 + };
68 private List<Role> arraySpinnerRole; 74 private List<Role> arraySpinnerRole;
69 private ArrayAdapter<Role> adapterRole; 75 private ArrayAdapter<Role> adapterRole;
70 76
71 -  
72 @Override 77 @Override
  78 + @NonNull
73 public Dialog onCreateDialog(Bundle savedInstanceState) { 79 public Dialog onCreateDialog(Bundle savedInstanceState) {
74 - myCalendar.set(Calendar.YEAR, myCalendar.get(Calendar.YEAR)-18); 80 + myCalendar.set(Calendar.YEAR, myCalendar.get(Calendar.YEAR) - 18);
75 // Use the Builder class for convenient dialog construction 81 // Use the Builder class for convenient dialog construction
76 LayoutInflater inflater = getActivity().getLayoutInflater(); 82 LayoutInflater inflater = getActivity().getLayoutInflater();
77 View view = inflater.inflate(R.layout.fragment_create_personne, null); 83 View view = inflater.inflate(R.layout.fragment_create_personne, null);
@@ -89,10 +95,10 @@ public class CreatePersonne extends DialogFragment implements NFCSupport { @@ -89,10 +95,10 @@ public class CreatePersonne extends DialogFragment implements NFCSupport {
89 mRole.setAdapter(adapterRole); 95 mRole.setAdapter(adapterRole);
90 changeRolePossibility(); 96 changeRolePossibility();
91 mNaissance = (Spinner) view.findViewById(R.id.create_personne_naissance); 97 mNaissance = (Spinner) view.findViewById(R.id.create_personne_naissance);
92 - arraySpinnerNaissance = new String[] { 98 + arraySpinnerNaissance = new String[]{
93 getString(R.string.create_personne_naissance) 99 getString(R.string.create_personne_naissance)
94 }; 100 };
95 - adapterNaissance = new ArrayAdapter<String>(getActivity(), 101 + adapterNaissance = new ArrayAdapter<>(getActivity(),
96 R.layout.simple_item_layout, arraySpinnerNaissance); 102 R.layout.simple_item_layout, arraySpinnerNaissance);
97 mNaissance.setAdapter(adapterNaissance); 103 mNaissance.setAdapter(adapterNaissance);
98 mProgressBar = (ProgressBar) view.findViewById(R.id.create_personne_progress_bar); 104 mProgressBar = (ProgressBar) view.findViewById(R.id.create_personne_progress_bar);
@@ -113,11 +119,10 @@ public class CreatePersonne extends DialogFragment implements NFCSupport { @@ -113,11 +119,10 @@ public class CreatePersonne extends DialogFragment implements NFCSupport {
113 button.setOnClickListener(new View.OnClickListener() { 119 button.setOnClickListener(new View.OnClickListener() {
114 @Override 120 @Override
115 public void onClick(View v) { 121 public void onClick(View v) {
116 - if (mLogin.getText().toString().isEmpty() && mCarte.getText().toString().isEmpty()){ 122 + if (mLogin.getText().toString().isEmpty() && mCarte.getText().toString().isEmpty()) {
117 mLogin.setError(getString(R.string.error_create_personne_login_carte)); 123 mLogin.setError(getString(R.string.error_create_personne_login_carte));
118 mCarte.setError(getString(R.string.error_create_personne_login_carte)); 124 mCarte.setError(getString(R.string.error_create_personne_login_carte));
119 - }  
120 - else { 125 + } else {
121 mProgressBar.setVisibility(View.VISIBLE); 126 mProgressBar.setVisibility(View.VISIBLE);
122 mLoginInput.setVisibility(View.GONE); 127 mLoginInput.setVisibility(View.GONE);
123 mCarteInput.setVisibility(View.GONE); 128 mCarteInput.setVisibility(View.GONE);
@@ -127,7 +132,7 @@ public class CreatePersonne extends DialogFragment implements NFCSupport { @@ -127,7 +132,7 @@ public class CreatePersonne extends DialogFragment implements NFCSupport {
127 try { 132 try {
128 if (!mLogin.getText().toString().isEmpty()) 133 if (!mLogin.getText().toString().isEmpty())
129 jsonObject.put("login", mLogin.getText().toString()); 134 jsonObject.put("login", mLogin.getText().toString());
130 - if(!mCarte.getText().toString().isEmpty()) 135 + if (!mCarte.getText().toString().isEmpty())
131 jsonObject.put("carte", mCarte.getText().toString()); 136 jsonObject.put("carte", mCarte.getText().toString());
132 jsonObject.put("role", JsonConverter.convertToJSONObject(mRole.getSelectedItem())); 137 jsonObject.put("role", JsonConverter.convertToJSONObject(mRole.getSelectedItem()));
133 if (!mNaissance.getSelectedItem().equals(getString(R.string.create_personne_naissance))) 138 if (!mNaissance.getSelectedItem().equals(getString(R.string.create_personne_naissance)))
@@ -153,14 +158,14 @@ public class CreatePersonne extends DialogFragment implements NFCSupport { @@ -153,14 +158,14 @@ public class CreatePersonne extends DialogFragment implements NFCSupport {
153 Toast.makeText(getContext(), ConvertBytesToString.bytesToStringVolLey(error.networkResponse.data), Toast.LENGTH_LONG).show(); 158 Toast.makeText(getContext(), ConvertBytesToString.bytesToStringVolLey(error.networkResponse.data), Toast.LENGTH_LONG).show();
154 } 159 }
155 } 160 }
156 - )  
157 - { 161 + ) {
158 @Override 162 @Override
159 public Map<String, String> getHeaders() throws AuthFailureError { 163 public Map<String, String> getHeaders() throws AuthFailureError {
160 - Map<String, String> headers = new HashMap<String, String>(); 164 + Map<String, String> headers = new HashMap<>();
161 headers.put("Authorization", MainActivity.session.getToken()); 165 headers.put("Authorization", MainActivity.session.getToken());
162 return headers; 166 return headers;
163 - }}; 167 + }
  168 + };
164 jsonObjectRequest.setTag(CreatePersonne.class); 169 jsonObjectRequest.setTag(CreatePersonne.class);
165 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 170 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
166 } 171 }
@@ -172,7 +177,7 @@ public class CreatePersonne extends DialogFragment implements NFCSupport { @@ -172,7 +177,7 @@ public class CreatePersonne extends DialogFragment implements NFCSupport {
172 mNaissance.setOnTouchListener(new View.OnTouchListener() { 177 mNaissance.setOnTouchListener(new View.OnTouchListener() {
173 @Override 178 @Override
174 public boolean onTouch(View v, MotionEvent event) { 179 public boolean onTouch(View v, MotionEvent event) {
175 - if(event.getAction() == MotionEvent.ACTION_UP) { 180 + if (event.getAction() == MotionEvent.ACTION_UP) {
176 new DatePickerDialog(getContext(), date, myCalendar 181 new DatePickerDialog(getContext(), date, myCalendar
177 .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), 182 .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
178 myCalendar.get(Calendar.DAY_OF_MONTH)).show(); 183 myCalendar.get(Calendar.DAY_OF_MONTH)).show();
@@ -184,13 +189,13 @@ public class CreatePersonne extends DialogFragment implements NFCSupport { @@ -184,13 +189,13 @@ public class CreatePersonne extends DialogFragment implements NFCSupport {
184 return dialog; 189 return dialog;
185 } 190 }
186 191
187 - private void changeRolePossibility(){  
188 - JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, VolleyUtils.baseUri + "/role" ,null , new Response.Listener<JSONArray>() { 192 + private void changeRolePossibility() {
  193 + JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, VolleyUtils.baseUri + "/role", null, new Response.Listener<JSONArray>() {
189 @Override 194 @Override
190 public void onResponse(JSONArray response) { 195 public void onResponse(JSONArray response) {
191 try { 196 try {
192 arraySpinnerRole.clear(); 197 arraySpinnerRole.clear();
193 - for (int i =0; i<response.length();++i){ 198 + for (int i = 0; i < response.length(); ++i) {
194 arraySpinnerRole.add(JsonConverter.getConverter().fromJson(String.valueOf(response.getJSONObject(i)), Role.class)); 199 arraySpinnerRole.add(JsonConverter.getConverter().fromJson(String.valueOf(response.getJSONObject(i)), Role.class));
195 } 200 }
196 adapterRole.notifyDataSetChanged(); 201 adapterRole.notifyDataSetChanged();
@@ -202,7 +207,7 @@ public class CreatePersonne extends DialogFragment implements NFCSupport { @@ -202,7 +207,7 @@ public class CreatePersonne extends DialogFragment implements NFCSupport {
202 }, new Response.ErrorListener() { 207 }, new Response.ErrorListener() {
203 @Override 208 @Override
204 public void onErrorResponse(VolleyError error) { 209 public void onErrorResponse(VolleyError error) {
205 - if(error.networkResponse == null) 210 + if (error.networkResponse == null)
206 Toast.makeText(getContext(), "Verifier votre connection Internet", Toast.LENGTH_LONG).show(); 211 Toast.makeText(getContext(), "Verifier votre connection Internet", Toast.LENGTH_LONG).show();
207 else 212 else
208 Toast.makeText(getContext(), ConvertBytesToString.bytesToStringVolLey(error.networkResponse.data), Toast.LENGTH_LONG).show(); 213 Toast.makeText(getContext(), ConvertBytesToString.bytesToStringVolLey(error.networkResponse.data), Toast.LENGTH_LONG).show();
@@ -213,18 +218,6 @@ public class CreatePersonne extends DialogFragment implements NFCSupport { @@ -213,18 +218,6 @@ public class CreatePersonne extends DialogFragment implements NFCSupport {
213 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonArrayRequest); 218 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonArrayRequest);
214 } 219 }
215 220
216 - DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {  
217 -  
218 - @Override  
219 - public void onDateSet(DatePicker view, int year, int monthOfYear,  
220 - int dayOfMonth) {  
221 - myCalendar.set(Calendar.YEAR, year);  
222 - myCalendar.set(Calendar.MONTH, monthOfYear);  
223 - myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);  
224 - updateLabel();  
225 - }  
226 - };  
227 -  
228 private void updateLabel() { 221 private void updateLabel() {
229 String myFormat = "yyyy-MM-dd"; //In which you need put here 222 String myFormat = "yyyy-MM-dd"; //In which you need put here
230 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE); 223 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE);
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/DeletePersonne.java
@@ -3,6 +3,7 @@ package net.plil.clubinfo.etunicorn.app.personne; @@ -3,6 +3,7 @@ package net.plil.clubinfo.etunicorn.app.personne;
3 import android.app.Dialog; 3 import android.app.Dialog;
4 import android.content.DialogInterface; 4 import android.content.DialogInterface;
5 import android.os.Bundle; 5 import android.os.Bundle;
  6 +import android.support.annotation.NonNull;
6 import android.support.v4.app.DialogFragment; 7 import android.support.v4.app.DialogFragment;
7 import android.support.v7.app.AlertDialog; 8 import android.support.v7.app.AlertDialog;
8 import android.view.LayoutInflater; 9 import android.view.LayoutInflater;
@@ -19,7 +20,6 @@ import com.android.volley.toolbox.JsonObjectRequest; @@ -19,7 +20,6 @@ import com.android.volley.toolbox.JsonObjectRequest;
19 20
20 import net.plil.clubinfo.etunicorn.R; 21 import net.plil.clubinfo.etunicorn.R;
21 import net.plil.clubinfo.etunicorn.app.MainActivity; 22 import net.plil.clubinfo.etunicorn.app.MainActivity;
22 -import net.plil.clubinfo.etunicorn.data.Event;  
23 import net.plil.clubinfo.etunicorn.data.Personne; 23 import net.plil.clubinfo.etunicorn.data.Personne;
24 import net.plil.clubinfo.etunicorn.utils.VolleyUtils; 24 import net.plil.clubinfo.etunicorn.utils.VolleyUtils;
25 25
@@ -33,7 +33,8 @@ public class DeletePersonne extends DialogFragment { @@ -33,7 +33,8 @@ public class DeletePersonne extends DialogFragment {
33 33
34 ProgressBar mProgressBar; 34 ProgressBar mProgressBar;
35 35
36 - public DeletePersonne(){} 36 + public DeletePersonne() {
  37 + }
37 38
38 /** 39 /**
39 * Create a new instance of MyDialogFragment, providing "num" 40 * Create a new instance of MyDialogFragment, providing "num"
@@ -46,20 +47,21 @@ public class DeletePersonne extends DialogFragment { @@ -46,20 +47,21 @@ public class DeletePersonne extends DialogFragment {
46 Bundle args = new Bundle(); 47 Bundle args = new Bundle();
47 args.putSerializable("personne", personne); 48 args.putSerializable("personne", personne);
48 f.setArguments(args); 49 f.setArguments(args);
49 -  
50 return f; 50 return f;
51 } 51 }
52 52
53 53
54 @Override 54 @Override
  55 + @NonNull
55 public Dialog onCreateDialog(Bundle savedInstanceState) { 56 public Dialog onCreateDialog(Bundle savedInstanceState) {
56 // Use the Builder class for convenient dialog construction 57 // Use the Builder class for convenient dialog construction
57 LayoutInflater inflater = getActivity().getLayoutInflater(); 58 LayoutInflater inflater = getActivity().getLayoutInflater();
58 View view = inflater.inflate(R.layout.fragment_delete_personne, null); 59 View view = inflater.inflate(R.layout.fragment_delete_personne, null);
59 60
60 mProgressBar = (ProgressBar) view.findViewById(R.id.delete_personne_progress_bar); 61 mProgressBar = (ProgressBar) view.findViewById(R.id.delete_personne_progress_bar);
61 - final Personne personne = (Personne) getArguments().getSerializable("personne");  
62 62
  63 + final Personne personne = (Personne) getArguments().getSerializable("personne");
  64 + assert personne != null;
63 65
64 AlertDialog dialog = new AlertDialog.Builder(getActivity()) 66 AlertDialog dialog = new AlertDialog.Builder(getActivity())
65 .setTitle(R.string.verif_delete_personne) 67 .setTitle(R.string.verif_delete_personne)
@@ -94,13 +96,14 @@ public class DeletePersonne extends DialogFragment { @@ -94,13 +96,14 @@ public class DeletePersonne extends DialogFragment {
94 Toast.makeText(getContext(), R.string.delete_refused, Toast.LENGTH_LONG).show(); 96 Toast.makeText(getContext(), R.string.delete_refused, Toast.LENGTH_LONG).show();
95 } 97 }
96 } 98 }
97 - ){ 99 + ) {
98 @Override 100 @Override
99 public Map<String, String> getHeaders() throws AuthFailureError { 101 public Map<String, String> getHeaders() throws AuthFailureError {
100 - Map<String, String> headers = new HashMap<String, String>(); 102 + Map<String, String> headers = new HashMap<>();
101 headers.put("Authorization", MainActivity.session.getToken()); 103 headers.put("Authorization", MainActivity.session.getToken());
102 return headers; 104 return headers;
103 - }}; 105 + }
  106 + };
104 jsonObjectRequest.setTag(DeletePersonne.class); 107 jsonObjectRequest.setTag(DeletePersonne.class);
105 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); 108 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
106 } 109 }
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/ModifyPersonne.java
@@ -4,6 +4,7 @@ import android.app.DatePickerDialog; @@ -4,6 +4,7 @@ import android.app.DatePickerDialog;
4 import android.app.Dialog; 4 import android.app.Dialog;
5 import android.content.DialogInterface; 5 import android.content.DialogInterface;
6 import android.os.Bundle; 6 import android.os.Bundle;
  7 +import android.support.annotation.NonNull;
7 import android.support.design.widget.TextInputLayout; 8 import android.support.design.widget.TextInputLayout;
8 import android.support.v4.app.DialogFragment; 9 import android.support.v4.app.DialogFragment;
9 import android.support.v7.app.AlertDialog; 10 import android.support.v7.app.AlertDialog;
@@ -26,8 +27,8 @@ import com.android.volley.toolbox.JsonArrayRequest; @@ -26,8 +27,8 @@ import com.android.volley.toolbox.JsonArrayRequest;
26 import com.android.volley.toolbox.JsonObjectRequest; 27 import com.android.volley.toolbox.JsonObjectRequest;
27 28
28 import net.plil.clubinfo.etunicorn.R; 29 import net.plil.clubinfo.etunicorn.R;
29 -import net.plil.clubinfo.etunicorn.app.NFCSupport;  
30 import net.plil.clubinfo.etunicorn.app.MainActivity; 30 import net.plil.clubinfo.etunicorn.app.MainActivity;
  31 +import net.plil.clubinfo.etunicorn.app.NFCSupport;
31 import net.plil.clubinfo.etunicorn.data.Personne; 32 import net.plil.clubinfo.etunicorn.data.Personne;
32 import net.plil.clubinfo.etunicorn.data.Role; 33 import net.plil.clubinfo.etunicorn.data.Role;
33 import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; 34 import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString;
@@ -62,7 +63,17 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport { @@ -62,7 +63,17 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport {
62 63
63 private String[] arraySpinnerNaissance; 64 private String[] arraySpinnerNaissance;
64 private ArrayAdapter<String> adapterNaissance; 65 private ArrayAdapter<String> adapterNaissance;
  66 + DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
65 67
  68 + @Override
  69 + public void onDateSet(DatePicker view, int year, int monthOfYear,
  70 + int dayOfMonth) {
  71 + myCalendar.set(Calendar.YEAR, year);
  72 + myCalendar.set(Calendar.MONTH, monthOfYear);
  73 + myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
  74 + updateLabel();
  75 + }
  76 + };
66 private List<Role> arraySpinnerRole; 77 private List<Role> arraySpinnerRole;
67 private ArrayAdapter<Role> adapterRole; 78 private ArrayAdapter<Role> adapterRole;
68 79
@@ -77,10 +88,10 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport { @@ -77,10 +88,10 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport {
77 return f; 88 return f;
78 } 89 }
79 90
80 -  
81 @Override 91 @Override
  92 + @NonNull
82 public Dialog onCreateDialog(Bundle savedInstanceState) { 93 public Dialog onCreateDialog(Bundle savedInstanceState) {
83 - myCalendar.set(Calendar.YEAR, myCalendar.get(Calendar.YEAR)-18); 94 + myCalendar.set(Calendar.YEAR, myCalendar.get(Calendar.YEAR) - 18);
84 // Use the Builder class for convenient dialog construction 95 // Use the Builder class for convenient dialog construction
85 LayoutInflater inflater = getActivity().getLayoutInflater(); 96 LayoutInflater inflater = getActivity().getLayoutInflater();
86 View view = inflater.inflate(R.layout.fragment_modify_personne, null); 97 View view = inflater.inflate(R.layout.fragment_modify_personne, null);
@@ -94,6 +105,7 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport { @@ -94,6 +105,7 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport {
94 mCarteInput = (TextInputLayout) view.findViewById(R.id.modify_personne_carte_input); 105 mCarteInput = (TextInputLayout) view.findViewById(R.id.modify_personne_carte_input);
95 106
96 final Personne personne = (Personne) getArguments().getSerializable("personne"); 107 final Personne personne = (Personne) getArguments().getSerializable("personne");
  108 + assert personne != null;
97 109
98 mCarte.setText(personne.getCarte()); 110 mCarte.setText(personne.getCarte());
99 mLogin.setText(personne.getLogin()); 111 mLogin.setText(personne.getLogin());
@@ -107,7 +119,7 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport { @@ -107,7 +119,7 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport {
107 mNaissance = (Spinner) view.findViewById(R.id.modify_personne_naissance); 119 mNaissance = (Spinner) view.findViewById(R.id.modify_personne_naissance);
108 final String myFormat = "yyyy-MM-dd"; //In which you need put here 120 final String myFormat = "yyyy-MM-dd"; //In which you need put here
109 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE); 121 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE);
110 - if (personne.getNaissance() == null){ 122 + if (personne.getNaissance() == null) {
111 arraySpinnerNaissance = new String[]{ 123 arraySpinnerNaissance = new String[]{
112 getString(R.string.modify_personne_hint_date) 124 getString(R.string.modify_personne_hint_date)
113 }; 125 };
@@ -116,7 +128,7 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport { @@ -116,7 +128,7 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport {
116 sdf.format(personne.getNaissance()) 128 sdf.format(personne.getNaissance())
117 }; 129 };
118 } 130 }
119 - adapterNaissance = new ArrayAdapter<String>(getActivity(), 131 + adapterNaissance = new ArrayAdapter<>(getActivity(),
120 R.layout.simple_item_layout, arraySpinnerNaissance); 132 R.layout.simple_item_layout, arraySpinnerNaissance);
121 mNaissance.setAdapter(adapterNaissance); 133 mNaissance.setAdapter(adapterNaissance);
122 134
@@ -150,10 +162,10 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport { @@ -150,10 +162,10 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport {
150 jsonObject.put("role", JsonConverter.convertToJSONObject(mRole.getSelectedItem())); 162 jsonObject.put("role", JsonConverter.convertToJSONObject(mRole.getSelectedItem()));
151 if (!mNaissance.getSelectedItem().equals(getString(R.string.modify_personne_hint_date))) 163 if (!mNaissance.getSelectedItem().equals(getString(R.string.modify_personne_hint_date)))
152 jsonObject.put("naissance", mNaissance.getSelectedItem().toString()); 164 jsonObject.put("naissance", mNaissance.getSelectedItem().toString());
153 - } catch (JSONException e){ 165 + } catch (JSONException e) {
154 e.printStackTrace(); 166 e.printStackTrace();
155 } 167 }
156 - JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.PUT, VolleyUtils.baseUri + "/personne/" + personne.getId() ,jsonObject , new Response.Listener<JSONObject>() { 168 + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.PUT, VolleyUtils.baseUri + "/personne/" + personne.getId(), jsonObject, new Response.Listener<JSONObject>() {
157 @Override 169 @Override
158 public void onResponse(JSONObject response) { 170 public void onResponse(JSONObject response) {
159 mProgressBar.setVisibility(View.GONE); 171 mProgressBar.setVisibility(View.GONE);
@@ -168,24 +180,25 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport { @@ -168,24 +180,25 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport {
168 if (error.networkResponse != null) 180 if (error.networkResponse != null)
169 Toast.makeText(getContext(), R.string.modify_refused + " : " + ConvertBytesToString.bytesToStringVolLey(error.networkResponse.data), Toast.LENGTH_LONG).show(); 181 Toast.makeText(getContext(), R.string.modify_refused + " : " + ConvertBytesToString.bytesToStringVolLey(error.networkResponse.data), Toast.LENGTH_LONG).show();
170 else 182 else
171 - Toast.makeText(getContext(), "!!" + error.getStackTrace().toString(), Toast.LENGTH_SHORT).show(); 183 + Toast.makeText(getContext(), "!!" + error.getMessage(), Toast.LENGTH_SHORT).show();
172 mRole.setVisibility(View.VISIBLE); 184 mRole.setVisibility(View.VISIBLE);
173 mCarteInput.setVisibility(View.VISIBLE); 185 mCarteInput.setVisibility(View.VISIBLE);
174 mLoginInput.setVisibility(View.VISIBLE); 186 mLoginInput.setVisibility(View.VISIBLE);
175 mNaissance.setVisibility(View.VISIBLE); 187 mNaissance.setVisibility(View.VISIBLE);
176 } 188 }
177 } 189 }
178 - ){ 190 + ) {
179 @Override 191 @Override
180 public Map<String, String> getHeaders() throws AuthFailureError { 192 public Map<String, String> getHeaders() throws AuthFailureError {
181 - Map<String, String> headers = new HashMap<String, String>(); 193 + Map<String, String> headers = new HashMap<>();
182 headers.put("Authorization", MainActivity.session.getToken()); 194 headers.put("Authorization", MainActivity.session.getToken());
183 return headers; 195 return headers;
184 - }}; 196 + }
  197 + };
185 jsonObjectRequest.setTag(ModifyPersonne.class); 198 jsonObjectRequest.setTag(ModifyPersonne.class);
186 199
187 try { 200 try {
188 - for (String s : jsonObjectRequest.getHeaders().keySet()){ 201 + for (String s : jsonObjectRequest.getHeaders().keySet()) {
189 System.out.println(s + " " + jsonObjectRequest.getHeaders().get(s)); 202 System.out.println(s + " " + jsonObjectRequest.getHeaders().get(s));
190 } 203 }
191 } catch (AuthFailureError authFailureError) { 204 } catch (AuthFailureError authFailureError) {
@@ -201,7 +214,7 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport { @@ -201,7 +214,7 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport {
201 mNaissance.setOnTouchListener(new View.OnTouchListener() { 214 mNaissance.setOnTouchListener(new View.OnTouchListener() {
202 @Override 215 @Override
203 public boolean onTouch(View v, MotionEvent event) { 216 public boolean onTouch(View v, MotionEvent event) {
204 - if(event.getAction() == MotionEvent.ACTION_UP) { 217 + if (event.getAction() == MotionEvent.ACTION_UP) {
205 new DatePickerDialog(getContext(), date, myCalendar 218 new DatePickerDialog(getContext(), date, myCalendar
206 .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), 219 .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
207 myCalendar.get(Calendar.DAY_OF_MONTH)).show(); 220 myCalendar.get(Calendar.DAY_OF_MONTH)).show();
@@ -213,18 +226,6 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport { @@ -213,18 +226,6 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport {
213 return dialog; 226 return dialog;
214 } 227 }
215 228
216 - DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {  
217 -  
218 - @Override  
219 - public void onDateSet(DatePicker view, int year, int monthOfYear,  
220 - int dayOfMonth) {  
221 - myCalendar.set(Calendar.YEAR, year);  
222 - myCalendar.set(Calendar.MONTH, monthOfYear);  
223 - myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);  
224 - updateLabel();  
225 - }  
226 - };  
227 -  
228 private void updateLabel() { 229 private void updateLabel() {
229 String myFormat = "yyyy-MM-dd"; //In which you need put here 230 String myFormat = "yyyy-MM-dd"; //In which you need put here
230 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE); 231 SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE);
@@ -240,13 +241,13 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport { @@ -240,13 +241,13 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport {
240 super.onStop(); 241 super.onStop();
241 } 242 }
242 243
243 - private void changeRolePossibility(){  
244 - JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, VolleyUtils.baseUri + "/role" ,null , new Response.Listener<JSONArray>() { 244 + private void changeRolePossibility() {
  245 + JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, VolleyUtils.baseUri + "/role", null, new Response.Listener<JSONArray>() {
245 @Override 246 @Override
246 public void onResponse(JSONArray response) { 247 public void onResponse(JSONArray response) {
247 try { 248 try {
248 arraySpinnerRole.clear(); 249 arraySpinnerRole.clear();
249 - for (int i =0; i<response.length();++i){ 250 + for (int i = 0; i < response.length(); ++i) {
250 arraySpinnerRole.add(JsonConverter.getConverter().fromJson(String.valueOf(response.getJSONObject(i)), Role.class)); 251 arraySpinnerRole.add(JsonConverter.getConverter().fromJson(String.valueOf(response.getJSONObject(i)), Role.class));
251 } 252 }
252 adapterRole.notifyDataSetChanged(); 253 adapterRole.notifyDataSetChanged();
@@ -258,7 +259,7 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport { @@ -258,7 +259,7 @@ public class ModifyPersonne extends DialogFragment implements NFCSupport {
258 }, new Response.ErrorListener() { 259 }, new Response.ErrorListener() {
259 @Override 260 @Override
260 public void onErrorResponse(VolleyError error) { 261 public void onErrorResponse(VolleyError error) {
261 - if(error.networkResponse == null) 262 + if (error.networkResponse == null)
262 Toast.makeText(getContext(), "Verifier votre connection Internet", Toast.LENGTH_LONG).show(); 263 Toast.makeText(getContext(), "Verifier votre connection Internet", Toast.LENGTH_LONG).show();
263 else 264 else
264 Toast.makeText(getContext(), ConvertBytesToString.bytesToStringVolLey(error.networkResponse.data), Toast.LENGTH_LONG).show(); 265 Toast.makeText(getContext(), ConvertBytesToString.bytesToStringVolLey(error.networkResponse.data), Toast.LENGTH_LONG).show();
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/MyPersonneRecyclerViewAdapter.java
@@ -16,14 +16,14 @@ import net.plil.clubinfo.etunicorn.data.Personne; @@ -16,14 +16,14 @@ import net.plil.clubinfo.etunicorn.data.Personne;
16 import java.util.List; 16 import java.util.List;
17 import java.util.Locale; 17 import java.util.Locale;
18 18
19 -public class MyPersonneRecyclerViewAdapter extends RecyclerView.Adapter<MyPersonneRecyclerViewAdapter.ViewHolder> { 19 +class MyPersonneRecyclerViewAdapter extends RecyclerView.Adapter<MyPersonneRecyclerViewAdapter.ViewHolder> {
20 20
21 private final List<Personne> mValues; 21 private final List<Personne> mValues;
22 private final PersonneFragment.OnListFragmentInteractionListener mListener; 22 private final PersonneFragment.OnListFragmentInteractionListener mListener;
23 private final Context context; 23 private final Context context;
24 24
25 25
26 - public MyPersonneRecyclerViewAdapter(List<Personne> items, PersonneFragment.OnListFragmentInteractionListener listener, Context context) { 26 + MyPersonneRecyclerViewAdapter(List<Personne> items, PersonneFragment.OnListFragmentInteractionListener listener, Context context) {
27 mValues = items; 27 mValues = items;
28 mListener = listener; 28 mListener = listener;
29 this.context = context; 29 this.context = context;
@@ -88,16 +88,16 @@ public class MyPersonneRecyclerViewAdapter extends RecyclerView.Adapter&lt;MyPerson @@ -88,16 +88,16 @@ public class MyPersonneRecyclerViewAdapter extends RecyclerView.Adapter&lt;MyPerson
88 return mValues.size(); 88 return mValues.size();
89 } 89 }
90 90
91 - public class ViewHolder extends RecyclerView.ViewHolder {  
92 - public final View mView;  
93 - public final TextView mLogin;  
94 - public final TextView mCarte;  
95 - public final TextView mRole;  
96 - public final TextView mSolde;  
97 - public final TextView mButton;  
98 - public Personne mItem; 91 + class ViewHolder extends RecyclerView.ViewHolder {
  92 + final View mView;
  93 + final TextView mLogin;
  94 + final TextView mCarte;
  95 + final TextView mRole;
  96 + final TextView mSolde;
  97 + final TextView mButton;
  98 + Personne mItem;
99 99
100 - public ViewHolder(View view) { 100 + ViewHolder(View view) {
101 super(view); 101 super(view);
102 mView = view; 102 mView = view;
103 mLogin = (TextView) view.findViewById(R.id.personne_login); 103 mLogin = (TextView) view.findViewById(R.id.personne_login);
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/PersonOverviewFragment.java
1 package net.plil.clubinfo.etunicorn.app.personne; 1 package net.plil.clubinfo.etunicorn.app.personne;
2 2
3 import android.app.Dialog; 3 import android.app.Dialog;
4 -import android.content.Context;  
5 -import android.net.Uri;  
6 import android.os.Bundle; 4 import android.os.Bundle;
  5 +import android.support.annotation.NonNull;
7 import android.support.v4.app.DialogFragment; 6 import android.support.v4.app.DialogFragment;
8 -import android.support.v4.app.Fragment;  
9 import android.support.v7.app.AlertDialog; 7 import android.support.v7.app.AlertDialog;
10 import android.view.LayoutInflater; 8 import android.view.LayoutInflater;
11 import android.view.View; 9 import android.view.View;
@@ -15,16 +13,10 @@ import android.widget.TextView; @@ -15,16 +13,10 @@ import android.widget.TextView;
15 import net.plil.clubinfo.etunicorn.R; 13 import net.plil.clubinfo.etunicorn.R;
16 import net.plil.clubinfo.etunicorn.data.Personne; 14 import net.plil.clubinfo.etunicorn.data.Personne;
17 15
18 -import java.text.SimpleDateFormat;  
19 import java.util.Locale; 16 import java.util.Locale;
20 17
21 -/**  
22 - * A simple {@link Fragment} subclass.  
23 - * Activities that contain this fragment must implement the  
24 - * {@link PersonOverviewFragment.OnFragmentInteractionListener} interface  
25 - * to handle interaction events.  
26 - */  
27 -public class PersonOverviewFragment extends DialogFragment{ 18 +
  19 +public class PersonOverviewFragment extends DialogFragment {
28 20
29 TextView mCarte; 21 TextView mCarte;
30 TextView mNaissance; 22 TextView mNaissance;
@@ -45,7 +37,8 @@ public class PersonOverviewFragment extends DialogFragment{ @@ -45,7 +37,8 @@ public class PersonOverviewFragment extends DialogFragment{
45 } 37 }
46 38
47 @Override 39 @Override
48 - public Dialog onCreateDialog(Bundle savedInstanceState){ 40 + @NonNull
  41 + public Dialog onCreateDialog(Bundle savedInstanceState) {
49 LayoutInflater inflater = getActivity().getLayoutInflater(); 42 LayoutInflater inflater = getActivity().getLayoutInflater();
50 View view = inflater.inflate(R.layout.fragment_person_overview, null); 43 View view = inflater.inflate(R.layout.fragment_person_overview, null);
51 44
@@ -60,7 +53,7 @@ public class PersonOverviewFragment extends DialogFragment{ @@ -60,7 +53,7 @@ public class PersonOverviewFragment extends DialogFragment{
60 assert personne != null; 53 assert personne != null;
61 mCarte.setText(personne.getCarte()); 54 mCarte.setText(personne.getCarte());
62 mRole.setText(personne.getRole().getNom()); 55 mRole.setText(personne.getRole().getNom());
63 - mSolde.setText(String.format(Locale.US, "%.2f",personne.getSolde())); 56 + mSolde.setText(String.format(Locale.US, "%.2f", personne.getSolde()));
64 if (personne.getNaissance() != null) 57 if (personne.getNaissance() != null)
65 mNaissance.setText(personne.getNaissance().toString()); 58 mNaissance.setText(personne.getNaissance().toString());
66 mLogin.setText(personne.getLogin()); 59 mLogin.setText(personne.getLogin());
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/PersonneFragment.java
@@ -20,8 +20,8 @@ import com.android.volley.VolleyError; @@ -20,8 +20,8 @@ import com.android.volley.VolleyError;
20 import com.android.volley.toolbox.JsonArrayRequest; 20 import com.android.volley.toolbox.JsonArrayRequest;
21 21
22 import net.plil.clubinfo.etunicorn.R; 22 import net.plil.clubinfo.etunicorn.R;
23 -import net.plil.clubinfo.etunicorn.app.NFCSupport;  
24 import net.plil.clubinfo.etunicorn.app.MainActivity; 23 import net.plil.clubinfo.etunicorn.app.MainActivity;
  24 +import net.plil.clubinfo.etunicorn.app.NFCSupport;
25 import net.plil.clubinfo.etunicorn.data.Personne; 25 import net.plil.clubinfo.etunicorn.data.Personne;
26 import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; 26 import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString;
27 import net.plil.clubinfo.etunicorn.utils.JsonConverter; 27 import net.plil.clubinfo.etunicorn.utils.JsonConverter;
@@ -119,13 +119,13 @@ public class PersonneFragment extends Fragment implements NFCSupport { @@ -119,13 +119,13 @@ public class PersonneFragment extends Fragment implements NFCSupport {
119 mListener = null; 119 mListener = null;
120 } 120 }
121 121
122 - private void setPersonnes(){  
123 - JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, VolleyUtils.baseUri + "/personne" ,null , new Response.Listener<JSONArray>() { 122 + private void setPersonnes() {
  123 + JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, VolleyUtils.baseUri + "/personne", null, new Response.Listener<JSONArray>() {
124 @Override 124 @Override
125 public void onResponse(JSONArray response) { 125 public void onResponse(JSONArray response) {
126 try { 126 try {
127 personnes.clear(); 127 personnes.clear();
128 - for (int i =0; i<response.length();++i){ 128 + for (int i = 0; i < response.length(); ++i) {
129 personnes.add(JsonConverter.getConverter().fromJson(String.valueOf(response.getJSONObject(i)), Personne.class)); 129 personnes.add(JsonConverter.getConverter().fromJson(String.valueOf(response.getJSONObject(i)), Personne.class));
130 } 130 }
131 mAdapter.notifyDataSetChanged(); 131 mAdapter.notifyDataSetChanged();
@@ -159,11 +159,13 @@ public class PersonneFragment extends Fragment implements NFCSupport { @@ -159,11 +159,13 @@ public class PersonneFragment extends Fragment implements NFCSupport {
159 @Override 159 @Override
160 public void processNFC(String idCardUser) { 160 public void processNFC(String idCardUser) {
161 CreatePersonne createPersonne = (CreatePersonne) getFragmentManager().findFragmentByTag(getString(R.string.tag_create_personne)); 161 CreatePersonne createPersonne = (CreatePersonne) getFragmentManager().findFragmentByTag(getString(R.string.tag_create_personne));
162 - if (createPersonne != null){ 162 + if (createPersonne != null) {
163 createPersonne.processNFC(idCardUser); 163 createPersonne.processNFC(idCardUser);
164 - }  
165 - else { 164 + } else {
166 ModifyPersonne modifyPersonne = (ModifyPersonne) getFragmentManager().findFragmentByTag(getString(R.string.tag_modify_personne)); 165 ModifyPersonne modifyPersonne = (ModifyPersonne) getFragmentManager().findFragmentByTag(getString(R.string.tag_modify_personne));
  166 + if (modifyPersonne != null){
  167 + modifyPersonne.processNFC(idCardUser);
  168 + }
167 } 169 }
168 170
169 } 171 }