EventDetailsScreen.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.example.yiupang.freefoodfinder;
  2. import android.os.Bundle;
  3. import android.view.View;
  4. import android.widget.TextView;
  5. import android.support.v7.app.AppCompatActivity;
  6. import java.text.SimpleDateFormat;
  7. import java.util.Date;
  8. import java.util.Locale;
  9. public class EventDetailsScreen extends AppCompatActivity
  10. {
  11. @Override
  12. protected void onCreate(Bundle savedInstanceState)
  13. {
  14. super.onCreate(savedInstanceState);
  15. setContentView(R.layout.activity_event_details_screen);
  16. SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
  17. String selectedEventName = (String)getIntent().getExtras().getSerializable("selectedEventName");
  18. String selectedEventTime = (String)getIntent().getExtras().getSerializable("selectedEventTime");
  19. String selectedEventPlace = (String)getIntent().getExtras().getSerializable("selectedEventPlace");
  20. String selectedEventDesc = (String)getIntent().getExtras().getSerializable("selectedEventDesc");
  21. String selectedEventFoodType = (String)getIntent().getExtras().getSerializable("selectedEventFoodType");
  22. TextView timeLabel = (TextView) findViewById(R.id.timelabel);
  23. timeLabel.setVisibility(View.GONE);
  24. TextView dateText = (TextView) findViewById(R.id.datetext);
  25. dateText.setVisibility(View.GONE);
  26. TextView nameText = (TextView) findViewById(R.id.nameText);
  27. nameText.setText(selectedEventName);
  28. TextView timeText = (TextView) findViewById(R.id.timeText);
  29. timeText.setText(selectedEventTime == null ? "TBA" :
  30. dayFormat.format(new Date(Long.parseLong(selectedEventTime))));
  31. TextView placeText = (TextView) findViewById(R.id.placeText);
  32. placeText.setText(selectedEventPlace == null || selectedEventPlace.equals("") ?
  33. "TBA" : selectedEventPlace);
  34. TextView foodText = (TextView) findViewById(R.id.foodText);
  35. foodText.setText(selectedEventFoodType);
  36. TextView descText = (TextView) findViewById( R.id.descText);
  37. descText.setText(selectedEventDesc);
  38. }
  39. }