PersonOverviewFragment.java
2.49 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
package net.plil.clubinfo.etunicorn.app.personne;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
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;
public class PersonOverviewFragment extends DialogFragment {
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
@NonNull
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.US, "%.2f", personne.getSolde()));
if (personne.getNaissance() != null)
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);
}
}