Search in sources :

Example 6 with CircleImageView

use of net.iGap.module.CircleImageView in project iGap-Android by KianIranian-STDG.

the class Toolbar method onMeasure.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);
    int actionBarHeight = getCurrentActionBarHeight();
    int actionBarHeightSpec = MeasureSpec.makeMeasureSpec(actionBarHeight, MeasureSpec.EXACTLY);
    int titleLeft = 0;
    setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight);
    if (backIcon != null && backIcon.getVisibility() != GONE) {
        backIcon.measure(MeasureSpec.makeMeasureSpec(LayoutCreator.dp(46), MeasureSpec.EXACTLY), backIcon.getMeasuredHeight());
        // 46 icon width + 8 margin
        titleLeft += LayoutCreator.dp(54);
    } else {
        titleLeft += LayoutCreator.dp(16);
    }
    if (circleImageView != null && circleImageView.getVisibility() != GONE) {
        circleImageView.measure(MeasureSpec.makeMeasureSpec(LayoutCreator.dp(46), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(LayoutCreator.dp(46), MeasureSpec.EXACTLY));
        titleLeft = LayoutCreator.dp(58);
    }
    int menuWidth = 0;
    if (items != null && items.getVisibility() != GONE) {
        if (isSearchBoxVisible) {
            menuWidth = MeasureSpec.makeMeasureSpec(width - LayoutCreator.dp(64), MeasureSpec.EXACTLY);
        } else {
            menuWidth = MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST);
        }
        items.measure(menuWidth, actionBarHeightSpec);
    }
    if (titleTextView != null && titleTextView.getVisibility() != GONE || subTitleTextView != null && subTitleTextView.getVisibility() != GONE) {
        int textWidth = width - (items != null ? items.getMeasuredWidth() : 0) - LayoutCreator.dp(16) - titleLeft;
        if (titleTextView != null && titleTextView.getVisibility() != GONE) {
            if (subTitleTextView != null && subTitleTextView.getVisibility() != GONE) {
                if (!titleIsFontIcon)
                    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
                subTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
            } else {
                if (!titleIsFontIcon)
                    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
            }
            titleTextView.measure(MeasureSpec.makeMeasureSpec(textWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
        }
        if (subTitleTextView != null && subTitleTextView.getVisibility() != GONE) {
            subTitleTextView.measure(MeasureSpec.makeMeasureSpec(textWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
        }
        if (verifiedChannelsIcon != null && verifiedChannelsIcon.getVisibility() != GONE) {
            verifiedChannelsIcon.measure(MeasureSpec.makeMeasureSpec(LayoutCreator.dp(12), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(LayoutCreator.dp(12), MeasureSpec.EXACTLY));
        }
        if (muteIcon != null && muteIcon.getVisibility() != GONE) {
            muteIcon.measure(MeasureSpec.makeMeasureSpec(LayoutCreator.dp(12), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(LayoutCreator.dp(12), MeasureSpec.EXACTLY));
        }
    }
    for (int i = 0, count = getChildCount(); i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == GONE || child == backIcon || child == titleTextView || child == subTitleTextView || child == items || child == circleImageView || child == verifiedChannelsIcon || child == muteIcon) {
            continue;
        }
        measureChildWithMargins(child, menuWidth, 0, MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY), 0);
    }
}
Also used : AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) ImageView(android.widget.ImageView) View(android.view.View) CircleImageView(net.iGap.module.CircleImageView) TextView(android.widget.TextView)

Example 7 with CircleImageView

use of net.iGap.module.CircleImageView in project iGap-Android by KianIranian-STDG.

the class StoryCell method initView.

public void initView(Context context, boolean needDivider, CircleStatus status, ImageLoadingView.Status imageLoadingStatus, IconClicked iconClicked, long createTime) {
    removeAllViews();
    if (G.themeColor == Theme.DARK) {
        setBackground(Theme.getSelectorDrawable(Theme.getInstance().getDividerColor(context)));
    } else {
        setBackgroundColor(Color.WHITE);
    }
    this.status = status;
    this.needDivider = needDivider;
    this.iconClicked = iconClicked;
    this.context = context;
    setWillNotDraw(!needDivider);
    View view;
    switch(this.status) {
        case CIRCLE_IMAGE:
            circleImage = new CircleImageView(getContext());
            circleImage.setLayoutParams(LayoutCreator.createFrame(56, 56, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, isRtl ? 0 : padding, 8, isRtl ? padding : 0, 8));
            view = circleImage;
            break;
        case LOADING_CIRCLE_IMAGE:
            circleImageLoading = new ImageLoadingView(context);
            circleImageLoading.setStatus(imageLoadingStatus);
            circleImageLoading.setLayoutParams(LayoutCreator.createFrame(72, 72, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, isRtl ? 0 : 8, 8, isRtl ? 8 : 0, 8));
            view = circleImageLoading;
            break;
        default:
            throw new IllegalStateException("Unexpected value: " + this.status);
    }
    addView(view);
    addIcon = new MaterialDesignTextView(context);
    addIcon.setText(R.string.icon_add_whit_circle);
    addIcon.setTextColor(getResources().getColor(R.color.green));
    addIcon.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    addIcon.setGravity(isRtl ? Gravity.LEFT : Gravity.RIGHT);
    addView(addIcon, LayoutCreator.createFrame(18, 18, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, isRtl ? 0 : padding, 8, isRtl ? padding : 0, 8));
    topViewRootView = new LinearLayout(context);
    topViewRootView.setOrientation(LinearLayout.HORIZONTAL);
    topViewRootView.setGravity(Gravity.CENTER);
    addView(topViewRootView, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, isRtl ? padding : ((padding * 2) + 56), 11.5f, isRtl ? ((padding * 2) + 56) : padding, 0));
    channelIconTv = new FontIconTextView(getContext());
    setTextSize(channelIconTv, R.dimen.dp14);
    channelIconTv.setText(R.string.icon_channel);
    channelIconTv.setTextColor(Theme.getInstance().getAccentColor(channelIconTv.getContext()));
    channelIconTv.setVisibility(GONE);
    topViewRootView.addView(channelIconTv, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER));
    topText = new TextView(context);
    topText.setSingleLine();
    topText.setTypeface(ResourcesCompat.getFont(getContext(), R.font.main_font_bold));
    ViewMaker.setTextSize(topText, R.dimen.dp15);
    topText.setSingleLine(true);
    topText.setEllipsize(TextUtils.TruncateAt.END);
    topText.setTextColor(Theme.getInstance().getSendMessageTextColor(topText.getContext()));
    topText.setGravity((isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    topViewRootView.addView(topText, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER, !isRtl && roomId != 0 && userId != AccountManager.getInstance().getCurrentUser().getId() ? 4 : 0, 0, isRtl && roomId != 0 && userId != AccountManager.getInstance().getCurrentUser().getId() ? 4 : 0, 0));
    verifyIconTv = new FontIconTextView(getContext());
    verifyIconTv.setTextColor(getContext().getResources().getColor(R.color.verify_color));
    verifyIconTv.setText(R.string.icon_blue_badge);
    setTextSize(verifyIconTv, R.dimen.standardTextSize);
    verifyIconTv.setVisibility(GONE);
    topViewRootView.addView(verifyIconTv, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER, !isRtl && roomId != 0 && userId != AccountManager.getInstance().getCurrentUser().getId() ? 4 : 0, 0, isRtl && roomId != 0 && userId != AccountManager.getInstance().getCurrentUser().getId() ? 4 : 0, 0));
    middleText = new TextView(context);
    middleText.setSingleLine();
    middleText.setTypeface(ResourcesCompat.getFont(getContext(), R.font.main_font_bold));
    ViewMaker.setTextSize(middleText, R.dimen.dp15);
    middleText.setSingleLine(true);
    middleText.setEllipsize(TextUtils.TruncateAt.END);
    middleText.setTextColor(Theme.getInstance().getPrimaryTextColor(context));
    middleText.setGravity((isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    middleText.setVisibility(GONE);
    addView(middleText, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, isRtl ? padding : ((padding * 2) + 56), 0, isRtl ? ((padding * 2) + 56) : padding, 0));
    bottomText = new TextView(context);
    bottomText.setSingleLine();
    ViewMaker.setTypeFace(bottomText);
    ViewMaker.setTextSize(bottomText, R.dimen.dp13);
    bottomText.setGravity((isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    bottomText.setTextColor(Color.GRAY);
    addView(bottomText, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, isRtl ? padding : ((padding * 2) + 56), 34.5f, isRtl ? ((padding * 2) + 56) : padding, 0));
    icon = new IconView(getContext());
    icon.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
    icon.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    addView(icon, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, padding, 0, padding, 0));
    icon2 = new IconView(getContext());
    icon2.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
    icon2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    addView(icon2, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, isRtl ? (padding + 30) : padding, 0, isRtl ? padding : (30 + padding), 0));
    LinearLayout iconsRootView = new LinearLayout(getContext());
    iconsRootView.setOrientation(LinearLayout.HORIZONTAL);
    iconsRootView.setGravity(Gravity.CENTER);
    addView(iconsRootView, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, isRtl ? 0 : 8, 8, isRtl ? 8 : 0, 8));
    uploadIcon = new MaterialDesignTextView(getContext());
    uploadIcon.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
    uploadIcon.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 23);
    uploadIcon.setText(R.string.icon_upload);
    uploadIcon.setVisibility(GONE);
    uploadIcon.setTextColor(Theme.getInstance().getSendMessageTextColor(uploadIcon.getContext()));
    uploadIcon.setGravity(Gravity.CENTER);
    uploadIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if ((circleImageLoading.getStatus() == ImageLoadingView.Status.FAILED && isFromMyStatus && !isRoom) || (circleImageLoading.getStatus() == ImageLoadingView.Status.FAILED && isFromMyStatus && isRoom && mode == 1)) {
                deleteIcon.setVisibility(GONE);
                uploadIcon.setVisibility(GONE);
                middleText.setTextColor(Theme.getInstance().getTitleTextColor(context));
                middleText.setText(context.getString(R.string.story_sending));
                circleImageLoading.setStatus(ImageLoadingView.Status.LOADING);
                StoryObject realmStoryProto;
                if (fileToken != null) {
                    realmStoryProto = MessageDataStorage.getInstance(AccountManager.selectedAccount).getStoryWithFileToken(fileToken);
                } else {
                    realmStoryProto = MessageDataStorage.getInstance(AccountManager.selectedAccount).getStoryWithUploadId(uploadId);
                }
                if (realmStoryProto != null && realmStoryProto.fileToken != null) {
                    MessageDataStorage.getInstance(AccountManager.selectedAccount).updateStoryStatus(realmStoryProto.id, MessageObject.STATUS_SENDING);
                    List<ProtoStoryUserAddNew.StoryAddRequest> storyAddRequests = new ArrayList<>();
                    ProtoStoryUserAddNew.StoryAddRequest.Builder storyAddRequest = ProtoStoryUserAddNew.StoryAddRequest.newBuilder();
                    storyAddRequest.setToken(realmStoryProto.fileToken);
                    storyAddRequest.setCaption(realmStoryProto.caption);
                    storyAddRequests.add(storyAddRequest.build());
                    if (isRoom) {
                        MessageController.getInstance(AccountManager.selectedAccount).addMyRoomStory(storyAddRequests, roomId);
                    } else {
                        MessageController.getInstance(AccountManager.selectedAccount).addMyStory(storyAddRequests);
                    }
                } else if (realmStoryProto != null && !Uploader.getInstance().isCompressingOrUploading(String.valueOf(realmStoryProto.id))) {
                    MessageDataStorage.getInstance(AccountManager.selectedAccount).updateStoryStatus(realmStoryProto.id, MessageObject.STATUS_SENDING);
                    HttpUploader.isStoryUploading = true;
                    Uploader.getInstance().upload(UploadObject.createForStory(realmStoryProto.id, realmStoryProto.attachmentObject.filePath, null, realmStoryProto.caption, ProtoGlobal.RoomMessageType.STORY));
                }
                EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.STORY_SENDING);
            } else {
                deleteStory.deleteStory(StoryCell.this, storyId, roomId, isRoom);
            }
        }
    });
    deleteIcon = new MaterialDesignTextView(getContext());
    deleteIcon.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
    deleteIcon.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 23);
    deleteIcon.setText(R.string.icon_other_horizontal_dots);
    deleteIcon.setVisibility(GONE);
    deleteIcon.setTextColor(Theme.getInstance().getSendMessageTextColor(deleteIcon.getContext()));
    deleteIcon.setGravity(Gravity.CENTER);
    deleteIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            deleteStory.deleteStory(StoryCell.this, storyId, roomId, isRoom);
        }
    });
    iconsRootView.addView(uploadIcon, LayoutCreator.createLinear(72, 72, Gravity.CENTER_VERTICAL));
    iconsRootView.addView(deleteIcon, LayoutCreator.createLinear(72, 72, Gravity.CENTER_VERTICAL));
    if (status == CircleStatus.LOADING_CIRCLE_IMAGE) {
        setOnClickListener(v -> {
            deleteStory.onStoryClick(this);
        });
        circleImageLoading.setOnClickListener(v -> {
            deleteStory.onStoryClick(this);
        });
    }
}
Also used : IconView(net.iGap.messenger.ui.components.IconView) MainStoryObject(net.iGap.story.MainStoryObject) StoryObject(net.iGap.story.StoryObject) FontIconTextView(net.iGap.module.FontIconTextView) View(android.view.View) FontIconTextView(net.iGap.module.FontIconTextView) TextView(android.widget.TextView) ImageLoadingView(net.iGap.story.liststories.ImageLoadingView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) IconView(net.iGap.messenger.ui.components.IconView) CircleImageView(net.iGap.module.CircleImageView) CircleImageView(net.iGap.module.CircleImageView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) ImageLoadingView(net.iGap.story.liststories.ImageLoadingView) FontIconTextView(net.iGap.module.FontIconTextView) TextView(android.widget.TextView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) List(java.util.List) ArrayList(java.util.ArrayList) ProtoStoryUserAddNew(net.iGap.proto.ProtoStoryUserAddNew) LinearLayout(android.widget.LinearLayout)

