Skip to content

Commit

Permalink
ADD: cancelable check credentials progress dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
darodriguez1994 committed Jan 13, 2019
1 parent 3ef0762 commit 0fa4796
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ void startProxyFromHelpDialog(@NonNull String user, @NonNull String pass, @NonNu
@NonNull String localPort, @NonNull boolean rememberPass,
@NonNull boolean setGlobalProxy, @NonNull boolean dontShowAgain);

void stopCredentialCheckTask();

void stopProxy();

void onDestroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,16 @@ public void startWifiConfActivity() {
public void showProgressDialog(boolean show) {
if (show) {
mProgressDialog.setMessage(getString(R.string.proxy_credentials_check_message));
mProgressDialog.setCancelable(false);
mProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
mPresenter.stopCredentialCheckTask();
}
});
mProgressDialog.show();
}
else {
mProgressDialog.setOnDismissListener(null);
mProgressDialog.dismiss();
}
}
Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/uci/localproxy/proxyscreen/ProxyPresenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class ProxyPresenter implements ProxyContract.Presenter {
@NonNull
private AppPreferencesHelper mPrefHelper;

private CredentialsCheckTask credentialsCheckTask;


public ProxyPresenter(@NonNull ProxyContract.View proxyView,
@NonNull AppPreferencesHelper prefHelper) {
Expand Down Expand Up @@ -137,7 +139,7 @@ public void onProfileLoaded(Profile profile) {
user = username.substring(backSlashPos + 1, username.length());
}

CredentialsCheckTask task = new CredentialsCheckTask(
credentialsCheckTask = new CredentialsCheckTask(
user,
password,
profile.getHost(),
Expand All @@ -148,7 +150,7 @@ public void onProfileLoaded(Profile profile) {
setGlobalProxy
);

task.execute();
credentialsCheckTask.execute();

}

Expand All @@ -159,6 +161,13 @@ public void onDataNoAvailable() {
});
}

@Override
public void stopCredentialCheckTask() {
if (credentialsCheckTask != null){
credentialsCheckTask.cancel(true);
}
}

@Override
public void stopProxy() {
mProxyView.stopProxyService();
Expand Down

0 comments on commit 0fa4796

Please sign in to comment.