コード例 #1
0
 public long getLastModificationDate() {
   long time = 0;
   String query =
       "SELECT max("
           + CacheHelper.PAGE_MODIFIED
           + ") FROM "
           + CacheHelper.TABLE_PAGE
           + " WHERE "
           + CacheHelper.PAGE_LANGUAGE
           + "="
           + String.valueOf(mLanguage.getId())
           + " AND "
           + CacheHelper.PAGE_LOCATION
           + "="
           + String.valueOf(mLocation.getId())
           + " AND "
           + CacheHelper.PAGE_TYPE
           + "="
           + Helper.quote(getType());
   Cursor cursor = mCache.executeRawQuery(query, null);
   if (cursor != null) {
     try {
       if (cursor.moveToFirst()) {
         time = cursor.getLong(0);
       }
     } finally {
       cursor.close();
     }
   }
   return time;
 }
コード例 #2
0
 private SQLiteQueryBuilder getCursorQueryBuilder(String tables) {
   SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
   builder.setTables(tables);
   builder.appendWhere(CacheHelper.PAGE_LANGUAGE + " = " + String.valueOf(mLanguage.getId()));
   builder.appendWhere(
       " AND " + CacheHelper.PAGE_LOCATION + " = " + String.valueOf(mLocation.getId()));
   builder.appendWhere(
       " AND " + CacheHelper.PAGE_STATUS + " != " + Helper.quote(PAGE_STATUS_TRASH));
   builder.appendWhere(" AND " + CacheHelper.PAGE_TYPE + " = " + Helper.quote(getType()));
   return builder;
 }
コード例 #3
0
  @Override
  public void store(@NonNull SQLiteDatabase db, @NonNull List<? extends Page> mPages) {
    if (mPages.isEmpty()) {
      return;
    }

    ContentValues pageValues = new ContentValues(14);
    ContentValues authorValues = new ContentValues(3);
    for (Page mPage : mPages) {
      List<Page> pages = new ArrayList<>();
      pages.add(mPage);
      pages.addAll(mPage.getSubPages());
      for (Page page : pages) {
        pageValues.clear();
        pageValues.put(CacheHelper.PAGE_ID, page.getId());
        pageValues.put(CacheHelper.PAGE_TITLE, page.getTitle());
        pageValues.put(CacheHelper.PAGE_TYPE, page.getType());
        pageValues.put(CacheHelper.PAGE_STATUS, page.getStatus());
        pageValues.put(CacheHelper.PAGE_MODIFIED, page.getModified());
        pageValues.put(CacheHelper.PAGE_DESCRIPTION, page.getDescription());
        pageValues.put(CacheHelper.PAGE_CONTENT, page.getContent());
        pageValues.put(CacheHelper.PAGE_PARENT_ID, page.getParentId());
        pageValues.put(CacheHelper.PAGE_ORDER, page.getOrder());
        pageValues.put(CacheHelper.PAGE_THUMBNAIL, page.getThumbnail());
        pageValues.put(CacheHelper.PAGE_LOCATION, mLocation.getId());
        pageValues.put(CacheHelper.PAGE_LANGUAGE, mLanguage.getId());
        pageValues.put(CacheHelper.PAGE_AUTHOR, page.getAuthor().getLogin());
        pageValues.put(CacheHelper.PAGE_AUTO_TRANSLATED, page.isAutoTranslated() ? 1 : 0);
        db.replace(CacheHelper.TABLE_PAGE, null, pageValues);

        authorValues.clear();
        authorValues.put(CacheHelper.AUTHOR_USERNAME, page.getAuthor().getLogin());
        authorValues.put(CacheHelper.AUTHOR_FIRSTNAME, page.getAuthor().getFirstName());
        authorValues.put(CacheHelper.AUTHOR_LASTNAME, page.getAuthor().getLastName());
        db.replace(CacheHelper.TABLE_AUTHOR, null, authorValues);

        mAvailableLanguageResource.store(db, page);
      }
    }
  }
コード例 #4
0
 private String makeLocationKey(Location location) {
   return String.format("location_key(%d)", location.getId());
 }
コード例 #5
0
 private String makePageDisclaimerKey(Language language, Location location) {
   return String.format("disclaimer_key(%d)(%d)", language.getId(), location.getId());
 }
コード例 #6
0
 private String makePageKey(Language language, Location location) {
   return String.format("page_key(%d)(%d)", language.getId(), location.getId());
 }
コード例 #7
0
 private static String makePushKey(Location location) {
   return "_push" + location.getId() + PROPERTY_REGISTERED_TS;
 }