Example 8 with CircleImageView

use of net.iGap.module.CircleImageView in project iGap-Android by KianIranian-STDG.

the class StoryCell method setStatus.

public void setStatus(CircleStatus status) {
    this.status = status;
    View view;
    switch(this.status) {
        case CIRCLE_IMAGE:
            if (circleImage == null) {
                circleImage = new CircleImageView(getContext());
                circleImage.setLayoutParams(LayoutCreator.createFrame(56, 56, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, isRtl ? 0 : padding, 8, isRtl ? padding : 0, 8));
                addView(circleImage, 0);
            } else {
                circleImage.setVisibility(VISIBLE);
            }
            if (circleImageLoading != null) {
                circleImageLoading.setVisibility(GONE);
            }
            break;
        case LOADING_CIRCLE_IMAGE:
            if (circleImage != null) {
                circleImage.setVisibility(GONE);
            }
            if (circleImageLoading == null) {
                circleImageLoading = new ImageLoadingView(context);
                circleImageLoading.setLayoutParams(LayoutCreator.createFrame(72, 72, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, isRtl ? 0 : 8, 8, isRtl ? 8 : 0, 8));
                addView(circleImageLoading, 0);
            } else {
                circleImageLoading.setVisibility(VISIBLE);
            }
            break;
        default:
            throw new IllegalStateException("Unexpected value: " + this.status);
    }
}
Also used : CircleImageView(net.iGap.module.CircleImageView) ImageLoadingView(net.iGap.story.liststories.ImageLoadingView) View(android.view.View) FontIconTextView(net.iGap.module.FontIconTextView) TextView(android.widget.TextView) ImageLoadingView(net.iGap.story.liststories.ImageLoadingView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) IconView(net.iGap.messenger.ui.components.IconView) CircleImageView(net.iGap.module.CircleImageView)

