Search in sources :

Example 1 with GroupCallGridCell

use of org.telegram.ui.Components.voip.GroupCallGridCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class GroupCallActivity method showMenuForCell.

private boolean showMenuForCell(View rendererCell) {
    if (itemAnimator.isRunning()) {
        return false;
    }
    if (avatarPriviewTransitionInProgress || avatarsPreviewShowed) {
        dismissAvatarPreview(true);
        return false;
    }
    if (scrimPopupWindow != null) {
        scrimPopupWindow.dismiss();
        scrimPopupWindow = null;
        return false;
    }
    clearScrimView();
    GroupCallUserCell view;
    if (rendererCell instanceof GroupCallGridCell) {
        GroupCallGridCell groupCallGridCell = ((GroupCallGridCell) rendererCell);
        if (groupCallGridCell.getParticipant() == call.videoNotAvailableParticipant) {
            return false;
        }
        view = new GroupCallUserCell(groupCallGridCell.getContext());
        long selfPeerId = MessageObject.getPeerId(selfPeer);
        view.setData(accountInstance, groupCallGridCell.getParticipant().participant, call, selfPeerId, null, false);
        hasScrimAnchorView = false;
        scrimGridView = groupCallGridCell;
        scrimRenderer = groupCallGridCell.getRenderer();
        if (!isTabletMode && !isLandscapeMode) {
            scrimViewAttached = true;
            containerView.addView(view, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 14, 0, 14, 0));
        } else {
            scrimViewAttached = false;
        }
    } else if (rendererCell instanceof GroupCallFullscreenAdapter.GroupCallUserCell) {
        GroupCallFullscreenAdapter.GroupCallUserCell groupCallFullscreenCell = ((GroupCallFullscreenAdapter.GroupCallUserCell) rendererCell);
        if (groupCallFullscreenCell.getParticipant() == call.videoNotAvailableParticipant.participant) {
            return false;
        }
        view = new GroupCallUserCell(groupCallFullscreenCell.getContext());
        long selfPeerId = MessageObject.getPeerId(selfPeer);
        view.setData(accountInstance, groupCallFullscreenCell.getParticipant(), call, selfPeerId, null, false);
        hasScrimAnchorView = false;
        scrimFullscreenView = groupCallFullscreenCell;
        scrimRenderer = groupCallFullscreenCell.getRenderer();
        if (scrimRenderer != null && scrimRenderer.showingInFullscreen) {
            scrimRenderer = null;
        }
        containerView.addView(view, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 14, 0, 14, 0));
        scrimViewAttached = true;
    } else {
        view = (GroupCallUserCell) rendererCell;
        hasScrimAnchorView = true;
        scrimViewAttached = true;
    }
    if (view == null) {
        return false;
    }
    boolean showWithAvatarPreview = !isLandscapeMode && !isTabletMode && !AndroidUtilities.isInMultiwindow;
    TLRPC.TL_groupCallParticipant participant = view.getParticipant();
    Rect rect = new Rect();
    ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getContext());
    popupLayout.setBackgroundDrawable(null);
    popupLayout.setPadding(0, 0, 0, 0);
    popupLayout.setOnTouchListener(new View.OnTouchListener() {

        private int[] pos = new int[2];

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                if (scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
                    View contentView = scrimPopupWindow.getContentView();
                    contentView.getLocationInWindow(pos);
                    rect.set(pos[0], pos[1], pos[0] + contentView.getMeasuredWidth(), pos[1] + contentView.getMeasuredHeight());
                    if (!rect.contains((int) event.getX(), (int) event.getY())) {
                        scrimPopupWindow.dismiss();
                    }
                }
            } else if (event.getActionMasked() == MotionEvent.ACTION_OUTSIDE) {
                if (scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
                    scrimPopupWindow.dismiss();
                }
            }
            return false;
        }
    });
    popupLayout.setDispatchKeyEventListener(keyEvent -> {
        if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
            scrimPopupWindow.dismiss();
        }
    });
    LinearLayout buttonsLayout = new LinearLayout(getContext());
    LinearLayout volumeLayout = !participant.muted_by_you ? new LinearLayout(getContext()) : null;
    currentOptionsLayout = buttonsLayout;
    LinearLayout linearLayout = new LinearLayout(getContext()) {

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int width = MeasureSpec.getSize(widthMeasureSpec);
            buttonsLayout.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
            if (volumeLayout != null) {
                volumeLayout.measure(MeasureSpec.makeMeasureSpec(buttonsLayout.getMeasuredWidth(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
                setMeasuredDimension(buttonsLayout.getMeasuredWidth(), buttonsLayout.getMeasuredHeight() + volumeLayout.getMeasuredHeight());
            } else {
                setMeasuredDimension(buttonsLayout.getMeasuredWidth(), buttonsLayout.getMeasuredHeight());
            }
        }
    };
    linearLayout.setMinimumWidth(AndroidUtilities.dp(240));
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    VolumeSlider volumeSlider = null;
    int color = AndroidUtilities.getOffsetColor(Theme.getColor(Theme.key_voipgroup_listViewBackgroundUnscrolled), Theme.getColor(Theme.key_voipgroup_listViewBackground), colorProgress, 1.0f);
    if (volumeLayout != null && !view.isSelfUser() && !participant.muted_by_you && (!participant.muted || participant.can_self_unmute)) {
        Drawable shadowDrawable = getContext().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
        volumeLayout.setBackgroundDrawable(shadowDrawable);
        linearLayout.addView(volumeLayout, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 0));
        volumeSlider = new VolumeSlider(getContext(), participant);
        volumeLayout.addView(volumeSlider, LayoutHelper.MATCH_PARENT, 48);
    }
    buttonsLayout.setMinimumWidth(AndroidUtilities.dp(240));
    buttonsLayout.setOrientation(LinearLayout.VERTICAL);
    Drawable shadowDrawable = getContext().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
    shadowDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
    buttonsLayout.setBackgroundDrawable(shadowDrawable);
    linearLayout.addView(buttonsLayout, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, volumeSlider != null ? -8 : 0, 0, 0));
    ScrollView scrollView;
    if (Build.VERSION.SDK_INT >= 21) {
        scrollView = new ScrollView(getContext(), null, 0, R.style.scrollbarShapeStyle) {

            @Override
            protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                super.onMeasure(widthMeasureSpec, heightMeasureSpec);
                setMeasuredDimension(linearLayout.getMeasuredWidth(), getMeasuredHeight());
            }
        };
    } else {
        scrollView = new ScrollView(getContext());
    }
    scrollView.setClipToPadding(false);
    popupLayout.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
    long peerId = MessageObject.getPeerId(participant.peer);
    ArrayList<String> items = new ArrayList<>(2);
    ArrayList<Integer> icons = new ArrayList<>(2);
    ArrayList<Integer> options = new ArrayList<>(2);
    boolean isAdmin = false;
    if (participant.peer instanceof TLRPC.TL_peerUser) {
        if (ChatObject.isChannel(currentChat)) {
            TLRPC.ChannelParticipant p = accountInstance.getMessagesController().getAdminInChannel(participant.peer.user_id, currentChat.id);
            isAdmin = p != null && (p instanceof TLRPC.TL_channelParticipantCreator || p.admin_rights.manage_call);
        } else {
            TLRPC.ChatFull chatFull = accountInstance.getMessagesController().getChatFull(currentChat.id);
            if (chatFull != null && chatFull.participants != null) {
                for (int a = 0, N = chatFull.participants.participants.size(); a < N; a++) {
                    TLRPC.ChatParticipant chatParticipant = chatFull.participants.participants.get(a);
                    if (chatParticipant.user_id == participant.peer.user_id) {
                        isAdmin = chatParticipant instanceof TLRPC.TL_chatParticipantAdmin || chatParticipant instanceof TLRPC.TL_chatParticipantCreator;
                        break;
                    }
                }
            }
        }
    } else {
        isAdmin = peerId == -currentChat.id;
    }
    if (view.isSelfUser()) {
        if (view.isHandRaised()) {
            items.add(LocaleController.getString("VoipGroupCancelRaiseHand", R.string.VoipGroupCancelRaiseHand));
            icons.add(R.drawable.msg_handdown);
            options.add(7);
        }
        items.add(view.hasAvatarSet() ? LocaleController.getString("VoipAddPhoto", R.string.VoipAddPhoto) : LocaleController.getString("VoipSetNewPhoto", R.string.VoipSetNewPhoto));
        icons.add(R.drawable.msg_addphoto);
        options.add(9);
        if (peerId > 0) {
            items.add(TextUtils.isEmpty(participant.about) ? LocaleController.getString("VoipAddBio", R.string.VoipAddBio) : LocaleController.getString("VoipEditBio", R.string.VoipEditBio));
        } else {
            items.add(TextUtils.isEmpty(participant.about) ? LocaleController.getString("VoipAddDescription", R.string.VoipAddDescription) : LocaleController.getString("VoipEditDescription", R.string.VoipEditDescription));
        }
        icons.add(TextUtils.isEmpty(participant.about) ? R.drawable.msg_addbio : R.drawable.msg_bio);
        options.add(10);
        items.add(peerId > 0 ? LocaleController.getString("VoipEditName", R.string.VoipEditName) : LocaleController.getString("VoipEditTitle", R.string.VoipEditTitle));
        icons.add(R.drawable.msg_edit);
        options.add(11);
    } else if (ChatObject.canManageCalls(currentChat)) {
        if (!isAdmin || !participant.muted) {
            if (!participant.muted || participant.can_self_unmute) {
                items.add(LocaleController.getString("VoipGroupMute", R.string.VoipGroupMute));
                icons.add(R.drawable.msg_voice_muted);
                options.add(0);
            } else {
                items.add(LocaleController.getString("VoipGroupAllowToSpeak", R.string.VoipGroupAllowToSpeak));
                if (participant.raise_hand_rating != 0) {
                    icons.add(R.drawable.msg_allowspeak);
                } else {
                    icons.add(R.drawable.msg_voice_unmuted);
                }
                options.add(1);
            }
        }
        if (participant.peer.channel_id != 0 && !ChatObject.isMegagroup(currentAccount, participant.peer.channel_id)) {
            items.add(LocaleController.getString("VoipGroupOpenChannel", R.string.VoipGroupOpenChannel));
            icons.add(R.drawable.msg_channel);
            options.add(8);
        } else {
            items.add(LocaleController.getString("VoipGroupOpenProfile", R.string.VoipGroupOpenProfile));
            icons.add(R.drawable.msg_openprofile);
            options.add(6);
        }
        if (!isAdmin && ChatObject.canBlockUsers(currentChat)) {
            items.add(LocaleController.getString("VoipGroupUserRemove", R.string.VoipGroupUserRemove));
            icons.add(R.drawable.msg_block2);
            options.add(2);
        }
    } else {
        if (participant.muted_by_you) {
            items.add(LocaleController.getString("VoipGroupUnmuteForMe", R.string.VoipGroupUnmuteForMe));
            icons.add(R.drawable.msg_voice_unmuted);
            options.add(4);
        } else {
            items.add(LocaleController.getString("VoipGroupMuteForMe", R.string.VoipGroupMuteForMe));
            icons.add(R.drawable.msg_voice_muted);
            options.add(5);
        }
        if (participant.peer.channel_id != 0 && !ChatObject.isMegagroup(currentAccount, participant.peer.channel_id)) {
            items.add(LocaleController.getString("VoipGroupOpenChannel", R.string.VoipGroupOpenChannel));
            icons.add(R.drawable.msg_msgbubble3);
            options.add(8);
        } else {
            items.add(LocaleController.getString("VoipGroupOpenChat", R.string.VoipGroupOpenChat));
            icons.add(R.drawable.msg_msgbubble3);
            options.add(6);
        }
    }
    for (int a = 0, N = items.size(); a < N; a++) {
        ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getContext(), a == 0, a == N - 1);
        if (options.get(a) != 2) {
            cell.setColors(Theme.getColor(Theme.key_voipgroup_actionBarItems), Theme.getColor(Theme.key_voipgroup_actionBarItems));
        } else {
            cell.setColors(Theme.getColor(Theme.key_voipgroup_leaveCallMenu), Theme.getColor(Theme.key_voipgroup_leaveCallMenu));
        }
        cell.setSelectorColor(Theme.getColor(Theme.key_voipgroup_listSelector));
        cell.setTextAndIcon(items.get(a), icons.get(a));
        buttonsLayout.addView(cell);
        final int i = a;
        cell.setTag(options.get(a));
        cell.setOnClickListener(v1 -> {
            if (i >= options.size()) {
                return;
            }
            TLRPC.TL_groupCallParticipant participant1 = call.participants.get(MessageObject.getPeerId(participant.peer));
            if (participant1 == null) {
                participant1 = participant;
            }
            processSelectedOption(participant1, MessageObject.getPeerId(participant1.peer), options.get(i));
            if (scrimPopupWindow != null) {
                scrimPopupWindow.dismiss();
            } else {
                if (options.get(i) != 9 && options.get(i) != 10 && options.get(i) != 11) {
                    dismissAvatarPreview(true);
                }
            }
        });
    }
    scrollView.addView(linearLayout, LayoutHelper.createScroll(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP));
    listView.stopScroll();
    layoutManager.setCanScrollVertically(false);
    scrimView = view;
    scrimView.setAboutVisible(true);
    containerView.invalidate();
    listView.invalidate();
    if (scrimAnimatorSet != null) {
        scrimAnimatorSet.cancel();
    }
    scrimPopupLayout = popupLayout;
    final ImageLocation imageLocation;
    final ImageLocation thumbLocation;
    if (peerId > 0) {
        TLRPC.User currentUser = accountInstance.getMessagesController().getUser(peerId);
        imageLocation = ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_BIG);
        thumbLocation = ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL);
    } else {
        TLRPC.Chat currentChat = accountInstance.getMessagesController().getChat(-peerId);
        imageLocation = ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_BIG);
        thumbLocation = ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_SMALL);
    }
    boolean hasAttachedRenderer = scrimRenderer != null && scrimRenderer.isAttached();
    if (imageLocation == null && !hasAttachedRenderer) {
        showWithAvatarPreview = false;
    } else if (showWithAvatarPreview) {
        avatarsViewPager.setParentAvatarImage(scrimView.getAvatarImageView());
        avatarsViewPager.setHasActiveVideo(hasAttachedRenderer);
        avatarsViewPager.setData(peerId, true);
        avatarsViewPager.setCreateThumbFromParent(true);
        avatarsViewPager.initIfEmpty(imageLocation, thumbLocation);
        if (scrimRenderer != null) {
            scrimRenderer.setShowingAsScrimView(true, true);
        }
        if (MessageObject.getPeerId(selfPeer) == peerId && currentAvatarUpdater != null && avatarUpdaterDelegate != null && avatarUpdaterDelegate.avatar != null) {
            avatarsViewPager.addUploadingImage(avatarUpdaterDelegate.uploadingImageLocation, ImageLocation.getForLocal(avatarUpdaterDelegate.avatar));
        }
    }
    if (showWithAvatarPreview) {
        avatarsPreviewShowed = true;
        popupLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
        containerView.addView(scrimPopupLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
        // scrimFullscreenView == null;
        useBlur = true;
        if (useBlur) {
            prepareBlurBitmap();
        }
        avatarPriviewTransitionInProgress = true;
        avatarPreviewContainer.setVisibility(View.VISIBLE);
        if (volumeSlider != null) {
            volumeSlider.invalidate();
        }
        runAvatarPreviewTransition(true, view);
        if (scrimFullscreenView != null) {
            scrimFullscreenView.getAvatarImageView().setAlpha(0f);
        }
    } else {
        avatarsPreviewShowed = false;
        scrimPopupWindow = new ActionBarPopupWindow(popupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {

            @Override
            public void dismiss() {
                super.dismiss();
                if (scrimPopupWindow != this) {
                    return;
                }
                scrimPopupWindow = null;
                if (scrimAnimatorSet != null) {
                    scrimAnimatorSet.cancel();
                    scrimAnimatorSet = null;
                }
                layoutManager.setCanScrollVertically(true);
                scrimAnimatorSet = new AnimatorSet();
                ArrayList<Animator> animators = new ArrayList<>();
                animators.add(ObjectAnimator.ofInt(scrimPaint, AnimationProperties.PAINT_ALPHA, 0));
                scrimAnimatorSet.playTogether(animators);
                scrimAnimatorSet.setDuration(220);
                scrimAnimatorSet.addListener(new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        clearScrimView();
                        containerView.invalidate();
                        listView.invalidate();
                        if (delayedGroupCallUpdated) {
                            delayedGroupCallUpdated = false;
                            applyCallParticipantUpdates(true);
                        }
                    }
                });
                scrimAnimatorSet.start();
            }
        };
        scrimPopupWindow.setPauseNotifications(true);
        scrimPopupWindow.setDismissAnimationDuration(220);
        scrimPopupWindow.setOutsideTouchable(true);
        scrimPopupWindow.setClippingEnabled(true);
        scrimPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
        scrimPopupWindow.setFocusable(true);
        popupLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
        scrimPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
        scrimPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
        scrimPopupWindow.getContentView().setFocusableInTouchMode(true);
        int popupX, popupY;
        if (scrimFullscreenView != null) {
            if (isLandscapeMode) {
                popupX = (int) (scrimFullscreenView.getX() + fullscreenUsersListView.getX() + renderersContainer.getX()) - popupLayout.getMeasuredWidth() + AndroidUtilities.dp(32);
                popupY = (int) (scrimFullscreenView.getY() + fullscreenUsersListView.getY() + renderersContainer.getY()) - AndroidUtilities.dp(6);
            } else {
                popupX = (int) (scrimFullscreenView.getX() + fullscreenUsersListView.getX() + renderersContainer.getX()) - AndroidUtilities.dp(14);
                popupY = (int) (scrimFullscreenView.getY() + fullscreenUsersListView.getY() + renderersContainer.getY() - popupLayout.getMeasuredHeight());
            }
        } else {
            popupX = (int) (listView.getX() + listView.getMeasuredWidth() + AndroidUtilities.dp(8) - popupLayout.getMeasuredWidth());
            if (hasScrimAnchorView) {
                popupY = (int) (listView.getY() + view.getY() + view.getClipHeight());
            } else if (scrimGridView != null) {
                popupY = (int) (listView.getY() + scrimGridView.getY() + scrimGridView.getMeasuredHeight());
            } else {
                popupY = (int) listView.getY();
            }
        }
        scrimPopupWindow.showAtLocation(listView, Gravity.LEFT | Gravity.TOP, popupX, popupY);
        scrimAnimatorSet = new AnimatorSet();
        ArrayList<Animator> animators = new ArrayList<>();
        animators.add(ObjectAnimator.ofInt(scrimPaint, AnimationProperties.PAINT_ALPHA, 0, 100));
        scrimAnimatorSet.playTogether(animators);
        scrimAnimatorSet.setDuration(150);
        scrimAnimatorSet.start();
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) AnimatorSet(android.animation.AnimatorSet) TLRPC(org.telegram.tgnet.TLRPC) ImageLocation(org.telegram.messenger.ImageLocation) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ActionBarMenuSubItem(org.telegram.ui.ActionBar.ActionBarMenuSubItem) GroupCallFullscreenAdapter(org.telegram.ui.Components.GroupCallFullscreenAdapter) GroupCallUserCell(org.telegram.ui.Cells.GroupCallUserCell) Rect(android.graphics.Rect) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) CellFlickerDrawable(org.telegram.ui.Components.voip.CellFlickerDrawable) BlobDrawable(org.telegram.ui.Components.BlobDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) WaveDrawable(org.telegram.ui.Components.WaveDrawable) RecordStatusDrawable(org.telegram.ui.Components.RecordStatusDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) GroupCallGridCell(org.telegram.ui.Components.voip.GroupCallGridCell) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) UndoView(org.telegram.ui.Components.UndoView) HintView(org.telegram.ui.Components.HintView) GroupCallMiniTextureView(org.telegram.ui.Components.voip.GroupCallMiniTextureView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) ScrollView(android.widget.ScrollView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout)

