]>
Commit | Line | Data |
---|---|---|
6d7e08bf PT |
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 | ||
6521d8d8 P |
8 | import java.text.ParseException; |
9 | import java.text.SimpleDateFormat; | |
10 | import java.util.Date; | |
11 | ||
6d7e08bf PT |
12 | public class AddEventTabListener implements ActionBar.TabListener { |
13 | public Fragment fragment; | |
c32befcc P |
14 | private Event ev; |
15 | int tabId; | |
6d7e08bf | 16 | |
c32befcc | 17 | public AddEventTabListener(final Fragment fragment,Event e,int tabId) { |
6d7e08bf | 18 | this.fragment = fragment; |
c32befcc P |
19 | this.ev = e; |
20 | this.tabId=tabId; | |
6d7e08bf PT |
21 | } |
22 | ||
23 | @Override | |
724f9857 | 24 | public void onTabSelected(final Tab tab, final FragmentTransaction ft) { |
6d7e08bf PT |
25 | ft.replace(R.id.fragment_container, fragment); |
26 | } | |
27 | ||
28 | @Override | |
724f9857 | 29 | public void onTabUnselected(final Tab tab, final FragmentTransaction ft) { |
c32befcc P |
30 | switch (tabId) { |
31 | case 0: | |
32 | ev.title=fragment.getView().findViewById(R.id.eventtitle).toString(); | |
6521d8d8 P |
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 | ||
c32befcc P |
46 | break; |
47 | case 1: | |
48 | ev.description=fragment.getView().findViewById(R.id.description).toString(); | |
49 | break; | |
50 | case 2: | |
51 | break; | |
52 | } | |
6d7e08bf PT |
53 | ft.remove(fragment); |
54 | } | |
55 | ||
56 | @Override | |
724f9857 | 57 | public void onTabReselected(final Tab tab, final FragmentTransaction ft) { |
6d7e08bf | 58 | // TODO Auto-generated method stub |
070d3ab2 | 59 | |
6d7e08bf PT |
60 | } |
61 | } |