Ejemplo n.º 1
0
  @SuppressLint("SimpleDateFormat")
  public void onClick(View v) {
    // TODO Auto-generated method stub
    Date theDate = Calendar.getInstance().getTime();
    SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd");
    String date = dateFormat.format(theDate); // On list view

    if (restaurantId == null) {
      SimpleDateFormat created = new SimpleDateFormat("dd MMM yyyy hh:mm aa");
      String createdDate = created.format(theDate);

      helper.insert(
          textTitle.getText().toString(),
          textContent.getText().toString(),
          date,
          "Created on " + createdDate.toString());
      count++;
      finish();
    } else {

      if (save.getText().toString() == "edit") {
        save.setText("save");

        textContent.setClickable(true);
        textContent.setFocusableInTouchMode(true);

        textTitle.setFocusable(true);
        textTitle.setClickable(true);
        textTitle.setFocusableInTouchMode(true);
      }
      SimpleDateFormat modified = new SimpleDateFormat("dd MMM yyyy hh:mm aa");
      String modifiedDate = modified.format(theDate);
      helper.update(
          restaurantId,
          textTitle.getText().toString(),
          textContent.getText().toString(),
          date,
          "Modified on " + modifiedDate.toString());

      Toast.makeText(getApplicationContext(), "saved", Toast.LENGTH_SHORT).show();
    }
  }
Ejemplo n.º 2
0
  private void load() {
    // TODO Auto-generated method stub

    save.setText("edit");

    textContent.setFocusable(false);
    textContent.setClickable(false);
    textContent.setFocusableInTouchMode(false);

    textTitle.setFocusable(false);
    textTitle.setClickable(false);
    textTitle.setFocusableInTouchMode(false);

    Cursor c = helper.getById(restaurantId);
    c.moveToFirst();
    textTitle.setText(helper.getTitle(c));
    textContent.setText(helper.getContent(c));
    dayEntries.setText(helper.getCreatedDate(c));
    c.close();
  }
Ejemplo n.º 3
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   helper.close();
 }