本文整理匯總了Java中org.thoughtcrime.securesms.database.NotInDirectoryException類的典型用法代碼示例。如果您正苦於以下問題:Java NotInDirectoryException類的具體用法?Java NotInDirectoryException怎麽用?Java NotInDirectoryException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NotInDirectoryException類屬於org.thoughtcrime.securesms.database包,在下文中一共展示了NotInDirectoryException類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isPushDestination
import org.thoughtcrime.securesms.database.NotInDirectoryException; //導入依賴的package包/類
private static boolean isPushDestination(Context context, String destination) {
TextSecureDirectory directory = TextSecureDirectory.getInstance(context);
try {
return directory.isSecureTextSupported(destination);
} catch (NotInDirectoryException e) {
try {
SignalServiceAccountManager accountManager = AccountManagerFactory.createManager(context);
Optional<ContactTokenDetails> registeredUser = accountManager.getContact(destination);
if (!registeredUser.isPresent()) {
registeredUser = Optional.of(new ContactTokenDetails());
registeredUser.get().setNumber(destination);
directory.setNumber(registeredUser.get(), false);
return false;
} else {
registeredUser.get().setNumber(destination);
directory.setNumber(registeredUser.get(), true);
return true;
}
} catch (IOException e1) {
Log.w(TAG, e1);
return false;
}
}
}
示例2: isActiveInDirectory
import org.thoughtcrime.securesms.database.NotInDirectoryException; //導入依賴的package包/類
private static boolean isActiveInDirectory(Context context, Recipient recipient) {
try {
return TextSecureDirectory.getInstance(context)
.isSecureTextSupported(Util.canonicalizeNumber(context, recipient.getNumber()));
} catch (NotInDirectoryException | InvalidNumberException e) {
return false;
}
}
示例3: isPushDestination
import org.thoughtcrime.securesms.database.NotInDirectoryException; //導入依賴的package包/類
private static boolean isPushDestination(Context context, String destination) {
TextSecureDirectory directory = TextSecureDirectory.getInstance(context);
try {
return directory.isActiveNumber(destination);
} catch (NotInDirectoryException e) {
try {
TextSecureAccountManager accountManager = TextSecureCommunicationFactory.createManager(context);
String contactToken = DirectoryUtil.getDirectoryServerToken(destination);
Optional<ContactTokenDetails> registeredUser = accountManager.getContact(contactToken);
if (!registeredUser.isPresent()) {
registeredUser = Optional.of(new ContactTokenDetails());
registeredUser.get().setNumber(destination);
directory.setNumber(registeredUser.get(), false);
return false;
} else {
registeredUser.get().setNumber(destination);
directory.setNumber(registeredUser.get(), true);
return true;
}
} catch (IOException e1) {
Log.w(TAG, e1);
return false;
}
}
}