]>
Commit | Line | Data |
---|---|---|
222ca38d PT |
1 | package ro.ieval.unical; |
2 | ||
99658f57 | 3 | import java.text.SimpleDateFormat; |
222ca38d | 4 | import java.util.Date; |
8a08d036 | 5 | import java.util.Locale; |
222ca38d PT |
6 | |
7 | import android.app.Activity; | |
5cf4714f | 8 | import android.content.Context; |
46e6c000 | 9 | import android.content.Intent; |
222ca38d PT |
10 | import android.os.Bundle; |
11 | import android.view.Menu; | |
12 | import android.view.MenuInflater; | |
46e6c000 | 13 | import android.view.MenuItem; |
222ca38d PT |
14 | import android.widget.TextView; |
15 | ||
5cf4714f | 16 | public class DisplayEventActivity extends Activity { |
39f0cac1 | 17 | public static final String EXTRA_EVENT = "event"; |
f580909c | 18 | private Event event; |
dc52b261 | 19 | private final DeleteEventDialog d=new DeleteEventDialog(); |
39f0cac1 | 20 | |
86ad3786 | 21 | public static void displayEvent(final Context context, final long id){ |
5cf4714f | 22 | final Intent i=new Intent(context,DisplayEventActivity.class); |
86ad3786 | 23 | i.putExtra(DisplayEventActivity.EXTRA_EVENT, id); |
5cf4714f MG |
24 | context.startActivity(i); |
25 | } | |
26 | ||
222ca38d | 27 | @Override |
86ad3786 MG |
28 | protected void onStart() { |
29 | super.onStart(); | |
30 | event=getIntent().hasExtra(EXTRA_EVENT) ? Event.getEventById(this, getIntent().getLongExtra(EXTRA_EVENT, 0)) : new Event(); | |
5cf4714f | 31 | setContentView(R.layout.event_view); |
f580909c | 32 | setTitle(event.title); |
070d3ab2 | 33 | |
8a08d036 MG |
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); | |
82d6ca01 | 40 | final TextView description= (TextView) findViewById(R.id.event_view_description); |
070d3ab2 | 41 | |
f580909c MG |
42 | final Date start=new Date(event.dtstart); |
43 | final Date end=new Date(event.dtend); | |
8a08d036 MG |
44 | final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.UK); |
45 | final SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss", Locale.UK); | |
dec0e894 | 46 | final SimpleDateFormat dayOfWeekFormat = new SimpleDateFormat("EEEEEEE", Locale.UK); |
070d3ab2 | 47 | |
8a08d036 | 48 | startDay.setText(dayOfWeekFormat.format(start)); |
ad349897 | 49 | if(!dateFormat.format(start).equals(dateFormat.format(end))) { |
8a08d036 | 50 | endDay.setText(dayOfWeekFormat.format(end)); |
8a08d036 | 51 | endDate.setText(dateFormat.format(end)); |
dec0e894 PT |
52 | } |
53 | startDate.setText(dateFormat.format(start)); | |
8a08d036 MG |
54 | startTime.setText(timeFormat.format(start)); |
55 | endTime.setText(timeFormat.format(end)); | |
f580909c | 56 | description.setText(event.description); |
222ca38d | 57 | } |
070d3ab2 | 58 | |
222ca38d | 59 | @Override |
5cf4714f MG |
60 | public boolean onCreateOptionsMenu(final Menu menu) { |
61 | final MenuInflater inflater = getMenuInflater(); | |
8a08d036 | 62 | inflater.inflate(R.menu.event, menu); |
222ca38d PT |
63 | return true; |
64 | } | |
070d3ab2 | 65 | |
46e6c000 | 66 | @Override |
5cf4714f | 67 | public boolean onOptionsItemSelected(final MenuItem item) { |
8a08d036 MG |
68 | // Handle item selection |
69 | switch (item. getItemId()) { | |
55084aed | 70 | case R.id.deleteevent: |
dc52b261 P |
71 | final Bundle b=new Bundle(); |
72 | b.putParcelable("Event",event); | |
73 | d.setArguments(b); | |
55084aed | 74 | d.show(getFragmentManager(), "Delete"); |
dc52b261 | 75 | |
55084aed MG |
76 | return true; |
77 | case R.id.eventlist: | |
78 | final Intent it=new Intent(this,EventListActivity.class); | |
79 | startActivity(it); | |
80 | return true; | |
81 | case R.id.edit_event: | |
82 | AddEventActivity.editEvent(DisplayEventActivity.this,event); | |
83 | return true; | |
84 | case R.id.add_alarm: | |
85 | ||
86 | return true; | |
87 | default: | |
88 | return true; | |
8a08d036 | 89 | } |
46e6c000 | 90 | } |
222ca38d | 91 | } |