Compare commits
124 Commits
molistar_r
...
molistar/d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e4d44155dc | ||
![]() |
06c974a6ed | ||
![]() |
4bfbd19b53 | ||
![]() |
61a26f0c4f | ||
![]() |
e8cfc8a13b | ||
![]() |
295de38074 | ||
![]() |
e3c5f10d02 | ||
![]() |
d949cfa7ff | ||
![]() |
e30f4fd15f | ||
![]() |
90ece5366b | ||
![]() |
555b81589c | ||
![]() |
e4cdc39ad8 | ||
![]() |
09411df1ff | ||
![]() |
9cbc6cf39f | ||
![]() |
444d043aa8 | ||
![]() |
f99d193598 | ||
![]() |
4a57bd50c5 | ||
![]() |
8a59f8a769 | ||
![]() |
2c1ecbb263 | ||
![]() |
aa2987cb0d | ||
![]() |
5e6864d87f | ||
![]() |
6aabeb3eb3 | ||
![]() |
9ff48bc500 | ||
![]() |
e9ba0b1929 | ||
![]() |
adf2adc173 | ||
![]() |
74b2d71821 | ||
![]() |
81a5c6ba65 | ||
![]() |
5f8a8113c6 | ||
![]() |
b0bf9ce98d | ||
![]() |
c3fcbc3942 | ||
![]() |
6e08f397ee | ||
![]() |
3d29568b3c | ||
![]() |
cb4dac8e81 | ||
![]() |
f58701a2d6 | ||
![]() |
654bc45c8c | ||
![]() |
87a36d796c | ||
![]() |
0bc1023c99 | ||
![]() |
154e688673 | ||
![]() |
a91dee592d | ||
![]() |
7ef78bc3e1 | ||
![]() |
b5bcd9cb5f | ||
![]() |
de7eb25045 | ||
![]() |
029b7fcf96 | ||
![]() |
23a3858a2c | ||
![]() |
67044ded6b | ||
![]() |
3e6d34a986 | ||
![]() |
e7ca237a3e | ||
![]() |
e26d548515 | ||
![]() |
539be23e47 | ||
![]() |
dcafb35e24 | ||
![]() |
8fa429aca6 | ||
![]() |
f08b6d4577 | ||
![]() |
3ea7aecd5c | ||
![]() |
178f4e24ef | ||
![]() |
e2861459fb | ||
![]() |
d704a44106 | ||
![]() |
da81a4e905 | ||
![]() |
6c081d9a38 | ||
![]() |
37d897035f | ||
![]() |
cea25c7497 | ||
![]() |
47d2bfd145 | ||
![]() |
047e1454bd | ||
![]() |
714d5baec6 | ||
![]() |
b20ee8064c | ||
![]() |
711135ae90 | ||
![]() |
ecf42e368e | ||
![]() |
205e1180e7 | ||
![]() |
bc48cc86a9 | ||
![]() |
e7b73a2961 | ||
![]() |
5070e21d16 | ||
![]() |
049006aa8b | ||
![]() |
86b498c00e | ||
![]() |
6df95cf11f | ||
![]() |
3b407c0bd6 | ||
![]() |
83af08076a | ||
![]() |
cdc1c51fec | ||
![]() |
a8191616a3 | ||
![]() |
410832690f | ||
![]() |
b1d2f0515b | ||
![]() |
82c2d8c25d | ||
![]() |
549088c99e | ||
![]() |
5910e7c5fd | ||
![]() |
53aed7599a | ||
![]() |
8aebb7c2c2 | ||
![]() |
3a120bf5f0 | ||
![]() |
2a0d8f06fa | ||
![]() |
495bae0d00 | ||
![]() |
2af7cec8dd | ||
![]() |
e9e4da8d60 | ||
![]() |
14c1805a2b | ||
![]() |
066fc4056b | ||
![]() |
f8ad0d3961 | ||
![]() |
0d974866c8 | ||
![]() |
b4f3c4f3e3 | ||
![]() |
f74b744f56 | ||
![]() |
b8f73ec0d5 | ||
![]() |
3ff80994f1 | ||
![]() |
c1426b39c4 | ||
![]() |
3b28974919 | ||
![]() |
63a28bc142 | ||
![]() |
729d626006 | ||
![]() |
a407268be1 | ||
![]() |
f4808e8acf | ||
![]() |
3e49dae43b | ||
![]() |
35d53ccdb2 | ||
![]() |
2a20d75ffd | ||
![]() |
5f157d8454 | ||
![]() |
5fbee068dc | ||
![]() |
046c7d66cd | ||
![]() |
accf4562b1 | ||
![]() |
5b90524144 | ||
![]() |
1284a6e8a2 | ||
![]() |
afdf3093a1 | ||
![]() |
843a37ed97 | ||
![]() |
f99c6d8b37 | ||
![]() |
7add521040 | ||
![]() |
b673f5603f | ||
![]() |
a4f9559ad9 | ||
![]() |
3226109442 | ||
![]() |
3c60225e35 | ||
![]() |
0a70c6a478 | ||
![]() |
16a8f9a52a | ||
![]() |
2a1983aa46 | ||
![]() |
eb187ebc56 |
@@ -117,6 +117,7 @@ android {
|
||||
'src/module_treasure_box/java',
|
||||
'src/module_public_chat/java',
|
||||
'src/module_game/java',
|
||||
'src/module_community/java',
|
||||
|
||||
]
|
||||
|
||||
@@ -133,6 +134,7 @@ android {
|
||||
'src/module_treasure_box/res',
|
||||
'src/module_public_chat/res',
|
||||
'src/module_game/res',
|
||||
'src/module_community/res',
|
||||
|
||||
]
|
||||
|
||||
@@ -203,6 +205,7 @@ dependencies {
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
|
||||
|
||||
api 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'androidx.gridlayout:gridlayout:1.0.0'
|
||||
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
|
||||
|
||||
@@ -219,7 +222,6 @@ dependencies {
|
||||
api "com.jzxiang.pickerview:TimePickerDialog:1.0.1"
|
||||
api "com.github.zyyoona7:EasyPopup:1.0.2"
|
||||
api "com.github.donkingliang:LabelsView:1.6.5"
|
||||
api "com.github.yyued:SVGAPlayer-Android:2.6.1"
|
||||
api "com.ms-square:expandableTextView:0.1.4"
|
||||
annotationProcessor 'androidx.annotation:annotation:1.6.0'
|
||||
|
||||
@@ -269,6 +271,8 @@ dependencies {
|
||||
//wheelView
|
||||
implementation 'com.contrarywind:wheelview:4.1.0'
|
||||
|
||||
// 轮播组件
|
||||
implementation 'io.github.youth5201314:banner:2.2.3'
|
||||
|
||||
implementation project(':modules:module_base')
|
||||
if (!isolationMode && file("../modules/module_google/build.gradle").exists()) {
|
||||
@@ -337,6 +341,16 @@ xmlClassGuard {
|
||||
"com.chwl.core": "com.hhchu.core",
|
||||
"com.chwl.library": "com.hhchu.library"]
|
||||
moveDir = [
|
||||
"com.chwl.app.community.dynamic" : "ffefcef.ddbccaec",
|
||||
"com.chwl.app.community.helper" : "eaeecbea.ccefdeaf",
|
||||
"com.chwl.app.community.holder" : "aafebee.febeeba",
|
||||
"com.chwl.app.community.im" : "eedadfa.cccedea",
|
||||
"com.chwl.app.community.publish" : "ddae.cfdb",
|
||||
"com.chwl.app.community.square" : "bddfb.eedde",
|
||||
"com.chwl.app.community.user_dynamic" : "ddcdbcbc.acbfcfba",
|
||||
"com.chwl.app.community.utils" : "cceaf.cbdcdb",
|
||||
"com.chwl.app.community.widget" : "bdfaa.beeefc",
|
||||
"com.chwl.app.community" : "cadfd.aeddb",
|
||||
"com.chwl.app.avroom.headline" : "eefce.eecad",
|
||||
"com.chwl.core.bean.game" : "caeccd.fdedac",
|
||||
"com.chwl.core.bean.room" : "afceec.aaafbc",
|
||||
|
@@ -82,7 +82,8 @@
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<!-- 对于 Android 12.0 及以上设备,还需要添加如下权限: -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" />
|
||||
<application
|
||||
android:name=".application.App"
|
||||
android:allowBackup="false"
|
||||
@@ -265,6 +266,9 @@
|
||||
android:name=".avroom.activity.RoomSettingActivity"
|
||||
android:label="@string/main_androidmanifest_07"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".avroom.activity.RoomTypeSwitchActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".avroom.activity.RoomBgSettingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@@ -729,8 +733,8 @@
|
||||
android:name=".ui.setting.PermissionGuideActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".vip.VipMainActivity"
|
||||
android:screenOrientation="portrait" /> <!-- 隐私设置 -->
|
||||
android:name=".vip.VipCenterActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".vip.VipSettingActivity"
|
||||
android:screenOrientation="portrait" /> <!-- 通知提醒设置 -->
|
||||
@@ -873,17 +877,22 @@
|
||||
|
||||
<service
|
||||
android:name="com.netease.nimlib.service.NimService"
|
||||
android:foregroundServiceType="remoteMessaging"
|
||||
android:process=":core" />
|
||||
<service
|
||||
android:name="com.netease.nimlib.service.NimService$Aux"
|
||||
android:foregroundServiceType="remoteMessaging"
|
||||
android:process=":core" />
|
||||
<service
|
||||
android:name="com.netease.nimlib.job.NIMJobService"
|
||||
android:foregroundServiceType="remoteMessaging"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE"
|
||||
android:process=":core" />
|
||||
<service android:name="com.netease.nimlib.service.ResponseService" />
|
||||
<service android:name="com.netease.nimlib.service.ResponseService"
|
||||
android:foregroundServiceType="remoteMessaging"/>
|
||||
<service
|
||||
android:name=".service.DaemonService"
|
||||
android:foregroundServiceType="mediaPlayback"
|
||||
android:enabled="true" />
|
||||
|
||||
<activity android:name=".avroom.room_album.RoomAlbumActivity" />
|
||||
@@ -931,6 +940,23 @@
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".community.dynamic.view.DynamicDetailActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".community.publish.view.PublishActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustNothing" />
|
||||
<activity
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:name=".ui.feedback.FeedbackActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity android:name=".ui.debug.DebugActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity android:name=".ui.game_team.record.GameTeamRecordActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
BIN
app/src/main/assets/svga/Combo_Boom.svga
Normal file
BIN
app/src/main/assets/svga/Combo_Boom.svga
Normal file
Binary file not shown.
@@ -25,6 +25,7 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.chwl.app.base.GlobalViewModelOwner;
|
||||
import com.chwl.app.common.widget.dialog.DialogManager;
|
||||
import com.chwl.app.community.square.SquareFragment;
|
||||
import com.chwl.app.game.core.GameStateAbility;
|
||||
import com.chwl.app.game.data.GameModel2;
|
||||
import com.chwl.app.game.ui.game.GameActivity;
|
||||
@@ -143,7 +144,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
private MainTabLayout mMainTabLayout;
|
||||
private AnchorCardView anchorCardView;
|
||||
private View viewClose;
|
||||
private int mCurrentTabType = MainTabType.TAB_TYPE_STAR;
|
||||
private int mCurrentTabType = MainTabType.TAB_TYPE_HOME;
|
||||
/**
|
||||
* 房间最小化动画,换成属性动画,原先的补间动画影响了activity的生命周期
|
||||
*/
|
||||
@@ -162,9 +163,9 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
private Runnable touchRunnable;
|
||||
|
||||
{
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_STAR, new StarFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_GAME, new GameHomeFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_HOME, new HomeFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_GAME, new GameHomeFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_SQUARE, new SquareFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_MSG, new ContactsListFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_ME, new MeFragment());
|
||||
}
|
||||
|
@@ -84,7 +84,6 @@ import com.chwl.library.common.file.FileHelper;
|
||||
import com.chwl.library.net.rxnet.RxNet;
|
||||
import com.chwl.library.net.rxnet.converter.GsonConverterPlugins;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.AppUtils;
|
||||
import com.chwl.library.utils.DeviceUuidFactory;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
@@ -417,7 +416,7 @@ public class App extends BaseApp {
|
||||
httpParams.put("netType", String.valueOf(SystemUtils.getNetworkType(context)));
|
||||
httpParams.put("model", SystemUtils.getPhoneModel());
|
||||
httpParams.put("appVersion", VersionUtil.getLocalName(context));
|
||||
httpParams.put("appVersionCode", String.valueOf(AppUtils.getVersionCode(context)));
|
||||
httpParams.put("appVersionCode", String.valueOf(VersionUtil.getVersionCode(context)));
|
||||
httpParams.put("deviceId", DeviceUuidFactory.getDeviceId(context));
|
||||
httpParams.put("androidId", MD5Utils.getMD5String(Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID)));
|
||||
httpParams.put("channel", AppMetaDataUtil.getChannelID());
|
||||
@@ -484,7 +483,6 @@ public class App extends BaseApp {
|
||||
ChannelModel.get();
|
||||
MarketVerifyModel.get();
|
||||
GiftModel.get();
|
||||
GiftModel.get().tryLoadGiftList();
|
||||
// 模厅
|
||||
HallDataManager.get().application();
|
||||
//全局处理
|
||||
|
@@ -97,7 +97,7 @@ public class GlobalHandleManager {
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
if (AvRoomDataManager.get().isSelfGamePlaying()) return;
|
||||
LevelUpDialog.start(activity, event.getLevelName(), true);
|
||||
// LevelUpDialog.start(activity, event.getLevelName(), true);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@@ -105,7 +105,7 @@ public class GlobalHandleManager {
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
if (AvRoomDataManager.get().isSelfGamePlaying()) return;
|
||||
LevelUpDialog.start(activity, event.getLevelName(), false);
|
||||
// LevelUpDialog.start(activity, event.getLevelName(), false);
|
||||
}
|
||||
|
||||
private static final class Helper {
|
||||
|
@@ -47,8 +47,7 @@ public abstract class BottomViewListenerWrapper {
|
||||
|
||||
}
|
||||
|
||||
public void onRoomGameplayClick(){
|
||||
public void onRoomGameplayClick(boolean isOnlyPK){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -42,6 +42,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.chwl.app.notify.RoomNotifyManager;
|
||||
import com.chwl.app.ui.webview.baishun.BaiShunGameWebFragment;
|
||||
import com.chwl.app.ui.webview.baishun.IBaiShunGameListener;
|
||||
import com.chwl.library.widget.SVGAView;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
|
||||
import com.chwl.core.room.game.bean.BaiShunGameConfig;
|
||||
import com.chwl.core.support.room.AudioRoomContext;
|
||||
@@ -177,6 +178,15 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
private static final String TAG = "AVRoomActivity";
|
||||
private static final int SHOW_RED_DIALOG_MAX = 10;
|
||||
public static boolean isPKModel = false;
|
||||
private static SVGAView.SVGACache svgaCache;
|
||||
|
||||
public static SVGAView.SVGACache getSvgaCache() {
|
||||
if (svgaCache == null) {
|
||||
svgaCache = SVGAView.newCache(20);
|
||||
}
|
||||
return svgaCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理限制进房
|
||||
*/
|
||||
@@ -899,6 +909,10 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
GiftModel.get().cancelCountDownTimer();
|
||||
EventBus.getDefault().unregister(this);
|
||||
DemoCache.saveBoolean("FirstCharge", false);
|
||||
if (svgaCache != null) {
|
||||
svgaCache.clear();
|
||||
}
|
||||
svgaCache = null;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,142 @@
|
||||
package com.chwl.app.avroom.activity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.databinding.RoomTypeSwitchActivityBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.super_admin.util.SuperAdminUtil
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
|
||||
class RoomTypeSwitchActivity : BaseViewBindingActivity<RoomTypeSwitchActivityBinding>() {
|
||||
|
||||
private var currentType: Int? = null
|
||||
|
||||
private var selectType: Int? = null
|
||||
|
||||
companion object {
|
||||
fun isCanSwitch(): Boolean {
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
return false
|
||||
}
|
||||
if (AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_HOME_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_REVELRY) {
|
||||
return false
|
||||
}
|
||||
if (AvRoomDataManager.get().isDatingMode) {
|
||||
return false
|
||||
}
|
||||
val roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
if (roomInfo == null || roomInfo.isPermitRoom == 1) {
|
||||
return false
|
||||
}
|
||||
return AvRoomDataManager.get().isManager
|
||||
}
|
||||
|
||||
fun start(context: Context) {
|
||||
context.startActivity(Intent(context, RoomTypeSwitchActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
initWhiteTitleBar(ResUtil.getString(R.string.room_type))
|
||||
initEvent()
|
||||
this.currentType = AvRoomDataManager.get().mCurrentRoomInfo?.type
|
||||
updateSelectView(currentType)
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
binding.tvSubmit.singleClick {
|
||||
selectType?.let {
|
||||
if (currentType != it) {
|
||||
trySwitchRoomType(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
addTypeSelectClick(binding.iv9, RoomInfo.ROOMTYPE_HOME_PARTY)
|
||||
addTypeSelectClick(binding.iv10, RoomInfo.ROOMTYPE_PARTY)
|
||||
addTypeSelectClick(binding.iv15, RoomInfo.ROOMTYPE_REVELRY)
|
||||
}
|
||||
|
||||
private fun addTypeSelectClick(view: View, type: Int) {
|
||||
view.setOnClickListener {
|
||||
updateSelectView(type)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateSelectView(type: Int?) {
|
||||
this.selectType = type
|
||||
val views = mapOf(
|
||||
RoomInfo.ROOMTYPE_HOME_PARTY to binding.iv9Border,
|
||||
RoomInfo.ROOMTYPE_PARTY to binding.iv10Border,
|
||||
RoomInfo.ROOMTYPE_REVELRY to binding.iv15Border
|
||||
)
|
||||
val displayRes = mapOf(
|
||||
RoomInfo.ROOMTYPE_HOME_PARTY to R.drawable.room_type_bg_9,
|
||||
RoomInfo.ROOMTYPE_PARTY to R.drawable.room_type_bg_10,
|
||||
RoomInfo.ROOMTYPE_REVELRY to R.drawable.room_type_bg_15
|
||||
)
|
||||
views.forEach {
|
||||
it.value.isVisible = it.key == type
|
||||
}
|
||||
val resId = displayRes.get(type)
|
||||
if (resId != null) {
|
||||
binding.ivSelected.setImageResource(resId)
|
||||
} else {
|
||||
binding.ivSelected.setImageDrawable(null)
|
||||
}
|
||||
if (type == currentType) {
|
||||
binding.tvSubmit.setText(R.string.room_type_using)
|
||||
} else {
|
||||
binding.tvSubmit.setText(R.string.room_type_use)
|
||||
}
|
||||
}
|
||||
|
||||
private fun trySwitchRoomType(type: Int) {
|
||||
val currentType = this.currentType
|
||||
if (currentType != null && currentType > type) {
|
||||
dialogManager.showOkCancelDialog(
|
||||
ResUtil.getString(R.string.switch_room_type_tips),
|
||||
ResUtil.getString(R.string.login_fragment_adduserinfofragment_04)
|
||||
) {
|
||||
requestSwitchRoomType(type)
|
||||
}
|
||||
} else {
|
||||
requestSwitchRoomType(type)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun requestSwitchRoomType(type: Int) {
|
||||
dialogManager.showProgressDialog(context)
|
||||
OpenRoomHelper.updateRoomInfoRx(
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
type,
|
||||
0
|
||||
).compose(bindToLifecycle()).subscribe({
|
||||
dialogManager.dismissDialog()
|
||||
finish()
|
||||
}, {
|
||||
SingleToastUtil.showToast(it.message)
|
||||
dialogManager.dismissDialog()
|
||||
})
|
||||
}
|
||||
|
||||
override fun needSteepStateBar(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun setStatusBar() {
|
||||
super.setStatusBar()
|
||||
StatusBarUtil.transparencyBar(this)
|
||||
StatusBarUtil.StatusBarLightMode(this)
|
||||
}
|
||||
}
|
@@ -15,8 +15,12 @@ import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.utils.AvatarHelper;
|
||||
import com.chwl.library.widget.SVGAView;
|
||||
import com.chwl.core.utils.extension.StringExtensionKt;
|
||||
import com.coorchice.library.SuperTextView;
|
||||
import com.example.lib_utils.StringUtils2;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.chwl.app.R;
|
||||
@@ -55,6 +59,9 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
public static final String MICRO_TYPE_DATING = "dating";
|
||||
public static final String MICRO_TYPE_DATING_VIP = "dating_vip";
|
||||
public static final String MICRO_TYPE_SINGLE = "single";
|
||||
public static final String MICRO_TYPE_PARTY = "party";
|
||||
public static final String MICRO_TYPE_REVELRY = "revelry";
|
||||
|
||||
protected static final int TYPE_KING = 2;
|
||||
protected static final int TYPE_BOSS = 1;
|
||||
protected static final int TYPE_NORMAL = 0;
|
||||
@@ -76,11 +83,16 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().getRoomQueueMemberInfoByMicPosition(position - 1);
|
||||
if (roomQueueInfo == null) return;
|
||||
NormalMicroViewHolder holder = (NormalMicroViewHolder) viewHolder;
|
||||
holder.micPositionNameOffset = getMicPositionNameOffset();
|
||||
holder.bind(roomQueueInfo, position - 1);
|
||||
}
|
||||
|
||||
public abstract String microType();
|
||||
|
||||
protected int getMicPositionNameOffset() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 9;
|
||||
@@ -137,7 +149,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
SVGAImageView ivHalo;
|
||||
|
||||
@Nullable
|
||||
ImageView ivHeadWear;
|
||||
SVGAView ivHeadWear;
|
||||
@Nullable
|
||||
ImageView ivCharmLevelTag;
|
||||
|
||||
@@ -146,6 +158,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
RoomQueueInfo info;
|
||||
int position = TYPE_INVALID;
|
||||
int micPositionNameOffset = 2;
|
||||
|
||||
NormalMicroViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@@ -162,6 +175,9 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ivUpImage.setOnClickListener(this);
|
||||
ivLockImage.setOnClickListener(this);
|
||||
ivAvatar.setOnClickListener(this);
|
||||
if (ivHeadWear != null) {
|
||||
ivHeadWear.bindCache(AVRoomActivity.getSvgaCache());
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
@@ -267,6 +283,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
private void clearHeadWear() {
|
||||
if (ivHeadWear == null) return;
|
||||
ivHeadWear.clearAnimation();
|
||||
ivHeadWear.stopAnimation();
|
||||
ivHeadWear.setImageDrawable(null);
|
||||
ivHeadWear.setTag(R.id.mic_item_head_wear, null);
|
||||
ivHeadWear.setVisibility(View.GONE);
|
||||
@@ -274,7 +291,11 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
protected void setDefalutText(int index) {
|
||||
tvNick.setTextColor(Color.WHITE);
|
||||
tvNick.setText("NO."+ (index + 1));
|
||||
tvNick.setText(getMicPositionName(index));
|
||||
}
|
||||
|
||||
protected String getMicPositionName(int index) {
|
||||
return "NO." + (index + micPositionNameOffset);
|
||||
}
|
||||
|
||||
protected void setSelectText(int index, String nick, int gender) {
|
||||
@@ -286,10 +307,13 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
private void updateNobleView(MicMemberInfo chatRoomMember) {
|
||||
if (ivHeadWear == null) return;
|
||||
String headWear = chatRoomMember.getHeadWearUrl();
|
||||
int headWearType = chatRoomMember.getHeadWearType();
|
||||
if (TextUtils.isEmpty(headWear)) {
|
||||
headWear = NobleUtil.getHeadResource(HeadWearInfo.EFFECT, chatRoomMember) != null ?
|
||||
NobleUtil.getHeadResource(HeadWearInfo.EFFECT, chatRoomMember) :
|
||||
NobleUtil.getHeadResource(HeadWearInfo.PIC, chatRoomMember);
|
||||
String type = NobleUtil.getHeadResource(HeadWearInfo.TYPE, chatRoomMember);
|
||||
headWearType = StringUtils2.INSTANCE.toInt(type);
|
||||
}
|
||||
String nobleHeadWear = (String) NobleUtil.getResource(NobleResourceType.KEY_HEAD_WEAR, chatRoomMember);
|
||||
if (!TextUtils.isEmpty(headWear)) {
|
||||
@@ -297,7 +321,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
//只有头饰发生改变才更新,防止闪烁
|
||||
if (!headWear.equals(ivHeadWear.getTag(R.id.mic_item_head_wear))) {
|
||||
ivHeadWear.setTag(R.id.mic_item_head_wear, headWear);
|
||||
NobleUtil.loadMicHeadWear(headWear, ivHeadWear, R.id.mic_item_head_wear, headWear);
|
||||
AvatarHelper.loadAvatarFrame(ivHeadWear, headWear, headWearType);
|
||||
}
|
||||
} else if (!TextUtils.isEmpty(nobleHeadWear)) {
|
||||
// 头饰
|
||||
@@ -478,10 +502,10 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
//控制最高最低头饰
|
||||
Observer<Integer> headWearObserver = headWearValue -> {
|
||||
if (ivCharmLevelTag == null) return;
|
||||
ivCharmLevelTag.setVisibility(View.GONE);
|
||||
if (headWearValue == 1) {
|
||||
ivCharmLevelTag.setVisibility(View.VISIBLE);
|
||||
ivCharmLevelTag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_charm_level_min));
|
||||
ivCharmLevelTag.setVisibility(View.GONE);
|
||||
// ivCharmLevelTag.setVisibility(View.VISIBLE);
|
||||
// ivCharmLevelTag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_charm_level_min));
|
||||
} else if (headWearValue == 2) {
|
||||
ivCharmLevelTag.setVisibility(View.VISIBLE);
|
||||
ivCharmLevelTag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_charm_level_max));
|
||||
|
@@ -27,6 +27,11 @@ public class CpMicroViewAdapter extends BaseMicroViewAdapter {
|
||||
return BaseMicroViewAdapter.MICRO_TYPE_CP;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMicPositionNameOffset() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindToRecyclerView(RecyclerView recyclerView) {
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(context, 3);
|
||||
|
@@ -27,6 +27,9 @@ import com.chwl.library.utils.ResUtil
|
||||
* @date 2017/12/18
|
||||
*/
|
||||
class DatingMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context) {
|
||||
override fun getMicPositionNameOffset(): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LayoutManager and bind this to RecyclerView
|
||||
|
@@ -2,7 +2,6 @@ package com.chwl.app.avroom.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -13,8 +12,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.core.bean.RoomQueueInfo;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
/**
|
||||
* @author xiaoyu
|
||||
@@ -27,6 +24,11 @@ public class MicroViewAdapter extends BaseMicroViewAdapter {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMicPositionNameOffset() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LayoutManager and bind this to RecyclerView
|
||||
*/
|
||||
@@ -62,15 +64,6 @@ public class MicroViewAdapter extends BaseMicroViewAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, final int position) {
|
||||
RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().getRoomQueueMemberInfoByMicPosition(position - 1);
|
||||
if (roomQueueInfo == null) {
|
||||
return;
|
||||
}
|
||||
NormalMicroViewHolder holder = (NormalMicroViewHolder) viewHolder;
|
||||
holder.bind(roomQueueInfo, position - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String microType() {
|
||||
|
@@ -0,0 +1,79 @@
|
||||
package com.chwl.app.avroom.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.core.bean.RoomQueueInfo;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
|
||||
/**
|
||||
* @author xiaoyu
|
||||
* @date 2017/12/18
|
||||
*/
|
||||
|
||||
public class PartyMicroViewAdapter extends BaseMicroViewAdapter {
|
||||
|
||||
public PartyMicroViewAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LayoutManager and bind this to RecyclerView
|
||||
*/
|
||||
@Override
|
||||
public void bindToRecyclerView(RecyclerView recyclerView) {
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(context, 5);
|
||||
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.setAdapter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View item;
|
||||
item = LayoutInflater.from(parent.getContext()).
|
||||
inflate(R.layout.list_item_micro, parent, false);
|
||||
return new MicroViewHolder(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String microType() {
|
||||
return BaseMicroViewAdapter.MICRO_TYPE_PARTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return TYPE_NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
class MicroViewHolder extends GiftValueViewHolder {
|
||||
MicroViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(RoomQueueInfo info, int position) {
|
||||
super.bind(info, position);
|
||||
ivUpImage.setImageResource(R.drawable.icon_room_up_micro);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void setDefalutText(int index) {
|
||||
super.setDefalutText(index);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
package com.chwl.app.avroom.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.core.bean.RoomQueueInfo;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
|
||||
/**
|
||||
* @author xiaoyu
|
||||
* @date 2017/12/18
|
||||
*/
|
||||
|
||||
public class RevelryMicroViewAdapter extends BaseMicroViewAdapter {
|
||||
|
||||
public RevelryMicroViewAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LayoutManager and bind this to RecyclerView
|
||||
*/
|
||||
@Override
|
||||
public void bindToRecyclerView(RecyclerView recyclerView) {
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(context, 5);
|
||||
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.setAdapter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View item;
|
||||
item = LayoutInflater.from(parent.getContext()).
|
||||
inflate(R.layout.list_item_micro, parent, false);
|
||||
return new MicroViewHolder(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String microType() {
|
||||
return BaseMicroViewAdapter.MICRO_TYPE_REVELRY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return TYPE_NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
class MicroViewHolder extends GiftValueViewHolder {
|
||||
MicroViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(RoomQueueInfo info, int position) {
|
||||
super.bind(info, position);
|
||||
ivUpImage.setImageResource(R.drawable.icon_room_up_micro);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void setDefalutText(int index) {
|
||||
super.setDefalutText(index);
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkFinishBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
|
||||
class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
|
||||
class RoomPkFinishDialog : BaseDialogFragment<DialogRoomPkFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkForceFinishBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
|
||||
class RoomPkForceFinishDialog : BaseDialog<DialogRoomPkForceFinishBinding>() {
|
||||
class RoomPkForceFinishDialog : BaseDialogFragment<DialogRoomPkForceFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@@ -4,7 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkReceivedBinding
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
@@ -16,7 +16,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class RoomPkReceivedDialog : BaseDialog<DialogRoomPkReceivedBinding>() {
|
||||
class RoomPkReceivedDialog : BaseDialogFragment<DialogRoomPkReceivedBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.chwl.app.avroom.anotherroompk
|
||||
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkRuleBinding
|
||||
|
||||
class RoomPkRuleDialog : BaseDialog<DialogRoomPkRuleBinding>() {
|
||||
class RoomPkRuleDialog : BaseDialogFragment<DialogRoomPkRuleBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -0,0 +1,126 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
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.annotation.StyleRes
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.widget.VDHLayout
|
||||
import com.chwl.app.ui.widget.dialog.BaseDialog
|
||||
|
||||
abstract class BaseRoomNotifyeBaseDialog<VB : ViewBinding>(context: Context, theme: Int = 0) : BaseDialog(context, theme) {
|
||||
|
||||
protected val handle = Handler(Looper.getMainLooper())
|
||||
protected lateinit var mBinding: VB
|
||||
|
||||
abstract fun createBinding(inflater: LayoutInflater): VB
|
||||
|
||||
abstract fun init()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mBinding = createBinding(LayoutInflater.from(context))
|
||||
setContentView(mBinding.root)
|
||||
setCancelable(true)
|
||||
setCanceledOnTouchOutside(false)
|
||||
window?.let {
|
||||
initWindow(it)
|
||||
}
|
||||
|
||||
init()
|
||||
|
||||
handle.postDelayed({
|
||||
dismissDialog()
|
||||
}, (getStaySecond()*1000).toLong())
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
handle.removeCallbacksAndMessages(null)
|
||||
super.onDetachedFromWindow()
|
||||
}
|
||||
|
||||
protected open fun initWindow(window: Window) {
|
||||
window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
val windowParams = window.attributes
|
||||
windowParams.width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
windowParams.height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
windowParams.dimAmount = 0.0f
|
||||
windowParams.gravity = Gravity.TOP
|
||||
windowParams.x = 0
|
||||
windowParams.y = getTopOffset()
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL)
|
||||
window.attributes = windowParams
|
||||
window.setWindowAnimations(getAnimations())
|
||||
}
|
||||
|
||||
protected open fun getStaySecond():Float{
|
||||
return 5f
|
||||
}
|
||||
|
||||
protected open fun getTopOffset():Int{
|
||||
return 0
|
||||
}
|
||||
|
||||
@StyleRes
|
||||
protected open fun getAnimations():Int{
|
||||
return R.style.anim_left
|
||||
}
|
||||
|
||||
override fun setContentView(view: View) {
|
||||
if (useSlipSlip()) {
|
||||
val vdhLayout = VDHLayout(context, null)
|
||||
vdhLayout.addView(view)
|
||||
vdhLayout.setListener { dismissDialog() }
|
||||
super.setContentView(vdhLayout)
|
||||
return
|
||||
}
|
||||
super.setContentView(view)
|
||||
}
|
||||
|
||||
override fun setContentView(layoutResID: Int) {
|
||||
if (useSlipSlip()) {
|
||||
val vdhLayout = VDHLayout(context, null)
|
||||
LayoutInflater.from(context).inflate(layoutResID, vdhLayout)
|
||||
vdhLayout.setListener { dismissDialog() }
|
||||
super.setContentView(vdhLayout)
|
||||
return
|
||||
}
|
||||
super.setContentView(layoutResID)
|
||||
}
|
||||
|
||||
override fun setContentView(view: View, params: ViewGroup.LayoutParams?) {
|
||||
if (useSlipSlip()) {
|
||||
val vdhLayout = VDHLayout(context, null)
|
||||
vdhLayout.addView(view)
|
||||
vdhLayout.setListener { dismissDialog() }
|
||||
super.setContentView(vdhLayout, params)
|
||||
return
|
||||
}
|
||||
super.setContentView(view, params)
|
||||
}
|
||||
|
||||
open fun dismissDialog(){
|
||||
try {
|
||||
dismiss()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否启动侧滑,左滑:删除,右滑:回到原位置
|
||||
*/
|
||||
protected open fun useSlipSlip(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.common.widget.dialog.DialogManager
|
||||
import com.chwl.app.common.widget.dialog.DialogManager.OkCancelDialogListener
|
||||
import com.chwl.app.databinding.RoomNotifyLuckGiftDlgBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.app.utils.NumberUtils
|
||||
import com.chwl.core.gift.bean.LuckyGiftMsgAllBean
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.example.lib_utils.UiUtils
|
||||
|
||||
/**
|
||||
* @Author Vance
|
||||
* 幸运礼物的飘屏,全服但是展示的时候限制只有房间才展示
|
||||
*/
|
||||
class BaseRoomNotifyeLuckGiftDialog(private val context: Context) : BaseRoomNotifyeBaseDialog<RoomNotifyLuckGiftDlgBinding>(context) {
|
||||
|
||||
override fun createBinding(inflater: LayoutInflater): RoomNotifyLuckGiftDlgBinding {
|
||||
return RoomNotifyLuckGiftDlgBinding.inflate(inflater)
|
||||
}
|
||||
|
||||
private var mDialogManager: DialogManager? = null
|
||||
var luckyGiftMsgBean: LuckyGiftMsgAllBean ? = null
|
||||
|
||||
override fun init() {
|
||||
|
||||
if (UiUtils.isRtl(context)) {
|
||||
mBinding.bg.scaleX = -1f
|
||||
}
|
||||
|
||||
ImageLoadUtils.loadImage(mBinding.avatar,luckyGiftMsgBean?.sender?.avatar?:"")
|
||||
mBinding.giftName.text = luckyGiftMsgBean?.giftNameMap?.getFirstText()
|
||||
mBinding.winNum.text = luckyGiftMsgBean?.times.toString()
|
||||
|
||||
val coinNum = NumberUtils.format(luckyGiftMsgBean?.coins?:0)
|
||||
mBinding.coinNum.text = coinNum
|
||||
|
||||
mBinding.clickArea.setOnClickListener {
|
||||
mDialogManager = DialogManager(context)
|
||||
mDialogManager?.showOkCancelDialog(ResUtil.getString(R.string.changeRoomTips), true, object : OkCancelDialogListener {
|
||||
override fun onCancel() {
|
||||
mDialogManager?.dismissDialog()
|
||||
}
|
||||
|
||||
override fun onOk() {
|
||||
mDialogManager?.dismissDialog()
|
||||
luckyGiftMsgBean?.roomUid?.let {
|
||||
if (AvRoomDataManager.get().roomUid != it) {
|
||||
AVRoomActivity.start(context, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var mCallBack : CallBack? = null
|
||||
interface CallBack{
|
||||
fun onHide();
|
||||
}
|
||||
|
||||
override fun dismissDialog() {
|
||||
super.dismissDialog()
|
||||
mCallBack?.onHide()
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -6,7 +6,7 @@ import android.view.WindowManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chwl.app.avroom.adapter.CreateRoomGameGuideAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogCreateGameRoomBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.app.ui.utils.RVDelegate
|
||||
@@ -14,7 +14,7 @@ import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.room.game.bean.GameInfo
|
||||
import com.chwl.core.room.game.GameModel
|
||||
|
||||
class CreateGameRoomDialog : BaseDialog<DialogCreateGameRoomBinding>() {
|
||||
class CreateGameRoomDialog : BaseDialogFragment<DialogCreateGameRoomBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<GameInfo>
|
||||
private val gameAdapter = CreateRoomGameGuideAdapter()
|
||||
|
@@ -9,7 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.CreateRoomGameAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogCreateRoomBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.app.ui.utils.RVDelegate
|
||||
@@ -19,7 +19,7 @@ import com.chwl.core.room.game.GameModel
|
||||
import com.chwl.core.utils.extension.toast
|
||||
import com.chwl.library.utils.ResUtil
|
||||
|
||||
class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
|
||||
class CreateRoomDialog : BaseDialogFragment<DialogCreateRoomBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<GameInfo>
|
||||
private val gameAdapter = CreateRoomGameAdapter()
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogNewUserGiftBinding
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.gift.bean.GiftInfo
|
||||
|
||||
class NewUserGiftDialog(val giftInfo: GiftInfo) :
|
||||
BaseDialog<DialogNewUserGiftBinding>() {
|
||||
BaseDialogFragment<DialogNewUserGiftBinding>() {
|
||||
|
||||
override fun init() {
|
||||
binding?.ivClose?.setOnClickListener {
|
||||
|
@@ -95,7 +95,10 @@ public class PKSelectPeopleDialog extends BaseDialog implements View.OnClickList
|
||||
keys[i] = micQueue.keyAt(i);
|
||||
}
|
||||
Arrays.sort(keys);
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
for (int i = 0; i < micEntityList.size(); i++) {
|
||||
if (i >= micQueue.size()) {
|
||||
continue;
|
||||
}
|
||||
RoomQueueInfo roomQueueInfo = micQueue.get(keys[i]);
|
||||
MicMemberInfo chatRoomMember = roomQueueInfo.mChatRoomMember;
|
||||
if (chatRoomMember != null) {
|
||||
|
@@ -11,6 +11,7 @@ import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.RoomGameListAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
@@ -38,7 +39,7 @@ class RoomGameListDialog :
|
||||
private var compositeDisposable: CompositeDisposable? = null
|
||||
private val adapter = RoomGameListAdapter()
|
||||
private var dialogManager: DialogManager? = null
|
||||
|
||||
private lateinit var recycleView: RecyclerView
|
||||
override fun getTheme(): Int {
|
||||
return R.style.ErbanBottomSheetDialogDimFalse
|
||||
}
|
||||
@@ -61,6 +62,8 @@ class RoomGameListDialog :
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
initView()
|
||||
val recyclerView: RecyclerView = view.findViewById(R.id.recyclerView)
|
||||
recycleView = recyclerView
|
||||
switchStatus(0)
|
||||
requestData()
|
||||
}
|
||||
@@ -89,6 +92,14 @@ class RoomGameListDialog :
|
||||
binding?.recyclerView?.adapter = adapter
|
||||
}
|
||||
|
||||
private fun updateDialogHeight(count: Int) {
|
||||
if (count > 10) {
|
||||
val layoutParams = recycleView.layoutParams
|
||||
layoutParams.height = 600
|
||||
recycleView.layoutParams = layoutParams
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestData() {
|
||||
val dataService =
|
||||
AudioRoomContext.get()
|
||||
@@ -96,6 +107,7 @@ class RoomGameListDialog :
|
||||
val cacheKey = "game_list#${parentFragment.hashCode()}"
|
||||
val list = dataService?.getData(cacheKey) as? List<GameInfo>
|
||||
if (!list.isNullOrEmpty()) {
|
||||
updateDialogHeight(list.size)
|
||||
loadData(list)
|
||||
return
|
||||
}
|
||||
@@ -106,6 +118,7 @@ class RoomGameListDialog :
|
||||
}
|
||||
.subscribe { it: List<GameInfo> ->
|
||||
dataService?.putData(cacheKey, it)
|
||||
updateDialogHeight(it.size)
|
||||
loadData(it)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
|
@@ -10,6 +10,8 @@ import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.activity.CreatePKActivity
|
||||
import com.chwl.app.avroom.adapter.RoomGameplayAdapter
|
||||
@@ -25,6 +27,7 @@ import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.anotherroompk.SingleRoomPKModel
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.room.core.RoomDataService
|
||||
import com.chwl.core.room.game.bean.BaiShunGameConfig
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
@@ -38,8 +41,11 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.gson.Gson
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
||||
class RoomGameplayDialog :
|
||||
BottomSheetDialogFragment() {
|
||||
class RoomGameplayDialog : BottomSheetDialogFragment() {
|
||||
|
||||
var isOnlyPK = false
|
||||
private lateinit var recycleView: RecyclerView
|
||||
|
||||
private var binding: RoomGameplayDialogBinding? = null
|
||||
private var compositeDisposable: CompositeDisposable? = null
|
||||
private val adapter = RoomGameplayAdapter()
|
||||
@@ -68,6 +74,10 @@ class RoomGameplayDialog :
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
initView()
|
||||
|
||||
val recyclerView: RecyclerView = view.findViewById(R.id.recyclerView)
|
||||
recycleView = recyclerView
|
||||
|
||||
switchStatus(0)
|
||||
requestData()
|
||||
}
|
||||
@@ -96,28 +106,46 @@ class RoomGameplayDialog :
|
||||
}
|
||||
|
||||
private fun requestData() {
|
||||
val dataService =
|
||||
AudioRoomContext.get()
|
||||
?.findAbility<RoomDataService>(RoomDataService::class.java.simpleName)
|
||||
val cacheKey = "gameplay_list#${parentFragment.hashCode()}"
|
||||
val list = dataService?.getData(cacheKey) as? List<RoomIcon>
|
||||
if (!list.isNullOrEmpty()) {
|
||||
loadSuccess(list)
|
||||
return
|
||||
if (isOnlyPK) {
|
||||
loadSuccess(arrayListOf())
|
||||
} else {
|
||||
val dataService =
|
||||
AudioRoomContext.get()
|
||||
?.findAbility<RoomDataService>(RoomDataService::class.java.simpleName)
|
||||
val cacheKey = "gameplay_list#${parentFragment.hashCode()}"
|
||||
val list = dataService?.getData(cacheKey) as? List<RoomIcon>
|
||||
|
||||
if (!list.isNullOrEmpty()) {
|
||||
updateDialogHeight(list.size)
|
||||
loadSuccess(list)
|
||||
return
|
||||
}
|
||||
val disposable = AvRoomModel.get().roomGamePlayList
|
||||
.doOnError {
|
||||
loadFail(it)
|
||||
}
|
||||
.subscribe { it: List<RoomIcon> ->
|
||||
dataService?.putData(cacheKey, it)
|
||||
updateDialogHeight(it.size)
|
||||
loadSuccess(it)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateDialogHeight(count: Int) {
|
||||
if (count > 10) {
|
||||
val layoutParams = recycleView.layoutParams
|
||||
layoutParams.height = 600
|
||||
recycleView.layoutParams = layoutParams
|
||||
}
|
||||
val disposable = AvRoomModel.get().roomGamePlayList
|
||||
.doOnError {
|
||||
loadFail(it)
|
||||
}
|
||||
.subscribe { it: List<RoomIcon> ->
|
||||
dataService?.putData(cacheKey, it)
|
||||
loadSuccess(it)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
private fun loadSuccess(list: List<RoomIcon>?) {
|
||||
val finalList = getLocalList()
|
||||
var finalList = mutableListOf<RoomGameplayItem>()
|
||||
if (isOnlyPK) {
|
||||
finalList = getLocalList()
|
||||
}
|
||||
list?.let {
|
||||
finalList.addAll(list.map {
|
||||
RoomGameplayItem.RoomIconItem(it) { dialog, item ->
|
||||
@@ -261,10 +289,7 @@ class RoomGameplayDialog :
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
return null
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenGame) {
|
||||
return null
|
||||
}
|
||||
if (AvRoomDataManager.get().isSingleRoom) {
|
||||
if (AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_HOME_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_REVELRY) {
|
||||
return null
|
||||
}
|
||||
val roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
@@ -299,10 +324,7 @@ class RoomGameplayDialog :
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
return null
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenGame) {
|
||||
return null
|
||||
}
|
||||
if (AvRoomDataManager.get().isSingleRoom) {
|
||||
if (AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_HOME_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_REVELRY) {
|
||||
return null
|
||||
}
|
||||
val roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
|
@@ -14,6 +14,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.avroom.activity.RoomTypeSwitchActivity;
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
@@ -76,6 +77,14 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
private Context context;
|
||||
private OptAdapter optAdapter;
|
||||
private OnActionListener onActionListener;
|
||||
private CallBack callBack;
|
||||
public void setCallBack(CallBack callBack) {
|
||||
this.callBack = callBack;
|
||||
}
|
||||
|
||||
public interface CallBack{
|
||||
void onCLick(int Type);
|
||||
}
|
||||
|
||||
public RoomOperationDialog(@NonNull Context context) {
|
||||
super(context, R.style.ErbanBottomSheetDialogDimFalse);
|
||||
@@ -131,6 +140,8 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
// addGiftValueAction(optAdapter);
|
||||
addSuperAdminAction(optAdapter);
|
||||
addShieldReportAction(optAdapter);
|
||||
addRoomTypeSwitchAction(optAdapter);
|
||||
//todo-- add pk btn
|
||||
rvOPtList.setAdapter(optAdapter);
|
||||
}
|
||||
|
||||
@@ -286,10 +297,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenGame()) {
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isSingleRoom()) {
|
||||
if (AvRoomDataManager.get().getRoomType() != RoomInfo.ROOMTYPE_HOME_PARTY) {
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isManager() && !AvRoomDataManager.get().isCpRoom()) {
|
||||
@@ -556,6 +564,18 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 房间类型切换
|
||||
*
|
||||
* @param optAdapter
|
||||
*/
|
||||
private void addRoomTypeSwitchAction(OptAdapter optAdapter) {
|
||||
if (RoomTypeSwitchActivity.Companion.isCanSwitch()) {
|
||||
optAdapter.addData(new OptAction(R.drawable.icon_room_type_switch,
|
||||
getContext().getResources().getString(R.string.room_type), () -> RoomTypeSwitchActivity.Companion.start(getContext())));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 超管管理
|
||||
*/
|
||||
|
@@ -5,7 +5,7 @@ import android.view.WindowManager
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.RoomTeamPkDialogBinding
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.app.ui.widget.dialog.CommonTipDialog
|
||||
@@ -28,7 +28,7 @@ import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.util.Locale
|
||||
|
||||
class RoomTeamPkDialog : BaseDialog<RoomTeamPkDialogBinding>() {
|
||||
class RoomTeamPkDialog : BaseDialogFragment<RoomTeamPkDialogBinding>() {
|
||||
|
||||
private var compositeDisposable: CompositeDisposable? = null
|
||||
|
||||
|
@@ -9,7 +9,7 @@ import android.view.WindowManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chwl.app.avroom.adapter.SendBroadcastAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSendBroadcastBinding
|
||||
import com.chwl.app.ui.utils.RVDelegate
|
||||
import com.chwl.app.utils.SpannableBuilder
|
||||
@@ -24,7 +24,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SendBroadcastDialog : BaseDialog<DialogSendBroadcastBinding>() {
|
||||
class SendBroadcastDialog : BaseDialogFragment<DialogSendBroadcastBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<String>
|
||||
private lateinit var adapter: SendBroadcastAdapter
|
||||
|
@@ -2,11 +2,11 @@ package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomTipBinding
|
||||
|
||||
class SingleRoomTipDialog :
|
||||
BaseDialog<DialogSingleRoomTipBinding>() {
|
||||
BaseDialogFragment<DialogSingleRoomTipBinding>() {
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun init() {
|
||||
binding?.root?.setOnClickListener {
|
||||
|
@@ -22,9 +22,7 @@ import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@@ -48,7 +46,6 @@ import com.chwl.app.avroom.dialog.RoomGameListDialog
|
||||
import com.chwl.app.avroom.dialog.RoomGameplayDialog
|
||||
import com.chwl.app.avroom.dialog.RoomOperationDialog
|
||||
import com.chwl.app.avroom.presenter.BaseRoomPresenter
|
||||
import com.chwl.app.avroom.public_chat.PublicChatRoomMessageWidget
|
||||
import com.chwl.app.avroom.room_album.RoomAlbumModel
|
||||
import com.chwl.app.avroom.view.IBaseRoomView
|
||||
import com.chwl.app.avroom.widget.BottomView
|
||||
@@ -60,16 +57,14 @@ import com.chwl.app.event.OpenRoomIntroEvent
|
||||
import com.chwl.app.friend.view.SelectFriendActivity
|
||||
import com.chwl.app.home.adapter.RoomActAdapter
|
||||
import com.chwl.app.music.widget.MusicPlayerView
|
||||
import com.chwl.app.public_chat.ui.message.HeadlineViewModel
|
||||
import com.chwl.app.room_chat.activity.RoomMsgActivity
|
||||
import com.chwl.app.ui.pay.ChargeActivity
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity
|
||||
import com.chwl.app.ui.widget.ButtonItem
|
||||
import com.chwl.app.ui.widget.GiftDialog
|
||||
import com.chwl.app.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
|
||||
import com.chwl.app.ui.widget.GiftDialog.SenGiftCallback
|
||||
import com.chwl.app.ui.widget.UserInfoDialog
|
||||
import com.chwl.app.ui.widget.dialog.CommonTipDialog
|
||||
import com.chwl.app.ui.widget.dynamicface.DynamicFaceDialog
|
||||
import com.chwl.app.ui.widget.magicindicator.MagicIndicator
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil
|
||||
@@ -78,13 +73,13 @@ import com.chwl.app.ui.widget.rollviewpager.RollPagerView
|
||||
import com.chwl.app.ui.widget.rollviewpager.Util
|
||||
import com.chwl.app.ui.widget.rollviewpager.hintview.ColorPointHintView
|
||||
import com.chwl.app.utils.KeyBoardUtils
|
||||
import com.chwl.app.vip.dialog.SelectPayTypeDialog
|
||||
import com.chwl.core.Constants
|
||||
import com.chwl.core.UriProvider
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.bean.RoomMicInfo
|
||||
import com.chwl.core.gift.GiftModel
|
||||
import com.chwl.core.gift.bean.GiftInfo
|
||||
import com.chwl.core.gift.event.GiftComboEvent
|
||||
import com.chwl.core.gift.event.RoomFreeGiftEvent
|
||||
import com.chwl.core.helper.AtProxy
|
||||
import com.chwl.core.home.bean.BannerInfo
|
||||
@@ -98,6 +93,8 @@ import com.chwl.core.manager.RoomEvent
|
||||
import com.chwl.core.mentoring_relationship.event.MentoringStopCountingEvent
|
||||
import com.chwl.core.room.anotherroompk.ShowGiftDialogEvent
|
||||
import com.chwl.core.room.anotherroompk.ShowUserInfoDialogEvent
|
||||
import com.chwl.core.room.bean.RightBottomIconConfig
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.room.event.RoomAtEvent
|
||||
import com.chwl.core.room.event.RoomClearScreenEvent
|
||||
@@ -116,12 +113,16 @@ import com.chwl.core.support.room.RoomWidget
|
||||
import com.chwl.core.user.UserModel
|
||||
import com.chwl.core.user.bean.BaseInfo
|
||||
import com.chwl.core.user.bean.UserInfo
|
||||
import com.chwl.core.utils.net.BalanceNotEnoughExeption
|
||||
import com.chwl.core.utils.net.VipLevelNotEnoughException
|
||||
import com.chwl.library.common.util.LimitClickUtils
|
||||
import com.chwl.library.net.rxnet.utils.RxNetWorkUtils
|
||||
import com.chwl.library.rxbus.RxBus
|
||||
import com.chwl.library.utils.*
|
||||
import com.chwl.library.utils.JavaUtil
|
||||
import com.chwl.library.utils.ListUtils
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.chwl.library.utils.UIUtils
|
||||
import com.google.gson.Gson
|
||||
import com.netease.nim.uikit.common.antispam.AntiSpamEvent
|
||||
import com.netease.nimlib.sdk.StatusCode
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder
|
||||
@@ -132,7 +133,6 @@ import com.tbruyelle.rxpermissions2.RxPermissions
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
@@ -153,12 +153,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
private var myUid: Long = 0
|
||||
protected lateinit var messagePager: ViewPager2
|
||||
protected lateinit var messageView: MessageView
|
||||
protected var publicChatMessageWidget: PublicChatRoomMessageWidget? = null
|
||||
protected lateinit var bottomView: BottomView
|
||||
protected lateinit var inputLayout: RelativeLayout
|
||||
protected lateinit var inputEdit: EditText
|
||||
protected lateinit var inputSend: ImageView
|
||||
protected lateinit var inputHeadlineSend: ImageView
|
||||
protected lateinit var microView: MicroView
|
||||
private var musicPlayerView: MusicPlayerView? = null
|
||||
private var mVsMusicPlayer: ViewStub? = null
|
||||
@@ -200,8 +198,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
// 房间小组件
|
||||
private var widgets: HashMap<String, RoomWidget> = HashMap()
|
||||
|
||||
private val headlineViewModel by activityViewModels<HeadlineViewModel>()
|
||||
|
||||
@CallSuper
|
||||
override fun onFindViews() {
|
||||
initMessageView()
|
||||
@@ -217,7 +213,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
false
|
||||
}
|
||||
inputSend = mView.findViewById(R.id.input_send)
|
||||
inputHeadlineSend = mView.findViewById(R.id.input_headline_send)
|
||||
microView = mView.findViewById(R.id.micro_view)
|
||||
mVsMusicPlayer = mView.findViewById(R.id.vs_music_player)
|
||||
messageView.setClickConsumer {
|
||||
@@ -240,10 +235,9 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
protected open fun initMessageView() {
|
||||
messagePager = mView.findViewById<ViewPager2>(R.id.message_pager)
|
||||
messageView = MessageView(context)
|
||||
publicChatMessageWidget = PublicChatRoomMessageWidget(requireContext())
|
||||
val tabList: MutableList<String> = java.util.ArrayList(2)
|
||||
tabList.add(getString(R.string.room))
|
||||
tabList.add(getString(R.string.public_chat))
|
||||
// tabList.add(getString(R.string.public_chat))
|
||||
val messageIndicator = mView.findViewById<MagicIndicator>(R.id.message_indicator)
|
||||
messagePager.offscreenPageLimit = tabList.size
|
||||
messagePager.adapter = object : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
@@ -251,12 +245,8 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): RecyclerView.ViewHolder {
|
||||
val view = if (viewType == 0) {
|
||||
messageView
|
||||
} else {
|
||||
publicChatMessageWidget
|
||||
}
|
||||
view?.layoutParams = ViewGroup.LayoutParams(
|
||||
val view = messageView
|
||||
view.layoutParams = ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
@@ -310,7 +300,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
override fun onSetListener() {
|
||||
bottomView.setMagicBtnEnable(true)
|
||||
inputSend.setOnClickListener(this)
|
||||
inputHeadlineSend.setOnClickListener(this)
|
||||
inputLayout.setOnTouchListener { _: View?, _: MotionEvent? ->
|
||||
inputEdit.clearFocus()
|
||||
inputLayout.visibility = View.GONE
|
||||
@@ -318,7 +307,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
messageView.setOnLongClickListener { _, account, name ->
|
||||
showInputLayout()
|
||||
if (atProxy == null) atProxy = AtProxy(inputEdit)
|
||||
@@ -374,44 +362,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
//获取免费礼物详情
|
||||
mvpPresenter?.queryFreeFlower()
|
||||
initRoomAlbum()
|
||||
initHeadline()
|
||||
}
|
||||
|
||||
private fun initHeadline() {
|
||||
headlineViewModel.loadingLiveData.observe(this) {
|
||||
if (it) dialogManager?.showProgressDialog(context)
|
||||
else dialogManager?.dismissDialog()
|
||||
}
|
||||
lifecycleScope.launch(Dispatchers.Main) {
|
||||
headlineViewModel.sendHeadlineFlow.collect {
|
||||
if (it.isSuccess) {
|
||||
SingleToastUtil.showToast(R.string.sent_success)
|
||||
inputEdit.setText("")
|
||||
KeyBoardUtils.hideKeyBoard(activity, inputEdit)
|
||||
} else {
|
||||
if (it.code == BalanceNotEnoughExeption.code) {
|
||||
showBalanceNotEnoughDialog()
|
||||
} else {
|
||||
SingleToastUtil.showToast(it.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
headlineViewModel.getHeadlinePayMoneyIsNull()
|
||||
}
|
||||
|
||||
private fun showBalanceNotEnoughDialog() {
|
||||
val tipDialog = CommonTipDialog(context)
|
||||
tipDialog.setTipMsg(ResUtil.getString(R.string.insufficient_balance_recharge_tips))
|
||||
tipDialog.setOkText(getString(R.string.charge))
|
||||
tipDialog.setOnActionListener(
|
||||
object : CommonTipDialog.OnActionListener {
|
||||
override fun onOk() {
|
||||
ChargeActivity.start(context)
|
||||
}
|
||||
}
|
||||
)
|
||||
tipDialog.show()
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@@ -650,6 +600,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
open fun updateView() {
|
||||
// 更新底欄
|
||||
showBottomViewForDifRole()
|
||||
bottomView.notifyStateChanged()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -664,6 +615,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
bottomView.showHomePartyDownMicBottom()
|
||||
}
|
||||
bottomView.showInputOrIcon(isOnMic)
|
||||
bottomView.updateGameEntrance()
|
||||
// 更新聽筒消息
|
||||
bottomView.setRemoteMuteOpen(!AudioEngineManager.get().isRemoteMute)
|
||||
if (isOnMic) {
|
||||
@@ -791,21 +743,66 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
override fun onClick(v: View) {
|
||||
if (mClickLimit.checkForTime(500)) return
|
||||
when (v.id) {
|
||||
R.id.iv_config_entrance -> {
|
||||
val roomInfo = AvRoomDataManager.get().mCurrentRoomInfo ?: return
|
||||
val configInfo = AvRoomDataManager.get().rightBottomIconConfig ?: return
|
||||
if (configInfo.skipType == 1) {
|
||||
playConfigWeb(configInfo.skipUrl)
|
||||
} else if (configInfo.skipType == 2) {
|
||||
playConfigBaishunGame(configInfo)
|
||||
}
|
||||
}
|
||||
R.id.iv_game -> {
|
||||
RoomGameListDialog().show(childFragmentManager, "GAME_LIST")
|
||||
val dialog = RoomGameplayDialog()
|
||||
dialog.isOnlyPK = false
|
||||
dialog.listener = object : RoomGameplayDialog.GameplayDialogListener {
|
||||
override fun onShowBaiShunGame(url: String, config: BaiShunGameConfig) {
|
||||
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
|
||||
}
|
||||
}
|
||||
dialog.show(childFragmentManager, "ROOM_GAME_PLAY")
|
||||
}
|
||||
R.id.input_send -> {
|
||||
sendMsg()
|
||||
}
|
||||
R.id.input_headline_send -> {
|
||||
sendHeadline()
|
||||
}
|
||||
R.id.layout_room_rank -> {
|
||||
DialogWebViewActivity.start(mContext, UriProvider.getRoomRanking())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun playConfigWeb(url: String) {
|
||||
CommonWebViewActivity.start(mContext, url)
|
||||
}
|
||||
|
||||
private fun playConfigBaishunGame(configInfo: RightBottomIconConfig) {
|
||||
val roomIcon: RoomIcon = RoomIcon(
|
||||
skipContent = configInfo.skipUrl,
|
||||
skipType = 3,
|
||||
showType = 1,
|
||||
code = "BAISHUN",
|
||||
ruleValue = configInfo.reserve)
|
||||
try {
|
||||
val url = roomIcon.skipContent
|
||||
val ruleValue = Gson().fromJson<RoomIcon.RuleValueBean>(
|
||||
roomIcon.ruleValue,
|
||||
RoomIcon.RuleValueBean::class.java
|
||||
)
|
||||
val config = Gson().fromJson<BaiShunGameConfig>(
|
||||
ruleValue.RESERVE,
|
||||
BaiShunGameConfig::class.java
|
||||
)
|
||||
if (config != null && url != null) {
|
||||
config.reloadDynamicParams()
|
||||
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
|
||||
} else {
|
||||
SingleToastUtil.showToast(R.string.manager_trtc_trtcengineadapter_042)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendMsg() {
|
||||
val message = inputEdit.text.toString().trim()
|
||||
if (isPublicMessageTab()) {
|
||||
@@ -815,41 +812,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendHeadline() {
|
||||
val message = inputEdit.text.toString().trim()
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_baseroomfragment_08))
|
||||
return
|
||||
}
|
||||
if (message.length > 100) {
|
||||
toast(R.string.headline_input_length_limit_tips)
|
||||
return
|
||||
}
|
||||
val money = headlineViewModel.headlinePayMoneyLiveData.value
|
||||
if (money != null) {
|
||||
showHeadlinePayDialog(money, message)
|
||||
} else {
|
||||
SingleToastUtil.showToast(R.string.ui_setting_modifypwdactivity_01)
|
||||
headlineViewModel.getHeadlinePayMoney()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showHeadlinePayDialog(money: Long, message: String) {
|
||||
KeyBoardUtils.hideKeyBoard(activity, inputEdit)
|
||||
SelectPayTypeDialog.newInstance(
|
||||
money.toString(),
|
||||
money,
|
||||
false
|
||||
).apply {
|
||||
setOnDiamondChargeClick {
|
||||
headlineViewModel.sendHeadline(message)
|
||||
}
|
||||
setOnChargeClick {
|
||||
ChargeActivity.start(context)
|
||||
}
|
||||
}.show(context)
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun sendMsg(msg: String) {
|
||||
if (!AuthModel.get().isImLogin) {
|
||||
@@ -880,7 +842,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
return
|
||||
}
|
||||
mvpPresenter?.sendPublicChatTextMessage(message)
|
||||
publicChatMessageWidget?.getMessageView()?.setNeedAutoScroll(true) // 發送後自動滾動公屏列表
|
||||
inputEdit.setText("")
|
||||
}
|
||||
|
||||
@@ -906,6 +867,9 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
for (i in micMemberInfos.indices) {
|
||||
targetUids.add(micMemberInfos[i].account.toLong())
|
||||
}
|
||||
|
||||
EventBus.getDefault().post(GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_BEGIN))
|
||||
|
||||
GiftModel.get()
|
||||
.sendRoomGift(
|
||||
giftInfo.giftId,
|
||||
@@ -927,11 +891,16 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
dialogManager.showOkDialog(message)
|
||||
}
|
||||
}
|
||||
.subscribe { _, throwable ->
|
||||
.subscribe { gift, throwable ->
|
||||
if (throwable != null) {
|
||||
toast(throwable.message)
|
||||
callback.onFail()
|
||||
EventBus.getDefault().post(GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_CANCEL))
|
||||
} else {
|
||||
giftDialog?.hide()
|
||||
val giftComboEvent = GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_END)
|
||||
giftComboEvent.giftNumber = gift.data.giftNum
|
||||
EventBus.getDefault().post(giftComboEvent)
|
||||
callback.onSuccess()
|
||||
}
|
||||
}
|
||||
@@ -1196,7 +1165,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
|
||||
override fun onSendPublicChatMsgSuccess(msg: ChatRoomMessage) {
|
||||
publicChatMessageWidget?.getMessageView()?.addMessages(msg)
|
||||
inputEdit.setText("")
|
||||
KeyBoardUtils.hideKeyBoard(activity, inputEdit)
|
||||
}
|
||||
@@ -1317,6 +1285,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
giftDialog?.setOnDismissListener { giftDialog = null }
|
||||
}
|
||||
if (giftDialog?.isShowing != true && !requireActivity().isFinishing) {
|
||||
EventBus.getDefault().post(GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_POINT))
|
||||
giftDialog?.show()
|
||||
}
|
||||
}
|
||||
@@ -1433,14 +1402,19 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
RoomMsgActivity.start(mContext)
|
||||
}
|
||||
|
||||
override fun onRoomGameplayClick() {
|
||||
val dialog = RoomGameplayDialog()
|
||||
dialog.listener = object : RoomGameplayDialog.GameplayDialogListener {
|
||||
override fun onShowBaiShunGame(url: String, config: BaiShunGameConfig) {
|
||||
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
|
||||
override fun onRoomGameplayClick(isOnlyPK: Boolean) {
|
||||
if (isOnlyPK) {
|
||||
val dialog = RoomGameplayDialog()
|
||||
dialog.isOnlyPK = isOnlyPK
|
||||
dialog.listener = object : RoomGameplayDialog.GameplayDialogListener {
|
||||
override fun onShowBaiShunGame(url: String, config: BaiShunGameConfig) {
|
||||
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
|
||||
}
|
||||
}
|
||||
dialog.show(childFragmentManager, "ROOM_GAME_PLAY")
|
||||
} else {
|
||||
RoomGameListDialog().show(childFragmentManager, "GAME_LIST")
|
||||
}
|
||||
dialog.show(childFragmentManager, "ROOM_GAME_PLAY")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1483,9 +1457,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
|
||||
open fun initWidget() {
|
||||
publicChatMessageWidget?.let {
|
||||
registerWidget(PublicChatRoomMessageWidget::class.java.simpleName, it)
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@@ -1503,7 +1474,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
* 打开公屏输入
|
||||
*/
|
||||
fun openMessageInput(text: String?) {
|
||||
inputHeadlineSend.isVisible = isPublicMessageTab()
|
||||
inputLayout.visibility = View.VISIBLE
|
||||
if (text != null) {
|
||||
inputEdit.setText(text)
|
||||
@@ -1519,6 +1489,26 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
|
||||
protected open fun onInitMusicPlayerView(view: MusicPlayerView) {
|
||||
|
||||
//todo-- 音乐按钮
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onGiftComboEvent(event: GiftComboEvent) {
|
||||
when (event.action) {
|
||||
|
||||
GiftComboEvent.Action.ACT_GIFT_START-> {
|
||||
giftDialog?.sendGift()
|
||||
}
|
||||
|
||||
GiftComboEvent.Action.ACT_GIFT_SHOW-> {
|
||||
giftDialog?.show()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -100,9 +100,6 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
messageView.messageListView?.let {
|
||||
setMessagePagerAutoHeight(it)
|
||||
}
|
||||
publicChatMessageWidget?.getMessageView()?.messageListView?.let {
|
||||
setMessagePagerAutoHeight(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
@@ -116,10 +113,14 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
dialogManager.showOkCancelDialog(
|
||||
getString(R.string.room_switch_standard_room_tips)
|
||||
) {
|
||||
var type = AvRoomDataManager.get().mCurrentRoomInfo?.oldType
|
||||
if (type == null || type <= 0) {
|
||||
type = RoomInfo.ROOMTYPE_HOME_PARTY
|
||||
}
|
||||
OpenRoomHelper.updateRoomInfo(
|
||||
baseActivity,
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
RoomInfo.ROOMTYPE_HOME_PARTY,
|
||||
type,
|
||||
0,
|
||||
false
|
||||
)
|
||||
|
@@ -6,7 +6,10 @@ import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewStub;
|
||||
@@ -15,11 +18,27 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.chwl.app.avroom.activity.RoomTitleEditActivity;
|
||||
import com.chwl.app.avroom.dialog.BaseRoomNotifyeLuckGiftDialog;
|
||||
import com.chwl.app.databinding.LayoutRoomNotifyLuckyGiftTipBinding;
|
||||
import com.chwl.app.utils.GiftAnimUtil;
|
||||
import com.chwl.app.utils.NumberUtils;
|
||||
import com.chwl.app.utils.WeakPool;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.gift.bean.LuckyGiftMsgAllBean;
|
||||
import com.chwl.core.gift.bean.LuckyGiftMsgSelfBean;
|
||||
import com.chwl.core.gift.bean.MsgSuperLuckyGift;
|
||||
import com.chwl.core.utils.ComboUtil;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.BonsellaJoinAttackButtonView;
|
||||
import com.chwl.app.ui.widget.GiftDialog;
|
||||
import com.chwl.app.ui.widget.UserInfoDialog;
|
||||
import com.chwl.core.gift.event.GiftComboEvent;
|
||||
import com.chwl.core.gift.toolbox.GiftToolbox;
|
||||
import com.chwl.core.utils.LogUtils;
|
||||
import com.chwl.library.utils.JavaUtil;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
@@ -64,6 +83,7 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
@@ -99,6 +119,9 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
//收藏房间
|
||||
private String FOLLOW_ROOM_TYPE = "";
|
||||
|
||||
//幸运礼物 飘屏队列
|
||||
private ArrayList<LuckyGiftMsgAllBean> mLuckyGiftList = new ArrayList<>();
|
||||
|
||||
public static HomePartyFragment newInstance() {
|
||||
HomePartyFragment homePartyFragment = new HomePartyFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
@@ -117,7 +140,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
if (roomFragment instanceof HomePartyRoomFragment) {
|
||||
((HomePartyRoomFragment) roomFragment).onNewIntent(intent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,6 +215,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
gameMainBinding.ivRoomNotice.setOnClickListener(this);
|
||||
roomMore.setOnClickListener(this);
|
||||
ivFollowRoom.setOnClickListener(this);
|
||||
// ivRoomShare.setOnClickListener(this);
|
||||
@@ -241,7 +264,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
case RoomEvent.ROOM_INFO_UPDATE:
|
||||
updateView(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
break;
|
||||
case RoomEvent.RECEIVE_NORMALE_GIFT:
|
||||
case RoomEvent.RECEIVE_NORMALE_GIFT://普通
|
||||
onReceiveGiftMsg(roomEvent.getGiftReceiveInfo());
|
||||
break;
|
||||
case RoomEvent.RECEIVE_MUTLT_NORMALEI_GIFT://普通多人
|
||||
@@ -265,12 +288,17 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
case RoomEvent.FANS_TEAM_JOIN:
|
||||
onReceiveFansTeamJoinMsg(roomEvent.getChatRoomMessage());
|
||||
break;
|
||||
case RoomEvent.MSG_SUPER_LUCKY_GIFT:
|
||||
onLuckyGiftMsg(roomEvent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取礼物飘屏是否展示
|
||||
*
|
||||
@@ -359,8 +387,18 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
tempFragment = SingleRoomFragment.newInstance();
|
||||
}
|
||||
break;
|
||||
case RoomInfo.ROOMTYPE_PARTY:
|
||||
if (!(tempFragment instanceof PartyRoomFragment)) {
|
||||
tempFragment = PartyRoomFragment.Companion.newInstance();
|
||||
}
|
||||
break;
|
||||
case RoomInfo.ROOMTYPE_REVELRY:
|
||||
if (!(tempFragment instanceof RevelryRoomFragment)) {
|
||||
tempFragment = RevelryRoomFragment.Companion.newInstance();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!(tempFragment instanceof HomePartyRoomFragment)) {
|
||||
if (tempFragment == null || !(tempFragment.getClass().getSimpleName().equals(HomePartyRoomFragment.class.getSimpleName()))) {
|
||||
tempFragment = HomePartyRoomFragment.newInstance();
|
||||
}
|
||||
break;
|
||||
@@ -390,6 +428,12 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
ivFollowRoom.setImageResource(AvRoomDataManager.get().isRoomFans ? R.drawable.room_ic_collect_yes : R.drawable.room_ic_collect_no);
|
||||
|
||||
setIdOnlineData();
|
||||
|
||||
if (AvRoomDataManager.get().getRoomType() != RoomInfo.ROOMTYPE_GAME) {
|
||||
gameMainBinding.ivRoomNotice.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
gameMainBinding.ivRoomNotice.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,6 +455,9 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_room_notice:
|
||||
showRoomIntroduction(AvRoomDataManager.get().isRoomOwner() || AvRoomDataManager.get().isRoomAdmin());
|
||||
break;
|
||||
case R.id.room_more:
|
||||
int gravity = Gravity.END;
|
||||
if(UiUtils.INSTANCE.isRtl(requireContext())){
|
||||
@@ -470,10 +517,16 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
luckyGiftTipPool.clear();
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
mLuckyGiftList.clear();
|
||||
|
||||
if (giftView != null) {
|
||||
giftView.release();
|
||||
}
|
||||
EventBus.getDefault().unregister(this);
|
||||
gameMainBinding.giftComboBtn.cancel();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -487,10 +540,10 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
updateOnlineNumberView(onlineNumber);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 普通多人
|
||||
*
|
||||
* @param giftMultiReceiverInfo
|
||||
*/
|
||||
private void onReceiveMultiGiftMsg(GiftMultiReceiverInfo giftMultiReceiverInfo) {
|
||||
if (giftMultiReceiverInfo == null || !isResumed()) return;
|
||||
@@ -498,12 +551,12 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
giftView = (GiftV2View) mVsGift2View.inflate();
|
||||
}
|
||||
giftView.onReceiveGiftToMultiMsg(giftMultiReceiverInfo);
|
||||
giftMultiReceiverInfo.isMulti = true;
|
||||
gameMainBinding.giftComboLayout.onRoomCustomMsg(giftMultiReceiverInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通全麦
|
||||
*
|
||||
* @param multiGiftReceiveInfo
|
||||
*/
|
||||
private void onReceiveAllMicGiftMsg(MultiGiftReceiveInfo multiGiftReceiveInfo) {
|
||||
if (multiGiftReceiveInfo == null || !isResumed()) return;
|
||||
@@ -511,14 +564,20 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
giftView = (GiftV2View) mVsGift2View.inflate();
|
||||
}
|
||||
giftView.onReceiveMultiGiftMsg(multiGiftReceiveInfo);
|
||||
gameMainBinding.giftComboLayout.onRoomCustomMsg(GiftToolbox.transformToGiftMultiReceiverInfo(multiGiftReceiveInfo));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通
|
||||
*/
|
||||
private void onReceiveGiftMsg(GiftReceiveInfo giftReceiveInfo) {
|
||||
if (giftReceiveInfo == null || !isResumed()) return;
|
||||
if (giftView == null) {
|
||||
giftView = (GiftV2View) mVsGift2View.inflate();
|
||||
}
|
||||
giftView.onReceiveGiftMsg(giftReceiveInfo);
|
||||
gameMainBinding.giftComboLayout.onRoomCustomMsg(GiftToolbox.transformToGiftMultiReceiverInfo(giftReceiveInfo));
|
||||
}
|
||||
|
||||
private void onReceiveMagicMsg(MagicReceivedInfo magicReceivedInfo) {
|
||||
@@ -572,4 +631,167 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void showRoomIntroduction(Boolean modify) {
|
||||
var isModify = modify;
|
||||
RoomInfo info = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
isModify = false;
|
||||
}
|
||||
if (isModify) {
|
||||
RoomTitleEditActivity.startForResult(getActivity(), info.getRoomDesc(), info.getIntroduction());
|
||||
} else {
|
||||
DialogFragment dialogFragment =
|
||||
RoomTitleDialogFragment.getInstance(info.getRoomDesc(), info.getIntroduction());
|
||||
dialogFragment.show(requireActivity().getSupportFragmentManager(), "roomTitle");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGiftComboEvent(GiftComboEvent event) {
|
||||
if (event.getAction() == GiftComboEvent.Action.ACT_GIFT_BEGIN) {
|
||||
if (gameMainBinding.giftComboBtn.isInCombo()){
|
||||
gameMainBinding.giftComboBtn.waitStart();
|
||||
}
|
||||
} else if (event.getAction() == GiftComboEvent.Action.ACT_GIFT_END) {
|
||||
showComboBtn(event.getGiftNumber());
|
||||
}else if (event.getAction() == GiftComboEvent.Action.ACT_GIFT_CANCEL) {
|
||||
if (gameMainBinding.giftComboBtn.isInCombo()) {
|
||||
gameMainBinding.giftComboBtn.cancel();
|
||||
}
|
||||
}else if (event.getAction() == GiftComboEvent.Action.ACT_GIFT_POINT) {
|
||||
ComboUtil.INSTANCE.setPoint(gameMainBinding.giftComboBtn);
|
||||
}
|
||||
}
|
||||
|
||||
private void showComboBtn(int number) {
|
||||
if (gameMainBinding.giftComboBtn.getOnGiftComboEndListener() == null) {
|
||||
|
||||
gameMainBinding.giftComboBtn.setOnClickListener(v -> {
|
||||
ComboUtil.INSTANCE.setPoint(gameMainBinding.giftComboBtn);
|
||||
EventBus.getDefault().post(new GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_START));
|
||||
gameMainBinding.giftComboBtn.onBtnDown();
|
||||
});
|
||||
|
||||
|
||||
gameMainBinding.giftComboBtn.setOnGiftComboEndListener(new BonsellaJoinAttackButtonView.OnGiftComboEndListener() {
|
||||
@Override
|
||||
public void onGiftComboEnd() {
|
||||
gameMainBinding.giftComboBtn.showView(false);
|
||||
EventBus.getDefault().post(new GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_SHOW));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
gameMainBinding.giftComboBtn.showView(true);
|
||||
gameMainBinding.giftComboBtn.start();
|
||||
gameMainBinding.giftComboBtn.updateNumber(number);
|
||||
}
|
||||
|
||||
|
||||
private void onLuckyGiftMsg(RoomEvent roomEvent) {
|
||||
MsgSuperLuckyGift msgSuperLuckyGift = roomEvent.getMsgSuperLuckyGift();
|
||||
if (msgSuperLuckyGift != null) {
|
||||
if (msgSuperLuckyGift.luckyGiftMsgAllBean != null) {
|
||||
showLuckyGiftDlg(msgSuperLuckyGift.luckyGiftMsgAllBean);
|
||||
}
|
||||
|
||||
if (msgSuperLuckyGift.luckyGiftMsgSelfBean != null) {
|
||||
showLuckyGiftDlgNotify(msgSuperLuckyGift.luckyGiftMsgSelfBean);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Handler handler = new Handler(Looper.getMainLooper());
|
||||
private WeakPool<View> luckyGiftTipPool = new WeakPool<>(3);
|
||||
private void showLuckyGiftDlgNotify(LuckyGiftMsgSelfBean luckyGiftMsgBean) {
|
||||
if (luckyGiftMsgBean == null) return;
|
||||
if (luckyGiftMsgBean.getUid() != AuthModel.get().getCurrentUid()) return;
|
||||
if (luckyGiftMsgBean.getRoomId() != AvRoomDataManager.get().getRoomId()) return;
|
||||
if (luckyGiftMsgBean.getRoomUid() != AvRoomDataManager.get().getRoomUid()) return;
|
||||
|
||||
LogUtils.i(" showLuckyGiftDlgNotify = start");
|
||||
|
||||
View root = luckyGiftTipPool.acquire(() -> {
|
||||
return LayoutInflater.from(gameMainBinding.flLuckyGiftNotifyLayout.getContext()).inflate(R.layout.layout_room_notify_lucky_gift_tip, gameMainBinding.flLuckyGiftNotifyLayout, false);
|
||||
});
|
||||
LayoutRoomNotifyLuckyGiftTipBinding binding = LayoutRoomNotifyLuckyGiftTipBinding.bind(root);
|
||||
binding.coinNum.setText(NumberUtils.format(luckyGiftMsgBean.getCoins()));
|
||||
binding.winNum.setText(java.lang.String.valueOf(luckyGiftMsgBean.getTimes()));
|
||||
if (luckyGiftMsgBean.getLevel() > 1) {
|
||||
binding.rootView.setBackgroundResource(R.drawable.bg_lucky_gift_tip_2);
|
||||
}
|
||||
root.setAlpha(0f);
|
||||
root.setScaleX(0f);
|
||||
root.setScaleY(0f);
|
||||
gameMainBinding.flLuckyGiftNotifyLayout.addView(root);
|
||||
GiftAnimUtil.showAnimation(root);
|
||||
// GiftAnimUtil.expandAnimation(root);
|
||||
|
||||
handler.postDelayed(() -> {
|
||||
try {
|
||||
root.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(500)
|
||||
.withEndAction(() -> {
|
||||
gameMainBinding.flLuckyGiftNotifyLayout.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
root.clearAnimation();
|
||||
gameMainBinding.flLuckyGiftNotifyLayout.removeView(root);
|
||||
luckyGiftTipPool.release(root);
|
||||
}
|
||||
});
|
||||
})
|
||||
.start();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}, 2300);
|
||||
}
|
||||
|
||||
BaseRoomNotifyeLuckGiftDialog allServiceLuckGiftDialog;
|
||||
private void showLuckyGiftDlg(LuckyGiftMsgAllBean luckyGiftMsgAllBean){
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDlg() ");
|
||||
mLuckyGiftList.add(luckyGiftMsgAllBean);
|
||||
if (!(allServiceLuckGiftDialog != null && allServiceLuckGiftDialog.isShowing())) {
|
||||
LuckyGiftMsgAllBean data = mLuckyGiftList.remove(0);
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDlg() -> showLuckyGiftDialog"+mLuckyGiftList.size());
|
||||
showLuckyGiftDialog(data);
|
||||
}
|
||||
}
|
||||
private void showLuckyGiftDialog(LuckyGiftMsgAllBean luckyGiftMsgAllBean){
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDialog() ");
|
||||
allServiceLuckGiftDialog = new BaseRoomNotifyeLuckGiftDialog(requireContext());
|
||||
allServiceLuckGiftDialog.setLuckyGiftMsgBean(luckyGiftMsgAllBean);
|
||||
allServiceLuckGiftDialog.setMCallBack(new BaseRoomNotifyeLuckGiftDialog.CallBack() {
|
||||
@Override
|
||||
public void onHide() {
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDialog() ->onHide");
|
||||
gameMainBinding.getRoot().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDialog() ->onHide->postDelayed");
|
||||
if (!mLuckyGiftList.isEmpty()){
|
||||
LuckyGiftMsgAllBean data = mLuckyGiftList.remove(0);
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDialog() ->onHide->postDelayed-> "+mLuckyGiftList.size());
|
||||
showLuckyGiftDialog(data);
|
||||
}
|
||||
}
|
||||
},100);
|
||||
}
|
||||
});
|
||||
allServiceLuckGiftDialog.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
@@ -14,8 +15,13 @@ import com.chwl.app.avroom.headline.RoomHeadlineWidget;
|
||||
import com.chwl.app.avroom.online.RoomOnlineWidget;
|
||||
import com.chwl.app.avroom.rank.RoomRankNumberWidget;
|
||||
import com.chwl.app.music.widget.MusicPlayerView;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity;
|
||||
import com.chwl.core.room.bean.RightBottomIconConfig;
|
||||
import com.chwl.core.room.bean.RoomIcon;
|
||||
import com.chwl.core.room.core.RoomDataService;
|
||||
import com.chwl.core.room.pk.event.PKDataUpdateEvent;
|
||||
import com.chwl.core.support.room.AudioRoomContext;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent;
|
||||
import com.chwl.app.R;
|
||||
@@ -79,6 +85,7 @@ import io.reactivex.Single;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
|
||||
/**
|
||||
* 轰趴房间
|
||||
@@ -101,6 +108,8 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
private PKMicQueueDialog pkMicQueueDialog;
|
||||
private Disposable roomPkOrderDisposable;
|
||||
|
||||
private boolean hasBaishunGames;
|
||||
|
||||
public static HomePartyRoomFragment newInstance() {
|
||||
HomePartyRoomFragment roomFragment = new HomePartyRoomFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
@@ -149,6 +158,28 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
updateQueuingMicBtn();
|
||||
updatePkScoreBoard();
|
||||
initRoomPkOrder(AvRoomDataManager.get().showPkBeginTime, AvRoomDataManager.get().pkBeginTime);
|
||||
requestData();
|
||||
}
|
||||
|
||||
private void requestData() {
|
||||
RoomDataService dataService = (RoomDataService) AudioRoomContext.Companion.get().findAbility(RoomDataService.class.getSimpleName());
|
||||
String cacheKey = "gameplay_list#" + hashCode();
|
||||
Disposable disposable = AvRoomModel.get().getRoomGamePlayList().doOnError(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
hasBaishunGames = false;
|
||||
updateConfigButtonArea();
|
||||
}
|
||||
}).subscribe(new Consumer<List<RoomIcon>>() {
|
||||
@Override
|
||||
public void accept(List<RoomIcon> roomIcons) throws Exception {
|
||||
if (dataService != null) {
|
||||
dataService.putData(cacheKey, roomIcons);
|
||||
}
|
||||
hasBaishunGames = roomIcons.size() > 0;
|
||||
updateConfigButtonArea();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -197,6 +228,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
gameBinding.setRoomInfo(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
updateQueuingMicBtn();
|
||||
updatePkScoreBoard();
|
||||
updateConfigButtonArea();
|
||||
getMvpPresenter().updateLeaveMode();
|
||||
break;
|
||||
case RoomEvent.ENTER_ROOM:
|
||||
@@ -467,6 +499,13 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
gameBinding.ivQueuingMicro.setVisibility(View.GONE);
|
||||
gameBinding.bottomView.updateQueuingMicButton();
|
||||
}
|
||||
updateMicroView();
|
||||
changeModelShowView();
|
||||
refreshDatingNextStatus();
|
||||
// updateConfigButtonArea();
|
||||
}
|
||||
|
||||
protected void updateMicroView(){
|
||||
String microType = microView.getAdapter() == null ? BaseMicroViewAdapter.MICRO_TYPE_NULL : microView.getAdapter().microType();
|
||||
if (AvRoomDataManager.get().isCpRoom()) {
|
||||
if (!microType.equals(BaseMicroViewAdapter.MICRO_TYPE_CP)) {
|
||||
@@ -484,21 +523,37 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
if (microView.getAdapter() != null) {
|
||||
microView.getAdapter().notifyDataSetChanged();
|
||||
}
|
||||
changeModelShowView();
|
||||
refreshDatingNextStatus();
|
||||
if (AvRoomDataManager.get().isDatingMode()) {
|
||||
gameBinding.ivGame.setVisibility(View.GONE);
|
||||
} else {
|
||||
gameBinding.ivGame.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updateMicBtn() {
|
||||
super.updateMicBtn();
|
||||
refreshDatingNextStatus();
|
||||
}
|
||||
|
||||
public void updateConfigButtonArea() {
|
||||
RightBottomIconConfig configModel = AvRoomDataManager.get().rightBottomIconConfig;
|
||||
if (configModel == null) {
|
||||
gameBinding.ivConfigEntrance.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (configModel.getIcon1Url() == null) {
|
||||
gameBinding.ivConfigEntrance.setVisibility(View.GONE);
|
||||
} else {
|
||||
ImageLoadUtils.loadAvatar(configModel.getIcon1Url(), gameBinding.ivConfigEntrance);
|
||||
gameBinding.ivConfigEntrance.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (configModel.getIcon2Url() != null) {
|
||||
ImageLoadUtils.loadAvatar(configModel.getIcon2Url(), gameBinding.ivGame);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasBaishunGames) {
|
||||
gameBinding.ivGame.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
gameBinding.ivGame.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateQueuingMicBtn() {
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
|
||||
bottomView.updateQueuingMicButton();
|
||||
@@ -561,7 +616,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onDatingSelectUserEvent(DatingSelectUserEvent event) {
|
||||
if (getMvpPresenter() != null) {
|
||||
|
@@ -0,0 +1,34 @@
|
||||
package com.chwl.app.avroom.fragment
|
||||
|
||||
import com.chwl.app.avroom.adapter.BaseMicroViewAdapter
|
||||
import com.chwl.app.avroom.adapter.PartyMicroViewAdapter
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.example.lib_utils.ktx.setMargin
|
||||
|
||||
/**
|
||||
* 聚会房
|
||||
*/
|
||||
class PartyRoomFragment : HomePartyRoomFragment() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): PartyRoomFragment {
|
||||
return PartyRoomFragment()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
super.onFindViews()
|
||||
microView.setMargin(0,UiUtils.dip2px(30f),0,0)
|
||||
}
|
||||
|
||||
override fun updateMicroView() {
|
||||
val microType =
|
||||
if (microView.adapter == null) BaseMicroViewAdapter.MICRO_TYPE_NULL else microView.adapter.microType()
|
||||
if (microType != BaseMicroViewAdapter.MICRO_TYPE_PARTY) {
|
||||
microView.bindAdapter(PartyMicroViewAdapter(mContext))
|
||||
}
|
||||
if (microView.adapter != null) {
|
||||
microView.adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.chwl.app.avroom.fragment
|
||||
|
||||
import com.chwl.app.avroom.adapter.BaseMicroViewAdapter
|
||||
import com.chwl.app.avroom.adapter.RevelryMicroViewAdapter
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.example.lib_utils.ktx.setMargin
|
||||
|
||||
/**
|
||||
* 狂欢房
|
||||
*/
|
||||
class RevelryRoomFragment : HomePartyRoomFragment() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): RevelryRoomFragment {
|
||||
return RevelryRoomFragment()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
super.onFindViews()
|
||||
microView.setMargin(0, UiUtils.dip2px(30f),0,0)
|
||||
}
|
||||
|
||||
override fun updateMicroView() {
|
||||
val microType =
|
||||
if (microView.adapter == null) BaseMicroViewAdapter.MICRO_TYPE_NULL else microView.adapter.microType()
|
||||
if (microType != BaseMicroViewAdapter.MICRO_TYPE_REVELRY) {
|
||||
microView.bindAdapter(RevelryMicroViewAdapter(mContext))
|
||||
}
|
||||
if (microView.adapter != null) {
|
||||
microView.adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
}
|
@@ -26,6 +26,7 @@ import com.chwl.app.fansteam.FansTeamJoinActivity
|
||||
import com.chwl.app.fansteam.FansTeamJoinedActivity
|
||||
import com.chwl.app.fansteam.FansTeamViewModel
|
||||
import com.chwl.app.music.widget.MusicPlayerView
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity
|
||||
import com.chwl.core.UriProvider
|
||||
@@ -36,6 +37,10 @@ import com.chwl.core.im.custom.bean.RequestUpmicAttachment
|
||||
import com.chwl.core.im.custom.bean.RoomPKAttachment
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.manager.RoomEvent
|
||||
import com.chwl.core.room.core.RoomDataService
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.core.support.room.AudioRoomContext.Companion.get
|
||||
import com.chwl.core.support.room.RoomAbility
|
||||
import com.chwl.core.user.bean.UserInfo
|
||||
import com.chwl.library.base.factory.CreatePresenter
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
@@ -63,6 +68,8 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
private lateinit var gameBinding: FragmentSingleRoomBinding
|
||||
private lateinit var upMicDialog: RequestUpMicDialog
|
||||
|
||||
private var hasBaishunGames = false
|
||||
|
||||
private val fansTeamViewModel: FansTeamViewModel by viewModels()
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_single_room
|
||||
|
@@ -2,6 +2,7 @@ package com.chwl.app.avroom.headline
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
@@ -9,12 +10,15 @@ import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomHeadlineWidgetBinding
|
||||
import com.chwl.app.public_chat.core.ChatRoomClient
|
||||
import com.chwl.app.public_chat.core.ChatRoomClientManager
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment
|
||||
import com.chwl.core.im.custom.bean.HeadlineChangedAttachment
|
||||
import com.chwl.core.public_chat_hall.bean.HeadlineBean
|
||||
import com.chwl.core.public_chat_hall.model.PublicChatModel
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.example.lib_utils.AppUtils
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum
|
||||
|
||||
@@ -44,6 +48,12 @@ class RoomHeadlineWidget : FrameLayoutRoomWidget {
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
if (UiUtils.isRtl(AppUtils.getApp())) {
|
||||
binding.tvHeadlineContent.gravity = Gravity.RIGHT
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart(roomView: RoomView) {
|
||||
super.onStart(roomView)
|
||||
if (!isInEditMode) {
|
||||
@@ -83,19 +93,17 @@ class RoomHeadlineWidget : FrameLayoutRoomWidget {
|
||||
|
||||
private fun requestCurrentHeadline() {
|
||||
safeLaunch {
|
||||
val data = PublicChatModel.getCurrentHeadline()
|
||||
updateHeadline(data)
|
||||
// val data = PublicChatModel.getCurrentHeadline()
|
||||
// updateHeadline(data)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateHeadline(data: HeadlineBean?) {
|
||||
val content = data?.content
|
||||
if (data?.isValid() == true && !content.isNullOrEmpty()) {
|
||||
binding.tvHeadlineContent.text = content
|
||||
this.isVisible = true
|
||||
} else {
|
||||
this.isVisible = false
|
||||
}
|
||||
binding.tvHeadlineContent.text = data?.content ?: ""
|
||||
binding.ivAvatar.loadAvatar(data?.avatar)
|
||||
binding.tvName.text = "${data?.nick ?: ""} :"
|
||||
binding.tvMoney.text = data?.payMoneyNum?.toString() ?: "0"
|
||||
this.isVisible = data?.isValid() == true && !data.content.isNullOrEmpty()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
@@ -9,6 +9,7 @@ import android.util.SparseArray;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chwl.core.manager.RoomMicQueueModel;
|
||||
import com.chwl.core.support.room.AudioRoomContext;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -121,11 +122,11 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
AvRoomDataManager.get().updateServiceRoomInfo(roomInfo);
|
||||
mAvRoomModel.enterRoom(roomInfo.getRoomId(), 3, fromType, fromNick, fromUid)
|
||||
.flatMap(this::dealServerMicInfo)
|
||||
.map(this::dealMicMemberFromIMNet)
|
||||
.flatMap(this::dealMicChatRoomMemberFromIMNet)
|
||||
.flatMap((Function<SparseArray<RoomQueueInfo>, ObservableSource<SparseArray<RoomQueueInfo>>>) roomQueue -> RoomMicQueueModel.INSTANCE.queueMicQueue(roomInfo.getRoomId(),roomQueue))
|
||||
.compose(bindUntilEvent(PresenterEvent.DESTROY))
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(roomQueueInfoSparseArray -> {
|
||||
AvRoomDataManager.get().replaceMicQueue(roomQueueInfoSparseArray);
|
||||
long uid = AuthModel.get().getCurrentUid();
|
||||
AudioEngineManager.get().startRtcEngine(uid, roomInfo.getAudioSdkType());
|
||||
// TODO 临时方案:后续逐步完善整个房间的RoomContext替换计划
|
||||
@@ -220,52 +221,12 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
IMNetEaseManager.get().getChatRoomEventObservable().onNext(new RoomEvent().setEvent(RoomEvent.ROOM_EXIT));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理网易云信队列上人员的信息
|
||||
*/
|
||||
private Observable<SparseArray<RoomQueueInfo>> dealMicChatRoomMemberFromIMNet(List<String> accounts) {
|
||||
if (ListUtils.isListEmpty(accounts))
|
||||
return Observable.just(AvRoomDataManager.get().mMicQueueMemberMap);
|
||||
return IMNetEaseManager.get().fetchRoomMembersByIds(accounts).observeOn(AndroidSchedulers.mainThread())
|
||||
.flatMap(chatRoomMembers -> {
|
||||
for (ChatRoomMember chatRoomMember : chatRoomMembers) {
|
||||
AvRoomDataManager.get().updateQueueChatRoomMemberExtension(chatRoomMember);
|
||||
}
|
||||
return Single.just(AvRoomDataManager.get().mMicQueueMemberMap);
|
||||
}).toObservable();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理网易云信坑位信息
|
||||
*/
|
||||
private List<String> dealMicMemberFromIMNet(List<Entry<String, String>> entries) {
|
||||
List<String> accounts = new ArrayList<>();
|
||||
if (!ListUtils.isListEmpty(entries)) {
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
MicMemberInfo chatRoomMember;
|
||||
for (Entry<String, String> entry : entries) {
|
||||
RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().mMicQueueMemberMap.get(Integer.parseInt(entry.key));
|
||||
if (roomQueueInfo != null) {
|
||||
JsonObject valueJsonObj = jsonParser.parse(entry.value).getAsJsonObject();
|
||||
if (valueJsonObj != null) {
|
||||
chatRoomMember = mGson.fromJson(valueJsonObj, MicMemberInfo.class);
|
||||
accounts.add(chatRoomMember.getAccount());
|
||||
roomQueueInfo.mChatRoomMember = chatRoomMember;
|
||||
}
|
||||
AvRoomDataManager.get().mMicQueueMemberMap.put(Integer.valueOf(entry.key), roomQueueInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return accounts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理服务端坑位信息
|
||||
*/
|
||||
@Nullable
|
||||
private ObservableSource<List<Entry<String, String>>> dealServerMicInfo(EnterChatRoomResultData enterChatRoomResultData) {
|
||||
private ObservableSource<SparseArray<RoomQueueInfo>> dealServerMicInfo(EnterChatRoomResultData enterChatRoomResultData) {
|
||||
AvRoomDataManager.get().mEnterChatRoomResultData = enterChatRoomResultData;
|
||||
if (enterChatRoomResultData == null)
|
||||
return Observable.error(new Throwable(GET_ROOM_FROM_IMNET_ERROR));
|
||||
@@ -295,11 +256,12 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
//初始化所有坑位
|
||||
Map<String, String> micMapStr = mGson.fromJson(roomMicStr, new TypeToken<Map<String, String>>() {
|
||||
}.getType());
|
||||
SparseArray<RoomQueueInfo> queue = new SparseArray<>();
|
||||
for (Map.Entry<String, String> entry : micMapStr.entrySet()) {
|
||||
AvRoomDataManager.get().mMicQueueMemberMap.put(Integer.valueOf(entry.getKey()),
|
||||
queue.put(Integer.valueOf(entry.getKey()),
|
||||
new RoomQueueInfo(mGson.fromJson(entry.getValue(), RoomMicInfo.class), null));
|
||||
}
|
||||
return mAvRoomModel.queryRoomMicInfo(roomInfo.getRoomId());
|
||||
return Observable.just(queue);
|
||||
}
|
||||
}
|
||||
return Observable.error(new Throwable(GET_ROOM_FROM_IMNET_ERROR));
|
||||
|
@@ -1,884 +0,0 @@
|
||||
package com.chwl.app.avroom.public_chat;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Spannable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.UIHelper;
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.avroom.dialog.RoomTeamPKResultDialog;
|
||||
import com.chwl.app.avroom.widget.OnMsgLongClickListener;
|
||||
import com.chwl.app.avroom.widget.TemplateMessageAdapter;
|
||||
import com.chwl.app.common.widget.CustomImageSpan;
|
||||
import com.chwl.app.common.widget.OriginalDrawStatusClickSpan;
|
||||
import com.chwl.app.photo.BigPhotoActivity;
|
||||
import com.chwl.app.photo.PagerOption;
|
||||
import com.chwl.app.public_chat.core.viewholder.ChatRoomMessageViewHolderThumbBase;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.DividerItemDecoration;
|
||||
import com.chwl.app.ui.widget.MyItemAnimator;
|
||||
import com.chwl.app.ui.widget.RecyclerViewNoViewpagerScroll;
|
||||
import com.chwl.app.ui.widget.TextSpannableBuilder;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.app.utils.ObjectTypeHelper;
|
||||
import com.chwl.app.utils.RegexUtil;
|
||||
import com.chwl.core.DemoCache;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.bean.attachmsg.RoomQueueMsgAttachment;
|
||||
import com.chwl.core.decoration.car.bean.CarInfo;
|
||||
import com.chwl.core.home.event.FollowRoomEvent;
|
||||
import com.chwl.core.home.model.CollectionRoomModel;
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.chwl.core.im.custom.bean.HeadlineChangedAttachment;
|
||||
import com.chwl.core.im.custom.bean.MonsterHuntingResultAttachment;
|
||||
import com.chwl.core.im.custom.bean.MonsterStatusAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomFollowOwnerAttachment2;
|
||||
import com.chwl.core.im.custom.bean.RoomTipAttachment;
|
||||
import com.chwl.core.im.custom.bean.TarotAttachment;
|
||||
import com.chwl.core.level.UserLevelResourceType;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterHuntingResult;
|
||||
import com.chwl.core.noble.NobleUtil;
|
||||
import com.chwl.core.praise.PraiseModel;
|
||||
import com.chwl.core.public_chat_hall.bean.HeadlineBean;
|
||||
import com.chwl.core.room.bean.RoomInfo;
|
||||
import com.chwl.core.room.pk.attachment.RoomPkAttachment;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.utils.ExtensionUtil;
|
||||
import com.chwl.library.common.util.Utils;
|
||||
import com.chwl.library.utils.JavaUtil;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.chwl.library.utils.SizeUtils;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.example.lib_utils.spannable.SpannableTextBuilder;
|
||||
import com.netease.nim.uikit.business.session.emoji.MoonUtil;
|
||||
import com.netease.nim.uikit.common.util.media.ImageUtil;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessageExtension;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
|
||||
import com.netease.nimlib.sdk.msg.attachment.ImageAttachment;
|
||||
import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.NotificationType;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
/**
|
||||
* 直播間消息界面
|
||||
*
|
||||
* @author xiaoyu
|
||||
*/
|
||||
public class PublicChatMessageView extends FrameLayout {
|
||||
|
||||
private static final String TAG = "PublicChatMessageView";
|
||||
private final static int MAX_MESSAGE_SIZE = 100;//公屏最多展示條數
|
||||
private final static int BLOCK_MAX_MESSAGE_SIZE = MAX_MESSAGE_SIZE * 3 / 2;//在查看消息停住的時候 最多消息條數.
|
||||
private final List<ChatRoomMessage> atMessages = new ArrayList<>();
|
||||
private final List<ChatRoomMessage> chatRoomMessages = new LinkedList<>();
|
||||
private RecyclerView messageListView;
|
||||
private TextView tvBottomTip;
|
||||
private TextView tvAtTip;
|
||||
private MessageAdapter mMessageAdapter;
|
||||
private LinearLayoutManager layoutManger;
|
||||
private int paddingWidth;
|
||||
private int paddingHeight;
|
||||
private int whiteColor;
|
||||
private int greyColor;
|
||||
private int roomTipColor;
|
||||
private int badgeWidth;
|
||||
private int badgeHeight;
|
||||
private int expLevelHeight;
|
||||
private int defTextSize = 12;
|
||||
private volatile boolean needAutoScroll = true;//是否自動滾動到底部
|
||||
private Consumer<String> clickConsumer;
|
||||
private OnClick onClick;
|
||||
|
||||
private OnMsgLongClickListener onLongClickListener;
|
||||
private TemplateMessageAdapter templateMessageAdapter;
|
||||
|
||||
public PublicChatMessageView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PublicChatMessageView(Context context, AttributeSet attr) {
|
||||
this(context, attr, 0);
|
||||
}
|
||||
|
||||
public PublicChatMessageView(Context context, AttributeSet attr, int i) {
|
||||
super(context, attr, i);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public void setOnLongClickListener(OnMsgLongClickListener onLongClickListener) {
|
||||
this.onLongClickListener = onLongClickListener;
|
||||
}
|
||||
|
||||
public void setClickConsumer(Consumer<String> clickConsumer) {
|
||||
this.clickConsumer = clickConsumer;
|
||||
}
|
||||
|
||||
public void setOnClick(OnClick onClick) {
|
||||
this.onClick = onClick;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private void init(Context context) {
|
||||
whiteColor = ContextCompat.getColor(context, R.color.white);
|
||||
greyColor = ContextCompat.getColor(context, R.color.white_transparent_50);
|
||||
roomTipColor = ContextCompat.getColor(context, R.color.color_FEE057);
|
||||
paddingWidth = Utils.dip2px(context, 11);
|
||||
paddingHeight = Utils.dip2px(context, 6);
|
||||
badgeWidth = Utils.dip2px(context, 15);
|
||||
badgeHeight = Utils.dip2px(context, 15);
|
||||
//經驗等級圖片後臺已經更換尺寸了,公屏同步下,尺寸是36:18
|
||||
expLevelHeight = Utils.dip2px(context, 18);
|
||||
// 內容區域
|
||||
layoutManger = new LinearLayoutManager(context, RecyclerView.VERTICAL, false);
|
||||
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
messageListView = new RecyclerViewNoViewpagerScroll(context);
|
||||
messageListView.setLayoutParams(params);
|
||||
messageListView.setFadingEdgeLength(60);
|
||||
messageListView.setVerticalFadingEdgeEnabled(true);
|
||||
messageListView.setOverScrollMode(OVER_SCROLL_NEVER);
|
||||
messageListView.setHorizontalScrollBarEnabled(false);
|
||||
addView(messageListView);
|
||||
messageListView.setLayoutManager(layoutManger);
|
||||
messageListView.addItemDecoration(new DividerItemDecoration(context, layoutManger.getOrientation(), 16, R.color.transparent));
|
||||
mMessageAdapter = new MessageAdapter(getContext());
|
||||
mMessageAdapter.setData(chatRoomMessages);
|
||||
messageListView.setAdapter(mMessageAdapter);
|
||||
messageListView.setItemAnimator(new MyItemAnimator());
|
||||
messageListView.getItemAnimator().setAddDuration(0);
|
||||
messageListView.getItemAnimator().setChangeDuration(0);
|
||||
messageListView.getItemAnimator().setMoveDuration(0);
|
||||
messageListView.getItemAnimator().setRemoveDuration(0);
|
||||
((SimpleItemAnimator) messageListView.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
|
||||
// 底部有新消息
|
||||
tvBottomTip = new TextView(context);
|
||||
LayoutParams params1 = new LayoutParams(
|
||||
Utils.dip2px(context, 115F), Utils.dip2px(context, 27));
|
||||
params1.gravity = Gravity.BOTTOM;
|
||||
params1.leftMargin = UIUtil.getScreenWidth(context) / 2 - UIUtil.dip2px(context, 115 / 2);
|
||||
tvBottomTip.setBackgroundResource(R.drawable.bg_messge_view_bottom_tip);
|
||||
tvBottomTip.setGravity(Gravity.CENTER);
|
||||
tvBottomTip.setText(context.getString(R.string.message_view_bottom_tip));
|
||||
tvBottomTip.setTextColor(context.getResources().getColor(R.color.appColor));
|
||||
tvBottomTip.setLayoutParams(params1);
|
||||
tvBottomTip.setVisibility(GONE);
|
||||
tvBottomTip.setOnClickListener(v -> {
|
||||
tvBottomTip.setVisibility(GONE);
|
||||
needAutoScroll = true;
|
||||
if (mMessageAdapter.getItemCount() > 0) {
|
||||
messageListView.smoothScrollToPosition(mMessageAdapter.getItemCount() - 1);
|
||||
}
|
||||
});
|
||||
addView(tvBottomTip);
|
||||
|
||||
//有人@我
|
||||
tvAtTip = new TextView(context);
|
||||
LayoutParams params2 = new LayoutParams(
|
||||
Utils.dip2px(context, 115F), Utils.dip2px(context, 27));
|
||||
params2.gravity = Gravity.BOTTOM;
|
||||
params2.leftMargin = UIUtil.getScreenWidth(context) / 2 - UIUtil.dip2px(context, 115 / 2);
|
||||
tvAtTip.setBackgroundResource(R.drawable.bg_messge_view_bottom_tip);
|
||||
tvAtTip.setGravity(Gravity.CENTER);
|
||||
tvAtTip.setText(context.getString(R.string.message_view_bottom_tip));
|
||||
tvAtTip.setTextColor(context.getResources().getColor(R.color.color_FD85C9));
|
||||
tvAtTip.setLayoutParams(params2);
|
||||
tvAtTip.setVisibility(GONE);
|
||||
tvAtTip.setOnClickListener(v -> {
|
||||
if (!atMessages.isEmpty()) {
|
||||
int scrollIndex = chatRoomMessages.indexOf(atMessages.remove(0));
|
||||
if (scrollIndex != -1 && scrollIndex < mMessageAdapter.getItemCount()) {
|
||||
messageListView.smoothScrollToPosition(scrollIndex);
|
||||
}
|
||||
}
|
||||
needAutoScroll = false;
|
||||
checkShowAtTip();
|
||||
});
|
||||
addView(tvAtTip);
|
||||
|
||||
messageListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(final RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
|
||||
// Logger.e(TAG, "onScrollStateChanged: SCROLL_STATE_DRAGGING");
|
||||
needAutoScroll = false;
|
||||
}
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
// Logger.e(TAG, "onScrollStateChanged: SCROLL_STATE_IDLE");
|
||||
|
||||
int lastVisibleItemPosition = layoutManger.findLastVisibleItemPosition();
|
||||
|
||||
if (lastVisibleItemPosition == RecyclerView.NO_POSITION) {
|
||||
// Logger.e(TAG, "lastCompletelyVisibleItemPosition : RecyclerView.NO_POSITION");
|
||||
needAutoScroll = true;
|
||||
} else if (!atMessages.isEmpty() && atMessages.remove(chatRoomMessages.get(lastVisibleItemPosition))) {
|
||||
checkShowAtTip();
|
||||
}
|
||||
// Log.e(TAG, "lastVisibleItemPosition:" + lastVisibleItemPosition
|
||||
// + " mMessageAdapter.getItemCount()-1:" + (recyclerView.getAdapter().getItemCount()-1)
|
||||
// + " dis:"+ (lastVisibleItemPosition-(recyclerView.getAdapter().getItemCount()-1)));
|
||||
if (lastVisibleItemPosition >= recyclerView.getAdapter().getItemCount() - 3) {
|
||||
//最後一個顯示出來了
|
||||
// Logger.e(TAG, ResUtil.getString(R.string.avroom_widget_messageview_01));
|
||||
needAutoScroll = true;
|
||||
tvBottomTip.setVisibility(GONE);
|
||||
keepSizeUnderLimit();
|
||||
} else {
|
||||
// Logger.e(TAG, ResUtil.getString(R.string.avroom_widget_messageview_02));
|
||||
// needAutoScroll = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private TemplateMessageAdapter getTemplateMessageAdapter() {
|
||||
if (templateMessageAdapter == null) {
|
||||
templateMessageAdapter = new TemplateMessageAdapter(uid -> {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(uid)).subscribe(clickConsumer);
|
||||
}
|
||||
});
|
||||
}
|
||||
return templateMessageAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加公屏消息請使用 {@link AvRoomDataManager#addChatRoomMessage(ChatRoomMessage)}
|
||||
*/
|
||||
public void addMessages(ChatRoomMessage msg) {
|
||||
if (msg == null) return;
|
||||
chatRoomMessages.add(msg);
|
||||
//通知adapter 刷新
|
||||
mMessageAdapter.notifyItemInserted(mMessageAdapter.getItemCount() - 1);
|
||||
showTipsOrScrollToBottom();
|
||||
checkAtMe(msg, false);
|
||||
}
|
||||
|
||||
public void addMessages(List<ChatRoomMessage> messages) {
|
||||
if (messages == null) return;
|
||||
chatRoomMessages.addAll(messages);
|
||||
//通知adapter 刷新
|
||||
mMessageAdapter.notifyDataSetChanged();
|
||||
showTipsOrScrollToBottom();
|
||||
for (ChatRoomMessage message : messages) {
|
||||
checkAtMe(message, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void addHistoryMessages(List<ChatRoomMessage> messages) {
|
||||
chatRoomMessages.addAll(0, messages);
|
||||
mMessageAdapter.notifyDataSetChanged();
|
||||
messageListView.scrollToPosition(mMessageAdapter.getItemCount() - 1);
|
||||
for (ChatRoomMessage message : messages) {
|
||||
checkAtMe(message, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void keepSizeUnderLimit() {
|
||||
while (chatRoomMessages.size() > MAX_MESSAGE_SIZE) {
|
||||
Log.i("keepSizeUnderLimit", "size" + chatRoomMessages.size());
|
||||
ChatRoomMessage message = chatRoomMessages.remove(0);
|
||||
if (atMessages.remove(message)) {
|
||||
checkShowAtTip();
|
||||
}
|
||||
mMessageAdapter.notifyItemRemoved(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkShowAtTip() {
|
||||
tvAtTip.setText(getContext().getString(R.string.message_at_tip, atMessages.size()));
|
||||
tvAtTip.setVisibility(atMessages.size() == 0 ? GONE : VISIBLE);
|
||||
}
|
||||
|
||||
private void checkAtMe(ChatRoomMessage msg, boolean history) {
|
||||
if (msg.getMsgType() != MsgTypeEnum.text) return;
|
||||
List<String> atUids = ExtensionUtil.getListExtension(msg, UserInfo.AT_UIDS);
|
||||
List<String> atNames = ExtensionUtil.getListExtension(msg, UserInfo.AT_NAMES);
|
||||
if (!ListUtils.isListEmpty(atUids) && !ListUtils.isListEmpty(atNames)) {
|
||||
for (int i = 0; i < atUids.size(); i++) {
|
||||
String uid = atUids.get(i);
|
||||
// 只有當被 @ 人的數組中包含自己的時候才會去變色
|
||||
if (Objects.equals(uid, String.valueOf(AuthModel.get().getCurrentUid()))) {
|
||||
Map<String, Long> atMap = DemoCache.readAtMsgUuid();
|
||||
if (atMap == null || !atMap.containsKey(msg.getUuid())) {
|
||||
if (!atMessages.contains(msg) && (!needAutoScroll || history)) {
|
||||
atMessages.add(msg);
|
||||
checkShowAtTip();
|
||||
}
|
||||
DemoCache.saveAtMsgUuid(msg.getUuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showTipsOrScrollToBottom() {
|
||||
if (!needAutoScroll) {
|
||||
tvBottomTip.setVisibility(VISIBLE);
|
||||
//超過某值後自動滾動下去
|
||||
if (mMessageAdapter.getItemCount() > BLOCK_MAX_MESSAGE_SIZE) {
|
||||
if (mMessageAdapter.getItemCount() > 0) {
|
||||
messageListView.smoothScrollToPosition(mMessageAdapter.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void clear() {
|
||||
if (mMessageAdapter != null) {
|
||||
chatRoomMessages.clear();
|
||||
mMessageAdapter.notifyDataSetChanged();
|
||||
}
|
||||
if (tvBottomTip != null) {
|
||||
needAutoScroll = true;
|
||||
tvBottomTip.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setNeedAutoScroll(boolean needAutoScroll) {
|
||||
this.needAutoScroll = needAutoScroll;
|
||||
}
|
||||
|
||||
public RecyclerView getMessageListView(){
|
||||
return messageListView;
|
||||
}
|
||||
|
||||
public interface OnClick {
|
||||
/**
|
||||
* 公屏查看公告
|
||||
*/
|
||||
void onShowRoomIntroduction();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageViewHolder> implements OnClickListener,Function1<Drawable, ImageSpan> {
|
||||
|
||||
private Context mContext;
|
||||
private List<ChatRoomMessage> data;
|
||||
|
||||
private int ITEM_TYPE_IMAGE = 1;
|
||||
|
||||
public MessageAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setData(List<ChatRoomMessage> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
ChatRoomMessage chatRoomMessage = data.get(position);
|
||||
if (chatRoomMessage.getMsgType() == MsgTypeEnum.image) {
|
||||
return ITEM_TYPE_IMAGE;
|
||||
}
|
||||
|
||||
return super.getItemViewType(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == ITEM_TYPE_IMAGE) {
|
||||
return new MessageAdapter.MessageViewHolder(LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.list_item_chatroom_msg_image, parent, false));
|
||||
|
||||
}
|
||||
return new MessageViewHolder(LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.list_item_chatrrom_msg, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(MessageViewHolder holder, int position) {
|
||||
if (getItemViewType(position) == ITEM_TYPE_IMAGE) {
|
||||
convertImage(holder, data.get(position));
|
||||
} else {
|
||||
convert(holder, data.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
protected void convertImage(MessageViewHolder baseViewHolder, ChatRoomMessage chatRoomMessage) {
|
||||
TextView tvContent = baseViewHolder.tvContent;
|
||||
tvContent.setLineSpacing(0, 1);
|
||||
tvContent.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||
tvContent.setOnClickListener(this);
|
||||
tvContent.setTag(chatRoomMessage);
|
||||
if (UiUtils.INSTANCE.isRtl(tvContent.getContext())) {
|
||||
tvContent.setTextDirection(View.TEXT_DIRECTION_RTL);
|
||||
}
|
||||
try {
|
||||
setVIPMessageBackground(chatRoomMessage, baseViewHolder.itemView);
|
||||
ChatRoomMessageExtension extension = chatRoomMessage.getChatRoomMessageExtension();
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
addCommonTag(chatRoomMessage, text, tvContent);
|
||||
String nickName = extension == null ? ResUtil.getString(R.string.avroom_widget_messageview_0116) : RegexUtil.getPrintableString(extension.getSenderNick());
|
||||
text.append(nickName, new ForegroundColorSpan(greyColor));
|
||||
tvContent.setText(text.build());
|
||||
|
||||
ImageView imageView = baseViewHolder.itemView.findViewById(R.id.iv_image);
|
||||
ImageAttachment msgAttachment = (ImageAttachment) chatRoomMessage.getAttachment();
|
||||
String path = msgAttachment.getThumbPath();
|
||||
if (TextUtils.isEmpty(path)) {
|
||||
path = msgAttachment.getPath();
|
||||
}
|
||||
if (TextUtils.isEmpty(path)) {
|
||||
path = "";
|
||||
}
|
||||
ImageLoadUtilsV2.loadImage(imageView, path);
|
||||
int[] bounds = new int[]{msgAttachment.getWidth(), msgAttachment.getHeight()};
|
||||
ImageUtil.ImageSize imageSize = ImageUtil.getThumbnailDisplaySize(bounds[0], bounds[1], ChatRoomMessageViewHolderThumbBase.getImageMaxEdge(), ChatRoomMessageViewHolderThumbBase.getImageMinEdge());
|
||||
ViewGroup.LayoutParams maskParams = imageView.getLayoutParams();
|
||||
maskParams.width = imageSize.width;
|
||||
maskParams.height = imageSize.height;
|
||||
imageView.setLayoutParams(maskParams);
|
||||
String finalPath = path;
|
||||
imageView.setOnClickListener(v -> {
|
||||
BigPhotoActivity.start((Activity) mContext, ObjectTypeHelper.pathToCustomItems(finalPath),
|
||||
0, new PagerOption());
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void convert(MessageViewHolder baseViewHolder, ChatRoomMessage chatRoomMessage) {
|
||||
if (chatRoomMessage == null) return;
|
||||
TextView tvContent = baseViewHolder.tvContent;
|
||||
tvContent.setLineSpacing(0, 1);
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setTextSize(defTextSize);
|
||||
tvContent.setOnClickListener(this);
|
||||
tvContent.setOnLongClickListener(null);
|
||||
tvContent.setTag(chatRoomMessage);
|
||||
tvContent.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||
if (UiUtils.INSTANCE.isRtl(tvContent.getContext())) {
|
||||
tvContent.setTextDirection(View.TEXT_DIRECTION_RTL);
|
||||
}
|
||||
clearBackground(tvContent);
|
||||
try {
|
||||
if (chatRoomMessage.getMsgType() == MsgTypeEnum.tip) {
|
||||
// 房間通告
|
||||
tvContent.setTextColor(ContextCompat.getColor(mContext, R.color.color_white));
|
||||
tvContent.setText(chatRoomMessage.getContent());
|
||||
tvContent.setBackgroundResource(R.drawable.shape_room_message_tip_bg);
|
||||
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.text) {
|
||||
setMsgText(chatRoomMessage, tvContent);
|
||||
setVIPMessageBackground(chatRoomMessage, tvContent);
|
||||
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.notification) {
|
||||
// 加上勛章
|
||||
setMsgNotification(chatRoomMessage, tvContent, baseViewHolder.getAdapterPosition());
|
||||
setVIPMessageBackground(chatRoomMessage, tvContent);
|
||||
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) {
|
||||
if (chatRoomMessage.getAttachment() != null && chatRoomMessage.getAttachment() instanceof CustomAttachment) {
|
||||
CustomAttachment attachment = (CustomAttachment) chatRoomMessage.getAttachment();
|
||||
int first = attachment.getFirst();
|
||||
int second = attachment.getSecond();
|
||||
if (first == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED) {
|
||||
if (second == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED_SUB) {
|
||||
setHeadlineMsg(chatRoomMessage, tvContent, attachment);
|
||||
}
|
||||
} else {
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
}
|
||||
} else {
|
||||
tvContent.setText("");
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedOperationException e) {
|
||||
e.printStackTrace();
|
||||
clearBackground(tvContent);
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
} catch (Exception e) {
|
||||
clearBackground(tvContent);
|
||||
tvContent.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
private void clearBackground(TextView textView) {
|
||||
// 清除文字
|
||||
textView.setText("");
|
||||
// 清除聊天氣泡
|
||||
textView.setBackgroundResource(R.drawable.shape_room_message_bg);
|
||||
textView.setPadding(paddingWidth, paddingHeight, paddingWidth, paddingHeight);
|
||||
}
|
||||
|
||||
private void setNullBackground(TextView textView) {
|
||||
// 清除聊天氣泡
|
||||
textView.setBackground(null);
|
||||
textView.setPadding(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public void setVIPMessageBackground(ChatRoomMessage chatRoomMessage, View view) {
|
||||
String androidBubbleUrl = NobleUtil.getResource(UserInfo.BUBBLE_URL_ANDROID, chatRoomMessage);
|
||||
if (TextUtils.isEmpty(androidBubbleUrl)) return;
|
||||
view.setPadding(paddingWidth, ScreenUtil.dip2px(10), paddingWidth, ScreenUtil.dip2px(10));
|
||||
ImageLoadUtils.loadNinePatchBg(view, androidBubbleUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* {badge}{level}xxx: 文字內容
|
||||
*
|
||||
* @param chatRoomMessage -
|
||||
* @param tvContent -
|
||||
*/
|
||||
private void setMsgText(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
addCommonTag(chatRoomMessage, text, tvContent);
|
||||
String nickName;
|
||||
if (chatRoomMessage.getFromAccount() != null && chatRoomMessage.getFromAccount().equals(AuthModel.get().getCurrentUid() + "")) {
|
||||
nickName = ResUtil.getString(R.string.avroom_widget_messageview_0116);
|
||||
} else {
|
||||
nickName = NobleUtil.getNamePlate(UserInfo.NICK, chatRoomMessage);
|
||||
}
|
||||
text.append(nickName, new ForegroundColorSpan(greyColor));
|
||||
text.append(": " + chatRoomMessage.getContent(), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
List<String> atUids = ExtensionUtil.getListExtension(chatRoomMessage, UserInfo.AT_UIDS);
|
||||
List<String> atNames = ExtensionUtil.getListExtension(chatRoomMessage, UserInfo.AT_NAMES);
|
||||
if (!ListUtils.isListEmpty(atUids) && !ListUtils.isListEmpty(atNames)) {
|
||||
for (int i = 0; i < atUids.size(); i++) {
|
||||
String name = atNames.get(i);
|
||||
String uid = atUids.get(i);
|
||||
// 只有當被 @ 人的數組中包含自己的時候才會去變色
|
||||
if (Objects.equals(uid, String.valueOf(AuthModel.get().getCurrentUid()))) {
|
||||
Pattern pattern = Pattern.compile(Pattern.quote(name));
|
||||
Matcher matcher = pattern.matcher(text.build().toString());
|
||||
while (matcher.find()) {
|
||||
int start = matcher.start();
|
||||
int end = matcher.end();
|
||||
text.build().setSpan(new ForegroundColorSpan(getContext().getResources().getColor(R.color.color_FD85C9)),
|
||||
start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Objects.equals(chatRoomMessage.getFromAccount(), String.valueOf(AuthModel.get().getCurrentUid()))) {
|
||||
tvContent.setOnLongClickListener(null);
|
||||
} else {
|
||||
tvContent.setOnLongClickListener(v -> {
|
||||
if (onLongClickListener != null) {
|
||||
onLongClickListener.onLongClick(v, chatRoomMessage.getFromAccount(), nickName);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
MoonUtil.replaceEmoticons(getContext(), text.builder.toString(), text.builder, this);
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
|
||||
private void addCommonTag(ChatRoomMessage chatRoomMessage, @NonNull TextSpannableBuilder builder, TextView tvContent) {
|
||||
ChatRoomMessageExtension extension = chatRoomMessage.getChatRoomMessageExtension();
|
||||
String userLevel = NobleUtil.getLevel(UserLevelResourceType.EXPER_URL, chatRoomMessage);
|
||||
boolean isOfficial = NobleUtil.getIsOfficial(UserInfo.IS_OFFICIAL, chatRoomMessage);
|
||||
String vipIcon = NobleUtil.getResource(UserInfo.VIP_ICON, chatRoomMessage);
|
||||
builder.append(vipIcon, expLevelHeight)
|
||||
.append(isOfficial ? ResourcesCompat.getDrawable(getResources(),
|
||||
R.mipmap.ic_user_official_13dp, null) : null,
|
||||
badgeWidth, badgeHeight)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(AvRoomDataManager.get().isSuperAdmin(chatRoomMessage.getFromAccount()) ? ResourcesCompat.getDrawable(getResources(),
|
||||
R.drawable.ic_room_super_admin, null) : null,
|
||||
SizeUtils.dp2px(tvContent.getContext(), 23), expLevelHeight);
|
||||
|
||||
// 官方主播認證
|
||||
String tvOfficialMask = NobleUtil.getLevel(UserInfo.OAC_NAME, chatRoomMessage).trim();
|
||||
String ivOfficialMask = NobleUtil.getLevel(UserInfo.OAC_ICON, chatRoomMessage);
|
||||
if (!TextUtils.isEmpty(tvOfficialMask) && !TextUtils.isEmpty(ivOfficialMask) && extension != null) { // extension != null 表示自己
|
||||
builder.appendBgAndContent(ivOfficialMask, tvOfficialMask);
|
||||
} else if (!TextUtils.isEmpty(ivOfficialMask)) {
|
||||
builder.append(ivOfficialMask, SizeUtils.dp2px(tvContent.getContext(), 62), expLevelHeight);
|
||||
}
|
||||
//等級
|
||||
builder.append(userLevel, expLevelHeight);
|
||||
//銘牌
|
||||
String tvNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_WORD, chatRoomMessage).trim();
|
||||
String ivNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_PIC, chatRoomMessage);
|
||||
if (!TextUtils.isEmpty(tvNamePlate) && !TextUtils.isEmpty(ivNamePlate)) { // extension != null 表示自己
|
||||
builder.appendBgAndContent(ivNamePlate, tvNamePlate);
|
||||
} else if (!TextUtils.isEmpty(ivNamePlate)) {
|
||||
builder.append(ivNamePlate, expLevelHeight);
|
||||
}
|
||||
}
|
||||
|
||||
private void setHeadlineMsg(ChatRoomMessage chatRoomMessage, TextView tvContent, CustomAttachment attachment) {
|
||||
HeadlineChangedAttachment headlineAttachment = (HeadlineChangedAttachment) attachment;
|
||||
SpannableTextBuilder builder = new SpannableTextBuilder(tvContent);
|
||||
if (attachment.getSecond() == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED_SUB) {
|
||||
HeadlineBean data = headlineAttachment.getHeadlineData();
|
||||
String nick = null;
|
||||
if (data != null) {
|
||||
nick = data.getNick();
|
||||
}
|
||||
if (nick == null) {
|
||||
nick = "";
|
||||
}
|
||||
builder.appendText(String.format(ResUtil.getString(R.string.headline_message_format), nick), null, null, null, null, null, null);
|
||||
builder.setTextStyle(nick, ContextCompat.getColor(getContext(), R.color.color_DE3446), null, null, null, null, null);
|
||||
}
|
||||
tvContent.setText(builder.build());
|
||||
tvContent.setTextSize(11);
|
||||
setNullBackground(tvContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* {badge}xxx來了
|
||||
*
|
||||
* @param chatRoomMessage -
|
||||
* @param tvContent -
|
||||
*/
|
||||
private void setMsgNotification(ChatRoomMessage chatRoomMessage, TextView tvContent, int position) {
|
||||
int fromType = 0;
|
||||
String fromNick = "";
|
||||
String fromUid = "";
|
||||
Map<String, Object> remoteExtension = chatRoomMessage.getRemoteExtension();
|
||||
if (remoteExtension != null) {
|
||||
fromType = (int) remoteExtension.get("fromType");
|
||||
fromNick = (String) remoteExtension.get("fromNick");
|
||||
fromUid = (String) remoteExtension.get("fromUid");
|
||||
}
|
||||
ChatRoomNotificationAttachment attachment = (ChatRoomNotificationAttachment) chatRoomMessage.getAttachment();
|
||||
String senderNick = "";
|
||||
List<String> nicks = attachment.getTargetNicks();
|
||||
if (nicks != null && nicks.size() > 0)
|
||||
senderNick = RegexUtil.getPrintableString(attachment.getTargetNicks().get(0));
|
||||
if (attachment.getType() != NotificationType.ChatRoomMemberIn) return;
|
||||
|
||||
// 座駕
|
||||
String carName = NobleUtil.getCarName(CarInfo.CAR_NAME, chatRoomMessage);
|
||||
carName = TextUtils.isEmpty(carName) ? "" : "\"" + carName + "\"";
|
||||
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
addCommonTag(chatRoomMessage, text, tvContent);
|
||||
text.append(senderNick, new ForegroundColorSpan(roomTipColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View view) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(chatRoomMessage.getFromAccount())
|
||||
.doOnSuccess(clickConsumer).subscribe();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
text.append(TextUtils.isEmpty(carName) ? "" : ResUtil.getString(R.string.avroom_widget_messageview_0150), new ForegroundColorSpan(greyColor))
|
||||
.append(carName, new ForegroundColorSpan(roomTipColor));
|
||||
String enterText = ResUtil.getString(R.string.avroom_widget_messageview_0151);
|
||||
if (fromType == AVRoomActivity.FROM_TYPE_RECOMMEND) {
|
||||
enterText = ResUtil.getString(R.string.avroom_widget_messageview_0152);
|
||||
}
|
||||
if (fromType == AVRoomActivity.FROM_TYPE_USER || fromType == AVRoomActivity.FROM_TYPE_HELLO) {
|
||||
String finalFromUid = fromUid;
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0153), new ForegroundColorSpan(whiteColor))
|
||||
.append(fromNick, new ForegroundColorSpan(roomTipColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View view) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(finalFromUid).doOnSuccess(clickConsumer).subscribe();
|
||||
}
|
||||
}
|
||||
});
|
||||
enterText = ResUtil.getString(R.string.avroom_widget_messageview_0154);
|
||||
}
|
||||
|
||||
if (fromType == AVRoomActivity.FROM_TYPE_GAME_RECOMMEND) {
|
||||
String finalFromUid = fromUid;
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0155), new ForegroundColorSpan(whiteColor))
|
||||
.append(fromNick, new ForegroundColorSpan(roomTipColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View view) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(finalFromUid).doOnSuccess(clickConsumer).subscribe();
|
||||
}
|
||||
}
|
||||
});
|
||||
enterText = ResUtil.getString(R.string.avroom_widget_messageview_0156);
|
||||
}
|
||||
|
||||
text.append(enterText, new ForegroundColorSpan(whiteColor));
|
||||
tvContent.setText(text.build());
|
||||
tvContent.setOnClickListener(null);
|
||||
tvContent.setMovementMethod(new LinkMovementMethod());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Drawable getNewUserDrawable(ChatRoomMessage chatRoomMessage) {
|
||||
boolean newUser = NobleUtil.getIsNewUser(UserInfo.IS_NEW_USER, chatRoomMessage);
|
||||
boolean isHelloUser = NobleUtil.getIsNewUser(UserInfo.IS_FROM_SAY_HELLO_CHANNEL, chatRoomMessage);
|
||||
if (newUser) {
|
||||
return ResourcesCompat.getDrawable(getResources(),
|
||||
isHelloUser ? R.drawable.ic_new_user_hello : R.drawable.ic_new_user,
|
||||
null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String account = "";
|
||||
ChatRoomMessage chatRoomMessage = (ChatRoomMessage) v.getTag();
|
||||
if (chatRoomMessage.getMsgType() != MsgTypeEnum.tip) {
|
||||
if (chatRoomMessage.getMsgType() == MsgTypeEnum.text) {
|
||||
account = chatRoomMessage.getFromAccount();
|
||||
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.notification) {
|
||||
account = chatRoomMessage.getFromAccount();
|
||||
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) {
|
||||
CustomAttachment attachment = (CustomAttachment) chatRoomMessage.getAttachment();
|
||||
if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_ROOM_TIP) {
|
||||
account = ((RoomTipAttachment) attachment).getUid() + "";
|
||||
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_BOX) {
|
||||
account = String.valueOf(((RoomBoxPrizeAttachment) attachment).getUid());
|
||||
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_QUEUE) {
|
||||
long handleUid = ((RoomQueueMsgAttachment) attachment).handleUid;
|
||||
if (handleUid > 0) {
|
||||
account = ((RoomQueueMsgAttachment) attachment).handleUid + "";
|
||||
} else {
|
||||
//ios沒用handleUid,導致iOS發的自定義消息,拿不到uid
|
||||
account = chatRoomMessage.getFromAccount();
|
||||
}
|
||||
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_MONSTER_HUNTING) {
|
||||
switch (attachment.getSecond()) {
|
||||
case CustomAttachment.CUSTOM_MSG_SUB_TYPE_MONSTER_HUNTING:
|
||||
MonsterDataBean dataBean = ((MonsterStatusAttachment) attachment).getDataBean();
|
||||
RoomInfo mCurrentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (!Objects.equals(mCurrentRoomInfo.getUid(), dataBean.getAppearRoomUid())) {
|
||||
AVRoomActivity.start(getContext(), dataBean.getAppearRoomUid());
|
||||
} else {
|
||||
SingleToastUtil.showToast("你已經在怪獸房間內");
|
||||
}
|
||||
break;
|
||||
|
||||
case CustomAttachment.CUSTOM_NOTI_SUB_GAME_RESULT:
|
||||
MonsterHuntingResult result = ((MonsterHuntingResultAttachment) attachment).getResult();
|
||||
UIHelper.showMonsterResult(getContext(), String.valueOf(result.getMonster().getMonsterId()));
|
||||
break;
|
||||
}
|
||||
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MESS_HEAD_ROOM_PK) {
|
||||
if (attachment.getSecond() == CustomAttachment.CUSTOM_MESS_SUB_ROOM_PK_RESULT) {
|
||||
RoomTeamPKResultDialog pkResultDialog = new RoomTeamPKResultDialog(getContext(), ((RoomPkAttachment) attachment).getRoomPkData());
|
||||
pkResultDialog.show();
|
||||
}
|
||||
} else if (attachment instanceof RoomFollowOwnerAttachment2 && !AvRoomDataManager.get().isRoomFans) {
|
||||
CollectionRoomModel.get().followRoom("1", ((RoomFollowOwnerAttachment2) attachment).getOwnerUid())
|
||||
.subscribe(s -> {
|
||||
AvRoomDataManager.get().isRoomFans = true;
|
||||
SingleToastUtil.showToast("收藏成功!");
|
||||
EventBus.getDefault().post(new FollowRoomEvent());
|
||||
PraiseModel.get().setFollowRoomSuccessRoomTip(JavaUtil.str2long(chatRoomMessage.getFromAccount()));
|
||||
});
|
||||
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MESS_TAROT) {
|
||||
if (attachment instanceof TarotAttachment) {
|
||||
account = ((TarotAttachment) attachment).getTarotMsgBean().getUid() + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(account)) return;
|
||||
if (clickConsumer != null) {
|
||||
Single.just(account).subscribe(clickConsumer);
|
||||
}
|
||||
} else {
|
||||
String content = chatRoomMessage.getContent();
|
||||
if (!TextUtils.isEmpty(content) && content.equals(ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_08)))
|
||||
if (onClick != null) {
|
||||
onClick.onShowRoomIntroduction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageSpan invoke(Drawable drawable) {
|
||||
return new CustomImageSpan(drawable);
|
||||
}
|
||||
|
||||
class MessageViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvContent;
|
||||
|
||||
public MessageViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
tvContent = itemView.findViewById(R.id.tv_content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
package com.chwl.app.avroom.public_chat
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.public_chat.core.ChatRoomClient
|
||||
import com.chwl.app.public_chat.core.ChatRoomClientManager
|
||||
import com.chwl.core.im.custom.bean.HeadlineChangedAttachment
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.netease.nim.uikit.api.model.NimException
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum
|
||||
import com.netease.nimlib.sdk.msg.model.QueryDirectionEnum
|
||||
|
||||
class PublicChatRoomMessageWidget : FrameLayoutRoomWidget {
|
||||
|
||||
private val messageView: PublicChatMessageView = PublicChatMessageView(context)
|
||||
|
||||
private var chatRoomClient: ChatRoomClient? = null
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
addView(messageView, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
||||
}
|
||||
|
||||
override fun onStart(roomView: RoomView) {
|
||||
super.onStart(roomView)
|
||||
chatRoomClient = ChatRoomClientManager.getPublicChatClient()
|
||||
if (chatRoomClient == null) {
|
||||
SingleToastUtil.showToast(R.string.public_chat_not_found)
|
||||
}
|
||||
chatRoomClient?.let {
|
||||
initChatRoom(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onReceiveMessage(message: ChatRoomMessage) {
|
||||
if (!filterMessageForMessageList(message)) {
|
||||
messageView.addMessages(message)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initChatRoom(chatRoomClient: ChatRoomClient) {
|
||||
getCompositeDisposable().add(
|
||||
chatRoomClient.enterChatRoom()
|
||||
.subscribe({ requestHistory(chatRoomClient) },
|
||||
{
|
||||
if (it is NimException) {
|
||||
SingleToastUtil.showToast(context.getString(R.string.avroom_fragment_homepartyroomfragment_011) + "(${it.code})")
|
||||
} else {
|
||||
SingleToastUtil.showToast(R.string.avroom_fragment_homepartyroomfragment_011)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
getCompositeDisposable().add(chatRoomClient.messageObservable.subscribe {
|
||||
it.forEach { message ->
|
||||
onReceiveMessage(message)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun requestHistory(chatRoomClient: ChatRoomClient) {
|
||||
val typeEnums = arrayOf(MsgTypeEnum.text, MsgTypeEnum.image)
|
||||
getCompositeDisposable().add(
|
||||
chatRoomClient.requestRemoteMessageType(
|
||||
0,
|
||||
50,
|
||||
QueryDirectionEnum.QUERY_OLD,
|
||||
typeEnums
|
||||
).subscribe({
|
||||
messageView.addHistoryMessages(it.reversed())
|
||||
}, {
|
||||
it.printStackTrace()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
private fun filterMessageForMessageList(message: ChatRoomMessage): Boolean {
|
||||
if (message.msgType == MsgTypeEnum.custom && message.attachment is HeadlineChangedAttachment) {
|
||||
val data = (message.attachment as HeadlineChangedAttachment).headlineData
|
||||
if (data == null || !data.isValid()) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun getMessageView() = messageView
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
chatRoomClient = null
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ import com.example.lib_utils.ktx.singleClick
|
||||
|
||||
/**
|
||||
* 房间榜单入口
|
||||
* //todo-- 房间榜单入口
|
||||
*/
|
||||
class RoomRankNumberWidget : FrameLayoutRoomWidget, RoomWidget {
|
||||
|
||||
|
@@ -3,13 +3,13 @@ package com.chwl.app.avroom.room_album
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogLockRoomAlbumPhotoBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2
|
||||
import com.chwl.core.gift.bean.GiftReceiveInfo
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
|
||||
class UnlockRoomAlbumPhotoDialog : BaseDialog<DialogLockRoomAlbumPhotoBinding>(){
|
||||
class UnlockRoomAlbumPhotoDialog : BaseDialogFragment<DialogLockRoomAlbumPhotoBinding>(){
|
||||
|
||||
var onUnlockRoomPhotoListener: OnUnlockRoomPhotoListener? = null
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkFinishBinding
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
@@ -14,7 +14,7 @@ import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SingleRoomPkFinishDialog : BaseDialog<DialogSingleRoomPkFinishBinding>() {
|
||||
class SingleRoomPkFinishDialog : BaseDialogFragment<DialogSingleRoomPkFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkForceFinishBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
|
||||
class SingleRoomPkForceFinishDialog : BaseDialog<DialogSingleRoomPkForceFinishBinding>() {
|
||||
class SingleRoomPkForceFinishDialog : BaseDialogFragment<DialogSingleRoomPkForceFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@@ -4,7 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkReceivedBinding
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
@@ -17,7 +17,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SingleRoomPkReceivedDialog : BaseDialog<DialogSingleRoomPkReceivedBinding>() {
|
||||
class SingleRoomPkReceivedDialog : BaseDialogFragment<DialogSingleRoomPkReceivedBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.chwl.app.avroom.singleroompk
|
||||
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkRuleBinding
|
||||
import com.chwl.core.room.anotherroompk.SingleRoomPKModel
|
||||
import com.chwl.core.utils.extension.toast
|
||||
|
||||
class SingleRoomPkRuleDialog : BaseDialog<DialogSingleRoomPkRuleBinding>() {
|
||||
class SingleRoomPkRuleDialog : BaseDialogFragment<DialogSingleRoomPkRuleBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -16,11 +16,11 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chwl.app.avroom.dialog.RoomGameplayDialog;
|
||||
import com.chwl.app.avroom.activity.RoomTypeSwitchActivity;
|
||||
import com.chwl.core.utils.extension.StringExtensionKt;
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
@@ -29,7 +29,6 @@ import com.netease.nimlib.sdk.uinfo.model.UserInfo;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.BottomViewListenerWrapper;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.vip.VipMainActivity;
|
||||
import com.chwl.app.room_chat.activity.RoomMsgActivity;
|
||||
import com.chwl.core.helper.ImHelperUtils;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
@@ -59,6 +58,7 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
|
||||
*/
|
||||
private static final int NEW_OPTION = 1;
|
||||
private static final String SH_NEW_OPTION = "sh_new_option";
|
||||
private static final String NEW_OPTION_ROOM_TYPE = "new_option_room_type";
|
||||
|
||||
private BottomViewListenerWrapper wrapper;
|
||||
private ImageView openMic;
|
||||
@@ -73,6 +73,10 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
|
||||
private ImageView iconMicQueue;
|
||||
private ImageView iconRoomMsg;
|
||||
|
||||
private ImageView iconRoomBaiShunGame;
|
||||
|
||||
private ImageView pkGameView;
|
||||
|
||||
@Nullable
|
||||
private PopupWindow msgTipPopupWindow;
|
||||
@NonNull
|
||||
@@ -104,11 +108,12 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
|
||||
remoteMute = findViewById(R.id.icon_room_open_remote_mic);
|
||||
faceLayout = findViewById(R.id.room_face_layout);
|
||||
micLayout = findViewById(R.id.room_mic_layout);
|
||||
iconRoomBaiShunGame = findViewById(R.id.icon_room_baishun_game);
|
||||
|
||||
iconMicQueue = (ImageView) findViewById(R.id.icon_mic_queue);
|
||||
|
||||
iconRoomMsg = findViewById(R.id.iv_room_message);
|
||||
ImageView gameView = findViewById(R.id.icon_room_game);
|
||||
pkGameView = findViewById(R.id.icon_room_PK_game);
|
||||
openMic.setOnClickListener(this);
|
||||
sendMsgInput.setOnClickListener(this);
|
||||
sendFace.setOnClickListener(this);
|
||||
@@ -117,7 +122,8 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
|
||||
sendMagic.setOnClickListener(this);
|
||||
iconMicQueue.setOnClickListener(this);
|
||||
iconRoomMsg.setOnClickListener(this);
|
||||
gameView.setOnClickListener(this);
|
||||
pkGameView.setOnClickListener(this);
|
||||
iconRoomBaiShunGame.setOnClickListener(this);
|
||||
|
||||
setMicBtnEnable(false);
|
||||
setMicBtnOpen(false);
|
||||
@@ -156,8 +162,11 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
|
||||
|
||||
if (newOption == NEW_OPTION) {
|
||||
sendMagic.setImageResource(R.drawable.room_menu_ic_more);
|
||||
if (isRemindOptionForRoomType()) {
|
||||
sendMagic.setImageResource(R.drawable.room_menu_ic_more_new);
|
||||
}
|
||||
} else {
|
||||
sendMagic.setImageResource(R.drawable.room_menu_ic_more);
|
||||
sendMagic.setImageResource(R.drawable.room_menu_ic_more_new);
|
||||
}
|
||||
sendMagic.setClickable(true);
|
||||
sendMagic.setOnClickListener(this);
|
||||
@@ -168,6 +177,29 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRemindOptionForRoomType() {
|
||||
boolean isReminded = (boolean) SharedPreferenceUtils.get(NEW_OPTION_ROOM_TYPE, false);
|
||||
if (isReminded) {
|
||||
return false;
|
||||
}
|
||||
if (RoomTypeSwitchActivity.Companion.isCanSwitch()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean updateOptionForRoomType() {
|
||||
boolean isReminded = (boolean) SharedPreferenceUtils.get(NEW_OPTION_ROOM_TYPE, false);
|
||||
if (isReminded) {
|
||||
return false;
|
||||
}
|
||||
if (RoomTypeSwitchActivity.Companion.isCanSwitch()) {
|
||||
SharedPreferenceUtils.put(NEW_OPTION_ROOM_TYPE, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onReceiveRecentContactChanged(List<RecentContact> imMessages) {
|
||||
setRoomMessageUnread(IMMessageManager.get().queryUnreadMsg());
|
||||
@@ -215,11 +247,36 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void setBaiShunBtnOpen(boolean isOpen) {
|
||||
iconRoomBaiShunGame.setVisibility(isOpen ? VISIBLE : GONE);
|
||||
}
|
||||
|
||||
public void notifyStateChanged() {
|
||||
setMagicBtnEnable(true);
|
||||
}
|
||||
|
||||
public void showHomePartyUpMicBottom() {
|
||||
faceLayout.setVisibility(VISIBLE);
|
||||
micLayout.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
public void updateGameEntrance() {
|
||||
//todo-- game btn
|
||||
if (AvRoomDataManager.get().isManager() || SuperAdminUtil.isSuperAdmin()) {
|
||||
if (!AvRoomDataManager.get().isCpRoom()) {
|
||||
pkGameView.setVisibility(VISIBLE);
|
||||
iconRoomBaiShunGame.setVisibility(VISIBLE);
|
||||
}
|
||||
} else {
|
||||
pkGameView.setVisibility(GONE);
|
||||
iconRoomBaiShunGame.setVisibility(GONE);
|
||||
}
|
||||
if (AvRoomDataManager.get().isSingleRoom() || AvRoomDataManager.get().isDatingMode()) {
|
||||
pkGameView.setVisibility(GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void showHomePartyDownMicBottom() {
|
||||
faceLayout.setVisibility(GONE);
|
||||
micLayout.setVisibility(GONE);
|
||||
@@ -295,12 +352,14 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
|
||||
}
|
||||
break;
|
||||
case R.id.icon_room_send_magic:
|
||||
|
||||
int newOption = (int) SharedPreferenceUtils.get(SH_NEW_OPTION, 0);
|
||||
if (newOption != NEW_OPTION) {
|
||||
SharedPreferenceUtils.put(SH_NEW_OPTION, NEW_OPTION);
|
||||
setMagicBtnEnable(true);
|
||||
}
|
||||
if (updateOptionForRoomType()) {
|
||||
setMagicBtnEnable(true);
|
||||
}
|
||||
|
||||
if (wrapper != null) {
|
||||
wrapper.onMoreBtnClick();
|
||||
@@ -317,9 +376,14 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
|
||||
wrapper.onRoomMessageClick();
|
||||
}
|
||||
break;
|
||||
case R.id.icon_room_game:
|
||||
case R.id.icon_room_PK_game:
|
||||
if (wrapper != null) {
|
||||
wrapper.onRoomGameplayClick();
|
||||
wrapper.onRoomGameplayClick(true);
|
||||
}
|
||||
break;
|
||||
case R.id.icon_room_baishun_game:
|
||||
if (wrapper != null) {
|
||||
wrapper.onRoomGameplayClick(false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@@ -6,7 +6,6 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
@@ -14,7 +13,7 @@ import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.chwl.core.helper.PathHelper;
|
||||
import com.chwl.library.utils.PathHelper;
|
||||
import com.chwl.library.download.DownloadException;
|
||||
import com.chwl.library.download.DownloadManager;
|
||||
import com.chwl.library.download.DownloadRequest;
|
||||
|
@@ -23,6 +23,8 @@ import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.chwl.core.utils.ComboUtil;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
@@ -89,6 +91,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
private int mScreenWidth;
|
||||
private int mScreenHeight;
|
||||
private Keyframe[] keyScale;
|
||||
private Keyframe[] keyScaleCombo;
|
||||
private Keyframe[] keyTrans;
|
||||
private SvgaObjectPool mMagicViewPool;
|
||||
|
||||
@@ -126,6 +129,13 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
keyScale[4] = (Keyframe.ofFloat(0.5f, 2f));
|
||||
keyScale[5] = (Keyframe.ofFloat(0.8f, 2f));
|
||||
keyScale[6] = (Keyframe.ofFloat(1f, 1f));
|
||||
|
||||
keyScaleCombo = new Keyframe[4];
|
||||
keyScaleCombo[0] = (Keyframe.ofFloat(0f, 0.25f));
|
||||
keyScaleCombo[1] = (Keyframe.ofFloat(0.25f, 0.5f));
|
||||
keyScaleCombo[2] = (Keyframe.ofFloat(0.5f, 0.75f));
|
||||
keyScaleCombo[3] = (Keyframe.ofFloat(1f, 1f));
|
||||
|
||||
keyTrans = new Keyframe[3];
|
||||
keyTrans[0] = (Keyframe.ofFloat(0f, 0));
|
||||
keyTrans[1] = (Keyframe.ofFloat(0.2f, 0));
|
||||
@@ -255,6 +265,14 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
}
|
||||
Point senderPoint = micViewPoint.get(senderPosition);
|
||||
Point receivePoint = micViewPoint.get(receivePosition);
|
||||
|
||||
// 连击 特殊动画
|
||||
if (giftReceiveInfo.getUid() == AuthModel.get().getCurrentUid()){
|
||||
if (ComboUtil.INSTANCE.isChangePoint()) {
|
||||
senderPoint = ComboUtil.INSTANCE.getPoint();
|
||||
}
|
||||
}
|
||||
|
||||
//设置动画结束的位置
|
||||
if (receivePoint == null || isGameRoomMoreThan6People()) { //这种情况就是接收者已经不在麦上
|
||||
//礼物送到中间的位置
|
||||
@@ -627,6 +645,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
return;
|
||||
}
|
||||
GiftInfo giftInfo = giftReceiveInfo.getGift();
|
||||
giftInfo.uid = giftReceiveInfo.getUid();
|
||||
if (giftInfo == null) {
|
||||
return;
|
||||
}
|
||||
@@ -668,8 +687,24 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
PropertyValuesHolder p1 = PropertyValuesHolder.ofKeyframe("translationY", keyTrans[0], keyTrans[1], keyTrans[2], keyTransY3, keyTransY4, keyTransY5);
|
||||
PropertyValuesHolder p2 = PropertyValuesHolder.ofKeyframe("scaleX", keyScale);
|
||||
PropertyValuesHolder p3 = PropertyValuesHolder.ofKeyframe("scaleY", keyScale);
|
||||
ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, p2, p3, p1, p0);
|
||||
objectAnimator.setDuration(4000);
|
||||
|
||||
PropertyValuesHolder p0c = PropertyValuesHolder.ofKeyframe("translationX", keyTrans[0], keyTransX5);
|
||||
PropertyValuesHolder p1c = PropertyValuesHolder.ofKeyframe("translationY", keyTrans[0], keyTransY5);
|
||||
PropertyValuesHolder p2c = PropertyValuesHolder.ofKeyframe("scaleX", keyScaleCombo);
|
||||
PropertyValuesHolder p3c = PropertyValuesHolder.ofKeyframe("scaleY", keyScaleCombo);
|
||||
|
||||
long time;
|
||||
ObjectAnimator objectAnimator;
|
||||
// 连击 特殊动画
|
||||
if (ComboUtil.INSTANCE.isChangePoint() && giftInfo.uid == AuthModel.get().getCurrentUid()){
|
||||
objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, p2c, p3c, p1c, p0c);
|
||||
time = 600;
|
||||
}else {
|
||||
objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, p2, p3, p1, p0);
|
||||
time = 2000;
|
||||
}
|
||||
|
||||
objectAnimator.setDuration(time);
|
||||
objectAnimator.start();
|
||||
objectAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
|
@@ -2286,7 +2286,7 @@ public class MessageView extends FrameLayout {
|
||||
})
|
||||
.append(ResUtil.getString(R.string.gift_message_01), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
|
||||
text.append(luckyGiftInfo.getGiftName() + ResUtil.getString(R.string.gift_message_02), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
text.append(luckyGiftInfo.getFirstGiftName() + ResUtil.getString(R.string.gift_message_02), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(luckyGiftInfo.getUser().getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
@@ -2341,7 +2341,7 @@ public class MessageView extends FrameLayout {
|
||||
})
|
||||
.append(ResUtil.getString(R.string.gift_message_01), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
|
||||
text.append(luckyGiftInfo.getGiftName() + ResUtil.getString(R.string.gift_message_02), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
text.append(luckyGiftInfo.getFirstGiftName() + ResUtil.getString(R.string.gift_message_02), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(luckyGiftInfo.getUser().getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
|
@@ -1442,6 +1442,7 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
enterRoomEffects = remoteExtension[UserInfo.ENTER_ROOM_EFFECTS] as String?
|
||||
}
|
||||
val wrapNick = "【" + targetNicks[0].subAndReplaceDot(7) + "】" + enterText
|
||||
|
||||
if (!TextUtils.isEmpty(enterRoomEffects)) {
|
||||
playMemberInAnimByUrl(wrapNick, enterRoomEffects)
|
||||
} else {
|
||||
@@ -1495,7 +1496,11 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
|
||||
private fun playMemberInAnim(text: String, svgaVideoEntity: SVGAVideoEntity) {
|
||||
binding.roomMenberInSvga.visibility = VISIBLE
|
||||
binding.roomMenberInSvga.loops = 1
|
||||
if (svgaVideoEntity.frames == 1) {
|
||||
binding.roomMenberInSvga.loops = 50
|
||||
} else {
|
||||
binding.roomMenberInSvga.loops = 1
|
||||
}
|
||||
binding.roomMenberInSvga.clearsAfterStop = true
|
||||
val dynamicEntity = SVGADynamicEntity()
|
||||
val textPaint = TextPaint()
|
||||
|
118
app/src/main/java/com/chwl/app/avroom/widget/VDHLayout.java
Normal file
118
app/src/main/java/com/chwl/app/avroom/widget/VDHLayout.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package com.chwl.app.avroom.widget;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.customview.widget.ViewDragHelper;
|
||||
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
|
||||
/**
|
||||
* 侧滑FrameLayout
|
||||
* 子View左滑删除,右滑弹起后复位
|
||||
*/
|
||||
public class VDHLayout extends FrameLayout {
|
||||
private final ViewDragHelper mDragHelper;
|
||||
|
||||
private final Point mAutoBackOriginPos = new Point();
|
||||
|
||||
private OnViewGoneListener listener;
|
||||
|
||||
public VDHLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelper.Callback() {
|
||||
@Override
|
||||
public boolean tryCaptureView(@NonNull View child, int pointerId) {
|
||||
mAutoBackOriginPos.x = child.getLeft();
|
||||
mAutoBackOriginPos.y = child.getTop();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* view的left
|
||||
*/
|
||||
@Override
|
||||
public int clampViewPositionHorizontal(@NonNull View child, int left, int dx) {
|
||||
return left;
|
||||
}
|
||||
|
||||
/**
|
||||
* view的top
|
||||
*/
|
||||
@Override
|
||||
public int clampViewPositionVertical(@NonNull View child, int top, int dy) {
|
||||
return child.getTop();
|
||||
}
|
||||
|
||||
|
||||
//手指释放的时候回调
|
||||
@Override
|
||||
public void onViewReleased(@NonNull View releasedChild, float xvel, float yvel) {
|
||||
//mAutoBackView手指释放时可以自动回去
|
||||
if (releasedChild.getLeft() < 0 && ((Math.abs(releasedChild.getLeft()) >= releasedChild.getMeasuredWidth() * 0.2))) {
|
||||
releasedChild.setEnabled(false);
|
||||
releasedChild.animate()
|
||||
.setDuration(100L)
|
||||
.translationX(-ScreenUtil.getDisplayWidth())
|
||||
.alpha(0F)
|
||||
.withEndAction(() -> {
|
||||
releasedChild.setVisibility(GONE);
|
||||
if(listener != null){
|
||||
listener.onViewGone();
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
mDragHelper.settleCapturedViewAt(mAutoBackOriginPos.x, mAutoBackOriginPos.y);
|
||||
ViewCompat.postInvalidateOnAnimation(VDHLayout.this);
|
||||
}
|
||||
}
|
||||
|
||||
//在边界拖动时回调
|
||||
@Override
|
||||
public void onEdgeDragStarted(int edgeFlags, int pointerId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewHorizontalDragRange(@NonNull View child) {
|
||||
return child.getMeasuredWidth();
|
||||
}
|
||||
|
||||
});
|
||||
mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||
return mDragHelper.shouldInterceptTouchEvent(event);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
mDragHelper.processTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void computeScroll() {
|
||||
if (mDragHelper.continueSettling(true)) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(OnViewGoneListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public interface OnViewGoneListener{
|
||||
void onViewGone();
|
||||
}
|
||||
}
|
@@ -28,6 +28,7 @@ import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -46,6 +47,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chwl.app.notify.GlobalNotifyManager;
|
||||
import com.chwl.library.language.LanguageHelper;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nimlib.sdk.NIMSDK;
|
||||
@@ -236,6 +238,21 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
}
|
||||
}
|
||||
|
||||
public void initVipCenterBar(String title) {
|
||||
mTitleBar = findViewById(R.id.title_bar);
|
||||
if (mTitleBar != null) {
|
||||
mTitleBar.setTitle(title);
|
||||
mTitleBar.setImmersive(false);
|
||||
mTitleBar.setTitleColor(getResources().getColor(R.color.color_FFE3AF));
|
||||
mTitleBar.setLeftImageResource(R.drawable.vip_center_back_button);
|
||||
mTitleBar.setBackgroundResource(R.color.transparent);
|
||||
mTitleBar.setLeftClickListener(v -> onLeftClickListener());
|
||||
if(UiUtils.INSTANCE.isRtl(context)){
|
||||
mTitleBar.leftTextViewUpdateScaleXForRTL();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void initWhiteTitleBar(String title) {
|
||||
mTitleBar = findViewById(R.id.title_bar);
|
||||
if (mTitleBar != null) {
|
||||
|
@@ -17,7 +17,7 @@ import com.trello.rxlifecycle3.components.support.RxDialogFragment
|
||||
import kotlinx.coroutines.launch
|
||||
import java.lang.reflect.ParameterizedType
|
||||
|
||||
abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
|
||||
abstract class BaseDialogFragment<T : ViewBinding> : RxDialogFragment() {
|
||||
|
||||
val isViewLoaded: Boolean get() = _binding != null
|
||||
protected var _binding: T? = null
|
@@ -63,6 +63,10 @@ public class TitleBar extends ViewGroup implements View.OnClickListener {
|
||||
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
public void leftTextViewUpdateScaleXForRTL() {
|
||||
mLeftText.setScaleX(-1);
|
||||
}
|
||||
|
||||
public TitleBar(Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
|
@@ -17,7 +17,6 @@ import com.chwl.app.databinding.PhotoDialogBinding
|
||||
import com.chwl.app.ui.widget.dialog.CommonTipDialog
|
||||
import com.chwl.library.common.base.BaseDialogFragment
|
||||
import com.chwl.library.common.photo.PhotoProvider
|
||||
import com.chwl.library.common.photo.PhotoProviderNew
|
||||
import com.chwl.library.common.util.PhotoCompressCallback
|
||||
import com.chwl.library.common.util.PhotoCompressUtil
|
||||
import com.chwl.library.common.util.PhotosCompressCallback
|
||||
@@ -84,7 +83,7 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
|
||||
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
} else {
|
||||
PhotoProviderNew.photoProvider(this, resultCode = REQUEST_CODE_OPEN_PHOTO_PROVIDER)
|
||||
PhotoProvider.photoProvider(this, resultCode = REQUEST_CODE_OPEN_PHOTO_PROVIDER)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +117,7 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
|
||||
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
} else {
|
||||
PhotoProviderNew.photoCamera(this, REQUEST_CODE_OPEN_CAMERA_PROVIDER)
|
||||
PhotoProvider.photoCamera(this, REQUEST_CODE_OPEN_CAMERA_PROVIDER)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,72 +0,0 @@
|
||||
package com.chwl.app.decoration.adapter;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.bindadapter.BaseAdapter;
|
||||
import com.chwl.app.bindadapter.BindingViewHolder;
|
||||
import com.chwl.app.databinding.ItemHeadWearBinding;
|
||||
import com.chwl.core.decoration.headwear.bean.HeadWearInfo;
|
||||
import com.chwl.core.noble.NobleUtil;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
|
||||
/**
|
||||
* Created by huangmeng1 on 2018/5/10.
|
||||
*/
|
||||
|
||||
public class HeadWearShopAdapter extends BaseAdapter<HeadWearInfo> {
|
||||
private int selectPosition;
|
||||
|
||||
public int getSelectPosition() {
|
||||
return selectPosition;
|
||||
}
|
||||
|
||||
public void setSelectPosition(int selectPosition) {
|
||||
notifyItemChanged(this.selectPosition);
|
||||
this.selectPosition = selectPosition;
|
||||
notifyItemChanged(this.selectPosition);
|
||||
}
|
||||
|
||||
public HeadWearShopAdapter(int layoutResId, int brid) {
|
||||
super(layoutResId, brid);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BindingViewHolder helper, HeadWearInfo item) {
|
||||
super.convert(helper, item);
|
||||
ItemHeadWearBinding binding = (ItemHeadWearBinding) helper.getBinding();
|
||||
binding.llRoot.setSelected(selectPosition == helper.getAdapterPosition());
|
||||
NobleUtil.loadHeadWears(item.getPic(), binding.ivHeadWear);
|
||||
binding.setSelectPosition(selectPosition == helper.getAdapterPosition());
|
||||
|
||||
if (item.getLabelType() == HeadWearInfo.LABEL_TYPE_NORMAL) {
|
||||
binding.ivTag.setVisibility(View.GONE);
|
||||
|
||||
} else if (HeadWearInfo.LABEL_TYPE_NEW == item.getLabelType()) {
|
||||
binding.ivTag.setVisibility(View.VISIBLE);
|
||||
binding.ivTag.setImageResource(R.drawable.ic_mark_new);
|
||||
|
||||
} else if (HeadWearInfo.LABEL_TYPE_DISCOUNT == item.getLabelType()) {
|
||||
binding.ivTag.setVisibility(View.VISIBLE);
|
||||
binding.ivTag.setImageResource(R.drawable.ic_mark_discount);
|
||||
|
||||
} else if (HeadWearInfo.LABEL_TYPE_LIMIT == item.getLabelType()) {
|
||||
binding.ivTag.setVisibility(View.VISIBLE);
|
||||
binding.ivTag.setImageResource(R.drawable.ic_mark_limit);
|
||||
|
||||
} else if (HeadWearInfo.LABEL_TYPE_EXCLUSIVE == item.getLabelType()) {
|
||||
binding.ivTag.setVisibility(View.VISIBLE);
|
||||
binding.ivTag.setImageResource(R.drawable.ic_mark_exclusive);
|
||||
}
|
||||
|
||||
binding.tvHeadName.setText(item.getName() + "");
|
||||
}
|
||||
|
||||
public void setCarInfoHasBeenBought(HeadWearInfo carInfo) {
|
||||
if (carInfo.getHeadwearId() <= 0 || ListUtils.isListEmpty(mData)) return;
|
||||
int index = mData.indexOf(carInfo);
|
||||
if (index == -1) return;
|
||||
mData.get(index).setStatus(HeadWearInfo.STATUS_IN_USED);
|
||||
notifyItemChanged(index);
|
||||
}
|
||||
}
|
@@ -6,9 +6,11 @@ import com.chwl.app.R;
|
||||
import com.chwl.app.bindadapter.BaseAdapter;
|
||||
import com.chwl.app.bindadapter.BindingViewHolder;
|
||||
import com.chwl.app.databinding.ItemMyHeadWearBinding;
|
||||
import com.chwl.app.utils.AvatarHelper;
|
||||
import com.chwl.core.decoration.headwear.bean.HeadWearInfo;
|
||||
import com.chwl.core.noble.NobleUtil;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.widget.SVGAView;
|
||||
|
||||
/**
|
||||
* Created by huangmeng1 on 2018/5/11.
|
||||
@@ -20,11 +22,14 @@ public class MyHeadWearAdapter extends BaseAdapter<HeadWearInfo> {
|
||||
super(layoutResId, brid);
|
||||
}
|
||||
|
||||
private SVGAView.SVGACache svgaCache = SVGAView.newCache(10);
|
||||
|
||||
@Override
|
||||
protected void convert(BindingViewHolder helper, HeadWearInfo item) {
|
||||
super.convert(helper, item);
|
||||
ItemMyHeadWearBinding binding = (ItemMyHeadWearBinding) helper.getBinding();
|
||||
NobleUtil.loadHeadWears(item.getPic(), binding.ivCarCover);
|
||||
binding.ivCarCover.bindCache(svgaCache);
|
||||
AvatarHelper.loadAvatarFrame(binding.ivCarCover, item.getFirstUrl(), item.getType());
|
||||
helper.addOnClickListener(R.id.tv_used);
|
||||
|
||||
if (item.getLabelType() == HeadWearInfo.LABEL_TYPE_NORMAL) {
|
||||
|
@@ -11,7 +11,15 @@ import com.chwl.app.databinding.ItemMyUserCardWearBinding;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.core.decoration.headwear.bean.HeadWearInfo;
|
||||
import com.chwl.core.decoration.headwear.bean.UserCardWearInfo;
|
||||
import com.chwl.library.download.DownloadException;
|
||||
import com.chwl.library.download.DownloadManager;
|
||||
import com.chwl.library.download.DownloadRequest;
|
||||
import com.chwl.library.download.DownloadTask;
|
||||
import com.chwl.library.download.FileDownloadListener;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.PathHelper;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created by huangmeng1 on 2018/5/11.
|
||||
@@ -27,7 +35,24 @@ public class MyUserCardWearAdapter extends BaseAdapter<UserCardWearInfo> {
|
||||
protected void convert(@NonNull BindingViewHolder helper, UserCardWearInfo item) {
|
||||
super.convert(helper, item);
|
||||
ItemMyUserCardWearBinding binding = (ItemMyUserCardWearBinding) helper.getBinding();
|
||||
ImageLoadUtils.loadImage(mContext, item.getPic(), binding.ivUserCardWear);
|
||||
binding.ivUserCardWearMp4.setLoop(Integer.MAX_VALUE);
|
||||
|
||||
String filePath = PathHelper.INSTANCE.generateResourcesFilePath(item.getPic());
|
||||
DownloadRequest request = DownloadRequest.Companion.build(item.getPic(), filePath, "gift_effect_download", null, 60000L);
|
||||
DownloadManager.INSTANCE.download(request, new FileDownloadListener() {
|
||||
@Override
|
||||
public void onDownloadCompleted(@NonNull DownloadTask task) {
|
||||
String path = task.getRequest().getPath();
|
||||
binding.ivUserCardWearMp4.startPlay(new File(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadError(@NonNull DownloadException exception) {
|
||||
ImageLoadUtils.loadImage(mContext, item.getPic(), binding.ivUserCardWear);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
helper.addOnClickListener(R.id.tv_used);
|
||||
|
||||
if (item.getLabelType() == HeadWearInfo.LABEL_TYPE_NORMAL) {
|
||||
|
@@ -93,18 +93,18 @@ public class MyUserCardWearFragment extends BaseBindingFragment<FrgMyDecorationC
|
||||
String cardId = headWearInfo.isUsed() ? null : headWearInfo.getCardId();
|
||||
|
||||
wearVm.userHeadWear(cardId)
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY))
|
||||
.doOnError(throwable -> {
|
||||
toast(throwable.getMessage());
|
||||
})
|
||||
.subscribe(s -> {
|
||||
for (int i = 0; i < shopAdapter.getData().size(); i++) {
|
||||
shopAdapter.getData().get(i).setUsed(Objects.equals(cardId,shopAdapter.getData().get(i).getCardId()));
|
||||
}
|
||||
shopAdapter.notifyDataSetChanged();
|
||||
//更新用户信息
|
||||
UserModel.get().updateCurrentUserInfo().subscribe();
|
||||
});
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY))
|
||||
.doOnError(throwable -> {
|
||||
toast(throwable.getMessage());
|
||||
})
|
||||
.subscribe(s -> {
|
||||
for (int i = 0; i < shopAdapter.getData().size(); i++) {
|
||||
shopAdapter.getData().get(i).setUsed(Objects.equals(cardId,shopAdapter.getData().get(i).getCardId()));
|
||||
}
|
||||
shopAdapter.notifyDataSetChanged();
|
||||
//更新用户信息
|
||||
UserModel.get().updateCurrentUserInfo().subscribe();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -129,9 +129,9 @@ class ConvertDiamondActivity : BaseViewBindingActivity<ActivityConvertDiamondBin
|
||||
}
|
||||
|
||||
binding.tvConvert.setOnClickListener { view ->
|
||||
if (binding.edDiamond.text.toString().toLong() < it.minDiamonds) {
|
||||
if (binding.edGold.text.toString().toLong() < it.minDiamonds) {
|
||||
toast(getString(R.string.convert_diamonds_01).format(it.minDiamonds))
|
||||
} else if (binding.edDiamond.text.toString().toLong() > it.maxDiamonds) {
|
||||
} else if (binding.edGold.text.toString().toLong() > it.maxDiamonds) {
|
||||
toast(getString(R.string.convert_diamonds_02).format(it.minDiamonds))
|
||||
} else {
|
||||
//去掉小数凑整:不管小数是多少,都进一
|
||||
|
@@ -19,25 +19,25 @@ class HomeMeViewModel : BaseViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun getHomeHistoryList(pageNum: Int) {
|
||||
fun getHomeHistoryList(pageNum: Int, pageSize: Int) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
historyRoomListLiveData.value = ListResult.failed(pageNum)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getHomeHistoryRoomList(pageNum, 10)
|
||||
val result = HomeModel.getHomeHistoryRoomList(pageNum, pageSize)
|
||||
historyRoomListLiveData.value = ListResult.success(result, pageNum)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getHomeCollectList(pageNum: Int) {
|
||||
fun getHomeCollectList(pageNum: Int, pageSize: Int) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
collectRoomListLiveData.value = ListResult.failed(pageNum)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getHomeMyCollectRoomList(pageNum, 10)
|
||||
val result = HomeModel.getHomeMyCollectRoomList(pageNum, pageSize)
|
||||
collectRoomListLiveData.value = ListResult.success(result, pageNum)
|
||||
}
|
||||
)
|
||||
|
@@ -13,8 +13,8 @@ class HomeMessageViewModel : BaseViewModel() {
|
||||
safeLaunch(needLoading = false, onError = {
|
||||
topPublicChatMessageLiveData.postValue(BeanResult.failed(it))
|
||||
}) {
|
||||
val value = PublicChatModel.getTopMessage()
|
||||
topPublicChatMessageLiveData.postValue(BeanResult.success(value ?: emptyList()))
|
||||
// val value = PublicChatModel.getTopMessage()
|
||||
// topPublicChatMessageLiveData.postValue(BeanResult.success(value ?: emptyList()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,13 +27,13 @@ class HomeViewModel : BaseViewModel() {
|
||||
val homeTabLiveData: MutableLiveData<List<HomeTagInfo>> = MutableLiveData<List<HomeTagInfo>>()
|
||||
|
||||
val homeRankListLiveData = MutableLiveData<List<List<HomeRankBean>>>()
|
||||
fun getTabRoomList(tabId: Int, pageNum: Int) {
|
||||
fun getTabRoomList(tabId: Int, pageNum: Int, pageSize: Int) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
tabRoomListLiveData.value = ListResult.failed(pageNum)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getHomeTabHome(tabId, pageNum, 10)
|
||||
val result = HomeModel.getHomeTabHome(tabId, pageNum, pageSize)
|
||||
tabRoomListLiveData.value = ListResult.success(result, pageNum)
|
||||
}
|
||||
)
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package com.chwl.app.home.adapter;
|
||||
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
@@ -59,7 +61,8 @@ public class CommunityNoticeAdapter extends BaseQuickAdapter<CommunityNoticeInfo
|
||||
}
|
||||
|
||||
helper.setGone(R.id.tv_label_community_notice_list, false);
|
||||
helper.setText(R.id.tv_content_community_notice_list, item.getMessage());
|
||||
TextView textView = helper.getView(R.id.tv_content_community_notice_list);
|
||||
textView.setText(item.getMessage());
|
||||
switch (item.getActionType()) {
|
||||
case 1: // 评论
|
||||
if (item.getTargetUid() == AuthModel.get().getCurrentUid()) {
|
||||
|
@@ -21,8 +21,8 @@ public class HomeIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
private final Context mContext;
|
||||
private final List<? extends CharSequence> mTitleList;
|
||||
|
||||
private int textSize = 21;
|
||||
private float minScale = 0.857f;
|
||||
private int textSize = 20;
|
||||
private float minScale = 0.8f;
|
||||
private boolean showIndicator = true;
|
||||
private OnItemSelectListener mOnItemSelectListener;
|
||||
|
||||
@@ -39,8 +39,8 @@ public class HomeIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int i) {
|
||||
ScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new ScaleTransitionPagerTitleView(context, true);
|
||||
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context, R.color.white_transparent_60));
|
||||
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(context, R.color.color_FFFFFF));
|
||||
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context, R.color.color_313131));
|
||||
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(context, R.color.color_313131));
|
||||
scaleTransitionPagerTitleView.setMinScale(minScale);
|
||||
scaleTransitionPagerTitleView.setTextSize(textSize);
|
||||
int padding = UIUtil.dip2px(context, 13);
|
||||
@@ -59,10 +59,10 @@ public class HomeIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(UIUtil.dip2px(mContext, 2.5));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(mContext, 1.5));
|
||||
indicator.setLineWidth(UIUtil.dip2px(mContext, 10));
|
||||
indicator.setColors(context.getResources().getColor(R.color.color_10ECD6));
|
||||
indicator.setLineHeight(context.getResources().getDimensionPixelOffset(R.dimen.dp_4));
|
||||
indicator.setRoundRadius(context.getResources().getDimensionPixelOffset(R.dimen.dp_2));
|
||||
indicator.setLineWidth(context.getResources().getDimensionPixelOffset(R.dimen.dp_13));
|
||||
indicator.setColors(context.getResources().getColor(R.color.color_e29030));
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
// lp.bottomMargin = mBottomMargin;
|
||||
indicator.setLayoutParams(lp);
|
||||
|
@@ -1,9 +1,13 @@
|
||||
package com.chwl.app.home.adapter
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.RecycledViewPool
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
@@ -11,14 +15,54 @@ import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.ui.utils.loadFromAssets
|
||||
import com.chwl.core.home.bean.HomeRoomInfo
|
||||
import com.example.lib_utils.AppUtils
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.opensource.svgaplayer.SVGADrawable
|
||||
import com.opensource.svgaplayer.SVGAImageView
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/13
|
||||
*/
|
||||
class HomeRoomAdapter :
|
||||
BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.home_item_room) {
|
||||
class HomeRoomAdapter : BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.home_item_room) {
|
||||
private var micUserItemViewPool = RecycledViewPool().apply {
|
||||
setMaxRecycledViews(0, 50)
|
||||
}
|
||||
|
||||
private val isRTL = UiUtils.isRtl(AppUtils.getApp())
|
||||
|
||||
override fun onCreateDefViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
return super.onCreateDefViewHolder(parent, viewType).apply {
|
||||
val micUserRecyclerView = this.getView<RecyclerView>(R.id.recycler_view_users)
|
||||
micUserRecyclerView.setOnTouchListener { v, event -> true }
|
||||
micUserRecyclerView.setRecycledViewPool(micUserItemViewPool)
|
||||
micUserRecyclerView.setHasFixedSize(true)
|
||||
micUserRecyclerView.layoutManager =
|
||||
LinearLayoutManager(parent.context, RecyclerView.HORIZONTAL, false).apply {
|
||||
this.recycleChildrenOnDetach = true
|
||||
this.isSmoothScrollbarEnabled
|
||||
}
|
||||
micUserRecyclerView.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
val offset = AppUtils.getApp().resources.getDimensionPixelOffset(R.dimen.dp_4) * -1
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
val position = parent.getChildAdapterPosition(view)
|
||||
if (position != 0) {
|
||||
if (isRTL) {
|
||||
outRect.right = offset
|
||||
} else {
|
||||
outRect.left = offset
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
micUserRecyclerView.adapter = HomeRoomUserAdapter()
|
||||
}
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
|
||||
helper.apply {
|
||||
@@ -28,18 +72,10 @@ class HomeRoomAdapter :
|
||||
setText(R.id.tv_desc, item.roomDesc)
|
||||
}
|
||||
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
helper.getView(R.id.iv_avatar_0),
|
||||
helper.getView(R.id.iv_avatar_1),
|
||||
helper.getView(R.id.iv_avatar_2),
|
||||
helper.getView(R.id.iv_avatar_3),
|
||||
helper.getView(R.id.iv_avatar_4)
|
||||
)
|
||||
for (i in avatars.indices) {
|
||||
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
|
||||
avatars[i].isInvisible = avatarUrl.isNullOrBlank()
|
||||
avatars[i].load(avatarUrl)
|
||||
}
|
||||
val micUserRecyclerView = helper.getView<RecyclerView>(R.id.recycler_view_users)
|
||||
val userAdapter = micUserRecyclerView.adapter as HomeRoomUserAdapter
|
||||
userAdapter.setNewData(item.micUsers)
|
||||
|
||||
val topView = helper.getView<ImageView>(R.id.iv_top)
|
||||
if (item.isHourTop1 == 1) {
|
||||
topView.setImageResource(R.drawable.home_room_bg_hour_top)
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package com.chwl.app.home.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.core.home.bean.MicUsersBean
|
||||
|
||||
class HomeRoomUserAdapter :
|
||||
BaseQuickAdapter<MicUsersBean, BaseViewHolder>(R.layout.home_item_room_user) {
|
||||
override fun convert(helper: BaseViewHolder, item: MicUsersBean?) {
|
||||
val avatarView = helper.getView<ImageView>(R.id.iv_avatar)
|
||||
avatarView.loadAvatar(item?.avatar)
|
||||
}
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
package com.chwl.app.home.adapter
|
||||
|
||||
import android.text.style.ImageSpan
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.core.public_chat_hall.bean.PublicChatMessageBean
|
||||
import com.netease.nim.uikit.api.NimUIKit
|
||||
import com.netease.nim.uikit.business.session.emoji.MoonUtil
|
||||
|
||||
class PublicChatLaneAdapter(private val data: MutableList<PublicChatMessageBean>) :
|
||||
RecyclerView.Adapter<BaseViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
return BaseViewHolder(
|
||||
LayoutInflater.from(parent.context).inflate(R.layout.public_chat_lane_item, null)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val item = getItem(position)
|
||||
val textView = holder.getView<TextView>(R.id.tv_message)
|
||||
MoonUtil.identifyFaceExpressionSmall(
|
||||
NimUIKit.getContext(),
|
||||
textView,
|
||||
item?.content ?: "",
|
||||
ImageSpan.ALIGN_CENTER
|
||||
)
|
||||
val avatarView = holder.getView<ImageView>(R.id.iv_avatar)
|
||||
avatarView.loadAvatar(item?.fromAvatar ?: "")
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return Int.MAX_VALUE
|
||||
}
|
||||
|
||||
fun getRealItemCount(): Int {
|
||||
return data.size
|
||||
}
|
||||
|
||||
fun setNewData(list: List<PublicChatMessageBean>) {
|
||||
data.clear()
|
||||
data.addAll(list)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun getItem(position: Int): PublicChatMessageBean? {
|
||||
if (data.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
return data[position % data.size]
|
||||
}
|
||||
|
||||
}
|
@@ -7,14 +7,14 @@ import android.view.WindowManager
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isGone
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogHelloMessageBinding
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.room_chat.activity.RoomMsgActivity
|
||||
import com.chwl.core.channel_page.bean.HelloMessageInfo
|
||||
import com.chwl.library.utils.ResUtil
|
||||
|
||||
class HelloMessageDialog : BaseDialog<DialogHelloMessageBinding>() {
|
||||
class HelloMessageDialog : BaseDialogFragment<DialogHelloMessageBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogNewUserHelloBinding
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.channel_page.bean.NewUserHelloInfo
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
|
||||
class NewUserHelloDialog : BaseDialog<DialogNewUserHelloBinding>() {
|
||||
class NewUserHelloDialog : BaseDialogFragment<DialogNewUserHelloBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -3,12 +3,12 @@ package com.chwl.app.home.dialog
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRecommendRoomBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.home.bean.HomeRoomInfo
|
||||
|
||||
class RecommendRoomDialog : BaseDialog<DialogRecommendRoomBinding>() {
|
||||
class RecommendRoomDialog : BaseDialogFragment<DialogRecommendRoomBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -19,13 +19,13 @@ import com.chwl.app.avroom.adapter.CommonVPAdapter
|
||||
import com.chwl.app.base.BaseViewBindingFragment
|
||||
import com.chwl.app.databinding.FragmentContactListBinding
|
||||
import com.chwl.app.home.HomeMessageViewModel
|
||||
import com.chwl.app.home.adapter.PublicChatLaneAdapter
|
||||
import com.chwl.app.home.helper.AutoScrollTask
|
||||
import com.chwl.app.public_chat.ui.message.PublicChatRoomMessageActivity
|
||||
import com.chwl.app.support.FragmentVisibleStateHelper
|
||||
import com.chwl.app.ui.im.friend.FriendListFragment
|
||||
import com.chwl.app.ui.im.recent.RecentListFragment
|
||||
import com.chwl.app.ui.relation.FansListFragment
|
||||
import com.chwl.app.ui.user.adapter.ContactsIndicatorAdapter
|
||||
import com.chwl.app.ui.user.adapter.UserInfoIndicatorAdapter
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.chwl.core.Constants
|
||||
@@ -41,7 +41,6 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
|
||||
MainTabContentView {
|
||||
|
||||
private val viewModel: HomeMessageViewModel by activityViewModels()
|
||||
private val publicChatAdapter = PublicChatLaneAdapter(ArrayList())
|
||||
|
||||
private val stateHelper = FragmentVisibleStateHelper(this).start {
|
||||
onVisibleChanged(it)
|
||||
@@ -63,7 +62,6 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
|
||||
} else {
|
||||
2
|
||||
}
|
||||
binding.recyclerViewPublicChat.scrollBy(x, 0)
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
@@ -85,7 +83,9 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
|
||||
tagList.add(getString(R.string.layout_fragment_contact_list_04))
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(false)
|
||||
val magicIndicatorAdapter = UserInfoIndicatorAdapter(context, tagList)
|
||||
commonNavigator.rightPadding = 20
|
||||
commonNavigator.leftPadding = 20
|
||||
val magicIndicatorAdapter = ContactsIndicatorAdapter(context, tagList)
|
||||
magicIndicatorAdapter.setOnItemSelectListener { position: Int, view: TextView? ->
|
||||
binding.viewPager.currentItem = position
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
|
||||
}
|
||||
|
||||
override fun onScroll(
|
||||
e1: MotionEvent,
|
||||
e1: MotionEvent?,
|
||||
e2: MotionEvent,
|
||||
distanceX: Float,
|
||||
distanceY: Float
|
||||
@@ -150,7 +150,7 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
|
||||
}
|
||||
|
||||
override fun onFling(
|
||||
e1: MotionEvent,
|
||||
e1: MotionEvent?,
|
||||
e2: MotionEvent,
|
||||
velocityX: Float,
|
||||
velocityY: Float
|
||||
@@ -158,37 +158,20 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
|
||||
return true
|
||||
}
|
||||
})
|
||||
binding.layoutPublicChat.singleClick {
|
||||
PublicChatRoomMessageActivity.start(requireContext())
|
||||
}
|
||||
binding.recyclerViewPublicChat.setOnTouchListener { v, event ->
|
||||
gestureDetectorCompat.onTouchEvent(event)
|
||||
}
|
||||
binding.recyclerViewPublicChat.layoutManager =
|
||||
StaggeredGridLayoutManager(2, RecyclerView.HORIZONTAL)
|
||||
binding.recyclerViewPublicChat.adapter = publicChatAdapter
|
||||
viewModel.topPublicChatMessageLiveData.observe(this) {
|
||||
val newList = it.data
|
||||
if (it.isSuccess && !newList.isNullOrEmpty()) {
|
||||
publicChatAdapter.setNewData(newList)
|
||||
switchPublicChatMessageScrollState(stateHelper.isVisible)
|
||||
}
|
||||
binding.recyclerViewPublicChat.isVisible = (publicChatAdapter.getRealItemCount() > 0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun switchPublicChatMessageScrollState(isVisible: Boolean) {
|
||||
if (isVisible && publicChatAdapter.getRealItemCount() > 0) {
|
||||
autoScrollTask.start()
|
||||
} else {
|
||||
autoScrollTask.stop()
|
||||
}
|
||||
// if (isVisible && publicChatAdapter.getRealItemCount() > 0) {
|
||||
// autoScrollTask.start()
|
||||
// } else {
|
||||
// autoScrollTask.stop()
|
||||
// }
|
||||
}
|
||||
|
||||
private fun onVisibleChanged(isVisible: Boolean) {
|
||||
switchPublicChatMessageScrollState(isVisible)
|
||||
if (isVisible) {
|
||||
viewModel.getTopPublicChatMessageIfNull()
|
||||
}
|
||||
// switchPublicChatMessageScrollState(isVisible)
|
||||
// if (isVisible) {
|
||||
// viewModel.getTopPublicChatMessageIfNull()
|
||||
// }
|
||||
}
|
||||
}
|
@@ -56,7 +56,7 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
titleList.add(getString(R.string.main_tab_recommend))
|
||||
titleList.add(getString(R.string.main_me))
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(false)
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
val magicIndicatorAdapter = HomeIndicatorAdapter(context, titleList)
|
||||
magicIndicatorAdapter.setOnItemSelectListener { position: Int, view: TextView? ->
|
||||
binding.viewPager.currentItem = position
|
||||
|
@@ -198,7 +198,7 @@ class HomeRecommendFragment : BaseViewBindingFragment<FragmentHomeRecommendBindi
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
val itemId = getItemId(position)
|
||||
return HomeTabRoomFragment.newInstance(itemId.toInt()).apply {
|
||||
autoRefreshOnVisible = true
|
||||
this.autoRefreshOnVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,7 @@ class HomeRoomCollectListFragment : BaseViewBindingFragment<HomeTabRoomFragmentB
|
||||
private val viewModel: HomeMeViewModel by viewModels()
|
||||
|
||||
private var pageNum = 1
|
||||
private val pageSize = 50
|
||||
|
||||
companion object {
|
||||
fun newInstance(): HomeRoomCollectListFragment {
|
||||
@@ -58,7 +59,7 @@ class HomeRoomCollectListFragment : BaseViewBindingFragment<HomeTabRoomFragmentB
|
||||
}
|
||||
}
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setPageSize(10)
|
||||
.setPageSize(pageSize)
|
||||
.setAdapter(adapter)
|
||||
.setRecyclerView(binding.mRecyclerRoom)
|
||||
.setEmptyView(
|
||||
@@ -90,7 +91,7 @@ class HomeRoomCollectListFragment : BaseViewBindingFragment<HomeTabRoomFragmentB
|
||||
} else {
|
||||
pageNum++
|
||||
}
|
||||
viewModel.getHomeCollectList(pageNum)
|
||||
viewModel.getHomeCollectList(pageNum, pageSize)
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
|
@@ -29,6 +29,7 @@ class HomeRoomHistoryListFragment : BaseViewBindingFragment<HomeTabRoomFragmentB
|
||||
private val viewModel: HomeMeViewModel by viewModels()
|
||||
|
||||
private var pageNum = 1
|
||||
private val pageSize = 50
|
||||
|
||||
companion object {
|
||||
fun newInstance(): HomeRoomHistoryListFragment {
|
||||
@@ -58,7 +59,7 @@ class HomeRoomHistoryListFragment : BaseViewBindingFragment<HomeTabRoomFragmentB
|
||||
}
|
||||
}
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setPageSize(10)
|
||||
.setPageSize(pageSize)
|
||||
.setAdapter(adapter)
|
||||
.setRecyclerView(binding.mRecyclerRoom)
|
||||
.setEmptyView(
|
||||
@@ -90,7 +91,7 @@ class HomeRoomHistoryListFragment : BaseViewBindingFragment<HomeTabRoomFragmentB
|
||||
} else {
|
||||
pageNum++
|
||||
}
|
||||
viewModel.getHomeHistoryList(pageNum)
|
||||
viewModel.getHomeHistoryList(pageNum, pageSize)
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.chwl.app.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@@ -33,6 +32,7 @@ class HomeTabRoomFragment : BaseViewBindingFragment<HomeTabRoomFragmentBinding>(
|
||||
var autoRefreshOnVisible = false
|
||||
|
||||
private var pageNum = 1
|
||||
private val pageSize = 50
|
||||
private var tabId: Int? = null
|
||||
|
||||
companion object {
|
||||
@@ -70,7 +70,7 @@ class HomeTabRoomFragment : BaseViewBindingFragment<HomeTabRoomFragmentBinding>(
|
||||
}
|
||||
}
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setPageSize(10)
|
||||
.setPageSize(pageSize)
|
||||
.setAdapter(adapter)
|
||||
.setRecyclerView(binding.mRecyclerRoom)
|
||||
.setEmptyView(
|
||||
@@ -102,7 +102,7 @@ class HomeTabRoomFragment : BaseViewBindingFragment<HomeTabRoomFragmentBinding>(
|
||||
} else {
|
||||
pageNum++
|
||||
}
|
||||
homeViewModel.getTabRoomList(tabId ?: 0, pageNum)
|
||||
homeViewModel.getTabRoomList(tabId ?: 0, pageNum, pageSize)
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
|
@@ -35,7 +35,7 @@ import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.app.ui.wallet.WalletActivity
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.view.GenderAgeTextView
|
||||
import com.chwl.app.vip.VipMainActivity
|
||||
import com.chwl.app.vip.VipCenterActivity
|
||||
import com.chwl.app.vip.VipViewModel
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.initial.InitialModel
|
||||
@@ -353,7 +353,7 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
}
|
||||
|
||||
R.id.iv_vip -> {
|
||||
VipMainActivity.start(mContext)
|
||||
VipCenterActivity.start(mContext)
|
||||
//进入贵族中心埋点
|
||||
val goldWalletInfo = PayModel.get().currentWalletInfo
|
||||
val map = HashMap<String, Any>(5)
|
||||
|
@@ -35,6 +35,8 @@ import com.chwl.core.utils.net.RxHelper;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
public class OpenRoomHelper {
|
||||
|
||||
public static void openRoom(BaseActivity activity) {
|
||||
@@ -135,6 +137,25 @@ public class OpenRoomHelper {
|
||||
|
||||
}
|
||||
|
||||
public static Single<RoomInfo> updateRoomInfoRx(RoomInfo roomInfo, int type, long gameId) {
|
||||
RoomSettingModel roomSettingModel = new RoomSettingModel();
|
||||
return roomSettingModel.updateRoomInfo(
|
||||
roomInfo.getTitle(),
|
||||
roomInfo.getRoomDesc(),
|
||||
roomInfo.getIntroduction(),
|
||||
roomInfo.roomPwd,
|
||||
roomInfo.getRoomTypeLable(),
|
||||
roomInfo.tagId,
|
||||
roomInfo.getUid(),
|
||||
AuthModel.get().getTicket(),
|
||||
roomInfo.isHasAnimationEffect(),
|
||||
roomInfo.getAudioQuality(),
|
||||
roomInfo.getLimitType(),
|
||||
roomInfo.isPureMode(),
|
||||
type,
|
||||
gameId);
|
||||
}
|
||||
|
||||
public static void updateRoomInfo(BaseActivity activity, RoomInfo roomInfo, int type, long gameId, boolean needOpen) {
|
||||
RoomSettingModel roomSettingModel = new RoomSettingModel();
|
||||
roomSettingModel.updateRoomInfo(
|
||||
|
@@ -15,7 +15,12 @@ import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.chwl.app.ui.login.LoginPasswordActivity;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.bean.response.result.TicketResult;
|
||||
import com.chwl.core.gift.GiftModel;
|
||||
import com.chwl.library.language.LanguageHelper;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.example.lib_utils.log.LogUtil;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.chwl.app.MainActivity;
|
||||
@@ -32,6 +37,10 @@ import com.chwl.core.utils.OaidUtil;
|
||||
import com.chwl.core.utils.SharedPreferenceUtils;
|
||||
import com.chwl.library.common.util.DeviceUtil;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* @author xiaoyu
|
||||
* @date 2017/12/30
|
||||
@@ -43,8 +52,15 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis
|
||||
private ActivitySplashBinding mBinding;
|
||||
private SplashComponent mLocalSplashVo;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
// ticket状态 -1:加载失败、0:加载中、1:加载成功
|
||||
private int ticketState = 0;
|
||||
|
||||
private volatile boolean needJump = false;
|
||||
|
||||
private Runnable jumpRunnable;
|
||||
|
||||
public static void start(Context context) {
|
||||
Intent starter = new Intent(context, SplashActivity.class);
|
||||
context.startActivity(starter);
|
||||
@@ -72,9 +88,10 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis
|
||||
// 从堆栈恢复,不再重复解析之前的intent
|
||||
setIntent(new Intent());
|
||||
}
|
||||
initiate();
|
||||
StatusBarUtil.transparencyBar(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
initTicket();
|
||||
initiate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,8 +162,12 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis
|
||||
}
|
||||
|
||||
public void jumpActivity(Intent intent) {
|
||||
AccountInfo currentAccountInfo = DemoCache.readCurrentAccountInfo();
|
||||
if (currentAccountInfo == null || TextUtils.isEmpty(currentAccountInfo.getAccess_token())) {
|
||||
jumpRunnable = () -> jumpActivityImpl(intent);
|
||||
next();
|
||||
}
|
||||
|
||||
public void jumpActivityImpl(Intent intent) {
|
||||
if (!AuthModel.get().isLogin()) {
|
||||
NimMiddleActivity.openCommunity = false;
|
||||
LoginPasswordActivity.start(this);
|
||||
finish();
|
||||
@@ -190,4 +211,53 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis
|
||||
|
||||
}
|
||||
|
||||
private void initTicket() {
|
||||
ticketState = 0;
|
||||
if (!AuthModel.get().isLogin()) {
|
||||
ticketState = -1;
|
||||
next();
|
||||
return;
|
||||
}
|
||||
AuthModel.get().refreshTicket().subscribe(new SingleObserver<TicketResult>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
disposable.add(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(TicketResult ticketResult) {
|
||||
LogUtil.d("SplashActivity", "initTicket onSuccess", false);
|
||||
onTicketSuccess();
|
||||
ticketState = 1;
|
||||
next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
LogUtil.d("SplashActivity", "initTicket throwable:" + throwable.getMessage(), false);
|
||||
SingleToastUtil.showToast(throwable.getMessage());
|
||||
AuthModel.get().reset();
|
||||
ticketState = -1;
|
||||
next();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onTicketSuccess() {
|
||||
GiftModel.get().tryLoadGiftList();
|
||||
}
|
||||
|
||||
private void next() {
|
||||
if (ticketState != 0 && jumpRunnable != null) {
|
||||
jumpRunnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (disposable != null && !disposable.isDisposed()) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import com.chwl.library.common.util.AlbumUtils;
|
||||
import com.chwl.library.common.util.ExecutorCenter;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.example.matisse.internal.entity.CustomItem;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -192,4 +193,16 @@ public class BigPhotoActivity extends BaseViewBindingActivity<ActivityBigPhotoBi
|
||||
super.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needSteepStateBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setStatusBar() {
|
||||
super.setStatusBar();
|
||||
StatusBarUtil.transparencyBar(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,76 @@
|
||||
package com.chwl.app.photo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.core.community.bean.DynamicMedia;
|
||||
import com.chwl.library.utils.ScreenUtils;
|
||||
import com.chwl.library.utils.config.BasicConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
public class DynamicImageAdapter extends BaseQuickAdapter<DynamicMedia, BaseViewHolder> {
|
||||
|
||||
private Context context;
|
||||
@Setter
|
||||
private int mTwoImageHeight;
|
||||
@Setter
|
||||
private int mThreeImageHeight;
|
||||
|
||||
private int imageWidth;
|
||||
|
||||
private int bigImageWidth;
|
||||
|
||||
@Setter
|
||||
private int singleImageHeight;
|
||||
|
||||
public DynamicImageAdapter(int layoutResId, @Nullable List<DynamicMedia> data) {
|
||||
super(layoutResId, data);
|
||||
context = BasicConfig.INSTANCE.getAppContext();
|
||||
imageWidth = UIUtil.getScreenWidth(context) * 2 / 5;
|
||||
bigImageWidth = UIUtil.getScreenWidth(context);
|
||||
|
||||
mTwoImageHeight = (ScreenUtils.getScreenWidth(context) - UIUtil.dip2px(context, 50F)) / 2;
|
||||
mThreeImageHeight = (ScreenUtils.getScreenWidth(context) - UIUtil.dip2px(context, 60F)) / 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, DynamicMedia item) {
|
||||
ImageView ivPhoto = helper.getView(R.id.riv_photo);
|
||||
helper.setGone(R.id.iv_gif_tag, item.isGif());
|
||||
ViewGroup.LayoutParams layoutParams = ivPhoto.getLayoutParams();
|
||||
if (helper.itemView instanceof ConstraintLayout && getData().size() > 1) {
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, item.getResUrl(), imageWidth);
|
||||
} else {
|
||||
switch (getData().size()) {
|
||||
case 1:
|
||||
layoutParams.height = singleImageHeight;
|
||||
ivPhoto.setLayoutParams(layoutParams);
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, item.getResUrl(), bigImageWidth);
|
||||
break;
|
||||
case 2:
|
||||
layoutParams.height = mTwoImageHeight;
|
||||
ivPhoto.setLayoutParams(layoutParams);
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, item.getResUrl(), imageWidth);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
layoutParams.height = mThreeImageHeight;
|
||||
ivPhoto.setLayoutParams(layoutParams);
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, item.getResUrl(), imageWidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@ package com.chwl.app.support
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.chwl.app.BuildConfig
|
||||
import com.chwl.app.base.BaseViewModel
|
||||
import com.chwl.core.helper.PathHelper
|
||||
import com.chwl.library.utils.PathHelper
|
||||
import com.chwl.core.home.model.HomeModel
|
||||
import com.chwl.library.common.util.SPUtils
|
||||
import com.chwl.library.download.DownloadException
|
||||
|
50
app/src/main/java/com/chwl/app/ui/debug/DebugActivity.kt
Normal file
50
app/src/main/java/com/chwl/app/ui/debug/DebugActivity.kt
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.chwl.app.ui.debug
|
||||
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.databinding.DebugActivityBinding
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
|
||||
class DebugActivity : BaseViewBindingActivity<DebugActivityBinding>() {
|
||||
override fun init() {
|
||||
initWhiteTitleBar("调试")
|
||||
initSVGAList()
|
||||
}
|
||||
|
||||
private fun initSVGAList() {
|
||||
val adapter = DebugAdapter()
|
||||
binding.recyclerView.adapter = adapter
|
||||
// binding.recyclerView.setItemViewCacheSize(-1)
|
||||
val svgaList = listOf(
|
||||
"https://image.pekolive.com/花和玫瑰.svga",
|
||||
"https://image.pekolive.com/firecrown.svga",
|
||||
"https://image.pekolive.com/ningtangchengbaoqietu.svga",
|
||||
"https://image.pekolive.com/xunmengfengche.svga",
|
||||
"https://image.pekolive.com/tonghuaqiyuan1334.svga",
|
||||
"https://image.pekolive.com/mengquyinhe.svga",
|
||||
"https://image.pekolive.com/duqinghuashu.svga",
|
||||
"https://image.pekolive.com/juzhijingling.svga",
|
||||
"https://image.pekolive.com/3121_aixintouwei.svga",
|
||||
"https://image.pekolive.com/4051_langmanyewan.svga"
|
||||
)
|
||||
val list = ArrayList<String>()
|
||||
list.addAll(svgaList)
|
||||
list.addAll(svgaList)
|
||||
adapter.setNewData(list)
|
||||
binding.btnRefreshAll.setOnClickListener {
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
binding.btnRefresh.setOnClickListener {
|
||||
adapter.notifyItemChanged(5, true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun needSteepStateBar(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun setStatusBar() {
|
||||
super.setStatusBar()
|
||||
StatusBarUtil.transparencyBar(this)
|
||||
StatusBarUtil.StatusBarLightMode(this)
|
||||
}
|
||||
}
|
47
app/src/main/java/com/chwl/app/ui/debug/DebugAdapter.kt
Normal file
47
app/src/main/java/com/chwl/app/ui/debug/DebugAdapter.kt
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.chwl.app.ui.debug
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.library.widget.SVGAView
|
||||
import com.example.lib_utils.log.ILog
|
||||
|
||||
class DebugAdapter : BaseQuickAdapter<String, BaseViewHolder>(R.layout.debug_item_svga), ILog {
|
||||
|
||||
private val svgaCache = SVGAView.newCache(10)
|
||||
override fun convertPayloads(
|
||||
helper: BaseViewHolder,
|
||||
item: String?,
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
super.convertPayloads(helper, item, payloads)
|
||||
logD("convertPayloads holder:${helper.absoluteAdapterPosition} #${helper.hashCode()} SVGAView")
|
||||
val svgaView = helper.getView<SVGAView>(R.id.svga_view)
|
||||
svgaView.loadUrl(item)
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: String?) {
|
||||
logD("convert holder:${helper.absoluteAdapterPosition} #${helper.hashCode()} SVGAView")
|
||||
helper.setText(R.id.tv_name, helper.absoluteAdapterPosition.toString())
|
||||
val item = getItem(helper.bindingAdapterPosition)
|
||||
val svgaView = helper.getView<SVGAView>(R.id.svga_view)
|
||||
svgaView.bindCache(svgaCache)
|
||||
svgaView.setLogTag(helper.absoluteAdapterPosition.toString())
|
||||
svgaView.loadUrl(item)
|
||||
}
|
||||
|
||||
override fun onViewAttachedToWindow(holder: BaseViewHolder) {
|
||||
super.onViewAttachedToWindow(holder)
|
||||
logD("onViewAttachedToWindow holder:${holder.absoluteAdapterPosition} #${holder.hashCode()} SVGAView")
|
||||
// val item = getItem(holder.bindingAdapterPosition)
|
||||
// val svgaView = holder.getView<SVGAView>(R.id.svga_view)
|
||||
// svgaView.bindCache(SVGAView.newCache(10))
|
||||
// svgaView.setLogTag(holder.absoluteAdapterPosition.toString())
|
||||
// svgaView.loadUrl(item)
|
||||
}
|
||||
|
||||
override fun onViewDetachedFromWindow(holder: BaseViewHolder) {
|
||||
super.onViewDetachedFromWindow(holder)
|
||||
logD("onViewDetachedFromWindow holder:${holder.absoluteAdapterPosition} #${holder.hashCode()} SVGAView")
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
package com.chwl.app.ui.feedback
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseBindingDialog
|
||||
import com.chwl.app.databinding.FeedbackCustomerServiceDialogBinding
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.SpacingDecoration
|
||||
import com.chwl.library.annatation.ActLayoutRes
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
|
||||
@ActLayoutRes(R.layout.feedback_customer_service_dialog)
|
||||
class CustomerServiceDialog(context: Context, val map: Map<String, String?>) :
|
||||
BaseBindingDialog<FeedbackCustomerServiceDialogBinding>(context, R.style.dialog) {
|
||||
private val adapter = CustomerServiceItemAdapter()
|
||||
|
||||
override fun onStart() {
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
super.onStart()
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
binding.layoutRoot.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
binding.tvNext.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
binding.recyclerView.addItemDecoration(
|
||||
SpacingDecoration(
|
||||
0,
|
||||
context.resources.getDimensionPixelOffset(R.dimen.dp_10),
|
||||
false
|
||||
)
|
||||
)
|
||||
binding.recyclerView.adapter = adapter
|
||||
val list = map.map {
|
||||
it
|
||||
}
|
||||
adapter.setNewData(list)
|
||||
adapter.setOnItemChildClickListener { adapter, view, position ->
|
||||
val text = this.adapter.getItem(position)?.value
|
||||
if (text != null) {
|
||||
copyText(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun copyText(text: String) {
|
||||
try {
|
||||
val cm =
|
||||
context?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
cm.setPrimaryClip(ClipData.newPlainText("text", text))
|
||||
SingleToastUtil.showToast(R.string.have_copy)
|
||||
} catch (e: Exception) {
|
||||
SingleToastUtil.showToast(e.toString())
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.chwl.app.ui.feedback
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.example.lib_utils.AppUtils
|
||||
import com.example.lib_utils.UiUtils
|
||||
|
||||
class CustomerServiceItemAdapter :
|
||||
BaseQuickAdapter<Map.Entry<String, String?>, BaseViewHolder>(R.layout.feedback_customer_service_item) {
|
||||
|
||||
private var isRTL = UiUtils.isRtl(AppUtils.getApp())
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
return super.onCreateViewHolder(parent, viewType).apply {
|
||||
this.addOnClickListener(R.id.layout_copy)
|
||||
val textView = getView<TextView>(R.id.tv_content)
|
||||
if (isRTL) {
|
||||
textView.gravity = Gravity.RIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun convert(helper: BaseViewHolder, item: Map.Entry<String, String?>) {
|
||||
val textView = helper.getView<TextView>(R.id.tv_content)
|
||||
textView.text = "${item.key}: ${item.value ?: ""}"
|
||||
}
|
||||
|
||||
}
|
353
app/src/main/java/com/chwl/app/ui/feedback/FeedbackActivity.kt
Normal file
353
app/src/main/java/com/chwl/app/ui/feedback/FeedbackActivity.kt
Normal file
@@ -0,0 +1,353 @@
|
||||
package com.chwl.app.ui.feedback
|
||||
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.widget.ImageView.ScaleType
|
||||
import androidx.activity.viewModels
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.databinding.FeedbackActivityBinding
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.ui.widget.dialog.CommonTipDialog
|
||||
import com.chwl.core.file.FileModel
|
||||
import com.chwl.core.home.bean.FeedbackTypeBean
|
||||
import com.chwl.library.common.photo.PhotoProvider
|
||||
import com.chwl.library.common.photo.PhotoProvider.photoProvider
|
||||
import com.chwl.library.common.util.PhotoCompressUtil
|
||||
import com.chwl.library.common.util.PhotosCompressCallback
|
||||
import com.chwl.library.easypermisssion.EasyPermissions
|
||||
import com.chwl.library.easyphoto.utils.settings.SettingsUtils
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.SolveEditTextScrollClash
|
||||
import com.example.lib_utils.ktx.getColorById
|
||||
import com.example.lib_utils.ktx.setOnInputChangedListener
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import com.example.lib_utils.spannable.SpannableTextBuilder
|
||||
import com.google.android.flexbox.FlexDirection
|
||||
import com.google.android.flexbox.FlexWrap
|
||||
import com.google.android.flexbox.FlexboxLayoutManager
|
||||
import com.google.android.flexbox.JustifyContent
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class FeedbackActivity : BaseViewBindingActivity<FeedbackActivityBinding>(),
|
||||
EasyPermissions.PermissionCallbacks {
|
||||
|
||||
private val PERMISSION_CODE_STORAGE = 12
|
||||
private val REQUEST_CODE_OPEN_PHOTO_PROVIDER = 111 // 从相册中选择
|
||||
|
||||
private val viewModel: FeedbackViewModel by viewModels()
|
||||
private val adapter = FeedbackTypeAdapter()
|
||||
private var compressJob: Job? = null
|
||||
private var wantShowCustomerService = false
|
||||
private var imagePath: String? = null
|
||||
private var imageUrl: String? = null
|
||||
|
||||
override fun init() {
|
||||
initWhiteTitleBar(ResUtil.getString(R.string.feedback_title))
|
||||
initView()
|
||||
initEvent()
|
||||
initObserve()
|
||||
refreshSubmitState()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
val flexBoxLayoutManager = FlexboxLayoutManager(context)
|
||||
flexBoxLayoutManager.flexDirection = FlexDirection.ROW
|
||||
flexBoxLayoutManager.flexWrap = FlexWrap.WRAP
|
||||
flexBoxLayoutManager.justifyContent = JustifyContent.FLEX_START
|
||||
binding.recyclerViewType.layoutManager = flexBoxLayoutManager
|
||||
binding.recyclerViewType.adapter = adapter
|
||||
binding.etContent.setOnTouchListener(SolveEditTextScrollClash(binding.etContent))
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
adapter.setOnItemClickListener { adapter, view, position ->
|
||||
this.adapter.selectItem(this.adapter.getItem(position))
|
||||
refreshSubmitState()
|
||||
}
|
||||
binding.tvSubmit.singleClick {
|
||||
dialogManager.showProgressDialog(this)
|
||||
submit()
|
||||
}
|
||||
binding.ivImage.singleClick {
|
||||
checkStoragePermission()
|
||||
}
|
||||
binding.ivCustomerService.singleClick {
|
||||
showCustomerServiceDialog()
|
||||
}
|
||||
binding.etContent.setOnInputChangedListener {
|
||||
updateContentInputTips(this)
|
||||
refreshSubmitState()
|
||||
true
|
||||
}
|
||||
binding.etContact.setOnInputChangedListener {
|
||||
refreshSubmitState()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun initObserve() {
|
||||
viewModel.loadingLiveData.observe(this) {
|
||||
if (it) dialogManager.showProgressDialog(this)
|
||||
else dialogManager.dismissDialog()
|
||||
}
|
||||
viewModel.configLiveData.observe(this) {
|
||||
if (it?.isSuccess == true) {
|
||||
loadTypeList(it.data?.typeEnumList)
|
||||
if (wantShowCustomerService) {
|
||||
showCustomerServiceDialog(it.data?.customContactMap)
|
||||
}
|
||||
} else if (it?.message != null) {
|
||||
toast(it.message ?: "")
|
||||
}
|
||||
wantShowCustomerService = false
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||
viewModel.submitStateFlow.collectLatest {
|
||||
dialogManager.dismissDialog()
|
||||
if (it.isSuccess) {
|
||||
toast(R.string.home_model_homemodel_01)
|
||||
finish()
|
||||
} else if (it.message != null) {
|
||||
toast(it.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateContentInputTips(length: Int) {
|
||||
if (length > 0) {
|
||||
SpannableTextBuilder(binding.tvContentCount)
|
||||
.appendText(
|
||||
text = length.toString(),
|
||||
textColor = getColorById(R.color.color_3FDDAC)
|
||||
)
|
||||
.appendText(text = "/300")
|
||||
.apply()
|
||||
} else {
|
||||
binding.tvContentCount.text = "${length}/300"
|
||||
}
|
||||
}
|
||||
|
||||
private fun showCustomerServiceDialog() {
|
||||
val config = viewModel.configLiveData.value?.data
|
||||
if (config == null) {
|
||||
wantShowCustomerService = true
|
||||
viewModel.getConfig()
|
||||
return
|
||||
}
|
||||
showCustomerServiceDialog(config.customContactMap)
|
||||
}
|
||||
|
||||
private fun showCustomerServiceDialog(info: Map<String, String>?) {
|
||||
if (info.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
CustomerServiceDialog(this, info).show()
|
||||
}
|
||||
|
||||
private fun loadTypeList(type: List<FeedbackTypeBean>?) {
|
||||
adapter.setNewData(type)
|
||||
}
|
||||
|
||||
private fun onAddImage(path: String?) {
|
||||
if (path.isNullOrEmpty()) {
|
||||
imagePath = null
|
||||
imageUrl = null
|
||||
binding.ivImage.scaleType = ScaleType.CENTER_INSIDE
|
||||
binding.ivImage.setImageResource(R.drawable.feedback_ic_add)
|
||||
} else {
|
||||
imagePath = path
|
||||
imageUrl = null
|
||||
binding.ivImage.load(path)
|
||||
binding.ivImage.scaleType = ScaleType.CENTER_CROP
|
||||
}
|
||||
refreshSubmitState()
|
||||
}
|
||||
|
||||
private fun refreshSubmitState() {
|
||||
binding.tvSubmit.isEnabled = canSubmit()
|
||||
}
|
||||
|
||||
private fun canSubmit(): Boolean {
|
||||
if (binding.etContent.text.isNullOrEmpty()) {
|
||||
return false
|
||||
}
|
||||
if (binding.etContact.text.isNullOrEmpty()) {
|
||||
return false
|
||||
}
|
||||
if (adapter.getSelectItem() == null) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun submit() {
|
||||
val content = binding.etContent.text.trim().toString()
|
||||
val contact = binding.etContact.text.trim().toString()
|
||||
val type = adapter.getSelectItem()?.type ?: ""
|
||||
val imagePath = imagePath
|
||||
if (imagePath != null && imageUrl == null) {
|
||||
uploadImage(imagePath, {
|
||||
imageUrl = it
|
||||
submit()
|
||||
}, {
|
||||
if (it != null) {
|
||||
toast(ResUtil.getString(R.string.ui_user_userinfomodifyactivity_08) + ":${it.message}")
|
||||
}
|
||||
dialogManager.dismissDialog()
|
||||
})
|
||||
} else {
|
||||
viewModel.submitFeedback(
|
||||
type = type,
|
||||
content = content,
|
||||
image = imageUrl ?: "",
|
||||
contact = contact
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun uploadImage(path: String, success: (String) -> Unit, failed: (Throwable?) -> Unit) {
|
||||
FileModel.get()
|
||||
.uploadFile(path)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe { url: String?, throwable: Throwable? ->
|
||||
if (url != null) {
|
||||
success.invoke(url)
|
||||
} else {
|
||||
failed.invoke(throwable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (requestCode == REQUEST_CODE_OPEN_PHOTO_PROVIDER) {
|
||||
if (data == null) {
|
||||
return
|
||||
}
|
||||
PhotoProvider.getResultPathListAsync(data) { list ->
|
||||
if (list.isNullOrEmpty()) {
|
||||
SingleToastUtil.showToastShort(com.netease.nim.uikit.R.string.picker_image_error)
|
||||
return@getResultPathListAsync
|
||||
}
|
||||
val paths = list.map { it.path }.toMutableList()
|
||||
compressPhotos(paths)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<String?>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this)
|
||||
}
|
||||
|
||||
private fun checkStoragePermission() {
|
||||
if (!EasyPermissions.hasPermissions(
|
||||
this,
|
||||
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
) {
|
||||
EasyPermissions.requestPermissions(
|
||||
this,
|
||||
getString(R.string.permission_storage_rationale),
|
||||
PERMISSION_CODE_STORAGE,
|
||||
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
} else {
|
||||
photoProvider(
|
||||
this,
|
||||
1,
|
||||
true,
|
||||
REQUEST_CODE_OPEN_PHOTO_PROVIDER,
|
||||
true,
|
||||
true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun compressPhotos(paths: MutableList<String>) {
|
||||
compressJob?.cancel(null)
|
||||
compressJob = PhotoCompressUtil.compress(
|
||||
this, paths,
|
||||
PhotoCompressUtil.getCompressCachePath(),
|
||||
object : PhotosCompressCallback {
|
||||
override fun onSuccess(compressedImgList: ArrayList<String>) {
|
||||
val firstItem = compressedImgList.firstOrNull() ?: return
|
||||
onAddImage(firstItem)
|
||||
}
|
||||
|
||||
override fun onFail(e: Throwable) {
|
||||
ToastUtils.show(getString(R.string.picker_image_error))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun needSteepStateBar(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun setStatusBar() {
|
||||
super.setStatusBar()
|
||||
StatusBarUtil.transparencyBar(this)
|
||||
StatusBarUtil.StatusBarLightMode(this)
|
||||
}
|
||||
|
||||
override fun onPermissionsGranted(requestCode: Int, perms: MutableList<String>) {
|
||||
if (requestCode == PERMISSION_CODE_STORAGE) {
|
||||
checkStoragePermission()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPermissionsDenied(requestCode: Int, perms: MutableList<String>) {
|
||||
if (requestCode == PERMISSION_CODE_STORAGE) {
|
||||
val requestTip = getString(R.string.permission_storage_denied)
|
||||
val mPrivacyDialog = CommonTipDialog(context)
|
||||
mPrivacyDialog.setTipMsg(requestTip)
|
||||
mPrivacyDialog.setOkText(getString(R.string.room_perform_go_update))
|
||||
mPrivacyDialog.setOnActionListener(object : CommonTipDialog.OnActionListener {
|
||||
override fun onOk() {
|
||||
//同意跳到应用详情页面
|
||||
SettingsUtils.startMyApplicationDetailsForResult(
|
||||
this@FeedbackActivity,
|
||||
packageName
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCancel() {
|
||||
super.onCancel()
|
||||
//取消跳到应用详情页面
|
||||
ToastUtils.show(getString(R.string.permission_storage_refused))
|
||||
}
|
||||
})
|
||||
mPrivacyDialog.show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (viewModel.configLiveData.value?.data == null) {
|
||||
viewModel.getConfig()
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
package com.chwl.app.ui.feedback
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.core.home.bean.FeedbackTypeBean
|
||||
|
||||
class FeedbackTypeAdapter : BaseQuickAdapter<FeedbackTypeBean, BaseViewHolder>(R.layout.feedback_item_type) {
|
||||
|
||||
private var selectItem: FeedbackTypeBean? = null
|
||||
|
||||
override fun convertPayloads(
|
||||
helper: BaseViewHolder,
|
||||
item: FeedbackTypeBean?,
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
super.convertPayloads(helper, item, payloads)
|
||||
convertState(helper, item)
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: FeedbackTypeBean?) {
|
||||
helper.setText(R.id.tv_name, item?.desc ?: "")
|
||||
convertState(helper, item)
|
||||
}
|
||||
|
||||
private fun convertState(helper: BaseViewHolder, item: FeedbackTypeBean?) {
|
||||
if (selectItem == item) {
|
||||
helper.setBackgroundRes(R.id.tv_name, R.drawable.shape_85f6d3_15dp)
|
||||
} else {
|
||||
helper.setBackgroundRes(R.id.tv_name, R.drawable.shape_f3f5fa_15dp)
|
||||
}
|
||||
}
|
||||
|
||||
fun selectItem(item: FeedbackTypeBean?) {
|
||||
this.selectItem = item
|
||||
notifyItemRangeChanged(0, itemCount, true)
|
||||
}
|
||||
|
||||
fun getSelectItem(): FeedbackTypeBean? {
|
||||
return selectItem
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package com.chwl.app.ui.feedback
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.chwl.app.base.BaseViewModel
|
||||
import com.chwl.core.bean.response.BeanResult
|
||||
import com.chwl.core.home.bean.FeedbackConfigBean
|
||||
import com.chwl.core.home.model.HomeModel
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
|
||||
class FeedbackViewModel : BaseViewModel() {
|
||||
val configLiveData = MutableLiveData<BeanResult<FeedbackConfigBean>?>()
|
||||
|
||||
val submitStateFlow = MutableSharedFlow<BeanResult<Any?>>()
|
||||
|
||||
fun getConfig() {
|
||||
safeLaunch(
|
||||
needLoading = true,
|
||||
onError = {
|
||||
configLiveData.postValue(BeanResult.failed(it))
|
||||
}) {
|
||||
val value = HomeModel.getFeedbackConfig()
|
||||
configLiveData.postValue(BeanResult.success(value))
|
||||
}
|
||||
}
|
||||
|
||||
fun submitFeedback(type: String, content: String, image: String, contact: String) {
|
||||
safeLaunch(
|
||||
needLoading = true,
|
||||
onError = {
|
||||
submitStateFlow.emit(BeanResult.failed(it))
|
||||
}) {
|
||||
val value = HomeModel.commitFeedback(contact, content, image, type)
|
||||
submitStateFlow.emit(BeanResult.success(value))
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,202 @@
|
||||
package com.chwl.app.ui.game_team.invite
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.common.widget.dialog.DialogManager
|
||||
import com.chwl.app.databinding.GameTeamInviteDialogBinding
|
||||
import com.chwl.app.ui.pay.ChargeActivity
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.game_team.UserGameTeamInfo
|
||||
import com.chwl.core.pay.PayModel
|
||||
import com.chwl.core.pay.bean.WalletInfo
|
||||
import com.chwl.core.utils.net.BalanceNotEnoughExeption
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
||||
|
||||
class GameTeamInviteDialog : BaseDialogFragment<GameTeamInviteDialogBinding>() {
|
||||
|
||||
private val viewModel: GameTeamInviteViewModel by viewModels()
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var gravity = Gravity.CENTER
|
||||
|
||||
private var gameId: Long = 0
|
||||
private var gameUid: Long = 0
|
||||
private var gameBackground: String? = null
|
||||
private var gamePrice: Long = 0
|
||||
private var gameInning: Long = 1
|
||||
private var dialogManager: DialogManager? = null
|
||||
|
||||
var successListener: (() -> Unit)? = null
|
||||
|
||||
companion object {
|
||||
fun newInstance(info: UserGameTeamInfo): GameTeamInviteDialog {
|
||||
return newInstance(info.uid ?: 0, info.gameId ?: 0, info.pic, info.price ?: 0, 1)
|
||||
}
|
||||
|
||||
fun newInstance(
|
||||
targetUid: Long,
|
||||
gameId: Long,
|
||||
gameBackground: String?,
|
||||
gamePrice: Long,
|
||||
gameInning: Long,
|
||||
): GameTeamInviteDialog {
|
||||
return GameTeamInviteDialog().apply {
|
||||
arguments = Bundle().apply {
|
||||
putLong("targetUid", targetUid)
|
||||
putLong("gameId", gameId)
|
||||
putSerializable("gameBackground", gameBackground)
|
||||
putLong("gamePrice", gamePrice)
|
||||
putLong("gameInning", gameInning)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
gameUid = arguments?.getLong("targetUid") ?: 0
|
||||
gameId = arguments?.getLong("gameId") ?: 0
|
||||
gameBackground = arguments?.getString("gameBackground")
|
||||
gamePrice = arguments?.getLong("gamePrice") ?: 0
|
||||
gameInning = arguments?.getLong("gameInning") ?: 1
|
||||
dialogManager = DialogManager(requireContext())
|
||||
initView()
|
||||
initEvent()
|
||||
initObserve()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateBalance()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
binding.ivGameImage.load(gameBackground)
|
||||
updateInning(0)
|
||||
requestBalance()
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
binding.ivClose.setOnClickListener {
|
||||
safeDismiss()
|
||||
}
|
||||
|
||||
binding.tvPay.singleClick {
|
||||
pay()
|
||||
}
|
||||
|
||||
binding.layoutRecharge.setOnClickListener {
|
||||
ChargeActivity.start(context)
|
||||
}
|
||||
|
||||
binding.ivCountAdd.setOnClickListener {
|
||||
updateInning(1)
|
||||
}
|
||||
|
||||
binding.ivCountSubtract.setOnClickListener {
|
||||
updateInning(-1)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initObserve() {
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
viewLifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
viewModel.payResultFlow.collectLatest {
|
||||
dialogManager?.dismissDialog()
|
||||
if (it.isSuccess) {
|
||||
successListener?.invoke()
|
||||
SingleToastUtil.showToast(R.string.game_team_19)
|
||||
safeDismiss()
|
||||
} else if (it.code == BalanceNotEnoughExeption.code) {
|
||||
showBalanceNotEnoughDialog()
|
||||
} else {
|
||||
it.message?.let { msg ->
|
||||
SingleToastUtil.showToast(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showBalanceNotEnoughDialog() {
|
||||
dialogManager?.showOkCancelDialog(
|
||||
ResUtil.getString(R.string.widget_dialog_dialoguihelper_04),
|
||||
ResUtil.getString(R.string.treasure_to_charge)
|
||||
) {
|
||||
ChargeActivity.start(context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun pay() {
|
||||
dialogManager?.showProgressDialog(requireContext())
|
||||
viewModel.pay(gameId, gameUid, gameInning)
|
||||
}
|
||||
|
||||
private fun updateInning(add: Int) {
|
||||
var newInning = gameInning + add
|
||||
if (newInning <= 0) {
|
||||
newInning = 1
|
||||
}
|
||||
gameInning = newInning
|
||||
if (gameInning <= 1L) {
|
||||
binding.ivCountSubtract.setImageResource(R.drawable.game_team_invite_ic_subtract_disabled)
|
||||
binding.ivCountSubtract.isEnabled = false
|
||||
} else {
|
||||
binding.ivCountSubtract.setImageResource(R.drawable.game_team_invite_ic_subtract)
|
||||
binding.ivCountSubtract.isEnabled = true
|
||||
}
|
||||
binding.tvCount.text = gameInning.toString()
|
||||
updateMoney()
|
||||
}
|
||||
|
||||
private fun updateMoney() {
|
||||
val total = gamePrice * gameInning
|
||||
binding.tvMoney.text = total.toString()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun updateBalance() {
|
||||
if (_binding == null) {
|
||||
return
|
||||
}
|
||||
val balanceTitle = getString(R.string.gift_wallet_overage)
|
||||
val balanceValue = PayModel.get().currentWalletInfo?.diamondNum ?: 0.0
|
||||
var balanceBigDecimal = BigDecimal.valueOf(balanceValue)
|
||||
balanceBigDecimal = balanceBigDecimal.setScale(0, RoundingMode.DOWN)
|
||||
binding.tvBalance.text = "$balanceTitle${balanceBigDecimal.toPlainString()}"
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun requestBalance() {
|
||||
PayModel.get().myRemoteWalletInfo.compose<WalletInfo>(bindToLifecycle())
|
||||
.subscribe { info: WalletInfo ->
|
||||
updateBalance()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
dialogManager?.dismissDialog()
|
||||
dialogManager = null
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
successListener = null
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package com.chwl.app.ui.game_team.invite
|
||||
|
||||
import com.chwl.app.base.BaseViewModel
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.bean.response.BeanResult
|
||||
import com.chwl.core.room.game.GameModel
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
|
||||
class GameTeamInviteViewModel : BaseViewModel() {
|
||||
|
||||
var payResultFlow = MutableSharedFlow<BeanResult<Any>>()
|
||||
|
||||
fun pay(gameId: Long, gameUid: Long, inning: Long) {
|
||||
safeLaunch(onError = {
|
||||
payResultFlow.emit(BeanResult.failed(it))
|
||||
}) {
|
||||
val result =
|
||||
GameModel.startGameTeam(gameId, gameUid, inning, AuthModel.get().currentUid)
|
||||
payResultFlow.emit(BeanResult.success(result))
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
package com.chwl.app.ui.game_team.record
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.databinding.GameTeamRecordActivityBinding
|
||||
import com.chwl.app.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
|
||||
class GameTeamRecordActivity : BaseViewBindingActivity<GameTeamRecordActivityBinding>() {
|
||||
|
||||
companion object {
|
||||
fun start(context: Context) {
|
||||
context.startActivity(Intent(context, GameTeamRecordActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
initWhiteTitleBar(ResUtil.getString(R.string.game_team_09))
|
||||
initTab()
|
||||
}
|
||||
|
||||
private fun initTab() {
|
||||
val fragmentList = ArrayList<Fragment>()
|
||||
fragmentList.add(GameTeamRecordFragment.newInstance(GameTeamRecordFragment.TYPE_INITIATOR))
|
||||
fragmentList.add(GameTeamRecordFragment.newInstance(GameTeamRecordFragment.TYPE_RECEIVER))
|
||||
val titleList = ArrayList<String>()
|
||||
titleList.add(getString(R.string.game_team_10))
|
||||
titleList.add(getString(R.string.game_team_11))
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(false)
|
||||
val magicIndicatorAdapter = GameTeamRecordIndicatorAdapter(context, titleList)
|
||||
magicIndicatorAdapter.setOnItemSelectListener { position: Int, view: TextView? ->
|
||||
binding.viewPager.currentItem = position
|
||||
}
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
binding.magicIndicator.navigator = commonNavigator
|
||||
binding.viewPager.offscreenPageLimit = 2
|
||||
binding.viewPager.adapter = CommonVPAdapter(
|
||||
supportFragmentManager,
|
||||
lifecycle,
|
||||
fragmentList
|
||||
)
|
||||
binding.viewPager.isUserInputEnabled = false
|
||||
ViewPagerHelper.bind(binding.magicIndicator, binding.viewPager)
|
||||
}
|
||||
|
||||
override fun needSteepStateBar(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun setStatusBar() {
|
||||
super.setStatusBar()
|
||||
StatusBarUtil.transparencyBar(this)
|
||||
StatusBarUtil.StatusBarLightMode(this)
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.chwl.app.ui.game_team.record
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isVisible
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.core.game_team.GameTeamRecordBean
|
||||
|
||||
class GameTeamRecordAdapter :
|
||||
BaseQuickAdapter<GameTeamRecordBean, BaseViewHolder>(R.layout.game_team_record_item) {
|
||||
|
||||
var isInitiator = false
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: GameTeamRecordBean?) {
|
||||
helper.addOnClickListener(R.id.tv_repurchase, R.id.tv_chat, R.id.iv_order_id_copy)
|
||||
val userAvatarView = helper.getView<ImageView>(R.id.iv_user_avatar)
|
||||
val repurchaseView = helper.getView<View>(R.id.tv_repurchase)
|
||||
if (isInitiator) {
|
||||
repurchaseView.isVisible = true
|
||||
helper.setText(R.id.tv_user_name, item?.toNick ?: "")
|
||||
helper.setText(R.id.tv_user_id, item?.toErBanNo?.toString() ?: "")
|
||||
userAvatarView.load(item?.toAvatar)
|
||||
} else {
|
||||
repurchaseView.isVisible = false
|
||||
helper.setText(R.id.tv_user_name, item?.fromNick ?: "")
|
||||
helper.setText(R.id.tv_user_id, item?.fromErBanNo?.toString() ?: "")
|
||||
userAvatarView.load(item?.fromAvatar)
|
||||
}
|
||||
helper.setText(R.id.tv_game_name, item?.gameName ?: "")
|
||||
helper.setText(R.id.tv_order_money, item?.amount?.toString())
|
||||
helper.setText(R.id.tv_order_time, item?.orderTime)
|
||||
helper.setText(R.id.tv_order_id, item?.orderNo)
|
||||
}
|
||||
}
|
@@ -0,0 +1,154 @@
|
||||
package com.chwl.app.ui.game_team.record
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseViewBindingFragment
|
||||
import com.chwl.app.common.EmptyViewHelper
|
||||
import com.chwl.app.databinding.GameTemaRecordFragmentBinding
|
||||
import com.chwl.app.ui.game_team.invite.GameTeamInviteDialog
|
||||
import com.chwl.app.ui.im.avtivity.NimP2PMessageActivity
|
||||
import com.chwl.app.ui.utils.RVDelegate
|
||||
import com.chwl.app.utils.ClipboardUtils
|
||||
import com.chwl.core.game_team.GameTeamRecordBean
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
|
||||
class GameTeamRecordFragment : BaseViewBindingFragment<GameTemaRecordFragmentBinding>() {
|
||||
|
||||
companion object {
|
||||
const val TYPE_INITIATOR = 0
|
||||
const val TYPE_RECEIVER = 1
|
||||
fun newInstance(type: Int): GameTeamRecordFragment {
|
||||
return GameTeamRecordFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putInt("type", type)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val viewModel: GameTeamRecordViewModel by viewModels()
|
||||
private val adapter = GameTeamRecordAdapter()
|
||||
|
||||
private var type: Int = TYPE_INITIATOR
|
||||
|
||||
private var rvDelegate: RVDelegate<GameTeamRecordBean>? = null
|
||||
|
||||
private var pageNum = 1
|
||||
|
||||
private val pageSize = 20
|
||||
|
||||
override fun init() {
|
||||
type = arguments?.getInt("type", TYPE_INITIATOR) ?: TYPE_INITIATOR
|
||||
initView()
|
||||
initEvent()
|
||||
initObserve()
|
||||
binding.swipeRefresh.isRefreshing = true
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
adapter.isInitiator = type == TYPE_INITIATOR
|
||||
binding.recyclerView.adapter = adapter
|
||||
rvDelegate = RVDelegate.Builder<GameTeamRecordBean>()
|
||||
.setPageSize(pageSize)
|
||||
.setAdapter(adapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setEmptyView(
|
||||
EmptyViewHelper.createEmptyTextViewHeight(
|
||||
context,
|
||||
getString(R.string.data_empty)
|
||||
)
|
||||
)
|
||||
.setLayoutManager(LinearLayoutManager(mContext))
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
adapter.setOnItemChildClickListener { adapter, view, position ->
|
||||
val item = (adapter.getItem(position) as? GameTeamRecordBean)
|
||||
?: return@setOnItemChildClickListener
|
||||
|
||||
when (view.id) {
|
||||
R.id.tv_repurchase -> {
|
||||
jumpRepurchase(item)
|
||||
}
|
||||
|
||||
R.id.tv_chat -> {
|
||||
jumpChat(item)
|
||||
}
|
||||
|
||||
R.id.iv_order_id_copy -> {
|
||||
ClipboardUtils.copyText(item.orderNo ?: "")
|
||||
toast(getString(R.string.have_copy))
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.swipeRefresh.setOnRefreshListener {
|
||||
loadData(true)
|
||||
}
|
||||
adapter.setOnLoadMoreListener({
|
||||
loadData(false)
|
||||
}, binding.recyclerView)
|
||||
}
|
||||
|
||||
private fun initObserve() {
|
||||
viewModel.listLiveData.observe(this) {
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
rvDelegate?.loadData(it)
|
||||
if (!it.isSuccess && it.message != null) {
|
||||
toast(it.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun jumpRepurchase(item: GameTeamRecordBean) {
|
||||
val uid = getTargetUidByItem(item)
|
||||
val gameId = item.gameId
|
||||
val gameBackground = item.gamePic
|
||||
val gamePrice = item.price ?: 0
|
||||
val gameInning = item.inning ?: 1
|
||||
if (uid == null || gameId == null) {
|
||||
toast(R.string.data_parsing_exception)
|
||||
return
|
||||
}
|
||||
GameTeamInviteDialog.newInstance(
|
||||
targetUid = uid,
|
||||
gameId = gameId,
|
||||
gameBackground = gameBackground,
|
||||
gamePrice = gamePrice,
|
||||
gameInning = gameInning
|
||||
).apply {
|
||||
this.successListener = {
|
||||
loadData(true)
|
||||
}
|
||||
}.safeShow(requireActivity().supportFragmentManager, requireActivity())
|
||||
}
|
||||
|
||||
private fun jumpChat(item: GameTeamRecordBean) {
|
||||
val targetUid = getTargetUidByItem(item)?.toString()
|
||||
if (targetUid.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
NimP2PMessageActivity.start(requireContext(), targetUid)
|
||||
}
|
||||
|
||||
private fun getTargetUidByItem(item: GameTeamRecordBean): Long? {
|
||||
val targetUid = if (type == TYPE_INITIATOR) {
|
||||
item.toUid
|
||||
} else {
|
||||
item.fromUid
|
||||
}
|
||||
return targetUid
|
||||
}
|
||||
|
||||
private fun loadData(isRefresh: Boolean) {
|
||||
if (isRefresh) {
|
||||
pageNum = 1
|
||||
} else {
|
||||
pageNum++
|
||||
}
|
||||
viewModel.getRecordList(type, pageNum, pageSize)
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
package com.chwl.app.ui.game_team.record;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.widget.XRecyclerView.ScaleTransitionPagerTitleView;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GameTeamRecordIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
private final Context mContext;
|
||||
private final List<? extends CharSequence> mTitleList;
|
||||
|
||||
private int textSize = 14;
|
||||
private float minScale = 1f;
|
||||
private boolean showIndicator = true;
|
||||
private OnItemSelectListener mOnItemSelectListener;
|
||||
|
||||
public GameTeamRecordIndicatorAdapter(Context context, List<? extends CharSequence> charSequences) {
|
||||
this.mContext = context;
|
||||
this.mTitleList = charSequences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mTitleList == null ? 0 : mTitleList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int i) {
|
||||
ScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new ScaleTransitionPagerTitleView(context, true);
|
||||
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context, R.color.color_66000000));
|
||||
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(context, R.color.color_000000));
|
||||
scaleTransitionPagerTitleView.setMinScale(minScale);
|
||||
scaleTransitionPagerTitleView.setTextSize(textSize);
|
||||
int padding = UIUtil.dip2px(context, 13);
|
||||
scaleTransitionPagerTitleView.setPadding(padding, 0, padding, 0);
|
||||
scaleTransitionPagerTitleView.setText(mTitleList.get(i));
|
||||
scaleTransitionPagerTitleView.setOnClickListener(view -> {
|
||||
if (mOnItemSelectListener != null) {
|
||||
mOnItemSelectListener.onItemSelect(i, scaleTransitionPagerTitleView);
|
||||
}
|
||||
|
||||
});
|
||||
return scaleTransitionPagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(context.getResources().getDimensionPixelOffset(R.dimen.dp_3));
|
||||
indicator.setRoundRadius(context.getResources().getDimensionPixelOffset(R.dimen.dp_2));
|
||||
indicator.setLineWidth(context.getResources().getDimensionPixelOffset(R.dimen.dp_13));
|
||||
indicator.setColors(context.getResources().getColor(R.color.color_0FCA81));
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
// lp.bottomMargin = mBottomMargin;
|
||||
indicator.setLayoutParams(lp);
|
||||
return indicator;
|
||||
}
|
||||
|
||||
public int getTextSize() {
|
||||
return textSize;
|
||||
}
|
||||
|
||||
public void setTextSize(int textSize) {
|
||||
this.textSize = textSize;
|
||||
}
|
||||
|
||||
public float getMinScale() {
|
||||
return minScale;
|
||||
}
|
||||
|
||||
public void setMinScale(float minScale) {
|
||||
this.minScale = minScale;
|
||||
}
|
||||
|
||||
public boolean isShowIndicator() {
|
||||
return showIndicator;
|
||||
}
|
||||
|
||||
public void setShowIndicator(boolean showIndicator) {
|
||||
this.showIndicator = showIndicator;
|
||||
}
|
||||
|
||||
public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
|
||||
mOnItemSelectListener = onItemSelectListener;
|
||||
}
|
||||
|
||||
public interface OnItemSelectListener {
|
||||
void onItemSelect(int position, TextView view);
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.chwl.app.ui.game_team.record
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.chwl.app.base.BaseViewModel
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.bean.response.ListResult
|
||||
import com.chwl.core.game_team.GameTeamRecordBean
|
||||
import com.chwl.core.room.game.GameModel
|
||||
|
||||
class GameTeamRecordViewModel : BaseViewModel() {
|
||||
|
||||
val listLiveData = MutableLiveData<ListResult<GameTeamRecordBean>>()
|
||||
|
||||
fun getRecordList(type: Int, pageNum: Int, pageSize: Int) {
|
||||
safeLaunch(onError = {
|
||||
listLiveData.postValue(ListResult.failed(pageNum, it))
|
||||
}) {
|
||||
val list =
|
||||
GameModel.getGameTeamRecordList(type, pageNum, pageSize, AuthModel.get().currentUid)
|
||||
listLiveData.postValue(ListResult.success(list, pageNum))
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user