Added README.txt and GPL Header to Source Files
[DHBWCampusApp.git] / app / src / main / java / de / dhbwloe / campusapp / fragments / MensaCard.java
1 /* MensaCard.java
2  *
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 package de.dhbwloe.campusapp.fragments;
17 import android.content.Context;
18 import android.net.Uri;
19 import android.os.Bundle;
20 import android.support.v4.app.Fragment;
21 import android.view.LayoutInflater;
22 import android.view.View;
23 import android.view.ViewGroup;
24 import android.widget.TextView;
25
26 import java.text.DecimalFormat;
27
28 import de.dhbwloe.campusapp.CampusAppFragment;
29 import de.dhbwloe.campusapp.R;
30 import de.dhbwloe.campusapp.search.SearchIndices;
31
32 /**
33  * A simple {@link Fragment} subclass.
34  * Activities that contain this fragment must implement the
35  * {@link MensaCard.OnFragmentInteractionListener} interface
36  * to handle interaction events.
37  * Use the {@link MensaCard#newInstance} factory method to
38  * create an instance of this fragment.
39  */
40 public class MensaCard extends CampusAppFragment {
41     private View view;
42
43     @Override
44     public View onCreateView(LayoutInflater inflater, ViewGroup container,
45                              Bundle savedInstanceState) {
46         view = inflater.inflate(R.layout.fragment_mensa_card, container, false);
47         AppContext.setTitle(AppContext.getResString(R.string.mensacard_title));
48
49         Bundle args = getArguments();
50         if(args != null && args.containsKey("balance")) {
51             showNfcCardData(args);
52         }
53
54         return view;
55     }
56
57     public void showNfcCardData(Bundle bundle) {
58         TextView cardDataView = (TextView)view.findViewById(R.id.balanceTxt);
59         double balance = bundle.getDouble("balance");
60         DecimalFormat df = new DecimalFormat(AppContext.getResString(R.string.mensaformat_price));
61         cardDataView.setText(df.format(balance));
62     }
63
64 }