Skip to content

Commit

Permalink
Issue #322 background relogin and rerequest updates attempt added
Browse files Browse the repository at this point in the history
  • Loading branch information
yeriomin committed Nov 16, 2017
1 parent b680f79 commit 269cb39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@

import java.util.List;

public class BackgroundUpdatableAppsTask extends UpdatableAppsTask {
public class BackgroundUpdatableAppsTask extends UpdatableAppsTask implements CloneableTask {

private boolean forceUpdate = false;

public void setForceUpdate(boolean forceUpdate) {
this.forceUpdate = forceUpdate;
}

@Override
public CloneableTask clone() {
BackgroundUpdatableAppsTask task = new BackgroundUpdatableAppsTask();
task.setForceUpdate(forceUpdate);
task.setContext(context);
return task;
}

@Override
protected void onPostExecute(List<App> apps) {
super.onPostExecute(apps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.widget.TextView;

import com.github.yeriomin.playstoreapi.AuthException;
import com.github.yeriomin.playstoreapi.GooglePlayException;
import com.github.yeriomin.yalpstore.AccountTypeDialogBuilder;
import com.github.yeriomin.yalpstore.ContextUtil;
import com.github.yeriomin.yalpstore.CredentialsEmptyException;
Expand Down Expand Up @@ -74,15 +73,11 @@ protected void processIOException(IOException e) {
}

protected void processAuthException(AuthException e) {
if (!ContextUtil.isAlive(context)) {
Log.e(getClass().getName(), "AuthException happened and the provided context is not ui capable");
return;
}
AccountTypeDialogBuilder builder = new AccountTypeDialogBuilder(this.context);
builder.setCaller(this);
if (e instanceof CredentialsEmptyException) {
Log.i(getClass().getName(), "Credentials empty");
if (new FirstLaunchChecker(context).isFirstLogin()) {
if (new FirstLaunchChecker(context).isFirstLogin() && ContextUtil.isAlive(context)) {
Log.i(getClass().getName(), "First launch, so using built-in account");
builder.logInWithPredefinedAccount();
ContextUtil.toast(context, R.string.first_login_message);
Expand All @@ -97,7 +92,11 @@ protected void processAuthException(AuthException e) {
ContextUtil.toast(this.context, R.string.error_incorrect_password);
new PlayStoreApiAuthenticator(context).logout();
}
builder.show();
if (ContextUtil.isAlive(context)) {
builder.show();
} else {
Log.e(getClass().getName(), "AuthException happened and the provided context is not ui capable");
}
}

static protected boolean noNetwork(Throwable e) {
Expand Down

0 comments on commit 269cb39

Please sign in to comment.