Пример #1
0
 public static void putAllMyTags(List<AskTag> myTags) {
   AppApplication.getDaoSession().getDatabase().beginTransaction();
   try {
     AskTagDao tagDao = AppApplication.getDaoSession().getAskTagDao();
     tagDao.deleteAll();
     tagDao.insertInTx(myTags);
     AppApplication.getDaoSession().getDatabase().setTransactionSuccessful();
     SharedPreferencesUtil.saveLong(Consts.Key_Last_Ask_Tags_Version, System.currentTimeMillis());
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     AppApplication.getDaoSession().getDatabase().endTransaction();
   }
 }
Пример #2
0
 /**
  * 调整未选中项的顺序,Key_Last_Ask_Tags_Version
  *
  * @param myTags tag
  */
 public static void putUnselectedTags(List<AskTag> myTags) {
   AppApplication.getDaoSession().getDatabase().beginTransaction();
   try {
     List<AskTag> tags = getSelectedTags();
     tags.addAll(myTags);
     for (int i = 0; i < tags.size(); i++) {
       tags.get(i).setId(null);
     }
     AskTagDao tagDao = AppApplication.getDaoSession().getAskTagDao();
     tagDao.deleteAll();
     tagDao.insertInTx(tags);
     AppApplication.getDaoSession().getDatabase().setTransactionSuccessful();
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     AppApplication.getDaoSession().getDatabase().endTransaction();
   }
 }
Пример #3
0
 public static List<AskTag> getUnselectedTags() {
   AskTagDao tagDao = AppApplication.getDaoSession().getAskTagDao();
   QueryBuilder<AskTag> builder =
       tagDao
           .queryBuilder()
           .where(AskTagDao.Properties.Selected.eq(false))
           .orderAsc(AskTagDao.Properties.Order);
   return builder.list();
 }
Пример #4
0
 public static List<SubItem> getSelectedQuestionSubItems() {
   AskTagDao tagDao = AppApplication.getDaoSession().getAskTagDao();
   QueryBuilder<AskTag> builder =
       tagDao
           .queryBuilder()
           .where(AskTagDao.Properties.Selected.eq(true))
           .orderAsc(AskTagDao.Properties.Order);
   List<AskTag> askTags = builder.list();
   ArrayList<SubItem> subItems = new ArrayList<>();
   for (int i = 0; i < askTags.size(); i++) {
     AskTag tag = askTags.get(i);
     SubItem subItem = new SubItem(tag.getSection(), tag.getType(), tag.getName(), tag.getValue());
     subItems.add(subItem);
   }
   return subItems;
 }
Пример #5
0
 public static List<AskTag> getAllMyTags() {
   AskTagDao tagDao = AppApplication.getDaoSession().getAskTagDao();
   return tagDao.loadAll();
 }
Пример #6
0
 public static long getAskTagsNumber() {
   AskTagDao tagDao = AppApplication.getDaoSession().getAskTagDao();
   return tagDao.count();
 }
Пример #7
0
 public static void clearAllMyTags() {
   AskTagDao tagDao = AppApplication.getDaoSession().getAskTagDao();
   tagDao.deleteAll();
   SharedPreferencesUtil.saveLong(Consts.Key_Last_Ask_Tags_Version, System.currentTimeMillis());
 }