Commit c8a73f2c175ebdf9b2b6bf3e3a4b882be6248c1d
1 parent
68348eda
Adding Event fragment
Showing
18 changed files
with
485 additions
and
18 deletions
Show diff stats
app/src/main/java/net/plil/clubinfo/etunicorn/app/Crediter.java
@@ -63,7 +63,7 @@ public class Crediter extends FragmentNFC { | @@ -63,7 +63,7 @@ public class Crediter extends FragmentNFC { | ||
63 | } | 63 | } |
64 | 64 | ||
65 | @Override | 65 | @Override |
66 | - public void processNFC() { | 66 | + public void processNFC(String idCardUser) { |
67 | mProgressBar.setVisibility(View.VISIBLE); | 67 | mProgressBar.setVisibility(View.VISIBLE); |
68 | JSONObject jsonObject = new JSONObject(); | 68 | JSONObject jsonObject = new JSONObject(); |
69 | try { | 69 | try { |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Debiter.java
@@ -70,9 +70,10 @@ public class Debiter extends FragmentNFC { | @@ -70,9 +70,10 @@ public class Debiter extends FragmentNFC { | ||
70 | } | 70 | } |
71 | 71 | ||
72 | @Override | 72 | @Override |
73 | - public void processNFC() { | 73 | + public void processNFC(String iDCardUser) { |
74 | mProgressBar.setVisibility(View.VISIBLE); | 74 | mProgressBar.setVisibility(View.VISIBLE); |
75 | JSONObject jsonObject = new JSONObject(); | 75 | JSONObject jsonObject = new JSONObject(); |
76 | + //TODO verifier champ complet avant de construire la requete | ||
76 | try { | 77 | try { |
77 | jsonObject.put("participant", 1); | 78 | jsonObject.put("participant", 1); |
78 | jsonObject.put("acteur", 2); | 79 | jsonObject.put("acteur", 2); |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/EventFragment.java
0 โ 100644
@@ -0,0 +1,105 @@ | @@ -0,0 +1,105 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.app.Event; | ||
2 | + | ||
3 | +import android.content.Context; | ||
4 | +import android.os.Bundle; | ||
5 | +import android.support.v7.widget.LinearLayoutManager; | ||
6 | +import android.support.v7.widget.RecyclerView; | ||
7 | +import android.view.LayoutInflater; | ||
8 | +import android.view.View; | ||
9 | +import android.view.ViewGroup; | ||
10 | + | ||
11 | +import net.plil.clubinfo.etunicorn.R; | ||
12 | +import net.plil.clubinfo.etunicorn.app.FragmentNFC; | ||
13 | +import net.plil.clubinfo.etunicorn.data.Event; | ||
14 | + | ||
15 | +import java.sql.Date; | ||
16 | +import java.util.ArrayList; | ||
17 | +import java.util.Calendar; | ||
18 | +import java.util.List; | ||
19 | + | ||
20 | +/** | ||
21 | + * A fragment representing a list of Items. | ||
22 | + * <p/> | ||
23 | + * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener} | ||
24 | + * interface. | ||
25 | + */ | ||
26 | +public class EventFragment extends FragmentNFC { | ||
27 | + | ||
28 | + private OnListFragmentInteractionListener mListener; | ||
29 | + | ||
30 | + public EventFragment() { | ||
31 | + } | ||
32 | + | ||
33 | + | ||
34 | + public static EventFragment newInstance() { | ||
35 | + return new EventFragment(); | ||
36 | + } | ||
37 | + | ||
38 | + @Override | ||
39 | + public void onCreate(Bundle savedInstanceState) { | ||
40 | + super.onCreate(savedInstanceState); | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
45 | + Bundle savedInstanceState) { | ||
46 | + View view = inflater.inflate(R.layout.fragment_event_list, container, false); | ||
47 | + | ||
48 | + // Set the adapter | ||
49 | + if (view instanceof RecyclerView) { | ||
50 | + Context context = view.getContext(); | ||
51 | + RecyclerView recyclerView = (RecyclerView) view; | ||
52 | + recyclerView.setLayoutManager(new LinearLayoutManager(context)); | ||
53 | + | ||
54 | + List<Event> events = new ArrayList<>(); | ||
55 | + for (int i = 0; i< 150; ++i){ | ||
56 | + Event ev = new Event(); | ||
57 | + ev.setNomEvent("Hello " + i); | ||
58 | + ev.setPrice(15.52); | ||
59 | + ev.setDate(new Date(Calendar.getInstance().getTimeInMillis())); | ||
60 | + events.add(ev); | ||
61 | + } | ||
62 | + | ||
63 | + recyclerView.setAdapter(new MyEventRecyclerViewAdapter(events, mListener, getActivity())); | ||
64 | + } | ||
65 | + return view; | ||
66 | + } | ||
67 | + | ||
68 | + | ||
69 | + @Override | ||
70 | + public void onAttach(Context context) { | ||
71 | + super.onAttach(context); | ||
72 | + if (context instanceof OnListFragmentInteractionListener) { | ||
73 | + mListener = (OnListFragmentInteractionListener) context; | ||
74 | + } else { | ||
75 | + throw new RuntimeException(context.toString() | ||
76 | + + " must implement OnListFragmentInteractionListener"); | ||
77 | + } | ||
78 | + } | ||
79 | + | ||
80 | + @Override | ||
81 | + public void onDetach() { | ||
82 | + super.onDetach(); | ||
83 | + mListener = null; | ||
84 | + } | ||
85 | + | ||
86 | + @Override | ||
87 | + public void processNFC(String idCardUser) { | ||
88 | + | ||
89 | + } | ||
90 | + | ||
91 | + /** | ||
92 | + * This interface must be implemented by activities that contain this | ||
93 | + * fragment to allow an interaction in this fragment to be communicated | ||
94 | + * to the activity and potentially other fragments contained in that | ||
95 | + * activity. | ||
96 | + * <p/> | ||
97 | + * See the Android Training lesson <a href= | ||
98 | + * "http://developer.android.com/training/basics/fragments/communicating.html" | ||
99 | + * >Communicating with Other Fragments</a> for more information. | ||
100 | + */ | ||
101 | + public interface OnListFragmentInteractionListener { | ||
102 | + void onListFragmentInteraction(Event item); | ||
103 | + void onListFragmentInteractionLong(Event item); | ||
104 | + } | ||
105 | +} |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/MyEventRecyclerViewAdapter.java
0 โ 100644
@@ -0,0 +1,83 @@ | @@ -0,0 +1,83 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.app.Event; | ||
2 | + | ||
3 | +import android.content.Context; | ||
4 | +import android.support.v7.widget.RecyclerView; | ||
5 | +import android.view.LayoutInflater; | ||
6 | +import android.view.View; | ||
7 | +import android.view.ViewGroup; | ||
8 | +import android.widget.TextView; | ||
9 | + | ||
10 | +import net.plil.clubinfo.etunicorn.R; | ||
11 | +import net.plil.clubinfo.etunicorn.data.Event; | ||
12 | + | ||
13 | +import java.util.List; | ||
14 | +import java.util.Locale; | ||
15 | + | ||
16 | + | ||
17 | +public class MyEventRecyclerViewAdapter extends RecyclerView.Adapter<MyEventRecyclerViewAdapter.ViewHolder> { | ||
18 | + | ||
19 | + private final List<Event> mEvents; | ||
20 | + private final EventFragment.OnListFragmentInteractionListener mListener; | ||
21 | + private final Context context; | ||
22 | + | ||
23 | + public MyEventRecyclerViewAdapter(List<Event> items, EventFragment.OnListFragmentInteractionListener listener, Context context) { | ||
24 | + mEvents = items; | ||
25 | + mListener = listener; | ||
26 | + this.context = context; | ||
27 | + } | ||
28 | + | ||
29 | + @Override | ||
30 | + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
31 | + View view = LayoutInflater.from(parent.getContext()) | ||
32 | + .inflate(R.layout.fragment_event, parent, false); | ||
33 | + return new ViewHolder(view); | ||
34 | + } | ||
35 | + | ||
36 | + @Override | ||
37 | + public void onBindViewHolder(final ViewHolder holder, int position) { | ||
38 | + holder.mItem = mEvents.get(position); | ||
39 | + holder.mContentView.setText(mEvents.get(position).getNomEvent()); | ||
40 | + holder.mPriceView.setText(String.format(Locale.FRANCE, "%.2f", mEvents.get(position).getPrice())); | ||
41 | + holder.mId = mEvents.get(position).getIdEvent(); | ||
42 | + | ||
43 | + holder.mView.setOnClickListener(new View.OnClickListener() { | ||
44 | + @Override | ||
45 | + public void onClick(View v) { | ||
46 | + if (null != mListener) { | ||
47 | + mListener.onListFragmentInteraction(holder.mItem); | ||
48 | + } | ||
49 | + } | ||
50 | + }); | ||
51 | + | ||
52 | + holder.mView.setOnLongClickListener(new View.OnLongClickListener() { | ||
53 | + @Override | ||
54 | + public boolean onLongClick(View v) { | ||
55 | + mListener.onListFragmentInteractionLong(holder.mItem); | ||
56 | + return true; | ||
57 | + } | ||
58 | + }); | ||
59 | + } | ||
60 | + | ||
61 | + @Override | ||
62 | + public int getItemCount() { | ||
63 | + return mEvents.size(); | ||
64 | + } | ||
65 | + | ||
66 | + class ViewHolder extends RecyclerView.ViewHolder { | ||
67 | + final View mView; | ||
68 | + int mId; | ||
69 | + final TextView mContentView; | ||
70 | + final TextView mPriceView; | ||
71 | + final TextView mButtonView; | ||
72 | + Event mItem; | ||
73 | + | ||
74 | + public ViewHolder(View view) { | ||
75 | + super(view); | ||
76 | + mView = view; | ||
77 | + mContentView = (TextView) view.findViewById(R.id.event_name); | ||
78 | + mPriceView = (TextView) view.findViewById(R.id.event_price); | ||
79 | + mButtonView = (TextView) view.findViewById(R.id.event_options); | ||
80 | + } | ||
81 | + | ||
82 | + } | ||
83 | +} |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/PaiementEvent.java
0 โ 100644
@@ -0,0 +1,107 @@ | @@ -0,0 +1,107 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.app.Event; | ||
2 | + | ||
3 | +import android.app.Dialog; | ||
4 | +import android.content.DialogInterface; | ||
5 | +import android.os.Bundle; | ||
6 | +import android.support.v4.app.DialogFragment; | ||
7 | +import android.support.v7.app.AlertDialog; | ||
8 | +import android.view.LayoutInflater; | ||
9 | +import android.view.View; | ||
10 | +import android.widget.ProgressBar; | ||
11 | +import android.widget.TextView; | ||
12 | +import android.widget.Toast; | ||
13 | + | ||
14 | +import com.android.volley.Request; | ||
15 | +import com.android.volley.Response; | ||
16 | +import com.android.volley.VolleyError; | ||
17 | +import com.android.volley.toolbox.JsonObjectRequest; | ||
18 | + | ||
19 | +import net.plil.clubinfo.etunicorn.R; | ||
20 | +import net.plil.clubinfo.etunicorn.data.Consommation; | ||
21 | +import net.plil.clubinfo.etunicorn.data.Event; | ||
22 | +import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | ||
23 | + | ||
24 | +import org.json.JSONException; | ||
25 | +import org.json.JSONObject; | ||
26 | + | ||
27 | +import java.util.Locale; | ||
28 | + | ||
29 | + | ||
30 | +public class PaiementEvent extends DialogFragment { | ||
31 | + | ||
32 | + ProgressBar mProgressBar; | ||
33 | + TextView mPaiementEventName; | ||
34 | + TextView mPaiementEventPrice; | ||
35 | + int eventId; | ||
36 | + | ||
37 | + public PaiementEvent(){} | ||
38 | + | ||
39 | + public static PaiementEvent newInstance(Event event) { | ||
40 | + PaiementEvent f = new PaiementEvent(); | ||
41 | + Bundle args = new Bundle(); | ||
42 | + args.putSerializable("event", event); | ||
43 | + f.setArguments(args); | ||
44 | + return f; | ||
45 | + } | ||
46 | + | ||
47 | + | ||
48 | + @Override | ||
49 | + public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
50 | + // Use the Builder class for convenient dialog construction | ||
51 | + LayoutInflater inflater = getActivity().getLayoutInflater(); | ||
52 | + View view = inflater.inflate(R.layout.fragment_paiment_event, null); | ||
53 | + mProgressBar = (ProgressBar) view.findViewById(R.id.paiment_event_progress_bar); | ||
54 | + mPaiementEventName = (TextView) view.findViewById(R.id.paiment_event_name); | ||
55 | + mPaiementEventPrice = (TextView) view.findViewById(R.id.paiment_event_price); | ||
56 | + | ||
57 | + | ||
58 | + Event event = (Event) getArguments().getSerializable("event"); | ||
59 | + mPaiementEventName.setText(event.getNomEvent()); | ||
60 | + mPaiementEventPrice.setText(String.format(Locale.FRANCE, "%.2f โฌ", event.getPrice())); | ||
61 | + | ||
62 | + eventId = event.getIdEvent(); | ||
63 | + | ||
64 | + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | ||
65 | + builder | ||
66 | + .setTitle(R.string.payment_event) | ||
67 | + .setView(view) | ||
68 | + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | ||
69 | + public void onClick(DialogInterface dialog, int id) { | ||
70 | + // User cancelled the dialog | ||
71 | + } | ||
72 | + }); | ||
73 | + // Create the AlertDialog object and return it | ||
74 | + return builder.create(); | ||
75 | + } | ||
76 | + | ||
77 | + | ||
78 | + public void processNFC() { | ||
79 | + mProgressBar.setVisibility(View.VISIBLE); | ||
80 | + JSONObject jsonObject = new JSONObject(); | ||
81 | + try { | ||
82 | + jsonObject.put("participant", 1); | ||
83 | + jsonObject.put("acteur", 2); | ||
84 | + jsonObject.put("id", eventId); | ||
85 | + } catch (JSONException e) { | ||
86 | + e.printStackTrace(); | ||
87 | + } | ||
88 | + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/transaction/evenement", jsonObject, new Response.Listener<JSONObject>() { | ||
89 | + @Override | ||
90 | + public void onResponse(JSONObject response) { | ||
91 | + mProgressBar.setVisibility(View.GONE); | ||
92 | + Toast.makeText(getContext(), R.string.payment_done, Toast.LENGTH_LONG).show(); | ||
93 | + dismiss(); | ||
94 | + } | ||
95 | + }, new Response.ErrorListener() { | ||
96 | + @Override | ||
97 | + public void onErrorResponse(VolleyError error) { | ||
98 | + mProgressBar.setVisibility(View.GONE); | ||
99 | + Toast.makeText(getContext(), R.string.payment_refused, Toast.LENGTH_LONG).show(); | ||
100 | + dismiss(); | ||
101 | + } | ||
102 | + } | ||
103 | + ); | ||
104 | + | ||
105 | + VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | ||
106 | + } | ||
107 | +} |
app/src/main/java/net/plil/clubinfo/etunicorn/app/FragmentNFC.java
@@ -8,5 +8,5 @@ import android.view.View; | @@ -8,5 +8,5 @@ import android.view.View; | ||
8 | */ | 8 | */ |
9 | 9 | ||
10 | public abstract class FragmentNFC extends Fragment { | 10 | public abstract class FragmentNFC extends Fragment { |
11 | - public abstract void processNFC(); | 11 | + public abstract void processNFC(String idCardUser); |
12 | } | 12 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java
@@ -4,6 +4,7 @@ import android.app.PendingIntent; | @@ -4,6 +4,7 @@ import android.app.PendingIntent; | ||
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.net.Uri; | 5 | import android.net.Uri; |
6 | import android.nfc.NfcAdapter; | 6 | import android.nfc.NfcAdapter; |
7 | +import android.nfc.Tag; | ||
7 | import android.os.Bundle; | 8 | import android.os.Bundle; |
8 | import android.support.design.widget.AppBarLayout; | 9 | import android.support.design.widget.AppBarLayout; |
9 | import android.support.design.widget.TabLayout; | 10 | import android.support.design.widget.TabLayout; |
@@ -17,17 +18,22 @@ import android.view.Menu; | @@ -17,17 +18,22 @@ import android.view.Menu; | ||
17 | import android.view.MenuItem; | 18 | import android.view.MenuItem; |
18 | import android.view.Window; | 19 | import android.view.Window; |
19 | import android.view.WindowManager; | 20 | import android.view.WindowManager; |
21 | +import android.widget.Toast; | ||
20 | 22 | ||
21 | import net.plil.clubinfo.etunicorn.R; | 23 | import net.plil.clubinfo.etunicorn.R; |
24 | +import net.plil.clubinfo.etunicorn.app.Event.EventFragment; | ||
25 | +import net.plil.clubinfo.etunicorn.app.Event.PaiementEvent; | ||
22 | import net.plil.clubinfo.etunicorn.app.consommation.FragmentConsommation; | 26 | import net.plil.clubinfo.etunicorn.app.consommation.FragmentConsommation; |
23 | import net.plil.clubinfo.etunicorn.app.consommation.PaiementConsommation; | 27 | import net.plil.clubinfo.etunicorn.app.consommation.PaiementConsommation; |
24 | import net.plil.clubinfo.etunicorn.data.Consommation; | 28 | import net.plil.clubinfo.etunicorn.data.Consommation; |
29 | +import net.plil.clubinfo.etunicorn.data.Event; | ||
30 | +import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; | ||
25 | 31 | ||
26 | import java.util.ArrayList; | 32 | import java.util.ArrayList; |
27 | import java.util.List; | 33 | import java.util.List; |
28 | 34 | ||
29 | 35 | ||
30 | -public class MainActivity extends AppCompatActivity implements FragmentConsommation.OnListFragmentInteractionListener{ | 36 | +public class MainActivity extends AppCompatActivity implements FragmentConsommation.OnListFragmentInteractionListener, EventFragment.OnListFragmentInteractionListener{ |
31 | 37 | ||
32 | /** | 38 | /** |
33 | * The {@link android.support.v4.view.PagerAdapter} that will provide | 39 | * The {@link android.support.v4.view.PagerAdapter} that will provide |
@@ -109,8 +115,9 @@ public class MainActivity extends AppCompatActivity implements FragmentConsommat | @@ -109,8 +115,9 @@ public class MainActivity extends AppCompatActivity implements FragmentConsommat | ||
109 | protected void onNewIntent(Intent intent) { | 115 | protected void onNewIntent(Intent intent) { |
110 | super.onNewIntent(intent); | 116 | super.onNewIntent(intent); |
111 | if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) { | 117 | if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) { |
118 | + Tag myTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); | ||
112 | FragmentNFC fNFC = (FragmentNFC) getSupportFragmentManager().getFragments().get(mViewPager.getCurrentItem()); | 119 | FragmentNFC fNFC = (FragmentNFC) getSupportFragmentManager().getFragments().get(mViewPager.getCurrentItem()); |
113 | - fNFC.processNFC(); | 120 | + fNFC.processNFC(ConvertBytesToString.bytesToHexString(myTag.getId())); |
114 | } | 121 | } |
115 | } | 122 | } |
116 | 123 | ||
@@ -136,7 +143,18 @@ public class MainActivity extends AppCompatActivity implements FragmentConsommat | @@ -136,7 +143,18 @@ public class MainActivity extends AppCompatActivity implements FragmentConsommat | ||
136 | } | 143 | } |
137 | 144 | ||
138 | @Override | 145 | @Override |
139 | - public void onListFragmentInteractionLong(Consommation item) { | 146 | + public void onListFragmentInteractionLong(Consommation consommation) { |
147 | + | ||
148 | + } | ||
149 | + | ||
150 | + @Override | ||
151 | + public void onListFragmentInteraction(Event item) { | ||
152 | + PaiementEvent paiementEvent = PaiementEvent.newInstance(item); | ||
153 | + paiementEvent.show(getSupportFragmentManager(), "paiementEvent"); | ||
154 | + } | ||
155 | + | ||
156 | + @Override | ||
157 | + public void onListFragmentInteractionLong(Event item) { | ||
140 | 158 | ||
141 | } | 159 | } |
142 | 160 | ||
@@ -158,13 +176,15 @@ public class MainActivity extends AppCompatActivity implements FragmentConsommat | @@ -158,13 +176,15 @@ public class MainActivity extends AppCompatActivity implements FragmentConsommat | ||
158 | return Debiter.newInstance(); | 176 | return Debiter.newInstance(); |
159 | else if (position == Action.CONSOMATION.getValue()) | 177 | else if (position == Action.CONSOMATION.getValue()) |
160 | return FragmentConsommation.newInstance(); | 178 | return FragmentConsommation.newInstance(); |
179 | + else if (position == Action.EVENT.getValue()) | ||
180 | + return EventFragment.newInstance(); | ||
161 | else | 181 | else |
162 | return null; | 182 | return null; |
163 | } | 183 | } |
164 | 184 | ||
165 | @Override | 185 | @Override |
166 | public int getCount() { | 186 | public int getCount() { |
167 | - return 3; | 187 | + return 4; |
168 | } | 188 | } |
169 | 189 | ||
170 | @Override | 190 | @Override |
@@ -175,12 +195,14 @@ public class MainActivity extends AppCompatActivity implements FragmentConsommat | @@ -175,12 +195,14 @@ public class MainActivity extends AppCompatActivity implements FragmentConsommat | ||
175 | return "Crediter"; | 195 | return "Crediter"; |
176 | else if (position == Action.CONSOMATION.getValue()) | 196 | else if (position == Action.CONSOMATION.getValue()) |
177 | return "Consommation"; | 197 | return "Consommation"; |
198 | + else if(position == Action.EVENT.getValue()) | ||
199 | + return getString(R.string.event); | ||
178 | return null; | 200 | return null; |
179 | } | 201 | } |
180 | } | 202 | } |
181 | 203 | ||
182 | private enum Action { | 204 | private enum Action { |
183 | - DEBITER(0), CREDITER(1), CONSOMATION(2); | 205 | + DEBITER(0), CREDITER(1), CONSOMATION(2), EVENT(3); |
184 | 206 | ||
185 | private final int value; | 207 | private final int value; |
186 | Action(int value) { | 208 | Action(int value) { |
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/ConsommationRecyclerViewAdapter.java
@@ -114,9 +114,5 @@ public class ConsommationRecyclerViewAdapter extends RecyclerView.Adapter<Consom | @@ -114,9 +114,5 @@ public class ConsommationRecyclerViewAdapter extends RecyclerView.Adapter<Consom | ||
114 | mButtonMenu = (TextView) view.findViewById(R.id.consomation_options); | 114 | mButtonMenu = (TextView) view.findViewById(R.id.consomation_options); |
115 | } | 115 | } |
116 | 116 | ||
117 | - @Override | ||
118 | - public String toString() { | ||
119 | - return super.toString() + " '" + mContentView.getText() + "'"; | ||
120 | - } | ||
121 | } | 117 | } |
122 | } | 118 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/FragmentConsommation.java
@@ -99,8 +99,7 @@ public class FragmentConsommation extends FragmentNFC { | @@ -99,8 +99,7 @@ public class FragmentConsommation extends FragmentNFC { | ||
99 | } | 99 | } |
100 | 100 | ||
101 | @Override | 101 | @Override |
102 | - public void processNFC() { | ||
103 | - | 102 | + public void processNFC(String idCardUser) { |
104 | PaiementConsommation paiementConsommation = (PaiementConsommation) getFragmentManager().findFragmentByTag("paiementConsommation"); | 103 | PaiementConsommation paiementConsommation = (PaiementConsommation) getFragmentManager().findFragmentByTag("paiementConsommation"); |
105 | if (paiementConsommation == null){ | 104 | if (paiementConsommation == null){ |
106 | Toast.makeText(getContext(), R.string.payment_consumable_alert_no_selection, Toast.LENGTH_LONG).show(); | 105 | Toast.makeText(getContext(), R.string.payment_consumable_alert_no_selection, Toast.LENGTH_LONG).show(); |
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/PaiementConsommation.java
@@ -41,8 +41,6 @@ public class PaiementConsommation extends DialogFragment { | @@ -41,8 +41,6 @@ public class PaiementConsommation extends DialogFragment { | ||
41 | */ | 41 | */ |
42 | public static PaiementConsommation newInstance(Consommation consommation) { | 42 | public static PaiementConsommation newInstance(Consommation consommation) { |
43 | PaiementConsommation f = new PaiementConsommation(); | 43 | PaiementConsommation f = new PaiementConsommation(); |
44 | - | ||
45 | - // Supply num input as an argument. | ||
46 | Bundle args = new Bundle(); | 44 | Bundle args = new Bundle(); |
47 | args.putSerializable("consommation", consommation); | 45 | args.putSerializable("consommation", consommation); |
48 | f.setArguments(args); | 46 | f.setArguments(args); |
app/src/main/java/net/plil/clubinfo/etunicorn/data/Event.java
0 โ 100644
@@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.data; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | +import java.sql.Date; | ||
5 | + | ||
6 | +/** | ||
7 | + * Created by badetitou on 04/02/2017. | ||
8 | + */ | ||
9 | + | ||
10 | +public class Event implements Serializable{ | ||
11 | + | ||
12 | + private int idEvent; | ||
13 | + private String nomEvent; | ||
14 | + private double price; | ||
15 | + private Date date; | ||
16 | + | ||
17 | + public Event() { | ||
18 | + } | ||
19 | + | ||
20 | + public int getIdEvent() { | ||
21 | + return idEvent; | ||
22 | + } | ||
23 | + | ||
24 | + public void setIdEvent(int idEvent) { | ||
25 | + this.idEvent = idEvent; | ||
26 | + } | ||
27 | + | ||
28 | + public String getNomEvent() { | ||
29 | + return nomEvent; | ||
30 | + } | ||
31 | + | ||
32 | + public void setNomEvent(String nomEvent) { | ||
33 | + this.nomEvent = nomEvent; | ||
34 | + } | ||
35 | + | ||
36 | + public double getPrice() { | ||
37 | + return price; | ||
38 | + } | ||
39 | + | ||
40 | + public void setPrice(double price) { | ||
41 | + this.price = price; | ||
42 | + } | ||
43 | + | ||
44 | + public Date getDate() { | ||
45 | + return date; | ||
46 | + } | ||
47 | + | ||
48 | + public void setDate(Date date) { | ||
49 | + this.date = date; | ||
50 | + } | ||
51 | +} |
app/src/main/java/net/plil/clubinfo/etunicorn/utils/ConvertBytesToString.java
0 โ 100644
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.utils; | ||
2 | + | ||
3 | +/** | ||
4 | + * Created by badetitou on 04/02/2017. | ||
5 | + */ | ||
6 | + | ||
7 | +public class ConvertBytesToString { | ||
8 | + | ||
9 | + public static String bytesToHexString(byte[] bytes){ | ||
10 | + StringBuilder stringBuilder = new StringBuilder(""); | ||
11 | + if (bytes == null || bytes.length <= 0) { | ||
12 | + return null; | ||
13 | + } | ||
14 | + | ||
15 | + char[] buffer = new char[2]; | ||
16 | + for (int i = 0; i < bytes.length; i++) { | ||
17 | + buffer[0] = Character.forDigit((bytes[i] >>> 4) & 0x0F, 16); | ||
18 | + buffer[1] = Character.forDigit(bytes[i] & 0x0F, 16); | ||
19 | + System.out.println(buffer); | ||
20 | + stringBuilder.append(buffer); | ||
21 | + } | ||
22 | + | ||
23 | + return stringBuilder.toString(); | ||
24 | + } | ||
25 | + | ||
26 | +} |
app/src/main/res/layout/fragment_crediter.xml
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | tools:context="net.plil.clubinfo.etunicorn.app.Crediter"> | 5 | tools:context="net.plil.clubinfo.etunicorn.app.Crediter"> |
6 | 6 | ||
7 | <EditText | 7 | <EditText |
8 | - android:inputType="numberSigned" | 8 | + android:inputType="numberSigned|numberDecimal" |
9 | android:layout_width="wrap_content" | 9 | android:layout_width="wrap_content" |
10 | android:layout_height="wrap_content" | 10 | android:layout_height="wrap_content" |
11 | android:hint="@string/enter_money" | 11 | android:hint="@string/enter_money" |
app/src/main/res/layout/fragment_debiter.xml
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | 6 | ||
7 | 7 | ||
8 | <EditText | 8 | <EditText |
9 | - android:inputType="numberSigned" | 9 | + android:inputType="numberSigned|numberDecimal" |
10 | android:ems="10" | 10 | android:ems="10" |
11 | android:id="@+id/debiter_edit_text_money" | 11 | android:id="@+id/debiter_edit_text_money" |
12 | android:gravity="center" | 12 | android:gravity="center" |
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + android:layout_width="wrap_content" | ||
4 | + android:layout_height="wrap_content" | ||
5 | + xmlns:tools="http://schemas.android.com/tools" | ||
6 | + android:orientation="horizontal" | ||
7 | + android:foreground="?attr/selectableItemBackground"> | ||
8 | + | ||
9 | + <TextView | ||
10 | + android:id="@+id/event_name" | ||
11 | + android:layout_width="wrap_content" | ||
12 | + android:layout_height="wrap_content" | ||
13 | + android:layout_margin="@dimen/text_margin" | ||
14 | + android:textAppearance="?attr/textAppearanceListItem" /> | ||
15 | + | ||
16 | + <TextView | ||
17 | + android:id="@+id/event_price" | ||
18 | + android:layout_width="wrap_content" | ||
19 | + android:layout_height="wrap_content" | ||
20 | + android:layout_margin="@dimen/text_margin" | ||
21 | + android:textAppearance="?attr/textAppearanceListItem" | ||
22 | + android:layout_toRightOf="@id/event_name"/> | ||
23 | + | ||
24 | + <TextView | ||
25 | + android:id="@+id/event_options" | ||
26 | + android:layout_width="wrap_content" | ||
27 | + android:layout_height="match_parent" | ||
28 | + android:layout_alignParentRight="true" | ||
29 | + android:layout_alignParentTop="true" | ||
30 | + android:paddingLeft="@dimen/activity_horizontal_margin" | ||
31 | + android:text="⋮" | ||
32 | + android:textAppearance="?android:textAppearanceLarge" | ||
33 | + tools:ignore="RtlHardcoded,RtlSymmetry" | ||
34 | + android:textStyle="normal|bold" | ||
35 | + android:translationY="10dp" /> | ||
36 | +</RelativeLayout> |
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
4 | + xmlns:tools="http://schemas.android.com/tools" | ||
5 | + android:id="@+id/list" | ||
6 | + android:name="net.plil.clubinfo.etunicorn.app.Event.EventFragment" | ||
7 | + android:layout_width="match_parent" | ||
8 | + android:layout_height="match_parent" | ||
9 | + android:layout_marginLeft="16dp" | ||
10 | + android:layout_marginRight="16dp" | ||
11 | + app:layoutManager="LinearLayoutManager" | ||
12 | + tools:context="net.plil.clubinfo.etunicorn.app.Event.EventFragment" | ||
13 | + tools:listitem="@layout/fragment_event" /> |
app/src/main/res/layout/fragment_paiment_event.xml
0 โ 100644
@@ -0,0 +1,28 @@ | @@ -0,0 +1,28 @@ | ||
1 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
2 | + xmlns:tools="http://schemas.android.com/tools" | ||
3 | + android:layout_width="match_parent" | ||
4 | + android:layout_height="match_parent" | ||
5 | + tools:context="net.plil.clubinfo.etunicorn.app.consommation.PaiementConsommation" | ||
6 | + android:orientation="vertical"> | ||
7 | + | ||
8 | + <TextView | ||
9 | + android:layout_width="wrap_content" | ||
10 | + android:layout_height="wrap_content" | ||
11 | + android:id="@+id/paiment_event_name" | ||
12 | + android:layout_gravity="center" | ||
13 | + android:textAppearance="@android:style/TextAppearance.Material.Medium" /> | ||
14 | + | ||
15 | + <TextView | ||
16 | + android:layout_width="wrap_content" | ||
17 | + android:layout_height="wrap_content" | ||
18 | + android:id="@+id/paiment_event_price" | ||
19 | + android:layout_gravity="center" | ||
20 | + android:textAppearance="@android:style/TextAppearance.Material.Medium" /> | ||
21 | + | ||
22 | + <ProgressBar | ||
23 | + android:layout_width="match_parent" | ||
24 | + android:layout_height="match_parent" | ||
25 | + android:id="@+id/paiment_event_progress_bar" | ||
26 | + android:visibility="gone"/> | ||
27 | + | ||
28 | +</LinearLayout> |
app/src/main/res/values/strings.xml
@@ -28,4 +28,6 @@ | @@ -28,4 +28,6 @@ | ||
28 | <string name="delete_refused">Delete refused</string> | 28 | <string name="delete_refused">Delete refused</string> |
29 | <string name="modify_done">Modify done</string> | 29 | <string name="modify_done">Modify done</string> |
30 | <string name="modify_refused">Modify refused</string> | 30 | <string name="modify_refused">Modify refused</string> |
31 | + <string name="event">Event</string> | ||
32 | + <string name="payment_event">Event payment</string> | ||
31 | </resources> | 33 | </resources> |