Search in sources :

Example 1 with RealmContacts

use of net.iGap.realm.RealmContacts in project iGap-Android by KianIranian-STDG.

the class FragmentContactsProfileViewModel method mainStart.

private void mainStart() {
    if (enterFrom.equals(ProtoGlobal.Room.Type.GROUP.toString()) || roomId == 0) {
        RealmRoom realmRoom = DbManager.getInstance().doRealmTask(realm -> {
            return realm.where(RealmRoom.class).equalTo("chatRoom.peer_id", userId).findFirst();
        });
        if (realmRoom != null) {
            shearedId = realmRoom.getId();
        }
    } else {
        shearedId = roomId;
    }
    if (!RealmRoom.isNotificationServices(roomId)) {
        isShowReportView.set(true);
    } else {
        isShowReportView.set(false);
    }
    if (userId == AccountManager.getInstance().getCurrentUser().getId()) {
        cloudVisibility.postValue(true);
    } else
        cloudVisibility.postValue(false);
    registeredInfo = DbManager.getInstance().doRealmTask(realm -> {
        return RealmRegisteredInfo.getRegistrationInfo(realm, userId);
    });
    if (registeredInfo != null) {
        registeredInfo.addChangeListener((RealmObjectChangeListener<RealmRegisteredInfo>) (realmModel, changeSet) -> {
            if (changeSet != null) {
                for (int i = 0; i < changeSet.getChangedFields().length; i++) {
                    if (changeSet.getChangedFields()[i].equals("blockUser")) {
                        userBlockState.set(realmModel.isBlockUser() ? R.string.un_block_user : R.string.block);
                    }
                }
            }
        });
        isBot = registeredInfo.isBot();
        if (isBot || userId == AccountManager.getInstance().getCurrentUser().getId()) {
            callVisibility.setValue(View.GONE);
            menuVisibility.setValue(View.GONE);
            videoCallVisibility.setValue(View.GONE);
        } else {
            callVisibility.setValue(View.VISIBLE);
            menuVisibility.setValue(View.VISIBLE);
            videoCallVisibility.setValue(View.VISIBLE);
        }
        isBlockUser = registeredInfo.isBlockUser();
        userBlockState.set(isBlockUser ? R.string.un_block_user : R.string.block);
        registeredInfo.addChangeListener(element -> isBlockUser = registeredInfo.isBlockUser());
        DbManager.getInstance().doRealmTask(realm -> {
            if (registeredInfo.getLastAvatar(realm) != null) {
                String mainFilePath = registeredInfo.getLastAvatar(realm).getFile().getLocalFilePath();
                if (mainFilePath != null && new File(mainFilePath).exists()) {
                    // if main image is exist showing that
                    avatarPath = mainFilePath;
                } else {
                    avatarPath = registeredInfo.getLastAvatar(realm).getFile().getLocalThumbnailPath();
                }
                avatarList = registeredInfo.getAvatars(realm);
            }
        });
    }
    RealmContacts realmUser = DbManager.getInstance().doRealmTask(realm -> {
        return realm.where(RealmContacts.class).equalTo("id", userId).findFirst();
    });
    if (registeredInfo != null) {
        if (registeredInfo.getDisplayName() != null && !registeredInfo.getDisplayName().equals("")) {
            contactName.setValue(registeredInfo.getDisplayName());
        } else {
            contactName.setValue(G.fragmentActivity.getResources().getString(R.string.nick_name_not_exist));
        }
        if (registeredInfo.getBio() == null || registeredInfo.getBio().length() == 0) {
            bioVisibility.set(View.GONE);
        } else {
            bioVisibility.set(View.VISIBLE);
            bio.set(registeredInfo.getBio());
        }
        username.set(registeredInfo.getUsername());
        phone.set(registeredInfo.getPhoneNumber());
        phoneNumber = "+" + registeredInfo.getPhoneNumber();
        firstName = registeredInfo.getFirstName();
        lastName = registeredInfo.getLastName();
        lastSeenValue = registeredInfo.getLastSeen();
        color = registeredInfo.getColor();
        initials = registeredInfo.getInitials();
        userStatus = registeredInfo.getStatus();
        isVerified = registeredInfo.isVerified();
    } else if (realmUser != null) {
        if (realmUser.getDisplay_name() != null && !realmUser.getDisplay_name().equals("")) {
            contactName.setValue(realmUser.getDisplay_name());
        } else {
            contactName.setValue(G.fragmentActivity.getResources().getString(R.string.nick_name_not_exist));
        }
        username.set(realmUser.getUsername());
        phone.set(Long.toString(realmUser.getPhone()));
        phoneNumber = "+" + realmUser.getPhone();
        firstName = realmUser.getFirst_name();
        lastName = realmUser.getLast_name();
        lastSeenValue = realmUser.getLast_seen();
        color = realmUser.getColor();
        initials = realmUser.getInitials();
        isVerified = realmUser.isVerified();
        if (realmUser.getBio() == null || realmUser.getBio().length() == 0) {
            bioVisibility.set(View.GONE);
        } else {
            bioVisibility.set(View.VISIBLE);
            bio.set(realmUser.getBio());
        }
    }
    if (isVerified) {
        verifyTextVisibility.set(View.VISIBLE);
    } else {
        verifyTextVisibility.set(View.INVISIBLE);
    }
    // todo: fixed it two times check it and first and her
    if (userId != 134 && AccountManager.getInstance().getCurrentUser().getId() != userId) {
        RealmCallConfig callConfig = DbManager.getInstance().doRealmTask(realm -> {
            return realm.where(RealmCallConfig.class).findFirst();
        });
        if (callConfig != null) {
            if (isBot) {
                callVisibility.setValue(View.GONE);
                videoCallVisibility.setValue(View.GONE);
            } else {
                if (callConfig.isVoice_calling()) {
                    callVisibility.setValue(View.VISIBLE);
                }
                if (callConfig.isVideo_calling()) {
                    videoCallVisibility.setValue(View.VISIBLE);
                }
            }
        } else {
            new RequestSignalingGetConfiguration().signalingGetConfiguration();
        }
    } else {
        callVisibility.setValue(View.GONE);
        videoCallVisibility.setValue(View.GONE);
    }
    RealmContacts realmContacts = DbManager.getInstance().doRealmTask(realm -> {
        return realm.where(RealmContacts.class).equalTo("phone", Long.parseLong(phone.get())).findFirst();
    });
    /**
     * if this user isn't in my contacts don't show phone number
     */
    if (realmContacts == null && enterFrom.equals(ProtoGlobal.Room.Type.GROUP.toString())) {
        showNumber.set(false);
        disableDeleteContact = true;
        menuVisibility.setValue(View.GONE);
    }
    if (!G.isAppRtl) {
        textsGravity.set(Gravity.LEFT);
    } else {
        textsGravity.set(Gravity.RIGHT);
    }
    setUserStatus(userStatus, lastSeenValue);
    setAvatar.setValue(userId != AccountManager.getInstance().getCurrentUser().getId());
    // todo: change it
    FragmentShearedMedia.getCountOfSharedMedia(shearedId);
    if (registeredInfo == null) {
        callVisibility.setValue(View.GONE);
        menuVisibility.setValue(View.GONE);
        videoCallVisibility.setValue(View.GONE);
    }
}
Also used : MutableLiveData(androidx.lifecycle.MutableLiveData) OnUserContactDelete(net.iGap.observers.interfaces.OnUserContactDelete) RealmChangeListener(io.realm.RealmChangeListener) AppUtils(net.iGap.module.AppUtils) RealmList(io.realm.RealmList) ObservableField(androidx.databinding.ObservableField) AccountManager(net.iGap.module.accountManager.AccountManager) ViewModel(androidx.lifecycle.ViewModel) LastSeenTimeUtil(net.iGap.module.LastSeenTimeUtil) RequestSignalingGetConfiguration(net.iGap.request.RequestSignalingGetConfiguration) G(net.iGap.G) RealmContacts(net.iGap.realm.RealmContacts) ArrayList(java.util.ArrayList) OnUserInfoResponse(net.iGap.observers.interfaces.OnUserInfoResponse) View(android.view.View) ObservableBoolean(androidx.databinding.ObservableBoolean) OnUserContactEdit(net.iGap.observers.interfaces.OnUserContactEdit) RequestUserInfo(net.iGap.request.RequestUserInfo) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) GoToSharedMediaModel(net.iGap.model.GoToSharedMediaModel) HelperCalander(net.iGap.helper.HelperCalander) RealmModel(io.realm.RealmModel) RealmObjectChangeListener(io.realm.RealmObjectChangeListener) RealmRoom(net.iGap.realm.RealmRoom) RequestUserContactsDelete(net.iGap.request.RequestUserContactsDelete) File(java.io.File) OnUserUpdateStatus(net.iGap.observers.interfaces.OnUserUpdateStatus) RealmAvatar(net.iGap.realm.RealmAvatar) Gravity(android.view.Gravity) List(java.util.List) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) ProtoGlobal(net.iGap.proto.ProtoGlobal) FragmentShearedMedia(net.iGap.fragments.FragmentShearedMedia) ObservableInt(androidx.databinding.ObservableInt) R(net.iGap.R) DbManager(net.iGap.module.accountManager.DbManager) RequestChatGetRoom(net.iGap.request.RequestChatGetRoom) RealmCallConfig(net.iGap.realm.RealmCallConfig) RealmCallConfig(net.iGap.realm.RealmCallConfig) RealmRoom(net.iGap.realm.RealmRoom) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) File(java.io.File) RequestSignalingGetConfiguration(net.iGap.request.RequestSignalingGetConfiguration) RealmContacts(net.iGap.realm.RealmContacts)

