Exemplo n.º 1
0
 /**
  * 添加段子
  *
  * @param content
  * @param afterToday true今天之后,反之今天之前
  * @return
  */
 public boolean inSertContent(String content, boolean afterToday) {
   Date date = afterToday ? mDailyJokeDAO.getLastDate() : mDailyJokeDAO.getBeforeDate();
   if (date == null) {
     date = filterDateFormat(new Date());
     if (getByDate(date) != null) return false;
   } else {
     date = offsetDate(afterToday ? 1 : -1, date);
   }
   DailyJoke dj = new DailyJoke();
   dj.setContent(content);
   dj.setDate(date);
   return inSert(dj);
 }
Exemplo n.º 2
0
 public DailyJoke getById(int id) {
   try {
     return mDailyJokeDAO.getById(id);
   } catch (Exception e) {
     e.toString();
   }
   return null;
 }
Exemplo n.º 3
0
 public boolean update(String content, Date date) {
   try {
     return mDailyJokeDAO.update(content, date) == 1 ? true : false;
   } catch (Exception e) {
     e.toString();
   }
   return false;
 }
Exemplo n.º 4
0
 /**
  * @param date 删除date[包括date]之前的段子
  * @return
  */
 public boolean deleteBefore(Date date) {
   try {
     return mDailyJokeDAO.deleteBefore(date) >= 1 ? true : false;
   } catch (Exception e) {
     e.toString();
   }
   return false;
 }
Exemplo n.º 5
0
 public int getCount() {
   try {
     return mDailyJokeDAO.getCount();
   } catch (Exception e) {
     e.toString();
   }
   return 0;
 }
Exemplo n.º 6
0
 public List<DailyJoke> getAll(int offset, int limit) {
   try {
     return mDailyJokeDAO.getAll(offset, limit);
   } catch (Exception e) {
     e.toString();
   }
   return null;
 }
Exemplo n.º 7
0
 public List<DailyJoke> getAll(Date date, int offset, int limit) {
   try {
     date = filterDateFormat(date);
     return mDailyJokeDAO.getAll(date, offset, limit);
   } catch (Exception e) {
     e.toString();
   }
   return null;
 }
Exemplo n.º 8
0
 public DailyJoke getByDate(Date date) {
   try {
     date = filterDateFormat(date);
     return mDailyJokeDAO.getByDate(date);
   } catch (Exception e) {
     e.toString();
   }
   return null;
 }
Exemplo n.º 9
0
  /**
   * 删除今天起多少天以前的段子
   *
   * @param offset
   * @return
   */
  public boolean deleteBefore(int offset) {
    try {

      return mDailyJokeDAO.deleteBefore(offsetDate(-Math.abs(offset), new Date())) >= 1
          ? true
          : false;
    } catch (Exception e) {
      e.toString();
    }
    return false;
  }
Exemplo n.º 10
0
 public boolean inSert(DailyJoke mDailyJoke) {
   try {
     if (getByDate(mDailyJoke.getDate()) != null) {
       return false;
     }
     mDailyJoke.setDate(filterDateFormat(mDailyJoke.getDate()));
     return mDailyJokeDAO.insert(mDailyJoke) == 1 ? true : false;
   } catch (Exception e) {
     e.toString();
   }
   return false;
 }