PersonOverviewFragment.java
3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package net.plil.clubinfo.etunicorn.app.personne;
import android.app.Dialog;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import net.plil.clubinfo.etunicorn.R;
import net.plil.clubinfo.etunicorn.data.Personne;
import java.util.Locale;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link PersonOverviewFragment.OnFragmentInteractionListener} interface
* to handle interaction events.
*/
public class PersonOverviewFragment extends DialogFragment{
private OnFragmentInteractionListener mListener;
TextView mCarte;
TextView mNaissance;
TextView mSolde;
TextView mLogin;
TextView mRole;
public PersonOverviewFragment() {
// Required empty public constructor
}
public static PersonOverviewFragment newInstance(Personne item) {
PersonOverviewFragment f = new PersonOverviewFragment();
Bundle args = new Bundle();
args.putSerializable("personne", item);
f.setArguments(args);
return f;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState){
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.fragment_person_overview, null);
final Personne personne = (Personne) getArguments().getSerializable("personne");
mCarte = (TextView) view.findViewById(R.id.personne_overview_carte);
mLogin = (TextView) view.findViewById(R.id.personne_overview_login);
mNaissance = (TextView) view.findViewById(R.id.personne_overview_naissance);
mSolde = (TextView) view.findViewById(R.id.personne_overview_solde);
mRole = (TextView) view.findViewById(R.id.personne_overview_role);
assert personne != null;
mCarte.setText(personne.getCarte());
mRole.setText(personne.getRole().getNom());
mSolde.setText(String.format(Locale.FRANCE, "%.2f",personne.getSolde()));
mNaissance.setText(personne.getNaissance().toString());
mLogin.setText(personne.getLogin());
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder
.setTitle(R.string.personne)
.setView(view);
return builder.create();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_person_overview, container, false);
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}