Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Holder layout not working #373

Open
super-gsevla opened this issue Jan 17, 2024 · 0 comments
Open

Holder layout not working #373

super-gsevla opened this issue Jan 17, 2024 · 0 comments

Comments

@super-gsevla
Copy link

Hey, I'm using ChatKit to build a custom chat implementation and unfortunately I guess it's not working properly.

I have this layout for my chat:

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.stfalcon.chatkit.messages.MessagesList
        android:id="@+id/messagesList"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintTop_toTopOf="parent"
        app:textAutoLink="all"
        android:background="@color/neutral50"
        android:padding="12dp"
        app:layout_constraintBottom_toTopOf="@+id/input"/>

    <com.stfalcon.chatkit.messages.MessageInput
        android:id="@+id/input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:showAttachmentButton="true"
        app:inputHint="@string/hint_enter_a_message"
        app:inputButtonDefaultBgDisabledColor="@color/neutral0"
        app:inputButtonDefaultIconDisabledColor="@color/primary"
        app:inputButtonDefaultBgColor="@color/primary"
        app:inputButtonDefaultIconColor="@color/neutral0"
        app:attachmentButtonDefaultBgColor="@color/primary"
        app:attachmentButtonDefaultIconColor="@color/neutral0"
        app:inputBackground="@color/neutral0"
        android:background="@color/neutral50"
        android:elevation="2dp"
        android:padding="8dp"
        app:layout_constraintBottom_toBottomOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

For outcoming text message I have

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:id="@id/bubble"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_marginLeft="40dp"
        android:layout_marginStart="40dp"
        android:orientation="vertical"
        android:background="@drawable/outgoing_message_wrapper"
        android:paddingTop="8dp"
        android:paddingBottom="4dp"
        android:paddingHorizontal="12dp">

        <TextView
            android:id="@id/messageText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@style/message_text"
            android:layout_marginBottom="4dp"
            android:inputType="text|textMultiLine"
            tools:text="Just testing text box. but much more bigger to test line break with this text box dasdasd asdaasdasd"/>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="16dp"
            android:layout_gravity="center_vertical|right"
            android:orientation="horizontal">

            <TextView
                android:id="@id/messageTime"
                android:layout_width="wrap_content"
                android:layout_height="16dp"
                android:gravity="right"
                android:layout_gravity="center_vertical|right"
                android:layout_weight="1"
                android:textAppearance="@style/message_date_text"
                tools:text="08:21"/>

            <ImageView
                android:id="@+id/messageTick"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="right"
                android:layout_gravity="center_vertical|right"
                android:layout_weight="0"
                android:src="@drawable/clock"
                android:layout_marginLeft="4dp" />

        </LinearLayout>

    </LinearLayout>

</RelativeLayout>

and outgoing_message_wrapper background is:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <stroke android:width="2dp"
        android:color="@color/neutral100"
        />

    <corners
        android:radius="12dp"
        android:topRightRadius="0dp"
        />

    <solid android:color="@color/neutral50" />
</shape>

And I have an init method to initialize all what I need:

    public void initChat(View view) {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        Handler handler = new Handler(Looper.getMainLooper());

        executor.execute(() -> {
            while(props.requiredPropsReady == false) {
                try {
                    synchronized (initLock) {
                        initLock.wait();
                    }
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }

            adapter = new MessagesListAdapter(
                    props.getPersonId(),
                    new MessageHolders().setIncomingTextLayout(R.layout.incoming_message).setOutcomingTextLayout(R.layout.outgoing_message),
                    new GlideImageLoader(context)
            );

            MessagesList messagesList = view.findViewById(R.id.messagesList);
            messagesList.setAdapter(adapter);

            ListenRoomMessages.start(context, adapter, props.getRoomUUID(), props.getPersonId());

            MessageInput input = view.findViewById(R.id.input);
            input.setInputListener(new MessageInputListener(this));

            adapter.setLoadMoreListener(new LoadMoreListener(this));

            List<DefaultMessageModel> messages = this.fetchInitialMessages();
            handler.post(() -> adapter.addToEnd(messages, false));
        });

    }

My bubbles are supposed to be like:
(incoming)
Captura de Tela 2024-01-17 às 13 05 34
(outcoming)
Captura de Tela 2024-01-17 às 13 05 59

But as you can see here:
Captura de Tela 2024-01-17 às 13 07 16
Layout is just partially applied.

I don't have any idea why it isn't working. But if I use styling via attributes, I can apply my custom bubbles, but inner styling like put clock icon next to time just stops to work.

Can anyone help me to achieve that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant