Git Product home page Git Product logo

chatdemo's Introduction

ChatDemo

##主界面选择实现方式:

image

##文字表情示例图片:

image

##图片发送示例图片:

image

##语音发送示例动图:

image

##注:RecyclerView和ListView实现方式不同,些许功能不同,按需使用。

(按二者缓存方式的特性,建议类似聊天这种局部更新频繁的界面使用RecyclerView。)

(RecyclerView现已完善,如有bug通知我再修复) ##16/11/7更新:

  • 优化界面流畅度,主要优化GifTextView控件,和RecyclerView界面的流畅度,主要解决滑动时图片和文字表情的闪烁问题。

##16/10/15更新:

  • 添加消息数据库,用于保存聊天记录。 数据库用的是GreenDao。数据分页加载。

因为是个Demo,所以ListView和RecyclerView用的同一个表,大家只需看实现方式即可。

##16/10/10更新:

  • 添加ListView的实现方式:PullToRefreshListView

PullToRefreshRecyclerView为RecyclerView的实现方式,若想切换ListView则需对ChatActivity和PullToRefreshLayout等做修改和一些属性修改。

ListView适配器:ChatListViewAdapter

RecyclerView适配器:ChatRecyclerAdapter

##16/9/30更新:

  • 界面由ListView改为RecyclerView

  • 增加添加item动画

  • 修复界面随键盘弹起问题,类似微信。

  • 优化界面,提升用户体验

##介绍:

  • 该项目是一个聊天界面,封装了包括文字、表情、图片和语音信息。
  • 支持静态表情,gif表情,文字表情混排。图文混排实现参考:Android聊天实现图文混编(包括gif显示)
  • 支持图片发送,裁剪图片形状,支持图片点击进入大图观看,支持放大缩小等。
  • 根据图片大小等比例缩放,并压缩显示。
  • 支持语音发送,接收语音未读状态显示,语音录制为amr格式保存文件,语音发送仿微信。
  • 语音播放工具可以参考另一个项目:android语音播放工具(自带缓存)
  • 若想录制mp3格式参考:Android录制mp3格式
  • 没有录音权限则提示用户。实现方式参考:Android录音权限被禁解决方案
  • 语音、图片支持三种状态:发送中、发送失败和发送成功(发送失败显示感叹号)。
  • 支持下拉加载更多,下拉加载更多用了ViewDragHelper,实现方式参考:Android下拉刷新
  • 支持时间显示,默认大于一分钟显示一次,具体规则参见ChatAdapter类。可根据需求修改。

##详细说明

ListView:

image

RecyclerView:

image

###主要:

  • ChatActivity:聊天界面
  • ChatListViewAdapter:ListView聊天界面适配器
  • ChatRecyclerAdapter:RecyclerView聊天界面适配器
  • ChatBean:聊天数据对象

###其他

  • ImageViewActivity:大图观看界面
  • AudioRecordButton:自定义录音控件
  • BubbleImageView:自定义图片裁剪控件
  • MediaManager:语音播放控件
  • GifTextView:自定义图文混排控件
  • pulltorefresh包:自定义下拉加载更多控件(仅支持下拉加载更多)
  • SlideInOutBottomItemAnimator:RecyclerView添加item动画(上滑)

图片加载使用Glide。

为了优化性能,滑动的过程中gif为静态显示。

文字发送按钮为键盘中的回车。

##后记:

该项目也是将之前做过的一些东西汇合了一下,时间比较短,大家就看一下具体的实现方式吧,可能有点乱,有时间的话我整理一下。

License

Copyright 2016 maojiqing

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

chatdemo's People

Contributors

ariesjiang avatar maximilianmao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatdemo's Issues

您好,请教您一个动画的问题

我是拿了您的聊天项目,结果我弄过去后发现发送文本消息的时候文字会上下跳动下,上下翻动历史记录的时候 文字会重叠,能帮忙解答下嘛

收到的语音消息下载策略

收到的语音消息怎么来维护下载策略呢,比如聊天界面每次加载50条数据,有30条是收到的语音消息,那么怎么做到只有在屏幕中显示的语音消息才开始下载并更新界面?

在华为的6.0系统上调动录音会引起ANR

在魅族的4.4和华为6.0上都遇到录音ANR的问题

 @Override
    public boolean onPreDraw() {
        return false;
    }

这个方法注释掉就好了,主要是按下时设置背景和文字引起的ANR,这个方法为什么要返回false?

界面错乱

发送和接收消息是消息会重叠 导致界面错乱 请修复此bug

语音功能的BUG

在使用完语音功能之后,语音消息并不能及时的显示在界面上,甚至整个界面就直接卡死了.不是到时失去焦点了还是因为ANR...
造成这个的原因是因为网络原因还是音频的缓存机制的问题?求大神指导

大神,有个问题想要请教一下,也希望你能完善一下,RecyclerView写聊天界面,有个下拉加载,想要做到微信QQ那种效果,加载完毕当前Item不动(不要有任何动画),只在上头增加条数,布局管理器中有这个方法可完美实现setReverseLayout(true);//反转 但是问题来了,设置了这个属性齐方式变到下面去了,查了一些论坛,发现布局管理器还有这个方法setStackFromEnd(true);果然对齐方式对了,可是下拉加载效果又不对了,如何才能解决这问题,我想到了自定义布局,可惜我是只菜鸟,求大神带带,关注你的github,希望早点修复这问题,我的QQ:83606260

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.