Search in sources :

Example 1 with RequestUserContactsGetBlockedList

use of net.iGap.request.RequestUserContactsGetBlockedList in project iGap-Android by KianIranian-STDG.

the class FragmentPrivacyAndSecurity method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    privacyAndSecurityToolbar = new Toolbar(getContext());
    privacyAndSecurityToolbar.setBackIcon(new BackDrawable(false));
    privacyAndSecurityToolbar.setTitle(getString(R.string.st_title_Privacy_Security));
    privacyAndSecurityToolbar.setListener(i -> {
        switch(i) {
            case -1:
                popBackStackFragment();
                break;
        }
    });
    fragmentPrivacyAndSecurityBinding.fpsLayoutToolbar.addView(privacyAndSecurityToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
    new RequestUserContactsGetBlockedList().userContactsGetBlockedList();
    RealmPrivacy.getUpdatePrivacyFromServer();
    fragmentPrivacyAndSecurityBinding.parentPrivacySecurity.setOnClickListener(view1 -> {
    });
    new RequestUserProfileGetSelfRemove().userProfileGetSelfRemove();
    fragmentPrivacyAndSecurityViewModel.goToBlockedUserPage.observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentBlockedUser()).setReplace(false).load();
        }
    });
    fragmentPrivacyAndSecurityViewModel.goToPassCodePage.observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentPassCode()).setReplace(false).load();
        }
    });
    fragmentPrivacyAndSecurityViewModel.goToSecurityPage.observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentSecurity()).setReplace(false).load();
        }
    });
    fragmentPrivacyAndSecurityViewModel.goToActiveSessionsPage.observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentActiveSessions()).setReplace(false).load();
        }
    });
}
Also used : RequestUserProfileGetSelfRemove(net.iGap.request.RequestUserProfileGetSelfRemove) RequestUserContactsGetBlockedList(net.iGap.request.RequestUserContactsGetBlockedList) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) HelperFragment(net.iGap.helper.HelperFragment) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 2 with RequestUserContactsGetBlockedList

use of net.iGap.request.RequestUserContactsGetBlockedList 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();
    }
}
Also used : RealmUserInfo(net.iGap.realm.RealmUserInfo) RequestUserLogin(net.iGap.request.RequestUserLogin) RequestUserContactsGetBlockedList(net.iGap.request.RequestUserContactsGetBlockedList) OnUserLogin(net.iGap.observers.interfaces.OnUserLogin)

Aggregations

RequestUserContactsGetBlockedList (net.iGap.request.RequestUserContactsGetBlockedList)2 HelperFragment (net.iGap.helper.HelperFragment)1 BackDrawable (net.iGap.messenger.ui.toolBar.BackDrawable)1 Toolbar (net.iGap.messenger.ui.toolBar.Toolbar)1 OnUserLogin (net.iGap.observers.interfaces.OnUserLogin)1 RealmUserInfo (net.iGap.realm.RealmUserInfo)1 RequestUserLogin (net.iGap.request.RequestUserLogin)1 RequestUserProfileGetSelfRemove (net.iGap.request.RequestUserProfileGetSelfRemove)1