Commit db2235673b427d787101e29d2eecc3ac4529c218
1 parent
c0f970a0
Evenement modify beautiful dialog
Showing
8 changed files
with
284 additions
and
75 deletions
Show diff stats
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/CreateEvent.java
1 | 1 | package net.plil.clubinfo.etunicorn.app.event; |
2 | 2 | |
3 | +import android.app.DatePickerDialog; | |
3 | 4 | import android.app.Dialog; |
4 | 5 | import android.content.DialogInterface; |
5 | 6 | import android.os.Bundle; |
7 | +import android.support.design.widget.TextInputLayout; | |
6 | 8 | import android.support.v4.app.DialogFragment; |
7 | 9 | import android.support.v7.app.AlertDialog; |
8 | 10 | import android.view.LayoutInflater; |
11 | +import android.view.MotionEvent; | |
9 | 12 | import android.view.View; |
13 | +import android.widget.ArrayAdapter; | |
14 | +import android.widget.Button; | |
15 | +import android.widget.DatePicker; | |
10 | 16 | import android.widget.EditText; |
11 | 17 | import android.widget.ProgressBar; |
18 | +import android.widget.Spinner; | |
19 | +import android.widget.Toast; | |
12 | 20 | |
13 | 21 | import com.android.volley.Request; |
14 | 22 | import com.android.volley.Response; |
... | ... | @@ -16,18 +24,31 @@ import com.android.volley.VolleyError; |
16 | 24 | import com.android.volley.toolbox.JsonObjectRequest; |
17 | 25 | |
18 | 26 | import net.plil.clubinfo.etunicorn.R; |
19 | -import net.plil.clubinfo.etunicorn.app.consommation.ModifyConsommation; | |
20 | 27 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; |
21 | 28 | |
22 | 29 | import org.json.JSONException; |
23 | 30 | import org.json.JSONObject; |
24 | 31 | |
32 | +import java.text.SimpleDateFormat; | |
33 | +import java.util.Calendar; | |
34 | +import java.util.Locale; | |
35 | + | |
25 | 36 | |
26 | 37 | public class CreateEvent extends DialogFragment { |
27 | 38 | |
39 | + Calendar myCalendar = Calendar.getInstance(); | |
40 | + | |
41 | + | |
28 | 42 | EditText mName; |
29 | 43 | EditText mPrice; |
30 | - EditText mDate; | |
44 | + Spinner mDate; | |
45 | + | |
46 | + TextInputLayout mPriceInput; | |
47 | + TextInputLayout mNameInput; | |
48 | + | |
49 | + private String[] arraySpinnerDate; | |
50 | + private ArrayAdapter<String> adapterDate; | |
51 | + | |
31 | 52 | ProgressBar mProgressBar; |
32 | 53 | |
33 | 54 | |
... | ... | @@ -38,46 +59,99 @@ public class CreateEvent extends DialogFragment { |
38 | 59 | View view = inflater.inflate(R.layout.fragment_create_event, null); |
39 | 60 | mName = (EditText) view.findViewById(R.id.create_event_name); |
40 | 61 | mPrice = (EditText) view.findViewById(R.id.create_event_price); |
41 | - mDate = (EditText) view.findViewById(R.id.create_event_date); | |
62 | + mDate = (Spinner) view.findViewById(R.id.create_event_date); | |
63 | + mPriceInput = (TextInputLayout) view.findViewById(R.id.create_event_price_input); | |
64 | + mNameInput = (TextInputLayout) view.findViewById(R.id.create_event_name_input); | |
65 | + arraySpinnerDate = new String[] { | |
66 | + getString(R.string.create_event_date_input) | |
67 | + }; | |
68 | + adapterDate = new ArrayAdapter<>(getActivity(), | |
69 | + R.layout.simple_item_layout, arraySpinnerDate); | |
70 | + mDate.setAdapter(adapterDate); | |
71 | + | |
42 | 72 | mProgressBar = (ProgressBar) view.findViewById(R.id.create_event_progress_bar); |
43 | 73 | AlertDialog dialog = new AlertDialog.Builder(getActivity()) |
44 | 74 | .setTitle(R.string.create_event) |
45 | 75 | .setView(view) |
46 | - .setPositiveButton(R.string.valid, new DialogInterface.OnClickListener() { | |
76 | + .setPositiveButton(R.string.valid, null) | |
77 | + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | |
47 | 78 | public void onClick(DialogInterface dialog, int id) { |
79 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(CreateEvent.class); | |
80 | + } | |
81 | + }).create(); | |
82 | + | |
83 | + mDate.setOnTouchListener(new View.OnTouchListener() { | |
84 | + @Override | |
85 | + public boolean onTouch(View v, MotionEvent event) { | |
86 | + if(event.getAction() == MotionEvent.ACTION_UP) { | |
87 | + new DatePickerDialog(getContext(), date, myCalendar | |
88 | + .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), | |
89 | + myCalendar.get(Calendar.DAY_OF_MONTH)).show(); | |
90 | + } | |
91 | + return true; | |
92 | + } | |
93 | + }); | |
48 | 94 | |
49 | - mProgressBar.setVisibility(View.VISIBLE); | |
50 | - mPrice.setVisibility(View.GONE); | |
51 | - mName.setVisibility(View.GONE); | |
52 | - JSONObject jsonObject = new JSONObject(); | |
53 | - try { | |
54 | - jsonObject.put("nomEvenement", mName.getText().toString()); | |
55 | - jsonObject.put("prix", Double.parseDouble(mPrice.getText().toString())); | |
56 | - jsonObject.put("date", mDate.getText().toString()); | |
57 | - } catch (JSONException e){ | |
58 | - e.printStackTrace(); | |
95 | + dialog.setOnShowListener(new DialogInterface.OnShowListener() { | |
96 | + @Override | |
97 | + public void onShow(DialogInterface dialog) { | |
98 | + Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); | |
99 | + button.setOnClickListener(new View.OnClickListener() { | |
100 | + @Override | |
101 | + public void onClick(View v) { | |
102 | + boolean testDateInputOk = true; | |
103 | + if (mPrice.getText().toString().isEmpty()) { | |
104 | + mPriceInput.setError(getString(R.string.error_create_event_input_price)); | |
105 | + testDateInputOk = false; | |
106 | + } else { | |
107 | + mPriceInput.setError(null); | |
59 | 108 | } |
60 | - JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/evenement" ,jsonObject , new Response.Listener<JSONObject>() { | |
61 | - @Override | |
62 | - public void onResponse(JSONObject response) { | |
63 | - mProgressBar.setVisibility(View.GONE); | |
109 | + if (mName.getText().toString().isEmpty()){ | |
110 | + mNameInput.setError(getString(R.string.error_create_event_input_nom)); | |
111 | + testDateInputOk = false; | |
112 | + } else { | |
113 | + mNameInput.setError(null); | |
114 | + } | |
115 | + if (((String)mDate.getSelectedItem()).equals(getString(R.string.create_event_date))) { | |
116 | + testDateInputOk = false; | |
117 | + Toast.makeText(getContext(), getString(R.string.error_create_event_date), Toast.LENGTH_LONG).show(); | |
118 | + } | |
119 | + if (testDateInputOk) { | |
120 | + mProgressBar.setVisibility(View.VISIBLE); | |
121 | + mPriceInput.setVisibility(View.GONE); | |
122 | + mNameInput.setVisibility(View.GONE); | |
123 | + mDate.setVisibility(View.GONE); | |
124 | + JSONObject jsonObject = new JSONObject(); | |
125 | + try { | |
126 | + jsonObject.put("nom", mName.getText().toString()); | |
127 | + jsonObject.put("prix", Double.parseDouble(mPrice.getText().toString())); | |
128 | + jsonObject.put("date", mDate.getAdapter().getItem(0)); | |
129 | + } catch (JSONException e){ | |
130 | + e.printStackTrace(); | |
64 | 131 | } |
65 | - }, new Response.ErrorListener() { | |
66 | - @Override | |
67 | - public void onErrorResponse(VolleyError error) { | |
68 | - mProgressBar.setVisibility(View.GONE); | |
132 | + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/evenement" ,jsonObject , new Response.Listener<JSONObject>() { | |
133 | + @Override | |
134 | + public void onResponse(JSONObject response) { | |
135 | + mProgressBar.setVisibility(View.GONE); | |
136 | + } | |
137 | + }, new Response.ErrorListener() { | |
138 | + @Override | |
139 | + public void onErrorResponse(VolleyError error) { | |
140 | + mProgressBar.setVisibility(View.GONE); | |
141 | + mPriceInput.setVisibility(View.VISIBLE); | |
142 | + mNameInput.setVisibility(View.VISIBLE); | |
143 | + mDate.setVisibility(View.VISIBLE); | |
144 | + Toast.makeText(getContext(), error.getMessage(), Toast.LENGTH_LONG).show(); | |
145 | + } | |
69 | 146 | } |
147 | + ); | |
148 | + jsonObjectRequest.setTag(CreateEvent.class); | |
149 | + VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | |
70 | 150 | } |
71 | - ); | |
72 | - jsonObjectRequest.setTag(CreateEvent.class); | |
73 | - VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | |
74 | - } | |
75 | - }) | |
76 | - .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | |
77 | - public void onClick(DialogInterface dialog, int id) { | |
78 | - VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(CreateEvent.class); | |
79 | 151 | } |
80 | - }).create(); | |
152 | + }); | |
153 | + } | |
154 | + }); | |
81 | 155 | dialog.setCanceledOnTouchOutside(false); |
82 | 156 | return dialog; |
83 | 157 | } |
... | ... | @@ -89,4 +163,23 @@ public class CreateEvent extends DialogFragment { |
89 | 163 | super.onStop(); |
90 | 164 | } |
91 | 165 | |
166 | + DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() { | |
167 | + | |
168 | + @Override | |
169 | + public void onDateSet(DatePicker view, int year, int monthOfYear, | |
170 | + int dayOfMonth) { | |
171 | + myCalendar.set(Calendar.YEAR, year); | |
172 | + myCalendar.set(Calendar.MONTH, monthOfYear); | |
173 | + myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); | |
174 | + updateLabel(); | |
175 | + } | |
176 | + }; | |
177 | + | |
178 | + private void updateLabel() { | |
179 | + String myFormat = "yyyy-MM-dd"; //In which you need put here | |
180 | + SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE); | |
181 | + arraySpinnerDate[0] = sdf.format(myCalendar.getTime()); | |
182 | + adapterDate.notifyDataSetChanged(); | |
183 | + } | |
184 | + | |
92 | 185 | } | ... | ... |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/DeleteEvent.java
... | ... | @@ -7,6 +7,7 @@ import android.support.v4.app.DialogFragment; |
7 | 7 | import android.support.v7.app.AlertDialog; |
8 | 8 | import android.view.LayoutInflater; |
9 | 9 | import android.view.View; |
10 | +import android.widget.Button; | |
10 | 11 | import android.widget.ProgressBar; |
11 | 12 | import android.widget.Toast; |
12 | 13 | |
... | ... | @@ -51,16 +52,27 @@ public class DeleteEvent extends DialogFragment { |
51 | 52 | LayoutInflater inflater = getActivity().getLayoutInflater(); |
52 | 53 | View view = inflater.inflate(R.layout.fragment_delete_event, null); |
53 | 54 | |
54 | - mProgressBar = (ProgressBar) view.findViewById(R.id.delete_consommation_progress_bar); | |
55 | - final Event event = (Event) getArguments().getSerializable("event"); | |
55 | + mProgressBar = (ProgressBar) view.findViewById(R.id.delete_event_progress_bar); | |
56 | + final Event event = (Event) getArguments().getSerializable("evenement"); | |
56 | 57 | |
57 | 58 | |
58 | 59 | AlertDialog dialog = new AlertDialog.Builder(getActivity()) |
59 | 60 | .setTitle(R.string.verif_delete_event) |
60 | 61 | .setView(view) |
61 | - .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { | |
62 | + .setPositiveButton(R.string.delete, null) | |
63 | + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | |
64 | + public void onClick(DialogInterface dialog, int id) { | |
65 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(DeleteEvent.class); | |
66 | + } | |
67 | + }).create(); | |
68 | + dialog.setCanceledOnTouchOutside(false); | |
69 | + dialog.setOnShowListener(new DialogInterface.OnShowListener() { | |
70 | + @Override | |
71 | + public void onShow(DialogInterface dialog) { | |
72 | + Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); | |
73 | + button.setOnClickListener(new View.OnClickListener() { | |
62 | 74 | @Override |
63 | - public void onClick(DialogInterface dialog, int which) { | |
75 | + public void onClick(View v) { | |
64 | 76 | mProgressBar.setVisibility(View.VISIBLE); |
65 | 77 | |
66 | 78 | JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.DELETE, VolleyUtils.baseUri + "/evenement/" + event.getIdEvent(), null, new Response.Listener<JSONObject>() { |
... | ... | @@ -75,20 +87,14 @@ public class DeleteEvent extends DialogFragment { |
75 | 87 | public void onErrorResponse(VolleyError error) { |
76 | 88 | mProgressBar.setVisibility(View.GONE); |
77 | 89 | Toast.makeText(getContext(), R.string.delete_refused, Toast.LENGTH_LONG).show(); |
78 | - dismiss(); | |
79 | 90 | } |
80 | 91 | } |
81 | 92 | ); |
82 | 93 | jsonObjectRequest.setTag(DeleteEvent.class); |
83 | 94 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); |
84 | 95 | } |
85 | - }) | |
86 | - .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | |
87 | - public void onClick(DialogInterface dialog, int id) { | |
88 | - VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(DeleteEvent.class); | |
89 | - } | |
90 | - }).create(); | |
91 | - dialog.setCanceledOnTouchOutside(false); | |
96 | + }); | |
97 | + }}); | |
92 | 98 | return dialog; |
93 | 99 | } |
94 | 100 | ... | ... |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/ModifyEvent.java
1 | 1 | package net.plil.clubinfo.etunicorn.app.event; |
2 | 2 | |
3 | +import android.app.DatePickerDialog; | |
3 | 4 | import android.app.Dialog; |
4 | 5 | import android.content.DialogInterface; |
5 | 6 | import android.os.Bundle; |
7 | +import android.support.design.widget.TextInputLayout; | |
6 | 8 | import android.support.v4.app.DialogFragment; |
7 | 9 | import android.support.v7.app.AlertDialog; |
8 | 10 | import android.view.LayoutInflater; |
11 | +import android.view.MotionEvent; | |
9 | 12 | import android.view.View; |
13 | +import android.widget.ArrayAdapter; | |
14 | +import android.widget.Button; | |
15 | +import android.widget.DatePicker; | |
10 | 16 | import android.widget.EditText; |
11 | 17 | import android.widget.ProgressBar; |
18 | +import android.widget.Spinner; | |
12 | 19 | import android.widget.Toast; |
13 | 20 | |
14 | 21 | import com.android.volley.Request; |
... | ... | @@ -23,16 +30,25 @@ import net.plil.clubinfo.etunicorn.utils.VolleyUtils; |
23 | 30 | import org.json.JSONException; |
24 | 31 | import org.json.JSONObject; |
25 | 32 | |
33 | +import java.text.SimpleDateFormat; | |
34 | +import java.util.Calendar; | |
26 | 35 | import java.util.Locale; |
27 | 36 | |
28 | 37 | |
29 | 38 | public class ModifyEvent extends DialogFragment { |
30 | 39 | |
40 | + Calendar myCalendar = Calendar.getInstance(); | |
41 | + private String[] arraySpinnerDate; | |
42 | + private ArrayAdapter<String> adapterDate; | |
43 | + | |
31 | 44 | EditText mNom; |
32 | 45 | EditText mPrice; |
33 | - EditText mDate; | |
46 | + Spinner mDate; | |
34 | 47 | ProgressBar mProgressBar; |
35 | 48 | |
49 | + TextInputLayout mNomInput; | |
50 | + TextInputLayout mPriceInput; | |
51 | + | |
36 | 52 | public static ModifyEvent newInstance(Event event) { |
37 | 53 | ModifyEvent f = new ModifyEvent(); |
38 | 54 | |
... | ... | @@ -52,30 +68,64 @@ public class ModifyEvent extends DialogFragment { |
52 | 68 | View view = inflater.inflate(R.layout.fragment_modify_event, null); |
53 | 69 | mNom = (EditText) view.findViewById(R.id.modify_event_name); |
54 | 70 | mPrice = (EditText) view.findViewById(R.id.modify_event_price); |
55 | - mDate = (EditText) view.findViewById(R.id.modify_event_date); | |
71 | + mDate = (Spinner) view.findViewById(R.id.modify_event_date); | |
56 | 72 | mProgressBar = (ProgressBar) view.findViewById(R.id.modify_event_progress_bar); |
73 | + mNomInput = (TextInputLayout) view.findViewById(R.id.modify_event_name_input); | |
74 | + mPriceInput = (TextInputLayout) view.findViewById(R.id.modify_event_price_input); | |
75 | + | |
57 | 76 | |
58 | 77 | final Event event = (Event) getArguments().getSerializable("event"); |
59 | 78 | |
79 | + String myFormat = "yyyy-MM-dd"; //In which you need put here | |
80 | + SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE); | |
81 | + arraySpinnerDate = new String[] { | |
82 | + sdf.format(event.getDate().getTime()) | |
83 | + }; | |
84 | + adapterDate = new ArrayAdapter<>(getActivity(), | |
85 | + R.layout.simple_item_layout, arraySpinnerDate); | |
86 | + mDate.setAdapter(adapterDate); | |
87 | + | |
60 | 88 | mNom.setText(event.getNomEvent()); |
61 | - mPrice.setText(String.format(Locale.FRANCE, "%.2f", event.getPrice())); | |
62 | - mDate.setText(event.getDate().toString()); | |
89 | + mPrice.setText(String.format(Locale.US, "%.2f", event.getPrice())); | |
63 | 90 | |
64 | 91 | AlertDialog dialog = new AlertDialog.Builder(getActivity()) |
65 | 92 | .setTitle(R.string.modify) |
66 | 93 | .setView(view) |
67 | - .setPositiveButton(R.string.modify, new DialogInterface.OnClickListener() { | |
94 | + .setPositiveButton(R.string.modify, null) | |
95 | + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | |
68 | 96 | public void onClick(DialogInterface dialog, int id) { |
69 | - | |
97 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(ModifyEvent.class); | |
98 | + } | |
99 | + }).create(); | |
100 | + // Create the AlertDialog object and return it | |
101 | + mDate.setOnTouchListener(new View.OnTouchListener() { | |
102 | + @Override | |
103 | + public boolean onTouch(View v, MotionEvent event) { | |
104 | + if(event.getAction() == MotionEvent.ACTION_UP) { | |
105 | + new DatePickerDialog(getContext(), date, myCalendar | |
106 | + .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), | |
107 | + myCalendar.get(Calendar.DAY_OF_MONTH)).show(); | |
108 | + } | |
109 | + return true; | |
110 | + } | |
111 | + }); | |
112 | + dialog.setCanceledOnTouchOutside(false); | |
113 | + dialog.setOnShowListener(new DialogInterface.OnShowListener() { | |
114 | + @Override | |
115 | + public void onShow(DialogInterface dialog) { | |
116 | + Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); | |
117 | + button.setOnClickListener(new View.OnClickListener() { | |
118 | + @Override | |
119 | + public void onClick(View v) { | |
70 | 120 | mProgressBar.setVisibility(View.VISIBLE); |
71 | - mPrice.setVisibility(View.GONE); | |
72 | - mNom.setVisibility(View.GONE); | |
121 | + mPriceInput.setVisibility(View.GONE); | |
122 | + mNomInput.setVisibility(View.GONE); | |
73 | 123 | mDate.setVisibility(View.GONE); |
74 | 124 | JSONObject jsonObject = new JSONObject(); |
75 | 125 | try { |
76 | 126 | jsonObject.put("nomEvenement", mNom.getText().toString()); |
77 | 127 | jsonObject.put("prix", Double.parseDouble(mPrice.getText().toString())); |
78 | - jsonObject.put("date", mDate.getText().toString()); | |
128 | + jsonObject.put("date", mDate.getSelectedItem()); | |
79 | 129 | } catch (JSONException e){ |
80 | 130 | e.printStackTrace(); |
81 | 131 | } |
... | ... | @@ -90,6 +140,9 @@ public class ModifyEvent extends DialogFragment { |
90 | 140 | @Override |
91 | 141 | public void onErrorResponse(VolleyError error) { |
92 | 142 | mProgressBar.setVisibility(View.GONE); |
143 | + mPriceInput.setVisibility(View.VISIBLE); | |
144 | + mNomInput.setVisibility(View.VISIBLE); | |
145 | + mDate.setVisibility(View.VISIBLE); | |
93 | 146 | Toast.makeText(getContext(), R.string.modify_refused, Toast.LENGTH_LONG).show(); |
94 | 147 | |
95 | 148 | } |
... | ... | @@ -98,14 +151,10 @@ public class ModifyEvent extends DialogFragment { |
98 | 151 | jsonObjectRequest.setTag(ModifyEvent.class); |
99 | 152 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); |
100 | 153 | } |
101 | - }) | |
102 | - .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | |
103 | - public void onClick(DialogInterface dialog, int id) { | |
104 | - VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(ModifyEvent.class); | |
105 | - } | |
106 | - }).create(); | |
107 | - // Create the AlertDialog object and return it | |
108 | - dialog.setCanceledOnTouchOutside(false); | |
154 | + }); | |
155 | + | |
156 | + } | |
157 | + }); | |
109 | 158 | return dialog; |
110 | 159 | } |
111 | 160 | |
... | ... | @@ -116,5 +165,23 @@ public class ModifyEvent extends DialogFragment { |
116 | 165 | super.onStop(); |
117 | 166 | } |
118 | 167 | |
168 | + DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() { | |
169 | + | |
170 | + @Override | |
171 | + public void onDateSet(DatePicker view, int year, int monthOfYear, | |
172 | + int dayOfMonth) { | |
173 | + myCalendar.set(Calendar.YEAR, year); | |
174 | + myCalendar.set(Calendar.MONTH, monthOfYear); | |
175 | + myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); | |
176 | + updateLabel(); | |
177 | + } | |
178 | + }; | |
179 | + | |
180 | + private void updateLabel() { | |
181 | + String myFormat = "yyyy-MM-dd"; //In which you need put here | |
182 | + SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE); | |
183 | + arraySpinnerDate[0] = sdf.format(myCalendar.getTime()); | |
184 | + adapterDate.notifyDataSetChanged(); | |
185 | + } | |
119 | 186 | |
120 | 187 | -} |
188 | +} | |
121 | 189 | \ No newline at end of file | ... | ... |
app/src/main/java/net/plil/clubinfo/etunicorn/data/Event.java
app/src/main/res/layout/fragment_create_event.xml
... | ... | @@ -7,21 +7,32 @@ |
7 | 7 | android:layout_height="match_parent" |
8 | 8 | > |
9 | 9 | |
10 | - <EditText | |
10 | + <android.support.design.widget.TextInputLayout | |
11 | 11 | android:layout_width="match_parent" |
12 | 12 | android:layout_height="wrap_content" |
13 | - android:id="@+id/create_event_name" | |
14 | - android:hint="@string/create_event_name"/> | |
13 | + android:hint="@string/create_event_name" | |
14 | + android:id="@+id/create_event_name_input"> | |
15 | + <android.support.design.widget.TextInputEditText | |
16 | + android:layout_width="match_parent" | |
17 | + android:layout_height="wrap_content" | |
18 | + android:id="@+id/create_event_name" | |
19 | + /> | |
20 | + </android.support.design.widget.TextInputLayout> | |
15 | 21 | |
16 | - <EditText | |
22 | + <android.support.design.widget.TextInputLayout | |
17 | 23 | android:layout_width="match_parent" |
18 | 24 | android:layout_height="wrap_content" |
19 | 25 | android:hint="@string/create_consumable_price" |
20 | - android:id="@+id/create_event_price" | |
21 | - android:inputType="numberSigned|numberDecimal" | |
22 | - android:maxLines="1" /> | |
26 | + android:id="@+id/create_event_price_input"> | |
27 | + <android.support.design.widget.TextInputEditText | |
28 | + android:layout_width="match_parent" | |
29 | + android:layout_height="wrap_content" | |
30 | + android:id="@+id/create_event_price" | |
31 | + android:inputType="numberSigned|numberDecimal" | |
32 | + android:maxLines="1" /> | |
33 | + </android.support.design.widget.TextInputLayout> | |
23 | 34 | |
24 | - <EditText | |
35 | + <Spinner | |
25 | 36 | android:layout_width="match_parent" |
26 | 37 | android:layout_height="wrap_content" |
27 | 38 | android:hint="@string/create_event_date" | ... | ... |
app/src/main/res/layout/fragment_modify_event.xml
... | ... | @@ -5,18 +5,34 @@ |
5 | 5 | tools:context="net.plil.clubinfo.etunicorn.app.event.ModifyEvent" |
6 | 6 | android:orientation="vertical"> |
7 | 7 | |
8 | - <EditText | |
8 | + <android.support.design.widget.TextInputLayout | |
9 | 9 | android:layout_width="match_parent" |
10 | 10 | android:layout_height="wrap_content" |
11 | - android:id="@+id/modify_event_name" /> | |
11 | + android:id="@+id/modify_event_name_input"> | |
12 | 12 | |
13 | - <EditText | |
13 | + <android.support.design.widget.TextInputEditText | |
14 | + android:layout_width="match_parent" | |
15 | + android:layout_height="wrap_content" | |
16 | + android:id="@+id/modify_event_name" | |
17 | + android:hint="@string/modify_event_hint_name"/> | |
18 | + | |
19 | + </android.support.design.widget.TextInputLayout> | |
20 | + | |
21 | + <android.support.design.widget.TextInputLayout | |
14 | 22 | android:layout_width="match_parent" |
15 | 23 | android:layout_height="wrap_content" |
16 | - android:id="@+id/modify_event_price"/> | |
24 | + android:id="@+id/modify_event_price_input"> | |
25 | + | |
26 | + <android.support.design.widget.TextInputEditText | |
27 | + android:layout_width="match_parent" | |
28 | + android:layout_height="wrap_content" | |
29 | + android:id="@+id/modify_event_price" | |
30 | + android:hint="@string/modify_event_hint_price"/> | |
31 | + | |
32 | + </android.support.design.widget.TextInputLayout> | |
17 | 33 | |
18 | 34 | |
19 | - <EditText | |
35 | + <Spinner | |
20 | 36 | android:layout_width="match_parent" |
21 | 37 | android:layout_height="wrap_content" |
22 | 38 | android:id="@+id/modify_event_date" | ... | ... |
app/src/main/res/values-fr/strings.xml
... | ... | @@ -43,4 +43,14 @@ |
43 | 43 | <string name="error_enter_debit">Veuillez entrer une valeur avant d\'utiliser la carte NFC</string> |
44 | 44 | <string name="error_create_consomation_input_nom">Entrer le nom</string> |
45 | 45 | <string name="error_create_consomation_input_price">Entrer le prix</string> |
46 | + <string name="create_event_date_input">Date</string> | |
47 | + <string name="error_create_event_date">Entrer la date</string> | |
48 | + <string name="error_create_event_input_nom">Entrer le nom</string> | |
49 | + <string name="error_create_event_input_price">Entrer le prix</string> | |
50 | + <string name="error_modify_consommation_input_nom">Entrer le nouveau nom</string> | |
51 | + <string name="error_modify_consommation_input_price">Entrer le nouveau prix</string> | |
52 | + <string name="modify_consomation_hint_name">Nom</string> | |
53 | + <string name="modify_consomation_hint_price">Prix</string> | |
54 | + <string name="modify_event_hint_name">Nom</string> | |
55 | + <string name="modify_event_hint_price">Prix</string> | |
46 | 56 | </resources> |
47 | 57 | \ No newline at end of file | ... | ... |
app/src/main/res/values/strings.xml
... | ... | @@ -48,4 +48,10 @@ |
48 | 48 | <string name="error_modify_consommation_input_nom">Enter the new name</string> |
49 | 49 | <string name="modify_consomation_hint_name">Name</string> |
50 | 50 | <string name="modify_consomation_hint_price">Price</string> |
51 | + <string name="create_event_date_input">Date</string> | |
52 | + <string name="error_create_event_input_price">Enter the price</string> | |
53 | + <string name="error_create_event_input_nom">Enter the name</string> | |
54 | + <string name="error_create_event_date">Enter the date</string> | |
55 | + <string name="modify_event_hint_name">Name</string> | |
56 | + <string name="modify_event_hint_price">Price</string> | |
51 | 57 | </resources> | ... | ... |