use of net.iGap.observers.interfaces.OnUserLogin in project iGap-Android by KianIranian-STDG.
the class RegisterRepository method userLogin.
public void userLogin(String token) {
G.onUserLogin = new OnUserLogin() {
@Override
public void onLogin() {
G.onUserLogin = null;
DbManager.getInstance().doRealmTask(realm -> {
AccountManager.getInstance().addNewUser(userId, phoneNumber);
realm.executeTransaction(realm1 -> RealmUserInfo.putOrUpdate(realm1, userId, userName, phoneNumber, token, authorHash));
BotInit.setCheckDrIgap(true);
if (newUser) {
goToWelcomePage.postValue(userId);
HelperTracker.sendTracker(HelperTracker.TRACKER_REGISTRATION_NEW_USER);
} else {
// get user info for set nick name and after from that go to ActivityMain
getUserInfo();
requestUserInfo();
HelperTracker.sendTracker(HelperTracker.TRACKER_REGISTRATION_USER);
}
});
}
@Override
public void onLoginError(int majorCode, int minorCode) {
if (majorCode == 5 && minorCode == 1) {
requestLogin();
}
}
};
requestLogin();
}
use of net.iGap.observers.interfaces.OnUserLogin in project iGap-Android by KianIranian-STDG.
the class LoginActions method login.
/**
* try login to server and do common actions
*/
public static void login() {
if (!G.ISRealmOK) {
return;
}
G.onUserLogin = new OnUserLogin() {
@Override
public void onLogin() {
G.handler.post(new Runnable() {
@Override
public void run() {
if (firstEnter) {
firstEnter = false;
new RequestUserContactsGetBlockedList().userContactsGetBlockedList();
importContact();
}
getUserInfo();
if (G.isAppInFg) {
UserStatusController.getInstance().setOnline();
}
if (AndroidUtils.isAppOnForeground(G.context)) {
GPSTracker.getGpsTrackerInstance().checkLocation();
}
// sendWaitingRequestWrappers();
HelperCheckInternetConnection.detectConnectionTypeForDownload();
}
});
}
@Override
public void onLoginError(int majorCode, int minorCode) {
}
};
if (RequestManager.getInstance(AccountManager.selectedAccount).isSecure()) {
DbManager.getInstance().doRealmTask(realm -> {
RealmUserInfo userInfo = realm.where(RealmUserInfo.class).findFirst();
if (!RequestManager.getInstance(AccountManager.selectedAccount).isUserLogin()) {
if (userInfo != null) {
if (userInfo.getUserRegistrationState()) {
Log.wtf(LoginActions.class.getName(), "LoginActions.login: RequestUserLogin().userLogin");
new RequestUserLogin().userLogin(userInfo.getToken());
} else {
Log.wtf(LoginActions.class.getName(), "LoginActions.login:getUserRegistrationState" + userInfo.getUserRegistrationState());
}
} else {
Log.wtf(LoginActions.class.getName(), "LoginActions.login:userInfo != null");
}
} else {
Log.wtf(LoginActions.class.getName(), "LoginActions.login:else");
}
});
} else {
login();
}
}
Aggregations