Example 2 with GroupCallGridCell

use of org.telegram.ui.Components.voip.GroupCallGridCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class GroupCallTabletGridAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
    GroupCallGridCell cell = (GroupCallGridCell) holder.itemView;
    ChatObject.VideoParticipant oldVideoParticipant = cell.getParticipant();
    ChatObject.VideoParticipant videoParticipant;
    TLRPC.TL_groupCallParticipant participant;
    videoParticipant = videoParticipants.get(position);
    participant = videoParticipants.get(position).participant;
    cell.spanCount = getSpanCount(position);
    cell.position = position;
    cell.gridAdapter = this;
    if (cell.getMeasuredHeight() != getItemHeight(position)) {
        cell.requestLayout();
    }
    cell.setData(AccountInstance.getInstance(currentAccount), videoParticipant, groupCall, MessageObject.getPeerId(groupCall.selfPeer));
    if (oldVideoParticipant != null && !oldVideoParticipant.equals(videoParticipant) && cell.attached && cell.getRenderer() != null) {
        attachRenderer(cell, false);
        attachRenderer(cell, true);
    } else if (cell.getRenderer() != null) {
        cell.getRenderer().updateAttachState(true);
    }
}
Also used : ChatObject(org.telegram.messenger.ChatObject) GroupCallGridCell(org.telegram.ui.Components.voip.GroupCallGridCell) TLRPC(org.telegram.tgnet.TLRPC)

Aggregations

TLRPC (org.telegram.tgnet.TLRPC)2 GroupCallGridCell (org.telegram.ui.Components.voip.GroupCallGridCell)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 ValueAnimator (android.animation.ValueAnimator)1 SuppressLint (android.annotation.SuppressLint)1 Paint (android.graphics.Paint)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 Rect (android.graphics.Rect)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Drawable (android.graphics.drawable.Drawable)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1