Example 2 with RealmContacts

use of net.iGap.realm.RealmContacts in project iGap-Android by KianIranian-STDG.

the class FragmentSyncRegisteredContacts method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    G.onPhoneContact = this;
    G.onContactsGetList = this;
    Contacts.localPhoneContactId = 0;
    Contacts.getContact = true;
    userID = this.getArguments().getLong(ARG_USER_ID);
    // Toolbar Initial
    LinearLayout toolbarLayout = view.findViewById(R.id.frg_contact_ll_toolbar_layout);
    mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setSearchBoxShown(true).setLogoShown(true).setDefaultTitle(getString(R.string.str_frag_sync_contactWelcome));
    toolbarLayout.addView(mHelperToolbar.getView());
    mHelperToolbar.setListener(this);
    prgWaiting = view.findViewById(R.id.prgWaiting_addContact);
    AppUtils.setProgresColler(prgWaiting);
    Bundle bundle = this.getArguments();
    String title = null;
    if (bundle != null) {
        title = bundle.getString("TITLE");
        isCallAction = bundle.getBoolean("ACTION");
    }
    // My Code H.Amini
    // ContactUtils.syncContacts();
    realmRecyclerView = view.findViewById(R.id.recycler_view);
    realmRecyclerView.setItemViewCacheSize(1000);
    realmRecyclerView.setItemAnimator(null);
    layoutManager = new LinearLayoutManager(realmRecyclerView.getContext());
    realmRecyclerView.setLayoutManager(layoutManager);
    // get all the contacts from realm
    results = DbManager.getInstance().doRealmTask(realm -> {
        return realm.where(RealmContacts.class).findAll().sort("display_name");
    });
    results.addChangeListener(new RealmChangeListener<RealmResults<RealmContacts>>() {

        @Override
        public void onChange(@NotNull RealmResults<RealmContacts> realmContacts) {
            if (realmContacts.size() > 0) {
                fastScroller.setVisibility(View.VISIBLE);
            }
            contactListAdapter2.notifyDataSetChanged();
        }
    });
    // Load all of the data
    // contactListAdapter = new FragmentSyncRegisteredContacts.ContactListAdapter(results);
    contactListAdapter2 = new ContactListAdapter2(results);
    // realmRecyclerView.setAdapter(contactListAdapter);
    realmRecyclerView.setAdapter(contactListAdapter2);
    realmRecyclerView.setVisibility(View.VISIBLE);
    realmRecyclerView.setLayoutManager(new ScrollingLinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false, 1000));
    realmRecyclerView.setNestedScrollingEnabled(false);
    fastScroller = view.findViewById(R.id.fast_scroller);
    fastScroller.setRecyclerView(realmRecyclerView);
    fastScroller.setVisibility(View.GONE);
    // going to app directly
    skipBtn = view.findViewById(R.id.frag_sync_skipbtn);
    skipBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (getActivity() != null) {
                Intent intent = new Intent(getActivity(), ActivityMain.class);
                intent.putExtra(ARG_USER_ID, userID);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getActivity().startActivity(intent);
                getActivity().finish();
            }
        }
    });
    /*FragmentSyncRegisteredContacts.StickyHeader stickyHeader = new FragmentSyncRegisteredContacts.StickyHeader(results);
        decoration = new StickyRecyclerHeadersDecoration(stickyHeader);
        realmRecyclerView.addItemDecoration(decoration);*/
    onCliclRecyclerView = new FragmentSyncRegisteredContacts.onClickRecyclerView() {

        @Override
        public void onClick(View view, int position) {
            if (isMultiSelect) {
            }
        }
    };
    // get permission for contacts
    try {
        if (getPermission) {
            getPermission = false;
            HelperPermission.getContactPermision(G.fragmentActivity, new OnGetPermission() {

                @Override
                public void Allow() throws IOException {
                    /**
                     * if contacts size is zero send request for get contacts list
                     * for insuring that contacts not exist really or not
                     */
                    if (results.size() == 0) {
                        LoginActions.importContact();
                    }
                }

                @Override
                public void deny() {
                    /*if (results.size() == 0) {
                            new RequestUserContactsGetList().userContactGetList();
                        }*/
                    if (getActivity() == null || getActivity().isFinishing()) {
                        return;
                    }
                    Intent intent = new Intent(getContext(), ActivityMain.class);
                    intent.putExtra(ARG_USER_ID, userID);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    G.context.startActivity(intent);
                    G.fragmentActivity.finish();
                }
            });
        } else {
            if (results.size() == 0) {
                new RequestUserContactsGetList().userContactGetList();
            } else {
                hideProgress();
            }
        /*if (HelperPermission.grantedContactPermission()) {
                    new Contacts.FetchContactForClient().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                } else {
                    hideProgress();
                }*/
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) AppUtils(net.iGap.module.AppUtils) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ProgressBar(android.widget.ProgressBar) LastSeenTimeUtil(net.iGap.module.LastSeenTimeUtil) G(net.iGap.G) FragmentSyncRegisteredContactsBinding(net.iGap.databinding.FragmentSyncRegisteredContactsBinding) HelperPublicMethod(net.iGap.helper.HelperPublicMethod) LoginActions(net.iGap.module.LoginActions) FastScrollerBarBaseAdapter(net.iGap.module.scrollbar.FastScrollerBarBaseAdapter) HelperPermission(net.iGap.helper.HelperPermission) View(android.view.View) Button(android.widget.Button) HelperError(net.iGap.helper.HelperError) RecyclerView(androidx.recyclerview.widget.RecyclerView) DataBindingUtil(androidx.databinding.DataBindingUtil) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) OnPhoneContact(net.iGap.observers.interfaces.OnPhoneContact) AsyncTask(android.os.AsyncTask) ContactManager(net.iGap.helper.ContactManager) ProtoSignalingOffer(net.iGap.proto.ProtoSignalingOffer) RequestUserContactsGetList(net.iGap.request.RequestUserContactsGetList) ViewGroup(android.view.ViewGroup) DefaultRoundDialog(net.iGap.module.dialog.DefaultRoundDialog) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout) ScrollingLinearLayoutManager(net.iGap.module.ScrollingLinearLayoutManager) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Case(io.realm.Case) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) NotNull(org.jetbrains.annotations.NotNull) HelperToolbar(net.iGap.helper.HelperToolbar) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) RealmChangeListener(io.realm.RealmChangeListener) StructListOfContact(net.iGap.module.structs.StructListOfContact) ActivityMain(net.iGap.activities.ActivityMain) AccountManager(net.iGap.module.accountManager.AccountManager) Intent(android.content.Intent) RealmContacts(net.iGap.realm.RealmContacts) ArrayList(java.util.ArrayList) Contacts(net.iGap.module.Contacts) OnContactsGetList(net.iGap.observers.interfaces.OnContactsGetList) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) LayoutInflater(android.view.LayoutInflater) RealmResults(io.realm.RealmResults) CheckBox(net.iGap.module.customView.CheckBox) IOException(java.io.IOException) CircleImageView(net.iGap.module.CircleImageView) Gravity(android.view.Gravity) FastScroller(net.iGap.module.scrollbar.FastScroller) R(net.iGap.R) DbManager(net.iGap.module.accountManager.DbManager) Bundle(android.os.Bundle) ScrollingLinearLayoutManager(net.iGap.module.ScrollingLinearLayoutManager) Intent(android.content.Intent) IOException(java.io.IOException) ScrollingLinearLayoutManager(net.iGap.module.ScrollingLinearLayoutManager) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) CircleImageView(net.iGap.module.CircleImageView) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) ActivityMain(net.iGap.activities.ActivityMain) RequestUserContactsGetList(net.iGap.request.RequestUserContactsGetList) LinearLayout(android.widget.LinearLayout) RealmContacts(net.iGap.realm.RealmContacts) RealmResults(io.realm.RealmResults)

