]>
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; |
39f0cac1 | 19 | |
5cf4714f MG |
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); | |
24 | } | |
25 | ||
222ca38d | 26 | @Override |
5cf4714f | 27 | protected void onCreate(final Bundle savedInstanceState) { |
222ca38d | 28 | super.onCreate(savedInstanceState); |
f580909c | 29 | event=getIntent().getParcelableExtra(EXTRA_EVENT); |
5cf4714f | 30 | setContentView(R.layout.event_view); |
f580909c | 31 | setTitle(event.title); |
070d3ab2 | 32 | |
8a08d036 MG |
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); | |
82d6ca01 | 39 | final TextView description= (TextView) findViewById(R.id.event_view_description); |
070d3ab2 | 40 | |
f580909c MG |
41 | final Date start=new Date(event.dtstart); |
42 | final Date end=new Date(event.dtend); | |
8a08d036 MG |
43 | final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.UK); |
44 | final SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss", Locale.UK); | |
dec0e894 | 45 | final SimpleDateFormat dayOfWeekFormat = new SimpleDateFormat("EEEEEEE", Locale.UK); |
070d3ab2 | 46 | |
8a08d036 | 47 | startDay.setText(dayOfWeekFormat.format(start)); |
ad349897 | 48 | if(!dateFormat.format(start).equals(dateFormat.format(end))) { |
8a08d036 | 49 | endDay.setText(dayOfWeekFormat.format(end)); |
8a08d036 | 50 | endDate.setText(dateFormat.format(end)); |
dec0e894 PT |
51 | } |
52 | startDate.setText(dateFormat.format(start)); | |
8a08d036 MG |
53 | startTime.setText(timeFormat.format(start)); |
54 | endTime.setText(timeFormat.format(end)); | |
f580909c | 55 | description.setText(event.description); |
222ca38d | 56 | } |
070d3ab2 | 57 | |
222ca38d | 58 | @Override |
5cf4714f MG |
59 | public boolean onCreateOptionsMenu(final Menu menu) { |
60 | final MenuInflater inflater = getMenuInflater(); | |
8a08d036 | 61 | inflater.inflate(R.menu.event, menu); |
222ca38d PT |
62 | return true; |
63 | } | |
070d3ab2 | 64 | |
46e6c000 | 65 | @Override |
5cf4714f | 66 | public boolean onOptionsItemSelected(final MenuItem item) { |
8a08d036 MG |
67 | // Handle item selection |
68 | switch (item. getItemId()) { | |
69 | case R.id.NewEvent: | |
70 | final Intent i=new Intent(this,AddEventActivity.class); | |
46e6c000 | 71 | startActivity(i); |
8a08d036 MG |
72 | return true; |
73 | case R.id.deleteevent: | |
f580909c | 74 | final DeleteEventDialog d=new DeleteEventDialog(event,this); |
8a08d036 MG |
75 | d.show(getFragmentManager(), "Delete"); |
76 | return true; | |
77 | case R.id.eventlist: | |
78 | final Intent it=new Intent(this,EventListActivity.class); | |
79 | startActivity(it); | |
80 | return true; | |
ad349897 P |
81 | case R.id.edit_event: |
82 | AddEventActivity.editEvent(DisplayEventActivity.this,event); | |
83 | return true; | |
8a08d036 MG |
84 | default: |
85 | return true; | |
86 | } | |
46e6c000 | 87 | } |
222ca38d | 88 | } |