Remember the process of using emojicon once

first link

Open source project emojicon
write picture description here

This project seems to be very easy to use, quickly integrate emojicon, the manager will be impressed by me, when the time comes, I will get a promotion and raise my salary, become the general manager and become the CEO to marry Bai Fumei and then be cuckolded by the agent.. Hehe.. It's a little small to think about it Excited..

Two pits in this open source project

After the excitement was over, I still did it for a long time to complete.. Mainly due to the two giant pits in this project.. When the project is completed, if I have time, I will take a closer look at the source code. Let’s talk about the implementation first..

1.fragment?

In the usage described below on github.. write this

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:emojicon="http://schemas.android.com/apk/res-auto"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">

    <io.github.rockerhieu.emojicon.EmojiconTextView
            android:id="@+id/txtEmojicon"
            android:text="I \ue32d emojicon"
            emojicon:emojiconAlignment="baseline"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

    <io.github.rockerhieu.emojicon.EmojiconEditText
            android:id="@+id/editEmojicon"
            android:text="I \ue32d emojicon"
            emojicon:emojiconSize="28sp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    <fragment
            android:id="@+id/emojicons"
            android:layout_width="match_parent"
            android:layout_height="220dp"
            class="io.github.rockerhieu.emojicon.EmojiconsFragment"/>
</LinearLayout>

But the integration into the project has the following situation
write picture description here

The emojicons have fled.. the icon doesn't show up... it's like Bai Fumei abandoned me.. I've been looking for a long time and the problem can't be solved...

Later, I finally found the answer in the demo.. (The java code is also recommended to go to the demo. The demo is quite clear about the three methods)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:emojicon="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >


    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/use_system_default"
        android:id="@+id/use_system_default"
        android:checked="false" />

    <io.github.rockerhieu.emojicon.EmojiconTextView
        android:id="@+id/txtEmojicon"
        android:text="@string/i_love_emojicon"
        emojicon:emojiconAlignment="baseline"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <io.github.rockerhieu.emojicon.EmojiconEditText
        android:id="@+id/editEmojicon"
        android:hint="@string/hint"
        android:text="@string/i_love_emojicon"
        emojicon:emojiconSize="28sp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <FrameLayout   //这里是重点
        android:id="@+id/emojicons"
        android:layout_width="match_parent"
        android:layout_height="fill_parent" />
</LinearLayout>


Oh my god, this is not the same as what I said!
And it's all fra******.. I can't find it if I don't pay attention.
I don't know if the author is intentional or not... The FrameLayout here has been replaced on github with The method of Fragment .. leads to the situation that emojicon cannot be displayed..

2. How to interact with the server

Before I interacted with the server.. I still realized it.. Marrying Bai Fumei is probably enough... But I can still think about promotion and salary increase... Hehehe.. But after the server came, my dream was shattered …

The bottom layer of it is some special symbols... Then it is displayed in edittext and Textview by means of replacement.. These special symbols log out as spaces.. When they are sent to the server??? Now... And we have both ios and Android.. It is not feasible for me to encrypt all the text and get it back to decrypt..

Do our customers have to rely on imagination to see expressions? Of course not..

Finally found a feasible solution in a blog

Access method of emojicon expression in database

Inside it says..

MySQL version 5.5.3 and above can use utf8mb4 encoding for storage, which supports 4-byte UTF-8 characters. But doing this is likely to cause incompatibility problems elsewhere, and changing the database encoding will change the overall system too much and is not recommended.

But in fact, many databases (such as the oss Alibaba Cloud we use) can completely realize the storage and encoding management of one of the fields... That is to say.. Just click and send the dragon sword... Let the server click utf8mb4 for you. ..

However, the log they received after being sent to the server is still a space.. But this does not affect our access and interaction.. So this is a convenient, concise and feasible method...

At this point.. the integration of emojicon is completed.. The manager finally did not let me get a promotion and a salary increase to marry Bai Fumei and let me work overtime next Saturday... Alas....

If I have time, I'll take a look at the source code...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325483202&siteId=291194637