Example 3 with RealmContacts

use of net.iGap.realm.RealmContacts in project iGap-Android by KianIranian-STDG.

the class FragmentChat method itemAdapterBottomSheetForward.

private void itemAdapterBottomSheetForward() {
    String[] fieldNames = { "isPinned", "pinId", "updatedTime" };
    Sort[] sort = { Sort.DESCENDING, Sort.DESCENDING, Sort.DESCENDING };
    results = DbManager.getInstance().doRealmTask(realm -> {
        return realm.where(RealmRoom.class).equalTo("keepRoom", false).equalTo("isDeleted", false).equalTo("readOnly", false).findAll().sort(fieldNames, sort);
    });
    resultsContact = DbManager.getInstance().doRealmTask(realm -> {
        return realm.where(RealmContacts.class).findAll().sort("display_name");
    });
    List<Long> te = new ArrayList<>();
    te.add(chatPeerId);
    long identifier = 100L;
    for (RealmRoom r : results) {
        StructBottomSheetForward item = new StructBottomSheetForward();
        item.setId(r.getId());
        if (r.getType() == ProtoGlobal.Room.Type.CHAT) {
            te.add(r.getChatRoom().getPeerId());
        }
        item.setDisplayName(r.getTitle());
        if (r.getChatRoom() != null)
            item.setPeer_id(r.getChatRoom().getPeerId());
        item.setType(r.getType());
        item.setContactList(false);
        item.setNotExistRoom(false);
        identifier = identifier + 1;
        if (r.getChatRoom() != null && r.getChatRoom().getPeerId() > 0 && r.getChatRoom().getPeerId() == userId) {
            fastItemAdapterForward.add(0, new ItemBottomSheetForward(item, avatarHandler).withIdentifier(identifier));
        } else {
            fastItemAdapterForward.add(new ItemBottomSheetForward(item, avatarHandler).withIdentifier(identifier));
        }
    }
    for (RealmContacts r : resultsContact) {
        if (!te.contains(r.getId())) {
            StructBottomSheetForward item = new StructBottomSheetForward();
            item.setId(r.getId());
            item.setDisplayName(r.getDisplay_name());
            item.setContactList(true);
            item.setNotExistRoom(true);
            identifier = identifier + 1;
            fastItemAdapterForward.add(new ItemBottomSheetForward(item, avatarHandler).withIdentifier(identifier));
        }
    }
    G.handler.postDelayed(new Runnable() {

        @Override
        public void run() {
            if (isAdded()) {
                bottomSheetDialogForward.show();
            }
        }
    }, 100);
}
Also used : ThumbnailUtils(android.media.ThumbnailUtils) Bundle(android.os.Bundle) HelperNotification(net.iGap.helper.HelperNotification) StructBottomSheetForward(net.iGap.module.structs.StructBottomSheetForward) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) FileLog(net.iGap.helper.FileLog) UploadObject(net.iGap.module.upload.UploadObject) IMAGE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE_VALUE) ToolbarItem(net.iGap.messenger.ui.toolBar.ToolbarItem) AppCompatCheckBox(androidx.appcompat.widget.AppCompatCheckBox) NewChatItemHolder(net.iGap.adapter.items.chat.NewChatItemHolder) GroupChatRole(net.iGap.module.enums.GroupChatRole) HelperSetAction(net.iGap.helper.HelperSetAction) OnBotClick(net.iGap.observers.interfaces.OnBotClick) Handler(android.os.Handler) MediaStore(android.provider.MediaStore) Map(java.util.Map) OnChatSendMessageResponse(net.iGap.observers.interfaces.OnChatSendMessageResponse) ClipboardManager(android.content.ClipboardManager) CallActivity(net.iGap.activities.CallActivity) HelperError(net.iGap.helper.HelperError) DOWN(net.iGap.proto.ProtoClientGetRoomHistory.ClientGetRoomHistory.Direction.DOWN) GIF_TEXT(net.iGap.proto.ProtoGlobal.RoomMessageType.GIF_TEXT) RequestClientSubscribeToRoom(net.iGap.request.RequestClientSubscribeToRoom) ContextCompat(androidx.core.content.ContextCompat) HelperFragment(net.iGap.helper.HelperFragment) Log(android.util.Log) R.id.ac_ll_parent(net.iGap.R.id.ac_ll_parent) Realm(io.realm.Realm) HelperCalander(net.iGap.helper.HelperCalander) NumberTextView(net.iGap.messenger.ui.toolBar.NumberTextView) RealmObjectChangeListener(io.realm.RealmObjectChangeListener) RealmRoom(net.iGap.realm.RealmRoom) CHAT(net.iGap.proto.ProtoGlobal.Room.Type.CHAT) VIDEO(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO) CHANNEL(net.iGap.proto.ProtoGlobal.Room.Type.CHANNEL) SoundPool(android.media.SoundPool) CountDownLatch(java.util.concurrent.CountDownLatch) RequestChatUpdateDraft(net.iGap.request.RequestChatUpdateDraft) OnHelperSetAction(net.iGap.observers.interfaces.OnHelperSetAction) AttachFile.getFilePathFromUri(net.iGap.module.AttachFile.getFilePathFromUri) CLIPBOARD_SERVICE(android.content.Context.CLIPBOARD_SERVICE) RequestChatGetRoom(net.iGap.request.RequestChatGetRoom) RealmCallConfig(net.iGap.realm.RealmCallConfig) SuggestedStickerAdapter(net.iGap.fragments.emoji.SuggestedStickerAdapter) ActivityMain(net.iGap.activities.ActivityMain) BottomSheetBehavior(com.google.android.material.bottomsheet.BottomSheetBehavior) HelperUrl(net.iGap.helper.HelperUrl) AccountManager(net.iGap.module.accountManager.AccountManager) ChatAttachmentPopup(net.iGap.module.dialog.ChatAttachmentPopup) RealmContacts(net.iGap.realm.RealmContacts) ParamWithInitBitmap(net.iGap.helper.avatar.ParamWithInitBitmap) Calendar(java.util.Calendar) WebSettings(android.webkit.WebSettings) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) Toast(android.widget.Toast) ImageLoadingServiceInjector(net.iGap.module.imageLoaderService.ImageLoadingServiceInjector) IMAGE_TEXT(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE_TEXT) AudioItem(net.iGap.adapter.items.chat.AudioItem) RealmRoomAccess(net.iGap.realm.RealmRoomAccess) MessageObject(net.iGap.structs.MessageObject) VideoWithTextItem(net.iGap.adapter.items.chat.VideoWithTextItem) G.twoPaneMode(net.iGap.G.twoPaneMode) AppCompatDelegate(androidx.appcompat.app.AppCompatDelegate) AttachFile.request_code_VIDEO_CAPTURED(net.iGap.module.AttachFile.request_code_VIDEO_CAPTURED) IOException(java.io.IOException) FragmentMediaContainer(net.iGap.messenger.ui.components.FragmentMediaContainer) IResendMessage(net.iGap.observers.interfaces.IResendMessage) EventEditText(net.iGap.module.customView.EventEditText) SharedPreferences(android.content.SharedPreferences) AUDIO_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO_VALUE) HelperMimeType(net.iGap.helper.HelperMimeType) RoomObject(net.iGap.helper.RoomObject) NotifyFrameLayout(net.iGap.libs.emojiKeyboard.NotifyFrameLayout) EditText(android.widget.EditText) FileListerDialog(net.iGap.module.FileListerDialog.FileListerDialog) RequestUserContactsBlock(net.iGap.request.RequestUserContactsBlock) ISendPosition(net.iGap.observers.interfaces.ISendPosition) BottomSheetDialog(com.google.android.material.bottomsheet.BottomSheetDialog) JsonObject(com.google.gson.JsonObject) LinearLayout(android.widget.LinearLayout) RequestClientUnsubscribeFromRoom(net.iGap.request.RequestClientUnsubscribeFromRoom) AppUtils(net.iGap.module.AppUtils) PackageManager(android.content.pm.PackageManager) WindowManager(android.view.WindowManager) StickerDialogFragment(net.iGap.fragments.emoji.add.StickerDialogFragment) Animator(android.animation.Animator) Theme(net.iGap.module.Theme) GIF_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.GIF_VALUE) G(net.iGap.G) StatusTextFragment(net.iGap.story.StatusTextFragment) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) RequestClientGetRoomHistory(net.iGap.request.RequestClientGetRoomHistory) IntentRequests(net.iGap.module.IntentRequests) RealmUserInfo(net.iGap.realm.RealmUserInfo) ACTION_STATE_SWIPE(androidx.recyclerview.widget.ItemTouchHelper.ACTION_STATE_SWIPE) ContentResolver(android.content.ContentResolver) UnreadMessage(net.iGap.adapter.items.chat.UnreadMessage) HelperPermission(net.iGap.helper.HelperPermission) IMessageItem(net.iGap.observers.interfaces.IMessageItem) Gson(com.google.gson.Gson) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) RecyclerView(androidx.recyclerview.widget.RecyclerView) RealmString(net.iGap.realm.RealmString) HelperImageBackColor(net.iGap.helper.HelperImageBackColor) VIDEO_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO_VALUE) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) UP(net.iGap.proto.ProtoClientGetRoomHistory.ClientGetRoomHistory.Direction.UP) ProgressWaiting(net.iGap.adapter.items.chat.ProgressWaiting) VIDEO_TEXT(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO_TEXT) MessageController(net.iGap.controllers.MessageController) Status(net.iGap.module.downloader.Status) ProtoChannelGetMessagesStats(net.iGap.proto.ProtoChannelGetMessagesStats) ItemBottomSheetForward(net.iGap.adapter.items.ItemBottomSheetForward) DisplayMetrics(android.util.DisplayMetrics) GIF_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.GIF_TEXT_VALUE) STORY_REPLY_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.STORY_REPLY_VALUE) OnClientGetRoomMessage(net.iGap.observers.interfaces.OnClientGetRoomMessage) Disposable(io.reactivex.disposables.Disposable) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) MusicPlayer(net.iGap.module.MusicPlayer) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) StickerRepository(net.iGap.repository.StickerRepository) ActivityTrimVideo(net.iGap.activities.ActivityTrimVideo) LocationManager(android.location.LocationManager) EditorInfo(android.view.inputmethod.EditorInfo) IOnBackPressed(net.iGap.observers.interfaces.IOnBackPressed) RealmRoomMessageLocation(net.iGap.realm.RealmRoomMessageLocation) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) ActivityManager(android.app.ActivityManager) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) CallManager(net.iGap.viewmodel.controllers.CallManager) HelperGetMessageState(net.iGap.helper.HelperGetMessageState) OnVoiceRecord(net.iGap.observers.interfaces.OnVoiceRecord) RealmList(io.realm.RealmList) RequestClientGetFavoriteMenu(net.iGap.request.RequestClientGetFavoriteMenu) RealmRoomMessage.makeUnreadMessage(net.iGap.realm.RealmRoomMessage.makeUnreadMessage) TimeUtils(net.iGap.module.TimeUtils) AudioManager(android.media.AudioManager) InputMethodManager(android.view.inputmethod.InputMethodManager) FragmentActivity(androidx.fragment.app.FragmentActivity) AnimationUtils(android.view.animation.AnimationUtils) HelperCalander.convertToUnicodeFarsiNumber(net.iGap.helper.HelperCalander.convertToUnicodeFarsiNumber) RequestUserContactsUnblock(net.iGap.request.RequestUserContactsUnblock) MODE_PRIVATE(android.content.Context.MODE_PRIVATE) Build(android.os.Build) RequestUserInfo(net.iGap.request.RequestUserInfo) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView) RequestChannelUpdateDraft(net.iGap.request.RequestChannelUpdateDraft) RealmAdditional(net.iGap.realm.RealmAdditional) JsonSyntaxException(com.google.gson.JsonSyntaxException) LayoutInflater(android.view.LayoutInflater) BadgeView(net.iGap.adapter.items.chat.BadgeView) RealmResults(io.realm.RealmResults) DialogAction(com.afollestad.materialdialogs.DialogAction) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) IDispatchTochEvent(net.iGap.observers.interfaces.IDispatchTochEvent) Color(android.graphics.Color) CountDownTimer(android.os.CountDownTimer) FileItem(net.iGap.adapter.items.chat.FileItem) StructMessageOption(net.iGap.module.structs.StructMessageOption) Bitmap(android.graphics.Bitmap) HelperSaveFile(net.iGap.helper.HelperSaveFile) STICKER_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.STICKER_VALUE) ViewTreeObserver(android.view.ViewTreeObserver) VIDEO_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO_TEXT_VALUE) VOICE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VOICE_VALUE) R(net.iGap.R) OnConnectionChangeStateChat(net.iGap.observers.interfaces.OnConnectionChangeStateChat) ProtoClientGetRoomHistory(net.iGap.proto.ProtoClientGetRoomHistory) StickerItem(net.iGap.adapter.items.chat.StickerItem) SHOW(net.iGap.module.enums.ProgressState.SHOW) Vibrator(android.os.Vibrator) Activity(android.app.Activity) FastItemAdapter(com.mikepenz.fastadapter.commons.adapters.FastItemAdapter) Arrays(java.util.Arrays) MyLinearLayoutManager(net.iGap.module.MyLinearLayoutManager) RequestClientJoinByUsername(net.iGap.request.RequestClientJoinByUsername) VoiceRecord(net.iGap.module.VoiceRecord) ProtoFileDownload(net.iGap.proto.ProtoFileDownload) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) LastSeenTimeUtil(net.iGap.module.LastSeenTimeUtil) Drawable(android.graphics.drawable.Drawable) Manifest(android.Manifest) ProtoClientRoomReport(net.iGap.proto.ProtoClientRoomReport) AdditionalType(net.iGap.module.additionalData.AdditionalType) HelperPermission.showDeniedPermissionMessage(net.iGap.helper.HelperPermission.showDeniedPermissionMessage) Looper(android.os.Looper) DialogAnimation(net.iGap.module.DialogAnimation) Fragment(androidx.fragment.app.Fragment) OnSetAction(net.iGap.observers.interfaces.OnSetAction) Canvas(android.graphics.Canvas) ProgressState(net.iGap.module.enums.ProgressState) RealmConstants(net.iGap.realm.RealmConstants) CardView(androidx.cardview.widget.CardView) OnDeleteChatFinishActivity(net.iGap.observers.interfaces.OnDeleteChatFinishActivity) HelperTracker(net.iGap.helper.HelperTracker) RequestGroupUpdateDraft(net.iGap.request.RequestGroupUpdateDraft) OnLastSeenUpdateTiming(net.iGap.observers.interfaces.OnLastSeenUpdateTiming) OnComplete(net.iGap.observers.interfaces.OnComplete) RealmRoomDraft(net.iGap.realm.RealmRoomDraft) WALLET_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.WALLET_VALUE) Set(java.util.Set) ChatSendMessageUtil(net.iGap.module.ChatSendMessageUtil) ChatMoreItem(net.iGap.model.ChatMoreItem) BotInit(net.iGap.module.BotInit) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) RealmGroupRoom(net.iGap.realm.RealmGroupRoom) Uploader(net.iGap.module.upload.Uploader) StringRes(androidx.annotation.StringRes) JsonArray(com.google.gson.JsonArray) FontIconTextView(net.iGap.module.FontIconTextView) Nullable(androidx.annotation.Nullable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) HIDE(net.iGap.module.enums.ProgressState.HIDE) Tuple(net.iGap.libs.Tuple) OnGroupAvatarResponse(net.iGap.observers.interfaces.OnGroupAvatarResponse) SHP_SETTING(net.iGap.module.SHP_SETTING) Sort(io.realm.Sort) MyWebViewClient(net.iGap.libs.MyWebViewClient) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) VoiceItem(net.iGap.adapter.items.chat.VoiceItem) InputFilter(android.text.InputFilter) EventManager(net.iGap.observers.eventbus.EventManager) DownloadObject(net.iGap.module.downloader.DownloadObject) TextWatcher(android.text.TextWatcher) OnMessageReceive(net.iGap.observers.interfaces.OnMessageReceive) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) Config(net.iGap.Config) AttachmentObject(net.iGap.structs.AttachmentObject) StoryViewFragment(net.iGap.story.viewPager.StoryViewFragment) AttachFile.request_code_pic_audi(net.iGap.module.AttachFile.request_code_pic_audi) ImageSpan(android.text.style.ImageSpan) Environment(android.os.Environment) RequestClientGetRoomMessage(net.iGap.request.RequestClientGetRoomMessage) OnChatMessageRemove(net.iGap.observers.interfaces.OnChatMessageRemove) Editable(android.text.Editable) LOCATION_SERVICE(android.content.Context.LOCATION_SERVICE) ArrayList(java.util.ArrayList) VibrationEffect(android.os.VibrationEffect) LOCATION_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.LOCATION_VALUE) RealmChannelExtra(net.iGap.realm.RealmChannelExtra) ConnectionState(net.iGap.module.enums.ConnectionState) HelperGetAction(net.iGap.helper.HelperGetAction) LayoutCreator(net.iGap.helper.LayoutCreator) IMAGE_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE_TEXT_VALUE) WebChromeClient(android.webkit.WebChromeClient) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) LogWallet(net.iGap.adapter.items.chat.LogWallet) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) RESULT_CANCELED(android.app.Activity.RESULT_CANCELED) StructWebView(net.iGap.module.structs.StructWebView) StickerSettingFragment(net.iGap.fragments.emoji.remove.StickerSettingFragment) AnimatedStickerItem(net.iGap.adapter.items.chat.AnimatedStickerItem) OnChatEditMessageResponse(net.iGap.observers.interfaces.OnChatEditMessageResponse) File(java.io.File) IItemAdapter(com.mikepenz.fastadapter.IItemAdapter) Gravity(android.view.Gravity) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) Configuration(android.content.res.Configuration) LocationListener(net.iGap.observers.interfaces.LocationListener) LocationItem(net.iGap.adapter.items.chat.LocationItem) DbManager(net.iGap.module.accountManager.DbManager) CardToCardItem(net.iGap.adapter.items.chat.CardToCardItem) ValueAnimator(android.animation.ValueAnimator) FILE_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.FILE_TEXT_VALUE) ImageHelper(net.iGap.helper.ImageHelper) AttachFile.request_code_pic_file(net.iGap.module.AttachFile.request_code_pic_file) IMAGE(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE) RealmRoomMessage.makeSeenAllMessageOfRoom(net.iGap.realm.RealmRoomMessage.makeSeenAllMessageOfRoom) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) ResendMessage(net.iGap.module.ResendMessage) AttachFile(net.iGap.module.AttachFile) LOG_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.LOG_VALUE) LogWalletCardToCard(net.iGap.adapter.items.chat.LogWalletCardToCard) OnGetFavoriteMenu(net.iGap.observers.interfaces.OnGetFavoriteMenu) RealmChannelRoom(net.iGap.realm.RealmChannelRoom) AUDIO_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO_TEXT_VALUE) ContactItem(net.iGap.adapter.items.chat.ContactItem) LISTENED_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageStatus.LISTENED_VALUE) BottomSheetFragment(net.iGap.module.dialog.bottomsheet.BottomSheetFragment) View(android.view.View) Animation(android.view.animation.Animation) WebView(android.webkit.WebView) OnChatMessageSelectionChanged(net.iGap.observers.interfaces.OnChatMessageSelectionChanged) RealmRoomMessageContact(net.iGap.realm.RealmRoomMessageContact) StoryPagerFragment(net.iGap.story.StoryPagerFragment) ContactUtils(net.iGap.module.ContactUtils) ParentChatMoneyTransferFragment(net.iGap.fragments.chatMoneyTransfer.ParentChatMoneyTransferFragment) MessagesAdapter(net.iGap.adapter.MessagesAdapter) FILE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.FILE_VALUE) AdapterDrBot(net.iGap.adapter.AdapterDrBot) OnUpdateUserOrRoomInfo(net.iGap.observers.interfaces.OnUpdateUserOrRoomInfo) RequestClientRoomReport(net.iGap.request.RequestClientRoomReport) HelperGetDataFromOtherApp(net.iGap.helper.HelperGetDataFromOtherApp) ObjectAnimator(android.animation.ObjectAnimator) PassCode(net.iGap.model.PassCode) StructMessageInfo(net.iGap.module.structs.StructMessageInfo) InputType(android.text.InputType) StructIGStickerGroup(net.iGap.fragments.emoji.struct.StructIGStickerGroup) ViewStubCompat(androidx.appcompat.widget.ViewStubCompat) Additional(net.iGap.module.enums.Additional) TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.TEXT_VALUE) LogWalletTopup(net.iGap.adapter.items.chat.LogWalletTopup) ViewGroup(android.view.ViewGroup) OnForwardBottomSheet(net.iGap.observers.interfaces.OnForwardBottomSheet) OnUserUpdateStatus(net.iGap.observers.interfaces.OnUserUpdateStatus) HelperLog(net.iGap.helper.HelperLog) OnChatSendMessage(net.iGap.observers.interfaces.OnChatSendMessage) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) TextView(android.widget.TextView) FragmentSettingAddStickers(net.iGap.fragments.emoji.add.FragmentSettingAddStickers) CONTACT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.CONTACT_VALUE) RequestQueue(net.iGap.request.RequestQueue) RelativeLayout(android.widget.RelativeLayout) TextItem(net.iGap.adapter.items.chat.TextItem) IUpdateLogItem(net.iGap.observers.interfaces.IUpdateLogItem) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) NotNull(org.jetbrains.annotations.NotNull) OpenBottomSheetItem(net.iGap.observers.interfaces.OpenBottomSheetItem) Context(android.content.Context) AndroidUtils(net.iGap.module.AndroidUtils) SEEN_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageStatus.SEEN_VALUE) KeyEvent(android.view.KeyEvent) ResourcesCompat(androidx.core.content.res.ResourcesCompat) GifWithTextItem(net.iGap.adapter.items.chat.GifWithTextItem) RequestSignalingGetConfiguration(net.iGap.request.RequestSignalingGetConfiguration) OnChatDelete(net.iGap.observers.interfaces.OnChatDelete) Intent(android.content.Intent) HashMap(java.util.HashMap) RealmStickerItem(net.iGap.realm.RealmStickerItem) SUID(net.iGap.module.SUID) ClipData(android.content.ClipData) OnUserInfoResponse(net.iGap.observers.interfaces.OnUserInfoResponse) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) AnimatorSet(android.animation.AnimatorSet) TimeItem(net.iGap.adapter.items.chat.TimeItem) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) Cursor(android.database.Cursor) LogWalletBill(net.iGap.adapter.items.chat.LogWalletBill) ACTIVITY_SERVICE(android.content.Context.ACTIVITY_SERVICE) CONTACT(net.iGap.proto.ProtoGlobal.RoomMessageType.CONTACT) ToolbarItems(net.iGap.messenger.ui.toolBar.ToolbarItems) FileWriter(java.io.FileWriter) ProtoResponse(net.iGap.proto.ProtoResponse) MessageLoader(net.iGap.module.MessageLoader) LogItem(net.iGap.adapter.items.chat.LogItem) HelperString(net.iGap.helper.HelperString) ViewMaker(net.iGap.adapter.items.chat.ViewMaker) StructBottomSheet(net.iGap.module.structs.StructBottomSheet) OnFileSelectedListener(net.iGap.module.FileListerDialog.OnFileSelectedListener) ProtoGlobal(net.iGap.proto.ProtoGlobal) ImageWithTextItem(net.iGap.adapter.items.chat.ImageWithTextItem) ChannelChatRole(net.iGap.module.enums.ChannelChatRole) GROUP(net.iGap.proto.ProtoGlobal.Room.Type.GROUP) Collections(java.util.Collections) MimeTypeMap(android.webkit.MimeTypeMap) AbstractMessage(net.iGap.adapter.items.chat.AbstractMessage) RealmAttachment(net.iGap.realm.RealmAttachment) RealmQuery(io.realm.RealmQuery) ArrayList(java.util.ArrayList) RealmString(net.iGap.realm.RealmString) HelperString(net.iGap.helper.HelperString) StructBottomSheetForward(net.iGap.module.structs.StructBottomSheetForward) ItemBottomSheetForward(net.iGap.adapter.items.ItemBottomSheetForward) Sort(io.realm.Sort) RealmRoom(net.iGap.realm.RealmRoom) RealmContacts(net.iGap.realm.RealmContacts)

