Search in sources :

Example 1 with PushUpdateTask

use of wannabit.io.cosmostaion.task.FetchTask.PushUpdateTask in project cosmostation-android by cosmostation.

the class BaseActivity method onDeleteAccount.

public void onDeleteAccount(long id) {
    new PushUpdateTask(getBaseApplication(), null, mAccount, getBaseDao().getFCMToken(), false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    try {
        CryptoHelper.deleteKey(getString(R.string.key_mnemonic) + getBaseDao().onSelectAccount("" + id).uuid);
    } catch (Exception e) {
    }
    try {
        CryptoHelper.deleteKey(getString(R.string.key_private) + getBaseDao().onSelectAccount("" + id).uuid);
    } catch (Exception e) {
    }
    getBaseDao().onDeleteAccount("" + id);
    getBaseDao().onSelectBalance(id);
    if (getBaseDao().onSelectAccounts().size() > 0) {
        if (mAccount.id.equals(id)) {
            getBaseDao().setLastUser(getBaseDao().onSelectAccounts().get(0).id);
            onStartMainActivity(0);
        } else {
            getBaseDao().setLastUser(mAccount.id);
            onStartMainActivity(0);
            return;
        }
    } else {
        getBaseDao().setLastUser(-1);
        Intent intent = new Intent(this, IntroActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(intent);
    }
    for (BaseChain baseChain : getBaseDao().dpSortedChains()) {
        int accountNum = getBaseDao().onSelectAccountsByChain(baseChain).size();
        if (accountNum > 0) {
            getBaseDao().setLastUser(getBaseDao().onSelectAccountsByChain(baseChain).get(0).id);
            break;
        }
    }
}
Also used : Intent(android.content.Intent) PushUpdateTask(wannabit.io.cosmostaion.task.FetchTask.PushUpdateTask) WriterException(com.google.zxing.WriterException)

Aggregations

Intent (android.content.Intent)1 WriterException (com.google.zxing.WriterException)1 PushUpdateTask (wannabit.io.cosmostaion.task.FetchTask.PushUpdateTask)1