Commit c0f970a014b6457476454ec115f82b9f356a16d1
1 parent
6e48e148
Event handle stop dialog
Showing
5 changed files
with
40 additions
and
33 deletions
Show diff stats
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/CreateEvent.java
@@ -16,6 +16,7 @@ import com.android.volley.VolleyError; | @@ -16,6 +16,7 @@ import com.android.volley.VolleyError; | ||
16 | import com.android.volley.toolbox.JsonObjectRequest; | 16 | import com.android.volley.toolbox.JsonObjectRequest; |
17 | 17 | ||
18 | import net.plil.clubinfo.etunicorn.R; | 18 | import net.plil.clubinfo.etunicorn.R; |
19 | +import net.plil.clubinfo.etunicorn.app.consommation.ModifyConsommation; | ||
19 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | 20 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; |
20 | 21 | ||
21 | import org.json.JSONException; | 22 | import org.json.JSONException; |
@@ -39,8 +40,7 @@ public class CreateEvent extends DialogFragment { | @@ -39,8 +40,7 @@ public class CreateEvent extends DialogFragment { | ||
39 | mPrice = (EditText) view.findViewById(R.id.create_event_price); | 40 | mPrice = (EditText) view.findViewById(R.id.create_event_price); |
40 | mDate = (EditText) view.findViewById(R.id.create_event_date); | 41 | mDate = (EditText) view.findViewById(R.id.create_event_date); |
41 | mProgressBar = (ProgressBar) view.findViewById(R.id.create_event_progress_bar); | 42 | mProgressBar = (ProgressBar) view.findViewById(R.id.create_event_progress_bar); |
42 | - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | ||
43 | - builder | 43 | + AlertDialog dialog = new AlertDialog.Builder(getActivity()) |
44 | .setTitle(R.string.create_event) | 44 | .setTitle(R.string.create_event) |
45 | .setView(view) | 45 | .setView(view) |
46 | .setPositiveButton(R.string.valid, new DialogInterface.OnClickListener() { | 46 | .setPositiveButton(R.string.valid, new DialogInterface.OnClickListener() { |
@@ -69,18 +69,24 @@ public class CreateEvent extends DialogFragment { | @@ -69,18 +69,24 @@ public class CreateEvent extends DialogFragment { | ||
69 | } | 69 | } |
70 | } | 70 | } |
71 | ); | 71 | ); |
72 | - | 72 | + jsonObjectRequest.setTag(CreateEvent.class); |
73 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | 73 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); |
74 | } | 74 | } |
75 | }) | 75 | }) |
76 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | 76 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { |
77 | public void onClick(DialogInterface dialog, int id) { | 77 | public void onClick(DialogInterface dialog, int id) { |
78 | - // User cancelled the dialog | 78 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(CreateEvent.class); |
79 | } | 79 | } |
80 | - }); | ||
81 | - // Create the AlertDialog object and return it | ||
82 | - return builder.create(); | 80 | + }).create(); |
81 | + dialog.setCanceledOnTouchOutside(false); | ||
82 | + return dialog; | ||
83 | } | 83 | } |
84 | 84 | ||
85 | + @Override | ||
86 | + public void onStop() { | ||
87 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(CreateEvent.class); | ||
88 | + dismissAllowingStateLoss(); | ||
89 | + super.onStop(); | ||
90 | + } | ||
85 | 91 | ||
86 | } | 92 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/DeleteEvent.java
@@ -55,8 +55,7 @@ public class DeleteEvent extends DialogFragment { | @@ -55,8 +55,7 @@ public class DeleteEvent extends DialogFragment { | ||
55 | final Event event = (Event) getArguments().getSerializable("event"); | 55 | final Event event = (Event) getArguments().getSerializable("event"); |
56 | 56 | ||
57 | 57 | ||
58 | - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | ||
59 | - builder | 58 | + AlertDialog dialog = new AlertDialog.Builder(getActivity()) |
60 | .setTitle(R.string.verif_delete_event) | 59 | .setTitle(R.string.verif_delete_event) |
61 | .setView(view) | 60 | .setView(view) |
62 | .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { | 61 | .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { |
@@ -80,17 +79,24 @@ public class DeleteEvent extends DialogFragment { | @@ -80,17 +79,24 @@ public class DeleteEvent extends DialogFragment { | ||
80 | } | 79 | } |
81 | } | 80 | } |
82 | ); | 81 | ); |
83 | - | 82 | + jsonObjectRequest.setTag(DeleteEvent.class); |
84 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | 83 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); |
85 | } | 84 | } |
86 | }) | 85 | }) |
87 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | 86 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { |
88 | public void onClick(DialogInterface dialog, int id) { | 87 | public void onClick(DialogInterface dialog, int id) { |
89 | - | 88 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(DeleteEvent.class); |
90 | } | 89 | } |
91 | - }); | ||
92 | - return builder.create(); | 90 | + }).create(); |
91 | + dialog.setCanceledOnTouchOutside(false); | ||
92 | + return dialog; | ||
93 | } | 93 | } |
94 | 94 | ||
95 | + @Override | ||
96 | + public void onStop() { | ||
97 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(DeleteEvent.class); | ||
98 | + dismissAllowingStateLoss(); | ||
99 | + super.onStop(); | ||
100 | + } | ||
95 | 101 | ||
96 | } | 102 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/ModifyEvent.java
@@ -61,8 +61,7 @@ public class ModifyEvent extends DialogFragment { | @@ -61,8 +61,7 @@ public class ModifyEvent extends DialogFragment { | ||
61 | mPrice.setText(String.format(Locale.FRANCE, "%.2f", event.getPrice())); | 61 | mPrice.setText(String.format(Locale.FRANCE, "%.2f", event.getPrice())); |
62 | mDate.setText(event.getDate().toString()); | 62 | mDate.setText(event.getDate().toString()); |
63 | 63 | ||
64 | - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | ||
65 | - builder | 64 | + AlertDialog dialog = new AlertDialog.Builder(getActivity()) |
66 | .setTitle(R.string.modify) | 65 | .setTitle(R.string.modify) |
67 | .setView(view) | 66 | .setView(view) |
68 | .setPositiveButton(R.string.modify, new DialogInterface.OnClickListener() { | 67 | .setPositiveButton(R.string.modify, new DialogInterface.OnClickListener() { |
@@ -96,17 +95,25 @@ public class ModifyEvent extends DialogFragment { | @@ -96,17 +95,25 @@ public class ModifyEvent extends DialogFragment { | ||
96 | } | 95 | } |
97 | } | 96 | } |
98 | ); | 97 | ); |
99 | - | 98 | + jsonObjectRequest.setTag(ModifyEvent.class); |
100 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | 99 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); |
101 | } | 100 | } |
102 | }) | 101 | }) |
103 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | 102 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { |
104 | public void onClick(DialogInterface dialog, int id) { | 103 | public void onClick(DialogInterface dialog, int id) { |
105 | - // User cancelled the dialog | 104 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(ModifyEvent.class); |
106 | } | 105 | } |
107 | - }); | 106 | + }).create(); |
108 | // Create the AlertDialog object and return it | 107 | // Create the AlertDialog object and return it |
109 | - return builder.create(); | 108 | + dialog.setCanceledOnTouchOutside(false); |
109 | + return dialog; | ||
110 | + } | ||
111 | + | ||
112 | + @Override | ||
113 | + public void onStop() { | ||
114 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(ModifyEvent.class); | ||
115 | + dismissAllowingStateLoss(); | ||
116 | + super.onStop(); | ||
110 | } | 117 | } |
111 | 118 | ||
112 | 119 |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/PaiementEvent.java
@@ -66,9 +66,9 @@ public class PaiementEvent extends DialogFragment { | @@ -66,9 +66,9 @@ public class PaiementEvent extends DialogFragment { | ||
66 | .setView(view) | 66 | .setView(view) |
67 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | 67 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { |
68 | public void onClick(DialogInterface dialog, int id) { | 68 | public void onClick(DialogInterface dialog, int id) { |
69 | + VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementEvent.class); | ||
69 | } | 70 | } |
70 | }); | 71 | }); |
71 | - // Create the AlertDialog object and return it | ||
72 | Dialog dialog = builder.create(); | 72 | Dialog dialog = builder.create(); |
73 | dialog.setCanceledOnTouchOutside(false); | 73 | dialog.setCanceledOnTouchOutside(false); |
74 | return dialog; | 74 | return dialog; |
@@ -106,22 +106,13 @@ public class PaiementEvent extends DialogFragment { | @@ -106,22 +106,13 @@ public class PaiementEvent extends DialogFragment { | ||
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | - @Override | ||
110 | - public void onCancel(DialogInterface dialog) { | ||
111 | - VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementEvent.class); | ||
112 | - super.onCancel(dialog); | ||
113 | - } | ||
114 | 109 | ||
115 | @Override | 110 | @Override |
116 | public void onStop() { | 111 | public void onStop() { |
117 | VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementEvent.class); | 112 | VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementEvent.class); |
113 | + dismissAllowingStateLoss(); | ||
118 | super.onStop(); | 114 | super.onStop(); |
119 | } | 115 | } |
120 | 116 | ||
121 | - @Override | ||
122 | - public void onPause() { | ||
123 | - super.onPause(); | ||
124 | - dismiss(); | ||
125 | - } | ||
126 | 117 | ||
127 | } | 118 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/credit/Crediter.java
@@ -52,9 +52,6 @@ public class Crediter extends FragmentNFC { | @@ -52,9 +52,6 @@ public class Crediter extends FragmentNFC { | ||
52 | return view; | 52 | return view; |
53 | } | 53 | } |
54 | 54 | ||
55 | - | ||
56 | - | ||
57 | - | ||
58 | @Override | 55 | @Override |
59 | public void onAttach(Context context) { | 56 | public void onAttach(Context context) { |
60 | super.onAttach(context); | 57 | super.onAttach(context); |