|
@@ -24,7 +24,6 @@ import android.content.pm.ActivityInfo;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.support.annotation.NonNull;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
@@ -39,22 +38,33 @@ import com.nextcloud.talk.R;
|
|
|
import com.nextcloud.talk.api.NcApi;
|
|
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
|
|
import com.nextcloud.talk.controllers.base.BaseController;
|
|
|
+import com.nextcloud.talk.events.EventStatus;
|
|
|
import com.nextcloud.talk.jobs.CapabilitiesJob;
|
|
|
import com.nextcloud.talk.jobs.PushRegistrationJob;
|
|
|
+import com.nextcloud.talk.models.database.UserEntity;
|
|
|
+import com.nextcloud.talk.models.json.generic.Status;
|
|
|
+import com.nextcloud.talk.models.json.rooms.RoomsOverall;
|
|
|
+import com.nextcloud.talk.models.json.userprofile.UserProfileOverall;
|
|
|
import com.nextcloud.talk.utils.ApiUtils;
|
|
|
import com.nextcloud.talk.utils.ApplicationWideMessageHolder;
|
|
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
|
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
|
|
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
|
|
|
|
|
+import org.greenrobot.eventbus.EventBus;
|
|
|
+import org.greenrobot.eventbus.Subscribe;
|
|
|
+import org.greenrobot.eventbus.ThreadMode;
|
|
|
+
|
|
|
import java.net.CookieManager;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
import autodagger.AutoInjector;
|
|
|
import butterknife.BindView;
|
|
|
import io.reactivex.CompletableObserver;
|
|
|
-import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
+import io.reactivex.Observer;
|
|
|
import io.reactivex.disposables.Disposable;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
@@ -76,13 +86,15 @@ public class AccountVerificationController extends BaseController {
|
|
|
@Inject
|
|
|
AppPreferences appPreferences;
|
|
|
|
|
|
+ @Inject
|
|
|
+ EventBus eventBus;
|
|
|
+
|
|
|
@BindView(R.id.progress_text)
|
|
|
TextView progressText;
|
|
|
|
|
|
- private Disposable roomsQueryDisposable;
|
|
|
- private Disposable profileQueryDisposable;
|
|
|
- private Disposable dbQueryDisposable;
|
|
|
- private Disposable statusQueryDisposable;
|
|
|
+ private long internalAccountId = -1;
|
|
|
+
|
|
|
+ private List<Disposable> disposables = new ArrayList<>();
|
|
|
|
|
|
private String baseUrl;
|
|
|
private String username;
|
|
@@ -105,6 +117,18 @@ public class AccountVerificationController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onAttach(@NonNull View view) {
|
|
|
+ super.onAttach(view);
|
|
|
+ eventBus.register(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDetach(@NonNull View view) {
|
|
|
+ super.onDetach(view);
|
|
|
+ eventBus.unregister(this);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
|
|
|
return inflater.inflate(R.layout.controller_account_verification, container, false);
|
|
@@ -123,8 +147,6 @@ public class AccountVerificationController extends BaseController {
|
|
|
getActionBar().hide();
|
|
|
}
|
|
|
|
|
|
- dispose(null);
|
|
|
-
|
|
|
if (isAccountImport && !baseUrl.startsWith("http://") && !baseUrl.startsWith("https://") || (!TextUtils
|
|
|
.isEmpty(originalProtocol) && !baseUrl.startsWith(originalProtocol))) {
|
|
|
determineBaseUrlProtocol(true);
|
|
@@ -134,6 +156,13 @@ public class AccountVerificationController extends BaseController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void checkEverything() {
|
|
|
+ String credentials = ApiUtils.getCredentials(username, token);
|
|
|
+ cookieManager.getCookieStore().removeAll();
|
|
|
+
|
|
|
+ findServerTalkApp(credentials);
|
|
|
+ }
|
|
|
+
|
|
|
private void determineBaseUrlProtocol(boolean checkForcedHttps) {
|
|
|
cookieManager.getCookieStore().removeAll();
|
|
|
|
|
@@ -147,155 +176,229 @@ public class AccountVerificationController extends BaseController {
|
|
|
queryUrl = "http://" + baseUrl + ApiUtils.getUrlPostfixForStatus();
|
|
|
}
|
|
|
|
|
|
- statusQueryDisposable = ncApi.getServerStatus(queryUrl)
|
|
|
+ ncApi.getServerStatus(queryUrl)
|
|
|
.subscribeOn(Schedulers.newThread())
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
- .subscribe(status -> {
|
|
|
- if (checkForcedHttps) {
|
|
|
- baseUrl = "https://" + baseUrl;
|
|
|
- } else {
|
|
|
- baseUrl = "http://" + baseUrl;
|
|
|
+ .subscribe(new Observer<Status>() {
|
|
|
+ @Override
|
|
|
+ public void onSubscribe(Disposable d) {
|
|
|
+ disposables.add(d);
|
|
|
}
|
|
|
|
|
|
- checkEverything();
|
|
|
- }, throwable -> {
|
|
|
- if (checkForcedHttps) {
|
|
|
- determineBaseUrlProtocol(false);
|
|
|
- } else {
|
|
|
+ @Override
|
|
|
+ public void onNext(Status status) {
|
|
|
+ if (checkForcedHttps) {
|
|
|
+ baseUrl = "https://" + baseUrl;
|
|
|
+ } else {
|
|
|
+ baseUrl = "http://" + baseUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ checkEverything();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable e) {
|
|
|
+ if (checkForcedHttps) {
|
|
|
+ determineBaseUrlProtocol(false);
|
|
|
+ } else {
|
|
|
+ abortVerification();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete() {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void findServerTalkApp(String credentials) {
|
|
|
+ ncApi.getRooms(credentials, ApiUtils.getUrlForGetRooms(baseUrl))
|
|
|
+ .subscribeOn(Schedulers.newThread())
|
|
|
+ .subscribe(new Observer<RoomsOverall>() {
|
|
|
+ @Override
|
|
|
+ public void onSubscribe(Disposable d) {
|
|
|
+ disposables.add(d);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(RoomsOverall roomsOverall) {
|
|
|
+ fetchProfile(credentials);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable e) {
|
|
|
+ if (getActivity() != null) {
|
|
|
+ getActivity().runOnUiThread(() -> progressText.setText(String.format(getResources().getString(
|
|
|
+ R.string.nc_nextcloud_talk_app_not_installed), getResources().getString(R.string.nc_app_name))));
|
|
|
+ }
|
|
|
+
|
|
|
+ ApplicationWideMessageHolder.getInstance().setMessageType(
|
|
|
+ ApplicationWideMessageHolder.MessageType.SERVER_WITHOUT_TALK);
|
|
|
+
|
|
|
abortVerification();
|
|
|
}
|
|
|
- }, () -> {
|
|
|
- statusQueryDisposable.dispose();
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete() {
|
|
|
+
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void checkEverything() {
|
|
|
- String credentials = ApiUtils.getCredentials(username, token);
|
|
|
- cookieManager.getCookieStore().removeAll();
|
|
|
+ private void storeProfile(String credentials, String displayName, String userId) {
|
|
|
+ userUtils.createOrUpdateUser(username, token,
|
|
|
+ baseUrl, displayName, null, true,
|
|
|
+ userId, null, null,
|
|
|
+ appPreferences.getTemporaryClientCertAlias())
|
|
|
+ .subscribeOn(Schedulers.newThread())
|
|
|
+ .subscribe(new Observer<UserEntity>() {
|
|
|
+ @Override
|
|
|
+ public void onSubscribe(Disposable d) {
|
|
|
+ disposables.add(d);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(UserEntity userEntity) {
|
|
|
+ internalAccountId = userEntity.getId();
|
|
|
+
|
|
|
+ registerForPush();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable e) {
|
|
|
+ progressText.setText(progressText.getText().toString() +
|
|
|
+ "\n" +
|
|
|
+ getResources().getString(
|
|
|
+ R.string.nc_display_name_not_stored));
|
|
|
+ abortVerification();
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- roomsQueryDisposable = ncApi.getRooms(credentials, ApiUtils.getUrlForGetRooms(baseUrl))
|
|
|
+ @Override
|
|
|
+ public void onComplete() {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fetchProfile(String credentials) {
|
|
|
+ ncApi.getUserProfile(credentials,
|
|
|
+ ApiUtils.getUrlForUserProfile(baseUrl))
|
|
|
.subscribeOn(Schedulers.newThread())
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
- .subscribe(roomsOverall -> {
|
|
|
- progressText.setText(String.format(getResources().getString(
|
|
|
- R.string.nc_nextcloud_talk_app_installed), getResources().getString(R.string.nc_app_name)));
|
|
|
-
|
|
|
- profileQueryDisposable = ncApi.getUserProfile(credentials,
|
|
|
- ApiUtils.getUrlForUserProfile(baseUrl))
|
|
|
- .subscribeOn(Schedulers.newThread())
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
- .subscribe(userProfileOverall -> {
|
|
|
- progressText.setText(progressText.getText().toString() + "\n" +
|
|
|
- getResources().getString(R.string.nc_display_name_fetched));
|
|
|
-
|
|
|
- String displayName = null;
|
|
|
- if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData()
|
|
|
- .getDisplayName())) {
|
|
|
- displayName = userProfileOverall.getOcs().getData()
|
|
|
- .getDisplayName();
|
|
|
- } else if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData()
|
|
|
- .getDisplayNameAlt())) {
|
|
|
- displayName = userProfileOverall.getOcs().getData()
|
|
|
- .getDisplayNameAlt();
|
|
|
- }
|
|
|
-
|
|
|
- if (!TextUtils.isEmpty(displayName)) {
|
|
|
- dbQueryDisposable = userUtils.createOrUpdateUser(username, token,
|
|
|
- baseUrl, displayName, null, true,
|
|
|
- userProfileOverall.getOcs().getData().getUserId(), null, null,
|
|
|
- appPreferences.getTemporaryClientCertAlias())
|
|
|
- .subscribeOn(Schedulers.newThread())
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
- .subscribe(userEntity -> {
|
|
|
- progressText.setText(progressText.getText().toString()
|
|
|
- + "\n" +
|
|
|
- getResources().getString(
|
|
|
- R.string.nc_display_name_stored));
|
|
|
-
|
|
|
- new JobRequest.Builder(PushRegistrationJob.TAG).
|
|
|
- setUpdateCurrent(true).startNow().build().schedule();
|
|
|
-
|
|
|
- PersistableBundleCompat persistableBundleCompat = new
|
|
|
- PersistableBundleCompat();
|
|
|
- persistableBundleCompat.putLong(BundleKeys
|
|
|
- .KEY_INTERNAL_USER_ID, userEntity.getId());
|
|
|
-
|
|
|
- new JobRequest.Builder(CapabilitiesJob.TAG).setUpdateCurrent
|
|
|
- (false).addExtras(persistableBundleCompat).startNow()
|
|
|
- .build().schedule();
|
|
|
-
|
|
|
- cookieManager.getCookieStore().removeAll();
|
|
|
- userUtils.disableAllUsersWithoutId(userEntity.getId());
|
|
|
-
|
|
|
- if (userUtils.getUsers().size() == 1) {
|
|
|
- getRouter().setRoot(RouterTransaction.with(new
|
|
|
- MagicBottomNavigationController())
|
|
|
- .pushChangeHandler(new HorizontalChangeHandler())
|
|
|
- .popChangeHandler(new HorizontalChangeHandler()));
|
|
|
- } else {
|
|
|
- if (isAccountImport) {
|
|
|
- ApplicationWideMessageHolder.getInstance().setMessageType(
|
|
|
- ApplicationWideMessageHolder.MessageType.ACCOUNT_WAS_IMPORTED);
|
|
|
- }
|
|
|
- getRouter().popToRoot();
|
|
|
- }
|
|
|
- },
|
|
|
- throwable -> {
|
|
|
- progressText.setText(progressText.getText().toString() +
|
|
|
- "\n" +
|
|
|
- getResources().getString(
|
|
|
- R.string.nc_display_name_not_stored));
|
|
|
- abortVerification();
|
|
|
- }, () -> dispose(dbQueryDisposable));
|
|
|
-
|
|
|
- } else {
|
|
|
- progressText.setText(progressText.getText().toString() + "\n" +
|
|
|
- getResources().getString(R.string.nc_display_name_not_fetched));
|
|
|
- abortVerification();
|
|
|
- }
|
|
|
- }, throwable -> {
|
|
|
- progressText.setText(progressText.getText().toString()
|
|
|
- + "\n" + getResources().getString(
|
|
|
- R.string.nc_display_name_not_fetched));
|
|
|
- abortVerification();
|
|
|
- }, () -> dispose(profileQueryDisposable));
|
|
|
-
|
|
|
- }, throwable -> {
|
|
|
- progressText.setText(String.format(getResources().getString(
|
|
|
- R.string.nc_nextcloud_talk_app_not_installed), getResources().getString(R.string.nc_app_name)));
|
|
|
- ApplicationWideMessageHolder.getInstance().setMessageType(
|
|
|
- ApplicationWideMessageHolder.MessageType.SERVER_WITHOUT_TALK);
|
|
|
-
|
|
|
- abortVerification();
|
|
|
- }, () -> dispose(roomsQueryDisposable));
|
|
|
+ .subscribe(new Observer<UserProfileOverall>() {
|
|
|
+ @Override
|
|
|
+ public void onSubscribe(Disposable d) {
|
|
|
+ disposables.add(d);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(UserProfileOverall userProfileOverall) {
|
|
|
+ String displayName = null;
|
|
|
+ if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData()
|
|
|
+ .getDisplayName())) {
|
|
|
+ displayName = userProfileOverall.getOcs().getData()
|
|
|
+ .getDisplayName();
|
|
|
+ } else if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData()
|
|
|
+ .getDisplayNameAlt())) {
|
|
|
+ displayName = userProfileOverall.getOcs().getData()
|
|
|
+ .getDisplayNameAlt();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!TextUtils.isEmpty(displayName)) {
|
|
|
+ storeProfile(credentials, displayName, userProfileOverall.getOcs().getData().getUserId());
|
|
|
+ } else {
|
|
|
+ if (getActivity() != null) {
|
|
|
+ getActivity().runOnUiThread(() -> progressText.setText(progressText.getText().toString() + "\n" +
|
|
|
+ getResources().getString(R.string.nc_display_name_not_fetched)));
|
|
|
+ }
|
|
|
+ abortVerification();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable e) {
|
|
|
+ if (getActivity() != null) {
|
|
|
+ getActivity().runOnUiThread(() -> progressText.setText(progressText.getText().toString() + "\n" +
|
|
|
+ getResources().getString(R.string.nc_display_name_not_fetched)));
|
|
|
+ }
|
|
|
+ abortVerification();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete() {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- private void dispose(@Nullable Disposable disposable) {
|
|
|
- if (disposable != null && !disposable.isDisposed()) {
|
|
|
- disposable.dispose();
|
|
|
- disposable = null;
|
|
|
- } else if (disposable == null) {
|
|
|
- if (roomsQueryDisposable != null && !roomsQueryDisposable.isDisposed()) {
|
|
|
- roomsQueryDisposable.dispose();
|
|
|
- roomsQueryDisposable = null;
|
|
|
- }
|
|
|
+ private void registerForPush() {
|
|
|
+ new JobRequest.Builder(PushRegistrationJob.TAG).
|
|
|
+ setUpdateCurrent(true).startNow().build().schedule();
|
|
|
+ }
|
|
|
|
|
|
- if (profileQueryDisposable != null && !profileQueryDisposable.isDisposed()) {
|
|
|
- profileQueryDisposable.dispose();
|
|
|
- profileQueryDisposable = null;
|
|
|
+ @Subscribe(threadMode = ThreadMode.BACKGROUND)
|
|
|
+ public void onMessageEvent(EventStatus eventStatus) {
|
|
|
+ if (eventStatus.getEventType().equals(EventStatus.EventType.PUSH_REGISTRATION)) {
|
|
|
+ if (internalAccountId == eventStatus.getUserId() && !eventStatus.isAllGood() && getActivity() != null) {
|
|
|
+ getActivity().runOnUiThread(() -> progressText.setText(progressText.getText().toString() + "\n" +
|
|
|
+ getResources().getString(R.string.nc_push_disabled)));
|
|
|
}
|
|
|
-
|
|
|
- if (dbQueryDisposable != null && !dbQueryDisposable.isDisposed()) {
|
|
|
- dbQueryDisposable.dispose();
|
|
|
- dbQueryDisposable = null;
|
|
|
+ fetchAndStoreCapabilities();
|
|
|
+ } else if (eventStatus.getEventType().equals(EventStatus.EventType.CAPABILITIES_FETCH)) {
|
|
|
+ if (internalAccountId == eventStatus.getUserId() && !eventStatus.isAllGood()) {
|
|
|
+ if (getActivity() != null) {
|
|
|
+ getActivity().runOnUiThread(() -> progressText.setText(progressText.getText().toString() + "\n" +
|
|
|
+ getResources().getString(R.string.nc_capabilities_failed)));
|
|
|
+ }
|
|
|
+ abortVerification();
|
|
|
+ } else if (internalAccountId == eventStatus.getUserId() && eventStatus.isAllGood()) {
|
|
|
+ proceedWithLogin();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (statusQueryDisposable != null && !statusQueryDisposable.isDisposed()) {
|
|
|
- statusQueryDisposable.dispose();
|
|
|
- statusQueryDisposable = null;
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fetchAndStoreCapabilities() {
|
|
|
+ PersistableBundleCompat persistableBundleCompat = new
|
|
|
+ PersistableBundleCompat();
|
|
|
+ persistableBundleCompat.putLong(BundleKeys
|
|
|
+ .KEY_INTERNAL_USER_ID, internalAccountId);
|
|
|
+
|
|
|
+ new JobRequest.Builder(CapabilitiesJob.TAG).setUpdateCurrent
|
|
|
+ (false).addExtras(persistableBundleCompat).startNow()
|
|
|
+ .build().scheduleAsync();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void proceedWithLogin() {
|
|
|
+ cookieManager.getCookieStore().removeAll();
|
|
|
+ userUtils.disableAllUsersWithoutId(internalAccountId);
|
|
|
+
|
|
|
+ if (getActivity() != null) {
|
|
|
+ getActivity().runOnUiThread(() -> {
|
|
|
+ if (userUtils.getUsers().size() == 1) {
|
|
|
+ getRouter().setRoot(RouterTransaction.with(new
|
|
|
+ MagicBottomNavigationController())
|
|
|
+ .pushChangeHandler(new HorizontalChangeHandler())
|
|
|
+ .popChangeHandler(new HorizontalChangeHandler()));
|
|
|
+ } else {
|
|
|
+ if (isAccountImport) {
|
|
|
+ ApplicationWideMessageHolder.getInstance().setMessageType(
|
|
|
+ ApplicationWideMessageHolder.MessageType.ACCOUNT_WAS_IMPORTED);
|
|
|
+ }
|
|
|
+ getRouter().popToRoot();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ private void dispose() {
|
|
|
+ for (int i = 0; i < disposables.size(); i++) {
|
|
|
+ if (!disposables.get(i).isDisposed()) {
|
|
|
+ disposables.get(i).dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -308,45 +411,70 @@ public class AccountVerificationController extends BaseController {
|
|
|
|
|
|
@Override
|
|
|
public void onDestroy() {
|
|
|
+ dispose();
|
|
|
super.onDestroy();
|
|
|
- dispose(null);
|
|
|
}
|
|
|
|
|
|
private void abortVerification() {
|
|
|
- dispose(null);
|
|
|
|
|
|
if (!isAccountImport) {
|
|
|
- userUtils.deleteUser(username, baseUrl).subscribe(new CompletableObserver() {
|
|
|
- @Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
+ if (internalAccountId != -1) {
|
|
|
+ userUtils.deleteUserWithId(internalAccountId).subscribe(new CompletableObserver() {
|
|
|
+ @Override
|
|
|
+ public void onSubscribe(Disposable d) {
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void onComplete() {
|
|
|
- new Handler().postDelayed(() -> getRouter().popToRoot(), 7500);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public void onComplete() {
|
|
|
+ if (getActivity() != null) {
|
|
|
+ getActivity().runOnUiThread(() -> {
|
|
|
+ new Handler().postDelayed(() -> getRouter().popToRoot(), 7500);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void onError(Throwable e) {
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable e) {
|
|
|
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (getActivity() != null) {
|
|
|
+ getActivity().runOnUiThread(() -> {
|
|
|
+ new Handler().postDelayed(() -> getRouter().popToRoot(), 7500);
|
|
|
+ });
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
} else {
|
|
|
ApplicationWideMessageHolder.getInstance().setMessageType(
|
|
|
ApplicationWideMessageHolder.MessageType.FAILED_TO_IMPORT_ACCOUNT);
|
|
|
new Handler().postDelayed(() -> {
|
|
|
if (getRouter().hasRootController()) {
|
|
|
- getRouter().popToRoot();
|
|
|
+ if (getActivity() != null) {
|
|
|
+ getActivity().runOnUiThread(() -> {
|
|
|
+ getRouter().popToRoot();
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
} else {
|
|
|
if (userUtils.anyUserExists()) {
|
|
|
- getRouter().setRoot(RouterTransaction.with(new MagicBottomNavigationController())
|
|
|
- .pushChangeHandler(new HorizontalChangeHandler())
|
|
|
- .popChangeHandler(new HorizontalChangeHandler()));
|
|
|
+ if (getActivity() != null) {
|
|
|
+ getActivity().runOnUiThread(() -> {
|
|
|
+
|
|
|
+ getRouter().setRoot(RouterTransaction.with(new MagicBottomNavigationController())
|
|
|
+ .pushChangeHandler(new HorizontalChangeHandler())
|
|
|
+ .popChangeHandler(new HorizontalChangeHandler()));
|
|
|
+ });
|
|
|
+ }
|
|
|
} else {
|
|
|
- getRouter().setRoot(RouterTransaction.with(new ServerSelectionController())
|
|
|
- .pushChangeHandler(new HorizontalChangeHandler())
|
|
|
- .popChangeHandler(new HorizontalChangeHandler()));
|
|
|
+ if (getActivity() != null) {
|
|
|
+ getActivity().runOnUiThread(() -> {
|
|
|
+ getRouter().setRoot(RouterTransaction.with(new ServerSelectionController())
|
|
|
+ .pushChangeHandler(new HorizontalChangeHandler())
|
|
|
+ .popChangeHandler(new HorizontalChangeHandler()));
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}, 7500);
|