Edit event. work in progress[2]
[unical.git] / src / ro / ieval / unical / AddEventTabListener.java
CommitLineData
6d7e08bf
PT
1package ro.ieval.unical;
2
3import android.app.ActionBar;
4import android.app.ActionBar.Tab;
5import android.app.Fragment;
6import android.app.FragmentTransaction;
2a92dcf2
P
7import android.widget.EditText;
8import android.widget.TextView;
6d7e08bf 9
6521d8d8
P
10import java.text.ParseException;
11import java.text.SimpleDateFormat;
12import java.util.Date;
13
6d7e08bf
PT
14public 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}
This page took 0.013353 seconds and 4 git commands to generate.