Commit c0f970a014b6457476454ec115f82b9f356a16d1

Authored by badetitou
1 parent 6e48e148

Event handle stop dialog

app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/CreateEvent.java
... ... @@ -16,6 +16,7 @@ import com.android.volley.VolleyError;
16 16 import com.android.volley.toolbox.JsonObjectRequest;
17 17  
18 18 import net.plil.clubinfo.etunicorn.R;
  19 +import net.plil.clubinfo.etunicorn.app.consommation.ModifyConsommation;
19 20 import net.plil.clubinfo.etunicorn.utils.VolleyUtils;
20 21  
21 22 import org.json.JSONException;
... ... @@ -39,8 +40,7 @@ public class CreateEvent extends DialogFragment {
39 40 mPrice = (EditText) view.findViewById(R.id.create_event_price);
40 41 mDate = (EditText) view.findViewById(R.id.create_event_date);
41 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 44 .setTitle(R.string.create_event)
45 45 .setView(view)
46 46 .setPositiveButton(R.string.valid, new DialogInterface.OnClickListener() {
... ... @@ -69,18 +69,24 @@ public class CreateEvent extends DialogFragment {
69 69 }
70 70 }
71 71 );
72   -
  72 + jsonObjectRequest.setTag(CreateEvent.class);
73 73 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
74 74 }
75 75 })
76 76 .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
77 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 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 59 .setTitle(R.string.verif_delete_event)
61 60 .setView(view)
62 61 .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
... ... @@ -80,17 +79,24 @@ public class DeleteEvent extends DialogFragment {
80 79 }
81 80 }
82 81 );
83   -
  82 + jsonObjectRequest.setTag(DeleteEvent.class);
84 83 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
85 84 }
86 85 })
87 86 .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
88 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 61 mPrice.setText(String.format(Locale.FRANCE, "%.2f", event.getPrice()));
62 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 65 .setTitle(R.string.modify)
67 66 .setView(view)
68 67 .setPositiveButton(R.string.modify, new DialogInterface.OnClickListener() {
... ... @@ -96,17 +95,25 @@ public class ModifyEvent extends DialogFragment {
96 95 }
97 96 }
98 97 );
99   -
  98 + jsonObjectRequest.setTag(ModifyEvent.class);
100 99 VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest);
101 100 }
102 101 })
103 102 .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
104 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 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 66 .setView(view)
67 67 .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
68 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 72 Dialog dialog = builder.create();
73 73 dialog.setCanceledOnTouchOutside(false);
74 74 return dialog;
... ... @@ -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 110 @Override
116 111 public void onStop() {
117 112 VolleyUtils.getInstance(getContext()).getRequestQueue().cancelAll(PaiementEvent.class);
  113 + dismissAllowingStateLoss();
118 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 52 return view;
53 53 }
54 54  
55   -
56   -
57   -
58 55 @Override
59 56 public void onAttach(Context context) {
60 57 super.onAttach(context);
... ...