1、通用弹窗---Xpopup
功能强大,UI简洁,交互优雅的通用弹窗!可以替代Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner等组件,自带十几种效果良好的动画, 支持完全的UI和动画自定义!它有这样几个特点:
- 功能强大,内部封装了常用的弹窗,内置十几种良好的动画,将弹窗和动画的自定义设计的极其简单
- UI和动画简洁,遵循Material Design,在设计动画的时候考虑了很多细节,过渡,层级的变化;或者说是模拟系统组件的动画
- 交互优雅,实现了优雅的手势交互以及智能的嵌套滚动,具体看Demo
- 适配全面屏,目前适配了小米,华为,谷歌,OPPO,VIVO,三星,魅族,一加全系全面屏手机
- 通用性,项目需求复杂多变,产品经理天马行空,虽然很难做到UI的通用,但是你可以看到交互和动画完全可以通用;至于弹窗的UI和逻辑可能需要你自定义
引入地址:
implementation 'com.github.li-xiaojun:XPopup:2.10.0'
项目地址:https://gitcode.com/angcyo/XPopup
2、下拉刷新、上拉加载更多控件
开源库地址:https://gitcode.com/angcyo/SmartRefreshLayout
项目中可以根据某一种刷新stytle去集成,也可以全部集成,下面展示部分集成示例:
implementation 'io.github.scwang90:refresh-layout-kernel:2.1.0' //核心必须依赖
implementation 'io.github.scwang90:refresh-header-classics:2.1.0' //经典刷新头
implementation 'io.github.scwang90:refresh-footer-classics:2.1.0' //经典加载
3、长连接通讯
implementation 'org.java-websocket:Java-WebSocket:1.5.2'
4、圆角控件
implementation 'com.makeramen:roundedimageview:2.3.0' <com.makeramen.roundedimageview.RoundedImageView android:id="@+id/iv_bg" android:layout_width="@dimen/dp_80" android:layout_height="@dimen/dp_120" app:riv_corner_radius="@dimen/dp_5" android:scaleType="fitXY" android:src="@mipmap/preview_default" />
5、json解析和转换
Gson库、FastJson库
implementation 'com.alibaba:fastjson:1.2.32' implementation 'com.google.code.gson:gson:2.8.5'
6、日志记录库
可以打印和写日志到文件,并可以设置清理策略
implementation 'com.elvishew:xlog:1.11.1'
使用示例:
object XLogUtil {
fun init(context: Context) {
val config = LogConfiguration.Builder()
.logLevel(LogLevel.ALL)
.tag("MyTag")//添加标识
.enableThreadInfo()
.build()
val androidPrinter =
AndroidPrinter(true)//// Printer that print the log using android.util.Log
val rootFolder=context.getExternalFilesDir(null)?.path
var logFolder = if(rootFolder.isNullOrEmpty()){
Environment.getExternalStorageDirectory().path + "/MyLog"
}else{
"$rootFolder/MyLog"
}
val filePrinter = FilePrinter.Builder(logFolder)//定义日志写入路径
.fileNameGenerator(MyFileNameGenerator())//日志文件名格式
.backupStrategy(FileSizeBackupStrategy((300 * 1024 * 1024).toLong()))//单个日志文件的大小默认:FileSizeBackupStrategy(1024 * 1024) 默认单个日志文件1M
.cleanStrategy(FileLastModifiedCleanStrategy(5L * 24L * 60L * 60L * 1000L))//日志文件存活时间,单位毫秒
.flattener(ClassicFlattener())//配置写入文件日志格式
.writer(SimpleWriter())//配置日志写入
.build()
XLog.init(config, androidPrinter, filePrinter)
}
fun d(msg: String) {
XLog.d(msg)
}
fun i(msg: String) {
XLog.i(msg)
}
fun e(msg: String) {
XLog.e(msg)
}
fun w(msg: String) {
XLog.w(msg)
}
fun v(msg: String) {
XLog.v(msg)
}
}
7、文件选择
使用场景:如需选择文件上传
implementation 'me.rosuh:AndroidFilePicker:1.0.1'