コード例 #1
0
 @Inject
 public DisBoardsLocalRepoImpl(DaoSession daoSession) {
   this.daoSession = daoSession;
   this.boardPostDao = daoSession.getBoardPostDao();
   this.boardPostListDao = daoSession.getBoardPostListDao();
   this.boardPostCommentDao = daoSession.getBoardPostCommentDao();
   this.boardPostSummaryDao = daoSession.getBoardPostSummaryDao();
 }
コード例 #2
0
  @Override
  public void setBoardPost(final BoardPost boardPost) throws Exception {
    AssertUtils.checkMainThread();
    daoSession.callInTx(
        new Callable<Boolean>() {
          @Override
          public Boolean call() throws Exception {
            if (boardPost != null) {
              // Horrible we want to keep this local value
              BoardPost existingBoardPost = boardPostDao.load(boardPost.getBoardPostID());
              if (existingBoardPost != null) {
                boardPost.setNumberOfTimesOpened(existingBoardPost.getNumberOfTimesOpened());
              }

              boardPostDao.insertOrReplace(boardPost);
              List<BoardPostComment> boardPostComments = boardPost.getComments();
              boardPostCommentDao.insertOrReplaceInTx(boardPostComments);
            }
            return true;
          }
        });
  }