EventDetailsScreen.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. String selectedEventName;
  12. TextView nameText;
  13. int success;
  14. @Override
  15. protected void onCreate(Bundle savedInstanceState)
  16. {
  17. super.onCreate(savedInstanceState);
  18. setContentView(R.layout.activity_event_details_screen);
  19. SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
  20. selectedEventName = (String)getIntent().getExtras().getSerializable("selectedEventName");
  21. String selectedEventTime = (String)getIntent().getExtras().getSerializable("selectedEventTime");
  22. String selectedEventPlace = (String)getIntent().getExtras().getSerializable("selectedEventPlace");
  23. String selectedEventDesc = (String)getIntent().getExtras().getSerializable("selectedEventDesc");
  24. String selectedEventFoodType = (String)getIntent().getExtras().getSerializable("selectedEventFoodType");
  25. TextView timeLabel = (TextView) findViewById(R.id.timelabel);
  26. timeLabel.setVisibility(View.GONE);
  27. TextView dateText = (TextView) findViewById(R.id.datetext);
  28. dateText.setVisibility(View.GONE);
  29. nameText = (TextView) findViewById(R.id.nameText);
  30. nameText.setText(selectedEventName);
  31. TextView timeText = (TextView) findViewById(R.id.timeText);
  32. timeText.setText(selectedEventTime == null ? "TBA" :
  33. dayFormat.format(new Date(Long.parseLong(selectedEventTime))));
  34. TextView placeText = (TextView) findViewById(R.id.placeText);
  35. placeText.setText(selectedEventPlace == null || "".equals(selectedEventPlace) ?
  36. "TBA" : selectedEventPlace);
  37. TextView foodText = (TextView) findViewById(R.id.foodText);
  38. foodText.setText(selectedEventFoodType);
  39. TextView descText = (TextView) findViewById( R.id.descText);
  40. descText.setText(selectedEventDesc);
  41. if(selectedEventDesc != null && selectedEventFoodType != null
  42. && selectedEventPlace != null && selectedEventTime != null
  43. && selectedEventName != null)
  44. {
  45. success = 1;
  46. }
  47. else
  48. {
  49. success = 0;
  50. }
  51. }
  52. }