]>
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; | |
b5283c72 | 7 | import android.util.Log; |
2a92dcf2 P |
8 | import android.widget.EditText; |
9 | import android.widget.TextView; | |
6d7e08bf | 10 | |
6521d8d8 P |
11 | import java.text.ParseException; |
12 | import java.text.SimpleDateFormat; | |
13 | import java.util.Date; | |
14 | ||
6d7e08bf | 15 | public class AddEventTabListener implements ActionBar.TabListener { |
c6a13256 | 16 | private Fragment fragment; |
c32befcc | 17 | private Event ev; |
c6a13256 MG |
18 | private boolean isAdded = false; |
19 | private int tabId; | |
6d7e08bf | 20 | |
c32befcc | 21 | public AddEventTabListener(final Fragment fragment,Event e,int tabId) { |
6d7e08bf | 22 | this.fragment = fragment; |
c32befcc P |
23 | this.ev = e; |
24 | this.tabId=tabId; | |
6d7e08bf PT |
25 | } |
26 | ||
27 | @Override | |
724f9857 | 28 | public void onTabSelected(final Tab tab, final FragmentTransaction ft) { |
b5283c72 | 29 | ft.replace(android.R.id.content, fragment, null); |
6d7e08bf PT |
30 | } |
31 | ||
32 | @Override | |
724f9857 | 33 | public void onTabUnselected(final Tab tab, final FragmentTransaction ft) { |
c32befcc P |
34 | switch (tabId) { |
35 | case 0: | |
b5283c72 MG |
36 | ev.title=((TextView)fragment.getView().findViewById(R.id.eventtitle)).getText().toString(); |
37 | String start=((TextView)fragment.getView().findViewById(R.id.date_start)).getText()+ " " + | |
38 | ((TextView)fragment.getView().findViewById(R.id.time_start)).getText(); | |
39 | String end=((TextView)fragment.getView().findViewById(R.id.date_end)).getText()+ " " + | |
40 | ((TextView)fragment.getView().findViewById(R.id.time_end)).getText(); | |
6521d8d8 P |
41 | try { |
42 | Date s=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(start); | |
43 | Date e=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(end); | |
44 | ev.dtstart=s.getTime(); | |
45 | ev.dtend=s.getTime(); | |
46 | } catch (ParseException e) { | |
c6a13256 | 47 | e.printStackTrace(); |
6521d8d8 P |
48 | } |
49 | ||
c32befcc P |
50 | break; |
51 | case 1: | |
52 | ev.description=fragment.getView().findViewById(R.id.description).toString(); | |
53 | break; | |
54 | case 2: | |
55 | break; | |
56 | } | |
6d7e08bf PT |
57 | } |
58 | ||
59 | @Override | |
724f9857 | 60 | public void onTabReselected(final Tab tab, final FragmentTransaction ft) { |
c6a13256 | 61 | // do nothing |
6d7e08bf PT |
62 | } |
63 | } |