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";
19 private final DeleteEventDialog d
=new DeleteEventDialog();
21 public static void displayEvent(final Context context
, final long id
){
22 final Intent i
=new Intent(context
,DisplayEventActivity
.class);
23 i
.putExtra(DisplayEventActivity
.EXTRA_EVENT
, id
);
24 context
.startActivity(i
);
28 protected void onStart() {
30 event
=getIntent().hasExtra(EXTRA_EVENT
) ? Event
.getEventById(this, getIntent().getLongExtra(EXTRA_EVENT
, 0)) : new Event();
31 setContentView(R
.layout
.event_view
);
32 setTitle(event
.title
);
34 final TextView startDay
= (TextView
) findViewById(R
.id
.startday
);
35 final TextView endDay
= (TextView
) findViewById(R
.id
.endday
);
36 final TextView startDate
= (TextView
) findViewById(R
.id
.startdate
);
37 final TextView endDate
= (TextView
) findViewById(R
.id
.enddate
);
38 final TextView startTime
= (TextView
) findViewById(R
.id
.starttime
);
39 final TextView endTime
= (TextView
) findViewById(R
.id
.endtime
);
40 final TextView description
= (TextView
) findViewById(R
.id
.event_view_description
);
42 final Date start
=new Date(event
.dtstart
);
43 final Date end
=new Date(event
.dtend
);
44 final SimpleDateFormat dateFormat
= new SimpleDateFormat("MM/dd/yyyy", Locale
.UK
);
45 final SimpleDateFormat timeFormat
= new SimpleDateFormat("HH:mm:ss", Locale
.UK
);
46 final SimpleDateFormat dayOfWeekFormat
= new SimpleDateFormat("EEEEEEE", Locale
.UK
);
48 startDay
.setText(dayOfWeekFormat
.format(start
));
49 if(!dateFormat
.format(start
).equals(dateFormat
.format(end
))) {
50 endDay
.setText(dayOfWeekFormat
.format(end
));
51 endDate
.setText(dateFormat
.format(end
));
53 startDate
.setText(dateFormat
.format(start
));
54 startTime
.setText(timeFormat
.format(start
));
55 endTime
.setText(timeFormat
.format(end
));
56 description
.setText(event
.description
);
60 public boolean onCreateOptionsMenu(final Menu menu
) {
61 final MenuInflater inflater
= getMenuInflater();
62 inflater
.inflate(R
.menu
.event
, menu
);
67 public boolean onOptionsItemSelected(final MenuItem item
) {
68 // Handle item selection
69 switch (item
. getItemId()) {
70 case R
.id
.deleteevent
:
71 final Bundle b
=new Bundle();
72 b
.putParcelable("Event",event
);
74 d
.show(getFragmentManager(), "Delete");
78 final Intent it
=new Intent(this,EventListActivity
.class);
82 AddEventActivity
.editEvent(DisplayEventActivity
.this,event
);
85 startActivity(new Intent(this,AddAlarmActivity
.class));