public final class AddEventActivity extends Activity implements OnDateSetListener, OnTimeSetListener{
private TextView dateTimeTextView;
- private static Event tempEvent=new Event();
public static final String EXTRA_EVENT = "event";
- private static Fragment f1,f2,f3;
public static void editEvent(final Context c, final Event e) {
- Intent i = new Intent(c,AddEventActivity.class);
+ final Intent i = new Intent(c,AddEventActivity.class);
i.putExtra(AddEventActivity.EXTRA_EVENT,e);
- tempEvent=e;
c.startActivity(i);
}
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.add_event_title);
+ final Event event = getIntent().hasExtra(EXTRA_EVENT) ? (Event) getIntent().getParcelableExtra(EXTRA_EVENT) : new Event();
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
final ActionBar.Tab t1 = actionBar.newTab().setText(this.getString(R.string.addevtab1));
final ActionBar.Tab t2 = actionBar.newTab().setText(this.getString(R.string.addevtab2));
final ActionBar.Tab t3 = actionBar.newTab().setText(this.getString(R.string.addevtab3));
- f1 = new TrivialFragment();
+ final Fragment f1 = new TrivialFragment();
final Bundle b1=new Bundle();
b1.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_basic_tab);
- b1.putParcelable(TrivialFragment.ARGUMENT_EVENT,tempEvent);
+ b1.putParcelable(TrivialFragment.ARGUMENT_EVENT, event);
f1.setArguments(b1);
- f2 = new TrivialFragment();
+ final Fragment f2 = new TrivialFragment();
final Bundle b2=new Bundle();
b2.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_details_tab);
- b2.putParcelable(TrivialFragment.ARGUMENT_EVENT,tempEvent);
+ b2.putParcelable(TrivialFragment.ARGUMENT_EVENT, event);
f2.setArguments(b2);
- f3 = new TrivialFragment();
+ final Fragment f3 = new TrivialFragment();
final Bundle b3=new Bundle();
b3.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_other_tab);
- b3.putParcelable(TrivialFragment.ARGUMENT_EVENT,tempEvent);
+ b3.putParcelable(TrivialFragment.ARGUMENT_EVENT, event);
f3.setArguments(b3);
- t1.setTabListener(new AddEventTabListener(f1,tempEvent,0));
- t2.setTabListener(new AddEventTabListener(f2,tempEvent,1));
- t3.setTabListener(new AddEventTabListener(f3,tempEvent,2));
+ t1.setTabListener(new AddEventTabListener(f1, event, 0));
+ t2.setTabListener(new AddEventTabListener(f2, event, 1));
+ t3.setTabListener(new AddEventTabListener(f3, event, 2));
actionBar.addTab(t1);
actionBar.addTab(t2);