1:添加炼仙传说功能
2:修改混淆,
This commit is contained in:
@@ -44,7 +44,6 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = '11'
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
// exclude 'lib/arm64-v8a/libagora-fdkaac.so'
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.xscm.moduleutil.base
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.voice.lib_base.ext.inflateBindingWithGeneric
|
||||
import com.xscm.moduleutil.R
|
||||
|
||||
|
||||
open class BaseBottomFragmentDialog<B : ViewBinding?>(private val resourceID: Int) :
|
||||
DialogFragment() {
|
||||
var mDatabind: B? = null
|
||||
val mBinding: B get() = mDatabind!!
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = Dialog(requireActivity(), R.style.myChooseDialog)
|
||||
mDatabind = DataBindingUtil.inflate(LayoutInflater.from(requireContext()), resourceID, null, false) as B
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setContentView(mBinding!!.root)
|
||||
val window = dialog.window
|
||||
val params = window!!.attributes
|
||||
params.width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
params.height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
params.gravity = Gravity.BOTTOM
|
||||
window.attributes = params
|
||||
dialog.setCanceledOnTouchOutside(true)
|
||||
return dialog
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
mDatabind = inflateBindingWithGeneric(inflater, container, false)
|
||||
// return if (mBinding != null) mBinding!!.root else mDatabind?.root
|
||||
return mBinding?.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
WindowCompat.setDecorFitsSystemWindows(requireDialog().window!!, false)
|
||||
requireDialog().setOnShowListener { dialog: DialogInterface? ->
|
||||
(view.parent as ViewGroup).setBackgroundColor(
|
||||
Color.TRANSPARENT
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
mDatabind = null
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun setBundleArgs(bundleArgs: Bundle?): BaseBottomFragmentDialog<B> {
|
||||
arguments = bundleArgs
|
||||
return this
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.voice.lib_base.base.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.voice.lib_base.ext.inflateBindingWithGeneric
|
||||
import com.xscm.moduleutil.R
|
||||
|
||||
open class BaseFragmentDialog<B : ViewBinding?>(private val resourceID: Int) : DialogFragment() {
|
||||
var mDatabind: B? = null
|
||||
val mBinding: B get() = mDatabind!!
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = Dialog(requireActivity(), R.style.myChooseDialog)
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
mDatabind = DataBindingUtil.inflate<ViewDataBinding>(LayoutInflater.from(requireContext()), resourceID, null, false) as B
|
||||
dialog.setContentView(mDatabind!!.root)
|
||||
val window = dialog.window
|
||||
val params = window!!.attributes
|
||||
params.width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
params.height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
window.attributes = params
|
||||
dialog.setCanceledOnTouchOutside(true)
|
||||
return dialog
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
mDatabind = inflateBindingWithGeneric(inflater, container, false)
|
||||
return if (mBinding != null) mBinding!!.root else null
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
WindowCompat.setDecorFitsSystemWindows(requireDialog().window!!, false)
|
||||
requireDialog().setOnShowListener { dialog: DialogInterface? ->
|
||||
(view.parent as ViewGroup).setBackgroundColor(
|
||||
Color.TRANSPARENT
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
mDatabind = null
|
||||
}
|
||||
|
||||
|
||||
fun setBundleArgs(bundleArgs: Bundle?): BaseFragmentDialog<B> {
|
||||
arguments = bundleArgs
|
||||
return this
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.xscm.moduleutil.base
|
||||
|
||||
import androidx.lifecycle.*
|
||||
import com.xscm.moduleutil.http.RetrofitClient
|
||||
import com.xscm.moduleutil.widget.room.PassRoomException
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.MultipartBody
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
open class BaseViewModel : ViewModel(), LifecycleObserver {
|
||||
private var clickTime: Long = 0
|
||||
var baseRepository = RetrofitClient.getInstance()
|
||||
|
||||
private val passRoom by lazy { MutableLiveData<Exception>() }
|
||||
|
||||
private val error by lazy { MutableLiveData<Exception>() }
|
||||
|
||||
private val finally by lazy { MutableLiveData<Int>() }
|
||||
|
||||
|
||||
|
||||
|
||||
//进入房间
|
||||
|
||||
var imgListData: MutableLiveData<List<String>> = MutableLiveData()
|
||||
var addImgData = MutableLiveData<Any>()
|
||||
|
||||
|
||||
//运行在UI线程的协程
|
||||
fun launchUI(block: suspend CoroutineScope.() -> Unit) = viewModelScope.launch {
|
||||
try {
|
||||
block()
|
||||
} catch (e: Exception) {
|
||||
if (e is PassRoomException) {
|
||||
passRoom.value = e
|
||||
} else {
|
||||
error.value = e
|
||||
// throw e
|
||||
}
|
||||
|
||||
} finally {
|
||||
finally.value = 200
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求失败,出现异常
|
||||
*/
|
||||
fun getError(): LiveData<Exception> {
|
||||
return error
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求完成,在此处做一些关闭操作
|
||||
*/
|
||||
fun getFinally(): LiveData<Int> {
|
||||
return finally
|
||||
}
|
||||
|
||||
}
|
||||
@@ -137,13 +137,13 @@ public class CommonAppContext extends MultiDexApplication implements Application
|
||||
@Getter
|
||||
public UnreadCountEvent unreadCountEvent;
|
||||
|
||||
public static int selectRelease = 1;
|
||||
public static int selectRelease = -1;
|
||||
|
||||
public int is_open = 0;//主题的开关
|
||||
|
||||
public String appId = "com.qxcm.qxlive";
|
||||
public String appVersionCode = "87";
|
||||
public String appVersionName = "1.0.9.7";
|
||||
public String appVersionCode = "88";
|
||||
public String appVersionName = "1.0.9.8";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.xscm.moduleutil.base;
|
||||
|
||||
public class RealTimeMessages<T> {
|
||||
|
||||
public T data;
|
||||
|
||||
public int code;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.xscm.moduleutil.base
|
||||
|
||||
|
||||
data class SocketBean(
|
||||
val code: Int, val data: Any
|
||||
)
|
||||
@@ -66,6 +66,7 @@ public class RoomSettingBean implements MultiItemEntity {
|
||||
public static final int QXRoomSettingTypeRoomTimeRedSound = 35;//红包声音
|
||||
|
||||
public static final int QXRoomSettingTypeRoomBusinessTime = 37;//营业时间
|
||||
public static final int QXRoomSettingTypeRoomBusinessLegend = 38;//炼仙传说
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.xscm.moduleutil.bean.room.refining
|
||||
|
||||
|
||||
data class BoxJiangChiBean(
|
||||
var gid: String = "",
|
||||
var gift_name: String = "",
|
||||
var gift_price: String = "",
|
||||
var base_image: String = "",
|
||||
var play_image: String = ""
|
||||
)
|
||||
|
||||
|
||||
|
||||
data class MonsterLogBean(
|
||||
val add_time: Int,
|
||||
val id: Int,
|
||||
val is_evil_wind: Int,
|
||||
val is_join: Int,
|
||||
val win_type: Int,
|
||||
val win_type_data: List<WinTypeData>,
|
||||
val join_data: List<WinTypeData>,
|
||||
|
||||
val base_image: String,
|
||||
val gift_name: String,
|
||||
val gift_price: Int,
|
||||
val num: Int,
|
||||
val type_name: String,
|
||||
)
|
||||
|
||||
|
||||
data class WinTypeData(
|
||||
val type: Int, val type_name: String,
|
||||
val num: Int
|
||||
)
|
||||
|
||||
|
||||
data class MonsterUserLogBean(
|
||||
val add_time: Int,
|
||||
val base64_nick_name: String,
|
||||
val base_image: String,
|
||||
val gift_name: String,
|
||||
val gift_price: String,
|
||||
val head_pic: String,
|
||||
val id: Int,
|
||||
val mid: Int,
|
||||
val nick_name: String,
|
||||
val num: Int,
|
||||
val type_name: String,
|
||||
val uid: Int,
|
||||
val win_type: Int
|
||||
)
|
||||
|
||||
data class MonsterInfoBean(
|
||||
val integral: String,
|
||||
val is_finsh: Int,
|
||||
val multiple_list: List<Multiple>,
|
||||
val open_monster_price: String,
|
||||
val surplus_time: Int,
|
||||
val win_number: Int
|
||||
)
|
||||
|
||||
data class Multiple(
|
||||
val id: Int,
|
||||
val multiple: Double,
|
||||
val type_name: String,
|
||||
val num: Int,
|
||||
val type: Int
|
||||
)
|
||||
|
||||
data class MonsterResultBean(
|
||||
val head_pic: String,
|
||||
val id: String,
|
||||
val integral: String,
|
||||
val nick_name: String,
|
||||
val num: Int,
|
||||
val price: Int,
|
||||
val type: String,
|
||||
val type_name: String,
|
||||
val uid: Int
|
||||
)
|
||||
|
||||
data class MonsterEndBean(
|
||||
val game_name: String,
|
||||
val gift_name: String,
|
||||
val is_finsh: Int,
|
||||
val is_push_message: Int,
|
||||
val multiple_list: List<Multiple>,
|
||||
val num: Int,
|
||||
val surplus_time: Int,
|
||||
val total_gift_price: Int,
|
||||
val win_count: Int,
|
||||
val win_number: Int,
|
||||
val win_type_name: String
|
||||
)
|
||||
|
||||
data class OpenMonsterBean(
|
||||
val base_image: String, // 礼物图片
|
||||
val gid: Int, // 礼物id
|
||||
val gift_name: String, // 礼物名称
|
||||
val gift_price: String, // 礼物价格
|
||||
val is_win: Int,// 是否中奖 2未中奖 1中奖
|
||||
val num: Int, // 中奖数量
|
||||
val total_gift_price: Int, // 总价格
|
||||
val type_name: String, // 中奖类型
|
||||
val win_type: Int // 中奖类型
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,11 @@ import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.bean.room.*;
|
||||
import com.xscm.moduleutil.bean.room.refining.BoxJiangChiBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterInfoBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterLogBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterResultBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterUserLogBean;
|
||||
import com.xscm.moduleutil.bean.zhuangb.ZhuangBanShangChengBean;
|
||||
import com.xscm.moduleutil.utils.cos.TempKeyBean;
|
||||
import com.xscm.moduleutil.widget.Constants;
|
||||
@@ -540,6 +545,25 @@ public interface ApiServer {
|
||||
@POST(Constants.SET_USER_DECORATE)
|
||||
Call<BaseModel<String>> setUserDecorate(@Field("udid") String udid);
|
||||
|
||||
@GET(Constants.GET_MONSTER_INFO_BOX)
|
||||
Call<BaseModel<MonsterInfoBean>> get_monster_info_box();
|
||||
|
||||
@GET(Constants.GET_OPEN_BEAT_MONSTER)
|
||||
Call<BaseModel<MonsterResultBean>> open_beat_monster(@Query("rid")String rid,@Query("type") String type,@Query("num") String num);
|
||||
|
||||
@GET(Constants.GET_MONSTER_BOX_LIST)
|
||||
Call<BaseModel<List<BoxJiangChiBean>>> get_monster_box_list();
|
||||
|
||||
@GET(Constants.GET_USER_MONSTER_LOG)
|
||||
Call<BaseModel<List<MonsterUserLogBean>>> get_user_monster_log(@Query("page")String page);
|
||||
|
||||
@GET(Constants.GET_MONSTER_LOG)
|
||||
Call<BaseModel<List<MonsterLogBean>>> get_monster_log(@Query("page")String page,@Query("page_limit")String page_limit);
|
||||
|
||||
@GET(Constants.GET_MONSTER_NOTE)
|
||||
Call<BaseModel<String>> get_monster_note();
|
||||
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_CANCEL_USER_DECORATE)
|
||||
Call<BaseModel<String>> cancelUserDecorate(@Field("type") String type);
|
||||
|
||||
@@ -22,6 +22,11 @@ import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.bean.room.*;
|
||||
import com.xscm.moduleutil.bean.room.refining.BoxJiangChiBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterInfoBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterLogBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterResultBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterUserLogBean;
|
||||
import com.xscm.moduleutil.bean.zhuangb.ZhuangBanShangChengBean;
|
||||
import com.xscm.moduleutil.listener.CPListener;
|
||||
import com.xscm.moduleutil.listener.JoinRoomErrorListener;
|
||||
@@ -1299,7 +1304,7 @@ public class RetrofitClient {
|
||||
}
|
||||
|
||||
public void roomHotCard(String udid, String room_id, String num, BaseObserver<String> observer) {
|
||||
sApiServer.roomHotCard(udid, room_id, num).enqueue(new Callback<BaseModel<String>>(){
|
||||
sApiServer.roomHotCard(udid, room_id, num).enqueue(new Callback<BaseModel<String>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
|
||||
@@ -1313,7 +1318,7 @@ public class RetrofitClient {
|
||||
} else if (baseModel.getCode() == 0) {
|
||||
ToastUtils.showLong(baseModel.getMsg());
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
ToastUtils.showLong("使用热度卡出现错误", response.code());
|
||||
LogUtils.e("roomHotCard", response.message());
|
||||
}
|
||||
@@ -2326,7 +2331,8 @@ public class RetrofitClient {
|
||||
|
||||
/**
|
||||
* 礼物标签表
|
||||
* @param type 1:房间获取标签 2:打赏,不要热度卡 3:
|
||||
*
|
||||
* @param type 1:房间获取标签 2:打赏,不要热度卡 3:
|
||||
* @param observer
|
||||
*/
|
||||
|
||||
@@ -2357,7 +2363,8 @@ public class RetrofitClient {
|
||||
|
||||
/**
|
||||
* 获取礼物列表
|
||||
* @param type 0:只获取热门礼物和普通礼物 99:拍卖卡关系选择礼物 100:歌单礼物
|
||||
*
|
||||
* @param type 0:只获取热门礼物和普通礼物 99:拍卖卡关系选择礼物 100:歌单礼物
|
||||
* @param roomId
|
||||
* @param observer
|
||||
*/
|
||||
@@ -2962,7 +2969,7 @@ public class RetrofitClient {
|
||||
// sApiServer.getSubsidyDetail(roomId).compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
}
|
||||
|
||||
public void getPersonaltyList(String from,BaseObserver<List<PersonaltyBean>> observer) {
|
||||
public void getPersonaltyList(String from, BaseObserver<List<PersonaltyBean>> observer) {
|
||||
sApiServer.getPersonaltyList(from).enqueue(new Callback<BaseModel<List<PersonaltyBean>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<List<PersonaltyBean>>> call, Response<BaseModel<List<PersonaltyBean>>> response) {
|
||||
@@ -3120,7 +3127,7 @@ public class RetrofitClient {
|
||||
} else {
|
||||
MessageListenerSingleton.getInstance().quitGroup(roomId);
|
||||
}
|
||||
if (joinRoomErrorListener != null){
|
||||
if (joinRoomErrorListener != null) {
|
||||
joinRoomErrorListener.onJoinRoomError(roomInfoRespBaseModel.getCode(), roomInfoRespBaseModel.getMsg());
|
||||
}
|
||||
}
|
||||
@@ -4132,8 +4139,8 @@ public class RetrofitClient {
|
||||
}
|
||||
|
||||
|
||||
public void editRoom(String room_id, String room_name, String room_cover, String room_intro, String room_background,String roomPwd, BaseObserver<String> observer) {
|
||||
sApiServer.editRoom(room_id, room_name, room_cover, room_intro, room_background,roomPwd).enqueue(new Callback<BaseModel<String>>() {
|
||||
public void editRoom(String room_id, String room_name, String room_cover, String room_intro, String room_background, String roomPwd, BaseObserver<String> observer) {
|
||||
sApiServer.editRoom(room_id, room_name, room_cover, room_intro, room_background, roomPwd).enqueue(new Callback<BaseModel<String>>() {
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
|
||||
onNextRetu(response, observer);
|
||||
@@ -4715,10 +4722,10 @@ public class RetrofitClient {
|
||||
} else if (baseModel.getCode() == 301) {
|
||||
setCode301(baseModel.getMsg());
|
||||
} else {
|
||||
ToastUtils.showShort(baseModel.getMsg());
|
||||
// ToastUtils.showShort(baseModel.getMsg());
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showShort("盲盒转盘失败,", response.code());
|
||||
ToastUtils.showShort("暂无活动,", response.code());
|
||||
LogUtils.e("盲盒转盘", response.message());
|
||||
}
|
||||
}
|
||||
@@ -5034,8 +5041,8 @@ public class RetrofitClient {
|
||||
});
|
||||
}
|
||||
|
||||
public void checkTxt(String room_name, String room_cover, String room_intro,String roomPwd, BaseObserver<String> observer) {
|
||||
sApiServer.checkTxt(room_name, room_cover, room_intro,roomPwd).enqueue(new Callback<ResponseBody>() {
|
||||
public void checkTxt(String room_name, String room_cover, String room_intro, String roomPwd, BaseObserver<String> observer) {
|
||||
sApiServer.checkTxt(room_name, room_cover, room_intro, roomPwd).enqueue(new Callback<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
|
||||
if (response.code() == 200) {
|
||||
@@ -5079,6 +5086,199 @@ public class RetrofitClient {
|
||||
});
|
||||
}
|
||||
|
||||
public void get_monster_info_box(BaseObserver<MonsterInfoBean> observer) {
|
||||
sApiServer.get_monster_info_box().enqueue(new Callback<BaseModel<MonsterInfoBean>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<MonsterInfoBean>> call, Response<BaseModel<MonsterInfoBean>> response) {
|
||||
if (response.code() == 200) {
|
||||
BaseModel<MonsterInfoBean> baseModel = response.body();
|
||||
if (baseModel.getCode() == 1) {
|
||||
observer.onNext(baseModel.getData());
|
||||
} else if (baseModel.getCode() == 301) {
|
||||
setCode301(baseModel.getMsg());
|
||||
} else {
|
||||
ToastUtils.showShort(baseModel.getMsg());
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showShort("请求错误:" + response.code());
|
||||
LogUtils.e("get_monster_info_box", response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<MonsterInfoBean>> call, Throwable t) {
|
||||
LogUtils.e("get_monster_info_box", t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void open_beat_monster(String rid, String type, String num, BaseObserver<MonsterResultBean> observer) {
|
||||
sApiServer.open_beat_monster(rid, type, num).enqueue(new Callback<BaseModel<MonsterResultBean>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<MonsterResultBean>> call, Response<BaseModel<MonsterResultBean>> response) {
|
||||
if (response.code() == 200) {
|
||||
BaseModel<MonsterResultBean> baseModel = response.body();
|
||||
if (baseModel.getCode() == 1) {
|
||||
if (baseModel.getData() != null) {
|
||||
observer.onNext(baseModel.getData());
|
||||
}
|
||||
} else if (baseModel.getCode() == 301) {
|
||||
setCode301(baseModel.getMsg());
|
||||
} else {
|
||||
ToastUtils.showShort(baseModel.getMsg());
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showShort("请求错误:" + response.code());
|
||||
LogUtils.e("open_beat_monster", response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<MonsterResultBean>> call, Throwable t) {
|
||||
LogUtils.e("open_beat_monster", t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void get_monster_box_list(BaseObserver<List<BoxJiangChiBean>> observer) {
|
||||
sApiServer.get_monster_box_list().enqueue(new Callback<BaseModel<List<BoxJiangChiBean>>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<List<BoxJiangChiBean>>> call, Response<BaseModel<List<BoxJiangChiBean>>> response) {
|
||||
if (response.code() == 200) {
|
||||
BaseModel<List<BoxJiangChiBean>> baseModel = response.body();
|
||||
if (baseModel.getCode() == 1) {
|
||||
if (baseModel.getData() != null) {
|
||||
observer.onNext(baseModel.getData());
|
||||
}else {
|
||||
observer.onNext(new ArrayList<>());
|
||||
}
|
||||
} else if (baseModel.getCode() == 301) {
|
||||
setCode301(baseModel.getMsg());
|
||||
} else {
|
||||
ToastUtils.showShort(baseModel.getMsg());
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showShort("请求错误:" + response.code());
|
||||
LogUtils.e("get_monster_box_list", response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<List<BoxJiangChiBean>>> call, Throwable t) {
|
||||
LogUtils.e("get_monster_box_list", t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void get_user_monster_log(String page, BaseObserver<List<MonsterUserLogBean>> observer) {
|
||||
sApiServer.get_user_monster_log(page).enqueue(new Callback<BaseModel<List<MonsterUserLogBean>>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<List<MonsterUserLogBean>>> call, Response<BaseModel<List<MonsterUserLogBean>>> response) {
|
||||
if (response.code() == 200) {
|
||||
BaseModel<List<MonsterUserLogBean>> baseModel = response.body();
|
||||
// if (baseModel != null) {
|
||||
// observer.onNext(baseModel);
|
||||
// } else {
|
||||
// observer.onNext(new ArrayList<>());
|
||||
// }
|
||||
if (baseModel.getCode() == 1) {
|
||||
if (baseModel.getData()!=null) {
|
||||
observer.onNext(baseModel.getData());
|
||||
}else {
|
||||
observer.onNext(new ArrayList<>());
|
||||
}
|
||||
} else if (baseModel.getCode() == 301) {
|
||||
setCode301(baseModel.getMsg());
|
||||
} else {
|
||||
ToastUtils.showShort(baseModel.getMsg());
|
||||
}
|
||||
} else
|
||||
ToastUtils.showShort("请求错误:" + response.code());
|
||||
LogUtils.e("get_user_monster_log", response.message());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<List<MonsterUserLogBean>>> call, Throwable t) {
|
||||
LogUtils.e("get_user_monster_log", t.fillInStackTrace());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void get_monster_log(String page, BaseObserver<List<MonsterLogBean>> observer) {
|
||||
sApiServer.get_monster_log(page, "20").enqueue(new Callback<BaseModel<List<MonsterLogBean>>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<List<MonsterLogBean>>> call, Response<BaseModel<List<MonsterLogBean>>> response) {
|
||||
if (response.code() == 200) {
|
||||
BaseModel<List<MonsterLogBean>> baseModel = response.body();
|
||||
// if (baseModel != null) {
|
||||
// observer.onNext(baseModel);
|
||||
// } else {
|
||||
// observer.onNext(new ArrayList<>());
|
||||
// }
|
||||
if (baseModel.getCode() == 1) {
|
||||
if (baseModel.getData()!=null) {
|
||||
observer.onNext(baseModel.getData());
|
||||
}else {
|
||||
observer.onNext(new ArrayList<>());
|
||||
}
|
||||
} else if (baseModel.getCode() == 301)
|
||||
setCode301(baseModel.getMsg());
|
||||
else {
|
||||
ToastUtils.showShort(baseModel.getMsg());
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showShort("请求错误:" + response.code());
|
||||
LogUtils.e("get_monster_log", response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<List<MonsterLogBean>>> call, Throwable t) {
|
||||
LogUtils.e("get_monster_log", t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void get_monster_note(BaseObserver<String> observer) {
|
||||
sApiServer.get_monster_note().enqueue(new Callback<BaseModel<String>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
|
||||
|
||||
if (response.code() == 200) {
|
||||
BaseModel<String> baseModel = response.body();
|
||||
if (baseModel.getCode()==1){
|
||||
if (baseModel.getData()!=null){
|
||||
observer.onNext(baseModel.getData());
|
||||
}else {
|
||||
observer.onNext("");
|
||||
}
|
||||
}else if (baseModel.getCode() == 301) {
|
||||
setCode301(baseModel.getMsg());
|
||||
}else if (baseModel.getCode() == 0) {
|
||||
ToastUtils.showShort(baseModel.getMsg());
|
||||
}
|
||||
|
||||
}else {
|
||||
ToastUtils.showShort("请求错误:" + response.code());
|
||||
LogUtils.e("get_monster_note", response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
|
||||
LogUtils.e("get_monster_note", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void cancelUserDecorate(String type, BaseObserver<String> observer) {
|
||||
sApiServer.cancelUserDecorate(type).enqueue(new Callback<BaseModel<String>>() {
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,7 @@ public class MqttConnect {
|
||||
public static String qx_hour_ranking = "";
|
||||
|
||||
public static String qx_redpacket_arrive = "";//红包飘屏的主题
|
||||
public static String qx_xianxuan = "";//炼仙传说推送
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
String[] topic;
|
||||
int[] qos = {1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // 消息质量
|
||||
@@ -50,12 +51,14 @@ public class MqttConnect {
|
||||
update_app = "qx_xunlehui"; // 巡乐会飘屏
|
||||
qx_hour_ranking = "qx_hour_ranking";//小时榜飘屏
|
||||
qx_redpacket_arrive = "qx_redpacket_arrive"; //红包飘屏的主题
|
||||
qx_xianxuan = "qx_xianxuan"; //红包飘屏的主题
|
||||
|
||||
ArrayList<String> topicList = new ArrayList<>();
|
||||
topicList.add(shutdown);
|
||||
topicList.add(update_app);
|
||||
topicList.add(qx_hour_ranking);
|
||||
topicList.add(qx_redpacket_arrive);
|
||||
topicList.add(qx_xianxuan);
|
||||
topic = topicList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@@ -93,6 +96,7 @@ public class MqttConnect {
|
||||
sub(update_app);
|
||||
sub(qx_hour_ranking);
|
||||
sub(qx_redpacket_arrive);
|
||||
sub(qx_xianxuan);
|
||||
|
||||
// UI操作回到主线程
|
||||
ActivityUtils.getTopActivity().runOnUiThread(() -> uiTip("MQTT连接成功"));
|
||||
|
||||
@@ -6,9 +6,16 @@ import android.os.Looper;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.xscm.moduleutil.base.RealTimeMessages;
|
||||
import com.xscm.moduleutil.base.SocketBean;
|
||||
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
||||
import com.xscm.moduleutil.bean.XLHBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterEndBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterInfoBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.OpenMonsterBean;
|
||||
import com.xscm.moduleutil.event.HourlyBean;
|
||||
import com.xscm.moduleutil.event.RedBean;
|
||||
import com.xscm.moduleutil.event.RoomGiftRunable;
|
||||
@@ -59,6 +66,51 @@ public class MqttInitCallback implements MqttCallback {
|
||||
receiveQXHourRanking(topic, messageStr);
|
||||
} else if (topic.equals("qx_redpacket_arrive")) {
|
||||
receiveRed(topic, messageStr);
|
||||
} else if (topic.equals("qx_xianxuan")) {
|
||||
receiveXianxuanMessage(messageStr);
|
||||
}
|
||||
}
|
||||
|
||||
private void receiveXianxuanMessage(String messageStr) {
|
||||
try {
|
||||
JSONObject jsonObject = JSON.parseObject(messageStr);
|
||||
String message = jsonObject.getString("msg");
|
||||
// 将事件处理放到主线程执行
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
processXianxuanMessage(message);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("MQTT", "解析MQTT消息异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void processXianxuanMessage(String message) {
|
||||
SocketBean dataList = GsonUtils.fromJson(message, SocketBean.class);
|
||||
switch (dataList.getCode()) {
|
||||
case 3031:
|
||||
RealTimeMessages<MonsterInfoBean> monsterInfo = GsonUtils.fromJson(
|
||||
message,
|
||||
new TypeToken<RealTimeMessages<MonsterInfoBean>>() {}.getType()
|
||||
);
|
||||
EventBus.getDefault().post(monsterInfo.data);
|
||||
break;
|
||||
case 3032:
|
||||
RealTimeMessages<OpenMonsterBean> openMonster =
|
||||
GsonUtils.fromJson(
|
||||
message,
|
||||
new TypeToken<RealTimeMessages<OpenMonsterBean>>() {}.getType()
|
||||
);
|
||||
EventBus.getDefault().post(openMonster.data);
|
||||
break;
|
||||
case 3033:
|
||||
RealTimeMessages<MonsterEndBean> monsterEndBean =
|
||||
GsonUtils.fromJson(
|
||||
message,
|
||||
new TypeToken<RealTimeMessages<MonsterEndBean>>() {}.getType()
|
||||
);
|
||||
EventBus.getDefault().post(monsterEndBean.data);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.xscm.moduleutil.utils
|
||||
|
||||
import androidx.lifecycle.LifecycleCoroutineScope
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
import java.text.DecimalFormat
|
||||
|
||||
object CountDownUtil {
|
||||
/**
|
||||
* 倒计时的实现
|
||||
*/
|
||||
fun countDown(lifecycleScope: LifecycleCoroutineScope,
|
||||
time: Int = 5,
|
||||
start: (scop: CoroutineScope) -> Unit,
|
||||
end: () -> Unit,
|
||||
next: (time: Int) -> Unit
|
||||
) {
|
||||
lifecycleScope.launch {
|
||||
// 在这个范围内启动的协程会在Lifecycle被销毁的时候自动取消
|
||||
flow {
|
||||
(time downTo 0).forEach {
|
||||
delay(1000)
|
||||
emit(it)
|
||||
}
|
||||
}.onStart {
|
||||
// 倒计时开始 ,在这里可以让Button 禁止点击状态
|
||||
start(this@launch)
|
||||
}.onCompletion {
|
||||
// 倒计时结束 ,在这里可以让Button 恢复点击状态
|
||||
end()
|
||||
}.catch {
|
||||
//错误
|
||||
// YYLogUtils.e(it.message ?: "Unkown Error")
|
||||
}.collect {
|
||||
// 在这里 更新值来显示到UI
|
||||
next(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun formatCountDownTime(milliseconds: Long): String {
|
||||
val sb = StringBuilder()
|
||||
val mss = milliseconds * 1000 / 1000
|
||||
val days = mss / (60 * 60 * 24)
|
||||
val hours = mss % (60 * 60 * 24) / (60 * 60)
|
||||
val minutes = mss % (60 * 60) / 60
|
||||
val seconds = mss % 60
|
||||
val format = DecimalFormat("00")
|
||||
if (days > 0 || hours > 0) {
|
||||
sb.append(format.format(hours)).append(":").append(format.format(minutes)).append(":")
|
||||
.append(format.format(seconds))
|
||||
} else {
|
||||
sb.append(format.format(minutes)).append(":").append(format.format(seconds))
|
||||
}
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
142
BaseModule/src/main/java/com/xscm/moduleutil/utils/TTSManager.kt
Normal file
142
BaseModule/src/main/java/com/xscm/moduleutil/utils/TTSManager.kt
Normal file
@@ -0,0 +1,142 @@
|
||||
package com.xscm.moduleutil.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.speech.tts.TextToSpeech
|
||||
import android.speech.tts.UtteranceProgressListener
|
||||
import java.util.LinkedList
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* 项目名称:羽声语音
|
||||
* 时间:2025/12/6 11:00
|
||||
* 用途:
|
||||
*/
|
||||
class TTSManager private constructor(context: Context) :
|
||||
TextToSpeech.OnInitListener {
|
||||
|
||||
companion object {
|
||||
@Volatile
|
||||
private var instance: TTSManager? = null
|
||||
|
||||
fun getInstance(context: Context): TTSManager {
|
||||
return instance ?: synchronized(this) {
|
||||
instance ?: TTSManager(context.applicationContext).also {
|
||||
instance = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var tts: TextToSpeech? = null
|
||||
private var isInitialized = false
|
||||
private val pendingQueue = LinkedList<String>()
|
||||
private var currentLanguage = Locale.CHINESE
|
||||
|
||||
init {
|
||||
initTTS(context)
|
||||
}
|
||||
|
||||
private fun initTTS(context: Context) {
|
||||
tts = TextToSpeech(context, this).apply {
|
||||
setOnUtteranceProgressListener(object : UtteranceProgressListener() {
|
||||
override fun onStart(utteranceId: String?) {
|
||||
// 开始朗读
|
||||
}
|
||||
|
||||
override fun onDone(utteranceId: String?) {
|
||||
// 朗读完成
|
||||
}
|
||||
|
||||
override fun onError(utteranceId: String?) {
|
||||
// 发生错误
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInit(status: Int) {
|
||||
isInitialized = if (status == TextToSpeech.SUCCESS) {
|
||||
setLanguage(currentLanguage)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
if (isInitialized) {
|
||||
processPendingQueue()
|
||||
}
|
||||
}
|
||||
|
||||
fun speak(text: String, flush: Boolean = true) {
|
||||
if (!isInitialized || tts == null) {
|
||||
pendingQueue.add(text)
|
||||
return
|
||||
}
|
||||
|
||||
val utteranceId = System.currentTimeMillis().toString()
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
val params = Bundle().apply {
|
||||
putString(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, utteranceId)
|
||||
}
|
||||
tts?.speak(text,
|
||||
if (flush) TextToSpeech.QUEUE_FLUSH else TextToSpeech.QUEUE_ADD,
|
||||
params,
|
||||
utteranceId)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
val params = HashMap<String, String>()
|
||||
params[TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID] = utteranceId
|
||||
tts?.speak(text,
|
||||
if (flush) TextToSpeech.QUEUE_FLUSH else TextToSpeech.QUEUE_ADD,
|
||||
params)
|
||||
}
|
||||
}
|
||||
|
||||
fun setLanguage(locale: Locale): Boolean {
|
||||
currentLanguage = locale
|
||||
return if (isInitialized) {
|
||||
tts?.setLanguage(locale) == TextToSpeech.LANG_COUNTRY_AVAILABLE
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
tts?.stop()
|
||||
}
|
||||
|
||||
fun pause() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
tts?.stop()
|
||||
}
|
||||
}
|
||||
|
||||
fun resume() {
|
||||
// 根据需要实现
|
||||
}
|
||||
|
||||
fun setSpeechRate(rate: Float) {
|
||||
tts?.setSpeechRate(rate)
|
||||
}
|
||||
|
||||
fun setPitch(pitch: Float) {
|
||||
tts?.setPitch(pitch)
|
||||
}
|
||||
|
||||
private fun processPendingQueue() {
|
||||
while (pendingQueue.isNotEmpty()) {
|
||||
speak(pendingQueue.poll())
|
||||
}
|
||||
}
|
||||
|
||||
fun release() {
|
||||
tts?.stop()
|
||||
tts?.shutdown()
|
||||
tts = null
|
||||
isInitialized = false
|
||||
instance = null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.voice.lib_base.ext
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.lang.reflect.ParameterizedType
|
||||
|
||||
/**
|
||||
* 作者 : QIngNing
|
||||
* 时间 : 2021/12/21
|
||||
* 描述 :
|
||||
*/
|
||||
|
||||
@JvmName("inflateWithGeneric")
|
||||
fun <VB : ViewBinding> AppCompatActivity.inflateBindingWithGeneric(layoutInflater: LayoutInflater): VB =
|
||||
withGenericBindingClass<VB>(this) { clazz ->
|
||||
clazz.getMethod("inflate", LayoutInflater::class.java).invoke(null, layoutInflater) as VB
|
||||
}.also { binding ->
|
||||
if (binding is ViewDataBinding) {
|
||||
binding.lifecycleOwner = this
|
||||
}
|
||||
}
|
||||
|
||||
@JvmName("inflateWithGeneric")
|
||||
fun <VB : ViewBinding> Fragment.inflateBindingWithGeneric(layoutInflater: LayoutInflater, parent: ViewGroup?, attachToParent: Boolean): VB =
|
||||
withGenericBindingClass<VB>(this) { clazz ->
|
||||
clazz.getMethod("inflate", LayoutInflater::class.java, ViewGroup::class.java, Boolean::class.java)
|
||||
.invoke(null, layoutInflater, parent, attachToParent) as VB
|
||||
}.also { binding ->
|
||||
if (binding is ViewDataBinding) {
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
}
|
||||
|
||||
private fun <VB : ViewBinding> withGenericBindingClass(any: Any, block: (Class<VB>) -> VB): VB {
|
||||
var genericSuperclass = any.javaClass.genericSuperclass
|
||||
var superclass = any.javaClass.superclass
|
||||
while (superclass != null) {
|
||||
if (genericSuperclass is ParameterizedType) {
|
||||
try {
|
||||
return block.invoke(genericSuperclass.actualTypeArguments[0] as Class<VB>)
|
||||
|
||||
} catch (e: NoSuchMethodException) {
|
||||
} catch (e: ClassCastException) {
|
||||
} catch (e: InvocationTargetException) {
|
||||
throw e.targetException
|
||||
}
|
||||
}
|
||||
genericSuperclass = superclass.genericSuperclass
|
||||
superclass = superclass.superclass
|
||||
}
|
||||
throw IllegalArgumentException("There is no generic of ViewBinding.")
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.Connection;
|
||||
@@ -54,7 +55,7 @@ public class DataLoggingInterceptor implements Interceptor {
|
||||
|
||||
logger.reset();
|
||||
logger.log(sLogStartFlag);
|
||||
logger.log(sFormatLine);
|
||||
// logger.log("2\n"+sFormatLine);
|
||||
|
||||
RequestBody requestBody = request.body();
|
||||
boolean hasRequestBody = requestBody != null;
|
||||
@@ -62,17 +63,17 @@ public class DataLoggingInterceptor implements Interceptor {
|
||||
Connection connection = chain.connection();
|
||||
Protocol protocol = connection != null ? connection.protocol() : Protocol.HTTP_1_1;
|
||||
// request.url().encodedPath() 这是只展示最后的url地址,没有带有前面的https对应的域名,只是展示路径
|
||||
String requestStartMessage = request.method() + " " + request.url().encodedPath() + " " + protocol;
|
||||
logger.log(requestStartMessage);
|
||||
String requestStartMessage = request.method() + " " + Arrays.toString(request.url().encodedPath().split("/api/")) + " " + protocol;
|
||||
// logger.log("3\n"+requestStartMessage);
|
||||
|
||||
if (hasRequestBody) {
|
||||
// Request body headers are only present when installed as a network interceptor. Force
|
||||
// them to be included (when available) so there values are known.
|
||||
if (requestBody.contentType() != null) {
|
||||
logger.log("Content-Type: " + requestBody.contentType());
|
||||
// logger.log("4\n"+ "Content-Type: " + requestBody.contentType());
|
||||
}
|
||||
if (requestBody.contentLength() != -1) {
|
||||
logger.log("Content-Length: " + requestBody.contentLength());
|
||||
// logger.log("5\n"+"Content-Length: " + requestBody.contentLength());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,14 +82,14 @@ public class DataLoggingInterceptor implements Interceptor {
|
||||
String name = rHeaders.name(i);
|
||||
// Skip headers from the request body as they are explicitly logged above.
|
||||
if (!"Content-Type".equalsIgnoreCase(name) && !"Content-Length".equalsIgnoreCase(name)) {
|
||||
logger.log(name + ": " + rHeaders.value(i));
|
||||
// logger.log("6\n"+name + ": " + rHeaders.value(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasRequestBody) {
|
||||
logger.log("END " + request.method());
|
||||
// logger.log("7\n"+"END " + request.method());
|
||||
} else if (bodyEncoded(request.headers())) {
|
||||
logger.log("END " + request.method() + " (encoded body omitted)");
|
||||
// logger.log("8\n"+"END " + request.method() + " (encoded body omitted)");
|
||||
} else {
|
||||
Buffer buffer = new Buffer();
|
||||
requestBody.writeTo(buffer);
|
||||
@@ -100,35 +101,35 @@ public class DataLoggingInterceptor implements Interceptor {
|
||||
}
|
||||
|
||||
if (charset != null) {
|
||||
logger.log(sFormatLine);
|
||||
// logger.log("9\n"+sFormatLine);
|
||||
if (isPlaintext(buffer)) {
|
||||
try {
|
||||
String requestStr = URLDecoder.decode(buffer.readString(charset), "UTF-8");
|
||||
String[] strs = requestStr.split("&");
|
||||
for (String str : strs) {
|
||||
logger.log(str);
|
||||
// logger.log("10\n"+str);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(buffer.readString(charset));
|
||||
logger.log("11\n"+buffer.readString(charset));
|
||||
}
|
||||
logger.log("END " + request.method()
|
||||
+ " (" + requestBody.contentLength() + "-byte body)");
|
||||
// logger.log("12\n"+"END " + request.method()
|
||||
// + " (" + requestBody.contentLength() + "-byte body)");
|
||||
} else {
|
||||
logger.log("END " + request.method() + " (binary "
|
||||
+ requestBody.contentLength() + "-byte body omitted)");
|
||||
// logger.log("13\n"+"END " + request.method() + " (binary "
|
||||
// + requestBody.contentLength() + "-byte body omitted)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(sFormatLine);
|
||||
// logger.log("14\n"+sFormatLine);
|
||||
|
||||
long startNs = System.nanoTime();
|
||||
Response response;
|
||||
try {
|
||||
response = chain.proceed(request);
|
||||
} catch (Exception e) {
|
||||
logger.log("HTTP FAILED: " + e);
|
||||
logger.log(sLogEndFlag);
|
||||
logger.log("15\n"+"HTTP FAILED: " + e);
|
||||
// logger.log(sLogEndFlag);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -137,21 +138,19 @@ public class DataLoggingInterceptor implements Interceptor {
|
||||
if (responseBody != null) {
|
||||
long contentLength = responseBody.contentLength();
|
||||
String bodySize = contentLength != -1 ? contentLength + "-byte" : "unknown-length";
|
||||
// logger.log(response.code() + " " + response.message() + " "
|
||||
// + response.request().url() + " (" + tookMs + "ms)");
|
||||
|
||||
logger.log(response.code() + " " + response.message() + " "
|
||||
+ response.request().url().encodedPath() + " → " + response.networkResponse().request().url().encodedPath() + " (" + tookMs + "ms)");
|
||||
logger.log("17\n"+response.code() + " " + response.message() + " "
|
||||
+ Arrays.toString(response.request().url().encodedPath().split("/api/")) + " → " + Arrays.toString(response.networkResponse().request().url().encodedPath().split("/api/")) + " (" + tookMs + "ms)");
|
||||
|
||||
Headers headers = response.headers();
|
||||
for (int i = 0, count = headers.size(); i < count; i++) {
|
||||
logger.log(headers.name(i) + ": " + headers.value(i));
|
||||
}
|
||||
// Headers headers = response.headers();
|
||||
// for (int i = 0, count = headers.size(); i < count; i++) {
|
||||
// logger.log("18\n"+headers.name(i) + ": " + headers.value(i));
|
||||
// }
|
||||
|
||||
if (!HttpHeaders.hasBody(response)) {
|
||||
logger.log("END HTTP");
|
||||
// logger.log("19\n"+"END HTTP");
|
||||
} else if (bodyEncoded(response.headers())) {
|
||||
logger.log("END HTTP (encoded body omitted)");
|
||||
// logger.log("20\n"+"END HTTP (encoded body omitted)");
|
||||
} else {
|
||||
BufferedSource source = responseBody.source();
|
||||
if (source.isOpen()) {
|
||||
@@ -165,26 +164,26 @@ public class DataLoggingInterceptor implements Interceptor {
|
||||
}
|
||||
|
||||
if (!isPlaintext(buffer)) {
|
||||
logger.log("END HTTP (binary " + buffer.size() + "-byte body omitted)");
|
||||
logger.log(sFormatLine);
|
||||
// logger.log("21\n"+"END HTTP (binary " + buffer.size() + "-byte body omitted)");
|
||||
// logger.log("22\n"+sFormatLine);
|
||||
logger.log(sLogEndFlag);
|
||||
return response;
|
||||
}
|
||||
|
||||
if (contentLength != 0 && charset != null) {
|
||||
logger.log(sFormatLine);
|
||||
// logger.log("24\n"+sFormatLine);
|
||||
//这是展示返回的数据日志
|
||||
// logger.log(buffer.clone().readString(charset));
|
||||
}
|
||||
|
||||
logger.log("END HTTP (" + buffer.size() + "-byte body)");
|
||||
// logger.log("25\n"+"END HTTP (" + buffer.size() + "-byte body)");
|
||||
} else {
|
||||
logger.log("END HTTP");
|
||||
// logger.log("26\n"+"END HTTP");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(sFormatLine);
|
||||
logger.log("27\n"+sFormatLine);
|
||||
logger.log(sLogEndFlag);
|
||||
|
||||
return response;
|
||||
|
||||
@@ -273,6 +273,15 @@ public class Constants {
|
||||
public static final String GET_PIT_TIME = "/api/BarRoom/get_pit_time_list";//酒吧房麦位时长列表
|
||||
public static final String POST_BLACK_ROOM_LIST = "/api/BarRoom/black_room_list";//小黑屋(酒吧房,交友小屋)列表
|
||||
|
||||
//炼仙传说
|
||||
public static final String GET_MONSTER_INFO_BOX = "/api/Monster/get_monster_info";//
|
||||
public static final String GET_OPEN_BEAT_MONSTER = "/api/monster/open_beat_monster";//
|
||||
public static final String GET_MONSTER_BOX_LIST = "/api/monster/get_monster_box_list";//
|
||||
public static final String GET_USER_MONSTER_LOG = "/api/monster/get_user_monster_log";//
|
||||
public static final String GET_MONSTER_LOG = "/api/monster/get_monster_log";//
|
||||
public static final String GET_MONSTER_NOTE = "/api/monster/get_monster_note";//
|
||||
|
||||
|
||||
public static final String UPDATEPASSWORD = "/api/room/setRoomPassword";//更新房间秘密啊
|
||||
public static final String GET_ROOM_ONLINE = "/api/Room/room_online_list";//房间在线列表
|
||||
public static final String GET_SJ_ROOM_NAME = "/api/Room/room_random_name";//随机房间名称
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
package com.xscm.moduleutil.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.xscm.moduleutil.R;
|
||||
|
||||
|
||||
/**
|
||||
* 小熊猫展示的金额,是在炼仙传说中使用的
|
||||
*/
|
||||
|
||||
public class ShapeRedTextView extends TextView {
|
||||
private final int SHAPE_RECTANGEL = 0;
|
||||
private final int SHAPE_OVAL = 1;
|
||||
|
||||
private int shape;
|
||||
private int solidNormalColor;
|
||||
private int solidPressedColor;
|
||||
private float cornersRadius;
|
||||
private float cornersTopLeft;
|
||||
private float cornersTopRight;
|
||||
private float cornersBottomLeft;
|
||||
private float cornersBottomRight;
|
||||
|
||||
// 渐变颜色属性
|
||||
private int gradientNormalStartColor;
|
||||
private int gradientNormalCenterColor;
|
||||
private int gradientNormalEndColor;
|
||||
|
||||
private int gradientPressedStartColor;
|
||||
private int gradientPressedCenterColor;
|
||||
private int gradientPressedEndColor;
|
||||
|
||||
private int gradientOrientation;
|
||||
|
||||
private float strokeWidth;
|
||||
private int strokeColor;
|
||||
|
||||
private int defaultColor = Color.parseColor("#00000000");
|
||||
private GradientDrawable.Orientation[] orientations;
|
||||
|
||||
public ShapeRedTextView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ShapeRedTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ShapeTextView);
|
||||
shape = array.getInteger(R.styleable.ShapeTextView_shape, SHAPE_RECTANGEL);
|
||||
|
||||
|
||||
solidNormalColor = array.getColor(R.styleable.ShapeTextView_solidNormal, defaultColor);
|
||||
solidPressedColor = array.getColor(R.styleable.ShapeTextView_solidPressed, defaultColor);
|
||||
|
||||
|
||||
cornersRadius = array.getDimension(R.styleable.ShapeTextView_cornersRadius, 0);
|
||||
|
||||
cornersTopLeft = array.getDimension(R.styleable.ShapeTextView_cornerTopLeft, 0);
|
||||
cornersTopRight = array.getDimension(R.styleable.ShapeTextView_cornerTopRight, 0);
|
||||
cornersBottomLeft = array.getDimension(R.styleable.ShapeTextView_cornerBottomLeft, 0);
|
||||
cornersBottomRight = array.getDimension(R.styleable.ShapeTextView_cornerBottomRight, 0);
|
||||
|
||||
strokeWidth = array.getDimension(R.styleable.ShapeTextView_strokeWidth, 0);
|
||||
|
||||
strokeColor = array.getColor(R.styleable.ShapeTextView_strokeColor, defaultColor);
|
||||
|
||||
gradientNormalStartColor = array.getColor(R.styleable.ShapeTextView_gradientNormalStartColor, defaultColor);
|
||||
|
||||
gradientNormalCenterColor = array.getColor(R.styleable.ShapeTextView_gradientNormalCenterColor, defaultColor);
|
||||
|
||||
gradientNormalEndColor = array.getColor(R.styleable.ShapeTextView_gradientNormalEndColor, defaultColor);
|
||||
|
||||
|
||||
gradientPressedStartColor = array.getColor(R.styleable.ShapeTextView_gradientPressedStartColor, defaultColor);
|
||||
gradientPressedCenterColor = array.getColor(R.styleable.ShapeTextView_gradientPressedCenterColor, defaultColor);
|
||||
gradientPressedEndColor = array.getColor(R.styleable.ShapeTextView_gradientPressedEndColor, defaultColor);
|
||||
|
||||
|
||||
TypedArray orientationArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeTextView);
|
||||
|
||||
gradientOrientation = orientationArray.getInteger(R.styleable.ShapeTextView_gradientOrientation, 6);
|
||||
|
||||
array.recycle();
|
||||
|
||||
|
||||
orientations = new GradientDrawable.Orientation[]{
|
||||
GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
GradientDrawable.Orientation.TR_BL,
|
||||
GradientDrawable.Orientation.RIGHT_LEFT,
|
||||
GradientDrawable.Orientation.BR_TL,
|
||||
GradientDrawable.Orientation.BOTTOM_TOP,
|
||||
GradientDrawable.Orientation.BL_TR,
|
||||
GradientDrawable.Orientation.LEFT_RIGHT,
|
||||
GradientDrawable.Orientation.TL_BR
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
setShape();
|
||||
}
|
||||
|
||||
private void setShape() {
|
||||
setGravity(Gravity.CENTER);
|
||||
setClickable(true);
|
||||
// normal state
|
||||
GradientDrawable drawableNormal = new GradientDrawable();
|
||||
// 设置Shape
|
||||
drawableNormal.setShape(shape);
|
||||
// 设置圆角半径
|
||||
drawableNormal.setCornerRadius(cornersRadius);
|
||||
// 圆角半径(每个圆角半径的值)
|
||||
if (cornersRadius == 0) {
|
||||
drawableNormal.setCornerRadii(new float[]{
|
||||
cornersTopLeft, cornersTopLeft,
|
||||
cornersTopRight, cornersTopRight,
|
||||
cornersBottomRight, cornersBottomRight,
|
||||
cornersBottomLeft, cornersBottomLeft});
|
||||
}
|
||||
//描边的宽度和颜色
|
||||
drawableNormal.setStroke((int) strokeWidth, strokeColor);
|
||||
//设置填充色
|
||||
if (solidNormalColor != defaultColor) {
|
||||
drawableNormal.setColor(solidNormalColor);
|
||||
} else {
|
||||
// 设置渐变色
|
||||
int[] gradientColors;
|
||||
if (gradientNormalStartColor != defaultColor && gradientNormalEndColor != defaultColor) {
|
||||
gradientColors = new int[]{gradientNormalStartColor, gradientNormalEndColor};
|
||||
if (gradientNormalCenterColor != defaultColor) {
|
||||
gradientColors = new int[]{gradientNormalStartColor, gradientNormalCenterColor, gradientNormalEndColor};
|
||||
}
|
||||
drawableNormal.setColors(gradientColors);
|
||||
|
||||
|
||||
drawableNormal.setOrientation(orientations[gradientOrientation]);
|
||||
} else {
|
||||
drawableNormal.setColor(solidNormalColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// pressed state
|
||||
GradientDrawable drawablePressed = new GradientDrawable();
|
||||
drawablePressed.setShape(shape);
|
||||
drawablePressed.setCornerRadius(cornersRadius);
|
||||
if (cornersRadius == 0) {
|
||||
drawablePressed.setCornerRadii(new float[]{
|
||||
cornersTopLeft, cornersTopLeft,
|
||||
cornersTopRight, cornersTopRight,
|
||||
cornersBottomRight, cornersBottomRight,
|
||||
cornersBottomLeft, cornersBottomLeft});
|
||||
}
|
||||
|
||||
drawablePressed.setStroke((int) strokeWidth, strokeColor);
|
||||
|
||||
drawablePressed.setColor(solidPressedColor);
|
||||
|
||||
// 设置背景选择器
|
||||
StateListDrawable stateListDrawable = new StateListDrawable();
|
||||
|
||||
if (solidPressedColor != defaultColor) {
|
||||
stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, drawablePressed);
|
||||
}
|
||||
int[] gradientPressdColors;
|
||||
if (gradientPressedStartColor != defaultColor && gradientPressedEndColor != defaultColor) {
|
||||
gradientPressdColors = new int[]{gradientPressedStartColor, gradientPressedEndColor};
|
||||
if (gradientPressedCenterColor != defaultColor) {
|
||||
gradientPressdColors = new int[]{gradientPressedStartColor, gradientPressedCenterColor, gradientPressedEndColor};
|
||||
}
|
||||
|
||||
drawablePressed.setColors(gradientPressdColors);
|
||||
drawablePressed.setOrientation(orientations[gradientOrientation]);
|
||||
stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, drawablePressed);
|
||||
|
||||
}
|
||||
|
||||
if (isEnabled()) {
|
||||
setAlpha(1.0f);
|
||||
} else {
|
||||
setAlpha(0.7f);
|
||||
}
|
||||
stateListDrawable.addState(new int[]{}, drawableNormal);
|
||||
|
||||
setBackground(stateListDrawable);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_selected="true" android:drawable="@mipmap/box_num_bg1"/>
|
||||
<item android:state_selected="false" android:drawable="@mipmap/box_num_bg2"/>
|
||||
</selector>
|
||||
BIN
BaseModule/src/main/res/mipmap-xxhdpi/box_num_bg1.webp
Normal file
BIN
BaseModule/src/main/res/mipmap-xxhdpi/box_num_bg1.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.0 KiB |
BIN
BaseModule/src/main/res/mipmap-xxhdpi/box_num_bg2.webp
Normal file
BIN
BaseModule/src/main/res/mipmap-xxhdpi/box_num_bg2.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
BaseModule/src/main/res/mipmap-xxhdpi/lxcs_iocn.webp
Normal file
BIN
BaseModule/src/main/res/mipmap-xxhdpi/lxcs_iocn.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
@@ -531,4 +531,37 @@
|
||||
<attr name="btnTextSize" format="dimension"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="ShapeTextView">
|
||||
<attr name="shape" format="enum">
|
||||
<enum name="rectangle" value="0" />
|
||||
<enum name="oval" value="1" />
|
||||
</attr>
|
||||
<attr name="solidNormal" format="color" />
|
||||
<attr name="solidPressed" format="color" />
|
||||
<attr name="cornersRadius" format="dimension" />
|
||||
<attr name="cornerTopLeft" format="dimension" />
|
||||
<attr name="cornerTopRight" format="dimension" />
|
||||
<attr name="cornerBottomLeft" format="dimension" />
|
||||
<attr name="cornerBottomRight" format="dimension" />
|
||||
<attr name="strokeWidth"/>
|
||||
<attr name="strokeColor" />
|
||||
<attr name="gradientNormalStartColor" format="color" />
|
||||
<attr name="gradientNormalCenterColor" format="color" />
|
||||
<attr name="gradientNormalEndColor" format="color" />
|
||||
|
||||
<attr name="gradientPressedStartColor" format="color" />
|
||||
<attr name="gradientPressedCenterColor" format="color" />
|
||||
<attr name="gradientPressedEndColor" format="color" />
|
||||
|
||||
<attr name="gradientOrientation" format="enum">
|
||||
<enum name="TOP_BOTTOM" value="0" />
|
||||
<enum name="TR_BL" value="1" />
|
||||
<enum name="RIGHT_LEFT" value="2" />
|
||||
<enum name="BR_TL" value="3" />
|
||||
<enum name="BOTTOM_TOP" value="4" />
|
||||
<enum name="BL_TR" value="5" />
|
||||
<enum name="LEFT_RIGHT" value="6" />
|
||||
<enum name="TL_BR" value="7" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
@@ -331,5 +331,13 @@
|
||||
<item name="android:textAllCaps">false</item>
|
||||
</style>
|
||||
|
||||
<style name="myChooseDialog" parent="@android:style/Theme.Dialog">
|
||||
<item name="android:windowFrame">@null</item>
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="android:backgroundDimEnabled">true</item>
|
||||
<item name="android:backgroundDimAmount">0.3</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user