]> iEval git - unical.git/blame - src/ro/ieval/unical/TrivialFragment.java
Edit event. work in progress[3]
[unical.git] / src / ro / ieval / unical / TrivialFragment.java
CommitLineData
724f9857
MG
1package ro.ieval.unical;
2
5835912b 3import android.app.ActionBar;
724f9857 4import android.app.Fragment;
5835912b 5import android.app.FragmentTransaction;
724f9857
MG
6import android.os.Bundle;
7import android.view.LayoutInflater;
8import android.view.View;
9import android.view.ViewGroup;
f2fe1090
P
10import android.widget.*;
11
12import java.text.SimpleDateFormat;
13import java.util.Date;
724f9857
MG
14
15public final class TrivialFragment extends Fragment {
f2fe1090
P
16 Event ev;
17 public TrivialFragment(Event e) {
18 ev=e;
19 }
20
21 @Override
22 public void onActivityCreated (Bundle savedInstanceState) {
23 super.onCreate(savedInstanceState);
24 switch (getArguments().getInt(ARGUMENT_LAYOUT)) {
25 case R.layout.add_event_basic_tab:
26 EditText title = (EditText) getView().findViewById(R.id.eventtitle);
27 title.setText(ev.title, TextView.BufferType.EDITABLE);
28
29 TextView tstart = (TextView) getView().findViewById(R.id.time_start);
30 TextView tend = (TextView) getView().findViewById(R.id.time_end);
31 SimpleDateFormat sf=new SimpleDateFormat("HH:MM");
32 Date d=new Date(ev.dtstart);
33 tstart.setText(sf.format(d).toString(),TextView.BufferType.NORMAL);
34 d.setTime(ev.dtend);
35 tend.setText(sf.format(d).toString(),TextView.BufferType.NORMAL);
36
37 SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
38 TextView dstart = (TextView)getView().findViewById(R.id.date_start);
39 TextView dend = (TextView)getView().findViewById(R.id.date_end);
40 d.setTime(ev.dtstart);
41 dstart.setText(sd.format(d).toString(),TextView.BufferType.NORMAL);
42 d.setTime(ev.dtend);
43 dend.setText(sd.format(d).toString(),TextView.BufferType.NORMAL);
44 break;
45 case R.layout.add_event_details_tab:
46 EditText description = (EditText) getView().findViewById(R.id.description);
47 description.setText(ev.description,TextView.BufferType.EDITABLE);
48 break;
49 case R.layout.add_event_other_tab:
50 break;
51 }
52
53 }
54
dfc674f6 55 private static class OnItemSelectedListener implements android.widget.AdapterView.OnItemSelectedListener{
f580909c 56 private final View repeatCount;
0dde5456
MG
57 private final View repeatUntil;
58
59 public OnItemSelectedListener(final View repeatCount, final View repeatUntil) {
dfc674f6 60 this.repeatCount=repeatCount;
0dde5456 61 this.repeatUntil=repeatUntil;
dfc674f6
MG
62 }
63
64 @Override
65 public void onItemSelected(final AdapterView<?> whatever, final View ignored, final int pos, final long id) {
66 switch(pos){
67 case 0:
68 repeatCount.setVisibility(View.GONE);
0dde5456 69 repeatUntil.setVisibility(View.GONE);
dfc674f6
MG
70 break;
71 case 1:
72 repeatCount.setVisibility(View.GONE);
0dde5456 73 repeatUntil.setVisibility(View.VISIBLE);
dfc674f6
MG
74 break;
75 case 2:
76 repeatCount.setVisibility(View.VISIBLE);
0dde5456 77 repeatUntil.setVisibility(View.GONE);
dfc674f6
MG
78 break;
79 default:
80 }
5835912b 81 }
dfc674f6
MG
82
83 @Override public void onNothingSelected(final AdapterView<?> arg0) { /* do nothing */ }
84 }
85
86 private static class OnCheckedChangeListener implements android.widget.CompoundButton.OnCheckedChangeListener{
87 private final LinearLayout layout;
88 private final View root;
89 public OnCheckedChangeListener(final LinearLayout layout, final View root){
90 this.layout=layout;
91 this.root=root;
92 }
93
94 @Override
95 public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
96 if(isChecked) {
97 Utils.setEnabledRecursively(layout, true);
98 final Spinner repeatType = (Spinner) root.findViewById(R.id.repeat_type);
0dde5456 99 repeatType.setOnItemSelectedListener(new OnItemSelectedListener(root.findViewById(R.id.repeat_count),root.findViewById(R.id.repeat_until)));
dfc674f6
MG
100 }else {
101 Utils.setEnabledRecursively(layout, false);
102 }
103 }
104 }
105
88ba7fcf 106 public static final String ARGUMENT_LAYOUT="layout";
724f9857
MG
107
108 @Override
109 public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
361c6a28 110
306c1a65 111 final View view=inflater.inflate(getArguments().getInt(ARGUMENT_LAYOUT), container, false);
dfc674f6 112 final LinearLayout layout = (LinearLayout) view.findViewById(R.id.repeat_layout);
361c6a28 113
dfc674f6 114 if(layout != null){
361c6a28 115 final Switch repeatSwitch = (Switch) view.findViewById(R.id.repeat_switch);
dfc674f6 116 Utils.setEnabledRecursively(layout, false);
361c6a28 117
dfc674f6 118 repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener(layout, view));
306c1a65
MG
119 }
120 return view;
121 }
724f9857 122}
This page took 0.042585 seconds and 4 git commands to generate.