升级gradle
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
@@ -24,5 +25,10 @@ android {
|
||||
dependencies {
|
||||
api 'androidx.annotation:annotation:1.1.0'
|
||||
api 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation "androidx.core:core-ktx:+"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
|
@@ -1 +0,0 @@
|
||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":100,"versionName":"1.0.0","enabled":true,"outputFile":"accompany_release_v1.0.0-05152110.apk","fullName":"accompanyRelease","baseName":"accompany-release"},"path":"accompany_release_v1.0.0-05152110.apk","properties":{}}]
|
@@ -2,6 +2,9 @@ apply plugin: 'com.android.application'
|
||||
|
||||
// android res guard 资源混淆脚本
|
||||
apply from: 'and_res_guard.gradle'
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
|
@@ -15,6 +15,7 @@ import java.util.List;
|
||||
public class RvAdapter {
|
||||
/**
|
||||
* 实现adapter加载更多的一些处理与rv的映射
|
||||
*
|
||||
* @param recyclerView
|
||||
* @param date rv的数据
|
||||
* @param newData 每次加载回的数控
|
||||
@@ -23,13 +24,9 @@ public class RvAdapter {
|
||||
* @param pageSize
|
||||
* @param <T>
|
||||
*/
|
||||
@BindingAdapter(value = {"date", "newData", "isLode", "error", "pageSize", "loadMoreListener"}, requireAll = false)
|
||||
public static <T> void bindRvData(RecyclerView recyclerView, List<T> date, List<T> newData, boolean isLode,
|
||||
Throwable throwable, int pageSize, BaseQuickAdapter.RequestLoadMoreListener loadMoreListener) {
|
||||
@BindingAdapter(value = {"date", "newData", "isLode", "error", "pageSize"}, requireAll = false)
|
||||
public static <T, R> void bindRvData(RecyclerView recyclerView, List<T> date, List<R> newData, boolean isLode, Throwable throwable, int pageSize) {
|
||||
BaseAdapter adapter = (BaseAdapter) recyclerView.getAdapter();
|
||||
if (loadMoreListener != null) {
|
||||
adapter.setOnLoadMoreListener(loadMoreListener, recyclerView);
|
||||
}
|
||||
adapter.setNewData(date);
|
||||
if (throwable != null) {
|
||||
adapter.loadMoreFail();
|
||||
@@ -43,9 +40,5 @@ public class RvAdapter {
|
||||
adapter.loadMoreComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter(value = {"refreshAction"}, requireAll = false)
|
||||
public static void refresh(SwipeRefreshLayout refreshLayout, SwipeRefreshLayout.OnRefreshListener listener) {
|
||||
refreshLayout.setOnRefreshListener(listener);
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginTop="15dp"
|
||||
refreshAction="@{viewmodel.onRefreshListener}"
|
||||
android:background="@color/color_FAFAFA"
|
||||
android:refreshing="@{viewmodel.loading}">
|
||||
|
||||
@@ -37,7 +36,6 @@
|
||||
isLode="@{viewmodel.isLode}"
|
||||
newData="@{viewmodel.loadData}"
|
||||
pageSize="@{viewmodel.pageSize}"
|
||||
loadMoreListener="@{viewmodel.loadMoreListener}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.61'
|
||||
|
||||
println "\n\n\n"
|
||||
println '当前选择版本 Version Name:'+ version_name
|
||||
@@ -13,11 +14,12 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath 'com.android.tools.build:gradle:3.6.2'
|
||||
//realm 数据库插件
|
||||
classpath "io.realm:realm-gradle-plugin:5.3.0"
|
||||
// android 资源混淆插件
|
||||
classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.15'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'realm-android'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
@@ -123,4 +125,9 @@ dependencies {
|
||||
api project(':nim_uikit')
|
||||
api project(':library')
|
||||
api project(':agora-ktv-kit-release')
|
||||
implementation "androidx.core:core-ktx:+"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
@@ -0,0 +1,26 @@
|
||||
package com.yizhuan.xchat_android_core.community
|
||||
|
||||
import com.yizhuan.xchat_android_core.decoration.headwear.bean.HeadWearInfo
|
||||
import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils
|
||||
import java.io.Serializable
|
||||
|
||||
|
||||
data class UserVo(
|
||||
var erbanNo: Long = 0,
|
||||
var uid: Long = 0,
|
||||
var birth: Long = 0,
|
||||
var nick: String? = null,
|
||||
var gender: Int = 0,
|
||||
var avatar: String? = null,
|
||||
var isHasRegPacket: Boolean = false,
|
||||
var userHeadwear: HeadWearInfo? = null
|
||||
) : Serializable {
|
||||
var age : Int = 0
|
||||
get() {
|
||||
if (field != 0) return field
|
||||
val current = CurrentTimeUtils.getCurrentTime()
|
||||
var age = current - birth
|
||||
age = age / 1000 / 60 / 60 / 24 / 365
|
||||
return if (age >= 0) age.toInt() else 0
|
||||
}
|
||||
}
|
@@ -67,6 +67,7 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_MODULE_HALL;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_PUBLIC_CHAT_HALL;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_QUEUING_MIC;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_GIFT_VALUE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SHARE_FAMILY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SHARE_MINI_WORLD;
|
||||
@@ -82,6 +83,11 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_PUBLIC_CHAT_HALL_AIT_ME;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_PUBLIC_CHAT_HALL_FULL_SCREEN;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_PUBLIC_CHAT_HALL_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_DIAMOND;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_MSG;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_RECEIVE_LUCKY_MONEY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_ADD_BLACK;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_KICK_ROOM;
|
||||
@@ -405,6 +411,20 @@ public class CustomAttachParser implements MsgAttachmentParser {
|
||||
}
|
||||
break;
|
||||
|
||||
case CUSTOM_MSG_RED_PACKAGE:
|
||||
switch (second) {
|
||||
case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_GIFT:
|
||||
case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_DIAMOND:
|
||||
case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_GIFT:
|
||||
case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND:
|
||||
attachment = new RedPackageAttachment(second);
|
||||
break;
|
||||
case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_MSG:
|
||||
attachment = new RedPackageRoomMsgAttachment(second);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CUSTOM_MSG_LEAVE_MODE:
|
||||
if (second == CUSTOM_MSG_LEAVE_MODE_NOTICE) {
|
||||
attachment = new LeaveModeAttachment();
|
||||
|
@@ -288,7 +288,6 @@ public class CustomAttachment implements MsgAttachment {
|
||||
public static final int CUSTOM_MSG_ROOM_FOLLOW_2 = 467;//在房间的公屏上关注房主,第二个
|
||||
public static final int CUSTOM_MSG_ROOM_FOLLOW_SUCCESS = 468;//在房间的关注房主,第二个
|
||||
|
||||
|
||||
//全服广播
|
||||
public static final int CUSTOM_MSG_HEADER_ALL_SERVICE_PUSH = 49;
|
||||
public static final int CUSTOM_MSG_SUB_TYPE_PUSH_APP_TO_UPDATE = 491;//推送App更新消息
|
||||
@@ -339,9 +338,17 @@ public class CustomAttachment implements MsgAttachment {
|
||||
public static final int CUSTOM_MSG_HEADER_TYPE_COMMON_SYS_NOTICATION = 58;
|
||||
public static final int CUSTOM_MSG_SUB_TYPE_FIRST_RECHARGE_SUCCESS = 581; //首充成功
|
||||
|
||||
//收藏房间
|
||||
//收藏房间消息
|
||||
public static final int CUSTOM_MSG_HEADER_TYPE_FOLLOW_ROOM = 59;
|
||||
public static final int CUSTOM_MSG_SUB_TYPE_FOLLOW_ROOM_SUCCESS = 591; //首充成功
|
||||
public static final int CUSTOM_MSG_SUB_TYPE_FOLLOW_ROOM_SUCCESS = 591;
|
||||
|
||||
//红包消息
|
||||
public static final int CUSTOM_MSG_RED_PACKAGE = 60;
|
||||
public static final int CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_GIFT = 601;
|
||||
public static final int CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_DIAMOND = 602;
|
||||
public static final int CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_GIFT = 603;
|
||||
public static final int CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND = 604;
|
||||
public static final int CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_MSG = 605;
|
||||
|
||||
|
||||
public CustomAttachment() {
|
||||
|
@@ -0,0 +1,33 @@
|
||||
package com.yizhuan.xchat_android_core.im.custom.bean;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.yinyuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* Created by MadisonRong on 17/06/2018.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class RedPackageAttachment extends CustomAttachment {
|
||||
|
||||
private RedPackageNotifyInfo redPackageNotifyInfo;
|
||||
|
||||
public RedPackageAttachment(int second) {
|
||||
super(CUSTOM_MSG_RED_PACKAGE, second);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseData(JSONObject data) {
|
||||
redPackageNotifyInfo = new Gson().fromJson(data.toJSONString(), RedPackageNotifyInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject packData() {
|
||||
String jsonStr = new Gson().toJson(redPackageNotifyInfo);
|
||||
return JSONObject.parseObject(jsonStr);
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package com.yizhuan.xchat_android_core.im.custom.bean;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.yinyuan.xchat_android_core.redpackage.RedEnvelopeRoomMsg;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* Created by MadisonRong on 17/06/2018.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class RedPackageRoomMsgAttachment extends CustomAttachment {
|
||||
|
||||
private RedEnvelopeRoomMsg redEnvelopeRoomMsg;
|
||||
|
||||
public RedPackageRoomMsgAttachment(int second) {
|
||||
super(CUSTOM_MSG_RED_PACKAGE, second);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseData(JSONObject data) {
|
||||
redEnvelopeRoomMsg = new Gson().fromJson(data.toJSONString(), RedEnvelopeRoomMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject packData() {
|
||||
String jsonStr = new Gson().toJson(redEnvelopeRoomMsg);
|
||||
return JSONObject.parseObject(jsonStr);
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package com.yinyuan.xchat_android_core.redpackage
|
||||
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo
|
||||
|
||||
|
||||
data class RedEnvelopeGiftItemVO(
|
||||
var giftNum: Int = 0,
|
||||
var giftVo: GiftInfo? = null
|
||||
)
|
@@ -0,0 +1,11 @@
|
||||
package com.yinyuan.xchat_android_core.redpackage
|
||||
|
||||
import com.yizhuan.xchat_android_core.community.UserVo
|
||||
|
||||
|
||||
class RedEnvelopeItemVO(
|
||||
var amount: String,
|
||||
var createTime: Long = 0,
|
||||
var redEnvelopeGiftItemVOs: List<RedEnvelopeGiftItemVO>? = null,
|
||||
var userVO: UserVo
|
||||
)
|
@@ -0,0 +1,40 @@
|
||||
package com.yinyuan.xchat_android_core.redpackage
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
/**
|
||||
* 开红包发送公屏信息
|
||||
*/
|
||||
data class RedEnvelopeRoomMsg(
|
||||
|
||||
/**
|
||||
* 开红包者 uid
|
||||
*/
|
||||
var openRedEnvelopeId: String = "",
|
||||
|
||||
/**
|
||||
* 开红包者昵称
|
||||
*/
|
||||
var openRedEnvelopeUserNick: String = "",
|
||||
|
||||
/**
|
||||
* 红包类型
|
||||
*/
|
||||
var redEnvelopeType: Int = 0,
|
||||
|
||||
/**
|
||||
* 红包金额
|
||||
*/
|
||||
var amount: Double = 0.0,
|
||||
|
||||
/**
|
||||
* 红包主人 uid
|
||||
*/
|
||||
var redEnvelopeMasterId: Long = 0,
|
||||
|
||||
/**
|
||||
* 红包主人昵称
|
||||
*/
|
||||
var redEnvelopeMasterNick: String = ""
|
||||
|
||||
) : Serializable
|
@@ -0,0 +1,23 @@
|
||||
package com.yinyuan.xchat_android_core.redpackage
|
||||
|
||||
/**
|
||||
* 红包状态
|
||||
*/
|
||||
interface RedEnvelopeState {
|
||||
companion object {
|
||||
/**
|
||||
* ING(1, “开抢中”)
|
||||
* TIME_OUT(2, “过时”)
|
||||
* REMAIN_ZERO(3, “抢光了”)
|
||||
* SUCCESS(4, “抢到了”)
|
||||
* WILL(5, “将要开始”)
|
||||
* TIME_OUT_BACK(6, “超时已退还”)
|
||||
*/
|
||||
const val ING = 1
|
||||
const val TIME_OUT = 2
|
||||
const val REMAIN_ZERO = 3
|
||||
const val SUCCESS = 4
|
||||
const val WILL = 5
|
||||
const val TIME_OUT_BACK = 6
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.yinyuan.xchat_android_core.redpackage
|
||||
|
||||
import com.yizhuan.xchat_android_core.community.UserVo
|
||||
|
||||
|
||||
data class RedEnvelopeVO(
|
||||
var beginTime: Long = 0,
|
||||
var createTime: Long = 0,
|
||||
var endTime: Long = 0,
|
||||
var id: String,
|
||||
var message: String,
|
||||
var redEnvelopeAmount: Double = 0.0,
|
||||
var roomUId: Long = 0,
|
||||
/**
|
||||
* 红包类型 1:房间水晶红包 2:全服水晶红包 3:房间礼物红包 4:全服礼物红包
|
||||
*/
|
||||
var type: Int = 0,
|
||||
var updateTime: Long = 0,
|
||||
var userId: Long = 0,
|
||||
var totalNum: String = "",
|
||||
var pickNum: String = "",
|
||||
var userVO: UserVo? = null
|
||||
)
|
@@ -0,0 +1,18 @@
|
||||
package com.yinyuan.xchat_android_core.redpackage
|
||||
|
||||
|
||||
data class RedPackageInfo(
|
||||
var redEnvelopeItemVOs: List<RedEnvelopeItemVO>? = null,
|
||||
var redEnvelopeVO: RedEnvelopeVO? = null,
|
||||
|
||||
/**
|
||||
* ING(1, “开抢中”)
|
||||
* TIME_OUT(2, “过时”)
|
||||
* REMAIN_ZERO(3, “抢光了”)
|
||||
* SUCCESS(4, “抢到了”)
|
||||
* WILL(5, “将要开始”)
|
||||
* TIME_OUT_BACK(6, “超时已退还”)
|
||||
*/
|
||||
var redEnvelopeState: Int = 0
|
||||
|
||||
)
|
@@ -0,0 +1,82 @@
|
||||
package com.yinyuan.xchat_android_core.redpackage
|
||||
|
||||
|
||||
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult
|
||||
import com.yizhuan.xchat_android_core.utils.net.handleBeanData
|
||||
import com.yizhuan.xchat_android_core.utils.net.handleStringData
|
||||
import com.yizhuan.xchat_android_core.utils.net.io2main
|
||||
import com.yizhuan.xchat_android_library.net.rxnet.RxNet
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Single
|
||||
import retrofit2.http.*
|
||||
|
||||
object RedPackageModel {
|
||||
|
||||
|
||||
private val api: Api
|
||||
|
||||
init {
|
||||
api = RxNet.create(Api::class.java)
|
||||
}
|
||||
|
||||
fun sendRedPackage(goldNum: String, message: String, num: String, roomUId: String, type: Int, password: String): Single<String> {
|
||||
return api.sendRedPackage(goldNum, message, num, roomUId, type, password)
|
||||
.io2main()
|
||||
.handleStringData()
|
||||
}
|
||||
|
||||
|
||||
fun openRedPackage(redEnvelopeId: String): Single<RedPackageInfo> {
|
||||
return api.openRedPackage(redEnvelopeId)
|
||||
.io2main()
|
||||
.handleBeanData()
|
||||
}
|
||||
|
||||
fun getRedPackage(uid: Long): Observable<RedPackageNotifyInfo> {
|
||||
return api.getRedPackage(uid)
|
||||
.io2main()
|
||||
.handleBeanData()
|
||||
.toObservable()
|
||||
.flatMap { Observable.fromIterable(it) }
|
||||
.map { RedPackageNotifyInfo(it.id, it.type, it.message, it.userVO?.avatar?:"", it.userVO?.nick?:"", it.roomUId, "") }
|
||||
}
|
||||
|
||||
private interface Api {
|
||||
|
||||
/**
|
||||
* 发红包
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/red-envelope")
|
||||
fun sendRedPackage(@Field("goldNum") goldNum: String,
|
||||
@Field("message") message: String,
|
||||
@Field("num") num: String,
|
||||
@Field("roomUId") roomUId: String,
|
||||
@Field("type") type: Int,
|
||||
@Field("password") password: String): Single<ServiceResult<String>>
|
||||
|
||||
/**
|
||||
* 开红包
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/red-envelope/open")
|
||||
fun openRedPackage(@Field("redEnvelopeId") redEnvelopeId: String): Single<ServiceResult<RedPackageInfo>>
|
||||
|
||||
|
||||
/**
|
||||
* 当前可以领取的红包
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GET("/room/red-envelop")
|
||||
fun getRedPackage(@Query("uid") uid: Long): Single<ServiceResult<List<RedEnvelopeVO>>>
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,41 @@
|
||||
package com.yinyuan.xchat_android_core.redpackage
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
data class RedPackageNotifyInfo(
|
||||
|
||||
/**
|
||||
* 红包 id
|
||||
*/
|
||||
var redEnvelopeId: String = "",
|
||||
|
||||
/**
|
||||
* 红包类型
|
||||
*/
|
||||
var redEnvelopeType: Int = 0,
|
||||
|
||||
/**
|
||||
* 红包消息
|
||||
*/
|
||||
var redEnvelopeMessage: String = "",
|
||||
|
||||
/**
|
||||
* 红包发送者头像
|
||||
*/
|
||||
var sendUserAvatar: String = "",
|
||||
|
||||
/**
|
||||
* 红包发送者昵称
|
||||
*/
|
||||
var sendUserNick: String = "",
|
||||
/**
|
||||
* 房间uid
|
||||
*/
|
||||
var roomUid: Long = 0,
|
||||
|
||||
/**
|
||||
* 房间名称
|
||||
*/
|
||||
var roomTitle: String = ""
|
||||
|
||||
) : Serializable
|
@@ -0,0 +1,6 @@
|
||||
package com.yinyuan.xchat_android_core.redpackage
|
||||
|
||||
const val ROOM_DIAMOND = 1
|
||||
const val ROOM_GIFT = 3
|
||||
const val ALL_DIAMOND = 2
|
||||
const val ALL_GIFT = 4
|
@@ -0,0 +1,15 @@
|
||||
package com.yizhuan.xchat_android_core.utils;
|
||||
|
||||
public class CurrentTimeUtils {
|
||||
|
||||
private static long offsetTime;
|
||||
|
||||
public static void initTime(long currentTime) {
|
||||
if (currentTime == 0) return;
|
||||
offsetTime = System.currentTimeMillis() - currentTime;
|
||||
}
|
||||
|
||||
public static long getCurrentTime() {
|
||||
return System.currentTimeMillis() - offsetTime;
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package com.yizhuan.xchat_android_core.utils
|
||||
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
|
||||
|
||||
fun String?.subAndReplaceDot(maxLength: Int = 6): String {
|
||||
if (this == null) return ""
|
||||
return if (this.length > maxLength) this.substring(0, maxLength) + "..." else this
|
||||
}
|
||||
|
||||
fun String?.toIntOrDef(def: Int = 0): Int {
|
||||
return this?.toIntOrNull() ?: def
|
||||
}
|
||||
|
||||
fun String?.toDoubleOrDef(def: Double = 0.0): Double {
|
||||
return this?.toDoubleOrNull() ?: def
|
||||
}
|
||||
|
||||
fun String?.toast() {
|
||||
SingleToastUtil.showToast(this)
|
||||
}
|
||||
|
||||
inline fun String?.ifNullOrEmpty(defaultValue: () -> String): String =
|
||||
if (this.isNullOrEmpty()) defaultValue() else this
|
@@ -0,0 +1,80 @@
|
||||
package com.yizhuan.xchat_android_core.utils.net
|
||||
|
||||
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult
|
||||
import com.yizhuan.xchat_android_core.utils.ifNullOrEmpty
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
* 这里简单对接口脱掉外层,不适合成功情况下没有data字段的接口使用
|
||||
*
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
|
||||
fun <T> Single<ServiceResult<T>>.handleBeanData(): Single<T> {
|
||||
return this.handleException()
|
||||
.flatMap {
|
||||
if (it.isSuccess) {
|
||||
if (it.data != null) {
|
||||
return@flatMap Single.just(it.data)
|
||||
} else {
|
||||
return@flatMap Single.error<T>(Throwable("成功情况下接口返回data字段可以为空,不适合使用此方法脱掉外层。"))
|
||||
}
|
||||
} else {
|
||||
return@flatMap Single.error<T>(Throwable(it.message.ifNullOrEmpty { "未知错误" }))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* data是String的接口服务器返回的data可能是空的,写个String专用的,主要是进行了判空处理...
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
fun Single<ServiceResult<String>>.handleStringData(): Single<String> {
|
||||
return this.handleException()
|
||||
.flatMap {
|
||||
if (it.isSuccess) {
|
||||
return@flatMap Single.just(it.data.ifNullOrEmpty { "成功" })
|
||||
} else {
|
||||
return@flatMap Single.error<String>(Throwable(it.message.ifNullOrEmpty { "未知错误" }))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一IOException处理,请求接口报IOException基本是网络不正常导致的
|
||||
*
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
|
||||
fun <T> Single<T>.handleException(): Single<T> {
|
||||
return this.onErrorResumeNext {
|
||||
if (it is IOException) {
|
||||
return@onErrorResumeNext Single.error(Throwable("网络异常,请检查您的网络再试..."))
|
||||
}
|
||||
Single.error(it)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口线程调度
|
||||
*
|
||||
* @param <T>
|
||||
* @return
|
||||
</T> */
|
||||
fun <T> Single<T>.io2main(): Single<T> {
|
||||
return this.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ org.gradle.daemon=true
|
||||
# org.gradle.parallel=true
|
||||
android.enableD8=true
|
||||
android.injected.testOnly=false
|
||||
|
||||
android.useNewApkCreator=false
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
with_jenkins=false
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
|
||||
|
@@ -1,4 +1,5 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
@@ -85,5 +86,10 @@ dependencies {
|
||||
api "com.qiniu:qiniu-android-sdk:${qiniu}"
|
||||
|
||||
api "org.greenrobot:eventbus:${eventbusVersion}"
|
||||
implementation "androidx.core:core-ktx:+"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
@@ -1,4 +1,6 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
@@ -67,5 +69,10 @@ dependencies {
|
||||
annotationProcessor "com.github.bumptech.glide:compiler:${glideVersion}"
|
||||
|
||||
implementation project(':library')
|
||||
implementation "androidx.core:core-ktx:+"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
Reference in New Issue
Block a user