Search in sources :

Example 1 with RequestUserInfo

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);
}
Also used : StructListOfContact(net.iGap.module.structs.StructListOfContact) OnContactFetchForServer(net.iGap.observers.interfaces.OnContactFetchForServer) PackageManager(android.content.pm.PackageManager) MessageDigest(java.security.MessageDigest) AccountManager(net.iGap.module.accountManager.AccountManager) RequestUserLogin(net.iGap.request.RequestUserLogin) G(net.iGap.G) RealmPhoneContacts(net.iGap.realm.RealmPhoneContacts) RealmUserInfo(net.iGap.realm.RealmUserInfo) Manifest(android.Manifest) Gson(com.google.gson.Gson) RequestUserContactsGetBlockedList(net.iGap.request.RequestUserContactsGetBlockedList) RequestUserInfo(net.iGap.request.RequestUserInfo) ContextCompat(androidx.core.content.ContextCompat) Log(android.util.Log) HelperCheckInternetConnection(net.iGap.helper.HelperCheckInternetConnection) AsyncTask(android.os.AsyncTask) UserStatusController(net.iGap.helper.UserStatusController) RequestUserContactsGetList(net.iGap.request.RequestUserContactsGetList) RequestManager(net.iGap.network.RequestManager) List(java.util.List) G.firstEnter(net.iGap.G.firstEnter) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) DbManager(net.iGap.module.accountManager.DbManager) OnSecuring(net.iGap.observers.interfaces.OnSecuring) OnUserLogin(net.iGap.observers.interfaces.OnUserLogin) RealmUserInfo(net.iGap.realm.RealmUserInfo) RequestUserInfo(net.iGap.request.RequestUserInfo) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 2 with RequestUserInfo

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();
    }
}
Also used : RealmStoryProto(net.iGap.realm.RealmStoryProto) RequestUserInfo(net.iGap.request.RequestUserInfo) RealmStoryViewInfo(net.iGap.realm.RealmStoryViewInfo) CountDownLatch(java.util.concurrent.CountDownLatch) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo)

Example 3 with RequestUserInfo

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();
}
Also used : MutableLiveData(androidx.lifecycle.MutableLiveData) WebSocketClient(net.iGap.WebSocketClient) OnReceiveInfoLocation(net.iGap.observers.interfaces.OnReceiveInfoLocation) RequestInfoLocation(net.iGap.request.RequestInfoLocation) GoToMainFromRegister(net.iGap.model.GoToMainFromRegister) AccountManager(net.iGap.module.accountManager.AccountManager) TwoStepVerificationVerifyPassword(net.iGap.observers.interfaces.TwoStepVerificationVerifyPassword) ProtoUserVerify(net.iGap.proto.ProtoUserVerify) OnUserRegistration(net.iGap.observers.interfaces.OnUserRegistration) RequestUserLogin(net.iGap.request.RequestUserLogin) OnUserProfileSetRepresentative(net.iGap.observers.interfaces.OnUserProfileSetRepresentative) RequestUserProfileSetRepresentative(net.iGap.request.RequestUserProfileSetRepresentative) G(net.iGap.G) OnUserInfoResponse(net.iGap.observers.interfaces.OnUserInfoResponse) RealmUserInfo(net.iGap.realm.RealmUserInfo) LocationModel(net.iGap.model.LocationModel) Handler(android.os.Handler) TwoStepVerificationGetPasswordDetail(net.iGap.observers.interfaces.TwoStepVerificationGetPasswordDetail) RequestInfoPage(net.iGap.request.RequestInfoPage) OnUserVerification(net.iGap.observers.interfaces.OnUserVerification) RequestWrapper(net.iGap.request.RequestWrapper) RequestUserInfo(net.iGap.request.RequestUserInfo) Log(android.util.Log) RequestUserProfileSetNickname(net.iGap.request.RequestUserProfileSetNickname) UserPasswordDetail(net.iGap.model.UserPasswordDetail) ProtoUserRegister(net.iGap.proto.ProtoUserRegister) HelperTracker(net.iGap.helper.HelperTracker) BuildConfig(net.iGap.BuildConfig) SingleLiveEvent(net.iGap.module.SingleLiveEvent) RequestUserTwoStepVerificationGetPasswordDetail(net.iGap.request.RequestUserTwoStepVerificationGetPasswordDetail) BotInit(net.iGap.module.BotInit) RealmAvatar(net.iGap.realm.RealmAvatar) OnInfoCountryResponse(net.iGap.observers.interfaces.OnInfoCountryResponse) List(java.util.List) RequestInfoCountry(net.iGap.request.RequestInfoCountry) HelperString(net.iGap.helper.HelperString) ProtoGlobal(net.iGap.proto.ProtoGlobal) RequestQueue(net.iGap.request.RequestQueue) OnUserProfileSetNickNameResponse(net.iGap.observers.interfaces.OnUserProfileSetNickNameResponse) ProtoRequest(net.iGap.proto.ProtoRequest) RequestUserTwoStepVerificationVerifyPassword(net.iGap.request.RequestUserTwoStepVerificationVerifyPassword) NotNull(org.jetbrains.annotations.NotNull) DbManager(net.iGap.module.accountManager.DbManager) OnUserLogin(net.iGap.observers.interfaces.OnUserLogin) OnUserLogin(net.iGap.observers.interfaces.OnUserLogin)

Example 4 with RequestUserInfo

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);
}
Also used : RequestUserInfo(net.iGap.request.RequestUserInfo) ProtoUserContactsImport(net.iGap.proto.ProtoUserContactsImport) RequestUserContactsGetList(net.iGap.request.RequestUserContactsGetList)

Example 5 with RequestUserInfo

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());
}
Also used : ProtoPushUserInfoExpired(net.iGap.proto.ProtoPushUserInfoExpired) RequestUserInfo(net.iGap.request.RequestUserInfo)

Aggregations

RequestUserInfo (net.iGap.request.RequestUserInfo)19 ProtoGlobal (net.iGap.proto.ProtoGlobal)9 RealmRegisteredInfo (net.iGap.realm.RealmRegisteredInfo)9 G (net.iGap.G)7 DbManager (net.iGap.module.accountManager.DbManager)7 AccountManager (net.iGap.module.accountManager.AccountManager)6 Handler (android.os.Handler)5 Realm (io.realm.Realm)4 HelperString (net.iGap.helper.HelperString)4 OnComplete (net.iGap.observers.interfaces.OnComplete)4 Looper (android.os.Looper)3 Log (android.util.Log)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 OnUserInfoResponse (net.iGap.observers.interfaces.OnUserInfoResponse)3 RealmAvatar (net.iGap.realm.RealmAvatar)3 RealmRoom (net.iGap.realm.RealmRoom)3 Bitmap (android.graphics.Bitmap)2 BitmapFactory (android.graphics.BitmapFactory)2 AsyncTask (android.os.AsyncTask)2