]> iEval git - unical.git/blob - src/ro/ieval/unical/DisplayEventActivity.java
Add alarm wip
[unical.git] / src / ro / ieval / unical / DisplayEventActivity.java
1 package ro.ieval.unical;
2
3 import java.text.SimpleDateFormat;
4 import java.util.Date;
5 import java.util.Locale;
6
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;
15
16 public class DisplayEventActivity extends Activity {
17 public static final String EXTRA_EVENT = "event";
18 private Event event;
19 private final DeleteEventDialog d=new DeleteEventDialog();
20
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);
25 }
26
27 @Override
28 protected void onStart() {
29 super.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);
33
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);
41
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);
47
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));
52 }
53 startDate.setText(dateFormat.format(start));
54 startTime.setText(timeFormat.format(start));
55 endTime.setText(timeFormat.format(end));
56 description.setText(event.description);
57 }
58
59 @Override
60 public boolean onCreateOptionsMenu(final Menu menu) {
61 final MenuInflater inflater = getMenuInflater();
62 inflater.inflate(R.menu.event, menu);
63 return true;
64 }
65
66 @Override
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);
73 d.setArguments(b);
74 d.show(getFragmentManager(), "Delete");
75
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 startActivity(new Intent(this,AddAlarmActivity.class));
86 return true;
87 default:
88 return true;
89 }
90 }
91 }
This page took 0.052643 seconds and 5 git commands to generate.