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