use of com.odysee.app.tasks.wallet.DefaultSyncTaskHandler in project odysee-android by OdyseeTeam.
the class SignInActivity 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, "", SignInActivity.this, 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();
}*/
loadSharedUserStateAndFinish();
}
@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);
/*if (listener != null) {
listener.onWalletSyncWaitingForInput();
}*/
Helper.setViewVisibility(layoutWalletSyncInputArea, View.VISIBLE);
Helper.setViewVisibility(closeSignupSignIn, 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 SignInActivity 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;
/*if (listener != null) {
listener.onWalletSyncEnabled();
}*/
loadSharedUserStateAndFinish();
}
@Override
public void onSyncSetError(Exception error) {
showError(error.getMessage());
Helper.setViewVisibility(walletSyncProgress, View.GONE);
Helper.setViewText(textWalletSyncLoading, R.string.wallet_sync_op_failed);
Helper.setViewVisibility(closeSignupSignIn, View.VISIBLE);
/*if (listener != null) {
listener.onWalletSyncFailed(error);
}*/
walletSyncStarted = false;
}
});
setTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.wallet.DefaultSyncTaskHandler in project odysee-android by OdyseeTeam.
the class MainActivity method pushCurrentWalletSync.
public void pushCurrentWalletSync() {
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) {
SyncSetTask setTask = new SyncSetTask(Lbryio.lastRemoteHash, hash, data, null);
setTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@Override
public void onSyncApplyError(Exception error) {
}
});
fetchTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.wallet.DefaultSyncTaskHandler in project odysee-android by OdyseeTeam.
the class WalletVerificationFragment 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;
if (listener != null) {
listener.onWalletSyncEnabled();
}
}
@Override
public void onSyncSetError(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);
}
}
});
setTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.wallet.DefaultSyncTaskHandler in project odysee-android by OdyseeTeam.
the class SignInFragment method runWalletSync.
private void runWalletSync(String password) {
if (walletSyncStarted) {
return;
}
walletSyncStarted = true;
Helper.setViewVisibility(layoutCollect, View.GONE);
Helper.setViewVisibility(layoutVerify, View.GONE);
Helper.setViewVisibility(layoutWalletSyncContainer, View.VISIBLE);
Helper.setViewVisibility(walletSyncProgress, View.VISIBLE);
Helper.setViewVisibility(textWalletSyncLoading, View.VISIBLE);
password = Utils.getSecureValue(MainActivity.SECURE_VALUE_KEY_SAVED_PASSWORD, getContext(), Lbry.KEYSTORE);
if (Helper.isNullOrEmpty(password)) {
password = Helper.getValue(inputWalletSyncPassword.getText());
}
final String actual = password;
SyncGetTask task = new SyncGetTask(password, false, null, new DefaultSyncTaskHandler() {
@Override
public void onSyncGetSuccess(WalletSync walletSync) {
currentWalletSync = walletSync;
Lbryio.lastRemoteHash = walletSync.getHash();
if (Helper.isNullOrEmpty(actual)) {
processExistingWallet(walletSync);
} else {
processExistingWalletWithPassword(actual);
}
}
@Override
public void onSyncGetWalletNotFound() {
// no wallet found, get sync apply data and run the process
processNewWallet();
}
@Override
public void onSyncGetError(Exception error) {
// try again
Helper.setViewVisibility(walletSyncProgress, View.GONE);
// Helper.setViewText(textWalletSyncLoading, error.getMessage());
Helper.setViewVisibility(textWalletSyncLoading, View.GONE);
Helper.setViewVisibility(layoutWalletSyncInputArea, View.VISIBLE);
walletSyncStarted = false;
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations