Commit | Line | Data |
---|---|---|
222ca38d PT |
1 | package ro.ieval.unical; |
2 | ||
99658f57 | 3 | import java.text.SimpleDateFormat; |
222ca38d | 4 | import java.util.Date; |
99658f57 | 5 | import java.util.GregorianCalendar; |
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 MG |
17 | public static final String EXTRA_EVENT = "event"; |
18 | ||
5cf4714f MG |
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 | ||
222ca38d | 25 | @Override |
5cf4714f | 26 | protected void onCreate(final Bundle savedInstanceState) { |
222ca38d | 27 | super.onCreate(savedInstanceState); |
39f0cac1 | 28 | final Event e=getIntent().getParcelableExtra(EXTRA_EVENT); |
5cf4714f | 29 | setContentView(R.layout.event_view); |
99658f57 | 30 | setTitle(e.title); |
0b5b93a4 | 31 | |
99658f57 PT |
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())); | |
222ca38d PT |
54 | } |
55 | ||
56 | @Override | |
5cf4714f MG |
57 | public boolean onCreateOptionsMenu(final Menu menu) { |
58 | final MenuInflater inflater = getMenuInflater(); | |
59 | inflater.inflate(R.menu.event, menu); | |
222ca38d PT |
60 | return true; |
61 | } | |
46e6c000 PT |
62 | |
63 | @Override | |
5cf4714f | 64 | public boolean onOptionsItemSelected(final MenuItem item) { |
46e6c000 | 65 | // Handle item selection |
0b5b93a4 | 66 | switch (item. getItemId()) { |
46e6c000 | 67 | case R.id.NewEvent: |
5cf4714f | 68 | final Intent i=new Intent(this,AddEventActivity.class); |
46e6c000 PT |
69 | startActivity(i); |
70 | return true; | |
71 | case R.id.deleteevent: | |
5cf4714f | 72 | final DeleteEventDialog d=new DeleteEventDialog(); |
46e6c000 PT |
73 | d.show(getFragmentManager(), "Delete"); |
74 | return true; | |
0b5b93a4 PT |
75 | case R.id.eventlist: |
76 | final Intent it=new Intent(this,EventListActivity.class); | |
77 | startActivity(it); | |
78 | return true; | |
46e6c000 PT |
79 | default: |
80 | return true; | |
81 | } | |
82 | } | |
222ca38d | 83 | } |