Compare commits
132 Commits
molistar_1
...
molistar_r
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3626d5708a | ||
![]() |
ebd9ddd8de | ||
![]() |
20497cb2b7 | ||
![]() |
61bb91920d | ||
![]() |
6a30060bf9 | ||
![]() |
76abafe1cc | ||
![]() |
6256151928 | ||
![]() |
3d59e7f244 | ||
![]() |
66f8a527f9 | ||
![]() |
57d0852d14 | ||
![]() |
38b0af2f35 | ||
![]() |
062c2ee0a9 | ||
![]() |
4ff5ca40e3 | ||
![]() |
ad543ccbbc | ||
![]() |
2d8f3939ee | ||
![]() |
e43b3348bf | ||
![]() |
8f552d6663 | ||
![]() |
a7c528fff1 | ||
![]() |
afc1d5ef69 | ||
![]() |
4a3c8cbdac | ||
![]() |
1c9c084c3e | ||
![]() |
39cd73b021 | ||
![]() |
f6e5017fbb | ||
![]() |
8562768556 | ||
![]() |
7d6f0c360b | ||
![]() |
e635f69b1f | ||
![]() |
66e9a1442e | ||
![]() |
30036526bd | ||
![]() |
de71c445c1 | ||
![]() |
088d27c51c | ||
![]() |
42007aa075 | ||
![]() |
bc441a8ac2 | ||
![]() |
5b9ada0902 | ||
![]() |
5f441aa8eb | ||
![]() |
9e8a95c1d6 | ||
![]() |
ac14be2c88 | ||
![]() |
e334c7ce16 | ||
![]() |
32b0fba6fb | ||
![]() |
d9a39877f1 | ||
![]() |
681bd8bca9 | ||
![]() |
fc62f8cd28 | ||
![]() |
696dc32234 | ||
![]() |
99e85366b3 | ||
![]() |
70785fdf47 | ||
![]() |
b353105ca2 | ||
![]() |
62dc2e3c9d | ||
![]() |
9c63c56488 | ||
![]() |
d3b16529e1 | ||
![]() |
d73770cfe2 | ||
![]() |
191990426a | ||
![]() |
87052c52c1 | ||
![]() |
568a42799d | ||
![]() |
c0663e4aa8 | ||
![]() |
a8e7634920 | ||
![]() |
8d292ccac0 | ||
![]() |
b81f0c0808 | ||
![]() |
b354931ed2 | ||
![]() |
f538dde6da | ||
![]() |
a37ff5d9b8 | ||
![]() |
f675e3e085 | ||
![]() |
63553473bf | ||
![]() |
15f8ae439b | ||
![]() |
f73b56726a | ||
![]() |
cbca06b03d | ||
![]() |
9b0168f614 | ||
![]() |
70b9e5cbdd | ||
![]() |
f95f8fb0f5 | ||
![]() |
8b90c472e3 | ||
![]() |
c924a2b2ac | ||
![]() |
e7d2c0cf75 | ||
![]() |
5946726d0b | ||
![]() |
ca266841ac | ||
![]() |
5c9ad5b2fb | ||
![]() |
68e6d2aa15 | ||
![]() |
fcecc29add | ||
![]() |
81ba536dba | ||
![]() |
3bf1af2c0b | ||
![]() |
48de4c765b | ||
![]() |
eb6fb9b2da | ||
![]() |
5cf07b86b3 | ||
![]() |
0fce835c0c | ||
![]() |
dcbd5aae25 | ||
![]() |
b5541afc5d | ||
![]() |
25e0c29dbc | ||
![]() |
46c6ee3e99 | ||
![]() |
6277322ebe | ||
![]() |
a8bc86b5aa | ||
![]() |
291f85c310 | ||
![]() |
26ea3dbfd5 | ||
![]() |
14a70f29c8 | ||
![]() |
96174fbfeb | ||
![]() |
492b5f7263 | ||
![]() |
408afcebcb | ||
![]() |
18904e853e | ||
![]() |
61ac515cf9 | ||
![]() |
c47281401e | ||
![]() |
58abce7456 | ||
![]() |
fdd6f1836f | ||
![]() |
5928151853 | ||
![]() |
c4cc6153df | ||
![]() |
ecdeee3e76 | ||
![]() |
a39a11343c | ||
![]() |
c5d0b80f1b | ||
![]() |
520efa04f8 | ||
![]() |
5b1b469316 | ||
![]() |
7ce3990728 | ||
![]() |
542e12a88b | ||
![]() |
7373093946 | ||
![]() |
792b140f0f | ||
![]() |
c64d74aa7d | ||
![]() |
73f24839d4 | ||
![]() |
9a532c5c3f | ||
![]() |
1b74aa08ce | ||
![]() |
831d219f36 | ||
![]() |
6858130a7e | ||
![]() |
db9077fbbc | ||
![]() |
e67ab3c1b3 | ||
![]() |
df0b246062 | ||
![]() |
bf133e5dc6 | ||
![]() |
b4f26d324c | ||
![]() |
4a2618a76b | ||
![]() |
1b56fd075b | ||
![]() |
f1586fb0ac | ||
![]() |
66aa5a5671 | ||
![]() |
52bfc9636b | ||
![]() |
7c0665b9ce | ||
![]() |
ecb3c46407 | ||
![]() |
6ce3a64ea3 | ||
![]() |
408ec37ff2 | ||
![]() |
ecdbf9e9c3 | ||
![]() |
d8ae8a559d | ||
![]() |
2f8511ca16 |
@@ -20,11 +20,11 @@ android {
|
||||
|
||||
flavorDimensions 'default'
|
||||
buildConfigField "boolean", "ISOLATION_MODE", "$isolationMode"
|
||||
resConfigs "en"
|
||||
resConfigs "en", "zh-rTW", "ar"
|
||||
if (isolationMode) {
|
||||
resValue "string", "app_name", "Mo-debug"
|
||||
} else {
|
||||
resValue "string", "app_name", "Molistar"
|
||||
resValue "string", "app_name", "MoliStar"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ android {
|
||||
if (abi == null) {
|
||||
abi = "universal"
|
||||
}
|
||||
outputFileName = "Molistar_${buildType.name}_v${defaultConfig.versionName}_${abi}_${date}.apk"
|
||||
outputFileName = "MoliStar_${buildType.name}_v${defaultConfig.versionName}_${abi}_${date}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ android {
|
||||
'src/module_bank_card/java',
|
||||
'src/module_super_admin/java',
|
||||
'src/module_album/java',
|
||||
'src/module_treasure_box/java',
|
||||
|
||||
]
|
||||
|
||||
@@ -127,6 +128,7 @@ android {
|
||||
'src/module_bank_card/res',
|
||||
'src/module_super_admin/res',
|
||||
'src/module_album/res',
|
||||
'src/module_treasure_box/res',
|
||||
|
||||
]
|
||||
|
||||
@@ -135,7 +137,7 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
def server_url_debug = '"http://api.molistar.xyz/"'
|
||||
def server_url_debug = '"http://beta.api.molistar.xyz/"'
|
||||
def server_url_release = '"https://api.molistar.xyz/"'
|
||||
|
||||
debug {
|
||||
@@ -274,7 +276,7 @@ channel {
|
||||
//多渠道包的输出目录,默认为new File(project.buildDir,"channel")
|
||||
outputDir = new File(project.buildDir, "channelapk")
|
||||
//多渠道包的命名规则,默认为:${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}-${buildTime}
|
||||
apkNameFormat = 'Molistar-${buildType}-${flavorName}-v${versionName}-${buildTime}'
|
||||
apkNameFormat = 'MoliStar-${buildType}-${flavorName}-v${versionName}-${buildTime}'
|
||||
//快速模式:生成渠道包时不进行校验(速度可以提升10倍以上,默认为false)
|
||||
fastMode = false
|
||||
//buildTime的时间格式,默认格式:yyyyMMdd-HHmmss
|
||||
@@ -289,7 +291,7 @@ aabResGuard {
|
||||
"*.R.raw.*",
|
||||
"*.R.drawable.icon"
|
||||
]
|
||||
obfuscatedBundleFileName = "duplicated-app.aab" // Obfuscated file name, must end with '.aab'
|
||||
obfuscatedBundleFileName = "MoliStar-app.aab" // Obfuscated file name, must end with '.aab'
|
||||
mergeDuplicatedRes = true // Whether to allow the merge of duplicate resources
|
||||
enableFilterFiles = false // Whether to allow filter files
|
||||
filterList = [ // file filter rules
|
||||
@@ -299,7 +301,7 @@ aabResGuard {
|
||||
|
||||
enableFilterStrings = false // switch of filter strings
|
||||
unusedStringPath = file("unused.txt").toPath() // strings will be filtered in this file
|
||||
languageWhiteList = ["en", "zh"] // keep en,en-xx,zh,zh-xx etc. remove others.
|
||||
languageWhiteList = ["en", "zh", "ar", "zh-rTW"] // keep en,en-xx,zh,zh-xx etc. remove others.
|
||||
}
|
||||
|
||||
//以下均为非必须
|
||||
@@ -312,6 +314,25 @@ xmlClassGuard {
|
||||
"com.chwl.core": "com.hhchu.core",
|
||||
"com.chwl.library": "com.hhchu.library"]
|
||||
moveDir = [
|
||||
"com.chwl.library.language" : "faceb.abded",
|
||||
"com.chwl.app.ui.invite" : "cfdd.baac",
|
||||
"com.chwl.app.ui.link" : "fdb.ddbd",
|
||||
"com.chwl.app.ui.language" : "cffafe.edafba",
|
||||
"com.chwl.core.file.cos" : "cccdbdcce.eccffeccb",
|
||||
"com.chwl.app.notify.views" : "fbbdbcaa.dbfaeadb",
|
||||
"com.chwl.app.notify" : "eaafaa.edeeef",
|
||||
"com.chwl.app.support.float" : "eadbfff.eccceee",
|
||||
"com.chwl.app.avroom.gameplay" : "dfcf.dbdcb",
|
||||
"com.chwl.app.treasure_box.activity" : "fdbac.cdfab",
|
||||
"com.chwl.app.treasure_box.adapter" : "febab.bdfcb",
|
||||
"com.chwl.app.treasure_box.fragment" : "ecbbc.baaada",
|
||||
"com.chwl.app.treasure_box.module" : "aecae.aeacf",
|
||||
"com.chwl.app.treasure_box.presenter" : "ddaaee.bacbdcb",
|
||||
"com.chwl.app.treasure_box.widget" : "bedacc.bbbceb",
|
||||
"com.chwl.app.treasure_box" : "afccebdddd.ecdedbfcea",
|
||||
"com.chwl.core.treasure_box.bean" : "eeaaaa.bbedeee",
|
||||
"com.chwl.core.treasure_box.event" : "dfbfa.edacdb",
|
||||
"com.chwl.core.treasure_box.model" : "abdf.ebeab",
|
||||
"com.example.lib_utils.spannable" : "babdfb.baacfc",
|
||||
"com.example.lib_utils.log" : "cade.bebee",
|
||||
"com.example.lib_utils.ktx" : "aedbdf.cbfffd",
|
||||
|
@@ -86,7 +86,7 @@
|
||||
<application
|
||||
android:name=".application.App"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/app_logo"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
@@ -127,6 +127,24 @@
|
||||
<!-- </intent-filter>-->
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.link.LinkActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/transparent_activity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data
|
||||
android:host="app"
|
||||
android:scheme="molistar" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="firebase_crashlytics_collection_enabled"-->
|
||||
<!-- android:value="${CRASHLYTICS_COLLECTION_ENABLED}" /> <!– 刘海屏适配 begin –>-->
|
||||
@@ -223,7 +241,7 @@
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="Molistar"
|
||||
android:label="MoliStar"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> <!-- 配置的service和receiver -->
|
||||
@@ -448,6 +466,15 @@
|
||||
android:name=".team.view.UpdateTeamNameActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".treasure_box.activity.TreasureBoxActivity"
|
||||
android:theme="@style/transparent_activity" />
|
||||
<activity
|
||||
android:name=".treasure_box.activity.BoxRankingActivity"
|
||||
android:theme="@style/room_message_activity" />
|
||||
<activity
|
||||
android:name=".treasure_box.activity.TreasureBoxHonourActivity"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
<activity android:name=".ui.setting.VerifyPhoneActivity" />
|
||||
<activity android:name=".ui.setting.ModifyPwdActivity" />
|
||||
<activity
|
||||
@@ -639,7 +666,12 @@
|
||||
<activity
|
||||
android:name=".ui.webview.DialogWebViewActivity"
|
||||
android:theme="@style/dialog_web_view_activity"
|
||||
android:windowSoftInputMode="adjustPan" /> <!-- 隐私政策 -->
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".ui.webview.room_banner.RoomWebDialogActivity"
|
||||
android:theme="@style/room_dialog_web_view_activity"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<!-- 隐私政策 -->
|
||||
<activity
|
||||
android:name=".ui.webview.DatingRuleWebViewActivity"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
@@ -846,6 +878,8 @@
|
||||
|
||||
<activity android:name=".avroom.room_album.RoomAlbumActivity" />
|
||||
|
||||
<activity android:name=".ui.language.LanguageActivity" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
File diff suppressed because one or more lines are too long
BIN
app/src/main/assets/svga/bubble_tran_bg.svga
Normal file
BIN
app/src/main/assets/svga/bubble_tran_bg.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/gold_box_bg.svga
Normal file
BIN
app/src/main/assets/svga/gold_box_bg.svga
Normal file
Binary file not shown.
Binary file not shown.
BIN
app/src/main/assets/svga/room_pk_pb_indicator.svga
Normal file
BIN
app/src/main/assets/svga/room_pk_pb_indicator.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/single_room_pk_pb_indicator.svga
Normal file
BIN
app/src/main/assets/svga/single_room_pk_pb_indicator.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/single_room_pk_vs.svga
Normal file
BIN
app/src/main/assets/svga/single_room_pk_vs.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/smash_eggs_open.svga
Normal file
BIN
app/src/main/assets/svga/smash_eggs_open.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/svga_voice_like_button.svga
Normal file
BIN
app/src/main/assets/svga/svga_voice_like_button.svga
Normal file
Binary file not shown.
BIN
app/src/main/ic_launcher-playstore.png
Normal file
BIN
app/src/main/ic_launcher-playstore.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
@@ -5,6 +5,7 @@ import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TY
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.net.http.HttpResponseCache;
|
||||
import android.os.Build;
|
||||
@@ -12,12 +13,14 @@ import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.util.Supplier;
|
||||
import androidx.multidex.MultiDex;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.bumptech.glide.request.target.ViewTarget;
|
||||
import com.chwl.app.support.IMUserInfoProvider;
|
||||
import com.example.lib_utils.LanguageUtils;
|
||||
import com.chwl.library.language.LanguageHelper;
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.example.lib_utils.ServiceTime;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
@@ -416,9 +419,9 @@ public class App extends BaseApp {
|
||||
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());
|
||||
httpParams.put("lang", LanguageUtils.INSTANCE.getSystemLanguage().toLanguageTag());
|
||||
httpParams.put("lang", LanguageHelper.INSTANCE.getSystemLanguage().toLanguageTag());
|
||||
RxNet.init(context)
|
||||
.debug(Env.isDebug())
|
||||
.debug(Env.isRealDebug())
|
||||
.setBaseUrl(url)
|
||||
.addInterceptors(new ParamsInterceptor(httpParams))
|
||||
.addInterceptors(new NoParamsInterceptor())//注意:拦截器的添加顺序,请求的拦截顺序
|
||||
@@ -478,6 +481,7 @@ public class App extends BaseApp {
|
||||
ChannelModel.get();
|
||||
MarketVerifyModel.get();
|
||||
GiftModel.get();
|
||||
GiftModel.get().tryLoadGiftList();
|
||||
// 模厅
|
||||
HallDataManager.get().application();
|
||||
//全局处理
|
||||
@@ -522,6 +526,8 @@ public class App extends BaseApp {
|
||||
BasicConfig.INSTANCE.setAppContext(this.getApplicationContext());
|
||||
SharedPreferenceUtils.init(this);
|
||||
ResUtil.init(this);
|
||||
ResUtil.contextSupplier = () -> App.gStack.getTopContext();
|
||||
LanguageHelper.INSTANCE.wrapContext(instance);
|
||||
initOtherSDK();
|
||||
initContext(this);
|
||||
//首次启动事件
|
||||
@@ -550,6 +556,12 @@ public class App extends BaseApp {
|
||||
MultiDex.install(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
LanguageHelper.INSTANCE.wrapContext(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTerminate() {
|
||||
super.onTerminate();
|
||||
|
@@ -1,17 +1,13 @@
|
||||
package com.chwl.app.avroom.activity;
|
||||
|
||||
import static android.view.View.VISIBLE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_PK;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_NOTIFY;
|
||||
|
||||
@@ -44,7 +40,9 @@ import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chwl.app.notify.RoomNotifyManager;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
|
||||
import com.chwl.core.support.room.RoomWidget;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nimlib.sdk.NIMSDK;
|
||||
import com.netease.nimlib.sdk.Observer;
|
||||
@@ -57,7 +55,6 @@ import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.dialog.NewUserGiftDialog;
|
||||
import com.chwl.app.avroom.dialog.SingleRoomTipDialog;
|
||||
@@ -79,12 +76,10 @@ import com.chwl.app.ui.patriarch.help.LimitEnterRoomHelper;
|
||||
import com.chwl.app.ui.user.activity.UserInfoActivity;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity;
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity;
|
||||
import com.chwl.app.ui.widget.NobleOpenNoticeView;
|
||||
import com.chwl.app.ui.widget.dialog.AllServiceGiftLevelDialog;
|
||||
import com.chwl.app.ui.widget.dialog.MonsterDialog;
|
||||
import com.chwl.app.utils.UserUtils;
|
||||
import com.chwl.app.room_chat.activity.RoomMsgActivity;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.DemoCache;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
@@ -98,8 +93,6 @@ import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.chwl.core.im.custom.bean.FairyMsgAttachment;
|
||||
import com.chwl.core.im.custom.bean.NotifyH5Attachment;
|
||||
import com.chwl.core.im.custom.bean.NotifyH5Info;
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeInfo;
|
||||
import com.chwl.core.im.custom.bean.RoomLuckySeaAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomLuckySeaMsgBean;
|
||||
import com.chwl.core.im.custom.bean.RoomPKAttachment;
|
||||
@@ -115,7 +108,6 @@ import com.chwl.core.module_hall.hall.HallModel;
|
||||
import com.chwl.core.module_hall.hall.bean.SuperAdminInfo;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterHuntingResult;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterInfo;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterProtocol;
|
||||
import com.chwl.core.monsterhunting.manager.MonsterDataManager;
|
||||
import com.chwl.core.noble.bean.AllServiceGiftProtocol;
|
||||
import com.chwl.core.noble.bean.NobleInfo;
|
||||
@@ -140,7 +132,6 @@ import com.chwl.core.support.room.RoomContext;
|
||||
import com.chwl.core.support.room.RoomView;
|
||||
import com.chwl.core.treasurefairy.bean.FairyMsgInfoBean;
|
||||
import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.user.bean.FirstChargeInfo;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.utils.LogUtils;
|
||||
import com.chwl.core.utils.StringFormatUtils;
|
||||
@@ -158,13 +149,12 @@ import java.lang.ref.WeakReference;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -227,6 +217,8 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
// 是否禁用VP滑动(true:不允许滑动;false:某些条件下可以滑动)
|
||||
private boolean viewPagerInputDisable;
|
||||
|
||||
private RoomNotifyManager roomNotify;
|
||||
|
||||
public static void start(Context context, long roomUid) {
|
||||
startForFromType(context, roomUid, FROM_TYPE_NORMAL, null, null);
|
||||
}
|
||||
@@ -505,6 +497,17 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
});
|
||||
|
||||
roomNotify = new RoomNotifyManager(this);
|
||||
roomNotify.setOnShowUserCard(new Function1<String, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(String s) {
|
||||
if (mCurrentFragment != null) {
|
||||
mCurrentFragment.showUserCardDialog(s);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
roomNotify.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1170,56 +1173,56 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
if (baseProtocol == null) return;
|
||||
if (!isValid()) return;
|
||||
switch (baseProtocol.getFirst()) {
|
||||
case CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
if (giftList == null) {
|
||||
giftList = new LinkedList<>();
|
||||
}
|
||||
int second2 = baseProtocol.getSecond();
|
||||
AllServiceGiftProtocol.DataBean data = JSON.parseObject(String.valueOf(baseProtocol.getData()), AllServiceGiftProtocol.DataBean.class);
|
||||
if (data == null || (data.getGiftUrl()) == null)
|
||||
return;
|
||||
giftList.add(data);
|
||||
if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
giftDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showGiftDialog();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_BOX://寻爱之旅
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
RoomBoxPrizeAttachment roomBoxPrizeAttachment = new RoomBoxPrizeAttachment(CUSTOM_MSG_BOX, CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
|
||||
RoomBoxPrizeInfo roomBoxPrizeBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
|
||||
roomBoxPrizeAttachment.setUid(roomBoxPrizeBean.getUid());
|
||||
roomBoxPrizeAttachment.setPrizeName(roomBoxPrizeBean.getPrizeName());
|
||||
roomBoxPrizeAttachment.setNick(roomBoxPrizeBean.getNick());
|
||||
roomBoxPrizeAttachment.setBoxTypeStr(roomBoxPrizeBean.getBoxTypeStr());
|
||||
roomBoxPrizeAttachment.setRoomUid(roomBoxPrizeBean.getRoomUid());
|
||||
roomBoxPrizeAttachment.setPrizeNum(roomBoxPrizeBean.getPrizeNum());
|
||||
roomBoxPrizeAttachment.setUserLevelLimit(roomBoxPrizeBean.getUserLevelLimit());
|
||||
if (AvRoomDataManager.get().isOpenPureMode()) {
|
||||
// 純凈模式打開後,僅能看跟自己相關的砸蛋消息
|
||||
if (Objects.equals(roomBoxPrizeAttachment.getUid(), AuthModel.get().getCurrentUid())) {
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
}
|
||||
} else {
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
.onNext(new RoomEvent()
|
||||
.setEvent(RoomEvent.BOX_NOTIFY_SVGA)
|
||||
.setChatRoomMessage(message));
|
||||
}
|
||||
}
|
||||
break;
|
||||
// case CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
// if (giftList == null) {
|
||||
// giftList = new LinkedList<>();
|
||||
// }
|
||||
// int second2 = baseProtocol.getSecond();
|
||||
// AllServiceGiftProtocol.DataBean data = JSON.parseObject(String.valueOf(baseProtocol.getData()), AllServiceGiftProtocol.DataBean.class);
|
||||
// if (data == null || (data.getGiftUrl()) == null)
|
||||
// return;
|
||||
// giftList.add(data);
|
||||
// if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
// if (giftDialog != null && giftDialog.isShowing()) {
|
||||
// // 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
// AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
// if (dataBean != null) {
|
||||
// return;
|
||||
// } else {
|
||||
// giftDialog.dismiss();
|
||||
// }
|
||||
// } else {
|
||||
// showGiftDialog();
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case CUSTOM_MSG_BOX://寻爱之旅
|
||||
// if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
// RoomBoxPrizeAttachment roomBoxPrizeAttachment = new RoomBoxPrizeAttachment(CUSTOM_MSG_BOX, CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
|
||||
// RoomBoxPrizeInfo roomBoxPrizeBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
|
||||
// roomBoxPrizeAttachment.setUid(roomBoxPrizeBean.getUid());
|
||||
// roomBoxPrizeAttachment.setPrizeName(roomBoxPrizeBean.getPrizeName());
|
||||
// roomBoxPrizeAttachment.setNick(roomBoxPrizeBean.getNick());
|
||||
// roomBoxPrizeAttachment.setBoxTypeStr(roomBoxPrizeBean.getBoxTypeStr());
|
||||
// roomBoxPrizeAttachment.setRoomUid(roomBoxPrizeBean.getRoomUid());
|
||||
// roomBoxPrizeAttachment.setPrizeNum(roomBoxPrizeBean.getPrizeNum());
|
||||
// roomBoxPrizeAttachment.setUserLevelLimit(roomBoxPrizeBean.getUserLevelLimit());
|
||||
// if (AvRoomDataManager.get().isOpenPureMode()) {
|
||||
// // 純凈模式打開後,僅能看跟自己相關的砸蛋消息
|
||||
// if (Objects.equals(roomBoxPrizeAttachment.getUid(), AuthModel.get().getCurrentUid())) {
|
||||
// ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
|
||||
// IMNetEaseManager.get().addMessages(message);
|
||||
// }
|
||||
// } else {
|
||||
// ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
|
||||
// IMNetEaseManager.get().addMessages(message);
|
||||
// IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
// .onNext(new RoomEvent()
|
||||
// .setEvent(RoomEvent.BOX_NOTIFY_SVGA)
|
||||
// .setChatRoomMessage(message));
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
case CustomAttachment.CUSTOM_MESS_TAROT:
|
||||
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING) {
|
||||
TarotMsgBean tarotMsgBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), TarotMsgBean.class);
|
||||
@@ -1262,7 +1265,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
RoomReceivedLuckyGiftAttachment attachment = new RoomReceivedLuckyGiftAttachment(CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY);
|
||||
attachment.setLuckyBagNoticeInfo(JSON.parseObject(String.valueOf(baseProtocol.getData()), LuckyBagNoticeInfo.class));
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
IMNetEaseManager.get().noticeServiceLuckyBagNotice(message);
|
||||
// IMNetEaseManager.get().noticeServiceLuckyBagNotice(message);
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
}
|
||||
break;
|
||||
@@ -1363,6 +1366,12 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RoomWidget findWidget(@NonNull String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class GiftBroadcastObserver implements Observer<BroadcastMessage> {
|
||||
private WeakReference<AVRoomActivity> mReference;
|
||||
|
||||
@@ -1382,14 +1391,14 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = JSON.parseObject(contentStr);
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
activity.onReceivedGiftBroadcastMessage(body);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
jsonObject = null;
|
||||
}
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
activity.onReceivedGiftBroadcastMessage(body);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ import android.text.TextUtils;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.core.room.bean.RoomOnlineUserBean;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.common.util.sys.NetworkUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
|
||||
@@ -20,7 +21,6 @@ import com.chwl.app.avroom.view.IRoomInviteView;
|
||||
import com.chwl.app.base.BaseMvpActivity;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.noble.NobleResourceType;
|
||||
import com.chwl.core.room.bean.OnlineChatMember;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.library.base.factory.CreatePresenter;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
@@ -106,8 +106,9 @@ public class RoomInviteActivity extends BaseMvpActivity<IRoomInviteView, RoomInv
|
||||
getMvpPresenter().requestChatMemberByPage(mPage, time, onlyManager);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRequestChatMemberByPageSuccess(List<OnlineChatMember> memberList, int page) {
|
||||
public void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> memberList) {
|
||||
|
||||
}
|
||||
|
||||
|
@@ -7,8 +7,10 @@ import android.view.View;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter;
|
||||
import com.chwl.app.avroom.fragment.RoomCharmListFragment;
|
||||
import com.chwl.app.avroom.fragment.RoomContributeListFragment;
|
||||
import com.chwl.app.base.BaseBindingActivity;
|
||||
@@ -39,18 +41,8 @@ public class RoomRankListActivity extends BaseBindingActivity<ActivityRoomRankLi
|
||||
List<Fragment> list = new ArrayList<>();
|
||||
list.add(RoomCharmListFragment.newInstance());
|
||||
list.add(new RoomContributeListFragment());
|
||||
mBinding.viewPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
return list.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
});
|
||||
mBinding.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
mBinding.viewPager.setAdapter(new CommonVPAdapter(getSupportFragmentManager(),getLifecycle(),list));
|
||||
mBinding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback(){
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
|
@@ -12,6 +12,9 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.utils.NamePlateHelper;
|
||||
import com.chwl.core.level.UserLevelVo;
|
||||
import com.chwl.core.room.bean.RoomOnlineUserBean;
|
||||
import com.netease.nim.uikit.impl.cache.NimUserInfoCache;
|
||||
import com.netease.nimlib.sdk.RequestCallbackWrapper;
|
||||
import com.netease.nimlib.sdk.uinfo.constant.GenderEnum;
|
||||
@@ -41,19 +44,16 @@ import io.reactivex.disposables.Disposable;
|
||||
* @author Administrator
|
||||
* @date 2017/12/4
|
||||
*/
|
||||
public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMember, BaseViewHolder> {
|
||||
|
||||
public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<RoomOnlineUserBean, BaseViewHolder> {
|
||||
private boolean mIsHomeParty;
|
||||
private Disposable mDisposable;
|
||||
private Context context;
|
||||
private OnRoomOnlineNumberChangeListener mListener;
|
||||
|
||||
public OnlineUserAdapter(Context context, boolean isHomeParty) {
|
||||
super(null);
|
||||
addItemType(OnlineChatMember.NORMAL, R.layout.list_item_online_user);
|
||||
addItemType(OnlineChatMember.NOBLE, R.layout.list_item_online_user_mystery);
|
||||
addItemType(RoomOnlineUserBean.NORMAL, R.layout.list_item_online_user);
|
||||
addItemType(RoomOnlineUserBean.NOBLE, R.layout.list_item_online_user_mystery);
|
||||
mIsHomeParty = isHomeParty;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,149 +63,76 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(@NonNull BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
|
||||
if (onlineChatMember != null && onlineChatMember.chatRoomMember != null) {
|
||||
if (onlineChatMember.getItemType() == OnlineChatMember.NORMAL) {
|
||||
setNormalData(baseViewHolder, onlineChatMember);
|
||||
} else {
|
||||
setMysteryData();
|
||||
}
|
||||
protected void convert(@NonNull BaseViewHolder helper, RoomOnlineUserBean item) {
|
||||
if (item.getItemType() == OnlineChatMember.NOBLE) {
|
||||
return;
|
||||
}
|
||||
// 性别
|
||||
final ImageView sexImage = helper.getView(R.id.sex);
|
||||
if (item.getGender() == 1) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if (item.getGender() == 2) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
sexImage.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setMysteryData() {
|
||||
//do nothing
|
||||
}
|
||||
// 昵称
|
||||
helper.setText(R.id.nick, RegexUtil.getPrintableString(item.getNick()));
|
||||
|
||||
private void setNormalData(BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
|
||||
setSexData(baseViewHolder, onlineChatMember);
|
||||
|
||||
ImageView roomOnlineTag = baseViewHolder.getView(R.id.room_online_tag);
|
||||
ImageView managerLogo = baseViewHolder.getView(R.id.manager_logo);
|
||||
// roomOnlineTag.setVisibility(onlineChatMember.isOnMic ? View.VISIBLE : View.GONE);
|
||||
roomOnlineTag.setVisibility(View.GONE);
|
||||
managerLogo.setVisibility((onlineChatMember.isAdmin || onlineChatMember.isRoomOwer)
|
||||
? View.VISIBLE : View.GONE);
|
||||
managerLogo.setVisibility(View.GONE);
|
||||
// managerLogo.setImageResource(onlineChatMember.isAdmin ? R.drawable.icon_admin_logo
|
||||
// : R.drawable.icon_user_list_room_ownner);
|
||||
|
||||
baseViewHolder.setText(R.id.nick, RegexUtil.getPrintableString(onlineChatMember.chatRoomMember.getNick()));
|
||||
|
||||
NobleAvatarView nobleAvatarView = baseViewHolder.getView(R.id.noble_avatar_view);
|
||||
// 头像
|
||||
NobleAvatarView nobleAvatarView = helper.getView(R.id.noble_avatar_view);
|
||||
nobleAvatarView.setSize(37, 54, 0);
|
||||
nobleAvatarView.setData(onlineChatMember.chatRoomMember);
|
||||
nobleAvatarView.setData(item);
|
||||
|
||||
// 官字
|
||||
baseViewHolder.getView(R.id.iv_user_official).setVisibility(onlineChatMember.isOfficial() ? View.VISIBLE : View.GONE);
|
||||
helper.getView(R.id.iv_user_official).setVisibility(item.isOfficial() ? View.VISIBLE : View.GONE);
|
||||
|
||||
// 管理
|
||||
ImageView ivManager = helper.getView(R.id.manager_logo);
|
||||
if (item.getMemberType() != null && item.getMemberType().equals("MANAGER")) {
|
||||
ivManager.setVisibility(View.VISIBLE);
|
||||
ivManager.setImageResource(R.drawable.icon_admin_logo);
|
||||
} else if (item.getMemberType() != null && item.getMemberType().equals("CREATOR")) {
|
||||
ivManager.setVisibility(View.VISIBLE);
|
||||
ivManager.setImageResource(R.drawable.icon_user_list_room_ownner);
|
||||
} else {
|
||||
ivManager.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 在麦
|
||||
ImageView ivMic = helper.getView(R.id.room_online_tag);
|
||||
ivMic.setVisibility(item.isInMic() ? View.VISIBLE : View.GONE);
|
||||
|
||||
|
||||
//等级
|
||||
UserLevelVo levelVo = item.getUserLevelVo();
|
||||
String experLevelUrl = null;
|
||||
String charmLevelUrl = null;
|
||||
if (levelVo != null) {
|
||||
experLevelUrl = levelVo.getExperUrl();
|
||||
charmLevelUrl = levelVo.getCharmUrl();
|
||||
}
|
||||
//经验等级
|
||||
AppCompatImageView ivUserExper = baseViewHolder.getView(R.id.iv_user_exper);
|
||||
String experLevelUrl = NobleUtil.getLevel(UserLevelResourceType.EXPER_URL, onlineChatMember.chatRoomMember);
|
||||
AppCompatImageView ivUserExper = helper.getView(R.id.iv_user_exper);
|
||||
boolean isExperLevelUrlEmpty = TextUtils.isEmpty(experLevelUrl);
|
||||
ivUserExper.setVisibility(!isExperLevelUrlEmpty ? View.VISIBLE : View.GONE);
|
||||
if (!isExperLevelUrlEmpty) {
|
||||
ImageLoadUtils.loadImage(mContext, experLevelUrl, ivUserExper);
|
||||
}
|
||||
//魅力等级
|
||||
AppCompatImageView ivUserCharm = baseViewHolder.getView(R.id.iv_user_charm);
|
||||
String charmLevelUrl = NobleUtil.getLevel(UserLevelResourceType.CHARM_URL, onlineChatMember.chatRoomMember);
|
||||
AppCompatImageView ivUserCharm = helper.getView(R.id.iv_user_charm);
|
||||
boolean isCharmLevelUrlEmpty = TextUtils.isEmpty(charmLevelUrl);
|
||||
ivUserCharm.setVisibility(!isCharmLevelUrlEmpty ? View.VISIBLE : View.GONE);
|
||||
if (!isCharmLevelUrlEmpty) {
|
||||
ImageLoadUtils.loadImage(mContext, charmLevelUrl, ivUserCharm);
|
||||
}
|
||||
|
||||
// 官方主播铭牌标识
|
||||
String fixWord = NobleUtil.getLevel(UserInfo.OAC_NAME, onlineChatMember.chatRoomMember);
|
||||
String iconPic = NobleUtil.getLevel(UserInfo.OAC_ICON, onlineChatMember.chatRoomMember);
|
||||
View inOfficialMask = baseViewHolder.getView(R.id.in_official_mask);
|
||||
if (!TextUtils.isEmpty(fixWord) && !TextUtils.isEmpty(iconPic)) {
|
||||
inOfficialMask.setVisibility(View.VISIBLE);
|
||||
TextView tvOfficialMask = inOfficialMask.findViewById(R.id.tv_official_mask);
|
||||
if (tvOfficialMask != null) {
|
||||
tvOfficialMask.setText(fixWord);
|
||||
}
|
||||
|
||||
ImageView ivOfficialMask = inOfficialMask.findViewById(R.id.iv_official_mask);
|
||||
if (ivOfficialMask != null) {
|
||||
ImageLoadUtils.loadImage(mContext, iconPic, ivOfficialMask);
|
||||
}
|
||||
|
||||
} else {
|
||||
inOfficialMask.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 铭牌
|
||||
String namePlateWord = NobleUtil.getLevel(UserInfo.NAMEPLATE_WORD, onlineChatMember.chatRoomMember);
|
||||
String namePlatePic = NobleUtil.getLevel(UserInfo.NAMEPLATE_PIC, onlineChatMember.chatRoomMember);
|
||||
View inNamePlate = baseViewHolder.getView(R.id.in_nameplate);
|
||||
if (!TextUtils.isEmpty(namePlateWord) && !TextUtils.isEmpty(namePlatePic)) {
|
||||
inNamePlate.setVisibility(View.VISIBLE);
|
||||
TextView tvNamePlate = inNamePlate.findViewById(R.id.tv_official_mask);
|
||||
if (tvNamePlate != null) {
|
||||
tvNamePlate.setText(namePlateWord);
|
||||
}
|
||||
|
||||
ImageView ivNamePlate = inNamePlate.findViewById(R.id.iv_official_mask);
|
||||
if (ivNamePlate != null) {
|
||||
ImageLoadUtils.loadImage(mContext, namePlatePic, ivNamePlate);
|
||||
}
|
||||
|
||||
} else {
|
||||
inNamePlate.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
AppCompatImageView ivUserLevel = baseViewHolder.getView(R.id.iv_noble_level);
|
||||
String resource = (String) NobleUtil.getResource(NobleResourceType.KEY_BADGE, onlineChatMember.chatRoomMember);
|
||||
if (TextUtils.isEmpty(resource)) {
|
||||
ivUserLevel.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
ivUserLevel.setVisibility(View.VISIBLE);
|
||||
NobleUtil.loadResource(resource, ivUserLevel);
|
||||
}
|
||||
|
||||
private void setSexData(BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
|
||||
final ImageView sexImage = baseViewHolder.getView(R.id.sex);
|
||||
String gender = NobleUtil.getLevel(UserInfo.GENDER, onlineChatMember.chatRoomMember);
|
||||
if ("1".equals(gender)) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if ("2".equals(gender)) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
NimUserInfo nimUserInfo = NimUserInfoCache.getInstance().getUserInfo(onlineChatMember.chatRoomMember.getAccount());
|
||||
if (nimUserInfo == null) {
|
||||
NimUserInfoCache.getInstance().getUserInfoFromRemote(onlineChatMember.chatRoomMember.getAccount(),
|
||||
new RequestCallbackWrapper<NimUserInfo>() {
|
||||
@Override
|
||||
public void onResult(int i, NimUserInfo nimUserInfo, Throwable throwable) {
|
||||
if (nimUserInfo != null) {
|
||||
if (nimUserInfo.getGenderEnum() == GenderEnum.MALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if (nimUserInfo.getGenderEnum() == GenderEnum.FEMALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
sexImage.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (nimUserInfo.getGenderEnum() == GenderEnum.MALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if (nimUserInfo.getGenderEnum() == GenderEnum.FEMALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
sexImage.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
View inNamePlate = helper.getView(R.id.in_nameplate);
|
||||
NamePlateHelper.INSTANCE.load(inNamePlate, inNamePlate.findViewById(R.id.tv_official_mask), inNamePlate.findViewById(R.id.iv_official_mask), item);
|
||||
}
|
||||
|
||||
private void registerRoomEvent() {
|
||||
@@ -242,7 +169,7 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
|
||||
updateMemberIn(roomEvent);
|
||||
} else if (event == RoomEvent.ROOM_MEMBER_EXIT) {
|
||||
if (mListener != null) {
|
||||
mListener.onMemberExit(roomEvent.getAccount(), mData);
|
||||
mListener.onMemberExit(roomEvent.getAccount());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -250,19 +177,19 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
|
||||
|
||||
private void updateMemberIn(RoomEvent roomEvent) {
|
||||
if (mListener != null) {
|
||||
mListener.onMemberIn(roomEvent.getAccount(), mData);
|
||||
mListener.onMemberIn(roomEvent.getAccount());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateManager(RoomEvent roomEvent) {
|
||||
if (mListener != null)
|
||||
mListener.onUpdateMemberManager(roomEvent.getAccount(),
|
||||
roomEvent.getEvent() == RoomEvent.ROOM_MANAGER_REMOVE, mData);
|
||||
roomEvent.getEvent() == RoomEvent.ROOM_MANAGER_REMOVE);
|
||||
}
|
||||
|
||||
private void updateDownUpMic(String account, boolean isUpMic) {
|
||||
if (mListener != null) {
|
||||
mListener.onMemberDownUpMic(account, isUpMic, mData);
|
||||
mListener.onMemberDownUpMic(account, isUpMic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,34 +210,29 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
|
||||
*
|
||||
* @param account
|
||||
*/
|
||||
void onMemberIn(String account, List<OnlineChatMember> dataList);
|
||||
void onMemberIn(String account);
|
||||
|
||||
/**
|
||||
* 成员出去回调
|
||||
*
|
||||
* @param account
|
||||
* @param dataList
|
||||
*/
|
||||
void onMemberExit(String account, List<OnlineChatMember> dataList);
|
||||
void onMemberExit(String account);
|
||||
|
||||
/**
|
||||
* 成员上下麦更新
|
||||
*
|
||||
* @param account
|
||||
* @param isUpMic
|
||||
* @param dataList
|
||||
*/
|
||||
void onMemberDownUpMic(String account, boolean isUpMic,
|
||||
List<OnlineChatMember> dataList);
|
||||
void onMemberDownUpMic(String account, boolean isUpMic);
|
||||
|
||||
/**
|
||||
* 设置管理员回调
|
||||
*
|
||||
* @param account
|
||||
* @param dataList
|
||||
*/
|
||||
void onUpdateMemberManager(String account, boolean isRemoveManager,
|
||||
List<OnlineChatMember> dataList);
|
||||
void onUpdateMemberManager(String account, boolean isRemoveManager);
|
||||
|
||||
void addMemberBlack();
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ class RoomPKSearchAdapter :
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: SimpleRoomInfo) {
|
||||
helper.setText(R.id.tv_room_title,item.title.subAndReplaceDot(7))
|
||||
.setText(R.id.tv_room_id,"Molistar号:${item.erbanNo}")
|
||||
.setText(R.id.tv_room_id,"ID:${item.erbanNo}")
|
||||
.setChecked(R.id.check_box,item.checked)
|
||||
ImageLoadUtils.loadImage(mContext,item.avatar,helper.getView(R.id.iv_avatar))
|
||||
helper.addOnClickListener(R.id.iv_avatar,R.id.check_box)
|
||||
|
@@ -25,6 +25,7 @@ import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.library.annatation.ActLayoutRes
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.example.lib_utils.UiUtils
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
|
||||
@@ -64,8 +65,11 @@ class ExitRoomPopupWindow(val avRoomActivity: AVRoomActivity) : PopupWindow() {
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
|
||||
animationStyle = R.style.style_anim_right_in_out
|
||||
if(UiUtils.isRtl(avRoomActivity)){
|
||||
animationStyle = R.style.style_anim_left_in_out
|
||||
}else{
|
||||
animationStyle = R.style.style_anim_right_in_out
|
||||
}
|
||||
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
|
||||
tvExitRoom.setOnClickListener {
|
||||
|
@@ -560,10 +560,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
} else {
|
||||
val roomQueueInfo = AvRoomDataManager.get()
|
||||
.getRoomQueueMemberInfoByAccount(myUid.toString())
|
||||
if (roomQueueInfo?.mChatRoomMember?.isNoProhibitMic == true && roomQueueInfo.mRoomMicInfo?.isMicMute == false) {
|
||||
bottomView.setMicBtnEnable(true)
|
||||
bottomView.setMicBtnOpen(true)
|
||||
} else if (roomQueueInfo?.mChatRoomMember != null
|
||||
if (roomQueueInfo?.mChatRoomMember != null
|
||||
&& myUid.toString() == roomQueueInfo.mChatRoomMember.account
|
||||
&& roomQueueInfo.mRoomMicInfo?.isMicMute == true
|
||||
) {
|
||||
@@ -714,7 +711,12 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY))
|
||||
.doOnError {
|
||||
if (it is VipLevelNotEnoughException) {
|
||||
dialogManager.showOkDialog("尚未達到贈送${giftInfo.giftName}所需貴族等級,所需貴族等級:${giftInfo.giftVipInfo?.vipName}")
|
||||
val message = context?.getString(
|
||||
R.string.send_gift_vip_level_tips,
|
||||
giftInfo.giftName ?: "",
|
||||
giftInfo.giftVipInfo?.vipName ?: ""
|
||||
)
|
||||
dialogManager.showOkDialog(message)
|
||||
}
|
||||
}
|
||||
.subscribe { _, throwable ->
|
||||
@@ -1228,6 +1230,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
return this
|
||||
}
|
||||
|
||||
override fun findWidget(name: String): RoomWidget? {
|
||||
return widgets[name]
|
||||
}
|
||||
|
||||
open fun initWidget() {
|
||||
|
||||
}
|
||||
|
@@ -17,6 +17,10 @@ import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.chwl.app.ui.widget.GiftDialog;
|
||||
import com.chwl.app.ui.widget.UserInfoDialog;
|
||||
import com.chwl.library.utils.JavaUtil;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
@@ -352,11 +356,11 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
// tempFragment = GameRoomFragment.newInstance();
|
||||
// }
|
||||
// break;
|
||||
// case RoomInfo.ROOM_TYPE_SINGLE:
|
||||
// if (!(tempFragment instanceof SingleRoomFragment)) {
|
||||
// tempFragment = SingleRoomFragment.newInstance();
|
||||
// }
|
||||
// break;
|
||||
case RoomInfo.ROOM_TYPE_SINGLE:
|
||||
if (!(tempFragment instanceof SingleRoomFragment)) {
|
||||
tempFragment = SingleRoomFragment.newInstance();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!(tempFragment instanceof HomePartyRoomFragment)) {
|
||||
tempFragment = HomePartyRoomFragment.newInstance();
|
||||
@@ -409,8 +413,12 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.room_more:
|
||||
int gravity = Gravity.END;
|
||||
if(UiUtils.INSTANCE.isRtl(requireContext())){
|
||||
gravity = Gravity.START;
|
||||
}
|
||||
ExitRoomPopupWindow.newInstance((AVRoomActivity) requireActivity())
|
||||
.showAtLocation(gameMainBinding.getRoot(), Gravity.END, 0, 0);
|
||||
.showAtLocation(gameMainBinding.getRoot(), gravity, 0, 0);
|
||||
break;
|
||||
case R.id.ll_room_info:
|
||||
RoomOnlineUserActivity.start(getActivity());
|
||||
@@ -552,4 +560,20 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
gameMainBinding.roomNums.setText(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_013) + onlineNumber);
|
||||
}
|
||||
|
||||
public void showUserCardDialog(String uid){
|
||||
long id = JavaUtil.str2long(uid);
|
||||
if (id == 0) {
|
||||
return;
|
||||
}
|
||||
if (roomFragment instanceof GiftDialog.OnGiftDialogBtnClickListener) {
|
||||
UserInfoDialog.showNewUserInfoDialog(
|
||||
mContext,
|
||||
id,
|
||||
true,
|
||||
true,
|
||||
true, (GiftDialog.OnGiftDialogBtnClickListener) roomFragment
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -8,6 +8,8 @@ import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.chwl.app.avroom.gameplay.RoomGameplayListWidget;
|
||||
import com.chwl.app.avroom.gameplay.RoomGameplayWidget;
|
||||
import com.chwl.app.music.widget.MusicPlayerView;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent;
|
||||
@@ -131,6 +133,8 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
@Override
|
||||
public void initWidget() {
|
||||
super.initWidget();
|
||||
registerWidget(RoomGameplayListWidget.class.getSimpleName(), gameBinding.gameplayListWidget);
|
||||
registerWidget(RoomGameplayWidget.class.getSimpleName(), gameBinding.gameplayWidget);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
|
@@ -6,11 +6,13 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chwl.core.room.bean.RoomOnlineUserBean;
|
||||
import com.netease.nim.uikit.common.util.sys.NetworkUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadmoreListener;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.OnlineUserAdapter;
|
||||
@@ -44,7 +46,6 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
private SmartRefreshLayout mRefreshLayout;
|
||||
|
||||
private OnlineUserAdapter mOnlineUserAdapter;
|
||||
private int mPage = Constants.PAGE_START;
|
||||
private boolean isShowToUser = false;
|
||||
|
||||
@Override
|
||||
@@ -58,25 +59,12 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
public void onFindViews() {
|
||||
mRecyclerView = mView.findViewById(R.id.recycler_view);
|
||||
mRefreshLayout = mView.findViewById(R.id.refresh_layout);
|
||||
mRefreshLayout.setEnableLoadmore(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
mRefreshLayout.setOnRefreshLoadmoreListener(new OnRefreshLoadmoreListener() {
|
||||
@Override
|
||||
public void onLoadmore(RefreshLayout refreshLayout) {
|
||||
if (!NetworkUtil.isNetAvailable(mContext)) {
|
||||
mRefreshLayout.finishLoadmore();
|
||||
return;
|
||||
}
|
||||
List<OnlineChatMember> data = mOnlineUserAdapter.getData();
|
||||
if (ListUtils.isListEmpty(data)) {
|
||||
mRefreshLayout.finishLoadmore();
|
||||
return;
|
||||
}
|
||||
loadData(data.get(data.size() - 1).chatRoomMember.getEnterTime());
|
||||
}
|
||||
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh(RefreshLayout refreshLayout) {
|
||||
if (!NetworkUtil.isNetAvailable(mContext)) {
|
||||
@@ -106,53 +94,24 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
|
||||
|
||||
public void firstLoad() {
|
||||
mPage = Constants.PAGE_START;
|
||||
loadData(0);
|
||||
loadData();
|
||||
}
|
||||
|
||||
private void loadData(long time) {
|
||||
getMvpPresenter().requestChatMemberByPage(mPage, time,
|
||||
mOnlineUserAdapter == null ? null : mOnlineUserAdapter.getData());
|
||||
private void loadData() {
|
||||
getMvpPresenter().requestRoomOnlineList(AvRoomDataManager.get().getRoomUid());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRequestChatMemberByPageSuccess(List<OnlineChatMember> chatRoomMemberList, int page) {
|
||||
mPage = page;
|
||||
if (!ListUtils.isListEmpty(chatRoomMemberList)) {
|
||||
//超管不显示
|
||||
Iterator<OnlineChatMember> iterator = chatRoomMemberList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
OnlineChatMember member = iterator.next();
|
||||
if (member != null && SuperAdminUtil.isSuperAdmin(member.chatRoomMember)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
mOnlineUserAdapter.setNewData(chatRoomMemberList);
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
} else {
|
||||
mRefreshLayout.finishLoadmore(0);
|
||||
}
|
||||
mPage++;
|
||||
} else {
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
} else {
|
||||
mRefreshLayout.finishLoadmore(0);
|
||||
}
|
||||
}
|
||||
public void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> chatRoomMemberList) {
|
||||
mOnlineUserAdapter.setNewData(chatRoomMemberList);
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestChatMemberByPageFail(String errorStr, int page) {
|
||||
Logger.i(ResUtil.getString(R.string.avroom_fragment_onlineuserfragment_01) + page);
|
||||
mPage = page;
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
} else {
|
||||
mRefreshLayout.finishLoadmore(0);
|
||||
}
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,16 +125,15 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {
|
||||
RoomInfo currentRoom = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (currentRoom != null) {
|
||||
List<OnlineChatMember> chatRoomMembers = mOnlineUserAdapter.getData();
|
||||
List<RoomOnlineUserBean> chatRoomMembers = mOnlineUserAdapter.getData();
|
||||
if (ListUtils.isListEmpty(chatRoomMembers)) return;
|
||||
OnlineChatMember onlineChatMember = chatRoomMembers.get(position);
|
||||
ChatRoomMember chatRoomMember = onlineChatMember.chatRoomMember;
|
||||
if (chatRoomMember != null) {
|
||||
RoomOnlineUserBean onlineChatMember = chatRoomMembers.get(position);
|
||||
if (onlineChatMember != null) {
|
||||
if (onlineChatMember.getItemType() == OnlineChatMember.NOBLE) {
|
||||
return;
|
||||
}
|
||||
UserInfoDialog.showNewUserInfoDialog(mContext,
|
||||
JavaUtil.str2long(chatRoomMember.getAccount()),
|
||||
onlineChatMember.getUid(),
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
@@ -185,28 +143,24 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberIn(String account, List<OnlineChatMember> dataList) {
|
||||
public void onMemberIn(String account) {
|
||||
// if (!isResumed()) return;
|
||||
// getMvpPresenter().onMemberInRefreshData(account, dataList, mPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberExit(String account, List<OnlineChatMember> dataList) {
|
||||
public void onMemberExit(String account) {
|
||||
// if (!isResumed()) return;
|
||||
// if (!isShowToUser()) return;
|
||||
// firstLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberDownUpMic(String account, boolean isUpMic, List<OnlineChatMember> dataList) {
|
||||
if (!isResumed()) return;
|
||||
getMvpPresenter().onMemberDownUpMic(account, isUpMic, dataList, mPage);
|
||||
public void onMemberDownUpMic(String account, boolean isUpMic) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateMemberManager(String account, boolean isRemoveManager, List<OnlineChatMember> dataList) {
|
||||
if (!isResumed()) return;
|
||||
getMvpPresenter().onUpdateMemberManager(account, dataList, isRemoveManager, mPage);
|
||||
public void onUpdateMemberManager(String account, boolean isRemoveManager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -3,6 +3,7 @@ package com.chwl.app.avroom.fragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter;
|
||||
import com.chwl.app.avroom.adapter.RoomContributeListAdapter;
|
||||
import com.chwl.app.avroom.widget.RankNavigatorAdapter;
|
||||
import com.chwl.app.base.BaseBindingFragment;
|
||||
@@ -26,7 +27,7 @@ public class RoomCharmListFragment extends BaseBindingFragment<FragmentRoomCharm
|
||||
ArrayList<Fragment> fragments = new ArrayList<>(2);
|
||||
fragments.add(RoomCharmRankingListFragment.newInstance(RoomContributeDataInfo.TYPE_ROOM_DAY_RANKING));
|
||||
fragments.add(RoomCharmRankingListFragment.newInstance(RoomContributeDataInfo.TYPE_ROOM_WEEK_RANKING));
|
||||
mBinding.vpCharmRankings.setAdapter(new RoomContributeListAdapter(getChildFragmentManager(), fragments));
|
||||
mBinding.vpCharmRankings.setAdapter(new CommonVPAdapter(getChildFragmentManager(), getLifecycle(),fragments));
|
||||
CommonNavigator commonNavigator = new CommonNavigator(getActivity());
|
||||
commonNavigator.setAdjustMode(false);
|
||||
|
||||
|
@@ -2,8 +2,10 @@ package com.chwl.app.avroom.fragment;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter;
|
||||
import com.chwl.app.avroom.adapter.RoomContributeListAdapter;
|
||||
import com.chwl.app.avroom.widget.RankNavigatorAdapter;
|
||||
import com.chwl.app.base.BaseMvpFragment;
|
||||
@@ -21,7 +23,7 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class RoomContributeListFragment extends BaseMvpFragment implements IMvpBaseView {
|
||||
|
||||
private ViewPager viewPager;
|
||||
private ViewPager2 viewPager;
|
||||
private MagicIndicator viewIndicator;
|
||||
|
||||
@Override
|
||||
@@ -43,7 +45,7 @@ public class RoomContributeListFragment extends BaseMvpFragment implements IMvpB
|
||||
if (AvRoomDataManager.get().isDatingMode()) {
|
||||
fragments.add(RoomContributeFragment.newInstance(RoomContributeDataInfo.TYPE_ROOM_MONTH_RANKING));
|
||||
}
|
||||
viewPager.setAdapter(new RoomContributeListAdapter(getChildFragmentManager(), fragments));
|
||||
viewPager.setAdapter(new CommonVPAdapter(getChildFragmentManager(),getLifecycle(), fragments));
|
||||
CommonNavigator commonNavigator = new CommonNavigator(getActivity());
|
||||
commonNavigator.setAdjustMode(false);
|
||||
RankNavigatorAdapter indicator = new RankNavigatorAdapter(AvRoomDataManager.get().isDatingMode());
|
||||
|
@@ -5,6 +5,7 @@ import android.view.View;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter;
|
||||
import com.chwl.app.avroom.adapter.RoomContributeListAdapter;
|
||||
import com.chwl.app.avroom.widget.RoomRankNavigatorAdapter;
|
||||
import com.chwl.app.base.BaseBindingFragment;
|
||||
@@ -29,7 +30,7 @@ public class RoomRankListFragment extends BaseBindingFragment<FragmentRoomRankLi
|
||||
List<Fragment> list = new ArrayList<>(2);
|
||||
list.add(new RoomContributeListFragment());
|
||||
list.add(RoomCharmListFragment.newInstance());
|
||||
mBinding.viewPager.setAdapter(new RoomContributeListAdapter(getChildFragmentManager(), list));
|
||||
mBinding.viewPager.setAdapter(new CommonVPAdapter(getChildFragmentManager(), getLifecycle(), list));
|
||||
|
||||
CommonNavigator commonNavigator = new CommonNavigator(getActivity());
|
||||
commonNavigator.setAdjustMode(true);
|
||||
|
@@ -0,0 +1,149 @@
|
||||
package com.chwl.app.avroom.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.OnMicroItemClickListener
|
||||
import com.chwl.app.avroom.adapter.SingleAnchorMicroViewAdapter
|
||||
import com.chwl.app.avroom.adapter.SingleRoomPKMicroViewAdapter
|
||||
import com.chwl.app.avroom.dialog.RequestUpMicDialog
|
||||
import com.chwl.app.avroom.gameplay.RoomGameplayListWidget
|
||||
import com.chwl.app.avroom.gameplay.RoomGameplayWidget
|
||||
import com.chwl.app.avroom.presenter.SingleRoomPresenter
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPkFinishDialog
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPkForceFinishDialog
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPkReceivedDialog
|
||||
import com.chwl.app.avroom.view.ISingleRoomView
|
||||
import com.chwl.app.databinding.FragmentSingleRoomBinding
|
||||
import com.chwl.app.music.widget.MusicPlayerView
|
||||
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.user.bean.UserInfo
|
||||
import com.chwl.library.base.factory.CreatePresenter
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
|
||||
/**
|
||||
* 個播房間
|
||||
*
|
||||
* @author chenran
|
||||
* @date 2017/7/26
|
||||
*/
|
||||
@CreatePresenter(SingleRoomPresenter::class)
|
||||
class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresenter?>(),
|
||||
ISingleRoomView, OnMicroItemClickListener {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(): SingleRoomFragment {
|
||||
val roomFragment = SingleRoomFragment()
|
||||
val bundle = Bundle()
|
||||
roomFragment.arguments = bundle
|
||||
return roomFragment
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var gameBinding: FragmentSingleRoomBinding
|
||||
private lateinit var upMicDialog: RequestUpMicDialog
|
||||
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_single_room
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
super.onFindViews()
|
||||
gameBinding = DataBindingUtil.bind(mView)!!
|
||||
gameBinding.lifecycleOwner = this
|
||||
gameBinding.click = this
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun initiate() {
|
||||
super.initiate()
|
||||
}
|
||||
|
||||
override fun onReceiveRoomEvent(roomEvent: RoomEvent?) {
|
||||
super.onReceiveRoomEvent(roomEvent)
|
||||
if (roomEvent == null) return
|
||||
when (roomEvent.event) {
|
||||
RoomEvent.REQUEST_UP_MIC -> {
|
||||
(roomEvent.chatRoomMessage?.attachment as? RequestUpmicAttachment)?.userInfo?.let {
|
||||
showInviteDialog(it)
|
||||
}
|
||||
}
|
||||
RoomEvent.ROOM_PK_INVITE ->
|
||||
SingleRoomPkReceivedDialog.newInstance((roomEvent.chatRoomMessage.attachment as RoomPKAttachment).roomPkBean)
|
||||
.show(mContext)
|
||||
RoomEvent.ROOM_PK_FINISH -> {
|
||||
val roomPkBean =
|
||||
(roomEvent.chatRoomMessage.attachment as RoomPKAttachment).roomPkBean
|
||||
if (roomPkBean.isForce) {
|
||||
SingleRoomPkForceFinishDialog.newInstance(roomPkBean).show(mContext)
|
||||
} else {
|
||||
SingleRoomPkFinishDialog.newInstance(roomPkBean).show(mContext)
|
||||
}
|
||||
gameBinding.microView.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//顯示請求上麥彈窗
|
||||
private fun showInviteDialog(userInfo: UserInfo) {
|
||||
if (!this::upMicDialog.isInitialized) {
|
||||
upMicDialog = RequestUpMicDialog(requireContext())
|
||||
}
|
||||
if (!upMicDialog.isShowing) {
|
||||
upMicDialog.openDialog()
|
||||
upMicDialog.setUser(userInfo)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSetListener() {
|
||||
super.onSetListener()
|
||||
bottomView.setBottomViewListener(BaseRoomBottomViewWrapper())
|
||||
}
|
||||
|
||||
override fun onEnterRoom() {
|
||||
super.onEnterRoom()
|
||||
}
|
||||
|
||||
override fun updateView() {
|
||||
super.updateView()
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode && gameBinding.microView.adapter !is SingleRoomPKMicroViewAdapter) {
|
||||
gameBinding.microView.bindAdapter(SingleRoomPKMicroViewAdapter(context))
|
||||
gameBinding.viewPkBoard.isVisible = true
|
||||
gameBinding.microView.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
topMargin = ScreenUtil.dip2px(140f)
|
||||
}
|
||||
} else if (!AvRoomDataManager.get().isOpenAnotherPKMode && gameBinding.microView.adapter !is SingleAnchorMicroViewAdapter) {
|
||||
gameBinding.microView.bindAdapter(SingleAnchorMicroViewAdapter(context))
|
||||
gameBinding.viewPkBoard.isVisible = false
|
||||
gameBinding.microView.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
topMargin = ScreenUtil.dip2px(110f)
|
||||
}
|
||||
} else {
|
||||
gameBinding.microView.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
registerWidget(
|
||||
RoomGameplayListWidget::class.java.simpleName,
|
||||
gameBinding.gameplayListWidget
|
||||
)
|
||||
registerWidget(RoomGameplayWidget::class.java.simpleName, gameBinding.gameplayWidget)
|
||||
}
|
||||
|
||||
override fun onInitMusicPlayerView(view: MusicPlayerView) {
|
||||
super.onInitMusicPlayerView(view)
|
||||
view.linkIconView(gameBinding.ivMusic, gameBinding.ivMusic)
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
|
||||
class GameplayRecyclerView : RecyclerView {
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
override fun onInterceptTouchEvent(e: MotionEvent?): Boolean {
|
||||
parent.requestDisallowInterceptTouchEvent(true)
|
||||
return super.onInterceptTouchEvent(e)
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewConfiguration
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomGameplayListWidgetBinding
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
|
||||
class RoomGameplayListWidget : FrameLayoutRoomWidget {
|
||||
private val adapter = RoomPlayListAdapter()
|
||||
private val binding: RoomGameplayListWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_gameplay_list_widget, this, true
|
||||
)
|
||||
|
||||
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 {
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.ivSwitch.setOnClickListener {
|
||||
getGameplayIconWidget()?.switchUI(false)
|
||||
}
|
||||
adapter.setOnItemClickListener { adapter, view, position ->
|
||||
(adapter.getItem(position) as? RoomIcon)?.let {
|
||||
getGameplayIconWidget()?.jump(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGameplayIconWidget(): RoomGameplayWidget? {
|
||||
return roomView?.findWidget(
|
||||
RoomGameplayWidget::class.simpleName ?: ""
|
||||
) as? RoomGameplayWidget
|
||||
}
|
||||
|
||||
fun loadData(list: List<RoomIcon>) {
|
||||
adapter.setNewData(list)
|
||||
if (list.size > 6) {
|
||||
binding.recyclerView.isScrollbarFadingEnabled = false
|
||||
binding.recyclerView.scrollBarFadeDuration = 0
|
||||
} else {
|
||||
binding.recyclerView.isScrollbarFadingEnabled = true
|
||||
binding.recyclerView.scrollBarFadeDuration =
|
||||
ViewConfiguration.getScrollBarFadeDuration()
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,119 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomGameplayWidgetBinding
|
||||
import com.chwl.app.treasure_box.widget.GoldBoxHelper
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.webview.room_banner.RoomWebDialogActivity
|
||||
import com.chwl.app.utils.CommonJumpHelper
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
|
||||
|
||||
class RoomGameplayWidget : FrameLayoutRoomWidget {
|
||||
private val binding: RoomGameplayWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_gameplay_widget, this, true
|
||||
)
|
||||
|
||||
private var isOpened = false
|
||||
|
||||
private var list: List<RoomIcon>? = 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 {
|
||||
binding.ivSwitch.setOnClickListener {
|
||||
switchUI(!isOpened)
|
||||
}
|
||||
binding.ivIcon.singleClick {
|
||||
list?.getOrNull(0)?.let {
|
||||
jump(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
|
||||
super.onInitialize(roomView, roomContext)
|
||||
refreshData()
|
||||
}
|
||||
|
||||
private fun refreshData() {
|
||||
val disposable = AvRoomModel.get().roomGamePlayList
|
||||
.subscribe { list: List<RoomIcon> ->
|
||||
loadData(list)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
fun switchUI(openListWidget: Boolean) {
|
||||
this.isOpened = openListWidget
|
||||
if (openListWidget) {
|
||||
this.visibility = View.INVISIBLE
|
||||
getGameplayListWidget()?.visibility = View.VISIBLE
|
||||
} else {
|
||||
this.visibility = View.VISIBLE
|
||||
getGameplayListWidget()?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData(list: List<RoomIcon>) {
|
||||
this.list = list
|
||||
this.isVisible = list.isNotEmpty()
|
||||
val listWidget = getGameplayListWidget()
|
||||
if (list.isEmpty()) {
|
||||
listWidget?.isVisible = false
|
||||
}
|
||||
listWidget?.loadData(list)
|
||||
binding.ivIcon.load(list.firstOrNull()?.icon)
|
||||
}
|
||||
|
||||
fun jump(data: RoomIcon) {
|
||||
if (data.isFindLove()) {
|
||||
GoldBoxHelper.handleBoxClick(context)
|
||||
} else {
|
||||
val url = data.skipContent
|
||||
if (data.skipType == 3 && !url.isNullOrEmpty()) {
|
||||
if (data.showType == 2) {
|
||||
RoomWebDialogActivity.start(context, url, false)
|
||||
} else {
|
||||
CommonWebViewActivity.start(context, url)
|
||||
}
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGameplayListWidget(): RoomGameplayListWidget? {
|
||||
return roomView?.findWidget(
|
||||
RoomGameplayListWidget::class.simpleName ?: ""
|
||||
) as? RoomGameplayListWidget
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
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.load
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
|
||||
|
||||
class RoomPlayListAdapter :
|
||||
BaseQuickAdapter<RoomIcon, BaseViewHolder>(R.layout.room_gameplay_item) {
|
||||
override fun convert(helper: BaseViewHolder, item: RoomIcon?) {
|
||||
helper.getView<ImageView>(R.id.iv_icon).load(item?.icon)
|
||||
}
|
||||
}
|
@@ -155,6 +155,9 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
AvRoomDataManager.get().roomPkLiveData.setValue(roomPkBean);
|
||||
if (AvRoomDataManager.get().isSingleRoom()){
|
||||
AudioEngineManager.get().setRemoteMute(roomPkBean.getAUid(), roomPkBean.getAMicStatus() == 0);
|
||||
if (AvRoomDataManager.get().isRoomOwner()) {
|
||||
AudioEngineManager.get().connectOtherRoom(String.valueOf(roomPkBean.getARoomId()), roomPkBean.getAUid());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -2,15 +2,9 @@ package com.chwl.app.avroom.presenter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.view.IHomePartyUserListView;
|
||||
import com.chwl.app.base.BaseMvpPresenter;
|
||||
import com.chwl.core.room.bean.OnlineChatMember;
|
||||
import com.chwl.core.room.model.HomePartyUserListModel;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
@@ -26,49 +20,17 @@ public class HomePartyUserListPresenter extends BaseMvpPresenter<IHomePartyUserL
|
||||
mHomePartyUserListMode = new HomePartyUserListModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取房间成员:第一页包含队列成员,固定成员,游客50人,之后每一页获取游客50人
|
||||
*
|
||||
* @param page 页数
|
||||
* @param time 固定成员列表用updateTime,
|
||||
* 游客列表用进入enterTime,
|
||||
* 填0会使用当前服务器最新时间开始查询,即第一页,单位毫秒
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
public void requestChatMemberByPage(final int page, long time, List<OnlineChatMember> oldList) {
|
||||
mHomePartyUserListMode.getOnLinePageMembers(page, time, oldList)
|
||||
.subscribe(onlineChatMembers -> {
|
||||
Logger.i(ResUtil.getString(R.string.avroom_presenter_homepartyuserlistpresenter_01), page, onlineChatMembers.size());
|
||||
if (getMvpView() != null) {
|
||||
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
|
||||
}
|
||||
}, throwable -> {
|
||||
throwable.printStackTrace();
|
||||
Logger.i(ResUtil.getString(R.string.avroom_presenter_homepartyuserlistpresenter_02), page, throwable.getMessage());
|
||||
if (getMvpView() != null) {
|
||||
getMvpView().onRequestChatMemberByPageFail(throwable.getMessage(), page);
|
||||
}
|
||||
});
|
||||
public void requestRoomOnlineList(long roomUid){
|
||||
mHomePartyUserListMode.getRoomOnlineList(roomUid).compose(bindToLifecycle()).subscribe((data, throwable) -> {
|
||||
if (getMvpView() != null) {
|
||||
if (data != null) {
|
||||
getMvpView().onRequestRoomOnlineListSuccess(data);
|
||||
} else {
|
||||
getMvpView().onRequestChatMemberByPageFail(throwable.getMessage(), 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onMemberDownUpMic(String account, boolean isUpMic, List<OnlineChatMember> dataList,
|
||||
final int page) {
|
||||
mHomePartyUserListMode.onMemberDownUpMic(account, isUpMic, dataList)
|
||||
.subscribe(onlineChatMembers -> {
|
||||
if (getMvpView() != null)
|
||||
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void onUpdateMemberManager(String account, List<OnlineChatMember> dataList,
|
||||
boolean isRemoveManager, final int page) {
|
||||
mHomePartyUserListMode.onUpdateMemberManager(account, isRemoveManager, dataList)
|
||||
.subscribe(onlineChatMembers -> {
|
||||
if (getMvpView() != null)
|
||||
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter;
|
||||
import com.chwl.app.base.BaseViewBindingActivity;
|
||||
import com.chwl.app.base.TitleBar;
|
||||
import com.chwl.app.databinding.ActivityMyRecommendCardBinding;
|
||||
@@ -49,7 +50,7 @@ public class MyRecommendCardActivity extends BaseViewBindingActivity<ActivityMyR
|
||||
fragmentList.add(RecommendCardFragment.newInstance(RcmdCardType.HAS_USED));
|
||||
//已失效
|
||||
fragmentList.add(RecommendCardFragment.newInstance(RcmdCardType.INVALID));
|
||||
binding.viewPager.setAdapter(new CardPagerAdapter(getSupportFragmentManager()));
|
||||
binding.viewPager.setAdapter(new CommonVPAdapter(getSupportFragmentManager() ,getLifecycle(), fragmentList));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,21 +83,4 @@ public class MyRecommendCardActivity extends BaseViewBindingActivity<ActivityMyR
|
||||
ViewPagerHelper.bind(binding.indicator, binding.viewPager);
|
||||
|
||||
}
|
||||
|
||||
class CardPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
public CardPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
return fragmentList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return fragmentList.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -251,7 +251,7 @@ class UploadRoomAlbumDialogFragment : BottomSheetDialogFragment() {
|
||||
}
|
||||
if (requestCode == 200) {
|
||||
PhotoProvider.getResultPathListAsync(data) {
|
||||
it?.let { paths ->
|
||||
it?.mapNotNull { it.path }?.let { paths ->
|
||||
compressPhotos(paths.toMutableList())
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ class SingleRoomPKSearchAdapter :
|
||||
tvSelect.text = ResUtil.getString(R.string.offline)
|
||||
tvSelect.setTextColor("#80C6C6E9".toColorInt())
|
||||
} else if (item.crossPking) {
|
||||
tvSelect.text = "PK中"
|
||||
tvSelect.text = tvSelect.context.getString(R.string.layout_item_home_tab_map_02)
|
||||
tvSelect.setTextColor("#80C6C6E9".toColorInt())
|
||||
} else {
|
||||
tvSelect.text = ResUtil.getString(R.string.select)
|
||||
|
@@ -3,6 +3,7 @@ package com.chwl.app.avroom.singleroompk
|
||||
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.databinding.DialogSingleRoomPkReceivedBinding
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
@@ -37,7 +38,7 @@ class SingleRoomPkReceivedDialog : BaseDialog<DialogSingleRoomPkReceivedBinding>
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding?.tvNick?.text = pkBean.inviteRoomTitle.subAndReplaceDot(7)
|
||||
binding?.tvTime?.text = "${pkBean.pkDuration}分鐘"
|
||||
binding?.tvTime?.text = "${pkBean.pkDuration}${getString(R.string.layout_activity_room_pk_create_010)}"
|
||||
pkBean.pkDesc.ifNotNullOrEmpty {
|
||||
binding?.tvDescTitle?.isVisible = true
|
||||
binding?.tvDesc?.isVisible = true
|
||||
|
@@ -2,7 +2,7 @@ package com.chwl.app.avroom.view;
|
||||
|
||||
|
||||
|
||||
import com.chwl.core.room.bean.OnlineChatMember;
|
||||
import com.chwl.core.room.bean.RoomOnlineUserBean;
|
||||
import com.chwl.library.base.IMvpBaseView;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
* @date 2017/12/8
|
||||
*/
|
||||
public interface IHomePartyUserListView extends IMvpBaseView {
|
||||
void onRequestChatMemberByPageSuccess(List<OnlineChatMember> memberList, int page);
|
||||
void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> memberList);
|
||||
|
||||
void onRequestChatMemberByPageFail(String errorStr, int page);
|
||||
|
||||
|
@@ -23,6 +23,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.opensource.svgaplayer.SVGACallback;
|
||||
@@ -91,6 +92,8 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
private Keyframe[] keyTrans;
|
||||
private SvgaObjectPool mMagicViewPool;
|
||||
|
||||
private boolean isRTL = false;
|
||||
|
||||
public GiftV2View(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -106,6 +109,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
|
||||
private void init(Context context) {
|
||||
this.context = context;
|
||||
isRTL = UiUtils.INSTANCE.isRtl(context);
|
||||
mSVGAParser = new SVGAParser(context);
|
||||
mSVGAVideoEntityMap = new HashMap<>(20);
|
||||
LayoutInflater.from(getContext()).inflate(R.layout.layout_gift_v2_view, this, true);
|
||||
@@ -249,7 +253,6 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
LogUtil.print("gift micViewPoint is null");
|
||||
continue;
|
||||
}
|
||||
|
||||
Point senderPoint = micViewPoint.get(senderPosition);
|
||||
Point receivePoint = micViewPoint.get(receivePosition);
|
||||
//设置动画结束的位置
|
||||
@@ -651,6 +654,11 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
Keyframe keyTransX3 = (Keyframe.ofFloat(0.5f, center.x - senderPoint.x - giftWidth / 2));
|
||||
Keyframe keyTransX4 = (Keyframe.ofFloat(0.8f, center.x - senderPoint.x - giftWidth / 2));
|
||||
Keyframe keyTransX5 = (Keyframe.ofFloat(1f, receivePoint.x - senderPoint.x));
|
||||
if (isRTL) {
|
||||
keyTransX3 = (Keyframe.ofFloat(0.5f, senderPoint.x - center.x + giftWidth / 2));
|
||||
keyTransX4 = (Keyframe.ofFloat(0.8f, senderPoint.x - center.x + giftWidth / 2));
|
||||
keyTransX5 = (Keyframe.ofFloat(1f, senderPoint.x - receivePoint.x));
|
||||
}
|
||||
|
||||
Keyframe keyTransY3 = (Keyframe.ofFloat(0.5f, center.y - senderPoint.y - giftHeight / 2));
|
||||
Keyframe keyTransY4 = (Keyframe.ofFloat(0.8f, center.y - senderPoint.y - giftHeight / 2));
|
||||
@@ -842,10 +850,12 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
|
||||
private static class SvgaObjectPool extends ObjectPool<SVGAImageView> {
|
||||
private WeakReference<GiftV2View> mReference;
|
||||
private boolean isRTL = false;
|
||||
|
||||
SvgaObjectPool(GiftV2View giftV2View) {
|
||||
super();
|
||||
mReference = new WeakReference<>(giftV2View);
|
||||
isRTL = UiUtils.INSTANCE.isRtl(giftV2View.getContext());
|
||||
}
|
||||
|
||||
private SVGAImageView cleanView(SVGAImageView imageView) {
|
||||
@@ -875,7 +885,11 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
SVGAImageView imageView = cleanView(super.borrowObject());
|
||||
LayoutParams params = new LayoutParams(parent.giftWidth, parent.giftHeight);
|
||||
imageView.setLayoutParams(params);
|
||||
params.leftMargin = senderPoint.x;
|
||||
if (isRTL) {
|
||||
params.rightMargin = senderPoint.x;
|
||||
}else{
|
||||
params.leftMargin = senderPoint.x;
|
||||
}
|
||||
params.topMargin = senderPoint.y;
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
if (parent.indexOfChild(imageView) == -1)
|
||||
@@ -896,7 +910,11 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
SVGAImageView imageView = cleanView(super.borrowObject());
|
||||
LayoutParams params = new LayoutParams(parent.giftWidth, parent.giftHeight);
|
||||
imageView.setLayoutParams(params);
|
||||
params.leftMargin = senderPoint.x;
|
||||
if (isRTL) {
|
||||
params.rightMargin = senderPoint.x;
|
||||
}else{
|
||||
params.leftMargin = senderPoint.x;
|
||||
}
|
||||
params.topMargin = senderPoint.y;
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
imageView.setScaleX(1.5F);
|
||||
|
@@ -4,6 +4,7 @@ import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_ALBUM;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_TEMPLATE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L1;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L2;
|
||||
@@ -18,6 +19,7 @@ import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_FANS_TEAM_JOIN;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_GIFT_COMPOUND;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUPER_LUCKY_GIFT_TEMPLATE;
|
||||
import static com.chwl.core.redpackage.RedPackageTypeKt.ALL_DIAMOND;
|
||||
import static com.chwl.core.redpackage.RedPackageTypeKt.ALL_GIFT;
|
||||
import static com.chwl.core.redpackage.RedPackageTypeKt.ROOM_DIAMOND;
|
||||
@@ -59,8 +61,10 @@ import com.bumptech.glide.request.target.Target;
|
||||
import com.chwl.app.photo.BigPhotoActivity;
|
||||
import com.chwl.app.photo.PagerOption;
|
||||
import com.chwl.app.utils.ObjectTypeHelper;
|
||||
import com.chwl.core.im.custom.bean.TemplateMessageAttachment;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
|
||||
import com.chwl.core.utils.extension.StringExtensionKt;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.netease.nim.uikit.business.uinfo.UserInfoHelper;
|
||||
import com.netease.nim.uikit.common.ui.span.RadiusBackgroundSpan;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
@@ -252,6 +256,7 @@ public class MessageView extends FrameLayout {
|
||||
private OnClick onClick;
|
||||
|
||||
private OnMsgLongClickListener onLongClickListener;
|
||||
private TemplateMessageAdapter templateMessageAdapter;
|
||||
|
||||
public MessageView(Context context) {
|
||||
this(context, null);
|
||||
@@ -265,7 +270,6 @@ public class MessageView extends FrameLayout {
|
||||
super(context, attr, i);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public void setOnLongClickListener(OnMsgLongClickListener onLongClickListener) {
|
||||
this.onLongClickListener = onLongClickListener;
|
||||
}
|
||||
@@ -435,6 +439,17 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
}
|
||||
|
||||
private TemplateMessageAdapter getTemplateMessageAdapter() {
|
||||
if (templateMessageAdapter == null) {
|
||||
templateMessageAdapter = new TemplateMessageAdapter(uid -> {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(uid)).subscribe(clickConsumer);
|
||||
}
|
||||
});
|
||||
}
|
||||
return templateMessageAdapter;
|
||||
}
|
||||
|
||||
public void onCurrentRoomReceiveNewMsg(List<ChatRoomMessage> messages) {
|
||||
if (messages == null) return;
|
||||
if (messages.size() == 1) {
|
||||
@@ -585,6 +600,7 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class SpannableBuilder {
|
||||
private SpannableStringBuilder builder;
|
||||
private TextView textView;
|
||||
@@ -616,6 +632,19 @@ public class MessageView extends FrameLayout {
|
||||
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @param drawable -icon url
|
||||
* @return -返回一個spannableStringBuilder
|
||||
*/
|
||||
public SpannableBuilder appendImg(String drawable, Object what) {
|
||||
if (TextUtils.isEmpty(drawable)) return this;
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
CustomImageSpan imageSpan = new CustomImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, drawable);
|
||||
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
builder.setSpan(what, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param drawable -icon url
|
||||
@@ -632,6 +661,16 @@ public class MessageView extends FrameLayout {
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpannableBuilder append(String drawable, int width, int height, Object what) {
|
||||
if (TextUtils.isEmpty(drawable)) return this;
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
CustomImageSpan imageSpan = new CustomImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, drawable, width, height);
|
||||
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
builder.setSpan(what, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本和背景分離的情況
|
||||
*/
|
||||
@@ -673,6 +712,16 @@ public class MessageView extends FrameLayout {
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpannableBuilder append(String imgUrl, int height, Object what) {
|
||||
if (TextUtils.isEmpty(imgUrl)) return this;
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
builder.setSpan(new CustomAutoWidthImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, imgUrl, height)
|
||||
, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
builder.setSpan(what, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param drawable -icon
|
||||
* @param width 寬
|
||||
@@ -793,6 +842,10 @@ public class MessageView extends FrameLayout {
|
||||
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) {
|
||||
@@ -1031,6 +1084,20 @@ public class MessageView extends FrameLayout {
|
||||
setFairyMsg(chatRoomMessage, tvContent);
|
||||
} else if (first == CUSTOM_MSG_ROOM_ALBUM) {
|
||||
setRoomAlbumMsg(chatRoomMessage, baseViewHolder);
|
||||
} else if (first == CUSTOM_MSG_ROOM_TEMPLATE) {
|
||||
TemplateMessageAttachment templateMessageAttachment = (TemplateMessageAttachment) chatRoomMessage.getAttachment();
|
||||
if (templateMessageAttachment != null) {
|
||||
getTemplateMessageAdapter().convert(tvContent, templateMessageAttachment.getTemplateMessage());
|
||||
} else {
|
||||
getTemplateMessageAdapter().convert(tvContent, null);
|
||||
}
|
||||
} else if (first == CUSTOM_MSG_SUPER_LUCKY_GIFT_TEMPLATE) {
|
||||
TemplateMessageAttachment templateMessageAttachment = (TemplateMessageAttachment) chatRoomMessage.getAttachment();
|
||||
if (templateMessageAttachment != null) {
|
||||
getTemplateMessageAdapter().convert(tvContent, templateMessageAttachment.getTemplateMessage());
|
||||
} else {
|
||||
getTemplateMessageAdapter().convert(tvContent, null);
|
||||
}
|
||||
} else {
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
@@ -1532,13 +1599,13 @@ public class MessageView extends FrameLayout {
|
||||
case ALL_DIAMOND:
|
||||
case ROOM_DIAMOND:
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_031), new ForegroundColorSpan(textColor))
|
||||
.append((int) roomMsg.getAmount() + ResUtil.getString(R.string.avroom_widget_messageview_032), new ForegroundColorSpan(roomTipColor));
|
||||
.append((int) roomMsg.getAmount() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor));
|
||||
tvContent.setText(text.build());
|
||||
break;
|
||||
case ALL_GIFT:
|
||||
case ROOM_GIFT:
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_033), new ForegroundColorSpan(textColor))
|
||||
.append((int) roomMsg.getAmount() + ResUtil.getString(R.string.avroom_widget_messageview_034), new ForegroundColorSpan(roomTipColor))
|
||||
.append((int) roomMsg.getAmount() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_035), new ForegroundColorSpan(textColor));
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
@@ -1934,15 +2001,15 @@ public class MessageView extends FrameLayout {
|
||||
RoomBoxPrizeAttachment attachment = (RoomBoxPrizeAttachment) chatRoomMessage.getAttachment();
|
||||
// 內容
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_093), new ForegroundColorSpan(greyColor))
|
||||
.append("厲害了 ", new ForegroundColorSpan(greyColor))
|
||||
.append(attachment.getNick() + " ", new ForegroundColorSpan(roomTipColor))
|
||||
.append(ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(R.string.avroom_widget_messageview_095), new ForegroundColorSpan(greyColor))
|
||||
.append("通過歡樂砸蛋" + "獲得 ", new ForegroundColorSpan(greyColor))
|
||||
.append(attachment.getPrizeName(), new ForegroundColorSpan(Color.WHITE));
|
||||
if (attachment.getPrizeNum() > 1) {
|
||||
text.append(" x" + attachment.getPrizeNum() + " ", new ForegroundColorSpan(roomTipColor));
|
||||
}
|
||||
if (attachment.getSecond() == CUSTOM_MSG_SUB_BOX_ME) {
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_096), new ForegroundColorSpan(Color.WHITE));
|
||||
text.append("(僅自己可見)", new ForegroundColorSpan(Color.WHITE));
|
||||
}
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
@@ -2281,7 +2348,7 @@ public class MessageView extends FrameLayout {
|
||||
builder.append(ResUtil.getString(R.string.avroom_widget_messageview_0120), new ForegroundColorSpan(roomTipNickColor));
|
||||
} else {
|
||||
builder.append(senderNick, new ForegroundColorSpan(roomTipNickColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0121) + auctionAttachment.getAuctionInfo().getRivals().get(0).getAuctMoney() + ResUtil.getString(R.string.avroom_widget_messageview_0122));
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0121) + auctionAttachment.getAuctionInfo().getRivals().get(0).getAuctMoney() + ResUtil.getString(R.string.avroom_widget_messageview_027));
|
||||
}
|
||||
tvContent.setText(builder.build());
|
||||
}
|
||||
@@ -2381,7 +2448,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0126), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(ResUtil.getString(R.string.gift_message_01), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(giftInfo == null ? "" : giftInfo.getGiftUrl(), giftLength, giftLength)
|
||||
.append("X" + giftAttachment.getMultiGiftReceiveInfo().getGiftNum(), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
tvContent.setText(text.build());
|
||||
@@ -2417,9 +2484,9 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0127), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
.append(ResUtil.getString(R.string.gift_message_01), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
|
||||
text.append(luckyGiftInfo.getGiftName() + ResUtil.getString(R.string.avroom_widget_messageview_0128), 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)))
|
||||
.append(luckyGiftInfo.getUser().getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
@@ -2428,10 +2495,10 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
});
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0129));
|
||||
text.append(ResUtil.getString(R.string.gift_message_04));
|
||||
for (GiftList luckyGiftList : luckyGiftInfo.getGiftList()) {
|
||||
if (luckyGiftList.getGiftInfo() == null) continue;
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0130) + luckyGiftList.getGiftInfo().getGoldPrice() + ResUtil.getString(R.string.avroom_widget_messageview_0131))
|
||||
text.append(ResUtil.getString(R.string.gift_message_03) + luckyGiftList.getGiftInfo().getGoldPrice() + ResUtil.getString(R.string.gift_message_05))
|
||||
.append(luckyGiftList.getGiftInfo().getGiftUrl(), giftLength, giftLength)
|
||||
.append("X" + luckyGiftList.getGiftNum(), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append("、");
|
||||
@@ -2472,9 +2539,9 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0132), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
.append(ResUtil.getString(R.string.gift_message_01), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
|
||||
text.append(luckyGiftInfo.getGiftName() + ResUtil.getString(R.string.avroom_widget_messageview_0133), 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)))
|
||||
.append(luckyGiftInfo.getUser().getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
@@ -2483,10 +2550,10 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
});
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0134));
|
||||
text.append(ResUtil.getString(R.string.gift_message_04));
|
||||
for (GiftList luckyGiftList : luckyGiftInfo.getGiftList()) {
|
||||
if (luckyGiftList.getGiftInfo() == null) continue;
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0135) + luckyGiftList.getGiftInfo().getGoldPrice() + ResUtil.getString(R.string.avroom_widget_messageview_0136))
|
||||
text.append(ResUtil.getString(R.string.gift_message_03) + luckyGiftList.getGiftInfo().getGoldPrice() + ResUtil.getString(R.string.gift_message_05))
|
||||
.append(luckyGiftList.getGiftInfo().getGiftUrl(), giftLength, giftLength)
|
||||
.append("X" + luckyGiftList.getGiftNum(), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append("、");
|
||||
@@ -2495,7 +2562,6 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
Editable msg = text.builder;
|
||||
msg.delete(msg.length() - 1, msg.length());
|
||||
|
||||
tvContent.setText(text.build());
|
||||
tvContent.setOnClickListener(null);
|
||||
tvContent.setMovementMethod(new LinkMovementMethod());
|
||||
@@ -2522,7 +2588,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0137), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
.append(ResUtil.getString(R.string.gift_message_06), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
|
||||
for (GiftReceiver targetUser : attachment.getGiftMultiReceiverInfo().getTargetUsers()) {
|
||||
text.append(targetUser.getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@@ -2698,7 +2764,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0149), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(ResUtil.getString(R.string.gift_message_06), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(targetNick, new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
@@ -2895,7 +2961,7 @@ public class MessageView extends FrameLayout {
|
||||
.append("【簽到瓜分百萬】哇塞,恭喜 ", new ForegroundColorSpan(greyColor))
|
||||
.append(attachment.getNick() + " ", new ForegroundColorSpan(roomTipColor))
|
||||
.append("簽到獲得 ", new ForegroundColorSpan(greyColor))
|
||||
.append(attachment.getGoldNum() + "鉆石", new ForegroundColorSpan(roomTipColor))
|
||||
.append(attachment.getGoldNum() + "金幣", new ForegroundColorSpan(roomTipColor))
|
||||
.append("!", new ForegroundColorSpan(greyColor));
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
@@ -98,7 +99,7 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
|
||||
|
||||
public void bindAdapter(@NonNull BaseMicroViewAdapter adapter) {
|
||||
if (adapter instanceof DatingMicroViewAdapter) {
|
||||
if (datingItemDecoration == null) datingItemDecoration = new DatingItemDecoration();
|
||||
if (datingItemDecoration == null) datingItemDecoration = new DatingItemDecoration(UiUtils.INSTANCE.isRtl(getContext()));
|
||||
recyclerView.addItemDecoration(datingItemDecoration);
|
||||
} else if (datingItemDecoration != null) {
|
||||
recyclerView.removeItemDecoration(datingItemDecoration);
|
||||
@@ -181,8 +182,15 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
|
||||
View view = child.findViewById(R.id.micro_layout);
|
||||
if (view != null) child = view;
|
||||
child.getLocationInWindow(location);
|
||||
int x = (location[0] + child.getWidth() / 2) - giftWidth / 2;
|
||||
int y = (location[1] + child.getHeight() / 2) - giftHeight / 2;
|
||||
int x;
|
||||
int y;
|
||||
if (UiUtils.INSTANCE.isRtl(getContext())) {
|
||||
location[0] = getWidth() - location[0];
|
||||
x = (location[0] - child.getWidth() / 2) - giftWidth / 2;
|
||||
}else{
|
||||
x = (location[0] + child.getWidth() / 2) - giftWidth / 2;
|
||||
}
|
||||
y = (location[1] + child.getHeight() / 2) - giftHeight / 2;
|
||||
Point point = new Point(x, y);
|
||||
LogUtils.d("x= " + x + " y= " + y);
|
||||
centerPoints.put(micPosition, point);
|
||||
|
@@ -151,8 +151,8 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
.subscribe { roomEvent: RoomEvent? ->
|
||||
if (roomEvent == null || AvRoomDataManager.get().isSelfGamePlaying) return@subscribe
|
||||
when (roomEvent.event) {
|
||||
RoomEvent.BOX_NOTIFY -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
// RoomEvent.BOX_NOTIFY -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
// RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.DATING_ALL_NOTIFY -> addDatingAllNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.RADISH_NOTIFY,
|
||||
RoomEvent.RADISH_NOTIFY_SVGA -> addRadishNotify(roomEvent.chatRoomMessage)
|
||||
@@ -305,143 +305,143 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
*
|
||||
* @param chatRoomMessage
|
||||
*/
|
||||
private fun addBoxNotify(chatRoomMessage: ChatRoomMessage) {
|
||||
if (binding.clNotify.visibility == GONE) {
|
||||
binding.clNotify.visibility = VISIBLE
|
||||
}
|
||||
messagesBox.add(chatRoomMessage)
|
||||
if (boxDisposable == null || messagesBox.size == 1) {
|
||||
boxDisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesBox.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
if (binding.flBoxNotify.childCount == 0) {
|
||||
val msg = messagesBox.removeAt(0)
|
||||
val attachment = msg.attachment
|
||||
if (attachment is CustomAttachment) {
|
||||
if (attachment.second == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY) {
|
||||
showBoxNotify(msg)
|
||||
} else if(attachment.second == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
showBoxNotifyBySVGA(msg)
|
||||
}
|
||||
// private fun addBoxNotify(chatRoomMessage: ChatRoomMessage) {
|
||||
// if (binding.clNotify.visibility == GONE) {
|
||||
// binding.clNotify.visibility = VISIBLE
|
||||
// }
|
||||
// messagesBox.add(chatRoomMessage)
|
||||
// if (boxDisposable == null || messagesBox.size == 1) {
|
||||
// boxDisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .takeWhile { messagesBox.size > 0 && !mContext.isDestroyed() }
|
||||
// .subscribe {
|
||||
// if (binding.flBoxNotify.childCount == 0) {
|
||||
// val msg = messagesBox.removeAt(0)
|
||||
// val attachment = msg.attachment
|
||||
// if (attachment is CustomAttachment) {
|
||||
// if (attachment.second == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY) {
|
||||
// showBoxNotify(msg)
|
||||
// } else if(attachment.second == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
// showBoxNotifyBySVGA(msg)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// private fun showBoxNotify(chatRoomMessage: ChatRoomMessage) {
|
||||
// val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
// val textView =
|
||||
// LayoutInflater.from(mContext).inflate(R.layout.layout_room_box_notify, null) as TextView
|
||||
// val text = SpannableBuilder()
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.avroom_widget_roomeffectview_08),
|
||||
// ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.nick.subAndReplaceDot(8),
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
// R.string.avroom_widget_roomeffectview_010
|
||||
// ), ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.prizeName,
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// if (attachment.prizeNum > 1) {
|
||||
// text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
// }
|
||||
// textView.text = text.build()
|
||||
// animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
// binding.flBoxNotify.addView(textView)
|
||||
// textView.startAnimation(animationBox)
|
||||
// binding.flBoxNotify.postDelayed(
|
||||
// {
|
||||
// animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
// textView.startAnimation(animationBox)
|
||||
// },
|
||||
// SHOW_TIME.toLong()
|
||||
// )
|
||||
// binding.flBoxNotify.postDelayed({
|
||||
// binding.flBoxNotify.removeView(textView)
|
||||
// }, CLOSE_TIME.toLong())
|
||||
// }
|
||||
|
||||
private fun showBoxNotify(chatRoomMessage: ChatRoomMessage) {
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
val textView =
|
||||
LayoutInflater.from(mContext).inflate(R.layout.layout_room_box_notify, null) as TextView
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_08),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.nick.subAndReplaceDot(8),
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
R.string.avroom_widget_roomeffectview_010
|
||||
), ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
if (attachment.prizeNum > 1) {
|
||||
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
}
|
||||
textView.text = text.build()
|
||||
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flBoxNotify.addView(textView)
|
||||
textView.startAnimation(animationBox)
|
||||
binding.flBoxNotify.postDelayed(
|
||||
{
|
||||
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
textView.startAnimation(animationBox)
|
||||
},
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
binding.flBoxNotify.postDelayed({
|
||||
binding.flBoxNotify.removeView(textView)
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
|
||||
private fun showBoxNotifyBySVGA(chatRoomMessage: ChatRoomMessage) {
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_011),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
StringUtils.abbreviate(attachment.nick, 8) + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
R.string.avroom_widget_roomeffectview_013
|
||||
), ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
if (attachment.prizeNum > 1) {
|
||||
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
}
|
||||
val svgaImageView = SVGAImageView(mContext)
|
||||
svgaImageView.loops = 1
|
||||
svgaImageView.clearsAfterDetached = true
|
||||
val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
svgaImageView.layoutParams = params
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
animationBox!!.setAnimationListener(object : SimpleAnimationListener() {
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
binding.flBoxNotify.removeView(svgaImageView)
|
||||
}
|
||||
})
|
||||
binding.flBoxNotify.startAnimation(animationBox)
|
||||
}
|
||||
}
|
||||
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flBoxNotify.addView(svgaImageView)
|
||||
binding.flBoxNotify.startAnimation(animationBox)
|
||||
|
||||
shareParser().decodeFromAssets("svga/box_notify.svga", object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
val dynamicEntity = SVGADynamicEntity()
|
||||
val textPaint = TextPaint()
|
||||
textPaint.color = Color.WHITE //字體顏色
|
||||
textPaint.textSize = 24f //字體大小
|
||||
dynamicEntity.setDynamicText(
|
||||
StaticLayout(
|
||||
text.build(),
|
||||
0,
|
||||
text.build().length,
|
||||
textPaint,
|
||||
0,
|
||||
Layout.Alignment.ALIGN_CENTER,
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "bg"
|
||||
)
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.stepToFrame(0, true)
|
||||
}
|
||||
|
||||
override fun onError() {}
|
||||
}, null)
|
||||
}
|
||||
// private fun showBoxNotifyBySVGA(chatRoomMessage: ChatRoomMessage) {
|
||||
// val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
// val text = SpannableBuilder()
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.avroom_widget_roomeffectview_011),
|
||||
// ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// StringUtils.abbreviate(attachment.nick, 8) + " ",
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
// R.string.avroom_widget_roomeffectview_013
|
||||
// ), ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.prizeName,
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// if (attachment.prizeNum > 1) {
|
||||
// text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
// }
|
||||
// val svgaImageView = SVGAImageView(mContext)
|
||||
// svgaImageView.loops = 1
|
||||
// svgaImageView.clearsAfterDetached = true
|
||||
// val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
// svgaImageView.layoutParams = params
|
||||
// svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
// override fun onFinished() {
|
||||
// animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
// animationBox!!.setAnimationListener(object : SimpleAnimationListener() {
|
||||
// override fun onAnimationEnd(animation: Animation?) {
|
||||
// binding.flBoxNotify.removeView(svgaImageView)
|
||||
// }
|
||||
// })
|
||||
// binding.flBoxNotify.startAnimation(animationBox)
|
||||
// }
|
||||
// }
|
||||
// animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
// binding.flBoxNotify.addView(svgaImageView)
|
||||
// binding.flBoxNotify.startAnimation(animationBox)
|
||||
//
|
||||
// shareParser().decodeFromAssets("svga/box_notify.svga", object : SVGAParser.ParseCompletion {
|
||||
// override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
// val dynamicEntity = SVGADynamicEntity()
|
||||
// val textPaint = TextPaint()
|
||||
// textPaint.color = Color.WHITE //字體顏色
|
||||
// textPaint.textSize = 24f //字體大小
|
||||
// dynamicEntity.setDynamicText(
|
||||
// StaticLayout(
|
||||
// text.build(),
|
||||
// 0,
|
||||
// text.build().length,
|
||||
// textPaint,
|
||||
// 0,
|
||||
// Layout.Alignment.ALIGN_CENTER,
|
||||
// 1.0f,
|
||||
// 0.0f,
|
||||
// false
|
||||
// ), "bg"
|
||||
// )
|
||||
// val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
// svgaImageView.setImageDrawable(drawable)
|
||||
// svgaImageView.stepToFrame(0, true)
|
||||
// }
|
||||
//
|
||||
// override fun onError() {}
|
||||
// }, null)
|
||||
// }
|
||||
|
||||
/**
|
||||
* 幸運池飄屏
|
||||
|
@@ -165,13 +165,13 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
.subscribe { roomEvent: RoomEvent? ->
|
||||
if (roomEvent == null || AvRoomDataManager.get().isSelfGamePlaying) return@subscribe
|
||||
when (roomEvent.event) {
|
||||
RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
addPlayNotify(RoomEvent.BOX_NOTIFY, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱svga
|
||||
addPlayNotify(RoomEvent.BOX_NOTIFY_SVGA, roomEvent.chatRoomMessage)
|
||||
}
|
||||
// RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
// addPlayNotify(RoomEvent.BOX_NOTIFY, roomEvent.chatRoomMessage)
|
||||
// }
|
||||
//
|
||||
// RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱svga
|
||||
// addPlayNotify(RoomEvent.BOX_NOTIFY_SVGA, roomEvent.chatRoomMessage)
|
||||
// }
|
||||
|
||||
RoomEvent.TAROT_NOTIFY,
|
||||
RoomEvent.TAROT_NOTIFY_SVGA -> {
|
||||
@@ -182,9 +182,9 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE ->//全服福袋
|
||||
//廳內福袋
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
// RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE ->//全服福袋
|
||||
// //廳內福袋
|
||||
// addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
|
||||
RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY -> {// 星级厨房房间飘屏通知
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
@@ -287,57 +287,57 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
when (messagesPlay[0].event) {
|
||||
RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 180.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
} else {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
showBoxNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 180.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
} else {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
showBoxNotifyBySVGA(messagesPlay.removeAt(0))
|
||||
}
|
||||
}
|
||||
// RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
// if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
// isPlayAnim = true
|
||||
// val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
// if (isPlay) {
|
||||
// margin(
|
||||
// binding.clNotify,
|
||||
// 0,
|
||||
// UIUtil.dip2px(context, 180.0),
|
||||
// 0,
|
||||
// 0
|
||||
// )
|
||||
// } else {
|
||||
// margin(
|
||||
// binding.clNotify,
|
||||
// 0,
|
||||
// UIUtil.dip2px(context, 60.0),
|
||||
// 0,
|
||||
// 0
|
||||
// )
|
||||
// }
|
||||
// showBoxNotify(
|
||||
// messagesPlay.removeAt(0)
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱
|
||||
// if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
// isPlayAnim = true
|
||||
// val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
// if (isPlay) {
|
||||
// margin(
|
||||
// binding.clNotify,
|
||||
// 0,
|
||||
// UIUtil.dip2px(context, 180.0),
|
||||
// 0,
|
||||
// 0
|
||||
// )
|
||||
// } else {
|
||||
// margin(
|
||||
// binding.clNotify,
|
||||
// 0,
|
||||
// UIUtil.dip2px(context, 60.0),
|
||||
// 0,
|
||||
// 0
|
||||
// )
|
||||
// }
|
||||
// showBoxNotifyBySVGA(messagesPlay.removeAt(0))
|
||||
// }
|
||||
// }
|
||||
|
||||
RoomEvent.TAROT_NOTIFY -> {
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
@@ -966,49 +966,49 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
isPlayAnim = false
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
|
||||
private fun showBoxNotify(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
val textView =
|
||||
LayoutInflater.from(mContext).inflate(R.layout.layout_room_box_notify, null) as TextView
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_08),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.nick.subAndReplaceDot(8),
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
R.string.avroom_widget_roomeffectview_010
|
||||
), ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
if (attachment.prizeNum > 1) {
|
||||
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
}
|
||||
textView.text = text.build()
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flPlayNotify.addView(textView)
|
||||
textView.startAnimation(animationPlay)
|
||||
binding.flPlayNotify.postDelayed(
|
||||
{
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
textView.startAnimation(animationPlay)
|
||||
},
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
binding.flPlayNotify.postDelayed({
|
||||
binding.flPlayNotify.removeView(textView)
|
||||
isPlayAnim = false
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
//
|
||||
// private fun showBoxNotify(roomPlayBean: RoomPlayBean) {
|
||||
// val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
// val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
// val textView =
|
||||
// LayoutInflater.from(mContext).inflate(R.layout.layout_room_box_notify, null) as TextView
|
||||
// val text = SpannableBuilder()
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.avroom_widget_roomeffectview_08),
|
||||
// ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.nick.subAndReplaceDot(8),
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
// R.string.avroom_widget_roomeffectview_010
|
||||
// ), ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.prizeName,
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// if (attachment.prizeNum > 1) {
|
||||
// text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
// }
|
||||
// textView.text = text.build()
|
||||
// animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
// binding.flPlayNotify.addView(textView)
|
||||
// textView.startAnimation(animationPlay)
|
||||
// binding.flPlayNotify.postDelayed(
|
||||
// {
|
||||
// animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
// textView.startAnimation(animationPlay)
|
||||
// },
|
||||
// SHOW_TIME.toLong()
|
||||
// )
|
||||
// binding.flPlayNotify.postDelayed({
|
||||
// binding.flPlayNotify.removeView(textView)
|
||||
// isPlayAnim = false
|
||||
// }, CLOSE_TIME.toLong())
|
||||
// }
|
||||
|
||||
private fun showTarotNotifyBySVGA(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
@@ -1066,78 +1066,78 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun showBoxNotifyBySVGA(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_011),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
StringUtils.abbreviate(attachment.nick, 8) + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
R.string.avroom_widget_roomeffectview_013
|
||||
), ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
if (attachment.prizeNum > 1) {
|
||||
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
}
|
||||
val svgaImageView = SVGAImageView(mContext)
|
||||
svgaImageView.loops = 1
|
||||
svgaImageView.clearsAfterDetached = true
|
||||
val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
svgaImageView.layoutParams = params
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
animationPlay!!.setAnimationListener(object : SimpleAnimationListener() {
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
binding.flPlayNotify.removeView(svgaImageView)
|
||||
isPlayAnim = false
|
||||
}
|
||||
})
|
||||
binding.flPlayNotify.startAnimation(animationPlay)
|
||||
}
|
||||
}
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flPlayNotify.addView(svgaImageView)
|
||||
binding.flPlayNotify.startAnimation(animationPlay)
|
||||
|
||||
shareParser().decodeFromAssets("svga/box_notify.svga", object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
val dynamicEntity = SVGADynamicEntity()
|
||||
val textPaint = TextPaint()
|
||||
textPaint.color = Color.WHITE //字體顏色
|
||||
textPaint.textSize = 24f //字體大小
|
||||
dynamicEntity.setDynamicText(
|
||||
StaticLayout(
|
||||
text.build(),
|
||||
0,
|
||||
text.build().length,
|
||||
textPaint,
|
||||
0,
|
||||
Layout.Alignment.ALIGN_CENTER,
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "bg"
|
||||
)
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.stepToFrame(0, true)
|
||||
}
|
||||
|
||||
override fun onError() {}
|
||||
}, null)
|
||||
}
|
||||
// private fun showBoxNotifyBySVGA(roomPlayBean: RoomPlayBean) {
|
||||
// val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
// val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
// val text = SpannableBuilder()
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.avroom_widget_roomeffectview_011),
|
||||
// ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// StringUtils.abbreviate(attachment.nick, 8) + " ",
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
// R.string.avroom_widget_roomeffectview_013
|
||||
// ), ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.prizeName,
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// if (attachment.prizeNum > 1) {
|
||||
// text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
// }
|
||||
// val svgaImageView = SVGAImageView(mContext)
|
||||
// svgaImageView.loops = 1
|
||||
// svgaImageView.clearsAfterDetached = true
|
||||
// val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
// svgaImageView.layoutParams = params
|
||||
// svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
// override fun onFinished() {
|
||||
// animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
// animationPlay!!.setAnimationListener(object : SimpleAnimationListener() {
|
||||
// override fun onAnimationEnd(animation: Animation?) {
|
||||
// binding.flPlayNotify.removeView(svgaImageView)
|
||||
// isPlayAnim = false
|
||||
// }
|
||||
// })
|
||||
// binding.flPlayNotify.startAnimation(animationPlay)
|
||||
// }
|
||||
// }
|
||||
// animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
// binding.flPlayNotify.addView(svgaImageView)
|
||||
// binding.flPlayNotify.startAnimation(animationPlay)
|
||||
//
|
||||
// shareParser().decodeFromAssets("svga/box_notify.svga", object : SVGAParser.ParseCompletion {
|
||||
// override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
// val dynamicEntity = SVGADynamicEntity()
|
||||
// val textPaint = TextPaint()
|
||||
// textPaint.color = Color.WHITE //字體顏色
|
||||
// textPaint.textSize = 24f //字體大小
|
||||
// dynamicEntity.setDynamicText(
|
||||
// StaticLayout(
|
||||
// text.build(),
|
||||
// 0,
|
||||
// text.build().length,
|
||||
// textPaint,
|
||||
// 0,
|
||||
// Layout.Alignment.ALIGN_CENTER,
|
||||
// 1.0f,
|
||||
// 0.0f,
|
||||
// false
|
||||
// ), "bg"
|
||||
// )
|
||||
// val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
// svgaImageView.setImageDrawable(drawable)
|
||||
// svgaImageView.stepToFrame(0, true)
|
||||
// }
|
||||
//
|
||||
// override fun onError() {}
|
||||
// }, null)
|
||||
// }
|
||||
|
||||
/**
|
||||
* 幸運池飄屏
|
||||
|
@@ -0,0 +1,177 @@
|
||||
package com.chwl.app.avroom.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.chwl.app.common.widget.OriginalDrawStatusClickSpan
|
||||
import com.chwl.app.utils.CommonJumpHelper
|
||||
import com.chwl.app.utils.SpannableBuilder
|
||||
import com.chwl.core.home.bean.BannerInfo
|
||||
import com.chwl.core.im.custom.bean.TemplateMessage
|
||||
import com.chwl.core.im.custom.bean.TemplateMessage.TemplateNode
|
||||
import com.chwl.core.im.custom.bean.TemplateMessage.Content
|
||||
import com.example.lib_utils.UiUtils
|
||||
|
||||
|
||||
class TemplateMessageAdapter(val listener: Listener?) {
|
||||
|
||||
/**
|
||||
* 解析为文本(子节点只支持TEXT类型)
|
||||
*/
|
||||
fun parse(context: Context, attachment: TemplateMessage?): SpannableStringBuilder? {
|
||||
val builder = SpannableBuilder()
|
||||
if (attachment == null) {
|
||||
return null
|
||||
}
|
||||
val nodeList = attachment.getNodeList()
|
||||
nodeList.forEach {
|
||||
if (it is TemplateNode.NormalNode) {
|
||||
val textColor = parseColor(it.textColor)
|
||||
if (textColor != null) {
|
||||
builder.append(it.text, ForegroundColorSpan(textColor))
|
||||
} else {
|
||||
builder.append(it.text)
|
||||
}
|
||||
} else if (it is TemplateNode.SpecialNode) {
|
||||
when (it.content.type) {
|
||||
Content.TEXT -> {
|
||||
val text = it.content.text?.getFirstText()
|
||||
if (!text.isNullOrEmpty()) {
|
||||
val textColor = parseColor(it.content.textColor)
|
||||
val clickSpan = createClickSpan(context, it.content, listener)
|
||||
val list = ArrayList<Any>()
|
||||
if (textColor != null) {
|
||||
list.add(ForegroundColorSpan(textColor))
|
||||
}
|
||||
if (clickSpan != null) {
|
||||
list.add(clickSpan)
|
||||
}
|
||||
builder.append(text, *list.toArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
fun convert(textView: TextView, attachment: TemplateMessage?) {
|
||||
if (attachment == null) {
|
||||
textView.text = ""
|
||||
return
|
||||
}
|
||||
val nodeList = attachment.getNodeList()
|
||||
val textBuilder = MessageView.SpannableBuilder(textView)
|
||||
nodeList.forEach {
|
||||
if (it is TemplateNode.NormalNode) {
|
||||
val textColor = parseColor(it.textColor)
|
||||
if (textColor != null) {
|
||||
textBuilder.append(it.text, ForegroundColorSpan(textColor))
|
||||
} else {
|
||||
textBuilder.append(it.text)
|
||||
}
|
||||
} else if (it is TemplateNode.SpecialNode) {
|
||||
when (it.content.type) {
|
||||
Content.TEXT -> {
|
||||
val text = it.content.text?.getFirstText()
|
||||
if (!text.isNullOrEmpty()) {
|
||||
val textColor = parseColor(it.content.textColor)
|
||||
val clickSpan = createClickSpan(textView.context, it.content, listener)
|
||||
val list = ArrayList<Any>()
|
||||
if (textColor != null) {
|
||||
list.add(ForegroundColorSpan(textColor))
|
||||
}
|
||||
if (clickSpan != null) {
|
||||
list.add(clickSpan)
|
||||
}
|
||||
textBuilder.append(text, *list.toArray())
|
||||
}
|
||||
}
|
||||
|
||||
TemplateMessage.Content.IMAGE -> {
|
||||
val image = it.content.image
|
||||
val width = it.content.width ?: 0
|
||||
val height = it.content.height ?: 0
|
||||
val clickSpan = createClickSpan(textView.context, it.content, listener)
|
||||
if (height > 0 && width == 0) {
|
||||
if (clickSpan != null) {
|
||||
textBuilder.append(
|
||||
image,
|
||||
UiUtils.dip2px(height.toFloat()),
|
||||
clickSpan
|
||||
)
|
||||
} else {
|
||||
textBuilder.append(image, UiUtils.dip2px(height.toFloat()))
|
||||
}
|
||||
} else if (height > 0 && width > 0) {
|
||||
if (clickSpan != null) {
|
||||
textBuilder.append(
|
||||
image,
|
||||
UiUtils.dip2px(width.toFloat()),
|
||||
UiUtils.dip2px(height.toFloat()), clickSpan
|
||||
)
|
||||
} else {
|
||||
textBuilder.append(
|
||||
image,
|
||||
UiUtils.dip2px(width.toFloat()),
|
||||
UiUtils.dip2px(height.toFloat())
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if (clickSpan != null) {
|
||||
textBuilder.appendImg(image, clickSpan)
|
||||
} else {
|
||||
textBuilder.appendImg(image)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
textView.text = textBuilder.build()
|
||||
textView.setOnClickListener(null)
|
||||
textView.movementMethod = LinkMovementMethod()
|
||||
}
|
||||
|
||||
private fun createClickSpan(
|
||||
context: Context,
|
||||
content: Content,
|
||||
listener: Listener?
|
||||
): OriginalDrawStatusClickSpan? {
|
||||
val skipType = content.getSkipType()
|
||||
val skipUri = content.getSkipUri()
|
||||
if (skipType > 0 && !skipUri.isNullOrEmpty()) {
|
||||
return object : OriginalDrawStatusClickSpan() {
|
||||
override fun onClick(widget: View) {
|
||||
if (skipType == BannerInfo.SKIP_TYPE_ROOM_USER_CARD) {
|
||||
listener?.onShowUserCard(skipUri)
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun parseColor(color: String?): Int? {
|
||||
if (color == null) {
|
||||
return null
|
||||
}
|
||||
try {
|
||||
return Color.parseColor(color)
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun onShowUserCard(uid: String)
|
||||
}
|
||||
}
|
@@ -8,6 +8,7 @@ import android.util.AttributeSet
|
||||
import android.widget.ProgressBar
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.chwl.app.R
|
||||
import com.example.lib_utils.UiUtils
|
||||
|
||||
class VipProgressBar(context: Context, attrs: AttributeSet?) : ProgressBar(context, attrs) {
|
||||
|
||||
@@ -19,6 +20,10 @@ class VipProgressBar(context: Context, attrs: AttributeSet?) : ProgressBar(conte
|
||||
private var mHeight = 0
|
||||
private val leftPadding = ScreenUtil.dip2px(9f)
|
||||
|
||||
private var isRTL = false
|
||||
init {
|
||||
isRTL = UiUtils.isRtl(context)
|
||||
}
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
mWidth = w
|
||||
@@ -28,7 +33,10 @@ class VipProgressBar(context: Context, attrs: AttributeSet?) : ProgressBar(conte
|
||||
@Synchronized
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
super.onDraw(canvas)
|
||||
val radio = progress * 1.0f / max
|
||||
var radio = progress * 1.0f / max
|
||||
if (isRTL) {
|
||||
radio = 1 - radio
|
||||
}
|
||||
canvas.drawBitmap(
|
||||
thumbBitmap,
|
||||
(mWidth - leftPadding * 2) * radio - thumbWidth / 2f + leftPadding,
|
||||
|
@@ -4,16 +4,10 @@ import static com.chwl.core.Constants.DEBUG_MAX_UID;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_HEAD_NOBLE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_OPENNOBLE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_RENEWNOBLE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP_USER_ALL_UPGRADE;
|
||||
@@ -25,6 +19,7 @@ import android.app.Dialog;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
@@ -49,6 +44,8 @@ import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chwl.app.notify.GlobalNotifyManager;
|
||||
import com.chwl.library.language.LanguageHelper;
|
||||
import com.google.gson.Gson;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nimlib.sdk.NIMSDK;
|
||||
@@ -87,11 +84,9 @@ import com.chwl.app.ui.widget.dialog.OpenNobleGlobalNoticeDialog;
|
||||
import com.chwl.app.utils.UserUtils;
|
||||
import com.chwl.core.XConstants;
|
||||
import com.chwl.core.bean.BaseProtocol;
|
||||
import com.chwl.core.gift.bean.LuckyBagNoticeInfo;
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.chwl.core.im.custom.bean.NotifyH5Info;
|
||||
import com.chwl.core.im.custom.bean.PlayEffectInfo;
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeInfo;
|
||||
import com.chwl.core.im.custom.bean.RoomLuckySeaMsgBean;
|
||||
import com.chwl.core.im.custom.bean.TarotMsgBean;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
@@ -176,6 +171,7 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
if (roomEvent == null) return;
|
||||
onReceiveChatRoomEvent(roomEvent);
|
||||
}));
|
||||
GlobalNotifyManager.INSTANCE.bindActivity(this);
|
||||
}
|
||||
|
||||
protected void onReceiveChatRoomEvent(RoomEvent roomEvent) {
|
||||
@@ -515,6 +511,18 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(LanguageHelper.INSTANCE.wrapContext(newBase));
|
||||
LanguageHelper.INSTANCE.wrapContext(newBase.getApplicationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
LanguageHelper.INSTANCE.changeLanguage(this, LanguageHelper.INSTANCE.getCurrentLanguage());
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
protected void onResume() {
|
||||
@@ -858,6 +866,10 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
return rxPermissions.request(mPerms);
|
||||
}
|
||||
|
||||
public RxPermissions getRxPermissions() {
|
||||
return rxPermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收到全局广播信息
|
||||
*
|
||||
@@ -930,62 +942,62 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
|| UserUtils.getUserInfo() == null)
|
||||
return;
|
||||
if (giftList == null) {
|
||||
giftList = new LinkedList<>();
|
||||
}
|
||||
int second2 = baseProtocol.getSecond();
|
||||
AllServiceGiftProtocol.DataBean data = JSON.parseObject(String.valueOf(baseProtocol.getData()), AllServiceGiftProtocol.DataBean.class);
|
||||
if (data == null || data.getGiftUrl() == null) return;
|
||||
giftList.add(data);
|
||||
if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
giftDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showGiftDialog();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_BOX://寻爱之旅
|
||||
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
|| UserUtils.getUserInfo() == null)
|
||||
return;
|
||||
if (playEffectList == null) {
|
||||
playEffectList = new LinkedList<>();
|
||||
}
|
||||
RoomBoxPrizeInfo roomBoxPrizeInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
|
||||
if (roomBoxPrizeInfo == null) return;
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
|
||||
playEffectInfo.setRoomBoxPrizeInfo(roomBoxPrizeInfo);
|
||||
playEffectList.add(playEffectInfo);
|
||||
if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
playEffectDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showPlayEffectDialog();
|
||||
}
|
||||
}
|
||||
break;
|
||||
// case CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
// if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
// if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
//// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
// || UserUtils.getUserInfo() == null)
|
||||
// return;
|
||||
// if (giftList == null) {
|
||||
// giftList = new LinkedList<>();
|
||||
// }
|
||||
// int second2 = baseProtocol.getSecond();
|
||||
// AllServiceGiftProtocol.DataBean data = JSON.parseObject(String.valueOf(baseProtocol.getData()), AllServiceGiftProtocol.DataBean.class);
|
||||
// if (data == null || data.getGiftUrl() == null) return;
|
||||
// giftList.add(data);
|
||||
// if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
// if (giftDialog != null && giftDialog.isShowing()) {
|
||||
// // 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
// AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
// if (dataBean != null) {
|
||||
// return;
|
||||
// } else {
|
||||
// giftDialog.dismiss();
|
||||
// }
|
||||
// } else {
|
||||
// showGiftDialog();
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case CUSTOM_MSG_BOX://寻爱之旅
|
||||
// if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
// if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
//// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
// || UserUtils.getUserInfo() == null)
|
||||
// return;
|
||||
// if (playEffectList == null) {
|
||||
// playEffectList = new LinkedList<>();
|
||||
// }
|
||||
// RoomBoxPrizeInfo roomBoxPrizeInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
|
||||
// if (roomBoxPrizeInfo == null) return;
|
||||
// if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
// PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
// playEffectInfo.setSecond(CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
|
||||
// playEffectInfo.setRoomBoxPrizeInfo(roomBoxPrizeInfo);
|
||||
// playEffectList.add(playEffectInfo);
|
||||
// if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
// // 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
// PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
// if (dataBean != null) {
|
||||
// return;
|
||||
// } else {
|
||||
// playEffectDialog.dismiss();
|
||||
// }
|
||||
// } else {
|
||||
// showPlayEffectDialog();
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
case CustomAttachment.CUSTOM_MESS_TAROT:
|
||||
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
@@ -1074,35 +1086,35 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_LUCKY_GIFT://福袋
|
||||
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
|| UserUtils.getUserInfo() == null)
|
||||
return;
|
||||
if (playEffectList == null) {
|
||||
playEffectList = new LinkedList<>();
|
||||
}
|
||||
LuckyBagNoticeInfo luckyBagNoticeInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), LuckyBagNoticeInfo.class);
|
||||
if (luckyBagNoticeInfo == null) return;
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL);
|
||||
playEffectInfo.setLuckyBagNoticeInfo(luckyBagNoticeInfo);
|
||||
playEffectList.add(playEffectInfo);
|
||||
if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
playEffectDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showPlayEffectDialog();
|
||||
}
|
||||
}
|
||||
break;
|
||||
// case CUSTOM_MSG_LUCKY_GIFT://福袋
|
||||
// if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
// if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
//// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
// || UserUtils.getUserInfo() == null)
|
||||
// return;
|
||||
// if (playEffectList == null) {
|
||||
// playEffectList = new LinkedList<>();
|
||||
// }
|
||||
// LuckyBagNoticeInfo luckyBagNoticeInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), LuckyBagNoticeInfo.class);
|
||||
// if (luckyBagNoticeInfo == null) return;
|
||||
// if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
// PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
// playEffectInfo.setSecond(CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL);
|
||||
// playEffectInfo.setLuckyBagNoticeInfo(luckyBagNoticeInfo);
|
||||
// playEffectList.add(playEffectInfo);
|
||||
// if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
// // 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
// PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
// if (dataBean != null) {
|
||||
// return;
|
||||
// } else {
|
||||
// playEffectDialog.dismiss();
|
||||
// }
|
||||
// } else {
|
||||
// showPlayEffectDialog();
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
case CUSTOM_MSG_FAIRY://夺宝精灵
|
||||
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
@@ -1360,14 +1372,14 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = JSON.parseObject(contentStr);
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
baseMvpActivity.onReceivedNimBroadcastMessage(body);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
jsonObject = null;
|
||||
}
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
baseMvpActivity.onReceivedNimBroadcastMessage(body);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.LayoutDirection;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -20,9 +21,12 @@ import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.text.TextUtilsCompat;
|
||||
|
||||
import com.chwl.app.R;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 类描述:
|
||||
@@ -446,18 +450,33 @@ public class TitleBar extends ViewGroup implements View.OnClickListener {
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), height);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
mLeftLayout.layout(0, mStatusBarHeight, mLeftLayout.getMeasuredWidth(), mLeftLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
mRightLayout.layout(mScreenWidth - mRightLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth, mRightLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
if (mLeftLayout.getMeasuredWidth() > mRightLayout.getMeasuredWidth()) {
|
||||
mCenterLayout.layout(mLeftLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mLeftLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
if(TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == LayoutDirection.RTL) {
|
||||
mRightLayout.layout(0, mStatusBarHeight, mRightLayout.getMeasuredWidth(), mRightLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
mLeftLayout.layout(mScreenWidth - mLeftLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth, mLeftLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
if (mRightLayout.getMeasuredWidth() > mLeftLayout.getMeasuredWidth()) {
|
||||
mCenterLayout.layout(mRightLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mRightLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
} else {
|
||||
mCenterLayout.layout(mLeftLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mLeftLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
} else {
|
||||
mCenterLayout.layout(mRightLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mRightLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
mLeftLayout.layout(0, mStatusBarHeight, mLeftLayout.getMeasuredWidth(), mLeftLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
mRightLayout.layout(mScreenWidth - mRightLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth, mRightLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
if (mLeftLayout.getMeasuredWidth() > mRightLayout.getMeasuredWidth()) {
|
||||
mCenterLayout.layout(mLeftLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mLeftLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
} else {
|
||||
mCenterLayout.layout(mRightLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mRightLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
|
||||
mDividerView.layout(0, getMeasuredHeight() - mDividerView.getMeasuredHeight(), getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
|
||||
|
@@ -10,10 +10,8 @@ import com.chwl.app.base.TitleBar;
|
||||
import com.chwl.app.bills.adapter.GiftExpendAdapter;
|
||||
import com.chwl.app.databinding.ActivityBillsGiftBinding;
|
||||
import com.chwl.app.ui.pay.ChargeActivity;
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity;
|
||||
import com.chwl.app.ui.widget.RecyclerViewNoBugLinearLayoutManager;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.core.bills.BillModel;
|
||||
import com.chwl.core.bills.bean.BillItemEntity;
|
||||
import com.chwl.core.bills.bean.ExpendInfo;
|
||||
@@ -21,8 +19,6 @@ import com.chwl.core.bills.bean.ExpendListInfo;
|
||||
import com.chwl.core.pay.PayModel;
|
||||
import com.chwl.core.pay.bean.WalletInfo;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.common.util.DeviceUtil;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.chwl.app.bills.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -13,10 +12,8 @@ import com.chwl.app.base.TitleBar;
|
||||
import com.chwl.app.bills.adapter.GiftIncomeAdapter;
|
||||
import com.chwl.app.databinding.ActivityBillsGiftBinding;
|
||||
import com.chwl.app.ui.pay.ChargeActivity;
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity;
|
||||
import com.chwl.app.ui.widget.RecyclerViewNoBugLinearLayoutManager;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.core.bills.BillModel;
|
||||
import com.chwl.core.bills.bean.BillItemEntity;
|
||||
import com.chwl.core.bills.bean.IncomeInfo;
|
||||
@@ -24,8 +21,6 @@ import com.chwl.core.bills.bean.IncomeListInfo;
|
||||
import com.chwl.core.pay.PayModel;
|
||||
import com.chwl.core.pay.bean.WalletInfo;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.common.util.DeviceUtil;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
|
@@ -12,18 +12,14 @@ import com.chwl.app.base.TitleBar;
|
||||
import com.chwl.app.bills.adapter.ChargeBillsAdapter;
|
||||
import com.chwl.app.databinding.ActivityBillsBinding;
|
||||
import com.chwl.app.ui.pay.ChargeActivity;
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity;
|
||||
import com.chwl.app.ui.widget.RecyclerViewNoBugLinearLayoutManager;
|
||||
import com.chwl.core.XConstants;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.core.bills.BillModel;
|
||||
import com.chwl.core.bills.bean.BillItemEntity;
|
||||
import com.chwl.core.bills.bean.ExpendInfo;
|
||||
import com.chwl.core.bills.bean.ExpendListInfo;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.common.util.DeviceUtil;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
|
@@ -26,7 +26,7 @@ public class ChargeBillsAdapter extends BillBaseAdapter {
|
||||
if (expendInfo == null) {
|
||||
return;
|
||||
}
|
||||
baseViewHolder.setText(R.id.tv_gold, ResUtil.getString(R.string.bills_adapter_chargebillsadapter_01) + expendInfo.getGoldNum() + ResUtil.getString(R.string.bills_adapter_chargebillsadapter_02))
|
||||
baseViewHolder.setText(R.id.tv_gold, ResUtil.getString(R.string.bills_adapter_chargebillsadapter_01) + expendInfo.getGoldNum() + ResUtil.getString(R.string.diamond))
|
||||
.setText(R.id.tv_money, expendInfo.getShowStr())
|
||||
.setText(R.id.tv_charge_time, TimeUtils.getYearMonthDayHourMinuteSecond(expendInfo.getRecordTime()));
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ public class WithdrawBillsAdapter extends BillBaseAdapter {
|
||||
IncomeInfo incomeInfo = billItemEntity.mWithdrawInfo;
|
||||
if (incomeInfo == null) return;
|
||||
baseViewHolder.setText(R.id.tv_date, TimeUtils.getYearMonthDayHourMinuteSecond(incomeInfo.getRecordTime()))
|
||||
.setText(R.id.tv_diamondNum, ResUtil.getString(R.string.bills_adapter_withdrawbillsadapter_01) + incomeInfo.getDiamondNum() + ResUtil.getString(R.string.bills_adapter_withdrawbillsadapter_02))
|
||||
.setText(R.id.tv_diamondNum, ResUtil.getString(R.string.bills_adapter_withdrawbillsadapter_01) + incomeInfo.getDiamondNum() + ResUtil.getString(R.string.diamond))
|
||||
.setText(R.id.tv_money, "+" + incomeInfo.getMoney() + ResUtil.getString(R.string.bills_adapter_withdrawbillsadapter_03));
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ public class WithdrawRedBillsAdapter extends BillBaseAdapter {
|
||||
public void convertNormal(BaseViewHolder baseViewHolder, BillItemEntity billItemEntity) {
|
||||
RedBagInfo redBagInfo = billItemEntity.mRedBagInfo;
|
||||
if (redBagInfo == null) return;
|
||||
baseViewHolder.setText(R.id.tv_diamondNum, ResUtil.getString(R.string.bills_adapter_withdrawredbillsadapter_01) + redBagInfo.getPacketNum() + ResUtil.getString(R.string.bills_adapter_withdrawredbillsadapter_02))
|
||||
baseViewHolder.setText(R.id.tv_diamondNum, ResUtil.getString(R.string.bills_adapter_withdrawredbillsadapter_01) + redBagInfo.getPacketNum() + ResUtil.getString(R.string.diamond))
|
||||
.setText(R.id.tv_date, TimeUtils.getYearMonthDayHourMinuteSecond(redBagInfo.getCreateTime()))
|
||||
// .setText(R.id.tv_money, "+" + redBagInfo.getMoney() + ResUtil.getString(R.string.bills_adapter_withdrawredbillsadapter_03))
|
||||
;
|
||||
|
@@ -21,12 +21,10 @@ import com.chwl.app.R;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.app.view.GenderAgeTextView;
|
||||
import com.chwl.core.utils.StarUtils;
|
||||
import com.chwl.library.utils.TimeUtils;
|
||||
import com.chwl.library.utils.config.BasicConfig;
|
||||
import com.chwl.library.widget.IOSSwitchView;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by huangmeng1 on 2018/1/4.
|
||||
|
@@ -207,7 +207,7 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
|
||||
REQUEST_CODE_OPEN_CAMERA_PROVIDER -> {
|
||||
if (mOnResultCallBack == null || data == null) return
|
||||
PhotoProvider.getResultPathListAsync(data) { paths ->
|
||||
val list = paths?.toMutableList() ?: ArrayList()
|
||||
val list = paths?.mapNotNull { it.path }?.toMutableList() ?: ArrayList()
|
||||
val path = list[0]
|
||||
if (!TextUtils.isEmpty(path)) {
|
||||
mJob?.cancel()
|
||||
@@ -233,7 +233,7 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
|
||||
REQUEST_CODE_OPEN_PHOTO_PROVIDER -> {
|
||||
if (mOnResultCallBack == null || data == null) return
|
||||
PhotoProvider.getResultPathListAsync(data) { list ->
|
||||
val paths = list?.toMutableList() ?: ArrayList()
|
||||
val paths = list?.mapNotNull { it.path }?.toMutableList() ?: ArrayList()
|
||||
if (paths.isEmpty()) {
|
||||
mOnResultCallBack?.choicePhotoCallBack(paths)
|
||||
} else {
|
||||
|
@@ -130,7 +130,7 @@ object PhotoProvider {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getResultPathListAsync(data: Intent?, resultListener: ((List<String>?) -> Unit)) {
|
||||
fun getResultPathListAsync(data: Intent?, resultListener: ((List<Photo>?) -> Unit)) {
|
||||
cancelJop()
|
||||
mPhotoJob = MainScope().launch {
|
||||
val list: List<Photo>? = data?.getParcelableArrayListExtra(EasyPhotos.RESULT_PHOTOS)
|
||||
@@ -150,22 +150,21 @@ object PhotoProvider {
|
||||
* 1. 项目使用到BitmapFactory.decodeFile(imgPath, options)之类的方法,该方法在android Q直接使用外部path测试中发现,获取图片信息失败
|
||||
*
|
||||
*/
|
||||
private fun copyToInternalCache(photos: List<Photo>?): List<String>? {
|
||||
private fun copyToInternalCache(photos: List<Photo>?): List<Photo>? {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
val foldPath = getInternalPath() + File.separator
|
||||
val newPaths = ArrayList<String>()
|
||||
photos?.forEach {
|
||||
if (it.uri != null && !it.name.isNullOrEmpty()) {
|
||||
val path = "$foldPath${it.name}"
|
||||
if (FileHelper.copyFileFromUri(it.uri, path, true)) {
|
||||
newPaths.add(path)
|
||||
it.path = path
|
||||
LibLogger.debug(TAG, "path: ${it.path} , displayName: ${it.name} , newPath: $path ")
|
||||
}
|
||||
}
|
||||
}
|
||||
newPaths
|
||||
photos
|
||||
} else {
|
||||
photos?.takeIf { it.isNotEmpty() }?.map { it.path }
|
||||
photos
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
@@ -62,7 +64,7 @@ public class MyDecorationActivity extends BaseBindingActivity<ActivityMyDecorati
|
||||
* 我的装饰Banner
|
||||
*/
|
||||
private static final String BANNER_TYPE = "3";
|
||||
private ViewPager viewPager;
|
||||
private ViewPager2 viewPager;
|
||||
private int mPosition;
|
||||
private boolean carGarageNeedUpdate = true;
|
||||
private MyHeadWearFragment myHeadWearFragment;
|
||||
@@ -98,27 +100,25 @@ public class MyDecorationActivity extends BaseBindingActivity<ActivityMyDecorati
|
||||
tabInfoList.add(new TabInfo(4, ResUtil.getString(R.string.decoration_view_mydecorationactivity_05)));
|
||||
tabInfoList.add(new TabInfo(5, ResUtil.getString(R.string.decoration_view_mydecorationactivity_06)));
|
||||
CommonNavigator commonNavigator = new CommonNavigator(this);
|
||||
commonNavigator.setAdjustMode(true);
|
||||
MyDecorationMagicIndicator indicator = new MyDecorationMagicIndicator(this, tabInfoList);
|
||||
indicator.setOnItemSelectListener(this);
|
||||
commonNavigator.setAdapter(indicator);
|
||||
mMagicIndicator.setNavigator(commonNavigator);
|
||||
ViewPagerHelper.bind(mMagicIndicator, viewPager);
|
||||
|
||||
myHeadWearFragment = new MyHeadWearFragment();
|
||||
mMyCarFragment = MyCarFragment.instance(this);
|
||||
mMyNamePlateFragment = new MyNamePlateFragment();
|
||||
mMyUserCardWearFragment = new MyUserCardWearFragment();
|
||||
mMyChatBubbleFragment = new MyChatBubbleFragment();
|
||||
viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
|
||||
viewPager.setAdapter(new FragmentStateAdapter(getSupportFragmentManager(), getLifecycle()) {
|
||||
@Override
|
||||
public int getCount() {
|
||||
public int getItemCount() {
|
||||
return tabInfoList.size();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
public Fragment createFragment(int position) {
|
||||
if (position == 0) {
|
||||
return myHeadWearFragment;
|
||||
} else if (position == 1) {
|
||||
@@ -132,12 +132,31 @@ public class MyDecorationActivity extends BaseBindingActivity<ActivityMyDecorati
|
||||
return mMyChatBubbleFragment;
|
||||
}
|
||||
});
|
||||
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
|
||||
viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
super.onPageSelected(position);
|
||||
if (position == 1) {
|
||||
mMagicIndicator.findViewById(R.id.car_badge_garage).setVisibility(View.GONE);
|
||||
if (mMagicIndicator != null) {
|
||||
mMagicIndicator.onPageSelected(position);
|
||||
// if (position == 1) {
|
||||
// mMagicIndicator.findViewById(R.id.car_badge_garage).setVisibility(View.GONE);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||
if (mMagicIndicator != null) {
|
||||
mMagicIndicator.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
super.onPageScrollStateChanged(state);
|
||||
if (mMagicIndicator != null) {
|
||||
mMagicIndicator.onPageScrollStateChanged(state);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -5,6 +5,7 @@ import android.content.Context;
|
||||
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.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;
|
||||
@@ -37,15 +38,15 @@ public class MyDecorationMagicIndicator extends CommonNavigatorAdapter {
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int i) {
|
||||
BadgeScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new BadgeScaleTransitionPagerTitleView(context);
|
||||
ScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new ScaleTransitionPagerTitleView(context);
|
||||
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(mContext, R.color.text_secondary_4f516a));
|
||||
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(mContext, R.color.text_title_color));
|
||||
scaleTransitionPagerTitleView.setMinScale(0.9f);
|
||||
scaleTransitionPagerTitleView.setTextSize(15);
|
||||
scaleTransitionPagerTitleView.setText(mTitleList.get(i).getName());
|
||||
if (mTitleList.get(i).getName().equals(ResUtil.getString(R.string.view_widgets_mydecorationmagicindicator_01))) {
|
||||
scaleTransitionPagerTitleView.findViewById(R.id.car_badge).setId(R.id.car_badge_garage);
|
||||
}
|
||||
// if (mTitleList.get(i).getName().equals(ResUtil.getString(R.string.view_widgets_mydecorationmagicindicator_01))) {
|
||||
// scaleTransitionPagerTitleView.findViewById(R.id.car_badge).setId(R.id.car_badge_garage);
|
||||
// }
|
||||
scaleTransitionPagerTitleView.setOnClickListener(view -> {
|
||||
if (mOnItemSelectListener != null) {
|
||||
mOnItemSelectListener.onItemSelect(i);
|
||||
|
@@ -132,9 +132,9 @@ class ConvertDiamondActivity : BaseViewBindingActivity<ActivityConvertDiamondBin
|
||||
|
||||
binding.tvConvert.setOnClickListener { view ->
|
||||
if (binding.edDiamond.text.toString().toLong() < it.minDiamonds) {
|
||||
toast("至少需要兌換${it.minDiamonds}鉆石")
|
||||
toast(getString(R.string.convert_diamonds_01).format(it.minDiamonds))
|
||||
} else if (binding.edDiamond.text.toString().toLong() > it.maxDiamonds) {
|
||||
toast("兌換鉆石數不能超過${it.maxDiamonds}鉆")
|
||||
toast(getString(R.string.convert_diamonds_02).format(it.minDiamonds))
|
||||
} else {
|
||||
//去掉小数凑整:不管小数是多少,都进一
|
||||
val gold = DoubleUtils.convertDoubleToString(
|
||||
|
@@ -54,10 +54,10 @@ class EarnRecordActivity : BaseViewBindingActivity<ActivityEarnRecordBinding>(),
|
||||
binding.tvGoldNum.text = String.format(it.golds.toString())
|
||||
if (it.isClanElder) {
|
||||
binding.csGoldBg.background =
|
||||
ContextCompat.getDrawable(this, R.drawable.bg_gold_detail)
|
||||
ContextCompat.getDrawable(this, R.drawable.bg_earn_diamond)
|
||||
} else {
|
||||
binding.csGoldBg.background =
|
||||
ContextCompat.getDrawable(this, R.drawable.bg_earn_gold)
|
||||
ContextCompat.getDrawable(this, R.drawable.bg_earn_diamond)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,8 +6,10 @@ import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter
|
||||
import com.chwl.app.module_hall.hall.fragment.AssociationFragment
|
||||
import com.chwl.app.module_hall.hall.fragment.AssociationRoomFragment
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
@@ -41,10 +43,9 @@ class AssociationActivity : BaseViewBindingActivity<ActivityAssociationBinding>(
|
||||
* 公會
|
||||
*/
|
||||
private fun initDetail() {
|
||||
val viewPager: ViewPager = binding.viewPagerDetail
|
||||
val viewPager = binding.viewPagerDetail
|
||||
val magicIndicator: MagicIndicator = binding.magicIndicator
|
||||
val fragmentList: MutableList<Fragment> = ArrayList()
|
||||
val pagerAdapter = CommonPagerAdapter(supportFragmentManager, fragmentList)
|
||||
val tagList: MutableList<String> = ArrayList()
|
||||
tagList.add(getString(R.string.me_association))
|
||||
tagList.add(getString(R.string.me_room))
|
||||
@@ -59,21 +60,24 @@ class AssociationActivity : BaseViewBindingActivity<ActivityAssociationBinding>(
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
magicIndicator.navigator = commonNavigator
|
||||
commonNavigator.titleContainer.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE
|
||||
viewPager.adapter = pagerAdapter
|
||||
ViewPagerHelper.bind(magicIndicator, viewPager)
|
||||
viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||
viewPager.adapter = CommonVPAdapter(supportFragmentManager, lifecycle, fragmentList)
|
||||
viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
||||
override fun onPageScrolled(
|
||||
position: Int,
|
||||
positionOffset: Float,
|
||||
positionOffsetPixels: Int
|
||||
) {
|
||||
magicIndicator.onPageScrolled(position, positionOffset, positionOffsetPixels)
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
magicIndicator.onPageSelected(position)
|
||||
viewPager.requestLayout()
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {}
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
magicIndicator.onPageScrollStateChanged(state)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
@@ -1,10 +1,13 @@
|
||||
package com.chwl.app.home.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isInvisible
|
||||
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.ImageLoadUtils
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.home.bean.HomeRoomInfo
|
||||
@@ -20,6 +23,7 @@ class HomeHotAdapter :
|
||||
getView<ImageView>(R.id.iv_room_image).load(item.avatar)
|
||||
setText(R.id.tv_online_number, item.onlineNum.toString())
|
||||
setText(R.id.tv_room_title, item.title)
|
||||
setText(R.id.tv_desc, item.introduction)
|
||||
}
|
||||
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
@@ -31,8 +35,26 @@ class HomeHotAdapter :
|
||||
)
|
||||
for (i in avatars.indices) {
|
||||
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
|
||||
avatars[i].isGone = avatarUrl.isNullOrBlank()
|
||||
avatars[i].isInvisible = avatarUrl.isNullOrBlank()
|
||||
avatars[i].load(avatarUrl)
|
||||
}
|
||||
val topView = helper.getView<ImageView>(R.id.iv_top)
|
||||
if (item.isHourTop1 == 1) {
|
||||
topView.setImageResource(R.drawable.home_room_bg_hour_top)
|
||||
topView.visibility = View.VISIBLE
|
||||
} else if (item.isWeekTop1 == 1) {
|
||||
topView.setImageResource(R.drawable.home_room_bg_week_top)
|
||||
topView.visibility = View.VISIBLE
|
||||
} else {
|
||||
topView.visibility = View.INVISIBLE
|
||||
}
|
||||
val tagPict = item.tagPict
|
||||
val tagView = helper.getView<ImageView>(R.id.iv_tag)
|
||||
if (tagPict.isNullOrEmpty()) {
|
||||
tagView.isVisible = false
|
||||
} else {
|
||||
ImageLoadUtils.loadImage(tagView, tagPict)
|
||||
tagView.isVisible = true
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,7 +22,7 @@ class RoomActAdapter(private val mContext: Context, private val data: List<Banne
|
||||
val bannerInfo = data[position]
|
||||
val actId = bannerInfo.bannerId.toString()
|
||||
ivCover.scaleType = ImageView.ScaleType.CENTER_CROP
|
||||
ImageLoadUtils.loadImage(
|
||||
ImageLoadUtils.loadImage(
|
||||
mContext,
|
||||
bannerInfo.bannerPic,
|
||||
ivCover,
|
||||
@@ -30,9 +30,9 @@ class RoomActAdapter(private val mContext: Context, private val data: List<Banne
|
||||
)
|
||||
ivCover.setOnClickListener { v: View? ->
|
||||
AvRoomModel.get().activityClickLog("2", actId).subscribe()
|
||||
if (bannerInfo.skipType == 3) {
|
||||
if (bannerInfo.getSkipType() == 3) {
|
||||
val list = data.filterList {
|
||||
skipType == 3
|
||||
getSkipType() == 3
|
||||
}
|
||||
val newPosition = list.indexOfFirst {
|
||||
it == bannerInfo
|
||||
|
@@ -28,7 +28,6 @@ import com.chwl.core.Constants
|
||||
import com.chwl.core.manager.AudioEngineManager
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.user.bean.UserInfo
|
||||
import com.chwl.core.utils.StarUtils
|
||||
import com.chwl.core.utils.extension.ifNullOrEmpty
|
||||
import com.chwl.library.common.widget.LinesFlexBoxLayoutManager
|
||||
import com.chwl.library.utils.ListUtils
|
||||
@@ -37,7 +36,6 @@ import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class RoomNewFriendsAdapter :
|
||||
@@ -57,8 +55,8 @@ class RoomNewFriendsAdapter :
|
||||
tvGenderAge.setGender(item.gender)
|
||||
|
||||
//设置星座
|
||||
val star = StarUtils.getConstellation(Date(item.birth))
|
||||
helper.setImageResource(R.id.iv_constellation, star)
|
||||
// val star = StarUtils.getConstellation(Date(item.birth))
|
||||
// helper.setImageResource(R.id.iv_constellation, star)
|
||||
|
||||
val tvTalk = helper.getView<TextView>(R.id.tv_talk)
|
||||
|
||||
|
@@ -4,9 +4,11 @@ import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.netease.nimlib.sdk.NIMClient
|
||||
import com.netease.nimlib.sdk.msg.MsgService
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter
|
||||
import com.chwl.app.base.BaseViewBindingFragment
|
||||
import com.chwl.app.common.widget.dialog.DialogManager.AbsOkDialogListener
|
||||
import com.chwl.app.databinding.FragmentContactListBinding
|
||||
@@ -38,8 +40,6 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
|
||||
}
|
||||
}
|
||||
|
||||
private var pagerAdapter: UserInfoPagerAdapter? = null
|
||||
|
||||
override fun init() {
|
||||
initViewPager()
|
||||
}
|
||||
@@ -50,7 +50,6 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
|
||||
fragmentList.add(FriendListFragment.newInstance(false, 0))
|
||||
fragmentList.add(AttentionFragment.newInstance(Constants.FAN_NO_MAIN_PAGE_TYPE))
|
||||
fragmentList.add(FansListFragment.newInstance(Constants.FAN_NO_MAIN_PAGE_TYPE))
|
||||
pagerAdapter = UserInfoPagerAdapter(childFragmentManager, fragmentList)
|
||||
val tagList: MutableList<String> = ArrayList(4)
|
||||
tagList.add(getString(R.string.message))
|
||||
tagList.add(getString(R.string.layout_fragment_contact_list_02))
|
||||
@@ -66,21 +65,31 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
|
||||
binding.magicIndicator.navigator = commonNavigator
|
||||
commonNavigator.titleContainer.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE
|
||||
binding.viewPager.offscreenPageLimit = 4
|
||||
binding.viewPager.adapter = pagerAdapter
|
||||
ViewPagerHelper.bind(binding.magicIndicator, binding.viewPager)
|
||||
binding.viewPager.addOnPageChangeListener(object : OnPageChangeListener {
|
||||
binding.viewPager.adapter = CommonVPAdapter(childFragmentManager, lifecycle, fragmentList)
|
||||
binding.viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
super.onPageScrollStateChanged(state)
|
||||
binding.magicIndicator.onPageScrollStateChanged(state)
|
||||
}
|
||||
|
||||
override fun onPageScrolled(
|
||||
position: Int,
|
||||
positionOffset: Float,
|
||||
positionOffsetPixels: Int
|
||||
) {
|
||||
super.onPageScrolled(position, positionOffset, positionOffsetPixels)
|
||||
binding.magicIndicator.onPageScrolled(
|
||||
position,
|
||||
positionOffset,
|
||||
positionOffsetPixels
|
||||
)
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
super.onPageSelected(position)
|
||||
binding.magicIndicator.onPageSelected(position)
|
||||
binding.viewPager.requestLayout()
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {}
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -1,29 +1,73 @@
|
||||
package com.chwl.app.home.fragment
|
||||
|
||||
import android.view.View
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.application.IReportConstants
|
||||
import com.chwl.app.application.ReportManager
|
||||
import com.chwl.app.base.BaseViewBindingFragment
|
||||
import com.chwl.app.databinding.FragmentHomeBinding
|
||||
import com.chwl.app.home.HomeViewModel
|
||||
import com.chwl.app.home.adapter.HomeBannerAdapter
|
||||
import com.chwl.app.ui.search.SearchActivity
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.chwl.app.utils.CommonJumpHelper
|
||||
import com.chwl.core.DemoCache
|
||||
import com.chwl.core.UriProvider
|
||||
import com.chwl.core.home.bean.BannerInfo
|
||||
import com.chwl.core.home.event.RefreshHomeDataEvent
|
||||
import com.chwl.library.utils.ListUtils
|
||||
import com.zhpan.bannerview.BannerViewPager
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
/**
|
||||
首页
|
||||
*/
|
||||
class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClickListener {
|
||||
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
override fun init() {
|
||||
initListener()
|
||||
initBanner()
|
||||
childFragmentManager.beginTransaction()
|
||||
.replace(R.id.frameLayout, RecommendFragment(), "RECOMMEND").commitAllowingStateLoss()
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
binding.ivSearch.setOnClickListener(this)
|
||||
binding.ivRanking.setOnClickListener(this)
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
it.finishRefresh()
|
||||
EventBus.getDefault().post(RefreshHomeDataEvent())
|
||||
homeViewModel.getBannerInfo()
|
||||
}
|
||||
binding.refreshLayout.isEnableLoadmore = false
|
||||
binding.refreshLayout.isEnableOverScrollBounce = false
|
||||
}
|
||||
|
||||
private fun initBanner() {
|
||||
val bannerView: BannerViewPager<BannerInfo?> =
|
||||
binding.bannerView as BannerViewPager<BannerInfo?>
|
||||
homeViewModel.bannerLiveData.observe(this) {
|
||||
it?.let {
|
||||
if (ListUtils.isListEmpty(it)) {
|
||||
bannerView.visibility = View.GONE
|
||||
return@let
|
||||
}
|
||||
bannerView.visibility = View.VISIBLE
|
||||
bannerView.adapter = HomeBannerAdapter()
|
||||
bannerView.post {
|
||||
binding.bannerView.setPageMargin(UIUtil.dip2px(mContext, 8.0))
|
||||
.setScrollDuration(800)
|
||||
.setOnPageClickListener { _: View?, position: Int ->
|
||||
CommonJumpHelper.bannerJump(context, it[position])
|
||||
}
|
||||
.create(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
homeViewModel.getBannerInfo()
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
@@ -42,6 +86,10 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
DemoCache.saveAnchorCardView(1)
|
||||
}
|
||||
}
|
||||
R.id.iv_ranking -> {
|
||||
//首页_排行榜
|
||||
CommonWebViewActivity.start(mContext, UriProvider.getRanking())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -57,10 +57,7 @@ import com.chwl.core.user.UserModel
|
||||
import com.chwl.core.user.bean.UserInfo
|
||||
import com.chwl.core.user.event.LoginUserInfoUpdateEvent
|
||||
import com.chwl.core.utils.CoreLogger
|
||||
import com.chwl.core.utils.StarUtils
|
||||
import com.chwl.core.vip.bean.VipInfo
|
||||
import com.chwl.library.common.util.DeviceUtil
|
||||
import com.chwl.library.utils.FormatUtils
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
@@ -176,7 +173,6 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
}
|
||||
mBinding.userInfo = mUserInfo
|
||||
mBinding.tvUserId.text = String.format(
|
||||
Locale.getDefault(),
|
||||
getString(R.string.text_user_id), it.erbanNo.toString()
|
||||
)
|
||||
mBinding.tvUserId.setOnLongClickListener(OnLongClickListener { _ ->
|
||||
@@ -186,8 +182,6 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
mBinding.ivCopy.setOnClickListener { _ ->
|
||||
copyName(it.erbanNo.toString())
|
||||
}
|
||||
val star = StarUtils.getConstellation(Date(it.birth))
|
||||
mBinding.ivConstellation.setImageResource(star)
|
||||
setUserLevel(it.userLevelVo)
|
||||
setWalletInfo()
|
||||
}
|
||||
@@ -240,21 +234,22 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
}
|
||||
|
||||
private fun updateHallInfo(clanAndHallInfo: ClanAndHallInfo?) {
|
||||
if ((clanAndHallInfo?.clan?.elderUid ?: 0L) > 0 || (clanAndHallInfo?.hall?.ownerUid
|
||||
?: 0L) > 0
|
||||
) {
|
||||
if ((clanAndHallInfo?.clan?.elderUid ?: 0L) > 0) {
|
||||
mBinding.ivGuild.setImageResource(R.drawable.me_bg_my_guild)
|
||||
mBinding.ivGuild.singleClick {
|
||||
if ((clanAndHallInfo?.clan?.elderUid ?: 0L) > 0) {
|
||||
ModuleClanActivity.start(context, clanAndHallInfo?.clan?.elderUid ?: 0L)
|
||||
} else if ((clanAndHallInfo?.hall?.ownerUid ?: 0L) > 0) {
|
||||
ModuleHallActivity.start(
|
||||
context,
|
||||
clanAndHallInfo?.hall?.hallId ?: 0L,
|
||||
clanAndHallInfo?.hall?.ownerUid ?: 0L
|
||||
)
|
||||
}
|
||||
ModuleClanActivity.start(context, clanAndHallInfo?.clan?.elderUid ?: 0L)
|
||||
}
|
||||
} else if ((clanAndHallInfo?.hall?.ownerUid ?: 0L) > 0) {
|
||||
mBinding.ivGuild.setImageResource(R.drawable.me_bg_my_guild)
|
||||
mBinding.ivGuild.singleClick {
|
||||
ModuleHallActivity.start(
|
||||
context,
|
||||
clanAndHallInfo?.hall?.hallId ?: 0L,
|
||||
clanAndHallInfo?.hall?.ownerUid ?: 0L
|
||||
)
|
||||
}
|
||||
} else {
|
||||
mBinding.ivGuild.setImageResource(R.drawable.me_bg_guild)
|
||||
mBinding.ivGuild.singleClick {
|
||||
//公會周榜
|
||||
context?.let { it1 -> AssociationActivity.start(it1) }
|
||||
|
@@ -9,6 +9,7 @@ import androidx.fragment.app.activityViewModels
|
||||
import com.coorchice.library.utils.LogUtils
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter
|
||||
import com.chwl.app.avroom.adapter.RoomVPAdapter
|
||||
import com.chwl.app.base.BaseFragment
|
||||
import com.chwl.app.databinding.FragmentPartyBinding
|
||||
@@ -121,8 +122,8 @@ class PartyFragment : BaseFragment(), PartyMagicIndicatorAdapter.OnItemSelectLis
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
mBinding.magicIndicator.navigator = commonNavigator
|
||||
mBinding.viewPager.offscreenPageLimit = 2
|
||||
mBinding.viewPager.adapter = RoomVPAdapter(
|
||||
childFragmentManager,
|
||||
mBinding.viewPager.adapter = CommonVPAdapter(
|
||||
childFragmentManager, lifecycle,
|
||||
mFragments
|
||||
)
|
||||
ViewPagerHelper.bind(mBinding.magicIndicator, mBinding.viewPager)
|
||||
|
@@ -39,19 +39,9 @@ class RecommendFragment : BaseViewBindingFragment<FragmentRecommendBinding>() {
|
||||
private var isShield = false
|
||||
|
||||
override fun init() {
|
||||
initRefreshView()
|
||||
initHotRoomTab()
|
||||
}
|
||||
|
||||
private fun initRefreshView() {
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
binding.refreshLayout.finishRefresh()
|
||||
EventBus.getDefault().post(RefreshHomeDataEvent())
|
||||
}
|
||||
binding.refreshLayout.isEnableLoadmore = false
|
||||
binding.refreshLayout.isEnableOverScrollBounce = false
|
||||
}
|
||||
|
||||
private fun initHotRoomTab() {
|
||||
roomHotAdapter = HomeHotAdapter()
|
||||
roomHotAdapter.onItemClickListener =
|
||||
|
@@ -54,7 +54,7 @@ public class MonsterHuntingRewardsAdapter extends BaseListRecyclerViewAdapter<Mo
|
||||
R.drawable.default_cover, UIUtil.dip2px(context, 10));
|
||||
switch (Integer.parseInt(reward.getProdType())) {
|
||||
case MonsterHuntingReward.REWARD_GOLD:
|
||||
holder.rewardNameView.setText(context.getString(R.string.currency_unit));
|
||||
holder.rewardNameView.setText(context.getString(R.string.diamonds));
|
||||
holder.rewardValueView.setVisibility(View.VISIBLE);
|
||||
holder.rewardValueView.setText(reward.getProdValue());
|
||||
break;
|
||||
|
237
app/src/main/java/com/chwl/app/notify/GlobalNotifyManager.kt
Normal file
237
app/src/main/java/com/chwl/app/notify/GlobalNotifyManager.kt
Normal file
@@ -0,0 +1,237 @@
|
||||
package com.chwl.app.notify
|
||||
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.alibaba.fastjson.JSON
|
||||
import com.chwl.app.NimMiddleActivity
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.avroom.anotherroompk.RoomPKCreateActivity
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPKCreateActivity
|
||||
import com.chwl.app.base.TitleBar
|
||||
import com.chwl.app.other.activity.SplashActivity
|
||||
import com.chwl.app.room_chat.activity.NimRoomP2PMessageActivity
|
||||
import com.chwl.app.room_chat.activity.RoomMsgActivity
|
||||
import com.chwl.app.support.float.FloatWindowEngine
|
||||
import com.chwl.app.support.float.SimpleFloatQueue
|
||||
import com.chwl.app.support.float.SimpleFloatWindow
|
||||
import com.chwl.app.treasure_box.activity.BoxRankingActivity
|
||||
import com.chwl.app.treasure_box.activity.TreasureBoxActivity
|
||||
import com.chwl.app.treasure_box.activity.TreasureBoxHonourActivity
|
||||
import com.chwl.app.ui.login.AddUserInfoActivity
|
||||
import com.chwl.app.ui.login.LoginCodeActivity
|
||||
import com.chwl.app.ui.login.LoginPhoneActivity
|
||||
import com.chwl.app.ui.setting.ResetPasswordActivity
|
||||
import com.chwl.app.ui.webview.room_banner.RoomBannerWebDialogActivity
|
||||
import com.chwl.app.ui.widget.LevelUpDialog
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.bean.BaseProtocol
|
||||
import com.chwl.core.gift.bean.LuckyBagNoticeInfo
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeAttachment
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeInfo
|
||||
import com.chwl.core.im.custom.bean.RoomTemplateNotifyMsgBean
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.manager.IMNetEaseManager
|
||||
import com.chwl.core.noble.bean.AllServiceGiftProtocol
|
||||
import com.chwl.core.user.UserModel
|
||||
import com.example.lib_utils.log.ILog
|
||||
import com.google.gson.Gson
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.netease.nimlib.sdk.NIMSDK
|
||||
import com.netease.nimlib.sdk.Observer
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.netease.nimlib.sdk.msg.model.BroadcastMessage
|
||||
import kotlinx.coroutines.cancel
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/3/20 19:30
|
||||
* Desc:
|
||||
**/
|
||||
object GlobalNotifyManager : Observer<BroadcastMessage>, ILog {
|
||||
|
||||
private val blackActivityList = listOf(
|
||||
SplashActivity::class.java,
|
||||
LoginPhoneActivity::class.java,
|
||||
LoginCodeActivity::class.java,
|
||||
ResetPasswordActivity::class.java,
|
||||
AddUserInfoActivity::class.java,
|
||||
NimMiddleActivity::class.java,
|
||||
// 房间页面单独处理
|
||||
AVRoomActivity::class.java,
|
||||
// 房间内玩法(该Activity用了透明主题且顶部区域还能看到房间页面,那就在房间页面展示飘屏即可)
|
||||
TreasureBoxActivity::class.java,
|
||||
BoxRankingActivity::class.java,
|
||||
TreasureBoxHonourActivity::class.java,
|
||||
RoomPKCreateActivity::class.java,
|
||||
SingleRoomPKCreateActivity::class.java,
|
||||
// 房间内私聊(该Activity用了透明主题且顶部区域还能看到房间页面,那就在房间页面展示飘屏即可)
|
||||
NimRoomP2PMessageActivity::class.java,
|
||||
RoomMsgActivity::class.java,
|
||||
// 房间内webDialog(该Activity用了透明主题且顶部区域还能看到房间页面,那就在房间页面展示飘屏即可)
|
||||
RoomBannerWebDialogActivity::class.java,
|
||||
// 升级弹窗
|
||||
LevelUpDialog::class.java
|
||||
)
|
||||
|
||||
val queue = SimpleFloatQueue()
|
||||
|
||||
init {
|
||||
start()
|
||||
}
|
||||
|
||||
fun start() {
|
||||
NIMSDK.getMsgServiceObserve().observeBroadcastMessage(this, true)
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
NIMSDK.getMsgServiceObserve().observeBroadcastMessage(this, false)
|
||||
}
|
||||
|
||||
fun bindActivity(activity: FragmentActivity) {
|
||||
if (!filter(activity)) {
|
||||
logD("bindActivity() 被过滤掉")
|
||||
return
|
||||
}
|
||||
activity.lifecycleScope.launchWhenStarted {
|
||||
bindActivityImpl(activity)
|
||||
this.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
private fun filter(activity: FragmentActivity): Boolean {
|
||||
if (blackActivityList.firstOrNull { it == activity::class.java } != null) {
|
||||
return false
|
||||
}
|
||||
if (!AuthModel.get().isLogin) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun bindActivityImpl(activity: FragmentActivity) {
|
||||
val widget = SimpleFloatWindow(activity)
|
||||
widget.maxVisibleCount = 1
|
||||
widget.bindActivity(activity)
|
||||
widget.adapter = NotifyAdapter()
|
||||
var statusHeight = TitleBar.getStatusBarHeight()
|
||||
if (statusHeight <= 0) {
|
||||
statusHeight = ScreenUtil.getStatusBarHeight(activity)
|
||||
}
|
||||
widget.getView().setPadding(0, statusHeight, 0, 0)
|
||||
val engine = FloatWindowEngine(widget, queue)
|
||||
engine.bindLifecycle(activity.lifecycle)
|
||||
engine.start()
|
||||
}
|
||||
|
||||
override fun onEvent(message: BroadcastMessage?) {
|
||||
if (message == null) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
val contentJsonStr: String = message.content
|
||||
val jsonObject = JSON.parseObject(contentJsonStr) ?: return
|
||||
if (jsonObject.containsKey("body")) {
|
||||
val body = jsonObject.getString("body")
|
||||
if (body.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
val baseProtocol: BaseProtocol<*> = try {
|
||||
JSON.parseObject(body, BaseProtocol::class.java)
|
||||
} catch (e: java.lang.Exception) {
|
||||
null
|
||||
} ?: return
|
||||
onReceivedNimBroadcastMessage(baseProtocol)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun onReceivedNimBroadcastMessage(protocol: BaseProtocol<*>) {
|
||||
when (protocol.first) {
|
||||
// 通用飘屏
|
||||
CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY -> {
|
||||
if (protocol.second == CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
|
||||
val data = Gson().fromJson<RoomTemplateNotifyMsgBean>(
|
||||
protocol.data.toString(),
|
||||
RoomTemplateNotifyMsgBean::class.java
|
||||
)
|
||||
if (UserModel.get().isSamePartition(data.partitionId ?: 0)) {
|
||||
queue.addLast(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 礼物
|
||||
CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT -> {
|
||||
if (protocol.second == CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
val data = Gson().fromJson<AllServiceGiftProtocol.DataBean>(
|
||||
protocol.data.toString(),
|
||||
AllServiceGiftProtocol.DataBean::class.java
|
||||
)
|
||||
if (UserModel.get().isSamePartition(data.partitionId)) {
|
||||
queue.addLast(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 寻爱之旅
|
||||
CustomAttachment.CUSTOM_MSG_BOX -> {
|
||||
if (protocol.second == CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
handleFindLive(protocol)
|
||||
}
|
||||
}
|
||||
// 福袋礼物
|
||||
CustomAttachment.CUSTOM_MSG_LUCKY_GIFT -> {
|
||||
if (protocol.second == CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
val data = Gson().fromJson<LuckyBagNoticeInfo>(
|
||||
protocol.data.toString(),
|
||||
LuckyBagNoticeInfo::class.java
|
||||
)
|
||||
if (UserModel.get().isSamePartition(data.partitionId)) {
|
||||
queue.addLast(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleFindLive(protocol: BaseProtocol<*>) {
|
||||
val data = Gson().fromJson<RoomBoxPrizeInfo>(
|
||||
protocol.data.toString(),
|
||||
RoomBoxPrizeInfo::class.java
|
||||
)
|
||||
if (!UserModel.get().isSamePartition(data.partitionId)) {
|
||||
return
|
||||
}
|
||||
val roomBoxPrizeAttachment = RoomBoxPrizeAttachment(
|
||||
CustomAttachment.CUSTOM_MSG_BOX,
|
||||
CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA
|
||||
)
|
||||
roomBoxPrizeAttachment.uid = data.uid
|
||||
roomBoxPrizeAttachment.prizeName = data.prizeName
|
||||
roomBoxPrizeAttachment.nick = data.nick
|
||||
roomBoxPrizeAttachment.boxTypeStr = data.boxTypeStr
|
||||
roomBoxPrizeAttachment.roomUid = data.roomUid
|
||||
roomBoxPrizeAttachment.prizeNum = data.prizeNum
|
||||
roomBoxPrizeAttachment.userLevelLimit = data.userLevelLimit
|
||||
val roomId = AvRoomDataManager.get().roomId
|
||||
var message: ChatRoomMessage? = null
|
||||
if (roomId > 0) {
|
||||
message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
|
||||
roomId.toString(),
|
||||
roomBoxPrizeAttachment
|
||||
)
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenPureMode) {
|
||||
// 純凈模式打開後,僅能看跟自己相關的砸蛋消息
|
||||
if (message != null && roomBoxPrizeAttachment.uid == AuthModel.get().currentUid) {
|
||||
IMNetEaseManager.get().addMessages(message)
|
||||
}
|
||||
} else {
|
||||
if (message != null) {
|
||||
IMNetEaseManager.get().addMessages(message)
|
||||
}
|
||||
queue.addLast(roomBoxPrizeAttachment)
|
||||
}
|
||||
}
|
||||
}
|
74
app/src/main/java/com/chwl/app/notify/NotifyAdapter.kt
Normal file
74
app/src/main/java/com/chwl/app/notify/NotifyAdapter.kt
Normal file
@@ -0,0 +1,74 @@
|
||||
package com.chwl.app.notify
|
||||
|
||||
import android.content.Context
|
||||
import com.chwl.app.notify.views.FindLoveImageNotify
|
||||
import com.chwl.app.notify.views.TemplateImageNotify
|
||||
import com.chwl.app.notify.views.TemplateSvgaNotify
|
||||
import com.chwl.app.notify.views.GiftNotify
|
||||
import com.chwl.app.notify.views.LuckyBagGiftNotify
|
||||
import com.chwl.app.notify.views.TestNotify
|
||||
import com.chwl.app.support.float.FloatView
|
||||
import com.chwl.app.support.float.FloatViewAdapter
|
||||
import com.chwl.app.support.float.FloatWindow
|
||||
import com.chwl.core.gift.bean.LuckyBagNoticeInfo
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeAttachment
|
||||
import com.chwl.core.im.custom.bean.RoomTemplateNotifyMsgBean
|
||||
import com.chwl.core.noble.bean.AllServiceGiftProtocol
|
||||
|
||||
|
||||
class NotifyAdapter : FloatViewAdapter {
|
||||
var onShowUserCard: ((String) -> Unit)? = null
|
||||
|
||||
override fun onCreateFloatView(context: Context, item: Any): FloatView? {
|
||||
when (item) {
|
||||
// 通用飘屏
|
||||
is RoomTemplateNotifyMsgBean -> {
|
||||
if (item.resourceType == RoomTemplateNotifyMsgBean.TYPE_IMAGE) {
|
||||
return TemplateImageNotify(context).apply {
|
||||
onShowUserCard = this@NotifyAdapter.onShowUserCard
|
||||
}
|
||||
} else if (item.resourceType == RoomTemplateNotifyMsgBean.TYPE_SVGA) {
|
||||
return TemplateSvgaNotify(context).apply {
|
||||
onShowUserCard = this@NotifyAdapter.onShowUserCard
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 寻爱
|
||||
is RoomBoxPrizeAttachment -> {
|
||||
if (item.second == CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
return FindLoveImageNotify(context, true)
|
||||
} else if (item.second == CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY) {
|
||||
return FindLoveImageNotify(context, false)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
// 礼物
|
||||
is AllServiceGiftProtocol.DataBean -> {
|
||||
return GiftNotify(context)
|
||||
}
|
||||
|
||||
// 福袋礼物
|
||||
is LuckyBagNoticeInfo -> {
|
||||
return LuckyBagGiftNotify(context)
|
||||
}
|
||||
|
||||
// 测试用
|
||||
is String -> {
|
||||
return TestNotify(context)
|
||||
}
|
||||
|
||||
else -> {
|
||||
return null
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onBindFloatView(window: FloatWindow, floatView: FloatView, item: Any) {
|
||||
floatView.onAttached(window, item)
|
||||
}
|
||||
}
|
127
app/src/main/java/com/chwl/app/notify/RoomNotifyManager.kt
Normal file
127
app/src/main/java/com/chwl/app/notify/RoomNotifyManager.kt
Normal file
@@ -0,0 +1,127 @@
|
||||
package com.chwl.app.notify
|
||||
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.chwl.app.base.TitleBar
|
||||
import com.chwl.app.support.float.DoubleQueue
|
||||
import com.chwl.app.support.float.FloatWindowEngine
|
||||
import com.chwl.app.support.float.SimpleFloatWindow
|
||||
import com.chwl.app.support.float.SimpleFloatQueue
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeAttachment
|
||||
import com.chwl.core.im.custom.bean.RoomReceivedLuckyGiftAttachment
|
||||
import com.chwl.core.im.custom.bean.RoomTemplateNotifyAttachment
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.manager.IMNetEaseManager
|
||||
import com.chwl.core.manager.RoomEvent
|
||||
import com.example.lib_utils.log.ILog
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.coroutines.cancel
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/3/22 14:47
|
||||
* Desc:
|
||||
**/
|
||||
class RoomNotifyManager(activity: FragmentActivity) : LifecycleEventObserver, ILog {
|
||||
val queue = SimpleFloatQueue()
|
||||
|
||||
private val compositeDisposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
var onShowUserCard: ((String) -> Unit)? = null
|
||||
|
||||
init {
|
||||
bindActivity(activity)
|
||||
}
|
||||
|
||||
private fun bindActivity(activity: FragmentActivity) {
|
||||
activity.lifecycleScope.launchWhenStarted {
|
||||
bindActivityImpl(activity)
|
||||
this.cancel()
|
||||
}
|
||||
activity.lifecycle.addObserver(this)
|
||||
}
|
||||
|
||||
private fun bindActivityImpl(activity: FragmentActivity) {
|
||||
val widget = SimpleFloatWindow(activity)
|
||||
widget.maxVisibleCount = 1
|
||||
widget.bindActivity(activity)
|
||||
widget.adapter = NotifyAdapter()
|
||||
var statusHeight = TitleBar.getStatusBarHeight()
|
||||
if (statusHeight <= 0) {
|
||||
statusHeight = ScreenUtil.getStatusBarHeight(activity)
|
||||
}
|
||||
widget.getView().setPadding(0, statusHeight, 0, 0)
|
||||
val queue = DoubleQueue(GlobalNotifyManager.queue, queue)
|
||||
val engine = FloatWindowEngine(widget, queue)
|
||||
engine.interceptor = { _ ->
|
||||
if (AvRoomDataManager.get().isSelfGamePlaying) {
|
||||
-1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
engine.bindLifecycle(activity.lifecycle)
|
||||
engine.start()
|
||||
}
|
||||
|
||||
fun start() {
|
||||
compositeDisposable.add(
|
||||
IMNetEaseManager.get().chatRoomEventObservable
|
||||
.subscribe { roomEvent: RoomEvent? ->
|
||||
if (roomEvent == null) return@subscribe
|
||||
try {
|
||||
onReceiveChatRoomEvent(roomEvent)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
if (!compositeDisposable.isDisposed) {
|
||||
compositeDisposable.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
||||
when (event) {
|
||||
Lifecycle.Event.ON_DESTROY -> {
|
||||
stop()
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onReceiveChatRoomEvent(roomEvent: RoomEvent) {
|
||||
when (roomEvent.event) {
|
||||
// 通用模版
|
||||
RoomEvent.TEMPLATE_NOTIFY -> {
|
||||
val attachment =
|
||||
roomEvent.chatRoomMessage.attachment as? RoomTemplateNotifyAttachment
|
||||
val data = attachment?.getTemplateMsg() ?: return
|
||||
queue.addLast(data)
|
||||
}
|
||||
|
||||
// 寻爱
|
||||
RoomEvent.BOX_NOTIFY, RoomEvent.BOX_NOTIFY_SVGA -> {
|
||||
val attachment =
|
||||
roomEvent.chatRoomMessage.attachment as? RoomBoxPrizeAttachment ?: return
|
||||
queue.addLast(attachment)
|
||||
}
|
||||
|
||||
// 福袋
|
||||
RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE -> {
|
||||
val message =
|
||||
(roomEvent.chatRoomMessage.attachment as? RoomReceivedLuckyGiftAttachment)?.luckyBagNoticeInfo
|
||||
?: return
|
||||
queue.addLast(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
package com.chwl.app.notify.views
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.support.float.BaseFloatView
|
||||
import com.chwl.app.utils.SpannableBuilder
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeAttachment
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
import com.example.lib_utils.UiUtils
|
||||
|
||||
|
||||
class FindLoveImageNotify(context: Context, val isHeightLevel: Boolean) : BaseFloatView(context) {
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.layout_template_notify_image, this, true)
|
||||
}
|
||||
|
||||
override fun onBind(item: Any) {
|
||||
val data = item as? RoomBoxPrizeAttachment
|
||||
if (data == null) {
|
||||
requestRemoveSelf()
|
||||
return
|
||||
}
|
||||
val textView = rootView.findViewById<TextView>(R.id.tv_text)
|
||||
textView.textSize = 12f
|
||||
textView.setTextColor(Color.WHITE)
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
"厲害了!",
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
data.nick.subAndReplaceDot(8),
|
||||
ForegroundColorSpan(resources.getColor(R.color.color_FFE44E))
|
||||
)
|
||||
.append(
|
||||
"通過歡樂砸蛋獲得\n", ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
data.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.color_FFE44E))
|
||||
)
|
||||
if (data.prizeNum > 1) {
|
||||
text.append("x" + data.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
}
|
||||
textView.text = text.build()
|
||||
textView.setPadding(0, UiUtils.dip2px(2f), 0, 0)
|
||||
val bgView = rootView.findViewById<ImageView>(R.id.iv_bg)
|
||||
if (isHeightLevel) {
|
||||
bgView.setImageResource(R.drawable.smash_eggs_notity_bg_5)
|
||||
} else {
|
||||
bgView.setImageResource(R.drawable.smash_eggs_notity_bg_4)
|
||||
}
|
||||
startEnterAnim()
|
||||
startDelayRemove()
|
||||
}
|
||||
}
|
142
app/src/main/java/com/chwl/app/notify/views/GiftNotify.kt
Normal file
142
app/src/main/java/com/chwl/app/notify/views/GiftNotify.kt
Normal file
@@ -0,0 +1,142 @@
|
||||
package com.chwl.app.notify.views
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewConfiguration
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.databinding.LayoutGiftNotifyBinding
|
||||
import com.chwl.app.support.float.BaseFloatView
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.app.ui.widget.dialog.AllServiceGiftGoRoomTipsDialog
|
||||
import com.chwl.core.noble.bean.AllServiceGiftProtocol
|
||||
import com.example.lib_utils.ktx.getColorById
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import com.example.lib_utils.spannable.SpannableTextBuilder
|
||||
|
||||
class GiftNotify(context: Context) : BaseFloatView(context) {
|
||||
private val view = TextView(context)
|
||||
|
||||
private var binding: LayoutGiftNotifyBinding? = null
|
||||
|
||||
companion object {
|
||||
private var marqueeError = false
|
||||
}
|
||||
|
||||
init {
|
||||
binding = LayoutGiftNotifyBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
}
|
||||
|
||||
override fun onBind(item: Any) {
|
||||
view.text = item.toString()
|
||||
val data = item as? AllServiceGiftProtocol.DataBean
|
||||
val binding = binding
|
||||
if (data == null || binding == null) {
|
||||
requestRemoveSelf()
|
||||
return
|
||||
}
|
||||
bindData(data, binding)
|
||||
startEnterAnim()
|
||||
var stayTime = (data.notifyStaySecond * 1000L).toLong()
|
||||
if (stayTime <= 0) {
|
||||
stayTime = 5000L
|
||||
}
|
||||
startDelayRemove(stayTime)
|
||||
}
|
||||
|
||||
private fun bindData(
|
||||
data: AllServiceGiftProtocol.DataBean,
|
||||
binding: LayoutGiftNotifyBinding
|
||||
) {
|
||||
binding.ivAvatar.singleClick {
|
||||
goRoom(data)
|
||||
}
|
||||
binding.tvRoomGo.singleClick {
|
||||
goRoom(data)
|
||||
}
|
||||
ImageLoadUtils.loadImage(binding.ivGift.getContext(), data.giftUrl, binding.ivGift)
|
||||
ImageLoadUtils.loadAvatar(data.sendUserAvatar ?: "", binding.ivAvatar)
|
||||
binding.tvRoomName.text = data.roomTitle
|
||||
if ((data.giftNum) <= 1) {
|
||||
binding.tvCount.text = ""
|
||||
} else {
|
||||
binding.tvCount.text = "X${data.giftNum}"
|
||||
}
|
||||
val message = context.getString(R.string.all_gift_message_format)
|
||||
.format(data.sendUserNick ?: "", data.recvUserNick ?: "", data.giftName ?: "")
|
||||
SpannableTextBuilder(binding.tvMessage).appendText(message)
|
||||
.setTextStyle(
|
||||
data.sendUserNick ?: "",
|
||||
binding.tvMessage.context.getColorById(R.color.color_FFE468)
|
||||
)
|
||||
.setTextStyle(
|
||||
data.recvUserNick + " ",
|
||||
binding.tvMessage.context.getColorById(R.color.color_FFE468)
|
||||
)
|
||||
.setTextStyle(
|
||||
data.giftName ?: "",
|
||||
binding.tvMessage.context.getColorById(R.color.white)
|
||||
).apply()
|
||||
when (data.levelNum.toIntOrNull()) {
|
||||
2 -> {
|
||||
binding.ivAvatarBg.setImageResource(R.drawable.all_service_gift_bg_avatar_2)
|
||||
binding.layoutRoot.setBackgroundResource(R.drawable.all_service_gift_bg_2)
|
||||
binding.tvRoomGo.setBackgroundResource(R.drawable.all_service_gift_bg_room_go2)
|
||||
}
|
||||
|
||||
3 -> {
|
||||
binding.ivAvatarBg.setImageResource(R.drawable.all_service_gift_bg_avatar_3)
|
||||
binding.layoutRoot.setBackgroundResource(R.drawable.all_service_gift_bg_3)
|
||||
binding.tvRoomGo.setBackgroundResource(R.drawable.all_service_gift_bg_room_go3)
|
||||
}
|
||||
|
||||
else -> {
|
||||
binding.ivAvatarBg.setImageDrawable(null)
|
||||
binding.layoutRoot.setBackgroundResource(R.drawable.all_service_gift_bg_1)
|
||||
binding.tvRoomGo.setBackgroundResource(R.drawable.all_service_gift_bg_room_go1)
|
||||
}
|
||||
}
|
||||
setupTextMarquee(binding.tvMessage)
|
||||
binding.groupRoom.isVisible = data.roomUid != 0L
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加跑马灯
|
||||
* 以及反射一些参数影响跑马灯
|
||||
*/
|
||||
private fun setupTextMarquee(view: TextView) {
|
||||
view.isSelected = true
|
||||
if (marqueeError) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
val configuration = ViewConfiguration.get(
|
||||
context
|
||||
)
|
||||
val claz: Class<*> = configuration.javaClass
|
||||
val field = claz.getDeclaredField("mFadingMarqueeEnabled")
|
||||
field.isAccessible = true
|
||||
field[configuration] = true
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
marqueeError = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun goRoom(
|
||||
data: AllServiceGiftProtocol.DataBean
|
||||
) {
|
||||
if (data.roomUid <= 0L) {
|
||||
// 非房间场景送的礼物
|
||||
return
|
||||
}
|
||||
if (AllServiceGiftGoRoomTipsDialog.isNeedTips()) {
|
||||
AllServiceGiftGoRoomTipsDialog(context, data.roomTitle ?: "", data.roomUid).show()
|
||||
} else {
|
||||
AVRoomActivity.start(context, data.roomUid)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
package com.chwl.app.notify.views
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.databinding.LayoutLuckyBagGiftNotifyBinding
|
||||
import com.chwl.app.support.float.BaseFloatView
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.app.ui.widget.dialog.AllServiceGiftGoRoomTipsDialog
|
||||
import com.chwl.core.gift.bean.LuckyBagNoticeInfo
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
import com.example.lib_utils.ktx.getColorById
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import com.example.lib_utils.spannable.SpannableTextBuilder
|
||||
import java.text.MessageFormat
|
||||
|
||||
class LuckyBagGiftNotify(context: Context) : BaseFloatView(context) {
|
||||
private val view = TextView(context)
|
||||
|
||||
private var binding: LayoutLuckyBagGiftNotifyBinding? = null
|
||||
|
||||
init {
|
||||
binding = LayoutLuckyBagGiftNotifyBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
val params = binding?.root?.layoutParams as? ConstraintLayout.LayoutParams
|
||||
params?.dimensionRatio = "375:71"
|
||||
binding?.root?.layoutParams = params
|
||||
}
|
||||
|
||||
override fun onBind(item: Any) {
|
||||
view.text = item.toString()
|
||||
val data = item as? LuckyBagNoticeInfo
|
||||
val binding = binding
|
||||
if (data == null || binding == null) {
|
||||
requestRemoveSelf()
|
||||
return
|
||||
}
|
||||
bindData(data, binding)
|
||||
startEnterAnim()
|
||||
startDelayRemove()
|
||||
}
|
||||
|
||||
private fun bindData(
|
||||
data: LuckyBagNoticeInfo,
|
||||
binding: LayoutLuckyBagGiftNotifyBinding
|
||||
) {
|
||||
binding.ivBag.singleClick {
|
||||
goRoom(data)
|
||||
}
|
||||
binding.ivGift.singleClick {
|
||||
goRoom(data)
|
||||
}
|
||||
ImageLoadUtils.loadImage(binding.ivBag.context, data.luckyBagGiftPic, binding.ivBag)
|
||||
ImageLoadUtils.loadImage(binding.ivGift.context, data.giftPic, binding.ivGift)
|
||||
|
||||
val userName = data.nick.subAndReplaceDot(6)
|
||||
val bagName = data.luckyBagName
|
||||
val giftName = data.giftName
|
||||
val price = data.goldPrice
|
||||
val num = data.giftNum.toString()
|
||||
val message = if (data.giftNum > 1) {
|
||||
MessageFormat.format(
|
||||
context.getString(R.string.gift_message_08), userName, bagName, price, giftName, num
|
||||
)
|
||||
} else {
|
||||
MessageFormat.format(
|
||||
context.getString(R.string.gift_message_07),
|
||||
userName,
|
||||
bagName,
|
||||
price,
|
||||
giftName
|
||||
)
|
||||
}
|
||||
SpannableTextBuilder(binding.tvMessage).appendText(message)
|
||||
.setTextStyle(
|
||||
userName,
|
||||
binding.tvMessage.context.getColorById(R.color.color_FFE468)
|
||||
)
|
||||
.setTextStyle(
|
||||
bagName,
|
||||
binding.tvMessage.context.getColorById(R.color.color_FFE468)
|
||||
)
|
||||
.setTextStyle(
|
||||
price,
|
||||
binding.tvMessage.context.getColorById(R.color.color_FFE468)
|
||||
).setTextStyle(
|
||||
giftName,
|
||||
binding.tvMessage.context.getColorById(R.color.color_FFE468)
|
||||
).apply()
|
||||
}
|
||||
|
||||
private fun goRoom(
|
||||
data: LuckyBagNoticeInfo
|
||||
) {
|
||||
if (data.roomUid <= 0L) {
|
||||
// 非房间场景送的礼物
|
||||
return
|
||||
}
|
||||
if (AllServiceGiftGoRoomTipsDialog.isNeedTips()) {
|
||||
AllServiceGiftGoRoomTipsDialog(context, data.roomTitle ?: "", data.roomUid).show()
|
||||
} else {
|
||||
AVRoomActivity.start(context, data.roomUid)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
package com.chwl.app.notify.views
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.bumptech.glide.request.target.CustomTarget
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.widget.TemplateMessageAdapter
|
||||
import com.chwl.app.support.float.BaseFloatView
|
||||
import com.chwl.app.utils.CommonJumpHelper
|
||||
import com.chwl.core.home.bean.BannerInfo
|
||||
import com.chwl.core.im.custom.bean.RoomTemplateNotifyMsgBean
|
||||
import com.netease.nim.uikit.support.glide.GlideApp
|
||||
|
||||
|
||||
class TemplateImageNotify(context: Context) : BaseFloatView(context),
|
||||
TemplateMessageAdapter.Listener {
|
||||
|
||||
private val templateMessageAdapter = TemplateMessageAdapter(this)
|
||||
|
||||
var onShowUserCard: ((String) -> Unit)? = null
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.layout_template_notify_image, this, true)
|
||||
}
|
||||
|
||||
override fun onBind(item: Any) {
|
||||
val data = item as? RoomTemplateNotifyMsgBean
|
||||
if (data == null) {
|
||||
requestRemoveSelf()
|
||||
return
|
||||
}
|
||||
if (data.resourceType != RoomTemplateNotifyMsgBean.TYPE_IMAGE) {
|
||||
requestRemoveSelf()
|
||||
return
|
||||
}
|
||||
val resourceContent = data.resourceContent
|
||||
if (resourceContent.isNullOrEmpty()) {
|
||||
requestRemoveSelf()
|
||||
return
|
||||
}
|
||||
|
||||
val textView = rootView.findViewById<TextView>(R.id.tv_text)
|
||||
val textSize = data.fontSize?.toFloat() ?: 12f
|
||||
val textColor =
|
||||
templateMessageAdapter.parseColor(data.textColor) ?: Color.WHITE
|
||||
textView.textSize = textSize
|
||||
textView.setTextColor(textColor)
|
||||
|
||||
val bgView = rootView.findViewById<ImageView>(R.id.iv_bg)
|
||||
GlideApp.with(bgView)
|
||||
.load(resourceContent).into(object : CustomTarget<Drawable>() {
|
||||
override fun onResourceReady(
|
||||
resource: Drawable,
|
||||
transition: Transition<in Drawable>?
|
||||
) {
|
||||
templateMessageAdapter.convert(textView, data)
|
||||
bgView.setImageDrawable(resource)
|
||||
startEnterAnim()
|
||||
val skipType = data.skipType
|
||||
if (skipType != null) {
|
||||
val clickAction = View.OnClickListener {
|
||||
if (skipType == BannerInfo.SKIP_TYPE_ROOM_USER_CARD) {
|
||||
onShowUserCard?.invoke(data.skipContent ?: "")
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, skipType, data.skipContent)
|
||||
}
|
||||
}
|
||||
rootView.setOnClickListener(clickAction)
|
||||
textView.setOnClickListener(clickAction)
|
||||
}
|
||||
startDelayRemove()
|
||||
}
|
||||
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
requestRemoveSelf()
|
||||
}
|
||||
|
||||
override fun onLoadFailed(errorDrawable: Drawable?) {
|
||||
super.onLoadFailed(errorDrawable)
|
||||
requestRemoveSelf()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onShowUserCard(uid: String) {
|
||||
onShowUserCard?.invoke(uid)
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
package com.chwl.app.notify.views
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.widget.TemplateMessageAdapter
|
||||
import com.chwl.app.support.float.BaseFloatView
|
||||
import com.chwl.app.utils.CommonJumpHelper
|
||||
import com.chwl.core.home.bean.BannerInfo
|
||||
import com.chwl.core.im.custom.bean.RoomTemplateNotifyMsgBean
|
||||
import com.example.lib_utils.log.ILog
|
||||
import com.opensource.svgaplayer.SVGADrawable
|
||||
import com.opensource.svgaplayer.SVGAImageView
|
||||
import com.opensource.svgaplayer.SVGAParser
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity
|
||||
import java.net.URL
|
||||
|
||||
|
||||
class TemplateSvgaNotify(context: Context) : BaseFloatView(context),
|
||||
TemplateMessageAdapter.Listener, ILog {
|
||||
|
||||
private val templateMessageAdapter = TemplateMessageAdapter(this)
|
||||
|
||||
var onShowUserCard: ((String) -> Unit)? = null
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.layout_template_notify_svga, this, true)
|
||||
}
|
||||
|
||||
override fun onBind(item: Any) {
|
||||
val data = item as? RoomTemplateNotifyMsgBean
|
||||
if (data == null) {
|
||||
requestRemoveSelf()
|
||||
return
|
||||
}
|
||||
if (data.resourceType != RoomTemplateNotifyMsgBean.TYPE_SVGA) {
|
||||
requestRemoveSelf()
|
||||
return
|
||||
}
|
||||
val resourceContent = data.resourceContent
|
||||
if (resourceContent.isNullOrEmpty()) {
|
||||
requestRemoveSelf()
|
||||
return
|
||||
}
|
||||
val textView = rootView.findViewById<TextView>(R.id.tv_text)
|
||||
val textSize = data.fontSize?.toFloat() ?: 12f
|
||||
val textColor =
|
||||
templateMessageAdapter.parseColor(data.textColor) ?: Color.WHITE
|
||||
textView.textSize = textSize
|
||||
textView.setTextColor(textColor)
|
||||
|
||||
val svgaView = rootView.findViewById<SVGAImageView>(R.id.iv_bg)
|
||||
SVGAParser.shareParser().decodeFromURL(
|
||||
URL(resourceContent),
|
||||
object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
logD("onComplete width:${videoItem.videoSize.width}")
|
||||
logD("onComplete height:${videoItem.videoSize.height}")
|
||||
val width = videoItem.videoSize.width
|
||||
val height = videoItem.videoSize.height
|
||||
var dimensionRatio = "75:11"
|
||||
if (width > 0 && height > 0) {
|
||||
dimensionRatio = "$width:$height"
|
||||
}
|
||||
val params = svgaView.layoutParams as ConstraintLayout.LayoutParams
|
||||
params.dimensionRatio = dimensionRatio
|
||||
svgaView.layoutParams = params
|
||||
val skipType = data.skipType
|
||||
if (skipType != null) {
|
||||
val clickAction = View.OnClickListener {
|
||||
if (skipType == BannerInfo.SKIP_TYPE_ROOM_USER_CARD) {
|
||||
onShowUserCard?.invoke(data.skipContent ?: "")
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, skipType, data.skipContent)
|
||||
}
|
||||
}
|
||||
rootView.setOnClickListener(clickAction)
|
||||
textView.setOnClickListener(clickAction)
|
||||
}
|
||||
val drawable = SVGADrawable(videoItem)
|
||||
svgaView.setImageDrawable(drawable)
|
||||
svgaView.startAnimation()
|
||||
templateMessageAdapter.convert(textView, data)
|
||||
startEnterAnim()
|
||||
startDelayRemove()
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
requestRemoveSelf()
|
||||
}
|
||||
},
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
override fun onShowUserCard(uid: String) {
|
||||
onShowUserCard?.invoke(uid)
|
||||
}
|
||||
}
|
30
app/src/main/java/com/chwl/app/notify/views/TestNotify.kt
Normal file
30
app/src/main/java/com/chwl/app/notify/views/TestNotify.kt
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.chwl.app.notify.views
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.chwl.app.support.float.BaseFloatView
|
||||
|
||||
class TestNotify(context: Context) : BaseFloatView(context) {
|
||||
private val view = TextView(context)
|
||||
|
||||
init {
|
||||
addView(
|
||||
view,
|
||||
ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
)
|
||||
setBackgroundColor(Color.parseColor("#44FFFFFF"))
|
||||
view.setTextColor(Color.RED)
|
||||
view.textSize = 30f
|
||||
}
|
||||
|
||||
override fun onBind(item: Any) {
|
||||
view.text = item.toString()
|
||||
startEnterAnim()
|
||||
startDelayRemove()
|
||||
}
|
||||
}
|
@@ -3,16 +3,19 @@ package com.chwl.app.other.activity;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.chwl.app.ui.login.LoginPasswordActivity;
|
||||
import com.chwl.library.language.LanguageHelper;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.chwl.app.MainActivity;
|
||||
@@ -80,6 +83,18 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis
|
||||
setIntent(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(LanguageHelper.INSTANCE.wrapContext(newBase));
|
||||
LanguageHelper.INSTANCE.wrapContext(newBase.getApplicationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
LanguageHelper.INSTANCE.changeLanguage(this, LanguageHelper.INSTANCE.getCurrentLanguage());
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
protected void initiate() {
|
||||
boolean isShowPrivacyAgreement = (boolean) SharedPreferenceUtils.get(SHOW_PRIVACY_AGREEMENT, true);
|
||||
|
@@ -58,7 +58,7 @@ public class DaemonService extends Service {
|
||||
if (roomInfo != null) {
|
||||
title = roomInfo.getTitle();
|
||||
Notification.Builder builder = new Notification.Builder(this);
|
||||
builder.setSmallIcon(R.mipmap.app_logo);
|
||||
builder.setSmallIcon(R.mipmap.ic_launcher);
|
||||
builder.setContentTitle(title);
|
||||
builder.setContentText(ResUtil.getString(R.string.erban_service_daemonservice_02));
|
||||
builder.setTicker(ResUtil.getString(R.string.erban_service_daemonservice_03));
|
||||
@@ -87,7 +87,7 @@ public class DaemonService extends Service {
|
||||
isStartForeground = true;
|
||||
} else {
|
||||
Notification.Builder builder = new Notification.Builder(this);
|
||||
builder.setSmallIcon(R.mipmap.app_logo);
|
||||
builder.setSmallIcon(R.mipmap.ic_launcher);
|
||||
builder.setContentText(ResUtil.getString(R.string.erban_service_daemonservice_05));
|
||||
builder.setTicker(ResUtil.getString(R.string.erban_service_daemonservice_06));
|
||||
//8.0系统适配
|
||||
|
@@ -22,6 +22,7 @@ import com.chwl.core.gift.bean.GiftInfo
|
||||
import com.chwl.core.home.bean.StarUser
|
||||
import com.chwl.core.utils.net.BalanceNotEnoughExeption
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.example.lib_utils.ktx.getColorById
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import com.opensource.svgaplayer.SVGADrawable
|
||||
@@ -151,7 +152,11 @@ class StarFragment : BaseViewBindingFragment<StarFragmentBinding>(), MainTabCont
|
||||
val layoutManager = CircleLayoutManager(context)
|
||||
layoutManager.infinite = true
|
||||
layoutManager.angleRotate = false
|
||||
layoutManager.gravity = CircleLayoutManager.LEFT
|
||||
layoutManager.gravity = if (UiUtils.isRtl(requireContext())) {
|
||||
CircleLayoutManager.RIGHT
|
||||
} else {
|
||||
CircleLayoutManager.LEFT
|
||||
}
|
||||
layoutManager.minRemoveAngle = -120f
|
||||
layoutManager.maxRemoveAngle = 120f
|
||||
layoutManager.moveSpeed = 0.12f
|
||||
@@ -160,7 +165,11 @@ class StarFragment : BaseViewBindingFragment<StarFragmentBinding>(), MainTabCont
|
||||
val width = binding.recyclerView.width
|
||||
layoutManager.radius = (width * 0.6).toInt()
|
||||
layoutManager.angleInterval = 20
|
||||
layoutManager.distanceToBottom = (width * 0.3f).toInt()
|
||||
layoutManager.distanceToBottom = if (UiUtils.isRtl(requireContext())) {
|
||||
(width * 0.54f).toInt()
|
||||
} else {
|
||||
(width * 0.3f).toInt()
|
||||
}
|
||||
}
|
||||
binding.recyclerView.layoutManager = layoutManager
|
||||
adapter.setOnItemClickListener { adapter, view, position ->
|
||||
@@ -190,16 +199,21 @@ class StarFragment : BaseViewBindingFragment<StarFragmentBinding>(), MainTabCont
|
||||
currentUser = user
|
||||
loadUserPanelLeft(user)
|
||||
loadUserPanelRight(user)
|
||||
val rtl = if (UiUtils.isRtl(requireContext())) {
|
||||
-1f
|
||||
} else {
|
||||
1f
|
||||
}
|
||||
binding.layoutUserPanelRight.translationX =
|
||||
binding.layoutUserPanelRight.width.toFloat()
|
||||
binding.layoutUserPanelRight.width.toFloat() * rtl
|
||||
binding.layoutUserPanelLeft.alpha = 0f
|
||||
binding.layoutUserPanelLeft.translationX = binding.layoutUserPanelLeft.width * -0.1f
|
||||
binding.layoutUserPanelLeft.translationX = binding.layoutUserPanelLeft.width * -0.1f * rtl
|
||||
binding.layoutUserPanelRight.isVisible = true
|
||||
binding.layoutUserPanelLeft.isVisible = true
|
||||
switchGiftAnimState(true)
|
||||
binding.layoutUserPanelRight.animate().translationX(0f)
|
||||
.setListener(object : DefAnimatorListener() {}).start()
|
||||
binding.animView.animate().translationX(-binding.animView.width.toFloat())
|
||||
binding.animView.animate().translationX(-binding.animView.width.toFloat() * rtl)
|
||||
.scaleX(0f).scaleY(0f).alpha(0f).setListener(object : DefAnimatorListener() {
|
||||
override fun onAnimationEnd(p0: Animator) {
|
||||
switchStarAnimState(false)
|
||||
@@ -243,10 +257,15 @@ class StarFragment : BaseViewBindingFragment<StarFragmentBinding>(), MainTabCont
|
||||
binding.ivRefresh.isVisible = true
|
||||
binding.animView.isVisible = true
|
||||
switchStarAnimState(true)
|
||||
val rtl = if (UiUtils.isRtl(requireContext())) {
|
||||
-1f
|
||||
} else {
|
||||
1f
|
||||
}
|
||||
binding.animView.animate().alpha(1f).translationX(0f).scaleX(1f).scaleY(1f)
|
||||
.setListener(object : DefAnimatorListener() {}).start()
|
||||
binding.layoutUserPanelRight.animate()
|
||||
.translationX(binding.layoutUserPanelRight.width.toFloat())
|
||||
.translationX(binding.layoutUserPanelRight.width.toFloat() * rtl)
|
||||
.setListener(object : DefAnimatorListener() {
|
||||
override fun onAnimationEnd(p0: Animator) {
|
||||
switchGiftAnimState(false)
|
||||
@@ -254,7 +273,7 @@ class StarFragment : BaseViewBindingFragment<StarFragmentBinding>(), MainTabCont
|
||||
}
|
||||
}).start()
|
||||
binding.layoutUserPanelLeft.animate()
|
||||
.translationX(binding.layoutUserPanelLeft.width * -0.1f)
|
||||
.translationX(binding.layoutUserPanelLeft.width * -0.1f * rtl)
|
||||
.alpha(0f).setListener(object : DefAnimatorListener() {
|
||||
|
||||
override fun onAnimationEnd(p0: Animator) {
|
||||
|
@@ -0,0 +1,82 @@
|
||||
package com.chwl.app.support.float
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.AnimationUtils
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.chwl.app.R
|
||||
|
||||
|
||||
abstract class BaseFloatView : ConstraintLayout, FloatView {
|
||||
private var window: FloatWindow? = 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)
|
||||
|
||||
@CallSuper
|
||||
override fun onAttached(window: FloatWindow, item: Any) {
|
||||
this.window = window
|
||||
onBind(item)
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
override fun onDetached() {
|
||||
this.window = null
|
||||
}
|
||||
|
||||
protected fun requestRemoveSelf(): Boolean {
|
||||
if (this.window == null) {
|
||||
return false
|
||||
} else {
|
||||
post {
|
||||
this.window?.removeChild(this)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun onBind(item: Any)
|
||||
|
||||
override fun getView(): View {
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
protected open fun startEnterAnim() {
|
||||
val inAnimation = AnimationUtils.loadAnimation(context, R.anim.anim_right_in)
|
||||
this.startAnimation(inAnimation)
|
||||
}
|
||||
|
||||
protected open fun startDelayRemove(delayMillis: Long = 5000) {
|
||||
postDelayed({
|
||||
val outAnimation = AnimationUtils.loadAnimation(context, R.anim.anim_left_out)
|
||||
outAnimation.setAnimationListener(object : Animation.AnimationListener {
|
||||
override fun onAnimationStart(animation: Animation?) {
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
requestRemoveSelf()
|
||||
}
|
||||
|
||||
override fun onAnimationRepeat(animation: Animation?) {
|
||||
}
|
||||
})
|
||||
this.startAnimation(outAnimation)
|
||||
}, delayMillis)
|
||||
}
|
||||
}
|
62
app/src/main/java/com/chwl/app/support/float/DoubleQueue.kt
Normal file
62
app/src/main/java/com/chwl/app/support/float/DoubleQueue.kt
Normal file
@@ -0,0 +1,62 @@
|
||||
package com.chwl.app.support.float
|
||||
|
||||
import com.example.lib_utils.log.ILog
|
||||
|
||||
|
||||
open class DoubleQueue(
|
||||
val queueA: FloatQueue,
|
||||
val queueB: FloatQueue
|
||||
) : FloatQueue, FloatQueue.QueueObserver, ILog {
|
||||
|
||||
private val queueObservable = FloatQueue.QueueObservable()
|
||||
|
||||
override fun pollFirst(): QueueItem? {
|
||||
return getFirstQueue()?.pollFirst()
|
||||
}
|
||||
|
||||
override fun peekFirst(): QueueItem? {
|
||||
return getFirstQueue()?.peekFirst()
|
||||
}
|
||||
|
||||
protected open fun getFirstQueue(): FloatQueue? {
|
||||
val itemA = queueA.peekFirst()
|
||||
val itemB = queueB.peekFirst()
|
||||
if (itemA != null && itemB != null) {
|
||||
if (itemA.time <= itemB.time) {
|
||||
return queueA
|
||||
} else {
|
||||
return queueB
|
||||
}
|
||||
}
|
||||
if (itemA != null) {
|
||||
return queueA
|
||||
}
|
||||
if (itemB != null) {
|
||||
return queueB
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun addLast(data: Any) {
|
||||
}
|
||||
|
||||
override fun registerObserver(observer: FloatQueue.QueueObserver) {
|
||||
queueObservable.registerObserver(observer)
|
||||
if (queueObservable.getCount() == 1) {
|
||||
queueA.registerObserver(this)
|
||||
queueB.registerObserver(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun unregisterObserver(observer: FloatQueue.QueueObserver) {
|
||||
queueObservable.unregisterObserver(observer)
|
||||
if (queueObservable.getCount() == 0) {
|
||||
queueA.unregisterObserver(this)
|
||||
queueB.unregisterObserver(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInserted() {
|
||||
queueObservable.notifyInserted()
|
||||
}
|
||||
}
|
48
app/src/main/java/com/chwl/app/support/float/FloatQueue.kt
Normal file
48
app/src/main/java/com/chwl/app/support/float/FloatQueue.kt
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.chwl.app.support.float
|
||||
|
||||
import android.database.Observable
|
||||
|
||||
|
||||
interface FloatQueue {
|
||||
fun pollFirst(): QueueItem?
|
||||
|
||||
fun peekFirst(): QueueItem?
|
||||
|
||||
fun addLast(data: Any)
|
||||
|
||||
fun registerObserver(observer: QueueObserver)
|
||||
|
||||
fun unregisterObserver(observer: QueueObserver)
|
||||
|
||||
interface QueueObserver {
|
||||
fun onInserted()
|
||||
}
|
||||
|
||||
class QueueObservable : Observable<QueueObserver>() {
|
||||
fun notifyInserted() {
|
||||
mObservers.forEach {
|
||||
it.onInserted()
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerObserver(observer: QueueObserver?) {
|
||||
try {
|
||||
super.registerObserver(observer)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun unregisterObserver(observer: QueueObserver?) {
|
||||
try {
|
||||
super.unregisterObserver(observer)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun getCount(): Int {
|
||||
return mObservers.size
|
||||
}
|
||||
}
|
||||
}
|
12
app/src/main/java/com/chwl/app/support/float/FloatView.kt
Normal file
12
app/src/main/java/com/chwl/app/support/float/FloatView.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.chwl.app.support.float
|
||||
|
||||
import android.view.View
|
||||
|
||||
|
||||
interface FloatView {
|
||||
fun onAttached(window: FloatWindow, item: Any)
|
||||
|
||||
fun onDetached()
|
||||
|
||||
fun getView(): View
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package com.chwl.app.support.float
|
||||
|
||||
import android.content.Context
|
||||
|
||||
|
||||
interface FloatViewAdapter {
|
||||
fun onCreateFloatView(context: Context, item: Any): FloatView?
|
||||
|
||||
fun onBindFloatView(window: FloatWindow, floatView: FloatView, item: Any)
|
||||
}
|
41
app/src/main/java/com/chwl/app/support/float/FloatWindow.kt
Normal file
41
app/src/main/java/com/chwl/app/support/float/FloatWindow.kt
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.chwl.app.support.float
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.contains
|
||||
import com.example.lib_utils.log.ILog
|
||||
|
||||
|
||||
interface FloatWindow : ILog {
|
||||
|
||||
fun bindActivity(activity: Activity) {
|
||||
val contentView = activity.window.decorView.findViewById<ViewGroup>(android.R.id.content)
|
||||
if (contentView == null) {
|
||||
logE("bindActivity() contentView=null")
|
||||
return
|
||||
}
|
||||
val view = getView()
|
||||
if (contentView.contains(view)) {
|
||||
return
|
||||
}
|
||||
if (view.layoutParams == null) {
|
||||
view.layoutParams = ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
}
|
||||
contentView.addView(view)
|
||||
}
|
||||
|
||||
|
||||
fun getView(): View
|
||||
|
||||
fun onBindEngine(engine: FloatWindowEngine)
|
||||
|
||||
fun removeChild(floatView: FloatView)
|
||||
|
||||
fun canShow(): Boolean
|
||||
|
||||
fun onShow(item: Any)
|
||||
}
|
@@ -0,0 +1,90 @@
|
||||
package com.chwl.app.support.float
|
||||
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.example.lib_utils.log.ILog
|
||||
|
||||
|
||||
open class FloatWindowEngine(
|
||||
val window: FloatWindow,
|
||||
val queue: FloatQueue
|
||||
) : LifecycleEventObserver, FloatQueue.QueueObserver, ILog {
|
||||
|
||||
private var isAvailable = true
|
||||
|
||||
/**
|
||||
* 拦截器
|
||||
* -1:直接消费掉(本次不展示,继续下一个)
|
||||
* 1:拦截(等于暂停展示)
|
||||
* 其他:默认处理
|
||||
*/
|
||||
var interceptor: ((QueueItem) -> Int)? = null
|
||||
|
||||
fun bindLifecycle(lifecycle: Lifecycle) {
|
||||
lifecycle.addObserver(this)
|
||||
}
|
||||
|
||||
fun start() {
|
||||
window.onBindEngine(this)
|
||||
queue.registerObserver(this)
|
||||
loop()
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
queue.unregisterObserver(this)
|
||||
}
|
||||
|
||||
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
||||
val isAvailableOld = isAvailable
|
||||
isAvailable = event.targetState.isAtLeast(Lifecycle.State.STARTED)
|
||||
if (isAvailableOld != isAvailable && isAvailable) {
|
||||
loop()
|
||||
}
|
||||
|
||||
if (event == Lifecycle.Event.ON_DESTROY) {
|
||||
stop()
|
||||
}
|
||||
}
|
||||
|
||||
fun loop() {
|
||||
if (!isAvailable) {
|
||||
return
|
||||
}
|
||||
val item = queue.peekFirst() ?: return
|
||||
when (interceptor?.invoke(item)) {
|
||||
-1 -> {
|
||||
// 直接消费掉,不进行展示,继续下一个
|
||||
logD("loop() -1")
|
||||
queue.pollFirst()
|
||||
loop()
|
||||
}
|
||||
|
||||
1 -> {
|
||||
// 拦截
|
||||
logD("loop() 1")
|
||||
return
|
||||
}
|
||||
|
||||
else -> {
|
||||
// 默认处理:尝试消费
|
||||
handleFirstItem()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun handleFirstItem() {
|
||||
if (window.canShow()) {
|
||||
logD("handleFirstItem() pollFirst")
|
||||
queue.pollFirst()?.let {
|
||||
window.onShow(it.data)
|
||||
}
|
||||
} else {
|
||||
logD("handleFirstItem() canShow==false")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInserted() {
|
||||
loop()
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.chwl.app.support.float
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import java.io.Serializable
|
||||
|
||||
@Keep
|
||||
data class QueueItem(val time: Long, val data: Any) : Serializable {
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.chwl.app.support.float
|
||||
|
||||
import com.chwl.core.utils.CurrentTimeUtils
|
||||
import java.util.LinkedList
|
||||
|
||||
|
||||
class SimpleFloatQueue : FloatQueue {
|
||||
|
||||
private val queueObservable = FloatQueue.QueueObservable()
|
||||
|
||||
private val queue: LinkedList<QueueItem> = LinkedList()
|
||||
|
||||
override fun pollFirst(): QueueItem? {
|
||||
return queue.pollFirst()
|
||||
}
|
||||
|
||||
override fun peekFirst(): QueueItem? {
|
||||
return queue.peekFirst()
|
||||
}
|
||||
|
||||
override fun addLast(data: Any) {
|
||||
val item = QueueItem(CurrentTimeUtils.getCurrentTime(), data)
|
||||
queue.addLast(item)
|
||||
queueObservable.notifyInserted()
|
||||
}
|
||||
|
||||
override fun registerObserver(observer: FloatQueue.QueueObserver) {
|
||||
queueObservable.registerObserver(observer)
|
||||
}
|
||||
|
||||
override fun unregisterObserver(observer: FloatQueue.QueueObserver) {
|
||||
queueObservable.unregisterObserver(observer)
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
package com.chwl.app.support.float
|
||||
|
||||
import android.animation.LayoutTransition
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
|
||||
open class SimpleFloatWindow : LinearLayout, FloatWindow {
|
||||
|
||||
var adapter: FloatViewAdapter? = null
|
||||
private var engine: FloatWindowEngine? = null
|
||||
|
||||
var maxVisibleCount: Int = 1
|
||||
|
||||
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 {
|
||||
orientation = VERTICAL
|
||||
initLayoutTransition()
|
||||
}
|
||||
|
||||
private fun initLayoutTransition() {
|
||||
val transition = LayoutTransition()
|
||||
transition.setAnimator(
|
||||
LayoutTransition.APPEARING, null
|
||||
)
|
||||
transition.setAnimator(
|
||||
LayoutTransition.DISAPPEARING, null
|
||||
)
|
||||
layoutTransition = transition
|
||||
}
|
||||
|
||||
override fun removeChild(floatView: FloatView) {
|
||||
floatView.onDetached()
|
||||
removeView(floatView.getView())
|
||||
engine?.loop()
|
||||
}
|
||||
|
||||
override fun getView(): View {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun onBindEngine(engine: FloatWindowEngine) {
|
||||
this.engine = engine
|
||||
}
|
||||
|
||||
override fun canShow(): Boolean {
|
||||
return this.childCount < maxVisibleCount
|
||||
}
|
||||
|
||||
override fun onShow(item: Any) {
|
||||
val floatView = adapter?.onCreateFloatView(context, item)
|
||||
if (floatView == null) {
|
||||
engine?.loop()
|
||||
return
|
||||
}
|
||||
addView(floatView.getView())
|
||||
adapter?.onBindFloatView(this, floatView, item)
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
package com.chwl.app.ui.behavior;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
|
||||
/**
|
||||
* 此文件不能删,引用到AppLayout下面的
|
||||
* create by lvzebiao @2020/1/7
|
||||
*/
|
||||
public class FixAppBarBehavior extends AppBarLayout.Behavior {
|
||||
|
||||
public FixAppBarBehavior() {
|
||||
}
|
||||
|
||||
public FixAppBarBehavior(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dxConsumed, int dyConsumed, int
|
||||
dxUnconsumed, int dyUnconsumed, int type) {
|
||||
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
|
||||
stopNestedScrollIfNeeded(dyUnconsumed, child, target, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dx, int dy, int[] consumed, int type) {
|
||||
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
|
||||
stopNestedScrollIfNeeded(dy, child, target, type);
|
||||
}
|
||||
|
||||
|
||||
private void stopNestedScrollIfNeeded(int dy, AppBarLayout child, View target, int type) {
|
||||
if (type == ViewCompat.TYPE_NON_TOUCH) {
|
||||
final int currOffset = getTopAndBottomOffset();
|
||||
if ((dy < 0 && currOffset == 0)
|
||||
|| (dy > 0 && currOffset == -child.getTotalScrollRange())) {
|
||||
ViewCompat.stopNestedScroll(target, ViewCompat.TYPE_NON_TOUCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -9,6 +9,7 @@ import androidx.databinding.ObservableField;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.vip.util.VipHelper;
|
||||
import com.chwl.core.gift.bean.GiftInfo;
|
||||
import com.chwl.core.gift.bean.GiftType;
|
||||
import com.chwl.core.gift.bean.SimpleVipInfo;
|
||||
import com.chwl.library.bindinglist.BaseItem;
|
||||
import com.chwl.library.utils.TimeUtils;
|
||||
@@ -65,6 +66,11 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
||||
*/
|
||||
public boolean isFreeGift;
|
||||
|
||||
/**
|
||||
* 是否超级幸运礼物
|
||||
*/
|
||||
public boolean isSuperLuckyGift;
|
||||
|
||||
public GiftInfoVm(Context context, GiftInfo data, boolean select, boolean isKnap) {
|
||||
super(context, data);
|
||||
this.isSelect.set(select);
|
||||
@@ -100,6 +106,7 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
||||
if (data.getConsumeType() == GiftInfo.CONSUME_TYPE_FREE_GIFT) {
|
||||
isFreeGift = true;
|
||||
}
|
||||
isSuperLuckyGift = (data.getGiftType() == GiftType.GIFT_TYPE_SUPER_LUCKY);
|
||||
SimpleVipInfo vipInfo = data.getGiftVipInfo();
|
||||
isLocked = vipInfo != null && VipHelper.getMyVipLevel() < vipInfo.getVipLevel();
|
||||
vipIcon = vipInfo == null ? "" : vipInfo.getVipIcon();
|
||||
|
@@ -92,7 +92,7 @@ public class MsgViewHolderText extends MsgViewHolderBase {
|
||||
.append(ResUtil.getString(R.string.im_chat_msgviewholdertext_01))
|
||||
.append(cuAttachment.getNick() + " ", new ForegroundColorSpan(appColor))
|
||||
.append(ResUtil.getString(R.string.im_chat_msgviewholdertext_02))
|
||||
.append(cuAttachment.getGoldNum() + ResUtil.getString(R.string.im_chat_msgviewholdertext_03), new ForegroundColorSpan(appColor))
|
||||
.append(cuAttachment.getGoldNum() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(appColor))
|
||||
.append("!");
|
||||
text = builder.build();
|
||||
} else if (attachment instanceof VoiceBottleShakeHeartAttachment) {
|
||||
|
196
app/src/main/java/com/chwl/app/ui/invite/InviteImageHelper.kt
Normal file
196
app/src/main/java/com/chwl/app/ui/invite/InviteImageHelper.kt
Normal file
@@ -0,0 +1,196 @@
|
||||
package com.chwl.app.ui.invite
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.core.view.drawToBitmap
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.LifecycleCoroutineScope
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.bumptech.glide.request.target.CustomTarget
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.common.widget.dialog.DialogManager
|
||||
import com.chwl.app.databinding.ShareInviteImageLayoutBinding
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.ktx.saveToAlbum
|
||||
import com.netease.nim.uikit.support.glide.GlideApp
|
||||
import com.tbruyelle.rxpermissions2.RxPermissions
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.resumeWithException
|
||||
import kotlin.jvm.Throws
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/3/11 15:57
|
||||
* Desc:邀请图片
|
||||
**/
|
||||
class InviteImageHelper {
|
||||
|
||||
fun saveToAlbum(
|
||||
activity: FragmentActivity,
|
||||
rxPermissions: RxPermissions,
|
||||
data: ShareInviteInfo,
|
||||
success: (() -> Unit)? = null
|
||||
) {
|
||||
checkStoragePermissions(rxPermissions) {
|
||||
if (it) {
|
||||
saveToAlbumImpl(activity, activity.lifecycleScope, data, success)
|
||||
} else {
|
||||
SingleToastUtil.showToast(activity.getString(R.string.ask_again))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkStoragePermissions(rxPermissions: RxPermissions, call: (Boolean) -> Unit) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
call.invoke(true)
|
||||
} else {
|
||||
val permissions = arrayOf(
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
val d = rxPermissions.request(*permissions)?.subscribe({
|
||||
if (it) {
|
||||
call.invoke(true)
|
||||
} else {
|
||||
call.invoke(false)
|
||||
}
|
||||
}, {
|
||||
it.printStackTrace()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveToAlbumImpl(
|
||||
context: Activity,
|
||||
lifecycleCoroutineScope: LifecycleCoroutineScope,
|
||||
data: ShareInviteInfo,
|
||||
success: (() -> Unit)? = null
|
||||
) {
|
||||
lifecycleCoroutineScope.launch {
|
||||
val dialogManager = DialogManager(context)
|
||||
dialogManager.showProgressDialog(context, false)
|
||||
try {
|
||||
val result = saveToAlbum(context, data)
|
||||
if (result) {
|
||||
SingleToastUtil.showToast(R.string.community_photo_bigphotoactivity_05)
|
||||
success?.invoke()
|
||||
} else {
|
||||
SingleToastUtil.showToast(R.string.community_photo_bigphotoactivity_06)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
SingleToastUtil.showToast(e.message)
|
||||
} finally {
|
||||
dialogManager.dismissDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Throws
|
||||
suspend fun saveToAlbum(context: Context, data: ShareInviteInfo): Boolean {
|
||||
val bitmap = generateBitmap(context, data)
|
||||
return saveToAlbum(context, bitmap)
|
||||
}
|
||||
|
||||
@Throws
|
||||
suspend fun generateBitmap(context: Context, data: ShareInviteInfo): Bitmap {
|
||||
val qrcodeUrl = data.qrCodeUrl
|
||||
if (qrcodeUrl.isNullOrEmpty()) {
|
||||
throw IllegalArgumentException(context.getString(R.string.utils_net_beanobserver_05))
|
||||
}
|
||||
val bitmap: Bitmap
|
||||
withContext(Dispatchers.IO) {
|
||||
val qrCode = loadQrcode(context, qrcodeUrl)
|
||||
data.qrcodeDrawable = qrCode
|
||||
val binding = createView(context)
|
||||
withContext(Dispatchers.Main) {
|
||||
bindView(binding, data)
|
||||
}
|
||||
bitmap = viewToBitmap(binding.root, UIUtil.dip2px(context, 375.0))
|
||||
}
|
||||
return bitmap
|
||||
}
|
||||
|
||||
suspend fun saveToAlbum(context: Context, bitmap: Bitmap): Boolean {
|
||||
val uri: Uri?
|
||||
withContext(Dispatchers.IO) {
|
||||
val fileName = "piko_invite_${System.currentTimeMillis()}.jpg"
|
||||
uri = bitmap.saveToAlbum(
|
||||
context = context,
|
||||
fileName = fileName,
|
||||
relativePath = null,
|
||||
quality = 90
|
||||
)
|
||||
}
|
||||
return uri != null
|
||||
}
|
||||
|
||||
private fun bindView(
|
||||
binding: ShareInviteImageLayoutBinding,
|
||||
data: ShareInviteInfo
|
||||
) {
|
||||
binding.ivQrcode.setImageDrawable(data.qrcodeDrawable)
|
||||
if (data.text.isNullOrEmpty()) {
|
||||
binding.tvQrcodeTips.isVisible = false
|
||||
} else {
|
||||
binding.tvQrcodeTips.isVisible = true
|
||||
binding.tvQrcodeTips.text = data.text
|
||||
}
|
||||
binding.tvCode.text =
|
||||
binding.tvCode.context.getString(R.string.invite_code) + data.invitationCode
|
||||
}
|
||||
|
||||
private suspend fun loadQrcode(context: Context, url: String): Drawable? {
|
||||
return suspendCancellableCoroutine {
|
||||
val target = GlideApp.with(context.applicationContext).load(url)
|
||||
.into(object : CustomTarget<Drawable>() {
|
||||
override fun onResourceReady(
|
||||
resource: Drawable,
|
||||
transition: Transition<in Drawable>?
|
||||
) {
|
||||
it.resume(resource)
|
||||
}
|
||||
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
}
|
||||
|
||||
override fun onLoadFailed(errorDrawable: Drawable?) {
|
||||
super.onLoadFailed(errorDrawable)
|
||||
it.resumeWithException(Exception(context.getString(R.string.utils_net_beanobserver_03)))
|
||||
}
|
||||
})
|
||||
it.invokeOnCancellation {
|
||||
it?.printStackTrace()
|
||||
GlideApp.with(context.applicationContext).clear(target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createView(context: Context): ShareInviteImageLayoutBinding {
|
||||
return ShareInviteImageLayoutBinding.inflate(LayoutInflater.from(context))
|
||||
}
|
||||
|
||||
private fun viewToBitmap(view: View, width: Int): Bitmap {
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
|
||||
view.measure(widthMeasureSpec, heightMeasureSpec)
|
||||
val measureWidth = view.measuredWidth
|
||||
val measureHeight = view.measuredHeight
|
||||
view.layout(0, 0, measureWidth, measureHeight)
|
||||
return view.drawToBitmap()
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
package com.chwl.app.ui.invite
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.ShareInviteDialogBinding
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.tbruyelle.rxpermissions2.RxPermissions
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/3/11 15:29
|
||||
* Desc:分享邀请
|
||||
**/
|
||||
class ShareInviteDialog(val data: ShareInviteInfo) : BottomSheetDialogFragment() {
|
||||
private var binding: ShareInviteDialogBinding? = null
|
||||
|
||||
private var rxPermissions: RxPermissions? = null
|
||||
|
||||
private val inviteImageHelper = InviteImageHelper()
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
rxPermissions = RxPermissions(this)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
initEvent()
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
binding?.let { binding ->
|
||||
binding.tvCancel.singleClick {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.tvSaveToAlbum.singleClick {
|
||||
rxPermissions?.let {
|
||||
inviteImageHelper.saveToAlbum(requireActivity(), it, data) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.tvShareLink.singleClick {
|
||||
copyLink(data.toUrl ?: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun copyLink(data: String) {
|
||||
try {
|
||||
val cm =
|
||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
cm?.setPrimaryClip(ClipData.newPlainText("text", data))
|
||||
SingleToastUtil.showToast(R.string.have_copy)
|
||||
dismissAllowingStateLoss()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
SingleToastUtil.showToast(R.string.avroom_activity_roomblacklistactivity_015)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTheme(): Int {
|
||||
return R.style.ErbanBottomSheetDialog
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
binding = ShareInviteDialogBinding.inflate(inflater)
|
||||
return binding?.root
|
||||
}
|
||||
}
|
31
app/src/main/java/com/chwl/app/ui/invite/ShareInviteInfo.kt
Normal file
31
app/src/main/java/com/chwl/app/ui/invite/ShareInviteInfo.kt
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.chwl.app.ui.invite
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.annotation.Keep
|
||||
import java.io.Serializable
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/3/11 18:56
|
||||
* Desc:分享邀请相关信息
|
||||
**/
|
||||
@Keep
|
||||
data class ShareInviteInfo(
|
||||
// 二维码图片
|
||||
val qrCodeUrl: String? = null,
|
||||
// 邀请码
|
||||
val invitationCode: String? = null,
|
||||
// 页面文案
|
||||
val text: String? = null,
|
||||
// 分享文案
|
||||
val shareText: String? = null,
|
||||
// 分享图片
|
||||
val shareImg: String? = null,
|
||||
// 分享标题
|
||||
val shareTitle: String? = null,
|
||||
// 跳转网页地址
|
||||
val toUrl: String? = null,
|
||||
// (1分享2保存)
|
||||
val type: Int? = null,
|
||||
@Transient
|
||||
var qrcodeDrawable: Drawable? = null
|
||||
) : Serializable
|
@@ -0,0 +1,83 @@
|
||||
package com.chwl.app.ui.language
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import com.chwl.app.MainActivity
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.application.App
|
||||
import com.chwl.app.base.BaseBindingActivity
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.base.TitleBar
|
||||
import com.chwl.app.databinding.LanguageActivityBinding
|
||||
import com.chwl.library.annatation.ActLayoutRes
|
||||
import com.chwl.library.language.LanguageHelper
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.example.lib_utils.AppUtils
|
||||
import com.example.lib_utils.ktx.getColorById
|
||||
import com.example.lib_utils.log.ILog
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
import java.util.Locale
|
||||
|
||||
|
||||
class LanguageActivity : BaseViewBindingActivity<LanguageActivityBinding>(), ILog {
|
||||
|
||||
companion object {
|
||||
var index = 0
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
val adapter = LanguageAdapter()
|
||||
val action: TitleBar.Action =
|
||||
object : TitleBar.TextAction(
|
||||
context.getString(R.string.save),
|
||||
context.getColorById(R.color.color_1F1B4F)
|
||||
) {
|
||||
override fun performAction(view: View) {
|
||||
adapter.getSelectLocale()?.let {
|
||||
changeLanguage(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
initTitleBar(ResUtil.getString(R.string.language_settings), action)
|
||||
adapter.selectLanguage(LanguageHelper.getCurrentLanguage())
|
||||
adapter.addData(LanguageItem(Locale.ENGLISH, "English"))
|
||||
adapter.addData(LanguageItem(Locale.TRADITIONAL_CHINESE, "繁體中文"))
|
||||
adapter.addData(LanguageItem(Locale("ar"), "بالعربية"))
|
||||
binding.recyclerView.adapter = adapter
|
||||
adapter.setOnItemClickListener { _, view, position ->
|
||||
adapter.getItem(position)?.locale?.let {
|
||||
adapter.selectLanguage(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeLanguage(locale: Locale) {
|
||||
if (locale.language == LanguageHelper.getCurrentLanguage().language) {
|
||||
return
|
||||
}
|
||||
LanguageHelper.changeLanguageConfig(locale)
|
||||
LanguageHelper.changeLanguage(App.gContext, locale)
|
||||
LanguageHelper.changeLanguage(AppUtils.getApp(), locale)
|
||||
restartMain()
|
||||
}
|
||||
|
||||
/**
|
||||
* 让页面重新执行生命周期
|
||||
*/
|
||||
private fun restartMain() {
|
||||
val intent = Intent()
|
||||
intent.setClass(context, MainActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
override fun needSteepStateBar(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun setStatusBar() {
|
||||
super.setStatusBar()
|
||||
StatusBarUtil.transparencyBar(this)
|
||||
StatusBarUtil.StatusBarLightMode(this)
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package com.chwl.app.ui.language
|
||||
|
||||
import android.view.View
|
||||
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 java.util.Locale
|
||||
|
||||
class LanguageAdapter : BaseQuickAdapter<LanguageItem, BaseViewHolder>(R.layout.language_item) {
|
||||
|
||||
private var selectLocale: Locale? = null
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: LanguageItem?) {
|
||||
helper.setText(R.id.tv_text, item?.name)
|
||||
convertState(helper, item)
|
||||
val lineView = helper.getView<View>(R.id.v_line)
|
||||
lineView.isVisible = helper.absoluteAdapterPosition != itemCount - 1
|
||||
}
|
||||
|
||||
override fun convertPayloads(
|
||||
helper: BaseViewHolder,
|
||||
item: LanguageItem?,
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
super.convertPayloads(helper, item, payloads)
|
||||
convertState(helper, item)
|
||||
}
|
||||
|
||||
private fun convertState(helper: BaseViewHolder, item: LanguageItem?) {
|
||||
val view = helper.getView<View>(R.id.iv_state)
|
||||
view.isVisible = selectLocale?.language == item?.locale?.language
|
||||
}
|
||||
|
||||
fun selectLanguage(locale: Locale) {
|
||||
this.selectLocale = locale
|
||||
notifyItemRangeChanged(0, itemCount, true)
|
||||
}
|
||||
|
||||
fun getSelectLocale() = selectLocale
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user