Skip to content

Commit

Permalink
fix: endless cycle when there is no network
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Sep 12, 2019
1 parent 0658f6b commit 719c2d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions app/src/main/java/co/tinode/tindroid/ChatsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import android.view.ViewGroup;
import android.widget.Toast;

import java.io.IOException;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/co/tinode/tindroid/UiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ public void run(AccountManagerFuture<Bundle> future) {
final Tinode tinode = Cache.getTinode();
tinode.setAutoLoginToken(token);
tinode.connect(hostName, tls).getResult();
// This will throw if login was not successful.
ServerMessage msg = tinode.loginToken(token).getResult();
// Logged in successfully. Save refreshed token for future use.
accountManager.setAuthToken(account, Utils.TOKEN_TYPE, tinode.getAuthToken());
Expand Down Expand Up @@ -326,7 +327,7 @@ public void run(AccountManagerFuture<Bundle> future) {
}
}
}
if (launch != null) {
if (launch != null && !activity.getComponentName().equals(launch.getComponent())) {
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
activity.startActivity(launch);
activity.finish();
Expand Down

0 comments on commit 719c2d7

Please sign in to comment.