Clean up
[unical.git] / src / ro / ieval / unical / AddEventTabListener.java
CommitLineData
6d7e08bf
PT
1package ro.ieval.unical;
2
3import android.app.ActionBar;
4import android.app.ActionBar.Tab;
5import android.app.Fragment;
6import android.app.FragmentTransaction;
2a92dcf2
P
7import android.widget.EditText;
8import android.widget.TextView;
6d7e08bf 9
6521d8d8
P
10import java.text.ParseException;
11import java.text.SimpleDateFormat;
12import java.util.Date;
13
6d7e08bf 14public class AddEventTabListener implements ActionBar.TabListener {
c6a13256 15 private Fragment fragment;
c32befcc 16 private Event ev;
c6a13256
MG
17 private boolean isAdded = false;
18 private int tabId;
6d7e08bf 19
c32befcc 20 public AddEventTabListener(final Fragment fragment,Event e,int tabId) {
6d7e08bf 21 this.fragment = fragment;
c32befcc
P
22 this.ev = e;
23 this.tabId=tabId;
6d7e08bf
PT
24 }
25
26 @Override
724f9857 27 public void onTabSelected(final Tab tab, final FragmentTransaction ft) {
c6a13256
MG
28 if(isAdded)
29 ft.attach(fragment);
30 else {
31 isAdded = true;
32 ft.add(android.R.id.content, fragment);
33 }
34
2a92dcf2
P
35 switch (tabId) {
36 case 0:
2a92dcf2 37 //EditText title =(EditText) fragment.getView().findViewById(R.id.eventtitle);
c6a13256 38 //title.setText(ev.title, TextView.BufferType.EDITABLE);
2a92dcf2
P
39 break;
40 }
6d7e08bf
PT
41 }
42
43 @Override
724f9857 44 public void onTabUnselected(final Tab tab, final FragmentTransaction ft) {
c32befcc
P
45 switch (tabId) {
46 case 0:
47 ev.title=fragment.getView().findViewById(R.id.eventtitle).toString();
6521d8d8
P
48 String start=fragment.getView().findViewById(R.id.date_start).toString()+ " " +
49 fragment.getView().findViewById(R.id.time_start).toString();
50 String end=fragment.getView().findViewById(R.id.date_end).toString()+ " " +
51 fragment.getView().findViewById(R.id.time_end).toString();
52 try {
53 Date s=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(start);
54 Date e=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(end);
55 ev.dtstart=s.getTime();
56 ev.dtend=s.getTime();
57 } catch (ParseException e) {
c6a13256 58 e.printStackTrace();
6521d8d8
P
59 }
60
c32befcc
P
61 break;
62 case 1:
63 ev.description=fragment.getView().findViewById(R.id.description).toString();
64 break;
65 case 2:
66 break;
67 }
c6a13256 68 ft.detach(fragment);
6d7e08bf
PT
69 }
70
71 @Override
724f9857 72 public void onTabReselected(final Tab tab, final FragmentTransaction ft) {
c6a13256 73 // do nothing
6d7e08bf
PT
74 }
75}
This page took 0.016302 seconds and 4 git commands to generate.