]> iEval git - unical.git/blob - src/ro/ieval/unical/DisplayEventActivity.java
8055ec131fa3040bc9cc76c31888c9f2eee68607
[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.GregorianCalendar;
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
19 public static void displayEvent(final Context context, final Event event){
20 final Intent i=new Intent(context,DisplayEventActivity.class);
21 i.putExtra(DisplayEventActivity.EXTRA_EVENT, event);
22 context.startActivity(i);
23 }
24
25 @Override
26 protected void onCreate(final Bundle savedInstanceState) {
27 super.onCreate(savedInstanceState);
28 final Event e=getIntent().getParcelableExtra(EXTRA_EVENT);
29 setContentView(R.layout.event_view);
30 setTitle(e.title);
31
32 final TextView startday= (TextView) findViewById(R.id.startday);
33 final TextView endday= (TextView) findViewById(R.id.endday);
34 final TextView startdate= (TextView) findViewById(R.id.startdate);
35 final TextView enddate= (TextView) findViewById(R.id.enddate);
36 final TextView starttime= (TextView) findViewById(R.id.starttime);
37 final TextView endtime= (TextView) findViewById(R.id.endtime);
38
39 GregorianCalendar cstart = new GregorianCalendar();
40 cstart.setTime(new Date(e.dtstart));
41 GregorianCalendar cend = new GregorianCalendar();
42 cend.setTime(new Date(e.dtend));
43 SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
44 SimpleDateFormat stf = new SimpleDateFormat("kk:mm:ss");
45
46 startday.setText(CalendarUtils.DayToString(this,cstart));
47 if(CalendarUtils.DayToString(this,cstart)!=CalendarUtils.DayToString(this, cend))
48 endday.setText(CalendarUtils.DayToString(this, cend));
49 startdate.setText(sdf.format(cstart.getTime()));
50 if(sdf.format(cstart.getTime())!=sdf.format(cend.getTime()))
51 enddate.setText(sdf.format(cend.getTime()));
52 starttime.setText(stf.format(cstart.getTime()));
53 endtime.setText(stf.format(cend.getTime()));
54 }
55
56 @Override
57 public boolean onCreateOptionsMenu(final Menu menu) {
58 final MenuInflater inflater = getMenuInflater();
59 inflater.inflate(R.menu.event, menu);
60 return true;
61 }
62
63 @Override
64 public boolean onOptionsItemSelected(final MenuItem item) {
65 // Handle item selection
66 switch (item. getItemId()) {
67 case R.id.NewEvent:
68 final Intent i=new Intent(this,AddEventActivity.class);
69 startActivity(i);
70 return true;
71 case R.id.deleteevent:
72 final DeleteEventDialog d=new DeleteEventDialog();
73 d.show(getFragmentManager(), "Delete");
74 return true;
75 case R.id.eventlist:
76 final Intent it=new Intent(this,EventListActivity.class);
77 startActivity(it);
78 return true;
79 default:
80 return true;
81 }
82 }
83 }
This page took 0.049289 seconds and 3 git commands to generate.