Example 4 with RealmContacts

use of net.iGap.realm.RealmContacts in project iGap-Android by KianIranian-STDG.

the class FragmentChat method showSpamBar.

/**
 * manage need showSpamBar for user or no
 */
private void showSpamBar() {
    RealmRegisteredInfo realmRegisteredInfo = DbManager.getInstance().doRealmTask(realm -> {
        return RealmRegisteredInfo.getRegistrationInfo(realm, chatPeerId);
    });
    RealmContacts realmContacts = DbManager.getInstance().doRealmTask(realm -> {
        return realm.where(RealmContacts.class).equalTo("id", chatPeerId).findFirst();
    });
    if (realmRegisteredInfo != null && realmRegisteredInfo.getId() != AccountManager.getInstance().getCurrentUser().getId()) {
        if (phoneNumber == null) {
            if (realmContacts == null && chatType == CHAT && !isChatReadOnly) {
                initSpamBarLayout(realmRegisteredInfo);
                vgSpamUser.setVisibility(View.VISIBLE);
            }
        }
        if (realmRegisteredInfo.getId() != AccountManager.getInstance().getCurrentUser().getId()) {
            if (!realmRegisteredInfo.getDoNotshowSpamBar()) {
                if (realmRegisteredInfo.isBlockUser()) {
                    initSpamBarLayout(realmRegisteredInfo);
                    blockUser = true;
                    txtSpamUser.setText(G.fragmentActivity.getResources().getString(R.string.un_block_user));
                    vgSpamUser.setVisibility(View.VISIBLE);
                } else {
                    if (vgSpamUser != null) {
                        vgSpamUser.setVisibility(View.GONE);
                    }
                }
            }
        }
        if (realmContacts != null && realmRegisteredInfo.getId() != AccountManager.getInstance().getCurrentUser().getId()) {
            if (realmContacts.isBlockUser()) {
                initSpamBarLayout(realmRegisteredInfo);
                blockUser = true;
                txtSpamUser.setText(G.fragmentActivity.getResources().getString(R.string.un_block_user));
                vgSpamUser.setVisibility(View.VISIBLE);
            } else {
                if (vgSpamUser != null) {
                    vgSpamUser.setVisibility(View.GONE);
                }
            }
        }
    }
    if (vgSpamUser != null) {
        RelativeLayout.LayoutParams spamLayoutParam = (RelativeLayout.LayoutParams) vgSpamUser.getLayoutParams();
        if (mediaContainer.getVisibility() == View.VISIBLE) {
            chatContainer.removeView(vgSpamUser);
            spamLayoutParam.topMargin = LayoutCreator.dp(95);
            chatContainer.addView(vgSpamUser);
        }
    }
}
Also used : RelativeLayout(android.widget.RelativeLayout) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) RealmContacts(net.iGap.realm.RealmContacts)

