當前位置: 首頁>>代碼示例>>Java>>正文


Java DirectoryRefreshJob類代碼示例

本文整理匯總了Java中org.thoughtcrime.securesms.jobs.DirectoryRefreshJob的典型用法代碼示例。如果您正苦於以下問題:Java DirectoryRefreshJob類的具體用法?Java DirectoryRefreshJob怎麽用?Java DirectoryRefreshJob使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DirectoryRefreshJob類屬於org.thoughtcrime.securesms.jobs包,在下文中一共展示了DirectoryRefreshJob類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: schedule

import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob; //導入依賴的package包/類
public static void schedule(Context context) {
  if (!TextSecurePreferences.isPushRegistered(context)) return;

  AlarmManager      alarmManager  = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  Intent            intent        = new Intent(DirectoryRefreshListener.REFRESH_EVENT);
  PendingIntent     pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
  long              time          = TextSecurePreferences.getDirectoryRefreshTime(context);

  if (time <= System.currentTimeMillis()) {
    if (time != 0) {
      ApplicationContext.getInstance(context)
                        .getJobManager()
                        .add(new DirectoryRefreshJob(context));
    }

    time = System.currentTimeMillis() + INTERVAL;
  }

  Log.w("DirectoryRefreshListener", "Scheduling for: " + time);

  alarmManager.cancel(pendingIntent);
  alarmManager.set(AlarmManager.RTC_WAKEUP, time, pendingIntent);

  TextSecurePreferences.setDirectoryRefreshTime(context, time);
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:26,代碼來源:DirectoryRefreshListener.java

示例2: doInBackground

import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob; //導入依賴的package包/類
@Override
    protected Void doInBackground(Integer... params) {
      Context context = DatabaseUpgradeActivity.this.getApplicationContext();

      Log.w("DatabaseUpgradeActivity", "Running background upgrade..");
      DatabaseFactory.getInstance(DatabaseUpgradeActivity.this)
                     .onApplicationLevelUpgrade(context, masterSecret, params[0], this);

      if (params[0] < CURVE25519_VERSION) {
        IdentityKeyUtil.migrateIdentityKeys(context, masterSecret);
      }

      if (params[0] < NO_V1_VERSION) {
        File v1sessions = new File(context.getFilesDir(), "sessions");

        if (v1sessions.exists() && v1sessions.isDirectory()) {
          File[] contents = v1sessions.listFiles();

          if (contents != null) {
            for (File session : contents) {
              session.delete();
            }
          }

          v1sessions.delete();
        }
      }

      if (params[0] < SIGNED_PREKEY_VERSION) {
        ApplicationContext.getInstance(getApplicationContext())
                          .getJobManager()
                          .add(new CreateSignedPreKeyJob(context));
      }

      if (params[0] < NO_DECRYPT_QUEUE_VERSION) {
        scheduleMessagesInPushDatabase(context);
      }

      if (params[0] < PUSH_DECRYPT_SERIAL_ID_VERSION) {
        scheduleMessagesInPushDatabase(context);
      }

      if (params[0] < MIGRATE_SESSION_PLAINTEXT) {
        new TextSecureSessionStore(context, masterSecret).migrateSessions();
        new TextSecurePreKeyStore(context, masterSecret).migrateRecords();

        IdentityKeyUtil.migrateIdentityKeys(context, masterSecret);
        scheduleMessagesInPushDatabase(context);;
      }

      if (params[0] < CONTACTS_ACCOUNT_VERSION) {
        ApplicationContext.getInstance(getApplicationContext())
                          .getJobManager()
                          .add(new DirectoryRefreshJob(getApplicationContext()));
      }

      if (params[0] < MEDIA_DOWNLOAD_CONTROLS_VERSION) {
        schedulePendingIncomingParts(context);
      }

      if (params[0] < REDPHONE_SUPPORT_VERSION) {
        ApplicationContext.getInstance(getApplicationContext())
                          .getJobManager()
                          .add(new RefreshAttributesJob(getApplicationContext()));
        ApplicationContext.getInstance(getApplicationContext())
                          .getJobManager()
                          .add(new DirectoryRefreshJob(getApplicationContext()));
      }

//      if (params[0] < FINGERPRINTS_NON_BLOCKING_VESRION) {
//        TextSecurePreferences.setBlockingIdentityUpdates(getApplicationContext(), true);
//      }

      return null;
    }
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:76,代碼來源:DatabaseUpgradeActivity.java

示例3: onAlarm

import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob; //導入依賴的package包/類
@Override
protected long onAlarm(Context context, long scheduledTime) {
  if (scheduledTime != 0 && TextSecurePreferences.isPushRegistered(context)) {
    ApplicationContext.getInstance(context)
                      .getJobManager()
                      .add(new DirectoryRefreshJob(context));
  }

  long newTime = System.currentTimeMillis() + INTERVAL;
  TextSecurePreferences.setDirectoryRefreshTime(context, newTime);

  return newTime;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:14,代碼來源:DirectoryRefreshListener.java


注:本文中的org.thoughtcrime.securesms.jobs.DirectoryRefreshJob類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。