记一次emojicon的使用过程
来源:互联网 发布:腾讯云mysql 外网连接 编辑:程序博客网 时间:2024/05/16 10:55
先上链接
开源项目emojicon
这个项目似乎看起来很好用, 快速集成emojicon, 经理会对我刮目相看, 到时候升职加薪,当上总经理出任CEO迎娶白富美然后被经纪人戴绿帽.. 嘿嘿.. 想想还有点小激动呢..
这个开源项目里的两个坑
激动完了之后,我还是做了好久才完成.. 主要归功于这个项目里的两个巨坑.. 等项目做完如果有时间我再去仔细了解一下源码.. 先说实现吧..
1.fragment?
在github上下面介绍的用法里.. 这样写道
<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>
但是集成到项目里面却出现了如下情况
emojicon们出逃了.. 图标显示不出来… 如同白富美抛弃了我一样.. 找了很久问题都解决不了…
后来终于在demo里找到答案..(java代码也建议去看demo .. demo就三个方法还是挺清楚的)
<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>
妈呀 这和说好的不一样啊!
而且都是fra******的.. 不注意根本发现不了..
也不知道作者是有心还是无意… 这里的FrameLayout在github上被换成了Fragment的方法.. 导致出现了emojicon无法显示的情况..
2.和服务器交互的办法
在没和服务器交互之前.. 我还算是实现了.. 迎娶白富美估计是够呛了… 但是升职加薪还是能想想的吧… 嘿嘿嘿.. 但是服务器来了之后我的梦想就破碎了…
它的底层是一些特殊符号… 然后用替换的方式显示在edittext 和 Textview中.. 这些特殊符号log出来是空格.. 传到服务器是??? 传回来是锟斤拷烫烫烫… 这样就爆炸了… 而且我们有ios和Android两端.. 我给文字全部加密拿回来解密也是不可行的..
难道我们的客户只能靠想象去看表情了么? 当然不能..
最终在一篇博客里找到了一点可行的办法
emojicon表情在数据库中的存取方法
里面写道..
MySQL 版本 5.5.3 以上可以使用utf8mb4编码来进行存储,此编码支持4字节的 UTF-8 字符。但是这样做很可能会在其他地方出现不兼容的问题,且更改数据库编码对系统整体改动太大,不推荐使用。
但是实际上现在很多数据库(如我们用的oss阿里云) ..完全可以实现对其中一个字段的存储编码管理… 也就是说.. 屠龙宝刀 点击就送… 让服务器给你点一下utf8mb4就可以了..
不过传到服务器之后他们收到的log出来依然是空格.. 但这已经不影响我们存取和交互了.. 所以这是个方便简洁可行的办法…
至此.. emojicon的集成就完成了.. 经理最终还是没让我升职加薪迎娶白富美并让我下周六加班… 唉….
如果有时间我再去看看源码吧…
- 记一次emojicon的使用过程
- EmojIcon的简单使用
- 记一次Gson使用过程中的踩到的 "坑"
- 记一次RecyclerView使用过程遇到的坑
- 记一次使用 git bisect 快速定位 bug 的过程
- 记一次linux下composer使用的坑爹过程
- 一次SQL Performance Analyzer的使用过程
- emojicon表情客户端和服务端的传递
- 记一次troubleshoot 磁盘满的过程
- 记一次打包源码的过程
- 记一次PermGen持续增长的解决过程
- 记一次拆机、装机的过程
- 记一次PermGen持续增长的解决过程
- 记一次GIT的安装过程
- 记一次openstack的部署过程
- 记一次kali拿站的过程
- 记一次用户登录的过程
- 记一次失败的oracle安装过程
- java集合框架
- PHP错误异常处理详解
- hdu 1160 FatMouse’s Speed
- ubuntu14.04.1虚拟机搭建git服务器
- Spring之@Autowired问题
- 记一次emojicon的使用过程
- 插入排序
- C/C++笔记--static与const关键字分析
- HDU 2298 Toxophily
- 事件分发
- Android选取相册中的图片并对其进行压缩
- 仿太平洋电脑网客户端的搜索头
- VeiwPager、Gallery、ViewFlipper区别
- 今天看到别人关于bundle pmvs的信息就转载一下