本文整理匯總了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);
}
示例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;
}
示例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;
}