use of net.iGap.request.RequestUserInfo in project iGap-Android by KianIranian-STDG.
the class LoginActions method getUserInfo.
private static void getUserInfo() {
final Long userId;
userId = DbManager.getInstance().doRealmTask(realm -> {
try {
RealmUserInfo realmUserInfo = realm.where(RealmUserInfo.class).findFirst();
if (realmUserInfo == null) {
throw new Exception("Empty Exception");
}
return realmUserInfo.getUserId();
} catch (Exception e) {
e.printStackTrace();
Log.wtf(LoginActions.class.getName(), "catch");
G.logoutAccount.postValue(true);
return null;
}
});
if (userId == null)
return;
new RequestUserInfo().userInfo(userId);
}
use of net.iGap.request.RequestUserInfo in project iGap-Android by KianIranian-STDG.
the class MessageDataStorage method updateOwnViews.
public void updateOwnViews(List<ProtoStoryGetOwnStoryViews.GroupedViews> groupedViews) {
CountDownLatch countdown = new CountDownLatch(1);
storageQueue.postRunnable(() -> {
try {
database.executeTransaction(realm -> {
int counter = 0;
for (int i = 0; i < groupedViews.size(); i++) {
// for (int j = 0; j < groupedViews.get(i).getStoryViewsList().size(); j++) {
// if (groupedViews.get(i).getStoryViewsList().get(j).getUserId() != AccountManager.getInstance().getCurrentUser().getId()) {
// counter++;
// }
// }
RealmStoryProto realmStoryProto = realm.where(RealmStoryProto.class).equalTo("isForReply", false).equalTo("storyId", groupedViews.get(i).getStoryId()).findFirst();
if (realmStoryProto != null) {
// realmStoryProto.setViewCount(counter);
boolean isExist = false;
for (int j = 0; j < groupedViews.get(i).getStoryViewsList().size(); j++) {
RealmRegisteredInfo realmRegisteredInfo = database.where(RealmRegisteredInfo.class).equalTo("id", groupedViews.get(i).getStoryViewsList().get(j).getUserId()).findFirst();
RealmStoryViewInfo realmStoryViewInfo;
realmStoryViewInfo = realm.where(RealmStoryViewInfo.class).equalTo("id", groupedViews.get(i).getStoryId()).equalTo("userId", groupedViews.get(i).getStoryViewsList().get(j).getUserId()).findFirst();
if (realmStoryViewInfo == null) {
realmStoryViewInfo = realm.createObject(RealmStoryViewInfo.class);
} else {
isExist = true;
}
if (realmRegisteredInfo == null) {
realmStoryViewInfo.setDisplayName("");
new RequestUserInfo().userInfo(groupedViews.get(i).getStoryViewsList().get(j).getUserId());
} else {
realmStoryViewInfo.setDisplayName(realmRegisteredInfo.getDisplayName());
realmStoryViewInfo.setProfileColor(realmRegisteredInfo.getColor());
}
realmStoryViewInfo.setId(groupedViews.get(i).getStoryId());
realmStoryViewInfo.setUserId(groupedViews.get(i).getStoryViewsList().get(j).getUserId());
realmStoryViewInfo.setCreatedTime(groupedViews.get(i).getStoryViewsList().get(j).getViewedAt());
if (isExist) {
realmStoryProto.getRealmStoryViewInfos().remove(realmStoryViewInfo);
}
realmStoryProto.getRealmStoryViewInfos().add(realmStoryViewInfo);
isExist = false;
}
}
counter = 0;
}
});
G.runOnUiThread(() -> getEventManager().postEvent(EventManager.STORY_VIEWS_FETCHED));
countdown.countDown();
} catch (Exception e) {
FileLog.e(e);
} finally {
countdown.countDown();
}
});
try {
countdown.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
use of net.iGap.request.RequestUserInfo 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.request.RequestUserInfo in project iGap-Android by KianIranian-STDG.
the class UserContactsImportResponse method handler.
@Override
public void handler() {
super.handler();
final ProtoUserContactsImport.UserContactsImportResponse.Builder builder = (ProtoUserContactsImport.UserContactsImportResponse.Builder) message;
boolean getContactList = true;
if (identity != null)
if (identity instanceof Boolean) {
getContactList = (Boolean) identity;
} else if (identity instanceof String) {
if (identity.equals(RequestUserContactImport.KEY)) {
new RequestUserInfo().contactImportWithCallBack(builder.getRegisteredContacts(0).getUserId());
}
}
if (G.onQueueSendContact != null) {
G.onQueueSendContact.sendContact();
} else {
Contacts.isSendingContactToServer = false;
}
if (getContactList) {
G.serverHashContact = G.localHashContact;
new RequestUserContactsGetList().userContactGetList();
}
MessageController.getInstance(AccountManager.selectedAccount).getStories(0);
}
use of net.iGap.request.RequestUserInfo in project iGap-Android by KianIranian-STDG.
the class PushUserInfoExpiredResponse method handler.
@Override
public void handler() {
super.handler();
ProtoPushUserInfoExpired.PushUserInfoExpiredResponse.Builder builder = (ProtoPushUserInfoExpired.PushUserInfoExpiredResponse.Builder) message;
new RequestUserInfo().userInfo(builder.getUserId(), RequestUserInfo.InfoType.UPDATE_ROOM.toString());
}
Aggregations