]>
Commit | Line | Data |
---|---|---|
222ca38d PT |
1 | package ro.ieval.unical; |
2 | ||
3 | import java.util.Date; | |
4 | ||
5 | import android.app.Activity; | |
5cf4714f | 6 | import android.content.Context; |
46e6c000 | 7 | import android.content.Intent; |
222ca38d PT |
8 | import android.os.Bundle; |
9 | import android.view.Menu; | |
10 | import android.view.MenuInflater; | |
46e6c000 | 11 | import android.view.MenuItem; |
222ca38d PT |
12 | import android.widget.TextView; |
13 | ||
5cf4714f | 14 | public class DisplayEventActivity extends Activity { |
39f0cac1 MG |
15 | public static final String EXTRA_EVENT = "event"; |
16 | ||
5cf4714f MG |
17 | public static void displayEvent(final Context context, final Event event){ |
18 | final Intent i=new Intent(context,DisplayEventActivity.class); | |
19 | i.putExtra(DisplayEventActivity.EXTRA_EVENT, event); | |
20 | context.startActivity(i); | |
21 | } | |
22 | ||
222ca38d | 23 | @Override |
5cf4714f | 24 | protected void onCreate(final Bundle savedInstanceState) { |
222ca38d | 25 | super.onCreate(savedInstanceState); |
39f0cac1 | 26 | final Event e=getIntent().getParcelableExtra(EXTRA_EVENT); |
5cf4714f | 27 | setContentView(R.layout.event_view); |
0b5b93a4 | 28 | |
222ca38d PT |
29 | final TextView eventTitle= (TextView) findViewById(R.id.eventTitle); |
30 | final TextView date=(TextView) findViewById(R.id.date); | |
31 | final TextView description=(TextView) findViewById(R.id.description); | |
32 | final TextView location= (TextView) findViewById(R.id.location); | |
0b5b93a4 | 33 | |
222ca38d | 34 | eventTitle.setText(e.title); |
5cf4714f | 35 | date.setText(new Date(e.dtstart).toString()); |
222ca38d | 36 | description.setText(e.description); |
39f0cac1 | 37 | location.setText(e.eventLocation); |
222ca38d PT |
38 | } |
39 | ||
40 | @Override | |
5cf4714f MG |
41 | public boolean onCreateOptionsMenu(final Menu menu) { |
42 | final MenuInflater inflater = getMenuInflater(); | |
43 | inflater.inflate(R.menu.event, menu); | |
222ca38d PT |
44 | return true; |
45 | } | |
46e6c000 PT |
46 | |
47 | @Override | |
5cf4714f | 48 | public boolean onOptionsItemSelected(final MenuItem item) { |
46e6c000 | 49 | // Handle item selection |
0b5b93a4 | 50 | switch (item. getItemId()) { |
46e6c000 | 51 | case R.id.NewEvent: |
5cf4714f | 52 | final Intent i=new Intent(this,AddEventActivity.class); |
46e6c000 PT |
53 | startActivity(i); |
54 | return true; | |
55 | case R.id.deleteevent: | |
5cf4714f | 56 | final DeleteEventDialog d=new DeleteEventDialog(); |
46e6c000 PT |
57 | d.show(getFragmentManager(), "Delete"); |
58 | return true; | |
0b5b93a4 PT |
59 | case R.id.eventlist: |
60 | final Intent it=new Intent(this,EventListActivity.class); | |
61 | startActivity(it); | |
62 | return true; | |
46e6c000 PT |
63 | default: |
64 | return true; | |
65 | } | |
66 | } | |
222ca38d | 67 | } |