use of androidx.annotation.AnyThread in project Signal-Android by signalapp.
the class PaymentSendJob method enqueuePayment.
/**
* @param totalFee Total quoted totalFee to the user. This is expected to cover all defrags and the actual transaction.
*/
@AnyThread
@NonNull
public static UUID enqueuePayment(@Nullable RecipientId recipientId, @NonNull MobileCoinPublicAddress publicAddress, @NonNull String note, @NonNull Money amount, @NonNull Money totalFee) {
UUID uuid = UUID.randomUUID();
long timestamp = System.currentTimeMillis();
Job sendJob = new PaymentSendJob(new Parameters.Builder().setQueue(QUEUE).setMaxAttempts(1).build(), uuid, timestamp, recipientId, Objects.requireNonNull(publicAddress), note, amount, totalFee);
JobManager.Chain chain = ApplicationDependencies.getJobManager().startChain(sendJob).then(new PaymentTransactionCheckJob(uuid, QUEUE)).then(new MultiDeviceOutgoingPaymentSyncJob(uuid));
if (recipientId != null) {
chain.then(new PaymentNotificationSendJob(recipientId, uuid, recipientId.toQueueKey(true)));
}
chain.then(PaymentLedgerUpdateJob.updateLedgerToReflectPayment(uuid)).enqueue();
return uuid;
}
use of androidx.annotation.AnyThread in project nextcloud-notes by stefan-niedermann.
the class NotesRepository method modifyCategoryOrder.
/**
* Modifies the sorting method for one category, the category can be normal category or
* one of "All notes", "Favorite", and "Uncategorized".
* If category is one of these three, sorting method will be modified in android.content.SharedPreference.
* The user can determine use which sorting method to show the notes for a category.
* When the user changes the sorting method, this method should be called.
*
* @param accountId The user accountID
* @param selectedCategory The category to be modified
* @param sortingMethod The sorting method in {@link CategorySortingMethod} enum format
*/
@AnyThread
public void modifyCategoryOrder(long accountId, @NonNull NavigationCategory selectedCategory, @NonNull CategorySortingMethod sortingMethod) {
executor.submit(() -> {
final var ctx = context.getApplicationContext();
final var sp = PreferenceManager.getDefaultSharedPreferences(ctx).edit();
int orderIndex = sortingMethod.getId();
switch(selectedCategory.getType()) {
case FAVORITES:
{
sp.putInt(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.label_favorites), orderIndex);
break;
}
case UNCATEGORIZED:
{
sp.putInt(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.action_uncategorized), orderIndex);
break;
}
case RECENT:
{
sp.putInt(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.label_all_notes), orderIndex);
break;
}
case DEFAULT_CATEGORY:
default:
{
final String category = selectedCategory.getCategory();
if (category != null) {
if (db.getCategoryOptionsDao().modifyCategoryOrder(accountId, category, sortingMethod) == 0) {
// Nothing updated means we didn't have this yet
final var categoryOptions = new CategoryOptions();
categoryOptions.setAccountId(accountId);
categoryOptions.setCategory(category);
categoryOptions.setSortingMethod(sortingMethod);
db.getCategoryOptionsDao().addCategoryOptions(categoryOptions);
}
} else {
throw new IllegalStateException("Tried to modify category order for " + ENavigationCategoryType.DEFAULT_CATEGORY + "but category is null.");
}
break;
}
}
sp.apply();
});
}
Aggregations