예제 #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();
   }
 }