Example 9 with CircleImageView

use of net.iGap.module.CircleImageView in project iGap-Android by KianIranian-STDG.

the class RoomListCell method setData.

public void setData(RealmRoom room, AvatarHandler avatarHandler, boolean isSelectedMode) {
    if (room.isPinned()) {
        if (!havePin) {
            pinIcon = new IconView(getContext());
            pinIcon.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
            pinIcon.setIconColor(Theme.getInstance().getSubTitleColor(getContext()));
            pinIcon.setIcon(R.string.icon_pin_to_top2);
            pinView = new AppCompatImageView(getContext());
            pinView.setBackgroundResource(R.drawable.pin);
            pinView.setAlpha(G.themeColor == Theme.DARK ? 0.2f : 0.6f);
            addView(pinView, 0);
            addView(pinIcon, 1);
            havePin = true;
        }
    } else if (havePin) {
        removeView(pinIcon);
        removeView(pinView);
        havePin = false;
    }
    if (!haveAvatar) {
        avatarImageView = new CircleImageView(getContext());
        addView(avatarImageView);
        haveAvatar = true;
        final boolean isMyCloud;
        isMyCloud = room.getChatRoom() != null && room.getChatRoom().getPeerId() > 0 && room.getChatRoom().getPeerId() == AccountManager.getInstance().getCurrentUser().getId();
        if (isMyCloud) {
            avatarHandler.removeImageViewFromHandler(avatarImageView);
            avatarImageView.setImageResource(R.drawable.ic_cloud_space_blue);
        } else {
            avatarHandler(room, avatarHandler);
        }
    } else {
        final boolean isMyCloud;
        isMyCloud = room.getChatRoom() != null && room.getChatRoom().getPeerId() > 0 && room.getChatRoom().getPeerId() == AccountManager.getInstance().getCurrentUser().getId();
        if (isMyCloud) {
            avatarHandler.removeImageViewFromHandler(avatarImageView);
            avatarImageView.setImageResource(R.drawable.ic_cloud_space_blue);
        } else {
            avatarHandler(room, avatarHandler);
        }
    }
    if (haveName) {
        roomNameTv.setText(EmojiManager.getInstance().replaceEmoji(room.getTitle(), roomNameTv.getPaint().getFontMetricsInt(), -1, false));
    }
    if (room.getType() == ProtoGlobal.Room.Type.CHANNEL && room.getChannelRoom().isVerified() || room.getType() == CHAT && room.getChatRoom().isVerified()) {
        if (!roomVerified) {
            verifyIconTv = new FontIconTextView(getContext());
            verifyIconTv.setTextColor(getContext().getResources().getColor(R.color.verify_color));
            verifyIconTv.setText(R.string.icon_blue_badge);
            setTextSize(verifyIconTv, R.dimen.standardTextSize);
            addView(verifyIconTv);
            roomVerified = true;
        }
    } else if (roomVerified) {
        removeView(verifyIconTv);
        roomVerified = false;
    }
    if (!haveDate) {
        messageDateTv = new AppCompatTextView(getContext());
        messageDateTv.setSingleLine(true);
        messageDateTv.setTextColor(Theme.getInstance().getSendMessageTextColor(messageDateTv.getContext()));
        setTextSize(messageDateTv, R.dimen.smallTextSize);
        setTypeFace(messageDateTv);
        addView(messageDateTv);
        haveDate = true;
    }
    if (room.getLastMessage() != null && room.getLastMessage().getUpdateOrCreateTime() != 0) {
        messageDateTv.setText(HelperCalander.getTimeForMainRoom(room.getLastMessage().getUpdateOrCreateTime()));
    }
    if (room.getMute()) {
        if (!isMute) {
            muteIconTv = new FontIconTextView(getContext());
            muteIconTv.setText(R.string.icon_mute);
            muteIconTv.setGravity(Gravity.RIGHT);
            muteIconTv.setTextColor(Theme.getInstance().getSendMessageTextColor(getContext()));
            setTextSize(muteIconTv, R.dimen.dp13);
            addView(muteIconTv);
            isMute = true;
        }
    } else if (isMute) {
        removeView(muteIconTv);
        isMute = false;
    }
    if (room.getType() == ProtoGlobal.Room.Type.CHANNEL || room.getType() == ProtoGlobal.Room.Type.GROUP) {
        if (!haveChatIcon) {
            chatIconTv = new FontIconTextView(getContext());
            setTextSize(chatIconTv, R.dimen.dp14);
            addView(chatIconTv);
            chatIconTv.setTextColor(Theme.getInstance().getSendMessageTextColor(chatIconTv.getContext()));
            haveChatIcon = true;
        }
        if (room.getType() == ProtoGlobal.Room.Type.CHANNEL)
            chatIconTv.setText(R.string.icon_channel);
        else if (room.getType() == ProtoGlobal.Room.Type.GROUP)
            chatIconTv.setText(R.string.icon_contacts);
    } else if (haveChatIcon) {
        removeView(chatIconTv);
        haveChatIcon = false;
    }
    if (room.getTitle() != null && !haveName) {
        roomNameTv = new TextView(getContext());
        roomNameTv.setTypeface(ResourcesCompat.getFont(getContext(), R.font.main_font_bold));
        setTextSize(roomNameTv, R.dimen.dp15);
        roomNameTv.setSingleLine(true);
        roomNameTv.setEllipsize(TextUtils.TruncateAt.END);
        roomNameTv.setText(EmojiManager.getInstance().replaceEmoji(room.getTitle(), roomNameTv.getPaint().getFontMetricsInt(), -1, false));
        roomNameTv.setTextColor(Theme.getInstance().getSendMessageTextColor(roomNameTv.getContext()));
        roomNameTv.setGravity(isRtl ? Gravity.RIGHT : Gravity.LEFT | Gravity.CENTER_VERTICAL);
        addView(roomNameTv);
        haveName = true;
    }
    if (room.getLastMessage() != null) {
        if (!haveLastMessage) {
            lastMessageTv = new AppCompatTextView(getContext());
            lastMessageTv.setPadding(4, 0, 4, 0);
            lastMessageTv.setEllipsize(TextUtils.TruncateAt.END);
            lastMessageTv.setGravity(isRtl ? Gravity.RIGHT : Gravity.LEFT | Gravity.CENTER_VERTICAL);
            lastMessageTv.setSingleLine(true);
            setTypeFace(lastMessageTv);
            setTextSize(lastMessageTv, R.dimen.dp13);
            addView(lastMessageTv);
            haveLastMessage = true;
        }
        getLastMessage(room, lastMessageTv);
    } else if (haveLastMessage) {
        removeView(lastMessageTv);
        haveLastMessage = false;
    }
    if (!(room.getUnreadCount() < 1)) {
        if (!haveBadge) {
            badgeView = new TextBadge(getContext());
            setTypeFace(badgeView.getTextView());
            addView(badgeView);
            haveBadge = true;
        }
        if (room.getMute()) {
            badgeView.setBadgeColor(getResources().getColor(R.color.gray_9d));
        } else {
            badgeView.setBadgeColor(Theme.getInstance().getAccentColor(badgeView.getContext()));
        }
        badgeView.setText(getUnreadCount(room.getUnreadCount()));
        if (havePin) {
            removeView(pinIcon);
        }
    } else if (haveBadge) {
        removeView(badgeView);
        if (havePin) {
            removeView(pinIcon);
            addView(pinIcon);
        }
        haveBadge = false;
    }
    if (haveLastMessage && room.getLastMessage().isAuthorMe()) {
        if (!haveStatus) {
            statusTv = new FontIconTextView(getContext());
            setTextSize(statusTv, R.dimen.xlargeTextSize);
            addView(statusTv);
            haveStatus = true;
        }
        ProtoGlobal.RoomMessageStatus status = ProtoGlobal.RoomMessageStatus.UNRECOGNIZED;
        if (room.getLastMessage().getStatus() != null) {
            try {
                status = ProtoGlobal.RoomMessageStatus.valueOf(room.getLastMessage().getStatus());
            } catch (RuntimeException e) {
                e.printStackTrace();
            }
        }
        AppUtils.rightMessageStatus(statusTv, status, room.getLastMessage().isAuthorMe());
    } else if (haveStatus) {
        removeView(statusTv);
        haveStatus = false;
    }
    if (isSelectedMode) {
        if (!haveCheckBox) {
            checkBox = new CheckBox(getContext(), R.drawable.round_check);
            checkBox.setVisibility(VISIBLE);
            addView(checkBox);
            haveCheckBox = true;
        }
    } else if (haveCheckBox) {
        removeView(checkBox);
        haveCheckBox = false;
    }
    requestLayout();
}
Also used : CircleImageView(net.iGap.module.CircleImageView) IconView(net.iGap.messenger.ui.components.IconView) CheckBox(net.iGap.module.customView.CheckBox) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) FontIconTextView(net.iGap.module.FontIconTextView) ProtoGlobal(net.iGap.proto.ProtoGlobal) FontIconTextView(net.iGap.module.FontIconTextView) TextView(android.widget.TextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) TextBadge(net.iGap.module.customView.TextBadge)

