]>
Commit | Line | Data |
---|---|---|
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 | ||
8 | import java.text.ParseException; | |
9 | import java.text.SimpleDateFormat; | |
10 | import java.util.Date; | |
11 | ||
12 | public class AddEventTabListener implements ActionBar.TabListener { | |
13 | public Fragment fragment; | |
14 | private Event ev; | |
15 | int tabId; | |
16 | ||
17 | public AddEventTabListener(final Fragment fragment,Event e,int tabId) { | |
18 | this.fragment = fragment; | |
19 | this.ev = e; | |
20 | this.tabId=tabId; | |
21 | } | |
22 | ||
23 | @Override | |
24 | public void onTabSelected(final Tab tab, final FragmentTransaction ft) { | |
25 | ft.replace(R.id.fragment_container, fragment); | |
26 | } | |
27 | ||
28 | @Override | |
29 | public void onTabUnselected(final Tab tab, final FragmentTransaction ft) { | |
30 | switch (tabId) { | |
31 | case 0: | |
32 | ev.title=fragment.getView().findViewById(R.id.eventtitle).toString(); | |
33 | String start=fragment.getView().findViewById(R.id.date_start).toString()+ " " + | |
34 | fragment.getView().findViewById(R.id.time_start).toString(); | |
35 | String end=fragment.getView().findViewById(R.id.date_end).toString()+ " " + | |
36 | fragment.getView().findViewById(R.id.time_end).toString(); | |
37 | try { | |
38 | Date s=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(start); | |
39 | Date e=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(end); | |
40 | ev.dtstart=s.getTime(); | |
41 | ev.dtend=s.getTime(); | |
42 | } catch (ParseException e) { | |
43 | e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. | |
44 | } | |
45 | ||
46 | break; | |
47 | case 1: | |
48 | ev.description=fragment.getView().findViewById(R.id.description).toString(); | |
49 | break; | |
50 | case 2: | |
51 | break; | |
52 | } | |
53 | ft.remove(fragment); | |
54 | } | |
55 | ||
56 | @Override | |
57 | public void onTabReselected(final Tab tab, final FragmentTransaction ft) { | |
58 | // TODO Auto-generated method stub | |
59 | ||
60 | } | |
61 | } |