1 package ro
.ieval
.unical
;
3 import java
.text
.SimpleDateFormat
;
5 import java
.util
.Locale
;
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";
20 public static void displayEvent(final Context context
, final Event event
){
21 final Intent i
=new Intent(context
,DisplayEventActivity
.class);
22 i
.putExtra(DisplayEventActivity
.EXTRA_EVENT
, event
);
23 context
.startActivity(i
);
27 protected void onCreate(final Bundle savedInstanceState
) {
28 super.onCreate(savedInstanceState
);
29 event
=getIntent().getParcelableExtra(EXTRA_EVENT
);
30 setContentView(R
.layout
.event_view
);
31 setTitle(event
.title
);
33 final TextView startDay
= (TextView
) findViewById(R
.id
.startday
);
34 final TextView endDay
= (TextView
) findViewById(R
.id
.endday
);
35 final TextView startDate
= (TextView
) findViewById(R
.id
.startdate
);
36 final TextView endDate
= (TextView
) findViewById(R
.id
.enddate
);
37 final TextView startTime
= (TextView
) findViewById(R
.id
.starttime
);
38 final TextView endTime
= (TextView
) findViewById(R
.id
.endtime
);
39 final TextView description
= (TextView
) findViewById(R
.id
.event_view_description
);
41 final Date start
=new Date(event
.dtstart
);
42 final Date end
=new Date(event
.dtend
);
43 final SimpleDateFormat dateFormat
= new SimpleDateFormat("MM/dd/yyyy", Locale
.UK
);
44 final SimpleDateFormat timeFormat
= new SimpleDateFormat("HH:mm:ss", Locale
.UK
);
45 final SimpleDateFormat dayOfWeekFormat
= new SimpleDateFormat("EEEEEEE", Locale
.UK
);
47 startDay
.setText(dayOfWeekFormat
.format(start
));
48 if(!dateFormat
.format(start
).equals(dateFormat
.format(end
))) {
49 endDay
.setText(dayOfWeekFormat
.format(end
));
50 endDate
.setText(dateFormat
.format(end
));
52 startDate
.setText(dateFormat
.format(start
));
53 startTime
.setText(timeFormat
.format(start
));
54 endTime
.setText(timeFormat
.format(end
));
55 description
.setText(event
.description
);
59 public boolean onCreateOptionsMenu(final Menu menu
) {
60 final MenuInflater inflater
= getMenuInflater();
61 inflater
.inflate(R
.menu
.event
, menu
);
66 public boolean onOptionsItemSelected(final MenuItem item
) {
67 // Handle item selection
68 switch (item
. getItemId()) {
69 case R
.id
.deleteevent
:
70 final DeleteEventDialog d
=new DeleteEventDialog(event
,this);
71 d
.show(getFragmentManager(), "Delete");
74 final Intent it
=new Intent(this,EventListActivity
.class);
78 AddEventActivity
.editEvent(DisplayEventActivity
.this,event
);