/**
  * TODOフォーム画面を表示
  *
  * @param item TODOリストデータ
  */
 public void showTodoForm(Todo item) {
   String tag = TodoFormFragment.TAG;
   TodoFormFragment fragment;
   if (item == null) {
     // 新規作成
     fragment = TodoFormFragment.newInstance();
   } else {
     // 編集
     fragment =
         TodoFormFragment.newInstance(
             item.getId(), item.getColorLabel(), item.getValue(), item.getCreatedTime());
   }
   if (!mIsTablet) {
     // スマートフォンレイアウトの場合はcontainerに表示
     getSupportFragmentManager()
         .beginTransaction()
         .replace(R.id.container, fragment, tag)
         .addToBackStack(tag)
         .commit();
   } else {
     // タブレットレイアウトの場合はcontainer2に表示
     getSupportFragmentManager()
         .beginTransaction()
         .replace(R.id.container2, fragment, tag)
         .addToBackStack(tag)
         .commit();
   }
 }
  private TodoDTO convertToDTO(Todo model) {
    TodoDTO dto = new TodoDTO();

    dto.setId(model.getId());
    dto.setTitle(model.getTitle());
    dto.setDescription(model.getDescription());

    return dto;
  }
示例#3
0
  private String listItems(HttpServletRequest request) {
    String html = "";

    Long userID = (Long) request.getSession().getAttribute("userID");
    if (userID == null) {
      return "You must log in first!";
    }

    for (Object o : DBUtil.get("SELECT t FROM Todo t WHERE t.completed != null")) {
      Todo t = (Todo) o;
      html += "<tr><td>" + t.getId() + "</td>";
      html += "<td>" + t.getName() + "</td>";
      html += "<td>" + t.getDescription() + "</td>";
      html += "<td>" + t.getDue() + "</td>";
      html += "<td>" + t.getCompleted() + "</td>";
      html += "<td>" + t.getStatusid() + "</td>";
      html += "<td>" + t.getPriority() + "</td></tr>";
    }
    return html;
  }
 public void deleteTodo(Todo todo) {
   long id = todo.getId();
   System.out.println("Todo deleted with id: " + id);
   database.delete(MySQLiteHelper.TABLE_TODOS, MySQLiteHelper.COLUMN_ID + " = " + id, null);
 }
 private boolean isSameTodo(@PathVariable Long id, @RequestBody Todo todo) {
   return !id.equals(todo.getId());
 }