Example 10 with CircleImageView

use of net.iGap.module.CircleImageView in project iGap-Android by KianIranian-STDG.

the class ViewMaker method makeCircleImageView.

static View makeCircleImageView() {
    CircleImageView circleImageView = new CircleImageView(context);
    circleImageView.setId(R.id.messageSenderAvatar);
    int size = (int) context.getResources().getDimension(R.dimen.dp48);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(size, size);
    params.setMargins(0, 0, (int) context.getResources().getDimension(dp8), 0);
    circleImageView.setLayoutParams(params);
    return circleImageView;
}
Also used : CircleImageView(net.iGap.module.CircleImageView) LinearLayout(android.widget.LinearLayout)

Aggregations

CircleImageView (net.iGap.module.CircleImageView)11 TextView (android.widget.TextView)9 View (android.view.View)6 LinearLayout (android.widget.LinearLayout)5 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)5 ImageView (android.widget.ImageView)4 FontIconTextView (net.iGap.module.FontIconTextView)4 FrameLayout (android.widget.FrameLayout)3 AppCompatTextView (androidx.appcompat.widget.AppCompatTextView)3 IconView (net.iGap.messenger.ui.components.IconView)3 MaterialDesignTextView (net.iGap.module.MaterialDesignTextView)3 ImageLoadingView (net.iGap.story.liststories.ImageLoadingView)3 ParamWithAvatarType (net.iGap.helper.avatar.ParamWithAvatarType)2 CheckBox (net.iGap.module.customView.CheckBox)2 ColorStateList (android.content.res.ColorStateList)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 InsetDrawable (android.graphics.drawable.InsetDrawable)1 LayerDrawable (android.graphics.drawable.LayerDrawable)1 DisplayMetrics (android.util.DisplayMetrics)1 TypedValue (android.util.TypedValue)1