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