Example 5 with RealmContacts

use of net.iGap.realm.RealmContacts in project iGap-Android by KianIranian-STDG.

the class ContactUtils method syncContacts.

/**
 * sync iGap contacts with phone contacts (add iGap Accounts to phone contacts that has iGap)
 */
public static void syncContacts() {
    try {
        HelperPermission.getContactPermision(G.fragmentActivity, new OnGetPermission() {

            @Override
            public void Allow() throws IOException {
                final MaterialDialog[] dialog = new MaterialDialog[1];
                dialog[0] = new MaterialDialog.Builder(G.currentActivity).title(R.string.sync_contact).content(R.string.just_wait_en).progress(false, 0, true).show();
                new Thread(() -> {
                    DbManager.getInstance().doRealmTransaction(realm1 -> {
                        final RealmResults<RealmContacts> realmContacts = realm1.where(RealmContacts.class).findAll();
                        final int contactsSize = realmContacts.size();
                        dialog[0].setMaxProgress(contactsSize);
                        for (RealmContacts realmContacts1 : realmContacts) {
                            addContactToPhoneBook(realmContacts1);
                            if (dialog[0].isCancelled()) {
                                break;
                            }
                            G.handler.post(() -> dialog[0].incrementProgress(1));
                        }
                        G.handler.postDelayed(() -> dialog[0].dismiss(), 500);
                    });
                }).start();
            }

            @Override
            public void deny() {
                showDeniedPermissionMessage(G.context.getString(R.string.permission_contact));
            // do nothing
            }
        });
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : IOException(java.io.IOException) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) RealmContacts(net.iGap.realm.RealmContacts)

Aggregations

RealmContacts (net.iGap.realm.RealmContacts)8 IOException (java.io.IOException)4 OnGetPermission (net.iGap.observers.interfaces.OnGetPermission)4 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 Gravity (android.view.Gravity)3 View (android.view.View)3 RealmResults (io.realm.RealmResults)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 G (net.iGap.G)3 R (net.iGap.R)3 AvatarHandler (net.iGap.helper.avatar.AvatarHandler)3 AppUtils (net.iGap.module.AppUtils)3 LastSeenTimeUtil (net.iGap.module.LastSeenTimeUtil)3 AccountManager (net.iGap.module.accountManager.AccountManager)3 DbManager (net.iGap.module.accountManager.DbManager)3 LayoutInflater (android.view.LayoutInflater)2 ViewGroup (android.view.ViewGroup)2 LinearLayout (android.widget.LinearLayout)2