import android.app.ActionBar.Tab;
import android.app.Fragment;
import android.app.FragmentTransaction;
+import android.util.Log;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
public class AddEventTabListener implements ActionBar.TabListener {
- public Fragment fragment;
+ private Fragment fragment;
+ private Event ev;
+ private boolean isAdded = false;
+ private int tabId;
- public AddEventTabListener(final Fragment fragment) {
+ public AddEventTabListener(final Fragment fragment,Event e,int tabId) {
this.fragment = fragment;
+ this.ev = e;
+ this.tabId=tabId;
}
@Override
public void onTabSelected(final Tab tab, final FragmentTransaction ft) {
- ft.replace(R.id.fragment_container, fragment);
+ ft.replace(android.R.id.content, fragment, null);
}
@Override
public void onTabUnselected(final Tab tab, final FragmentTransaction ft) {
- ft.remove(fragment);
+ switch (tabId) {
+ case 0:
+ ev.title=((TextView)fragment.getView().findViewById(R.id.eventtitle)).getText().toString();
+ String start=((TextView)fragment.getView().findViewById(R.id.date_start)).getText()+ " " +
+ ((TextView)fragment.getView().findViewById(R.id.time_start)).getText();
+ String end=((TextView)fragment.getView().findViewById(R.id.date_end)).getText()+ " " +
+ ((TextView)fragment.getView().findViewById(R.id.time_end)).getText();
+ try {
+ Date s=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(start);
+ Date e=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(end);
+ ev.dtstart=s.getTime();
+ ev.dtend=s.getTime();
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+
+ break;
+ case 1:
+ ev.description=fragment.getView().findViewById(R.id.description).toString();
+ break;
+ case 2:
+ break;
+ }
}
@Override
public void onTabReselected(final Tab tab, final FragmentTransaction ft) {
- // TODO Auto-generated method stub
-
+ // do nothing
}
}