X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=src%2Fro%2Fieval%2Funical%2FAddEventTabListener.java;h=9238d4c03a4679156a36162e9288d42c0f34ee0f;hb=b5283c7228e84cdc57b80143c8e5d93d85fd3e5c;hp=1a4661ae794e0746eb0164c6a4cbdbae4ed3630a;hpb=6d7e08bf032626962f50c8d9db6c1c5b3d978271;p=unical.git diff --git a/src/ro/ieval/unical/AddEventTabListener.java b/src/ro/ieval/unical/AddEventTabListener.java index 1a4661a..9238d4c 100644 --- a/src/ro/ieval/unical/AddEventTabListener.java +++ b/src/ro/ieval/unical/AddEventTabListener.java @@ -4,27 +4,60 @@ import android.app.ActionBar; 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(Fragment fragment) { + public AddEventTabListener(final Fragment fragment,Event e,int tabId) { this.fragment = fragment; + this.ev = e; + this.tabId=tabId; } @Override - public void onTabSelected(Tab tab, FragmentTransaction ft) { - ft.replace(R.id.fragment_container, fragment); + public void onTabSelected(final Tab tab, final FragmentTransaction ft) { + ft.replace(android.R.id.content, fragment, null); } @Override - public void onTabUnselected(Tab tab, FragmentTransaction ft) { - ft.remove(fragment); + public void onTabUnselected(final Tab tab, final FragmentTransaction ft) { + 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(Tab tab, FragmentTransaction ft) { - // TODO Auto-generated method stub - + public void onTabReselected(final Tab tab, final FragmentTransaction ft) { + // do nothing } }