Commit d6367fe9394b7cc05e769c3aab4e3bd71cbe23ba
1 parent
6790f988
Ajout liste
Consomation et le boutton qui va avec
Showing
12 changed files
with
426 additions
and
49 deletions
Show diff stats
app/build.gradle
@@ -29,5 +29,7 @@ dependencies { | @@ -29,5 +29,7 @@ dependencies { | ||
29 | compile 'com.android.volley:volley:1.0.0' | 29 | compile 'com.android.volley:volley:1.0.0' |
30 | compile 'com.google.code.gson:gson:2.4' | 30 | compile 'com.google.code.gson:gson:2.4' |
31 | compile 'com.android.support:support-v4:24.2.1' | 31 | compile 'com.android.support:support-v4:24.2.1' |
32 | + compile 'com.android.support:recyclerview-v7:24.2.1' | ||
32 | testCompile 'junit:junit:4.12' | 33 | testCompile 'junit:junit:4.12' |
34 | + compile 'com.android.support:gridlayout-v7:24.2.1' | ||
33 | } | 35 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/ConsomationRecyclerViewAdapter.java
0 → 100644
@@ -0,0 +1,77 @@ | @@ -0,0 +1,77 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.app; | ||
2 | + | ||
3 | +import android.support.v7.widget.RecyclerView; | ||
4 | +import android.view.LayoutInflater; | ||
5 | +import android.view.View; | ||
6 | +import android.view.ViewGroup; | ||
7 | +import android.widget.TextView; | ||
8 | + | ||
9 | +import net.plil.clubinfo.etunicorn.R; | ||
10 | +import net.plil.clubinfo.etunicorn.data.Consomation; | ||
11 | + | ||
12 | +import java.util.List; | ||
13 | +import java.util.Locale; | ||
14 | + | ||
15 | + | ||
16 | +public class ConsomationRecyclerViewAdapter extends RecyclerView.Adapter<ConsomationRecyclerViewAdapter.ViewHolder> { | ||
17 | + | ||
18 | + private final List<net.plil.clubinfo.etunicorn.data.Consomation> mValues; | ||
19 | + private final FragmentConsomation.OnListFragmentInteractionListener mListener; | ||
20 | + | ||
21 | + public ConsomationRecyclerViewAdapter(List<net.plil.clubinfo.etunicorn.data.Consomation> items, FragmentConsomation.OnListFragmentInteractionListener listener) { | ||
22 | + mValues = items; | ||
23 | + mListener = listener; | ||
24 | + } | ||
25 | + | ||
26 | + @Override | ||
27 | + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
28 | + View view = LayoutInflater.from(parent.getContext()) | ||
29 | + .inflate(R.layout.fragment_consomation_item, parent, false); | ||
30 | + return new ViewHolder(view); | ||
31 | + } | ||
32 | + | ||
33 | + @Override | ||
34 | + public void onBindViewHolder(final ViewHolder holder, int position) { | ||
35 | + holder.mItem = mValues.get(position); | ||
36 | + holder.mIdView.setText(String.format(Locale.FRANCE, "%d", mValues.get(position).getIdConsomation())); | ||
37 | + holder.mContentView.setText(mValues.get(position).getNomConsomation()); | ||
38 | + holder.mPriceView.setText(String.format(Locale.FRANCE, "%f",mValues.get(position).getPrix())); | ||
39 | + | ||
40 | + holder.mView.setOnClickListener(new View.OnClickListener() { | ||
41 | + @Override | ||
42 | + public void onClick(View v) { | ||
43 | + if (null != mListener) { | ||
44 | + // Notify the active callbacks interface (the activity, if the | ||
45 | + // fragment is attached to one) that an item has been selected. | ||
46 | + mListener.onListFragmentInteraction(holder.mItem); | ||
47 | + } | ||
48 | + } | ||
49 | + }); | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public int getItemCount() { | ||
54 | + return mValues.size(); | ||
55 | + } | ||
56 | + | ||
57 | + public class ViewHolder extends RecyclerView.ViewHolder { | ||
58 | + public final View mView; | ||
59 | + public final TextView mIdView; | ||
60 | + public final TextView mContentView; | ||
61 | + public final TextView mPriceView; | ||
62 | + public Consomation mItem; | ||
63 | + | ||
64 | + public ViewHolder(View view) { | ||
65 | + super(view); | ||
66 | + mView = view; | ||
67 | + mIdView = (TextView) view.findViewById(R.id.consomation_id); | ||
68 | + mContentView = (TextView) view.findViewById(R.id.consomation_name); | ||
69 | + mPriceView = (TextView) view.findViewById(R.id.consomation_price); | ||
70 | + } | ||
71 | + | ||
72 | + @Override | ||
73 | + public String toString() { | ||
74 | + return super.toString() + " '" + mContentView.getText() + "'"; | ||
75 | + } | ||
76 | + } | ||
77 | +} |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Crediter.java
1 | package net.plil.clubinfo.etunicorn.app; | 1 | package net.plil.clubinfo.etunicorn.app; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | -import android.content.Intent; | ||
5 | import android.net.Uri; | 4 | import android.net.Uri; |
6 | -import android.nfc.NdefMessage; | ||
7 | -import android.nfc.NfcAdapter; | ||
8 | -import android.nfc.NfcEvent; | ||
9 | import android.os.Bundle; | 5 | import android.os.Bundle; |
10 | -import android.os.Parcelable; | ||
11 | -import android.support.design.widget.Snackbar; | ||
12 | import android.support.v4.app.Fragment; | 6 | import android.support.v4.app.Fragment; |
13 | import android.view.LayoutInflater; | 7 | import android.view.LayoutInflater; |
14 | import android.view.View; | 8 | import android.view.View; |
15 | import android.view.ViewGroup; | 9 | import android.view.ViewGroup; |
10 | +import android.widget.EditText; | ||
11 | +import android.widget.ProgressBar; | ||
16 | import android.widget.Toast; | 12 | import android.widget.Toast; |
17 | 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 | + | ||
18 | import net.plil.clubinfo.etunicorn.R; | 19 | import net.plil.clubinfo.etunicorn.R; |
20 | +import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | ||
21 | + | ||
22 | +import org.json.JSONException; | ||
23 | +import org.json.JSONObject; | ||
19 | 24 | ||
20 | /** | 25 | /** |
21 | * A simple {@link Fragment} subclass. | 26 | * A simple {@link Fragment} subclass. |
@@ -26,44 +31,33 @@ import net.plil.clubinfo.etunicorn.R; | @@ -26,44 +31,33 @@ import net.plil.clubinfo.etunicorn.R; | ||
26 | * create an instance of this fragment. | 31 | * create an instance of this fragment. |
27 | */ | 32 | */ |
28 | public class Crediter extends FragmentNFC { | 33 | public class Crediter extends FragmentNFC { |
29 | - NfcAdapter mNfcAdapter; | 34 | + |
30 | 35 | ||
31 | private OnFragmentInteractionListener mListener; | 36 | private OnFragmentInteractionListener mListener; |
32 | 37 | ||
38 | + private EditText mMoneyEditText; | ||
39 | + private ProgressBar mProgressBar; | ||
40 | + | ||
33 | public Crediter() { | 41 | public Crediter() { |
34 | // Required empty public constructor | 42 | // Required empty public constructor |
35 | } | 43 | } |
36 | 44 | ||
37 | - /** | ||
38 | - * Use this factory method to create a new instance of | ||
39 | - * this fragment using the provided parameters. | ||
40 | - * | ||
41 | - * @return A new instance of fragment Crediter. | ||
42 | - */ | ||
43 | public static Crediter newInstance() { | 45 | public static Crediter newInstance() { |
44 | - Crediter fragment = new Crediter(); | ||
45 | - return fragment; | 46 | + return new Crediter(); |
46 | } | 47 | } |
47 | 48 | ||
48 | @Override | 49 | @Override |
49 | public void onCreate(Bundle savedInstanceState) { | 50 | public void onCreate(Bundle savedInstanceState) { |
50 | super.onCreate(savedInstanceState); | 51 | super.onCreate(savedInstanceState); |
51 | - mNfcAdapter = NfcAdapter.getDefaultAdapter(getContext()); | ||
52 | - if (mNfcAdapter == null) { | ||
53 | - Toast.makeText(getActivity(), "NFC is not available", Toast.LENGTH_LONG).show(); | ||
54 | - return; | ||
55 | - } | ||
56 | - if (!mNfcAdapter.isEnabled()){ | ||
57 | - Toast.makeText(getActivity(), "NFC is not enabled, please turn it on", Toast.LENGTH_LONG).show(); | ||
58 | - } | ||
59 | - | ||
60 | } | 52 | } |
61 | 53 | ||
62 | @Override | 54 | @Override |
63 | public View onCreateView(LayoutInflater inflater, ViewGroup container, | 55 | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
64 | Bundle savedInstanceState) { | 56 | Bundle savedInstanceState) { |
65 | - // Inflate the layout for this fragment | ||
66 | - return inflater.inflate(R.layout.fragment_crediter, container, false); | 57 | + View view = inflater.inflate(R.layout.fragment_crediter, container, false); |
58 | + mMoneyEditText = (EditText) view.findViewById(R.id.crediter_ask_money); | ||
59 | + mProgressBar = (ProgressBar) view.findViewById(R.id.crediter_progress_bar); | ||
60 | + return view; | ||
67 | } | 61 | } |
68 | 62 | ||
69 | 63 | ||
@@ -88,7 +82,29 @@ public class Crediter extends FragmentNFC { | @@ -88,7 +82,29 @@ public class Crediter extends FragmentNFC { | ||
88 | 82 | ||
89 | @Override | 83 | @Override |
90 | public void processNFC() { | 84 | public void processNFC() { |
91 | - Toast.makeText(getContext(), "DONE !!!!", Toast.LENGTH_LONG).show(); | 85 | + mProgressBar.setVisibility(View.VISIBLE); |
86 | + JSONObject jsonObject = new JSONObject(); | ||
87 | + try { | ||
88 | + jsonObject.put("participant", 1); | ||
89 | + jsonObject.put("acteur", 2); | ||
90 | + jsonObject.put("prix", Double.parseDouble(mMoneyEditText.getText().toString())); | ||
91 | + } catch (JSONException e){ | ||
92 | + e.printStackTrace(); | ||
93 | + } | ||
94 | + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/transaction/debit" ,jsonObject , new Response.Listener<JSONObject>() { | ||
95 | + @Override | ||
96 | + public void onResponse(JSONObject response) { | ||
97 | + mProgressBar.setVisibility(View.GONE); | ||
98 | + } | ||
99 | + }, new Response.ErrorListener() { | ||
100 | + @Override | ||
101 | + public void onErrorResponse(VolleyError error) { | ||
102 | + mProgressBar.setVisibility(View.GONE); | ||
103 | + } | ||
104 | + } | ||
105 | + ); | ||
106 | + | ||
107 | + VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | ||
92 | } | 108 | } |
93 | 109 | ||
94 | 110 |
app/src/main/java/net/plil/clubinfo/etunicorn/app/Debiter.java
@@ -36,7 +36,7 @@ import org.json.JSONObject; | @@ -36,7 +36,7 @@ import org.json.JSONObject; | ||
36 | * create an instance of this fragment. | 36 | * create an instance of this fragment. |
37 | */ | 37 | */ |
38 | public class Debiter extends FragmentNFC { | 38 | public class Debiter extends FragmentNFC { |
39 | - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER | 39 | + |
40 | 40 | ||
41 | private EditText mMoneyEditText; | 41 | private EditText mMoneyEditText; |
42 | private ProgressBar mProgressBar; | 42 | private ProgressBar mProgressBar; |
@@ -49,8 +49,7 @@ public class Debiter extends FragmentNFC { | @@ -49,8 +49,7 @@ public class Debiter extends FragmentNFC { | ||
49 | } | 49 | } |
50 | 50 | ||
51 | public static Debiter newInstance() { | 51 | public static Debiter newInstance() { |
52 | - Debiter fragment = new Debiter(); | ||
53 | - return fragment; | 52 | + return new Debiter(); |
54 | } | 53 | } |
55 | 54 | ||
56 | @Override | 55 | @Override |
app/src/main/java/net/plil/clubinfo/etunicorn/app/FragmentConsomation.java
0 → 100644
@@ -0,0 +1,117 @@ | @@ -0,0 +1,117 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.app; | ||
2 | + | ||
3 | +import android.content.Context; | ||
4 | +import android.os.Bundle; | ||
5 | +import android.support.v4.app.Fragment; | ||
6 | +import android.support.v7.widget.GridLayoutManager; | ||
7 | +import android.support.v7.widget.LinearLayoutManager; | ||
8 | +import android.support.v7.widget.RecyclerView; | ||
9 | +import android.view.LayoutInflater; | ||
10 | +import android.view.View; | ||
11 | +import android.view.ViewGroup; | ||
12 | + | ||
13 | +import net.plil.clubinfo.etunicorn.R; | ||
14 | +import net.plil.clubinfo.etunicorn.data.Consomation; | ||
15 | + | ||
16 | +import java.util.ArrayList; | ||
17 | +import java.util.List; | ||
18 | + | ||
19 | +/** | ||
20 | + * A fragment representing a list of Items. | ||
21 | + * <p/> | ||
22 | + * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener} | ||
23 | + * interface. | ||
24 | + */ | ||
25 | +public class FragmentConsomation extends FragmentNFC { | ||
26 | + | ||
27 | + private int mColumnCount = 1; | ||
28 | + private OnListFragmentInteractionListener mListener; | ||
29 | + | ||
30 | + /** | ||
31 | + * Mandatory empty constructor for the fragment manager to instantiate the | ||
32 | + * fragment (e.g. upon screen orientation changes). | ||
33 | + */ | ||
34 | + public FragmentConsomation() { | ||
35 | + } | ||
36 | + | ||
37 | + public static FragmentConsomation newInstance() { | ||
38 | + return new FragmentConsomation(); | ||
39 | + } | ||
40 | + | ||
41 | + @Override | ||
42 | + public void onCreate(Bundle savedInstanceState) { | ||
43 | + super.onCreate(savedInstanceState); | ||
44 | + } | ||
45 | + | ||
46 | + @Override | ||
47 | + public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
48 | + Bundle savedInstanceState) { | ||
49 | + View view = inflater.inflate(R.layout.fragment_consomation_item_list, container, false); | ||
50 | + RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.consomation_list); | ||
51 | + // Set the adapter | ||
52 | + Context context = recyclerView.getContext(); | ||
53 | + if (mColumnCount <= 1) { | ||
54 | + recyclerView.setLayoutManager(new LinearLayoutManager(context)); | ||
55 | + } else { | ||
56 | + recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount)); | ||
57 | + } | ||
58 | + List<Consomation> consomationList = new ArrayList<>(); | ||
59 | + Consomation c1 = new Consomation(); | ||
60 | + c1.setIdConsomation(1); | ||
61 | + c1.setNomConsomation("Hello"); | ||
62 | + c1.setPrix(12.5); | ||
63 | + consomationList.add(c1); | ||
64 | + c1 = new Consomation(); | ||
65 | + c1.setIdConsomation(2); | ||
66 | + c1.setNomConsomation("World"); | ||
67 | + c1.setPrix(42.407); | ||
68 | + consomationList.add(c1); | ||
69 | + for (int i = 0; i< 100; ++i){ | ||
70 | + c1 = new Consomation(); | ||
71 | + c1.setIdConsomation(i); | ||
72 | + c1.setNomConsomation("World"); | ||
73 | + c1.setPrix(42.407); | ||
74 | + consomationList.add(c1); | ||
75 | + } | ||
76 | + recyclerView.setAdapter(new ConsomationRecyclerViewAdapter(consomationList, mListener)); | ||
77 | + | ||
78 | + return view; | ||
79 | + } | ||
80 | + | ||
81 | + | ||
82 | + @Override | ||
83 | + public void onAttach(Context context) { | ||
84 | + super.onAttach(context); | ||
85 | + if (context instanceof OnListFragmentInteractionListener) { | ||
86 | + mListener = (OnListFragmentInteractionListener) context; | ||
87 | + } else { | ||
88 | + throw new RuntimeException(context.toString() | ||
89 | + + " must implement OnListFragmentInteractionListener"); | ||
90 | + } | ||
91 | + } | ||
92 | + | ||
93 | + @Override | ||
94 | + public void onDetach() { | ||
95 | + super.onDetach(); | ||
96 | + mListener = null; | ||
97 | + } | ||
98 | + | ||
99 | + @Override | ||
100 | + public void processNFC() { | ||
101 | + | ||
102 | + } | ||
103 | + | ||
104 | + /** | ||
105 | + * This interface must be implemented by activities that contain this | ||
106 | + * fragment to allow an interaction in this fragment to be communicated | ||
107 | + * to the activity and potentially other fragments contained in that | ||
108 | + * activity. | ||
109 | + * <p/> | ||
110 | + * See the Android Training lesson <a href= | ||
111 | + * "http://developer.android.com/training/basics/fragments/communicating.html" | ||
112 | + * >Communicating with Other Fragments</a> for more information. | ||
113 | + */ | ||
114 | + public interface OnListFragmentInteractionListener { | ||
115 | + void onListFragmentInteraction(Consomation item); | ||
116 | + } | ||
117 | +} |
app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java
@@ -4,24 +4,22 @@ import android.app.PendingIntent; | @@ -4,24 +4,22 @@ 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.os.Bundle; | ||
7 | import android.support.design.widget.TabLayout; | 8 | import android.support.design.widget.TabLayout; |
8 | -import android.support.v7.app.AppCompatActivity; | ||
9 | -import android.support.v7.widget.Toolbar; | ||
10 | - | ||
11 | import android.support.v4.app.Fragment; | 9 | import android.support.v4.app.Fragment; |
12 | import android.support.v4.app.FragmentManager; | 10 | import android.support.v4.app.FragmentManager; |
13 | import android.support.v4.app.FragmentPagerAdapter; | 11 | import android.support.v4.app.FragmentPagerAdapter; |
14 | import android.support.v4.view.ViewPager; | 12 | import android.support.v4.view.ViewPager; |
15 | -import android.os.Bundle; | 13 | +import android.support.v7.app.AppCompatActivity; |
14 | +import android.support.v7.widget.Toolbar; | ||
16 | import android.view.Menu; | 15 | import android.view.Menu; |
17 | import android.view.MenuItem; | 16 | import android.view.MenuItem; |
18 | 17 | ||
19 | -import android.widget.Toast; | ||
20 | - | ||
21 | import net.plil.clubinfo.etunicorn.R; | 18 | import net.plil.clubinfo.etunicorn.R; |
19 | +import net.plil.clubinfo.etunicorn.data.Consomation; | ||
22 | 20 | ||
23 | 21 | ||
24 | -public class MainActivity extends AppCompatActivity implements Crediter.OnFragmentInteractionListener, Debiter.OnFragmentInteractionListener{ | 22 | +public class MainActivity extends AppCompatActivity implements Crediter.OnFragmentInteractionListener, Debiter.OnFragmentInteractionListener, FragmentConsomation.OnListFragmentInteractionListener{ |
25 | 23 | ||
26 | /** | 24 | /** |
27 | * The {@link android.support.v4.view.PagerAdapter} that will provide | 25 | * The {@link android.support.v4.view.PagerAdapter} that will provide |
@@ -121,6 +119,11 @@ public class MainActivity extends AppCompatActivity implements Crediter.OnFragme | @@ -121,6 +119,11 @@ public class MainActivity extends AppCompatActivity implements Crediter.OnFragme | ||
121 | 119 | ||
122 | } | 120 | } |
123 | 121 | ||
122 | + @Override | ||
123 | + public void onListFragmentInteraction(Consomation item) { | ||
124 | + | ||
125 | + } | ||
126 | + | ||
124 | /** | 127 | /** |
125 | * A {@link FragmentPagerAdapter} that returns a fragment corresponding to | 128 | * A {@link FragmentPagerAdapter} that returns a fragment corresponding to |
126 | * one of the sections/tabs/pages. | 129 | * one of the sections/tabs/pages. |
@@ -133,20 +136,19 @@ public class MainActivity extends AppCompatActivity implements Crediter.OnFragme | @@ -133,20 +136,19 @@ public class MainActivity extends AppCompatActivity implements Crediter.OnFragme | ||
133 | 136 | ||
134 | @Override | 137 | @Override |
135 | public Fragment getItem(int position) { | 138 | public Fragment getItem(int position) { |
136 | - // getItem is called to instantiate the fragment for the given page. | ||
137 | - // Return a PlaceholderFragment (defined as a static inner class below). | ||
138 | if (position == Action.CREDITER.getValue()) | 139 | if (position == Action.CREDITER.getValue()) |
139 | return Crediter.newInstance(); | 140 | return Crediter.newInstance(); |
140 | else if (position == Action.DEBITER.getValue()) | 141 | else if (position == Action.DEBITER.getValue()) |
141 | return Debiter.newInstance(); | 142 | return Debiter.newInstance(); |
143 | + else if (position == Action.CONSOMATION.getValue()) | ||
144 | + return FragmentConsomation.newInstance(); | ||
142 | else | 145 | else |
143 | return null; | 146 | return null; |
144 | } | 147 | } |
145 | 148 | ||
146 | @Override | 149 | @Override |
147 | public int getCount() { | 150 | public int getCount() { |
148 | - // Show 3 total pages. | ||
149 | - return 2; | 151 | + return 3; |
150 | } | 152 | } |
151 | 153 | ||
152 | @Override | 154 | @Override |
@@ -155,12 +157,14 @@ public class MainActivity extends AppCompatActivity implements Crediter.OnFragme | @@ -155,12 +157,14 @@ public class MainActivity extends AppCompatActivity implements Crediter.OnFragme | ||
155 | return "Debiter"; | 157 | return "Debiter"; |
156 | else if (position == Action.CREDITER.getValue()) | 158 | else if (position == Action.CREDITER.getValue()) |
157 | return "Crediter"; | 159 | return "Crediter"; |
160 | + else if (position == Action.CONSOMATION.getValue()) | ||
161 | + return "Consomation"; | ||
158 | return null; | 162 | return null; |
159 | } | 163 | } |
160 | } | 164 | } |
161 | 165 | ||
162 | private enum Action { | 166 | private enum Action { |
163 | - DEBITER(0), CREDITER(1); | 167 | + DEBITER(0), CREDITER(1), CONSOMATION(2); |
164 | 168 | ||
165 | private final int value; | 169 | private final int value; |
166 | Action(int value) { | 170 | Action(int value) { |
app/src/main/java/net/plil/clubinfo/etunicorn/data/Consomation.java
0 → 100644
@@ -0,0 +1,38 @@ | @@ -0,0 +1,38 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.data; | ||
2 | + | ||
3 | +/** | ||
4 | + * Created by badetitou on 29/01/2017. | ||
5 | + */ | ||
6 | + | ||
7 | +public class Consomation { | ||
8 | + private int idConsomation; | ||
9 | + private String nomConsomation; | ||
10 | + private double prix; | ||
11 | + | ||
12 | + public Consomation() { | ||
13 | + } | ||
14 | + | ||
15 | + public int getIdConsomation() { | ||
16 | + return idConsomation; | ||
17 | + } | ||
18 | + | ||
19 | + public void setIdConsomation(int idConsomation) { | ||
20 | + this.idConsomation = idConsomation; | ||
21 | + } | ||
22 | + | ||
23 | + public String getNomConsomation() { | ||
24 | + return nomConsomation; | ||
25 | + } | ||
26 | + | ||
27 | + public void setNomConsomation(String nomConsomation) { | ||
28 | + this.nomConsomation = nomConsomation; | ||
29 | + } | ||
30 | + | ||
31 | + public double getPrix() { | ||
32 | + return prix; | ||
33 | + } | ||
34 | + | ||
35 | + public void setPrix(double prix) { | ||
36 | + this.prix = prix; | ||
37 | + } | ||
38 | +} |
app/src/main/java/net/plil/clubinfo/etunicorn/utils/ScrollAwareFABBehavior.java
0 → 100644
@@ -0,0 +1,41 @@ | @@ -0,0 +1,41 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.utils; | ||
2 | + | ||
3 | +import android.content.Context; | ||
4 | +import android.support.design.widget.CoordinatorLayout; | ||
5 | +import android.support.design.widget.FloatingActionButton; | ||
6 | +import android.support.v4.view.ViewCompat; | ||
7 | +import android.util.AttributeSet; | ||
8 | +import android.view.View; | ||
9 | + | ||
10 | +/** | ||
11 | + * Created by badetitou on 29/01/2017. | ||
12 | + */ | ||
13 | + | ||
14 | +public class ScrollAwareFABBehavior extends FloatingActionButton.Behavior { | ||
15 | + | ||
16 | + public ScrollAwareFABBehavior(Context context, AttributeSet attrs) { | ||
17 | + super(); | ||
18 | + } | ||
19 | + | ||
20 | + | ||
21 | + @Override | ||
22 | + public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, | ||
23 | + FloatingActionButton child, View directTargetChild, View target, int nestedScrollAxes) { | ||
24 | + return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL || | ||
25 | + super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, | ||
26 | + nestedScrollAxes); | ||
27 | + } | ||
28 | + | ||
29 | + @Override | ||
30 | + public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, | ||
31 | + View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { | ||
32 | + super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, | ||
33 | + dyUnconsumed); | ||
34 | + | ||
35 | + if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) { | ||
36 | + child.hide(); | ||
37 | + } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) { | ||
38 | + child.show(); | ||
39 | + } | ||
40 | + } | ||
41 | +} |
app/src/main/res/layout/fragment_consomation_item.xml
0 → 100644
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
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 | + android:orientation="horizontal"> | ||
6 | + | ||
7 | + <TextView | ||
8 | + android:id="@+id/consomation_id" | ||
9 | + android:layout_width="wrap_content" | ||
10 | + android:layout_height="wrap_content" | ||
11 | + android:layout_margin="@dimen/text_margin" | ||
12 | + android:textAppearance="?attr/textAppearanceListItem" /> | ||
13 | + | ||
14 | + <TextView | ||
15 | + android:id="@+id/consomation_name" | ||
16 | + android:layout_width="wrap_content" | ||
17 | + android:layout_height="wrap_content" | ||
18 | + android:layout_margin="@dimen/text_margin" | ||
19 | + android:textAppearance="?attr/textAppearanceListItem" | ||
20 | + android:layout_toRightOf="@id/consomation_id"/> | ||
21 | + | ||
22 | + <TextView | ||
23 | + android:id="@+id/consomation_price" | ||
24 | + android:layout_width="wrap_content" | ||
25 | + android:layout_height="wrap_content" | ||
26 | + android:layout_margin="@dimen/text_margin" | ||
27 | + android:textAppearance="?attr/textAppearanceListItem" | ||
28 | + android:layout_alignParentRight="true"/> | ||
29 | + | ||
30 | +</RelativeLayout> |
app/src/main/res/layout/fragment_consomation_item_list.xml
0 → 100644
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<android.support.design.widget.CoordinatorLayout | ||
3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
5 | + xmlns:tools="http://schemas.android.com/tools" | ||
6 | + android:layout_width="match_parent" | ||
7 | + android:layout_height="match_parent"> | ||
8 | + | ||
9 | + <android.support.v7.widget.RecyclerView | ||
10 | + android:id="@+id/consomation_list" | ||
11 | + android:name="net.plil.clubinfo.etunicorn.app.Consomation" | ||
12 | + android:layout_width="match_parent" | ||
13 | + android:layout_height="match_parent" | ||
14 | + android:layout_marginLeft="16dp" | ||
15 | + android:layout_marginRight="16dp" | ||
16 | + app:layoutManager="LinearLayoutManager" | ||
17 | + tools:context="net.plil.clubinfo.etunicorn.app.FragmentConsomation" | ||
18 | + tools:listitem="@layout/fragment_consomation_item" /> | ||
19 | + | ||
20 | + <android.support.design.widget.FloatingActionButton | ||
21 | + android:layout_width="wrap_content" | ||
22 | + android:layout_height="wrap_content" | ||
23 | + android:clickable="true" | ||
24 | + android:layout_gravity="bottom|end" | ||
25 | + android:layout_margin="24dp" | ||
26 | + android:id="@+id/consomation_add" | ||
27 | + app:fabSize="auto" | ||
28 | + app:srcCompat="@android:drawable/ic_menu_add" | ||
29 | + app:backgroundTint="@color/colorPrimaryDark" | ||
30 | + app:elevation="6dp" | ||
31 | + app:rippleColor="@color/colorAccent" | ||
32 | + app:layout_anchor="@id/consomation_list" | ||
33 | + app:layout_anchorGravity="bottom|right|end" | ||
34 | + app:layout_behavior="net.plil.clubinfo.etunicorn.utils.ScrollAwareFABBehavior"/> | ||
35 | + | ||
36 | +</android.support.design.widget.CoordinatorLayout> | ||
0 | \ No newline at end of file | 37 | \ No newline at end of file |
app/src/main/res/layout/fragment_crediter.xml
1 | -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | xmlns:tools="http://schemas.android.com/tools" | 2 | xmlns:tools="http://schemas.android.com/tools" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
5 | tools:context="net.plil.clubinfo.etunicorn.app.Crediter"> | 5 | tools:context="net.plil.clubinfo.etunicorn.app.Crediter"> |
6 | 6 | ||
7 | - <!-- TODO: Update blank fragment layout --> | ||
8 | - <TextView | ||
9 | - android:layout_width="match_parent" | ||
10 | - android:layout_height="match_parent" | ||
11 | - android:text="@string/hello_blank_fragment" /> | 7 | + <EditText |
8 | + android:inputType="numberSigned" | ||
9 | + android:layout_width="wrap_content" | ||
10 | + android:layout_height="wrap_content" | ||
11 | + android:hint="@string/enter_money" | ||
12 | + android:id="@+id/crediter_ask_money" | ||
13 | + android:ems="10" | ||
14 | + android:layout_centerVertical="true" | ||
15 | + android:layout_centerHorizontal="true" | ||
16 | + android:gravity="center"/> | ||
12 | 17 | ||
13 | -</FrameLayout> | 18 | + <ProgressBar |
19 | + style="?android:attr/progressBarStyle" | ||
20 | + android:layout_width="wrap_content" | ||
21 | + android:layout_height="wrap_content" | ||
22 | + android:layout_alignParentTop="true" | ||
23 | + android:layout_alignParentStart="true" | ||
24 | + android:id="@+id/crediter_progress_bar" | ||
25 | + android:layout_alignParentBottom="true" | ||
26 | + android:layout_alignParentEnd="true" | ||
27 | + android:visibility="gone"/> | ||
28 | + | ||
29 | +</RelativeLayout> |
app/src/main/res/values/dimens.xml
@@ -4,4 +4,5 @@ | @@ -4,4 +4,5 @@ | ||
4 | <dimen name="activity_vertical_margin">16dp</dimen> | 4 | <dimen name="activity_vertical_margin">16dp</dimen> |
5 | <dimen name="fab_margin">16dp</dimen> | 5 | <dimen name="fab_margin">16dp</dimen> |
6 | <dimen name="appbar_padding_top">8dp</dimen> | 6 | <dimen name="appbar_padding_top">8dp</dimen> |
7 | + <dimen name="text_margin">16dp</dimen> | ||
7 | </resources> | 8 | </resources> |