Edit event. Time now shows propperly
[unical.git] / src / ro / ieval / unical / AddEventTabListener.java
... / ...
CommitLineData
1package ro.ieval.unical;
2
3import android.app.ActionBar;
4import android.app.ActionBar.Tab;
5import android.app.Fragment;
6import android.app.FragmentTransaction;
7import android.util.Log;
8import android.widget.EditText;
9import android.widget.TextView;
10
11import java.text.ParseException;
12import java.text.SimpleDateFormat;
13import java.util.Date;
14
15public class AddEventTabListener implements ActionBar.TabListener {
16 private Fragment fragment;
17 private Event ev;
18 private boolean isAdded = false;
19 private int tabId;
20
21 public AddEventTabListener(final Fragment fragment,Event e,int tabId) {
22 this.fragment = fragment;
23 this.ev = e;
24 this.tabId=tabId;
25 }
26
27 @Override
28 public void onTabSelected(final Tab tab, final FragmentTransaction ft) {
29 ft.replace(android.R.id.content, fragment, null);
30 }
31
32 @Override
33 public void onTabUnselected(final Tab tab, final FragmentTransaction ft) {
34 switch (tabId) {
35 case 0:
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();
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) {
47 e.printStackTrace();
48 }
49
50 break;
51 case 1:
52 ev.description=fragment.getView().findViewById(R.id.description).toString();
53 break;
54 case 2:
55 break;
56 }
57 }
58
59 @Override
60 public void onTabReselected(final Tab tab, final FragmentTransaction ft) {
61 // do nothing
62 }
63}
This page took 0.008429 seconds and 4 git commands to generate.