コード例 #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(
        savedInstanceState,
        R.layout.eventdetails,
        getResources().getString(R.string.eventsDetailsTitle));

    if ((currentEvent = (Event) this.getIntent().getSerializableExtra("event")) != null) {

      gigPrefs = getPreferences(MODE_PRIVATE);

      mapObjects();
      fillData(currentEvent);

      eventsPersist = new EventDataSource(this);

      getRightButton().setText("+");

      eventsPersist.open();
      if (eventsPersist.getEventByID(currentEvent.getEventID()) != null) {
        this.scheduled = true;
        getRightButton().setText("-");
      }
      eventsPersist.close();

      getRightButton().setVisibility(Button.VISIBLE);
      getRightButton().setEnabled(true);

      getRightButton()
          .setOnClickListener(
              new View.OnClickListener() {

                public void onClick(View v) {
                  swapFollow();
                }
              });

      getLeftButton().setVisibility(TextView.VISIBLE);
      getLeftButton().setText(this.getIntent().getStringExtra("backActiv"));
      getLeftButton()
          .setOnClickListener(
              new View.OnClickListener() {
                public void onClick(View v) {
                  onBackPressed();
                }
              });
      getLeftButton().setEnabled(true);
    } else this.finish();
  }
コード例 #2
0
  private void swapFollow() {

    eventsPersist.open();
    if (scheduled) {
      eventsPersist.deleteEvent(this.currentEvent);
      getRightButton().setText("+");
      this.scheduled = false;
    } else {
      loginToFacebook();
      this.currentEvent = eventsPersist.createEvent(currentEvent);
      getRightButton().setText("-");
      this.scheduled = true;
      postToFacebook("");
    }
    eventsPersist.close();
  }