Commit 515eb39370b7edfec7abc6bd2a2d4d7c5dcbb5e2
1 parent
97f92a02
NFCSupport Update
Showing
13 changed files
with
53 additions
and
30 deletions
Show diff stats
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/EventFragment.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.content.Context; | 3 | import android.content.Context; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.support.design.widget.FloatingActionButton; | 5 | import android.support.design.widget.FloatingActionButton; |
6 | +import android.support.v4.app.Fragment; | ||
6 | import android.support.v7.widget.LinearLayoutManager; | 7 | import android.support.v7.widget.LinearLayoutManager; |
7 | import android.support.v7.widget.RecyclerView; | 8 | import android.support.v7.widget.RecyclerView; |
8 | import android.view.LayoutInflater; | 9 | import android.view.LayoutInflater; |
@@ -11,7 +12,7 @@ import android.view.ViewGroup; | @@ -11,7 +12,7 @@ import android.view.ViewGroup; | ||
11 | import android.widget.Toast; | 12 | import android.widget.Toast; |
12 | 13 | ||
13 | import net.plil.clubinfo.etunicorn.R; | 14 | import net.plil.clubinfo.etunicorn.R; |
14 | -import net.plil.clubinfo.etunicorn.app.FragmentNFC; | 15 | +import net.plil.clubinfo.etunicorn.app.NFCSupport; |
15 | import net.plil.clubinfo.etunicorn.data.Event; | 16 | import net.plil.clubinfo.etunicorn.data.Event; |
16 | 17 | ||
17 | import java.sql.Date; | 18 | import java.sql.Date; |
@@ -25,7 +26,7 @@ import java.util.List; | @@ -25,7 +26,7 @@ import java.util.List; | ||
25 | * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener} | 26 | * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener} |
26 | * interface. | 27 | * interface. |
27 | */ | 28 | */ |
28 | -public class EventFragment extends FragmentNFC { | 29 | +public class EventFragment extends Fragment implements NFCSupport { |
29 | 30 | ||
30 | private OnListFragmentInteractionListener mListener; | 31 | private OnListFragmentInteractionListener mListener; |
31 | 32 |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Event/PaiementEvent.java
@@ -17,6 +17,7 @@ import com.android.volley.VolleyError; | @@ -17,6 +17,7 @@ import com.android.volley.VolleyError; | ||
17 | import com.android.volley.toolbox.JsonObjectRequest; | 17 | import com.android.volley.toolbox.JsonObjectRequest; |
18 | 18 | ||
19 | import net.plil.clubinfo.etunicorn.R; | 19 | import net.plil.clubinfo.etunicorn.R; |
20 | +import net.plil.clubinfo.etunicorn.app.NFCSupport; | ||
20 | import net.plil.clubinfo.etunicorn.data.Event; | 21 | import net.plil.clubinfo.etunicorn.data.Event; |
21 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | 22 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; |
22 | 23 | ||
@@ -26,7 +27,7 @@ import org.json.JSONObject; | @@ -26,7 +27,7 @@ import org.json.JSONObject; | ||
26 | import java.util.Locale; | 27 | import java.util.Locale; |
27 | 28 | ||
28 | 29 | ||
29 | -public class PaiementEvent extends DialogFragment { | 30 | +public class PaiementEvent extends DialogFragment implements NFCSupport { |
30 | 31 | ||
31 | ProgressBar mProgressBar; | 32 | ProgressBar mProgressBar; |
32 | TextView mPaiementEventName; | 33 | TextView mPaiementEventName; |
app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java
@@ -145,7 +145,7 @@ public class MainActivity extends AppCompatActivity | @@ -145,7 +145,7 @@ public class MainActivity extends AppCompatActivity | ||
145 | super.onNewIntent(intent); | 145 | super.onNewIntent(intent); |
146 | if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) { | 146 | if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) { |
147 | Tag myTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); | 147 | Tag myTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); |
148 | - FragmentNFC fNFC = (FragmentNFC) getSupportFragmentManager().getFragments().get(mViewPager.getCurrentItem()); | 148 | + NFCSupport fNFC = (NFCSupport) getSupportFragmentManager().getFragments().get(mViewPager.getCurrentItem()); |
149 | fNFC.processNFC(ConvertBytesToString.bytesToHexString(myTag.getId())); | 149 | fNFC.processNFC(ConvertBytesToString.bytesToHexString(myTag.getId())); |
150 | } | 150 | } |
151 | } | 151 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/FragmentNFC.java renamed to app/src/main/java/net/plil/clubinfo/etunicorn/app/NFCSupport.java
1 | package net.plil.clubinfo.etunicorn.app; | 1 | package net.plil.clubinfo.etunicorn.app; |
2 | 2 | ||
3 | -import android.support.v4.app.Fragment; | ||
4 | -import android.view.View; | ||
5 | - | ||
6 | /** | 3 | /** |
7 | - * Created by badetitou on 28/01/2017. | 4 | + * Created by badetitou on 05/02/2017. |
8 | */ | 5 | */ |
9 | 6 | ||
10 | -public abstract class FragmentNFC extends Fragment { | ||
11 | - public abstract void processNFC(String idCardUser); | 7 | +public interface NFCSupport { |
8 | + | ||
9 | + void processNFC(String idCard); | ||
12 | } | 10 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/FragmentConsommation.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.content.Context; | 3 | import android.content.Context; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.support.design.widget.FloatingActionButton; | 5 | import android.support.design.widget.FloatingActionButton; |
6 | +import android.support.v4.app.Fragment; | ||
6 | import android.support.v7.widget.LinearLayoutManager; | 7 | import android.support.v7.widget.LinearLayoutManager; |
7 | import android.support.v7.widget.RecyclerView; | 8 | import android.support.v7.widget.RecyclerView; |
8 | import android.view.LayoutInflater; | 9 | import android.view.LayoutInflater; |
@@ -11,7 +12,7 @@ import android.view.ViewGroup; | @@ -11,7 +12,7 @@ import android.view.ViewGroup; | ||
11 | import android.widget.Toast; | 12 | import android.widget.Toast; |
12 | 13 | ||
13 | import net.plil.clubinfo.etunicorn.R; | 14 | import net.plil.clubinfo.etunicorn.R; |
14 | -import net.plil.clubinfo.etunicorn.app.FragmentNFC; | 15 | +import net.plil.clubinfo.etunicorn.app.NFCSupport; |
15 | import net.plil.clubinfo.etunicorn.data.Consommation; | 16 | import net.plil.clubinfo.etunicorn.data.Consommation; |
16 | 17 | ||
17 | import java.util.ArrayList; | 18 | import java.util.ArrayList; |
@@ -23,7 +24,7 @@ import java.util.List; | @@ -23,7 +24,7 @@ import java.util.List; | ||
23 | * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener} | 24 | * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener} |
24 | * interface. | 25 | * interface. |
25 | */ | 26 | */ |
26 | -public class FragmentConsommation extends FragmentNFC { | 27 | +public class FragmentConsommation extends Fragment implements NFCSupport { |
27 | 28 | ||
28 | private OnListFragmentInteractionListener mListener; | 29 | private OnListFragmentInteractionListener mListener; |
29 | 30 |
app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/PaiementConsommation.java
@@ -18,6 +18,7 @@ import com.android.volley.VolleyError; | @@ -18,6 +18,7 @@ import com.android.volley.VolleyError; | ||
18 | import com.android.volley.toolbox.JsonObjectRequest; | 18 | import com.android.volley.toolbox.JsonObjectRequest; |
19 | 19 | ||
20 | import net.plil.clubinfo.etunicorn.R; | 20 | import net.plil.clubinfo.etunicorn.R; |
21 | +import net.plil.clubinfo.etunicorn.app.NFCSupport; | ||
21 | import net.plil.clubinfo.etunicorn.app.event.PaiementEvent; | 22 | import net.plil.clubinfo.etunicorn.app.event.PaiementEvent; |
22 | import net.plil.clubinfo.etunicorn.data.Consommation; | 23 | import net.plil.clubinfo.etunicorn.data.Consommation; |
23 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | 24 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; |
@@ -28,7 +29,7 @@ import org.json.JSONObject; | @@ -28,7 +29,7 @@ import org.json.JSONObject; | ||
28 | import java.util.Locale; | 29 | import java.util.Locale; |
29 | 30 | ||
30 | 31 | ||
31 | -public class PaiementConsommation extends DialogFragment { | 32 | +public class PaiementConsommation extends DialogFragment implements NFCSupport { |
32 | 33 | ||
33 | ProgressBar mProgressBar; | 34 | ProgressBar mProgressBar; |
34 | TextView mPaiementConsommationName; | 35 | TextView mPaiementConsommationName; |
@@ -84,7 +85,7 @@ public class PaiementConsommation extends DialogFragment { | @@ -84,7 +85,7 @@ public class PaiementConsommation extends DialogFragment { | ||
84 | 85 | ||
85 | 86 | ||
86 | public void processNFC(String idCardUser) { | 87 | public void processNFC(String idCardUser) { |
87 | - Toast.makeText(getContext(), "Hello " + idCardUser, Toast.LENGTH_LONG).show(); | 88 | + Toast.makeText(getContext(), idCardUser, Toast.LENGTH_LONG).show(); |
88 | mProgressBar.setVisibility(View.VISIBLE); | 89 | mProgressBar.setVisibility(View.VISIBLE); |
89 | JSONObject jsonObject = new JSONObject(); | 90 | JSONObject jsonObject = new JSONObject(); |
90 | try { | 91 | try { |
app/src/main/java/net/plil/clubinfo/etunicorn/app/credit/Crediter.java
@@ -4,6 +4,7 @@ import android.content.Context; | @@ -4,6 +4,7 @@ import android.content.Context; | ||
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.support.design.widget.CoordinatorLayout; | 5 | import android.support.design.widget.CoordinatorLayout; |
6 | import android.support.design.widget.Snackbar; | 6 | import android.support.design.widget.Snackbar; |
7 | +import android.support.v4.app.Fragment; | ||
7 | import android.view.LayoutInflater; | 8 | import android.view.LayoutInflater; |
8 | import android.view.View; | 9 | import android.view.View; |
9 | import android.view.ViewGroup; | 10 | import android.view.ViewGroup; |
@@ -16,14 +17,14 @@ import com.android.volley.VolleyError; | @@ -16,14 +17,14 @@ import com.android.volley.VolleyError; | ||
16 | import com.android.volley.toolbox.JsonObjectRequest; | 17 | import com.android.volley.toolbox.JsonObjectRequest; |
17 | 18 | ||
18 | import net.plil.clubinfo.etunicorn.R; | 19 | import net.plil.clubinfo.etunicorn.R; |
19 | -import net.plil.clubinfo.etunicorn.app.FragmentNFC; | 20 | +import net.plil.clubinfo.etunicorn.app.NFCSupport; |
20 | import net.plil.clubinfo.etunicorn.data.Personne; | 21 | import net.plil.clubinfo.etunicorn.data.Personne; |
21 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | 22 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; |
22 | 23 | ||
23 | import org.json.JSONException; | 24 | import org.json.JSONException; |
24 | import org.json.JSONObject; | 25 | import org.json.JSONObject; |
25 | 26 | ||
26 | -public class Crediter extends FragmentNFC { | 27 | +public class Crediter extends Fragment implements NFCSupport{ |
27 | 28 | ||
28 | private EditText mMoneyEditText; | 29 | private EditText mMoneyEditText; |
29 | private ProgressBar mProgressBar; | 30 | private ProgressBar mProgressBar; |
app/src/main/java/net/plil/clubinfo/etunicorn/app/debit/Debiter.java
@@ -5,6 +5,7 @@ import android.os.Bundle; | @@ -5,6 +5,7 @@ import android.os.Bundle; | ||
5 | import android.support.design.widget.CoordinatorLayout; | 5 | import android.support.design.widget.CoordinatorLayout; |
6 | import android.support.design.widget.Snackbar; | 6 | import android.support.design.widget.Snackbar; |
7 | import android.support.design.widget.TextInputEditText; | 7 | import android.support.design.widget.TextInputEditText; |
8 | +import android.support.v4.app.Fragment; | ||
8 | import android.view.LayoutInflater; | 9 | import android.view.LayoutInflater; |
9 | import android.view.View; | 10 | import android.view.View; |
10 | import android.view.ViewGroup; | 11 | import android.view.ViewGroup; |
@@ -16,14 +17,14 @@ import com.android.volley.VolleyError; | @@ -16,14 +17,14 @@ import com.android.volley.VolleyError; | ||
16 | import com.android.volley.toolbox.JsonObjectRequest; | 17 | import com.android.volley.toolbox.JsonObjectRequest; |
17 | 18 | ||
18 | import net.plil.clubinfo.etunicorn.R; | 19 | import net.plil.clubinfo.etunicorn.R; |
19 | -import net.plil.clubinfo.etunicorn.app.FragmentNFC; | 20 | +import net.plil.clubinfo.etunicorn.app.NFCSupport; |
20 | import net.plil.clubinfo.etunicorn.data.Personne; | 21 | import net.plil.clubinfo.etunicorn.data.Personne; |
21 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | 22 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; |
22 | 23 | ||
23 | import org.json.JSONException; | 24 | import org.json.JSONException; |
24 | import org.json.JSONObject; | 25 | import org.json.JSONObject; |
25 | 26 | ||
26 | -public class Debiter extends FragmentNFC { | 27 | +public class Debiter extends Fragment implements NFCSupport { |
27 | 28 | ||
28 | 29 | ||
29 | private TextInputEditText mMoneyEditText; | 30 | private TextInputEditText mMoneyEditText; |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/CreatePersonne.java
@@ -24,9 +24,9 @@ import com.android.volley.Response; | @@ -24,9 +24,9 @@ import com.android.volley.Response; | ||
24 | import com.android.volley.VolleyError; | 24 | import com.android.volley.VolleyError; |
25 | import com.android.volley.toolbox.JsonArrayRequest; | 25 | import com.android.volley.toolbox.JsonArrayRequest; |
26 | import com.android.volley.toolbox.JsonObjectRequest; | 26 | import com.android.volley.toolbox.JsonObjectRequest; |
27 | -import com.google.gson.Gson; | ||
28 | 27 | ||
29 | import net.plil.clubinfo.etunicorn.R; | 28 | 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.data.Role; | 31 | import net.plil.clubinfo.etunicorn.data.Role; |
32 | import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; | 32 | import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; |
@@ -46,7 +46,7 @@ import java.util.Locale; | @@ -46,7 +46,7 @@ import java.util.Locale; | ||
46 | import java.util.Map; | 46 | import java.util.Map; |
47 | 47 | ||
48 | 48 | ||
49 | -public class CreatePersonne extends DialogFragment { | 49 | +public class CreatePersonne extends DialogFragment implements NFCSupport { |
50 | 50 | ||
51 | 51 | ||
52 | Calendar myCalendar = Calendar.getInstance(); | 52 | Calendar myCalendar = Calendar.getInstance(); |
@@ -236,4 +236,9 @@ public class CreatePersonne extends DialogFragment { | @@ -236,4 +236,9 @@ public class CreatePersonne extends DialogFragment { | ||
236 | dismissAllowingStateLoss(); | 236 | dismissAllowingStateLoss(); |
237 | super.onStop(); | 237 | super.onStop(); |
238 | } | 238 | } |
239 | + | ||
240 | + @Override | ||
241 | + public void processNFC(String idCard) { | ||
242 | + mCarte.setText(idCard); | ||
243 | + } | ||
239 | } | 244 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/ModifyPersonne.java
@@ -24,12 +24,9 @@ import com.android.volley.Response; | @@ -24,12 +24,9 @@ import com.android.volley.Response; | ||
24 | import com.android.volley.VolleyError; | 24 | import com.android.volley.VolleyError; |
25 | import com.android.volley.toolbox.JsonArrayRequest; | 25 | import com.android.volley.toolbox.JsonArrayRequest; |
26 | import com.android.volley.toolbox.JsonObjectRequest; | 26 | import com.android.volley.toolbox.JsonObjectRequest; |
27 | -import com.google.gson.Gson; | ||
28 | -import com.google.gson.JsonArray; | ||
29 | -import com.google.gson.JsonObject; | ||
30 | -import com.google.gson.JsonParser; | ||
31 | 27 | ||
32 | import net.plil.clubinfo.etunicorn.R; | 28 | import net.plil.clubinfo.etunicorn.R; |
29 | +import net.plil.clubinfo.etunicorn.app.NFCSupport; | ||
33 | import net.plil.clubinfo.etunicorn.app.MainActivity; | 30 | import net.plil.clubinfo.etunicorn.app.MainActivity; |
34 | import net.plil.clubinfo.etunicorn.data.Personne; | 31 | import net.plil.clubinfo.etunicorn.data.Personne; |
35 | import net.plil.clubinfo.etunicorn.data.Role; | 32 | import net.plil.clubinfo.etunicorn.data.Role; |
@@ -50,7 +47,7 @@ import java.util.Locale; | @@ -50,7 +47,7 @@ import java.util.Locale; | ||
50 | import java.util.Map; | 47 | import java.util.Map; |
51 | 48 | ||
52 | 49 | ||
53 | -public class ModifyPersonne extends DialogFragment { | 50 | +public class ModifyPersonne extends DialogFragment implements NFCSupport { |
54 | 51 | ||
55 | Calendar myCalendar = Calendar.getInstance(); | 52 | Calendar myCalendar = Calendar.getInstance(); |
56 | 53 | ||
@@ -271,4 +268,10 @@ public class ModifyPersonne extends DialogFragment { | @@ -271,4 +268,10 @@ public class ModifyPersonne extends DialogFragment { | ||
271 | jsonArrayRequest.setTag(ModifyPersonne.class); | 268 | jsonArrayRequest.setTag(ModifyPersonne.class); |
272 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonArrayRequest); | 269 | VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonArrayRequest); |
273 | } | 270 | } |
271 | + | ||
272 | + | ||
273 | + @Override | ||
274 | + public void processNFC(String idCard) { | ||
275 | + mCarte.setText(idCard); | ||
276 | + } | ||
274 | } | 277 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/MyPersonneRecyclerViewAdapter.java
@@ -74,11 +74,11 @@ public class MyPersonneRecyclerViewAdapter extends RecyclerView.Adapter<MyPerson | @@ -74,11 +74,11 @@ public class MyPersonneRecyclerViewAdapter extends RecyclerView.Adapter<MyPerson | ||
74 | switch (item.getItemId()) { | 74 | switch (item.getItemId()) { |
75 | case R.id.delete: | 75 | case R.id.delete: |
76 | DeletePersonne deletePersonne = DeletePersonne.newInstance(holder.mItem); | 76 | DeletePersonne deletePersonne = DeletePersonne.newInstance(holder.mItem); |
77 | - deletePersonne.show(((AppCompatActivity) context).getSupportFragmentManager(), "deleteConsommation"); | 77 | + deletePersonne.show(((AppCompatActivity) context).getSupportFragmentManager(), context.getString(R.string.tag_delete_personne)); |
78 | break; | 78 | break; |
79 | case R.id.modify: | 79 | case R.id.modify: |
80 | ModifyPersonne modifyPersonne = ModifyPersonne.newInstance(holder.mItem); | 80 | ModifyPersonne modifyPersonne = ModifyPersonne.newInstance(holder.mItem); |
81 | - modifyPersonne.show(((AppCompatActivity) context).getSupportFragmentManager(), "modifyConsommation"); | 81 | + modifyPersonne.show(((AppCompatActivity) context).getSupportFragmentManager(), context.getString(R.string.tag_modify_personne)); |
82 | break; | 82 | break; |
83 | } | 83 | } |
84 | return false; | 84 | return false; |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/PersonneFragment.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.content.Context; | 3 | import android.content.Context; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.support.design.widget.FloatingActionButton; | 5 | import android.support.design.widget.FloatingActionButton; |
6 | +import android.support.v4.app.Fragment; | ||
6 | import android.support.v7.widget.LinearLayoutManager; | 7 | import android.support.v7.widget.LinearLayoutManager; |
7 | import android.support.v7.widget.RecyclerView; | 8 | import android.support.v7.widget.RecyclerView; |
8 | import android.view.LayoutInflater; | 9 | import android.view.LayoutInflater; |
@@ -17,7 +18,7 @@ import com.android.volley.VolleyError; | @@ -17,7 +18,7 @@ import com.android.volley.VolleyError; | ||
17 | import com.android.volley.toolbox.JsonArrayRequest; | 18 | import com.android.volley.toolbox.JsonArrayRequest; |
18 | 19 | ||
19 | import net.plil.clubinfo.etunicorn.R; | 20 | import net.plil.clubinfo.etunicorn.R; |
20 | -import net.plil.clubinfo.etunicorn.app.FragmentNFC; | 21 | +import net.plil.clubinfo.etunicorn.app.NFCSupport; |
21 | import net.plil.clubinfo.etunicorn.app.MainActivity; | 22 | import net.plil.clubinfo.etunicorn.app.MainActivity; |
22 | import net.plil.clubinfo.etunicorn.data.Personne; | 23 | import net.plil.clubinfo.etunicorn.data.Personne; |
23 | import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; | 24 | import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; |
@@ -37,7 +38,7 @@ import java.util.Map; | @@ -37,7 +38,7 @@ import java.util.Map; | ||
37 | * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener} | 38 | * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener} |
38 | * interface. | 39 | * interface. |
39 | */ | 40 | */ |
40 | -public class PersonneFragment extends FragmentNFC { | 41 | +public class PersonneFragment extends Fragment implements NFCSupport { |
41 | 42 | ||
42 | private OnListFragmentInteractionListener mListener; | 43 | private OnListFragmentInteractionListener mListener; |
43 | private ArrayList<Personne> personnes = new ArrayList<>(); | 44 | private ArrayList<Personne> personnes = new ArrayList<>(); |
@@ -76,7 +77,7 @@ public class PersonneFragment extends FragmentNFC { | @@ -76,7 +77,7 @@ public class PersonneFragment extends FragmentNFC { | ||
76 | @Override | 77 | @Override |
77 | public void onClick(View v) { | 78 | public void onClick(View v) { |
78 | CreatePersonne newFragment = new CreatePersonne(); | 79 | CreatePersonne newFragment = new CreatePersonne(); |
79 | - newFragment.show(getFragmentManager(), "CreateEvent"); | 80 | + newFragment.show(getFragmentManager(), getString(R.string.tag_create_personne)); |
80 | } | 81 | } |
81 | }); | 82 | }); |
82 | 83 | ||
@@ -136,6 +137,13 @@ public class PersonneFragment extends FragmentNFC { | @@ -136,6 +137,13 @@ public class PersonneFragment extends FragmentNFC { | ||
136 | 137 | ||
137 | @Override | 138 | @Override |
138 | public void processNFC(String idCardUser) { | 139 | public void processNFC(String idCardUser) { |
140 | + CreatePersonne createPersonne = (CreatePersonne) getFragmentManager().findFragmentByTag(getString(R.string.tag_create_personne)); | ||
141 | + if (createPersonne != null){ | ||
142 | + createPersonne.processNFC(idCardUser); | ||
143 | + } | ||
144 | + else { | ||
145 | + ModifyPersonne modifyPersonne = (ModifyPersonne) getFragmentManager().findFragmentByTag(getString(R.string.tag_modify_personne)); | ||
146 | + } | ||
139 | 147 | ||
140 | } | 148 | } |
141 | 149 |
app/src/main/res/values/strings.xml
@@ -59,4 +59,7 @@ | @@ -59,4 +59,7 @@ | ||
59 | <string name="modify_personne_hint_date">Birthday</string> | 59 | <string name="modify_personne_hint_date">Birthday</string> |
60 | <string name="error_create_personne_login">Need a login or a carte ID</string> | 60 | <string name="error_create_personne_login">Need a login or a carte ID</string> |
61 | <string name="error_create_personne_login_carte">Need a login or a carte ID</string> | 61 | <string name="error_create_personne_login_carte">Need a login or a carte ID</string> |
62 | + <string name="tag_create_personne">createPersonne</string> | ||
63 | + <string name="tag_modify_personne">modifyPersonne</string> | ||
64 | + <string name="tag_delete_personne">deletePersonne</string> | ||
62 | </resources> | 65 | </resources> |