Ejemplo n.º 1
0
  @Override
  public void onClick(View v) {
    int viewId = v.getId();

    switch (viewId) {
      case R.id.btn_edit_details:
        {
          Intent intent = new Intent(this, CreateActivity.class);
          intent.putExtra("id", id);
          intent.putExtra("SENDER_CLASS_NAME", this.getClass());
          Toast.makeText(
                  getApplicationContext(),
                  "You are in edit mode and can modify the event!",
                  Toast.LENGTH_SHORT)
              .show();
          startActivity(intent);
          break;
        }
      case R.id.btn_delete_details:
        {
          mydb.deleteEvent(id);
          Toast.makeText(getApplicationContext(), "Event deleted!", Toast.LENGTH_SHORT).show();
          Intent intent = new Intent(EventDetailsActivity.this, MainActivity.class);
          startActivity(intent);
          break;
        }
      case R.id.btn_close_details:
        {
          Toast.makeText(getApplicationContext(), "Event details closed!", Toast.LENGTH_SHORT)
              .show();
          Intent intent;
          switch (sender) {
            case "class com.example.ric.mydiary.MainActivityFragment":
              intent = new Intent(EventDetailsActivity.this, MainActivity.class);
              startActivity(intent);
              break;
            case "class com.example.ric.mydiary.MainSearchFragment":
              intent = new Intent(EventDetailsActivity.this, MainActivity.class);
              MainActivity.viewPager.setCurrentItem(1);
              startActivity(intent);
              break;
          }
          break;
        }
      case R.id.btn_export_details:
        {
          InsertInCalendar(
              currentEvent.getTitle(),
              currentEvent.getDescription(),
              currentEvent.getPlace(),
              currentEvent.getDateTime());
          break;
        }
    }
  }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_event_details);

    closeButton = (FloatingActionButton) findViewById(R.id.btn_close_details);
    closeButton.setOnClickListener(this);
    editButton = (FloatingActionButton) findViewById(R.id.btn_edit_details);
    editButton.setOnClickListener(this);
    deleteButton = (FloatingActionButton) findViewById(R.id.btn_delete_details);
    deleteButton.setOnClickListener(this);
    exportButton = (FloatingActionButton) findViewById(R.id.btn_export_details);
    exportButton.setOnClickListener(this);

    mydb = new EventsDataSource(this);

    Bundle bundle = getIntent().getExtras();
    id = bundle.getLong("id");
    sender = bundle.get("SENDER_CLASS_NAME").toString();

    currentEvent = mydb.getEventsById(id);

    title = (TextView) findViewById(R.id.tv_title);
    description = (TextView) findViewById(R.id.tv_description);
    category = (TextView) findViewById(R.id.tv_category);
    date = (TextView) findViewById(R.id.tv_date);
    place = (TextView) findViewById(R.id.tv_place);
    imageView = (ImageView) this.findViewById(R.id.iv_image);

    title.setText(currentEvent.getTitle());
    description.setText(currentEvent.getDescription());
    category.setText(currentEvent.getCategory());
    date.setText(DateTimeSetter.setDateTimeToDisplayString(currentEvent.getDateTime()));
    place.setText(currentEvent.getPlace());
    Bitmap bitmap = BitmapFactory.decodeFile(currentEvent.getImage());
    imageView.setImageBitmap(bitmap);
  }