1 package ro
.ieval
.unical
;
3 import java
.text
.SimpleDateFormat
;
5 import java
.util
.GregorianCalendar
;
7 import android
.app
.Activity
;
8 import android
.content
.Context
;
9 import android
.content
.Intent
;
10 import android
.os
.Bundle
;
11 import android
.view
.Menu
;
12 import android
.view
.MenuInflater
;
13 import android
.view
.MenuItem
;
14 import android
.widget
.TextView
;
16 public class DisplayEventActivity
extends Activity
{
17 public static final String EXTRA_EVENT
= "event";
19 public static void displayEvent(final Context context
, final Event event
){
20 final Intent i
=new Intent(context
,DisplayEventActivity
.class);
21 i
.putExtra(DisplayEventActivity
.EXTRA_EVENT
, event
);
22 context
.startActivity(i
);
26 protected void onCreate(final Bundle savedInstanceState
) {
27 super.onCreate(savedInstanceState
);
28 final Event e
=getIntent().getParcelableExtra(EXTRA_EVENT
);
29 setContentView(R
.layout
.event_view
);
32 final TextView startday
= (TextView
) findViewById(R
.id
.startday
);
33 final TextView endday
= (TextView
) findViewById(R
.id
.endday
);
34 final TextView startdate
= (TextView
) findViewById(R
.id
.startdate
);
35 final TextView enddate
= (TextView
) findViewById(R
.id
.enddate
);
36 final TextView starttime
= (TextView
) findViewById(R
.id
.starttime
);
37 final TextView endtime
= (TextView
) findViewById(R
.id
.endtime
);
39 GregorianCalendar cstart
= new GregorianCalendar();
40 cstart
.setTime(new Date(e
.dtstart
));
41 GregorianCalendar cend
= new GregorianCalendar();
42 cend
.setTime(new Date(e
.dtend
));
43 SimpleDateFormat sdf
= new SimpleDateFormat("MM/dd/yyyy");
44 SimpleDateFormat stf
= new SimpleDateFormat("kk:mm:ss");
46 startday
.setText(CalendarUtils
.DayToString(this,cstart
));
47 if(CalendarUtils
.DayToString(this,cstart
)!=CalendarUtils
.DayToString(this, cend
))
48 endday
.setText(CalendarUtils
.DayToString(this, cend
));
49 startdate
.setText(sdf
.format(cstart
.getTime()));
50 if(sdf
.format(cstart
.getTime())!=sdf
.format(cend
.getTime()))
51 enddate
.setText(sdf
.format(cend
.getTime()));
52 starttime
.setText(stf
.format(cstart
.getTime()));
53 endtime
.setText(stf
.format(cend
.getTime()));
57 public boolean onCreateOptionsMenu(final Menu menu
) {
58 final MenuInflater inflater
= getMenuInflater();
59 inflater
.inflate(R
.menu
.event
, menu
);
64 public boolean onOptionsItemSelected(final MenuItem item
) {
65 // Handle item selection
66 switch (item
. getItemId()) {
68 final Intent i
=new Intent(this,AddEventActivity
.class);
71 case R
.id
.deleteevent
:
72 final DeleteEventDialog d
=new DeleteEventDialog();
73 d
.show(getFragmentManager(), "Delete");
76 final Intent it
=new Intent(this,EventListActivity
.class);