use of com.odysee.app.tasks.wallet.DefaultSyncTaskHandler in project odysee-android by OdyseeTeam.
the class SignInFragment method createNewRemoteSync.
private void createNewRemoteSync(String hash, String data) {
SyncSetTask setTask = new SyncSetTask("", hash, data, new DefaultSyncTaskHandler() {
@Override
public void onSyncSetSuccess(String hash) {
Lbryio.lastRemoteHash = hash;
finishSignIn();
}
@Override
public void onSyncSetError(Exception error) {
showError(error.getMessage());
Helper.setViewVisibility(walletSyncProgress, View.GONE);
Helper.setViewText(textWalletSyncLoading, R.string.wallet_sync_op_failed);
walletSyncStarted = false;
}
});
setTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.wallet.DefaultSyncTaskHandler in project odysee-android by OdyseeTeam.
the class SignInFragment method processExistingWallet.
public void processExistingWallet(WalletSync walletSync) {
// Try first sync apply
SyncApplyTask applyTask = new SyncApplyTask("", walletSync.getData(), null, new DefaultSyncTaskHandler() {
@Override
public void onSyncApplySuccess(String hash, String data) {
// check if local and remote hash are different, and then run sync set
Utils.setSecureValue(MainActivity.SECURE_VALUE_KEY_SAVED_PASSWORD, "", getContext(), Lbry.KEYSTORE);
if (!hash.equalsIgnoreCase(Lbryio.lastRemoteHash) && !Helper.isNullOrEmpty(Lbryio.lastRemoteHash)) {
new SyncSetTask(Lbryio.lastRemoteHash, hash, data, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
finishSignIn();
}
@Override
public void onSyncApplyError(Exception error) {
// failed, request the user to enter a password
Helper.setViewVisibility(walletSyncProgress, View.GONE);
Helper.setViewVisibility(textWalletSyncLoading, View.GONE);
Helper.setViewVisibility(inputWalletSyncPassword, View.VISIBLE);
Helper.setViewVisibility(layoutWalletSyncInputArea, View.VISIBLE);
walletSyncStarted = false;
}
});
applyTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.wallet.DefaultSyncTaskHandler in project odysee-android by OdyseeTeam.
the class SignInFragment method processNewWallet.
public void processNewWallet() {
SyncApplyTask fetchTask = new SyncApplyTask(true, null, new DefaultSyncTaskHandler() {
@Override
public void onSyncApplySuccess(String hash, String data) {
createNewRemoteSync(hash, data);
}
@Override
public void onSyncApplyError(Exception error) {
showError(error.getMessage());
Helper.setViewVisibility(walletSyncProgress, View.GONE);
Helper.setViewText(textWalletSyncLoading, R.string.wallet_sync_op_failed);
walletSyncStarted = false;
}
});
fetchTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations