use of com.odysee.app.tasks.wallet.SyncApplyTask in project odysee-android by OdyseeTeam.
the class WalletVerificationFragment 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);
}
if (listener != null) {
listener.onWalletSyncEnabled();
}
*/
}
@Override
public void onSyncApplyError(Exception error) {
// failed, request the user to enter a password
Helper.setViewVisibility(loading, View.GONE);
Helper.setViewVisibility(textLoading, View.GONE);
Helper.setViewVisibility(inputArea, View.VISIBLE);
if (listener != null) {
listener.onWalletSyncWaitingForInput();
}
}
});
applyTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.wallet.SyncApplyTask in project odysee-android by OdyseeTeam.
the class WalletVerificationFragment 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(loading, View.GONE);
Helper.setViewText(textLoading, R.string.wallet_sync_op_failed);
if (listener != null) {
listener.onWalletSyncFailed(error);
}
}
});
fetchTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.wallet.SyncApplyTask in project odysee-android by OdyseeTeam.
the class WalletVerificationFragment method processExistingWalletWithPassword.
public void processExistingWalletWithPassword(String password) {
Helper.setViewVisibility(loading, View.VISIBLE);
Helper.setViewVisibility(textLoading, View.VISIBLE);
Helper.setViewVisibility(inputArea, View.GONE);
if (currentWalletSync == null) {
showError(getString(R.string.wallet_sync_op_failed));
Helper.setViewText(textLoading, R.string.wallet_sync_op_failed);
return;
}
Helper.setViewText(textLoading, R.string.apply_wallet_data);
SyncApplyTask applyTask = new SyncApplyTask(password, currentWalletSync.getData(), null, new DefaultSyncTaskHandler() {
@Override
public void onSyncApplySuccess(String hash, String data) {
/*
Utils.setSecureValue(MainActivity.SECURE_VALUE_KEY_SAVED_PASSWORD, password, getContext(), Lbry.KEYSTORE);
// check if local and remote hash are different, and then run sync set
if (!hash.equalsIgnoreCase(Lbryio.lastRemoteHash) && !Helper.isNullOrEmpty(Lbryio.lastRemoteHash)) {
new SyncSetTask(Lbryio.lastRemoteHash, hash, data, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
if (listener != null) {
listener.onWalletSyncEnabled();
}
*/
}
@Override
public void onSyncApplyError(Exception error) {
// failed, request the user to enter a password
showError(error.getMessage());
Helper.setViewVisibility(loading, View.GONE);
Helper.setViewVisibility(textLoading, View.GONE);
Helper.setViewVisibility(inputArea, View.VISIBLE);
if (listener != null) {
listener.onWalletSyncWaitingForInput();
}
}
});
applyTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.wallet.SyncApplyTask in project odysee-android by OdyseeTeam.
the class MainActivity method syncApplyAndSet.
public void syncApplyAndSet() {
fullSyncInProgress = true;
String password = getSecureValue(SECURE_VALUE_KEY_SAVED_PASSWORD, this, Lbry.KEYSTORE);
SyncApplyTask fetchTask = new SyncApplyTask(true, password, new DefaultSyncTaskHandler() {
@Override
public void onSyncApplySuccess(String hash, String data) {
if (!hash.equalsIgnoreCase(Lbryio.lastRemoteHash)) {
syncSet(hash, data);
} else {
fullSyncInProgress = false;
queuedSyncCount = 0;
}
}
@Override
public void onSyncApplyError(Exception error) {
fullSyncInProgress = false;
if (queuedSyncCount > 0) {
queuedSyncCount--;
syncApplyAndSet();
}
}
});
fetchTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.wallet.SyncApplyTask in project odysee-android by OdyseeTeam.
the class SignInActivity method processExistingWalletWithPassword.
public void processExistingWalletWithPassword(String password) {
Helper.setViewVisibility(textWalletSyncLoading, View.VISIBLE);
Helper.setViewVisibility(inputWalletSyncPassword, View.GONE);
if (currentWalletSync == null) {
showError(getString(R.string.wallet_sync_op_failed));
Helper.setViewText(textWalletSyncLoading, R.string.wallet_sync_op_failed);
return;
}
Helper.setViewVisibility(walletSyncProgress, View.VISIBLE);
Helper.setViewText(textWalletSyncLoading, R.string.apply_wallet_data);
SyncApplyTask applyTask = new SyncApplyTask(password, currentWalletSync.getData(), null, new DefaultSyncTaskHandler() {
@Override
public void onSyncApplySuccess(String hash, String data) {
Utils.setSecureValue(MainActivity.SECURE_VALUE_KEY_SAVED_PASSWORD, password, SignInActivity.this, Lbry.KEYSTORE);
// check if local and remote hash are different, and then run sync set
if (!hash.equalsIgnoreCase(Lbryio.lastRemoteHash) && !Helper.isNullOrEmpty(Lbryio.lastRemoteHash)) {
new SyncSetTask(Lbryio.lastRemoteHash, hash, data, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
/*if (listener != null) {
listener.onWalletSyncEnabled();
}*/
loadSharedUserStateAndFinish();
}
@Override
public void onSyncApplyError(Exception error) {
// failed, request the user to enter a password
showError(error.getMessage());
Helper.setViewVisibility(walletSyncProgress, View.GONE);
Helper.setViewVisibility(textWalletSyncLoading, View.GONE);
Helper.setViewVisibility(inputWalletSyncPassword, View.VISIBLE);
Helper.setViewVisibility(layoutWalletSyncInputArea, View.VISIBLE);
Helper.setViewVisibility(closeSignupSignIn, View.VISIBLE);
walletSyncStarted = false;
}
});
applyTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations