Commit be985098e3ea9fb4dab0f02fa7209432e98cfa4a

Authored by badetitou
1 parent dd839264

Abstract class NFC

app/src/main/java/net/plil/clubinfo/etunicorn/app/Crediter.java
... ... @@ -25,11 +25,9 @@ import net.plil.clubinfo.etunicorn.R;
25 25 * Use the {@link Crediter#newInstance} factory method to
26 26 * create an instance of this fragment.
27 27 */
28   -public class Crediter extends Fragment {
  28 +public class Crediter extends FragmentNFC {
29 29 NfcAdapter mNfcAdapter;
30 30  
31   -
32   -
33 31 private OnFragmentInteractionListener mListener;
34 32  
35 33 public Crediter() {
... ... @@ -86,8 +84,9 @@ public class Crediter extends Fragment {
86 84 mListener = null;
87 85 }
88 86  
89   - public void processNFC(){
90   - Toast.makeText(getContext(), "HELLO NFC", Toast.LENGTH_LONG).show();
  87 + @Override
  88 + public void processNFC() {
  89 +
91 90 }
92 91  
93 92  
... ...
app/src/main/java/net/plil/clubinfo/etunicorn/app/Debiter.java
... ... @@ -18,7 +18,7 @@ import net.plil.clubinfo.etunicorn.R;
18 18 * Use the {@link Debiter#newInstance} factory method to
19 19 * create an instance of this fragment.
20 20 */
21   -public class Debiter extends Fragment {
  21 +public class Debiter extends FragmentNFC {
22 22 // TODO: Rename parameter arguments, choose names that match
23 23 // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
24 24 private static final String ARG_PARAM1 = "param1";
... ... @@ -92,6 +92,11 @@ public class Debiter extends Fragment {
92 92 mListener = null;
93 93 }
94 94  
  95 + @Override
  96 + public void processNFC() {
  97 +
  98 + }
  99 +
95 100 /**
96 101 * This interface must be implemented by activities that contain this
97 102 * fragment to allow an interaction in this fragment to be communicated
... ...
app/src/main/java/net/plil/clubinfo/etunicorn/app/FragmentNFC.java 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +package net.plil.clubinfo.etunicorn.app;
  2 +
  3 +import android.support.v4.app.Fragment;
  4 +
  5 +/**
  6 + * Created by badetitou on 28/01/2017.
  7 + */
  8 +
  9 +public abstract class FragmentNFC extends Fragment {
  10 + public abstract void processNFC();
  11 +}
... ...
app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java
... ... @@ -106,9 +106,8 @@ public class MainActivity extends AppCompatActivity {
106 106 @Override
107 107 protected void onNewIntent(Intent intent) {
108 108 super.onNewIntent(intent);
109   - Toast.makeText(getBaseContext(), mViewPager.getCurrentItem()+" NFC WORKING", Toast.LENGTH_LONG).show();
110   - Toast.makeText(getBaseContext(), intent.getParcelableExtra(NfcAdapter.EXTRA_TAG) + "", Toast.LENGTH_LONG).show();
111   -
  109 + ((FragmentNFC)mSectionsPagerAdapter.getItem(mViewPager.getCurrentItem())).processNFC();
  110 + Toast.makeText(getBaseContext(),"NFC WORKING", Toast.LENGTH_LONG).show();
112 111 }
113 112  
114 113 @Override
... ...