Compare commits
85 Commits
release2.1
...
v2.0.4
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f4fb164999 | ||
![]() |
6134bd508b | ||
![]() |
59adea0674 | ||
![]() |
6e9032bcb4 | ||
![]() |
9ce499c027 | ||
![]() |
dca7f68130 | ||
![]() |
3c21fe8cb6 | ||
![]() |
c0ea66522a | ||
![]() |
d4e4759994 | ||
![]() |
077cef5c26 | ||
![]() |
aebb11557a | ||
![]() |
52a73e3d08 | ||
![]() |
ac7089dc0b | ||
![]() |
2e167f2e21 | ||
![]() |
9aaa2043a4 | ||
![]() |
465f1de55c | ||
![]() |
a71b265687 | ||
![]() |
90e92e6f98 | ||
![]() |
eb4d32e6cc | ||
![]() |
92edbf42b4 | ||
![]() |
4194c492ab | ||
![]() |
d7ce32b101 | ||
![]() |
3237a772d7 | ||
![]() |
ddc65609d4 | ||
![]() |
888ee9dc4b | ||
![]() |
27f5931d30 | ||
![]() |
b4b1add221 | ||
![]() |
83f2a8f5a8 | ||
![]() |
746c0ccac4 | ||
![]() |
115d47db63 | ||
![]() |
517ad7bb38 | ||
![]() |
f87c54f0e1 | ||
![]() |
653116d3df | ||
![]() |
0ec9324f38 | ||
![]() |
475ec454ab | ||
![]() |
c3e001e70b | ||
![]() |
6965343562 | ||
![]() |
9b0b878593 | ||
![]() |
227f41e1bb | ||
![]() |
aaa5529e3c | ||
![]() |
33acf7fab5 | ||
![]() |
558328f639 | ||
![]() |
3d2d614bba | ||
![]() |
06c83e3305 | ||
![]() |
2934ad0e49 | ||
![]() |
10c7e3409e | ||
![]() |
ebf1b891db | ||
![]() |
f43afae374 | ||
![]() |
05d391bd1b | ||
![]() |
2ea4312a09 | ||
![]() |
46847b2bc7 | ||
![]() |
a95b7940f8 | ||
![]() |
090797b4d8 | ||
![]() |
8fadbea6fa | ||
![]() |
4ce884a903 | ||
![]() |
122d5842fe | ||
![]() |
12f2757861 | ||
![]() |
9d83904f20 | ||
![]() |
6b49e70f28 | ||
![]() |
c4c69169aa | ||
![]() |
3f341362bc | ||
![]() |
47749cd30f | ||
![]() |
4d1c7dc07b | ||
![]() |
167a41fd9c | ||
![]() |
b22b99af90 | ||
![]() |
0ab4fdb105 | ||
![]() |
4c3b9fdcaf | ||
![]() |
009518f019 | ||
![]() |
03ba5abd7d | ||
![]() |
d5b8ee1737 | ||
![]() |
a5094d6ead | ||
![]() |
9a6d31a711 | ||
![]() |
313675c09e | ||
![]() |
8f7d464262 | ||
![]() |
78383c9cfd | ||
![]() |
f7cd89683d | ||
![]() |
737aeaec3e | ||
![]() |
8e565c1e44 | ||
![]() |
3d5bf70208 | ||
![]() |
5211a4e256 | ||
![]() |
2fef91f1cb | ||
![]() |
0a54824057 | ||
![]() |
1c20b65a64 | ||
![]() |
348e63b45e | ||
![]() |
642f8ce309 |
@@ -26,7 +26,7 @@ dependencies {
|
||||
api 'androidx.annotation:annotation:1.4.0'
|
||||
api 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation "androidx.core:core-ktx:1.7.0"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'com.tencent.vasdolly'
|
||||
apply from: '../mob.gradle'
|
||||
|
||||
@@ -64,12 +65,12 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
lint {
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
disable 'MissingTranslation', 'ExtraTranslation', 'ContentDescription', 'SmallSp'
|
||||
disable 'MissingTranslation'
|
||||
disable 'ExtraTranslation'
|
||||
}
|
||||
|
||||
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
@@ -151,8 +152,6 @@ android {
|
||||
def server_url_release = '"https://api.pekolive.com/"'
|
||||
|
||||
debug {
|
||||
println("minifyEnabled = " + minify_enabled)
|
||||
|
||||
ext.enableCrashlytics = false
|
||||
ext.alwaysUpdateBuildId = false // Firebase Crashlytics禁用更新构建ID
|
||||
|
||||
@@ -160,8 +159,7 @@ android {
|
||||
buildConfigField "String", "BASE_URL_DEBUG", "BASE_URL"
|
||||
buildConfigField "String", "BASE_URL_STAGING", "BASE_URL"
|
||||
buildConfigField "String", "BASE_URL_RELEASE", server_url_release
|
||||
minifyEnabled minify_enabled.toBoolean() // 是否混淆
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
minifyEnabled false // 是否混淆
|
||||
crunchPngs false // 停用 PNG 压缩
|
||||
signingConfig signingConfigs.v2
|
||||
gradle.taskGraph.whenReady {
|
||||
@@ -215,9 +213,6 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.4.2'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
||||
|
15
app/proguard-rules.pro
vendored
@@ -99,18 +99,16 @@
|
||||
-keep class android.support.v7.** { *;}
|
||||
|
||||
#----------------EventBus事件巴士-----------------
|
||||
-keepattributes *Annotation*
|
||||
-keepclassmembers class * {
|
||||
-keepclassmembers class ** {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
}
|
||||
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
|
||||
# If using AsyncExecutord, keep required constructor of default event used.
|
||||
# Adjust the class name if a custom failure event type is used.
|
||||
-keepclassmembers class org.greenrobot.eventbus.util.ThrowableFailureEvent {
|
||||
<init>(java.lang.Throwable);
|
||||
|
||||
# Only required if you use AsyncExecutor
|
||||
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
|
||||
<init>(Java.lang.Throwable);
|
||||
}
|
||||
# Accessed via reflection, avoid renaming or removal
|
||||
-keep class org.greenrobot.eventbus.android.AndroidComponentsImpl
|
||||
|
||||
|
||||
#-------------云信相关的混淆配置------------
|
||||
-dontwarn com.netease.**
|
||||
@@ -236,7 +234,6 @@
|
||||
-dontwarn com.yizhuan.xchat_android_core.**
|
||||
-keep class com.yizhuan.xchat_android_core.** {*;}
|
||||
-keep class com.yizhuan.treasure_box.bean.** {*;}
|
||||
-keep class com.yizhuan.erban.avroom.bean.** {*;}
|
||||
|
||||
|
||||
#百度统计
|
||||
|
@@ -1086,8 +1086,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".avroom.room_album.RoomAlbumActivity" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
@@ -39,7 +39,7 @@ class RoomPKBoardView @JvmOverloads constructor(
|
||||
) : DragLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private val binding = LayoutRoomPkBoardViewBinding.inflate(LayoutInflater.from(context))
|
||||
private val observer = Observer<RoomPkBean?> { updateView(it) }
|
||||
private val observer = Observer<RoomPkBean> { updateView(it) }
|
||||
private var disposable: Disposable? = null
|
||||
private lateinit var helpPopupWindow: PopupWindow
|
||||
private var roomPkBean: RoomPkBean? = null
|
||||
|
@@ -1,14 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.bean
|
||||
|
||||
data class RoomAlbumPhotoInfo(
|
||||
val giftId: Int,
|
||||
val giftNum: Int,
|
||||
val giftUrl: String,
|
||||
val id: Int,
|
||||
val photoUrl: String,
|
||||
val roomUid: Int,
|
||||
val status: Int,
|
||||
val totalGoldPrice: Int,
|
||||
val type: Int,
|
||||
val uid: Int
|
||||
)
|
@@ -24,7 +24,6 @@ import com.yizhuan.erban.avroom.activity.CreatePKActivity;
|
||||
import com.yizhuan.erban.avroom.activity.RoomSettingActivity;
|
||||
import com.yizhuan.erban.avroom.anotherroompk.RoomPKCreateActivity;
|
||||
import com.yizhuan.erban.avroom.giftvalue.GiftValueDialogUiHelper;
|
||||
import com.yizhuan.erban.avroom.room_album.RoomAlbumActivity;
|
||||
import com.yizhuan.erban.avroom.singleroompk.SingleRoomPKCreateActivity;
|
||||
import com.yizhuan.erban.common.util.Utils;
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager;
|
||||
@@ -113,7 +112,6 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
true));
|
||||
rvOPtList.setLayoutManager(new FullyGridLayoutManager(getContext(), 5));
|
||||
optAdapter = new OptAdapter(context, null);
|
||||
addRoomAlbum(optAdapter);
|
||||
addDatingAction(optAdapter);
|
||||
addPKAction(optAdapter);
|
||||
addRoomPKAction(optAdapter);
|
||||
@@ -269,14 +267,6 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private void addRoomAlbum(OptAdapter optAdapter) {
|
||||
if (AvRoomDataManager.get().isHasRoomAlbum()) {
|
||||
optAdapter.addData(new OptAction(R.drawable.ic_room_operation_album, "房间相册", () -> {
|
||||
RoomAlbumActivity.start(getContext());
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 相亲 模式
|
||||
*
|
||||
@@ -429,7 +419,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
superAdminModel.roomOperate(SuperAdminModel.CLOSE_PUBLIC_SCREEN).subscribe();
|
||||
}
|
||||
AvRoomModel.get().closeScreen(roomInfo.getRoomId(),
|
||||
!isCloseScreen)
|
||||
!isCloseScreen)
|
||||
.compose(RxHelper.bindContext(context))
|
||||
.flatMap(data -> IMNetEaseManager.get().closeOpenScreen(
|
||||
data.getRoomId(), data))
|
||||
@@ -649,7 +639,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
}
|
||||
optAdapter.addData(new OptAction(R.drawable.icon_room_shield_report,
|
||||
ResUtil.getString(R.string.me_shield_report),
|
||||
() -> {
|
||||
() ->{
|
||||
DialogManager dialogManager = new DialogManager(context);
|
||||
List<ButtonItem> buttonItems = new ArrayList<>();
|
||||
ButtonItem buttonItem1 = new ButtonItem(ResUtil.getString(R.string.me_shield_room), () -> {
|
||||
|
@@ -18,8 +18,8 @@ import android.widget.TextView
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.android.billingclient.api.BillingClient
|
||||
import com.android.billingclient.api.BillingResult
|
||||
import com.android.billingclient.api.ProductDetails
|
||||
import com.android.billingclient.api.Purchase
|
||||
import com.android.billingclient.api.SkuDetails
|
||||
import com.appsflyer.AFInAppEventParameterName
|
||||
import com.appsflyer.AFInAppEventType
|
||||
import com.appsflyer.AppsFlyerLib
|
||||
@@ -123,7 +123,7 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
ResUtil.getString(R.string.avroom_firstcharge_firstchargedialog_01).toast()
|
||||
} else if (channel.equals(Constants.GOOGLE)) {
|
||||
goodsList?.get(position)?.let { charge ->
|
||||
buyProduct(charge.productDetails)
|
||||
buyProduct(charge.skuDetails)
|
||||
}
|
||||
} else {
|
||||
CommonWebViewActivity.start(
|
||||
@@ -142,23 +142,18 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
FirstChargeReward.ONE -> {
|
||||
spanSize = 6
|
||||
}
|
||||
|
||||
FirstChargeReward.TWO_LEFT -> {
|
||||
spanSize = 3
|
||||
}
|
||||
|
||||
FirstChargeReward.TWO_RIGHT -> {
|
||||
spanSize = 3
|
||||
}
|
||||
|
||||
FirstChargeReward.THREE -> {
|
||||
spanSize = 2
|
||||
}
|
||||
|
||||
FirstChargeReward.TWO_LEFT_SMALL -> {
|
||||
spanSize = 3
|
||||
}
|
||||
|
||||
FirstChargeReward.TWO_RIGHT_SMALL -> {
|
||||
spanSize = 3
|
||||
}
|
||||
@@ -201,13 +196,11 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
binding.rbPlanC.visibility = View.GONE
|
||||
binding.rbPlanA.text = "$${goodsList[0].chargeMoney}"
|
||||
}
|
||||
|
||||
2 -> {
|
||||
binding.rbPlanC.visibility = View.GONE
|
||||
binding.rbPlanA.text = "$${goodsList[0].chargeMoney}"
|
||||
binding.rbPlanB.text = "$${goodsList[1].chargeMoney}"
|
||||
}
|
||||
|
||||
3 -> {
|
||||
binding.rbPlanA.text = "$${goodsList[0].chargeMoney}"
|
||||
binding.rbPlanB.text = "$${goodsList[1].chargeMoney}"
|
||||
@@ -234,19 +227,20 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
for (bean in goodsList) {
|
||||
productKeys.add(bean.chargeProdId)
|
||||
}
|
||||
billingManager?.querySkuDetailsAsync(productKeys) { billingResult: BillingResult, productDetails: MutableList<ProductDetails> ->
|
||||
billingManager?.querySkuDetailsAsync(
|
||||
BillingClient.SkuType.INAPP, productKeys
|
||||
) { billingResult: BillingResult, skuDetailsList: List<SkuDetails>? ->
|
||||
if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
|
||||
Log.w(
|
||||
TAG,
|
||||
"Unsuccessful query for type: " + BillingClient.ProductType.INAPP + ". Error code: " + billingResult.responseCode
|
||||
"Unsuccessful query for type: " + BillingClient.SkuType.INAPP
|
||||
+ ". Error code: " + billingResult.responseCode
|
||||
)
|
||||
return@querySkuDetailsAsync
|
||||
}
|
||||
if (productDetails.isNotEmpty()) {
|
||||
} else if (skuDetailsList != null && skuDetailsList.isNotEmpty()) {
|
||||
for (chargeBean in goodsList) {
|
||||
for (skuDetails in productDetails) {
|
||||
if (skuDetails.productId == chargeBean.chargeProdId) {
|
||||
chargeBean.productDetails = skuDetails
|
||||
for (skuDetails in skuDetailsList) {
|
||||
if (skuDetails.sku == chargeBean.chargeProdId) {
|
||||
chargeBean.skuDetails = skuDetails
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -264,7 +258,7 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
) {
|
||||
PayModel.get().verifyOrder(
|
||||
purchase.accountIdentifiers!!.obfuscatedAccountId,
|
||||
purchase.products[0],
|
||||
purchase.skus[0],
|
||||
purchase.packageName,
|
||||
purchase.purchaseToken
|
||||
)
|
||||
@@ -273,12 +267,12 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
{ token: String? ->
|
||||
//L.i("token=" + token);
|
||||
billingManager?.consumeAsync(token)
|
||||
var skuDetails: ProductDetails? = null
|
||||
var skuDetails: SkuDetails? = null
|
||||
val goodList = goodsList
|
||||
if (!goodList.isNullOrEmpty()) {
|
||||
if (goodList != null && goodList.isNotEmpty()) {
|
||||
for (datum in goodList) {
|
||||
if (datum.chargeProdId == purchase.products[0]) {
|
||||
skuDetails = datum.productDetails
|
||||
if (datum.chargeProdId == purchase.skus[0]) {
|
||||
skuDetails = datum.skuDetails
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -288,12 +282,12 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
HashMap()
|
||||
eventValue[AFInAppEventParameterName.CONTENT_TYPE] = "Gold"
|
||||
eventValue[AFInAppEventParameterName.QUANTITY] = 1
|
||||
eventValue[AFInAppEventParameterName.CONTENT_ID] = purchase.orderId!!
|
||||
eventValue[AFInAppEventParameterName.CONTENT_ID] = purchase.orderId
|
||||
eventValue[AFInAppEventParameterName.REVENUE] =
|
||||
skuDetails.oneTimePurchaseOfferDetails?.priceAmountMicros!! / 1000000f
|
||||
eventValue["Price"] = skuDetails.oneTimePurchaseOfferDetails?.formattedPrice!!
|
||||
skuDetails.priceAmountMicros / 1000000f
|
||||
eventValue["Price"] = skuDetails.price
|
||||
eventValue[AFInAppEventParameterName.CURRENCY] =
|
||||
skuDetails.oneTimePurchaseOfferDetails?.priceCurrencyCode!!
|
||||
skuDetails.priceCurrencyCode
|
||||
AppsFlyerLib.getInstance().logEvent(
|
||||
applicationContext,
|
||||
AFInAppEventType.PURCHASE,
|
||||
@@ -321,10 +315,10 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
|
||||
/*购买商品*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun buyProduct(skuDetails: ProductDetails?) {
|
||||
fun buyProduct(skuDetails: SkuDetails?) {
|
||||
if (skuDetails != null) {
|
||||
Log.d(TAG, "BuyProduct:" + skuDetails.productId)
|
||||
PayModel.get().placeOrder(skuDetails.productId)
|
||||
Log.d(TAG, "BuyProduct:" + skuDetails.sku)
|
||||
PayModel.get().placeOrder(skuDetails.sku)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(
|
||||
{ recordId: PayRecordId ->
|
||||
@@ -378,7 +372,6 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
bean.itemType = FirstChargeReward.ONE
|
||||
}
|
||||
}
|
||||
|
||||
2 -> {
|
||||
for (i in firstChargeRewardList.indices) {
|
||||
if (i == 0) {
|
||||
@@ -388,13 +381,11 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3 -> {
|
||||
for (bean in firstChargeRewardList) {
|
||||
bean.itemType = FirstChargeReward.THREE
|
||||
}
|
||||
}
|
||||
|
||||
4 -> {
|
||||
for (i in firstChargeRewardList.indices) {
|
||||
if ((i + 1) % 2 != 0) {
|
||||
@@ -404,7 +395,6 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (firstChargeRewardList.size % 3 == 0) {
|
||||
for (bean in firstChargeRewardList) {
|
||||
|
@@ -11,10 +11,12 @@ import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewStub
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import android.widget.RelativeLayout
|
||||
@@ -47,7 +49,6 @@ import com.yizhuan.erban.avroom.dialog.RoomOperationDialog
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog
|
||||
import com.yizhuan.erban.avroom.presenter.BaseRoomPresenter
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageSendDialog
|
||||
import com.yizhuan.erban.avroom.room_album.RoomAlbumModel
|
||||
import com.yizhuan.erban.avroom.view.IBaseRoomView
|
||||
import com.yizhuan.erban.avroom.widget.BottomView
|
||||
import com.yizhuan.erban.avroom.widget.MessageView
|
||||
@@ -285,16 +286,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
|
||||
//获取免费礼物详情
|
||||
mvpPresenter?.queryFreeFlower()
|
||||
initRoomAlbum()
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun initRoomAlbum() {
|
||||
RoomAlbumModel.listUnlockRoomPhoto(AvRoomDataManager.get().roomUid)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe({
|
||||
AvRoomDataManager.get().unlockedRoomAlbumPhotos = it
|
||||
}, { toast(it.message) })
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@@ -1021,9 +1012,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun toUpMicroPhone(micPosition: Int, currentUid: String, b: Boolean) {
|
||||
if (!lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.CREATED)) {
|
||||
return
|
||||
}
|
||||
if (AvRoomDataManager.get().isSelfGamePlaying) {
|
||||
SingleToastUtil.showToast("遊戲中不可以換麥!")
|
||||
return
|
||||
|
@@ -1,84 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.databinding.DialogChooseGiftRoomAlbumBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.GridSpacingItemNewDecoration
|
||||
import com.yizhuan.xchat_android_core.gift.GiftModel
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftType
|
||||
|
||||
class ChooseGiftRoomAlbumDialogFragment : BottomSheetDialogFragment() {
|
||||
|
||||
private var _binding: DialogChooseGiftRoomAlbumBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
var onPickedListener: OnPickedListener? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(STYLE_NO_TITLE, R.style.ErbanBottomSheetDialog)
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog.window?.attributes?.apply {
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
height = WindowManager.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
|
||||
return dialog
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = DialogChooseGiftRoomAlbumBinding.inflate(layoutInflater, container, false)
|
||||
|
||||
binding.rvGifts.layoutManager = GridLayoutManager(context, 4)
|
||||
binding.rvGifts.addItemDecoration(GridSpacingItemNewDecoration(resources.getDimensionPixelOffset(R.dimen.dp_20), true))
|
||||
|
||||
|
||||
binding.rvGifts.adapter = object : BaseQuickAdapter<GiftInfo, BaseViewHolder>(R.layout.item_gift_room_album){
|
||||
override fun convert(helper: BaseViewHolder, item: GiftInfo) {
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_gift), item.giftUrl)
|
||||
helper.setText(R.id.tv_gift, item.giftName)
|
||||
helper.setText(R.id.tv_value, item.goldPrice.toString())
|
||||
}
|
||||
}.apply {
|
||||
val gifts = GiftModel.get().getGiftInfoList(GiftType.GIFT_TYPE_NORMAL)
|
||||
setNewData(gifts)
|
||||
|
||||
setOnItemClickListener { _, _, position ->
|
||||
onPickedListener?.onPicked(data[position])
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener { dismiss() }
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
fun interface OnPickedListener {
|
||||
fun onPicked(giftInfo: GiftInfo)
|
||||
}
|
||||
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import com.chad.library.adapter.base.entity.MultiItemEntity
|
||||
|
||||
data class PhotoItem(val path: String, val type: Int) : MultiItemEntity {
|
||||
override fun getItemType(): Int {
|
||||
return type
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TYPE_PHOTO = 0
|
||||
const val TYPE_ADD = 1
|
||||
}
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.LinearGradient
|
||||
import android.graphics.Shader
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseViewBindingActivity
|
||||
import com.yizhuan.erban.databinding.ActivityRoomAlbumBinding
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerIndicator
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerTitleView
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.indicators.GradientLinePagerIndicator
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView
|
||||
|
||||
class RoomAlbumActivity : BaseViewBindingActivity<ActivityRoomAlbumBinding>() {
|
||||
|
||||
val viewModel: RoomAlbumViewModel by viewModels()
|
||||
|
||||
override fun init() {
|
||||
initTitleBar(getString(R.string.room_album))
|
||||
mTitleBar.setBackgroundResource(R.color.white)
|
||||
|
||||
val titles = listOf("我的照片", "普通照片", "解鎖照片")
|
||||
|
||||
binding.indicator.navigator = CommonNavigator(this).apply {
|
||||
isAdjustMode = true
|
||||
|
||||
adapter = object : CommonNavigatorAdapter() {
|
||||
var startColor = ContextCompat.getColor(context, R.color.color_5CF1FF)
|
||||
var endColor = ContextCompat.getColor(context, R.color.color_CF70FF)
|
||||
override fun getCount(): Int {
|
||||
return 3
|
||||
}
|
||||
|
||||
override fun getTitleView(context: Context, index: Int): IPagerTitleView {
|
||||
return ColorTransitionPagerTitleView(context).apply {
|
||||
normalColor = ContextCompat.getColor(context, R.color.color_767585)
|
||||
selectedColor = ContextCompat.getColor(context, R.color.color_1F1B4F)
|
||||
text = titles[index]
|
||||
}.apply {
|
||||
setOnClickListener { binding.vp.currentItem = index }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getIndicator(context: Context?): IPagerIndicator {
|
||||
return object : GradientLinePagerIndicator(context) {
|
||||
@SuppressLint("DrawAllocation")
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
val g = LinearGradient(
|
||||
lineRect.left,
|
||||
lineRect.top,
|
||||
lineRect.right,
|
||||
lineRect.bottom,
|
||||
intArrayOf(startColor, endColor),
|
||||
null,
|
||||
Shader.TileMode.CLAMP
|
||||
)
|
||||
paint.shader = g
|
||||
canvas.drawRoundRect(lineRect, roundRadius, roundRadius, paint)
|
||||
}
|
||||
|
||||
}.apply {
|
||||
lineHeight = resources.getDimensionPixelOffset(R.dimen.dp_4).toFloat()
|
||||
lineWidth = resources.getDimensionPixelOffset(R.dimen.dp_15).toFloat()
|
||||
roundRadius = resources.getDimensionPixelOffset(R.dimen.dp_2).toFloat()
|
||||
mode = LinePagerIndicator.MODE_EXACTLY
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ViewPagerHelper.bind(binding.indicator, binding.vp)
|
||||
|
||||
val fragments = listOf(
|
||||
RoomAlbumFragment.newInstance(RoomAlbumFragment.TYPE_MINE),
|
||||
RoomAlbumFragment.newInstance(RoomAlbumFragment.TYPE_COMMON),
|
||||
RoomAlbumFragment.newInstance(RoomAlbumFragment.TYPE_LOCKED)
|
||||
)
|
||||
|
||||
binding.vp.adapter = object : FragmentStateAdapter(this) {
|
||||
override fun getItemCount(): Int {
|
||||
return fragments.size
|
||||
}
|
||||
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return fragments[position]
|
||||
}
|
||||
}
|
||||
|
||||
binding.tvUpload.setOnClickListener {
|
||||
UploadRoomAlbumDialogFragment().show(
|
||||
supportFragmentManager,
|
||||
UploadRoomAlbumDialogFragment::class.java.simpleName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, RoomAlbumActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,201 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chad.library.adapter.base.diff.BaseQuickDiffCallback
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.bean.RoomAlbumPhotoInfo
|
||||
import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.community.photo.BigPhotoActivity
|
||||
import com.yizhuan.erban.community.photo.PagerOption
|
||||
import com.yizhuan.erban.community.utils.ObjectTypeHelper
|
||||
import com.yizhuan.erban.databinding.FragmentRoomAlbumBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.erban.ui.widget.ButtonItem
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.GridSpacingItemNewDecoration
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
|
||||
class RoomAlbumFragment : BaseViewBindingFragment<FragmentRoomAlbumBinding>() {
|
||||
|
||||
private val activityViewModel by activityViewModels<RoomAlbumViewModel>()
|
||||
private val viewModel by viewModels<RoomAlbumFragmentViewModel>()
|
||||
|
||||
private val type: Int by lazy {
|
||||
requireArguments().getInt("type")
|
||||
}
|
||||
|
||||
private var page = 1
|
||||
|
||||
override fun init() {
|
||||
binding.recyclerView.layoutManager = GridLayoutManager(context, 2)
|
||||
val offsetH = resources.getDimensionPixelOffset(R.dimen.dp_7)
|
||||
val offsetV = resources.getDimensionPixelOffset(R.dimen.dp_4)
|
||||
binding.recyclerView.addItemDecoration(
|
||||
GridSpacingItemNewDecoration(
|
||||
offsetV,
|
||||
offsetH,
|
||||
false
|
||||
)
|
||||
)
|
||||
val adapter = object :
|
||||
BaseQuickAdapter<RoomAlbumPhotoInfo, BaseViewHolder>(R.layout.item_room_album) {
|
||||
override fun convert(helper: BaseViewHolder, item: RoomAlbumPhotoInfo) {
|
||||
val ivPhoto = helper.getView<ImageView>(R.id.iv_pic)
|
||||
if (item.status == 1) {
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, item.photoUrl)
|
||||
helper.setVisible(R.id.iv_lock, false)
|
||||
} else {
|
||||
ImageLoadUtils.loadImageWithBlur(
|
||||
context,
|
||||
item.photoUrl,
|
||||
ivPhoto,
|
||||
25, 4
|
||||
)
|
||||
helper.setVisible(R.id.iv_lock, true)
|
||||
}
|
||||
|
||||
helper.setVisible(R.id.v_action, type == TYPE_MINE)
|
||||
helper.setVisible(R.id.v_bottom_mask, item.type == 2)
|
||||
helper.setVisible(R.id.iv_gift, item.type == 2)
|
||||
helper.setVisible(R.id.iv_diamond, item.type == 2)
|
||||
helper.setVisible(R.id.tv_value, item.type == 2)
|
||||
|
||||
helper.itemView.setOnClickListener {
|
||||
if (item.type != 1) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
BigPhotoActivity.start(
|
||||
activity,
|
||||
ObjectTypeHelper.pathToCustomItems(item.photoUrl),
|
||||
0, PagerOption().setSave(true)
|
||||
)
|
||||
}
|
||||
|
||||
if (item.type == 2) {
|
||||
val ivGift = helper.getView<ImageView>(R.id.iv_gift)
|
||||
ImageLoadUtilsV2.loadImage(ivGift, item.giftUrl)
|
||||
helper.setText(R.id.tv_value, item.totalGoldPrice.toString())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateDefViewHolder(
|
||||
parent: ViewGroup?,
|
||||
viewType: Int
|
||||
): BaseViewHolder {
|
||||
val holder = super.onCreateDefViewHolder(parent, viewType)
|
||||
holder.addOnClickListener(R.id.v_action)
|
||||
return holder
|
||||
}
|
||||
|
||||
}.apply {
|
||||
addFooterView(View(context).apply {
|
||||
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, resources.getDimensionPixelOffset(R.dimen.dp_80))
|
||||
})
|
||||
setEnableLoadMore(true)
|
||||
setOnLoadMoreListener({
|
||||
viewModel.loadPhotos(type, ++page)
|
||||
}, binding.recyclerView)
|
||||
|
||||
setOnItemChildClickListener { _, view, position ->
|
||||
if (view.id == R.id.v_action) {
|
||||
val buttonItems = listOf(
|
||||
ButtonItem("發送到公屏") {
|
||||
dialogManager.showOkCancelDialog("確認將該照片發送至公屏") {
|
||||
viewModel.sendPhoto(data[position].id)
|
||||
}
|
||||
},
|
||||
ButtonItem("刪除照片") {
|
||||
viewModel.deletePhoto(data[position].id)
|
||||
},
|
||||
ButtonItem("查看大圖") {
|
||||
BigPhotoActivity.start(
|
||||
activity,
|
||||
ObjectTypeHelper.pathToCustomItems(data[position].photoUrl),
|
||||
0, PagerOption().setSave(true)
|
||||
)
|
||||
}
|
||||
)
|
||||
dialogManager.showCommonPopupDialog(buttonItems)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.recyclerView.adapter = adapter
|
||||
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
page = Constants.PAGE_START
|
||||
viewModel.loadPhotos(type)
|
||||
}
|
||||
|
||||
viewModel.loadPhotos(type)
|
||||
|
||||
activityViewModel.uploadLiveData.observe(this) {
|
||||
page = Constants.PAGE_START
|
||||
viewModel.loadPhotos(type)
|
||||
}
|
||||
|
||||
viewModel.myPhotosLiveData.observe(this@RoomAlbumFragment) {
|
||||
adapter.loadMoreComplete()
|
||||
|
||||
adapter.setNewDiffData(object : BaseQuickDiffCallback<RoomAlbumPhotoInfo>(it) {
|
||||
override fun areItemsTheSame(
|
||||
oldItem: RoomAlbumPhotoInfo,
|
||||
newItem: RoomAlbumPhotoInfo
|
||||
): Boolean {
|
||||
return oldItem.id == newItem.id
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(
|
||||
oldItem: RoomAlbumPhotoInfo,
|
||||
newItem: RoomAlbumPhotoInfo
|
||||
): Boolean {
|
||||
return oldItem.photoUrl === newItem.photoUrl
|
||||
}
|
||||
})
|
||||
|
||||
binding.refreshLayout.finishRefresh()
|
||||
}
|
||||
viewModel.deleteLiveData.observe(this) {
|
||||
viewModel.loadPhotos(type)
|
||||
}
|
||||
viewModel.loadStateLiveData.observe(this) {
|
||||
if (it == true) {
|
||||
adapter.loadMoreComplete()
|
||||
} else {
|
||||
if (page > 1) {
|
||||
page--
|
||||
}
|
||||
adapter.loadMoreFail()
|
||||
}
|
||||
binding.refreshLayout.finishRefresh()
|
||||
}
|
||||
viewModel.noMoreLiveData.observe(this) {
|
||||
if (it == true) {
|
||||
adapter.loadMoreEnd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TYPE_MINE = 0
|
||||
const val TYPE_COMMON = 1
|
||||
const val TYPE_LOCKED = 2
|
||||
fun newInstance(type: Int) = RoomAlbumFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putInt("type", type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.yizhuan.erban.avroom.bean.RoomAlbumPhotoInfo
|
||||
import com.yizhuan.erban.base.BaseViewModel
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
|
||||
class RoomAlbumFragmentViewModel : BaseViewModel() {
|
||||
|
||||
private val _myPhotosLiveData = MutableLiveData<MutableList<RoomAlbumPhotoInfo>?>()
|
||||
val myPhotosLiveData: LiveData<MutableList<RoomAlbumPhotoInfo>?> = _myPhotosLiveData
|
||||
|
||||
private val _deleteLiveData = MutableLiveData<Boolean?>()
|
||||
val deleteLiveData: LiveData<Boolean?> = _deleteLiveData
|
||||
|
||||
private val _loadStateLiveData = MutableLiveData<Boolean?>()
|
||||
val loadStateLiveData: LiveData<Boolean?> = _loadStateLiveData
|
||||
|
||||
private val _noMoreLiveData = MutableLiveData<Boolean?>()
|
||||
val noMoreLiveData: LiveData<Boolean?> = _noMoreLiveData
|
||||
|
||||
fun loadPhotos(type: Int, page: Int = 1) {
|
||||
safeLaunch(block = {
|
||||
val data = RoomAlbumModel.loadPhotos(AvRoomDataManager.get().roomUid, type, page)
|
||||
|
||||
data?.let {
|
||||
val value = _myPhotosLiveData.value
|
||||
if (page == 1) {
|
||||
_myPhotosLiveData.value = it.toMutableList()
|
||||
} else {
|
||||
value?.addAll(it)
|
||||
_myPhotosLiveData.value = value
|
||||
}
|
||||
|
||||
_loadStateLiveData.value = true
|
||||
_noMoreLiveData.value = it.size < Constants.PAGE_SIZE
|
||||
}
|
||||
|
||||
}, onError = {
|
||||
it.message.toast()
|
||||
_loadStateLiveData.value = false
|
||||
})
|
||||
}
|
||||
|
||||
fun sendPhoto(photoId: Int) {
|
||||
safeLaunch(block = {
|
||||
RoomAlbumModel.sendPhoto(AvRoomDataManager.get().roomUid, photoId)
|
||||
}, onComplete = {
|
||||
ToastUtils.show("發送成功")
|
||||
})
|
||||
}
|
||||
|
||||
fun deletePhoto(photoId: Int) {
|
||||
safeLaunch(block = {
|
||||
RoomAlbumModel.deletePhoto(photoId)
|
||||
|
||||
_deleteLiveData.value = true
|
||||
|
||||
}, onComplete = {
|
||||
ToastUtils.show("成功")
|
||||
})
|
||||
}
|
||||
|
||||
}
|
@@ -1,100 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import com.yizhuan.erban.avroom.bean.RoomAlbumPhotoInfo
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper
|
||||
import com.yizhuan.xchat_android_core.utils.net.launchRequest
|
||||
import com.yizhuan.xchat_android_library.net.rxnet.RxNet
|
||||
import io.reactivex.Single
|
||||
import retrofit2.http.Field
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.Query
|
||||
|
||||
object RoomAlbumModel {
|
||||
private val api = RxNet.create(Api::class.java)
|
||||
|
||||
suspend fun loadPhotos(roomUid: Long, type: Int, page: Int): List<RoomAlbumPhotoInfo>? {
|
||||
return launchRequest {
|
||||
api.loadPhotos(roomUid, type, page, Constants.PAGE_SIZE)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun uploadPhotos(roomUid: Long, type: Int, photoUrls: String, giftId: Int?): String? {
|
||||
return launchRequest {
|
||||
api.uploadPhotos(roomUid, type, photoUrls, giftId)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun sendPhoto(roomUid: Long, photoId: Int): String? {
|
||||
return launchRequest {
|
||||
api.sendPhoto(roomUid, photoId)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deletePhoto(photoId: Int): String? {
|
||||
return launchRequest {
|
||||
api.deletePhoto(photoId)
|
||||
}
|
||||
}
|
||||
|
||||
fun unlockRoomPhoto(roomUid: Long, photoId: Int): Single<GiftReceiveInfo> {
|
||||
return api.unlockRoomPhoto(roomUid, photoId)
|
||||
.compose(RxHelper.handleCommon())
|
||||
.compose(RxHelper.handleSchAndExce())
|
||||
}
|
||||
|
||||
fun listUnlockRoomPhoto(roomUid: Long): Single<List<Int>> {
|
||||
return api.listUnlockRoomPhoto(roomUid)
|
||||
.compose(RxHelper.handleCommon())
|
||||
.compose(RxHelper.handleSchAndExce())
|
||||
}
|
||||
|
||||
private interface Api {
|
||||
|
||||
@GET("roomAlbum/pagePhoto")
|
||||
suspend fun loadPhotos(
|
||||
@Query("roomUid") roomUid: Long,
|
||||
@Query("type") type: Int,
|
||||
@Query("page") page: Int,
|
||||
@Query("pageSize") pageSize: Int,
|
||||
): ServiceResult<List<RoomAlbumPhotoInfo>>
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("roomAlbum/upload")
|
||||
suspend fun uploadPhotos(
|
||||
@Field("roomUid") roomUid: Long,
|
||||
@Field("type") type: Int,
|
||||
@Field("photoUrls") photoUrls: String,
|
||||
@Field("giftId") giftId: Int?,
|
||||
): ServiceResult<String>
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("roomAlbum/sendPhoto")
|
||||
suspend fun sendPhoto(
|
||||
@Field("roomUid") roomUid: Long,
|
||||
@Field("id") photoId: Int,
|
||||
): ServiceResult<String>
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("roomAlbum/delete")
|
||||
suspend fun deletePhoto(
|
||||
@Field("id") photoId: Int,
|
||||
): ServiceResult<String>
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("roomAlbum/unlockPhoto")
|
||||
fun unlockRoomPhoto(
|
||||
@Field("roomUid") roomUid: Long,
|
||||
@Field("id") photoId: Int
|
||||
): Single<ServiceResult<GiftReceiveInfo>>
|
||||
|
||||
@GET("roomAlbum/listUnlockPhoto")
|
||||
fun listUnlockRoomPhoto(
|
||||
@Query("roomUid") roomUid: Long,
|
||||
): Single<ServiceResult<List<Int>>>
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.yizhuan.erban.base.BaseViewModel
|
||||
import com.yizhuan.erban.base.Event
|
||||
import com.yizhuan.xchat_android_core.file.FileModel
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
class RoomAlbumViewModel : BaseViewModel() {
|
||||
|
||||
|
||||
private val _uploadLiveData = MutableLiveData<Event<Boolean>>()
|
||||
val uploadLiveData: LiveData<Event<Boolean>?> = _uploadLiveData
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun upload(list: MutableList<String>, type: Int, unlockedGift: GiftInfo?) {
|
||||
Observable.fromIterable(list)
|
||||
.flatMap {
|
||||
FileModel.get().uploadFile(it).toObservable()
|
||||
}
|
||||
.toList()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
safeLaunch(onError = {
|
||||
_uploadLiveData.value = Event(false)
|
||||
}, block = {
|
||||
RoomAlbumModel.uploadPhotos(
|
||||
AvRoomDataManager.get().roomUid,
|
||||
type,
|
||||
it.joinToString(","),
|
||||
unlockedGift?.giftId
|
||||
)
|
||||
_uploadLiveData.value = Event(true)
|
||||
})
|
||||
}, {
|
||||
it.message.toast()
|
||||
_uploadLiveData.value = Event(false)
|
||||
})
|
||||
}
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.DialogLockRoomAlbumPhotoBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
|
||||
class UnlockRoomAlbumPhotoDialog : BaseDialog<DialogLockRoomAlbumPhotoBinding>(){
|
||||
|
||||
var onUnlockRoomPhotoListener: OnUnlockRoomPhotoListener? = null
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
val arguments = requireArguments()
|
||||
val giftUrl = arguments.getString("giftUrl")
|
||||
val giftName = arguments.getString("giftName")
|
||||
val price = arguments.getInt("price")
|
||||
val photoId = arguments.getInt("photoId")
|
||||
|
||||
ImageLoadUtilsV2.loadImage(binding.ivGift, giftUrl)
|
||||
binding.tvGiftName.text = giftName
|
||||
binding.tvValue.text = price.toString()
|
||||
|
||||
binding.tvAction.setOnClickListener {
|
||||
RoomAlbumModel.unlockRoomPhoto(AvRoomDataManager.get().roomUid, photoId)
|
||||
.subscribe({
|
||||
onUnlockRoomPhotoListener?.onUnlockRoomPhoto(it)
|
||||
dismiss()
|
||||
}, {
|
||||
ToastUtils.show(it.message)
|
||||
})
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
companion object{
|
||||
fun newInstance(photoId:Int, giftUrl: String?, giftName:String, price:Int): UnlockRoomAlbumPhotoDialog {
|
||||
val args = Bundle()
|
||||
args.putInt("photoId", photoId)
|
||||
args.putString("giftUrl", giftUrl)
|
||||
args.putString("giftName", giftName)
|
||||
args.putInt("price", price)
|
||||
val fragment = UnlockRoomAlbumPhotoDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
fun interface OnUnlockRoomPhotoListener{
|
||||
fun onUnlockRoomPhoto(unlockRoomAlbumPhotoInfo: GiftReceiveInfo)
|
||||
}
|
||||
}
|
@@ -1,294 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager
|
||||
import com.yizhuan.erban.databinding.DialogRoomAlbumUploadBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.GridSpacingItemNewDecoration
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo
|
||||
import com.yizhuan.xchat_android_library.common.photo.PhotoProvider
|
||||
import com.yizhuan.xchat_android_library.common.photo.PhotoProvider.photoProvider
|
||||
import com.yizhuan.xchat_android_library.common.util.PhotoCompressUtil.compress
|
||||
import com.yizhuan.xchat_android_library.common.util.PhotoCompressUtil.getCompressCachePath
|
||||
import com.yizhuan.xchat_android_library.common.util.PhotosCompressCallback
|
||||
import com.yizhuan.xchat_android_library.easypermisssion.EasyPermissions
|
||||
import kotlinx.coroutines.Job
|
||||
|
||||
class UploadRoomAlbumDialogFragment : BottomSheetDialogFragment() {
|
||||
|
||||
private var _binding: DialogRoomAlbumUploadBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val viewModel by activityViewModels<RoomAlbumViewModel>()
|
||||
|
||||
private lateinit var photoAdapter: BaseMultiItemQuickAdapter<PhotoItem, BaseViewHolder>
|
||||
|
||||
private var unlockedGift: GiftInfo? = null
|
||||
|
||||
private var compressJob: Job? = null
|
||||
|
||||
val dialogManager by lazy {
|
||||
DialogManager(context)
|
||||
}
|
||||
|
||||
private val addItem = PhotoItem("", PhotoItem.TYPE_ADD)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(STYLE_NO_TITLE, R.style.ErbanBottomSheetDialog)
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog.window?.attributes?.apply {
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
height = WindowManager.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
|
||||
return dialog
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = DialogRoomAlbumUploadBinding.inflate(layoutInflater, container, false)
|
||||
|
||||
binding.rvPhoto.layoutManager = GridLayoutManager(context, 3)
|
||||
binding.rvPhoto.addItemDecoration(
|
||||
GridSpacingItemNewDecoration(
|
||||
resources.getDimensionPixelOffset(
|
||||
R.dimen.dp_18
|
||||
), true
|
||||
)
|
||||
)
|
||||
|
||||
photoAdapter =
|
||||
object : BaseMultiItemQuickAdapter<PhotoItem, BaseViewHolder>(mutableListOf(addItem)) {
|
||||
init {
|
||||
addItemType(PhotoItem.TYPE_PHOTO, R.layout.item_publish_image)
|
||||
addItemType(PhotoItem.TYPE_ADD, R.layout.item_add_picture)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val holder = super.onCreateViewHolder(parent, viewType)
|
||||
if (viewType == PhotoItem.TYPE_PHOTO) {
|
||||
holder.setGone(R.id.iv_gif_tag, false)
|
||||
holder.setImageResource(R.id.iv_delete, R.drawable.ic_delete_room_album)
|
||||
holder.addOnClickListener(R.id.iv_delete)
|
||||
}
|
||||
return holder
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: PhotoItem) {
|
||||
if (item.type == PhotoItem.TYPE_ADD) {
|
||||
return
|
||||
}
|
||||
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_photo), item.path, false, 8)
|
||||
}
|
||||
}.apply {
|
||||
setOnItemChildClickListener { _, view, position ->
|
||||
if (view.id == R.id.iv_delete) {
|
||||
remove(position)
|
||||
if (data.last().type != PhotoItem.TYPE_ADD) {
|
||||
addData(addItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
setOnItemClickListener { _, _, position ->
|
||||
if (position == data.size - 1) {
|
||||
checkStoragePermission()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.rvPhoto.adapter = photoAdapter
|
||||
|
||||
binding.vGift.isEnabled = false
|
||||
binding.rgType.setOnCheckedChangeListener { group, checkedId ->
|
||||
if (checkedId == binding.rbCommon.id) {
|
||||
binding.tvNoGift.visibility = View.VISIBLE
|
||||
binding.tvNoGift.text =
|
||||
getString(R.string.room_album_type_no_need_unlocked_gift_tips)
|
||||
binding.groupGift.visibility = View.INVISIBLE
|
||||
unlockedGift = null
|
||||
|
||||
binding.vGift.isEnabled = false
|
||||
binding.tvGiftLabel.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
R.color.color_B3B3C3
|
||||
)
|
||||
)
|
||||
} else {
|
||||
binding.tvNoGift.visibility = View.VISIBLE
|
||||
binding.tvNoGift.text =
|
||||
getString(R.string.room_album_type_choose_unlocked_gift_tips)
|
||||
|
||||
binding.groupGift.visibility = View.INVISIBLE
|
||||
binding.vGift.isEnabled = true
|
||||
binding.tvGiftLabel.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
R.color.color_1F1B4F
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
binding.vGift.setOnClickListener {
|
||||
val chooseGiftRoomAlbumDialogFragment = ChooseGiftRoomAlbumDialogFragment()
|
||||
chooseGiftRoomAlbumDialogFragment.onPickedListener =
|
||||
ChooseGiftRoomAlbumDialogFragment.OnPickedListener {
|
||||
unlockedGift = it
|
||||
|
||||
binding.tvNoGift.visibility = View.INVISIBLE
|
||||
binding.groupGift.visibility = View.VISIBLE
|
||||
|
||||
ImageLoadUtilsV2.loadImage(binding.ivGift, it.giftUrl)
|
||||
binding.tvGiftName.text = it.giftName
|
||||
binding.tvGiftValue.text = it.goldPrice.toString()
|
||||
}
|
||||
chooseGiftRoomAlbumDialogFragment.show(
|
||||
childFragmentManager,
|
||||
UploadRoomAlbumDialogFragment::class.java.simpleName
|
||||
)
|
||||
}
|
||||
|
||||
binding.slConfirm.setOnClickListener {
|
||||
val list = mutableListOf<String>()
|
||||
photoAdapter.data.forEach {
|
||||
if (it.type == PhotoItem.TYPE_PHOTO) {
|
||||
list.add(it.path)
|
||||
}
|
||||
}
|
||||
if (list.size < 1) {
|
||||
ToastUtils.show("未選擇圖片")
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val type = if (binding.rgType.checkedRadioButtonId == binding.rbCommon.id) 1 else 2
|
||||
if (type == 2 && unlockedGift == null) {
|
||||
ToastUtils.show("未選擇解鎖禮物")
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
dialogManager.showProgressDialog(context)
|
||||
viewModel.upload(
|
||||
list,
|
||||
type,
|
||||
unlockedGift
|
||||
)
|
||||
}
|
||||
|
||||
viewModel.uploadLiveData.observe(this) {
|
||||
it?.getContentIfNotHandled()?.let { success ->
|
||||
dialogManager.hideProgressDialog()
|
||||
|
||||
if (success) {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener { dismiss() }
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
private fun checkStoragePermission() {
|
||||
if (!EasyPermissions.hasPermissions(
|
||||
requireContext(),
|
||||
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES
|
||||
else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
) {
|
||||
EasyPermissions.requestPermissions(
|
||||
this,
|
||||
getString(R.string.permission_storage_rationale),
|
||||
100,
|
||||
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES
|
||||
else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
} else {
|
||||
photoProvider(
|
||||
this,
|
||||
7 - photoAdapter.data.size,
|
||||
true,
|
||||
200,
|
||||
true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
if (requestCode == 200) {
|
||||
PhotoProvider.getResultPathListAsync(data) {
|
||||
it?.let { paths ->
|
||||
compressPhotos(paths.toMutableList())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun compressPhotos(paths: MutableList<String>) {
|
||||
compressJob?.cancel(null)
|
||||
compressJob = compress(
|
||||
requireContext(), paths,
|
||||
getCompressCachePath(),
|
||||
object : PhotosCompressCallback {
|
||||
override fun onSuccess(compressedImgList: ArrayList<String>) {
|
||||
val list = photoAdapter.data
|
||||
val removeLast = list.removeLast()
|
||||
compressedImgList.forEach { item ->
|
||||
list.add(PhotoItem(item, PhotoItem.TYPE_PHOTO))
|
||||
}
|
||||
if (list.size < 6) {
|
||||
list.add(removeLast)
|
||||
}
|
||||
photoAdapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onFail(e: Throwable) {
|
||||
ToastUtils.show(getString(R.string.picker_image_error))
|
||||
}
|
||||
}, 200, false, Constants.UPLOAD_IMAGE_MAX_SIZE, Constants.UPLOAD_IMAGE_MAX_FILE_LENGTH
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
}
|
@@ -3,7 +3,6 @@ package com.yizhuan.erban.avroom.widget;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_ALBUM;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L1;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L2;
|
||||
@@ -24,7 +23,6 @@ import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ROOM_DI
|
||||
import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ROOM_GIFT;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
@@ -44,7 +42,6 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -62,7 +59,6 @@ import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessageExtension;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
|
||||
import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.NotificationType;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
@@ -71,18 +67,13 @@ import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.UIHelper;
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
||||
import com.yizhuan.erban.avroom.dialog.PKResultDialog;
|
||||
import com.yizhuan.erban.avroom.room_album.UnlockRoomAlbumPhotoDialog;
|
||||
import com.yizhuan.erban.common.util.Utils;
|
||||
import com.yizhuan.erban.common.widget.CustomAutoWidthImageSpan;
|
||||
import com.yizhuan.erban.common.widget.CustomImageSpan;
|
||||
import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan;
|
||||
import com.yizhuan.erban.community.photo.BigPhotoActivity;
|
||||
import com.yizhuan.erban.community.photo.PagerOption;
|
||||
import com.yizhuan.erban.community.utils.ObjectTypeHelper;
|
||||
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
|
||||
import com.yizhuan.erban.treasurefairy.HomeFairyActivity;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2;
|
||||
import com.yizhuan.erban.ui.widget.DividerItemDecoration;
|
||||
import com.yizhuan.erban.ui.widget.MyItemAnimator;
|
||||
import com.yizhuan.erban.ui.widget.RecyclerViewNoViewpagerScroll;
|
||||
@@ -102,7 +93,6 @@ import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiver;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagGifts;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.toolbox.GiftToolbox;
|
||||
import com.yizhuan.xchat_android_core.helper.ImHelperUtils;
|
||||
import com.yizhuan.xchat_android_core.home.event.FollowRoomEvent;
|
||||
import com.yizhuan.xchat_android_core.home.model.CollectionRoomModel;
|
||||
@@ -129,20 +119,16 @@ import com.yizhuan.xchat_android_core.im.custom.bean.MultiGiftAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.MultiLuckyGiftAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageRoomMsgAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomAlbumAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomAlbumMsgInfo;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment2;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomNoticeAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPhoto;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTipAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.TarotAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.User;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.VipMessageAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.WelcomeAttachment;
|
||||
import com.yizhuan.xchat_android_core.level.UserLevelResourceType;
|
||||
@@ -749,28 +735,8 @@ public class MessageView extends FrameLayout {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
ChatRoomMessage chatRoomMessage = data.get(position);
|
||||
if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) {
|
||||
MsgAttachment attachment = chatRoomMessage.getAttachment();
|
||||
if (attachment instanceof CustomAttachment) {
|
||||
if (((CustomAttachment) attachment).getFirst() == CustomAttachment.CUSTOM_MSG_ROOM_ALBUM) {
|
||||
return CustomAttachment.CUSTOM_MSG_ROOM_ALBUM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.getItemViewType(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == CustomAttachment.CUSTOM_MSG_ROOM_ALBUM) {
|
||||
return new MessageViewHolder(LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.layout_msg_view_holder_room_album, parent, false));
|
||||
|
||||
}
|
||||
return new MessageViewHolder(LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.list_item_chatrrom_msg, parent, false));
|
||||
}
|
||||
@@ -1029,8 +995,6 @@ public class MessageView extends FrameLayout {
|
||||
setGiftCompoundMsg(chatRoomMessage, tvContent);
|
||||
} else if (first == CUSTOM_MSG_FAIRY) {
|
||||
setFairyMsg(chatRoomMessage, tvContent);
|
||||
} else if (first == CUSTOM_MSG_ROOM_ALBUM) {
|
||||
setRoomAlbumMsg(chatRoomMessage, baseViewHolder);
|
||||
} else {
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
@@ -1044,103 +1008,6 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private void setRoomAlbumMsg(ChatRoomMessage chatRoomMessage, MessageViewHolder baseViewHolder) {
|
||||
RoomAlbumAttachment attachment = (RoomAlbumAttachment) chatRoomMessage.getAttachment();
|
||||
RoomAlbumMsgInfo mRoomAlbumMsgInfo = attachment.getMRoomAlbumMsgInfo();
|
||||
|
||||
if (mRoomAlbumMsgInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoomPhoto roomPhoto = mRoomAlbumMsgInfo.getRoomPhoto();
|
||||
User user = mRoomAlbumMsgInfo.getUser();
|
||||
boolean isMyself = UserModel.get().isMyseft(user.getUid());
|
||||
|
||||
ImageView ivUserLevel = baseViewHolder.itemView.findViewById(R.id.iv_user_level);
|
||||
ImageView ivUserCharm = baseViewHolder.itemView.findViewById(R.id.iv_user_charm);
|
||||
ImageView ivPhoto = baseViewHolder.itemView.findViewById(R.id.iv_photo);
|
||||
ImageView ivGift = baseViewHolder.itemView.findViewById(R.id.iv_gift);
|
||||
ImageView ivDiamond = baseViewHolder.itemView.findViewById(R.id.iv_diamond);
|
||||
TextView tvNick = baseViewHolder.itemView.findViewById(R.id.tv_nick);
|
||||
TextView tvValue = baseViewHolder.itemView.findViewById(R.id.tv_value);
|
||||
TextView tvUnlock = baseViewHolder.itemView.findViewById(R.id.tv_unlock);
|
||||
View vBottomMask = baseViewHolder.itemView.findViewById(R.id.v_bottom_mask);
|
||||
|
||||
ImageLoadUtilsV2.loadImage(ivUserLevel, mRoomAlbumMsgInfo.getUserLevel().getExperUrl());
|
||||
ImageLoadUtilsV2.loadImage(ivUserCharm, mRoomAlbumMsgInfo.getUserLevel().getCharmUrl());
|
||||
tvNick.setText(user.getNick());
|
||||
tvUnlock.setText("解鎖");
|
||||
tvUnlock.setBackgroundResource(R.drawable.bg_9168fa_6);
|
||||
|
||||
if (roomPhoto.getType() == 1) {
|
||||
vBottomMask.setVisibility(View.INVISIBLE);
|
||||
ivGift.setVisibility(View.INVISIBLE);
|
||||
ivDiamond.setVisibility(View.INVISIBLE);
|
||||
tvValue.setVisibility(View.INVISIBLE);
|
||||
tvUnlock.setVisibility(View.INVISIBLE);
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, roomPhoto.getPhotoUrl());
|
||||
} else {
|
||||
vBottomMask.setVisibility(View.VISIBLE);
|
||||
ivGift.setVisibility(View.VISIBLE);
|
||||
ivDiamond.setVisibility(View.VISIBLE);
|
||||
tvValue.setVisibility(View.VISIBLE);
|
||||
tvUnlock.setVisibility(View.VISIBLE);
|
||||
|
||||
if (isMyself) {
|
||||
tvUnlock.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
if (isMyself || hadUnlock(roomPhoto.getId())) {
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, roomPhoto.getPhotoUrl());
|
||||
tvUnlock.setText("已解鎖");
|
||||
tvUnlock.setBackgroundResource(R.drawable.bg_9e9ea8_6);
|
||||
} else {
|
||||
ImageLoadUtils.loadImageWithBlur(mContext, roomPhoto.getPhotoUrl(), ivPhoto, 25, 4);
|
||||
}
|
||||
|
||||
ImageLoadUtilsV2.loadImage(ivGift, roomPhoto.getGiftUrl());
|
||||
tvValue.setText(String.valueOf(roomPhoto.getTotalGoldPrice()));
|
||||
}
|
||||
|
||||
ivPhoto.setOnClickListener(v -> {
|
||||
if (roomPhoto.getType() == 2 && !isMyself && !hadUnlock(roomPhoto.getId())) {
|
||||
unlockRoomPhoto(baseViewHolder.getAbsoluteAdapterPosition(), roomPhoto);
|
||||
return;
|
||||
}
|
||||
|
||||
BigPhotoActivity.start((Activity) mContext, ObjectTypeHelper.pathToCustomItems(roomPhoto.getPhotoUrl()),
|
||||
0, new PagerOption());
|
||||
});
|
||||
|
||||
baseViewHolder.itemView.setOnClickListener(v -> {
|
||||
if (roomPhoto.getType() == 2 && !isMyself && !hadUnlock(roomPhoto.getId())) {
|
||||
unlockRoomPhoto(baseViewHolder.getAbsoluteAdapterPosition(), roomPhoto);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
tvUnlock.setOnClickListener(v -> unlockRoomPhoto(baseViewHolder.getAbsoluteAdapterPosition(), roomPhoto));
|
||||
}
|
||||
|
||||
private void unlockRoomPhoto(int position, RoomPhoto roomPhoto) {
|
||||
UnlockRoomAlbumPhotoDialog unlockRoomAlbumPhotoDialog = UnlockRoomAlbumPhotoDialog.Companion
|
||||
.newInstance(roomPhoto.getId(), roomPhoto.getGiftUrl(), roomPhoto.getGiftName(), roomPhoto.getTotalGoldPrice());
|
||||
unlockRoomAlbumPhotoDialog.setOnUnlockRoomPhotoListener(giftReceiveInfo -> {
|
||||
giftReceiveInfo.setRoomAlbum(true);
|
||||
GiftToolbox.sendGiftRoomMessage(giftReceiveInfo);
|
||||
|
||||
AvRoomDataManager.get().addUnlockedRoomAlbumPhoto(roomPhoto.getId());
|
||||
notifyItemChanged(position);
|
||||
});
|
||||
unlockRoomAlbumPhotoDialog.show(mContext);
|
||||
|
||||
}
|
||||
|
||||
private boolean hadUnlock(int photoId) {
|
||||
List<Integer> unlockedIds= AvRoomDataManager.get().getUnlockedRoomAlbumPhotos();
|
||||
return unlockedIds.contains(photoId);
|
||||
}
|
||||
|
||||
private void setFairyMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
if (chatRoomMessage.getAttachment() instanceof FairyMsgAttachment) {
|
||||
FairyMsgAttachment attachment = (FairyMsgAttachment) chatRoomMessage.getAttachment();
|
||||
@@ -1459,7 +1326,7 @@ public class MessageView extends FrameLayout {
|
||||
case CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING:
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_026), new ForegroundColorSpan(textColor))
|
||||
.append(nickName, new ForegroundColorSpan(roomTipNickColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0160), new ForegroundColorSpan(textColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0160), new ForegroundColorSpan(textColor))
|
||||
.append(tarotMsgBean.getDrawGoldNum() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor));
|
||||
tvContent.setText(text.build());
|
||||
break;
|
||||
|
@@ -16,7 +16,7 @@ abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
|
||||
|
||||
private var _binding: T? = null
|
||||
private var onDismissListener: (() -> Unit)? = null
|
||||
val binding get() = _binding!!
|
||||
val binding get() = _binding
|
||||
open var width = ScreenUtil.getDialogWidth()
|
||||
open var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
open var gravity = Gravity.CENTER
|
||||
|
@@ -13,8 +13,8 @@ import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chuhai.core.component.SuperBottomSheetDialog;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.util.Utils;
|
||||
import com.yizhuan.erban.ui.widget.ButtonItem;
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author xiaoyu
|
||||
*/
|
||||
public class CommonPopupDialog extends SuperBottomSheetDialog implements OnClickListener {
|
||||
public class CommonPopupDialog extends BottomSheetDialog implements OnClickListener {
|
||||
private static final int BUTTON_ITEM_ID = 135798642;
|
||||
|
||||
private int mId;
|
||||
|
@@ -8,8 +8,6 @@ import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseActivity
|
||||
@@ -20,6 +18,7 @@ import com.yizhuan.xchat_android_core.room.bean.SearchRoomInfo
|
||||
import com.yizhuan.xchat_android_core.room.model.AvRoomModel
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import kotlinx.android.synthetic.main.activity_give_gold_search.*
|
||||
|
||||
class GiveGoldSearchActivity : BaseActivity(), TextWatcher {
|
||||
|
||||
@@ -43,7 +42,7 @@ class GiveGoldSearchActivity : BaseActivity(), TextWatcher {
|
||||
.setPageSize(Int.MAX_VALUE)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyTextView(this, ResUtil.getString(R.string.pay_activity_givegoldsearchactivity_01)))
|
||||
.setLayoutManager(LinearLayoutManager(this))
|
||||
.setRecyclerView(findViewById(R.id.recyclerView))
|
||||
.setRecyclerView(recyclerView)
|
||||
.setAdapter(adapter)
|
||||
.build()
|
||||
adapter.setOnItemClickListener { _, _, position ->
|
||||
@@ -54,8 +53,8 @@ class GiveGoldSearchActivity : BaseActivity(), TextWatcher {
|
||||
})
|
||||
finish()
|
||||
}
|
||||
findViewById<EditText>(R.id.editSearch).addTextChangedListener(this)
|
||||
findViewById<TextView>(R.id.tvCancel).setOnClickListener { finish() }
|
||||
editSearch.addTextChangedListener(this)
|
||||
tvCancel.setOnClickListener { finish() }
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
@@ -3,10 +3,10 @@ package com.yizhuan.erban.pay.activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseActivity
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import kotlinx.android.synthetic.main.activity_give_gold_success.*
|
||||
|
||||
class GiveGoldSuccessActivity : BaseActivity() {
|
||||
|
||||
@@ -24,9 +24,9 @@ class GiveGoldSuccessActivity : BaseActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_give_gold_success)
|
||||
initTitleBar(ResUtil.getString(R.string.pay_activity_givegoldsuccessactivity_01))
|
||||
findViewById<TextView>(R.id.tvNickname).text = "轉贈給:${intent.getStringExtra("nickname")}"
|
||||
findViewById<TextView>(R.id.tvGold).text = "${intent.getStringExtra("gold")?.toInt()}鉆石"
|
||||
findViewById<TextView>(R.id.tvSure).setOnClickListener { finish() }
|
||||
tvNickname.text = "轉贈給:${intent.getStringExtra("nickname")}"
|
||||
tvGold.text = "${intent.getStringExtra("gold")?.toInt()}鉆石"
|
||||
tvSure.setOnClickListener { finish() }
|
||||
}
|
||||
|
||||
|
||||
|
@@ -10,7 +10,6 @@ import android.text.TextWatcher
|
||||
import android.util.SparseArray
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import androidx.activity.viewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@@ -40,6 +39,7 @@ import com.yizhuan.xchat_android_core.pay.PayModel
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.user.bean.SearchUserInfo
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import kotlinx.android.synthetic.main.activity_give_gold_to_user.*
|
||||
|
||||
class GiveGoldToUserActivity : BaseViewBindingActivity<ActivityGiveGoldToUserBinding>(),
|
||||
GridPasswordNoFocusView.OnPasswordChangedListener,
|
||||
@@ -371,7 +371,7 @@ class GiveGoldToUserActivity : BaseViewBindingActivity<ActivityGiveGoldToUserBin
|
||||
if (password.length == 6) {
|
||||
searchUserInfo?.apply {
|
||||
dialogManager.showProgressDialog(context)
|
||||
PayModel.get().giveGold(uid, findViewById<EditText>(R.id.mEditGold).text.toString(), DESAndBase64(password))
|
||||
PayModel.get().giveGold(uid, mEditGold.text.toString(), DESAndBase64(password))
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError {
|
||||
toast(it.message)
|
||||
|
@@ -10,19 +10,7 @@ import com.yizhuan.erban.treasurefairy.event.UpdateDataEvent
|
||||
import com.yizhuan.erban.treasurefairy.view.MyFairyItemView
|
||||
import com.yizhuan.xchat_android_core.bean.response.ListResult
|
||||
import com.yizhuan.xchat_android_core.gift.bean.SimpleUserInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.Compound
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.DrawInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ExchangeGiftInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyResolveParam
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyTestParam
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ForestInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.MyFairyInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.PrizeInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ResolveInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.SendFairyInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.TestFairyRecordInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.TreasureFairyModel
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.*
|
||||
import com.yizhuan.xchat_android_core.utils.net.ServerException
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
@@ -66,8 +54,7 @@ class FairyViewModel : BaseViewModel() {
|
||||
val sendFairyRecordLiveData: LiveData<ListResult<SendFairyInfo>> = _sendFairyRecordLiveData
|
||||
|
||||
private val _compoundFairyInfosLiveData = MutableLiveData<SparseArray<FairyInfo>?>()
|
||||
val compoundFairyInfosLiveData: MutableLiveData<SparseArray<FairyInfo>?> =
|
||||
_compoundFairyInfosLiveData
|
||||
val compoundFairyInfosLiveData: MutableLiveData<SparseArray<FairyInfo>?> = _compoundFairyInfosLiveData
|
||||
|
||||
private val _testResultLiveData = MutableLiveData<Event<FairyInfo>?>()
|
||||
val testResultLiveData: MutableLiveData<Event<FairyInfo>?> = _testResultLiveData
|
||||
@@ -75,26 +62,17 @@ class FairyViewModel : BaseViewModel() {
|
||||
private val _testLegendResultLiveData = MutableLiveData<Event<FairyInfo>?>()
|
||||
val testLegendResultLiveData: MutableLiveData<Event<FairyInfo>?> = _testLegendResultLiveData
|
||||
|
||||
private val _resolveResultLiveData = MutableLiveData<Event<ResolveInfo>?>()
|
||||
val resolveResultLiveData: MutableLiveData<Event<ResolveInfo>?> = _resolveResultLiveData
|
||||
|
||||
private val _testRecordLiveData = MutableLiveData<ListResult<TestFairyRecordInfo>>()
|
||||
val testRecordLiveData: LiveData<ListResult<TestFairyRecordInfo>> = _testRecordLiveData
|
||||
|
||||
private val _exchangeGiftListLiveData = MutableLiveData<List<ExchangeGiftInfo>?>()
|
||||
val exchangeGiftListLiveData: MutableLiveData<List<ExchangeGiftInfo>?> =
|
||||
_exchangeGiftListLiveData
|
||||
val exchangeGiftListLiveData: MutableLiveData<List<ExchangeGiftInfo>?> = _exchangeGiftListLiveData
|
||||
|
||||
private val _exchangeGiftLiveData = MutableLiveData<Event<ExchangeGiftInfo>>()
|
||||
val exchangeGiftLiveData: LiveData<Event<ExchangeGiftInfo>> = _exchangeGiftLiveData
|
||||
|
||||
//精灵召唤列表
|
||||
private val _fairyCallInfoLiveData = MutableLiveData<List<ExchangeGiftInfo>?>()
|
||||
val fairyCallInfoLiveData: MutableLiveData<List<ExchangeGiftInfo>?> = _fairyCallInfoLiveData
|
||||
|
||||
private val _debrisExchangeListLiveData = MutableLiveData<List<ExchangeGiftInfo>?>()
|
||||
val debrisExchangeListLiveData: MutableLiveData<List<ExchangeGiftInfo>?> =
|
||||
_debrisExchangeListLiveData
|
||||
val debrisExchangeListLiveData: MutableLiveData<List<ExchangeGiftInfo>?> = _debrisExchangeListLiveData
|
||||
|
||||
private val _debrisExchangeLiveData = MutableLiveData<Event<ExchangeGiftInfo>>()
|
||||
val debrisExchangeLiveData: LiveData<Event<ExchangeGiftInfo>> = _debrisExchangeLiveData
|
||||
@@ -107,9 +85,6 @@ class FairyViewModel : BaseViewModel() {
|
||||
val exchangeDebrisRecordLiveData: LiveData<ListResult<ExchangeGiftInfo>> =
|
||||
_exchangeDebrisRecordLiveData
|
||||
|
||||
private val _buyDebrisLiveData = MutableLiveData<Event<Int>>()
|
||||
val buyDebrisLiveData: LiveData<Event<Int>> = _buyDebrisLiveData
|
||||
|
||||
init {
|
||||
initPrizeInfoList()
|
||||
}
|
||||
@@ -222,21 +197,6 @@ class FairyViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 精灵召唤列表
|
||||
*/
|
||||
fun getFairyCallInfo() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_myFairyInfoLiveData.value = null
|
||||
it.message.toast()
|
||||
},
|
||||
block = {
|
||||
_myFairyInfoLiveData.value = TreasureFairyModel.getMyFairyInfo()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getFriendsList(nick: String? = null) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
@@ -298,21 +258,20 @@ class FairyViewModel : BaseViewModel() {
|
||||
_compoundFairyInfosLiveData.value = null
|
||||
_testLegendResultLiveData.value = null
|
||||
_testResultLiveData.value = null
|
||||
_resolveResultLiveData.value = null
|
||||
val myFairyInfo = _myFairyInfoLiveData.value
|
||||
myFairyInfo?.lowElves?.forEach {
|
||||
it.selectedNum = 0
|
||||
}
|
||||
myFairyInfo?.highElves?.forEach {
|
||||
myFairyInfo?.middleElves?.forEach {
|
||||
it.selectedNum = 0
|
||||
}
|
||||
_myFairyInfoLiveData.value = myFairyInfo
|
||||
}
|
||||
|
||||
fun addTestFairy(fairyInfo: FairyInfo, size: Int) {
|
||||
fun addTestFairy(fairyInfo: FairyInfo) {
|
||||
val array = _compoundFairyInfosLiveData.value ?: SparseArray()
|
||||
|
||||
if (array.size() >= size) {
|
||||
if (array.size() >= 3) {
|
||||
"試煉爐已滿!".toast()
|
||||
} else {
|
||||
if (fairyInfo.elfNum == 0) {
|
||||
@@ -354,9 +313,9 @@ class FairyViewModel : BaseViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun oneKeyAdd(fairyInfos: List<FairyInfo>, size: Int) {
|
||||
fun oneKeyAdd(fairyInfos: List<FairyInfo>) {
|
||||
val compoundFairyInfos = _compoundFairyInfosLiveData.value ?: SparseArray()
|
||||
var needNum = size - compoundFairyInfos.size()
|
||||
var needNum = 3 - compoundFairyInfos.size()
|
||||
if (needNum == 0) {
|
||||
"試煉爐已滿!".toast()
|
||||
return
|
||||
@@ -368,7 +327,7 @@ class FairyViewModel : BaseViewModel() {
|
||||
compoundFairyInfos.put(nextIndex(compoundFairyInfos), it)
|
||||
}
|
||||
}
|
||||
if (needNum <= size && needNum != 0) {
|
||||
if (needNum <= 3 && needNum != 0) {
|
||||
"精靈數量不足".toast()
|
||||
return
|
||||
}
|
||||
@@ -383,27 +342,21 @@ class FairyViewModel : BaseViewModel() {
|
||||
fairyInfos.get(1) == null -> {
|
||||
1
|
||||
}
|
||||
fairyInfos.get(2) == null -> {
|
||||
2
|
||||
}
|
||||
fairyInfos.get(3) == null -> {
|
||||
3
|
||||
}
|
||||
else -> {
|
||||
4
|
||||
2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun testFairy(level: Int): Boolean {
|
||||
val fairyInfos = _compoundFairyInfosLiveData.value ?: SparseArray()
|
||||
if (fairyInfos.size() != 5) {
|
||||
if (fairyInfos.size() != 3) {
|
||||
"精靈數量不足".toast()
|
||||
return false
|
||||
}
|
||||
safeLaunch(
|
||||
onError = {
|
||||
if (level == MyFairyItemView.LEGEND) {
|
||||
if (level == MyFairyItemView.EPIC) {
|
||||
_testLegendResultLiveData.value = null
|
||||
} else {
|
||||
_testResultLiveData.value = null
|
||||
@@ -418,7 +371,7 @@ class FairyViewModel : BaseViewModel() {
|
||||
}
|
||||
fairyTestParam.level = level
|
||||
val result = TreasureFairyModel.testFairy(fairyTestParam)
|
||||
(if (level == MyFairyItemView.LEGEND) {
|
||||
(if (level == MyFairyItemView.EPIC) {
|
||||
_testLegendResultLiveData
|
||||
} else {
|
||||
_testResultLiveData
|
||||
@@ -429,30 +382,6 @@ class FairyViewModel : BaseViewModel() {
|
||||
return true
|
||||
}
|
||||
|
||||
fun resolveFairy(): Boolean {
|
||||
val fairyInfos = _compoundFairyInfosLiveData.value ?: SparseArray()
|
||||
if (fairyInfos.size() != 1) {
|
||||
"精靈數量不足".toast()
|
||||
return false
|
||||
}
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_resolveResultLiveData.value = null
|
||||
it.message.toast()
|
||||
},
|
||||
block = {
|
||||
val fairyTestParam = FairyResolveParam()
|
||||
fairyInfos.forEach { _, value ->
|
||||
fairyTestParam.expendList.add(Compound(value.elfId, 1))
|
||||
}
|
||||
val result = TreasureFairyModel.resolveFairy(fairyTestParam)
|
||||
_resolveResultLiveData.value = result?.let { Event(it[0]) }
|
||||
getMyFairyInfo()
|
||||
}
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
fun getTestFairyRecordList(
|
||||
page: Int,
|
||||
pageSize: Int
|
||||
@@ -480,18 +409,6 @@ class FairyViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
//精灵召唤列表
|
||||
fun getFairyCallList() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_fairyCallInfoLiveData.value = null
|
||||
},
|
||||
block = {
|
||||
val result = TreasureFairyModel.getFairyCallList()
|
||||
_fairyCallInfoLiveData.value = result
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getDebrisExchangeList() {
|
||||
safeLaunch(
|
||||
@@ -518,7 +435,6 @@ class FairyViewModel : BaseViewModel() {
|
||||
val result = TreasureFairyModel.exchangeGift(itemId)
|
||||
_debrisExchangeLiveData.value = result?.let { Event(it) }
|
||||
_myFairyInfoLiveData.value = TreasureFairyModel.getMyFairyInfo()
|
||||
initDrawInfo()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,21 +468,4 @@ class FairyViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
fun buyDebris(num: Int, uid: String) {
|
||||
safeLaunch(
|
||||
block = {
|
||||
TreasureFairyModel.buyDebris(num, uid)
|
||||
|
||||
_drawInfoLiveData.value?.apply {
|
||||
this.drawTicketNum = this.drawTicketNum + num
|
||||
_drawInfoLiveData.value = this
|
||||
}
|
||||
|
||||
initDrawInfo()
|
||||
|
||||
_buyDebrisLiveData.value = Event(num)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@@ -10,26 +10,24 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.*
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.toColorInt
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import com.alibaba.fastjson.JSON
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseViewBindingActivity
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager
|
||||
import com.yizhuan.erban.databinding.TreasureFairyDialogHomeBinding
|
||||
import com.yizhuan.erban.treasure_box.activity.TreasureBoxActivity
|
||||
import com.yizhuan.erban.treasurefairy.dialog.*
|
||||
import com.yizhuan.erban.treasurefairy.dialog.ForestFairyDialog
|
||||
import com.yizhuan.erban.treasurefairy.dialog.HomeMorePopupWindow
|
||||
import com.yizhuan.erban.treasurefairy.dialog.HomePrizeDialog
|
||||
import com.yizhuan.erban.treasurefairy.dialog.MyFairyDialog
|
||||
import com.yizhuan.erban.treasurefairy.view.CustomDrawable
|
||||
import com.yizhuan.erban.ui.webview.FairyDialogWebViewActivity
|
||||
import com.yizhuan.erban.utils.KeyBoardUtils
|
||||
import com.yizhuan.erban.utils.SpannableBuilder
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
@@ -42,11 +40,7 @@ import com.yizhuan.xchat_android_core.manager.RoomEvent
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.DrawInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.PrizeInfo
|
||||
import com.yizhuan.xchat_android_library.common.SpConstants
|
||||
import com.yizhuan.xchat_android_library.common.util.SPUtils
|
||||
import com.yizhuan.xchat_android_library.utils.FormatUtils
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import com.yizhuan.xchat_android_library.utils.TimeUtils
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
@@ -70,8 +64,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
|
||||
private var isCheck = false
|
||||
|
||||
private var mPrice = -1
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
@@ -104,75 +96,16 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
ScreenUtil.screenHeight - ScreenUtil.getStatusBarHeight(this)
|
||||
)
|
||||
window.setGravity(Gravity.BOTTOM)
|
||||
|
||||
binding.fairyItem0.isSelected = true
|
||||
looperHintPrize()
|
||||
|
||||
binding.viewPrice1.setOnClickListener {
|
||||
setFairyPriceSelect(1)
|
||||
binding.tvKeyNum.setOnClickListener {
|
||||
FairyDialogWebViewActivity.start(this, UriProvider.getFairyKey())
|
||||
}
|
||||
binding.viewPrice2.setOnClickListener {
|
||||
setFairyPriceSelect(2)
|
||||
}
|
||||
binding.viewPrice3.setOnClickListener {
|
||||
setFairyPriceSelect(3)
|
||||
}
|
||||
|
||||
binding.etQuantity.doAfterTextChanged {
|
||||
try {
|
||||
mPrice = it.toString().toInt()
|
||||
if (mPrice > TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT) {
|
||||
mPrice = TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT
|
||||
binding.etQuantity.setText(mPrice.toString())
|
||||
binding.etQuantity.setSelection(binding.etQuantity.text.length)
|
||||
SingleToastUtil.showToast(
|
||||
getString(
|
||||
R.string.treasure_box_activity_treasureboxactivity_01,
|
||||
TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT
|
||||
)
|
||||
)
|
||||
}
|
||||
setFairyPriceSelect(0)
|
||||
} catch (e: NumberFormatException) {
|
||||
e.printStackTrace()
|
||||
mPrice = -1
|
||||
}
|
||||
}
|
||||
|
||||
binding.tvBuy.setOnClickListener {
|
||||
if (mPrice < 1) {
|
||||
toast("請選擇購買的碎片數量")
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val date = SPUtils.getLong(SpConstants.FAIRY_BUY_DEBRIS, 0L)
|
||||
if (TimeUtils.isToday(date)) {
|
||||
viewModel.buyDebris(
|
||||
mPrice,
|
||||
AuthModel.get().currentUid.toString()
|
||||
)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
FairyBuyDebrisDialog.newInstance(mPrice).show(context)
|
||||
}
|
||||
|
||||
viewModel.buyDebrisLiveData.observe(this) {
|
||||
val date = SPUtils.getLong(SpConstants.FAIRY_BUY_SUCCESS, 0L)
|
||||
if (TimeUtils.isToday(date)) {
|
||||
ToastUtils.show("購買碎片成功")
|
||||
return@observe
|
||||
}
|
||||
|
||||
FairyBuySuccessDialog.newInstance(it.peekContent()).show(this)
|
||||
|
||||
}
|
||||
|
||||
binding.ivMyFairy.setOnClickListener {
|
||||
MyFairyDialog.newInstance().show(this)
|
||||
}
|
||||
binding.ivFairyStore.setOnClickListener {
|
||||
ExchangeFairyDialog.newInstance().show(context)
|
||||
binding.ivFairyTreasure.setOnClickListener {
|
||||
ForestFairyDialog.newInstance().show(this)
|
||||
}
|
||||
binding.ivOpen1.setOnClickListener {
|
||||
if (checkKeyNum(1)) {
|
||||
@@ -219,16 +152,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
isCheck = isChecked
|
||||
}
|
||||
|
||||
binding.viewBgLuckyValue.setOnClickListener {
|
||||
binding.ivRefresh.startAnimation(
|
||||
AnimationUtils.loadAnimation(
|
||||
this,
|
||||
R.anim.comm_loading
|
||||
)
|
||||
)
|
||||
viewModel.initDrawInfo()
|
||||
}
|
||||
|
||||
viewModel.prizeInfoListLiveData.observe(this) {
|
||||
it?.forEachIndexed { index, prizeInfo ->
|
||||
if (index < fairyItems.size) {
|
||||
@@ -243,9 +166,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
?.indexOfFirst { prize ->
|
||||
it[0].itemIndex == prize.itemIndex
|
||||
} ?: -2
|
||||
if (targetIndex >= fairyItems.size) {
|
||||
targetIndex = 0
|
||||
}
|
||||
if (targetIndex == -2) {
|
||||
viewModel.initPrizeInfoList()
|
||||
}
|
||||
@@ -257,8 +177,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
}
|
||||
|
||||
viewModel.drawInfoLiveData.observe(this) {
|
||||
binding.ivRefresh.clearAnimation()
|
||||
|
||||
it?.let {
|
||||
drawInfo = it
|
||||
binding.tvKeyNum.text = FormatUtils.formatBigNum(it.drawTicketNum.toString())
|
||||
@@ -266,12 +184,9 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
|
||||
binding.tvShortLuckyValue.text =
|
||||
SpannableBuilder()
|
||||
.append("還差", ForegroundColorSpan("#59FDFF".toColorInt()))
|
||||
.append("幸運值達到", ForegroundColorSpan("#59FDFF".toColorInt()))
|
||||
.append("${it.needLuckyNum}", ForegroundColorSpan("#FFE8AA".toColorInt()))
|
||||
.append(
|
||||
"幸運值,額外獲贈傳説精靈",
|
||||
ForegroundColorSpan("#59FDFF".toColorInt())
|
||||
)
|
||||
.append("后,下次奪寶獲贈精靈球", ForegroundColorSpan("#59FDFF".toColorInt()))
|
||||
.build()
|
||||
binding.ivLuckyStone.post {
|
||||
val drawable =
|
||||
@@ -287,8 +202,7 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
0f,
|
||||
binding.ivLuckyStone.width.toFloat(),
|
||||
binding.ivLuckyStone.height *
|
||||
(1 - it.luckyNum / (it.luckyNum + it.needLuckyNum).toFloat()
|
||||
.coerceAtLeast(1f)),
|
||||
(1 - it.luckyNum / it.needLuckyNum.toFloat().coerceAtLeast(1f)),
|
||||
Path.Direction.CW
|
||||
)
|
||||
drawable.setSrcPath(path)
|
||||
@@ -299,83 +213,21 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
|
||||
viewModel.showGetKeyLiveData.observe(this) {
|
||||
it.getContentIfNotHandled()?.let {
|
||||
DialogManager(context).showOkCancelDialog(
|
||||
"購買限時裝扮活動奪寶券",
|
||||
"去參与",
|
||||
"取消"
|
||||
) {
|
||||
DialogManager(context).showOkCancelDialog("購買限時裝扮活動奪寶券", "去參与", "取消") {
|
||||
FairyDialogWebViewActivity.start(context, UriProvider.getFairyKey())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setFairyPriceSelect(pos: Int) {
|
||||
if (pos == 0) {
|
||||
binding.viewPrice1.isSelected = false
|
||||
binding.viewPrice2.isSelected = false
|
||||
binding.viewPrice3.isSelected = false
|
||||
binding.ivDebris1.alpha = 0.4f
|
||||
binding.ivDebris2.alpha = 0.4f
|
||||
binding.ivDebris3.alpha = 0.4f
|
||||
binding.tvOne.alpha = 0.4f
|
||||
binding.tvTwo.alpha = 0.4f
|
||||
binding.tvThree.alpha = 0.4f
|
||||
return
|
||||
}
|
||||
|
||||
binding.etQuantity.text = null
|
||||
KeyBoardUtils.hideKeyBoard(this, binding.etQuantity)
|
||||
binding.etQuantity.clearFocus()
|
||||
|
||||
when (pos) {
|
||||
1 -> {
|
||||
mPrice = 1
|
||||
binding.viewPrice1.isSelected = true
|
||||
binding.viewPrice2.isSelected = false
|
||||
binding.viewPrice3.isSelected = false
|
||||
binding.ivDebris1.alpha = 1f
|
||||
binding.ivDebris2.alpha = 0.4f
|
||||
binding.ivDebris3.alpha = 0.4f
|
||||
binding.tvOne.alpha = 1f
|
||||
binding.tvTwo.alpha = 0.4f
|
||||
binding.tvThree.alpha = 0.4f
|
||||
}
|
||||
|
||||
2 -> {
|
||||
mPrice = 10
|
||||
binding.viewPrice1.isSelected = false
|
||||
binding.viewPrice2.isSelected = true
|
||||
binding.viewPrice3.isSelected = false
|
||||
binding.ivDebris1.alpha = 0.4f
|
||||
binding.ivDebris2.alpha = 1f
|
||||
binding.ivDebris3.alpha = 0.4f
|
||||
binding.tvOne.alpha = 0.4f
|
||||
binding.tvTwo.alpha = 1f
|
||||
binding.tvThree.alpha = 0.4f
|
||||
}
|
||||
|
||||
3 -> {
|
||||
mPrice = 100
|
||||
binding.viewPrice1.isSelected = false
|
||||
binding.viewPrice2.isSelected = false
|
||||
binding.viewPrice3.isSelected = true
|
||||
binding.ivDebris1.alpha = 0.4f
|
||||
binding.ivDebris2.alpha = 0.4f
|
||||
binding.ivDebris3.alpha = 1f
|
||||
binding.tvOne.alpha = 0.4f
|
||||
binding.tvTwo.alpha = 0.4f
|
||||
binding.tvThree.alpha = 1f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkKeyNum(num: Int): Boolean {
|
||||
val keyNum = drawInfo?.drawTicketNum ?: 0
|
||||
if (keyNum >= num) {
|
||||
return true
|
||||
}
|
||||
FairyBuyDebrisModifyQuantityDialog.newInstance(num).show(this)
|
||||
DialogManager(context).showOkCancelDialog("購買限時裝扮活動奪寶券", "去參与", "取消") {
|
||||
FairyDialogWebViewActivity.start(context, UriProvider.getFairyKey())
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -401,7 +253,7 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
fairyItems[selectIndex].isSelected = true
|
||||
}
|
||||
if ((selectIndex == targetIndex || targetIndex == -2) && minCount >= 24) {
|
||||
if (!isCheck) {
|
||||
if(!isCheck) {
|
||||
HomePrizeDialog.newInstance().show(context)
|
||||
}
|
||||
disposable?.dispose()
|
||||
@@ -468,10 +320,10 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
*/
|
||||
override fun onReceivedNimBroadcastMessage(body: String?) {
|
||||
val baseProtocol: BaseProtocol<*> = try {
|
||||
JSON.parseObject(body, BaseProtocol::class.java)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
} ?: return
|
||||
JSON.parseObject(body, BaseProtocol::class.java)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
} ?: return
|
||||
when (baseProtocol.first) {
|
||||
CustomAttachment.CUSTOM_MSG_BOX -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
val roomBoxPrizeAttachment = RoomBoxPrizeAttachment(
|
||||
@@ -512,7 +364,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
CustomAttachment.CUSTOM_MSG_LUCKY_SEA -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL) {
|
||||
val attachment = RoomLuckySeaAttachment(
|
||||
CustomAttachment.CUSTOM_MSG_LUCKY_SEA,
|
||||
@@ -532,7 +383,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
IMNetEaseManager.get()
|
||||
.noticeRoomEvent(message, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY)
|
||||
}
|
||||
|
||||
CustomAttachment.CUSTOM_MSG_LUCKY_GIFT -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY || baseProtocol.second == CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
val attachment =
|
||||
RoomReceivedLuckyGiftAttachment(CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY)
|
||||
@@ -547,7 +397,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
IMNetEaseManager.get().noticeServiceLuckyBagNotice(message)
|
||||
IMNetEaseManager.get().addMessages(message)
|
||||
}
|
||||
|
||||
CustomAttachment.CUSTOM_MSG_FAIRY -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5) {
|
||||
val attachment = FairyMsgAttachment(
|
||||
CustomAttachment.CUSTOM_MSG_FAIRY,
|
||||
@@ -563,7 +412,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
)
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.FAIRY_DRAW_GIFT_L5)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
@@ -12,8 +12,7 @@ class ExchangeDebrisAdapter :
|
||||
override fun convert(helper: BaseViewHolder, item: ExchangeGiftInfo) {
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_prize_icon), item.rewardPicUrl)
|
||||
helper.setText(R.id.tv_prize_name, item.getPrizeName())
|
||||
|
||||
helper.setText(R.id.tv_value, item.expendNum.toString())
|
||||
helper.setText(R.id.tv_need_num, "${item.expendNum}")
|
||||
helper.addOnClickListener(R.id.tv_exchange)
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,13 @@ class ExchangeFairyRecordAdapter :
|
||||
helper.setText(R.id.tv_time_year, formatYear.format(item.createTime))
|
||||
helper.setText(R.id.tv_time_hour, formatHour.format(item.createTime))
|
||||
helper.setText(R.id.tv_prize_name, "${item.rewardName}x${item.rewardNum}")
|
||||
helper.setText(
|
||||
R.id.tv_prize_type, when (item.convertLevel) {
|
||||
1 -> mContext.getString(R.string.fairy_primary_call)
|
||||
2 -> mContext.getString(R.string.fairy_epic_call)
|
||||
else -> mContext.getString(R.string.fairy_legend_call)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
package com.yizhuan.erban.treasurefairy.adapter
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ExchangeGiftInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.PropItemInfo
|
||||
|
||||
class ExchangeSummonAdapter :
|
||||
BaseQuickAdapter<ExchangeGiftInfo, BaseViewHolder>(R.layout.treasure_fairy_item_exchange_summon) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: ExchangeGiftInfo) {
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_prize_icon), item.rewardPicUrl)
|
||||
helper.setText(R.id.tv_prize_name, item.getPrizeName())
|
||||
|
||||
val adapter: BaseQuickAdapter<PropItemInfo, BaseViewHolder> =
|
||||
object : BaseQuickAdapter<PropItemInfo, BaseViewHolder>(R.layout.item_exchange_debris) {
|
||||
override fun convert(helper: BaseViewHolder, item: PropItemInfo) {
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_icon), item.picUrl)
|
||||
helper.setText(R.id.tv_num, "${item.propName}x${item.propNum}")
|
||||
}
|
||||
}
|
||||
helper.getView<RecyclerView>(R.id.mRecyclerView).adapter = adapter
|
||||
item.propItems?.let {
|
||||
adapter.setNewData(it)
|
||||
}
|
||||
|
||||
helper.addOnClickListener(R.id.tv_exchange)
|
||||
}
|
||||
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
package com.yizhuan.erban.treasurefairy.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.ui.utils.load
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyInfo
|
||||
import java.util.*
|
||||
|
||||
class ResolveFairyAdapter :
|
||||
BaseQuickAdapter<FairyInfo, BaseViewHolder>(R.layout.treasure_fairy_item_resolve_fairy) {
|
||||
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: FairyInfo) {
|
||||
helper.getView<ImageView>(R.id.iv_fairy_icon).load(item.elfPicUrl)
|
||||
helper.setText(R.id.tv_fairy_num, "${item.selectedNum}/${item.elfNum}")
|
||||
helper.setText(R.id.tv_fairy_name, item.elfName)
|
||||
helper.setBackgroundRes(
|
||||
R.id.ll_root,
|
||||
if (item.selectedNum > 0) R.drawable.treasure_fairy_bg_test_fairy_item_select else 0
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
package com.yizhuan.erban.treasurefairy.adapter
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ResolveInfo
|
||||
|
||||
class ResolveFairyResultAdapter :
|
||||
BaseQuickAdapter<ResolveInfo, BaseViewHolder>(R.layout.treasure_fairy_item_forest_prize_single_resolve) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: ResolveInfo) {
|
||||
helper.setText(R.id.tv_prize_name, "x${item.pieceNum}")
|
||||
}
|
||||
|
||||
}
|
@@ -19,9 +19,8 @@ class TestFairyRecordAdapter :
|
||||
helper.setText(R.id.tv_time_hour, formatHour.format(item.createTime))
|
||||
helper.setText(R.id.tv_prize_name, item.elfName)
|
||||
helper.setText(
|
||||
R.id.tv_prize_type, when (item.type) {
|
||||
4 -> "傳說試煉"
|
||||
7 -> "精靈分解"
|
||||
R.id.tv_prize_type, when (item.elfLevel) {
|
||||
2 -> "史詩試煉"
|
||||
else -> "傳說試煉"
|
||||
}
|
||||
)
|
||||
|
@@ -13,7 +13,6 @@ import com.yizhuan.erban.databinding.TreasureFairyDialogExchangeBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.erban.treasurefairy.fragment.ExchangeDebrisFragment
|
||||
import com.yizhuan.erban.treasurefairy.fragment.ExchangeFairyFragment
|
||||
import com.yizhuan.erban.treasurefairy.fragment.ExchangeSummonFragment
|
||||
|
||||
class ExchangeFairyDialog : BaseDialog<TreasureFairyDialogExchangeBinding>() {
|
||||
|
||||
@@ -33,31 +32,31 @@ class ExchangeFairyDialog : BaseDialog<TreasureFairyDialogExchangeBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.ivBack.setOnClickListener {
|
||||
binding?.ivBack?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.tvRecord.setOnClickListener {
|
||||
binding?.tvRecord?.setOnClickListener {
|
||||
ExchangeRecordDialog.newInstance().show(context)
|
||||
}
|
||||
binding.rg.setOnCheckedChangeListener { _, checkedId ->
|
||||
binding?.rg?.setOnCheckedChangeListener { _, checkedId ->
|
||||
when (checkedId) {
|
||||
R.id.rb_epic -> binding.viewPager.currentItem = 0
|
||||
R.id.rb_legend -> binding.viewPager.currentItem = 1
|
||||
R.id.rb_epic -> binding?.viewPager?.currentItem = 0
|
||||
R.id.rb_legend -> binding?.viewPager?.currentItem = 1
|
||||
}
|
||||
}
|
||||
binding.viewPager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
binding?.viewPager?.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
when (position) {
|
||||
0 -> binding.rg.check(R.id.rb_epic)
|
||||
1 -> binding.rg.check(R.id.rb_legend)
|
||||
0 -> binding?.rg?.check(R.id.rb_epic)
|
||||
1 -> binding?.rg?.check(R.id.rb_legend)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
binding.viewPager.adapter = RoomVPAdapter(
|
||||
binding?.viewPager?.adapter = RoomVPAdapter(
|
||||
childFragmentManager,
|
||||
listOf(
|
||||
ExchangeSummonFragment.newInstance(),
|
||||
ExchangeFairyFragment.newInstance(),
|
||||
ExchangeDebrisFragment.newInstance()
|
||||
)
|
||||
)
|
||||
|
@@ -1,65 +0,0 @@
|
||||
package com.yizhuan.erban.treasurefairy.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.TreasureFairyDialogBuyDebrisBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_library.common.SpConstants
|
||||
import com.yizhuan.xchat_android_library.common.util.SPUtils
|
||||
|
||||
/**
|
||||
* 购买碎片
|
||||
*/
|
||||
class FairyBuyDebrisDialog : BaseDialog<TreasureFairyDialogBuyDebrisBinding>() {
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
override var gravity = Gravity.CENTER
|
||||
private val viewModel: FairyViewModel by activityViewModels()
|
||||
|
||||
companion object {
|
||||
fun newInstance(num: Int): FairyBuyDebrisDialog {
|
||||
val args = Bundle()
|
||||
args.putInt("num", num)
|
||||
val fragment = FairyBuyDebrisDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val num by lazy { requireArguments().getInt("num") }
|
||||
private val price by lazy { AvRoomDataManager.get().mSeizeTreasureSwitchVo?.price ?: 0 }
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.tvDebrisNum.text = getString(R.string.buy_debris, num)
|
||||
binding.tvPrizeName.text = (num * price).toString()
|
||||
|
||||
binding.cbPay.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
SPUtils.putLong(SpConstants.FAIRY_BUY_DEBRIS, System.currentTimeMillis())
|
||||
} else {
|
||||
SPUtils.putLong(SpConstants.FAIRY_BUY_DEBRIS, 0L)
|
||||
}
|
||||
}
|
||||
|
||||
binding.tvBuy.setOnClickListener {
|
||||
viewModel.buyDebris(num, AuthModel.get().currentUid.toString())
|
||||
}
|
||||
|
||||
viewModel.buyDebrisLiveData.observe(this) {
|
||||
it.getContentIfNotHandled()?.let {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,102 +0,0 @@
|
||||
package com.yizhuan.erban.treasurefairy.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.TreasureFairyDialogBuyDebrisModifyQuantityBinding
|
||||
import com.yizhuan.erban.treasure_box.activity.TreasureBoxActivity
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.utils.StringUtils
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
|
||||
/**
|
||||
* 购买碎片
|
||||
*/
|
||||
class FairyBuyDebrisModifyQuantityDialog :
|
||||
BaseDialog<TreasureFairyDialogBuyDebrisModifyQuantityBinding>() {
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
override var gravity = Gravity.CENTER
|
||||
private val viewModel: FairyViewModel by activityViewModels()
|
||||
|
||||
companion object {
|
||||
fun newInstance(num: Int): FairyBuyDebrisModifyQuantityDialog {
|
||||
val args = Bundle()
|
||||
args.putInt("num", num)
|
||||
val fragment = FairyBuyDebrisModifyQuantityDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private var num = 0
|
||||
private val price by lazy { AvRoomDataManager.get().mSeizeTreasureSwitchVo?.price ?: 0 }
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
num = requireArguments().getInt("num")
|
||||
|
||||
binding.etNum.setText(num.toString())
|
||||
binding.tvPrizeName.text = (num * price).toString()
|
||||
|
||||
binding.ivDecrease.setOnClickListener {
|
||||
num = (num - 10).coerceAtLeast(1)
|
||||
binding.etNum.setText(num.toString())
|
||||
binding.etNum.setSelection(num.toString().length)
|
||||
binding.tvPrizeName.text = (num * price).toString()
|
||||
}
|
||||
|
||||
binding.ivIncrease.setOnClickListener {
|
||||
num = (num + 10).coerceAtMost(200)
|
||||
binding.etNum.setText(num.toString())
|
||||
binding.etNum.setSelection(num.toString().length)
|
||||
binding.tvPrizeName.text = (num * price).toString()
|
||||
}
|
||||
|
||||
binding.etNum.doAfterTextChanged {
|
||||
var n = StringUtils.toInt(binding.etNum.text.toString(), 0)
|
||||
|
||||
if (n < 1) {
|
||||
binding.etNum.setText("1")
|
||||
binding.etNum.setSelection(1)
|
||||
num = 1
|
||||
return@doAfterTextChanged
|
||||
}
|
||||
|
||||
if (n > TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT) {
|
||||
n = TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT
|
||||
binding.etNum.setText(n.toString())
|
||||
binding.etNum.setSelection(n.toString().length)
|
||||
SingleToastUtil.showToast(
|
||||
getString(
|
||||
R.string.treasure_box_activity_treasureboxactivity_01,
|
||||
TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT
|
||||
)
|
||||
)
|
||||
}
|
||||
binding.tvPrizeName.text = (n * price).toString()
|
||||
num = n
|
||||
}
|
||||
|
||||
|
||||
binding.tvBuy.setOnClickListener {
|
||||
viewModel.buyDebris(num, AuthModel.get().currentUid.toString())
|
||||
}
|
||||
|
||||
viewModel.buyDebrisLiveData.observe(this) {
|
||||
it.getContentIfNotHandled()?.let {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package com.yizhuan.erban.treasurefairy.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.TreasureFairyDialogBuySuccessBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.xchat_android_library.common.SpConstants
|
||||
import com.yizhuan.xchat_android_library.common.util.SPUtils
|
||||
|
||||
/**
|
||||
* 购买碎片成功
|
||||
*/
|
||||
class FairyBuySuccessDialog : BaseDialog<TreasureFairyDialogBuySuccessBinding>() {
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
override var gravity = Gravity.CENTER
|
||||
|
||||
companion object {
|
||||
fun newInstance(num: Int): FairyBuySuccessDialog {
|
||||
val args = Bundle()
|
||||
args.putSerializable("num", num)
|
||||
val fragment = FairyBuySuccessDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val num by lazy { requireArguments().getInt("num") }
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
override fun init() {
|
||||
binding.tvDebrisNum.text = "x${num}"
|
||||
|
||||
binding.cbPay.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
if (isChecked) {
|
||||
SPUtils.putLong(SpConstants.FAIRY_BUY_SUCCESS, System.currentTimeMillis())
|
||||
} else {
|
||||
SPUtils.putLong(SpConstants.FAIRY_BUY_SUCCESS, 0L)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -34,7 +34,7 @@ class HomePrizeDialog : BaseDialog<TreasureFairyDialogHomePrizeBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.rootView.setOnClickListener {
|
||||
binding?.rootView?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
val prizeInfoList = viewModel.resultLiveData.value?.peekContent()
|
||||
@@ -43,7 +43,7 @@ class HomePrizeDialog : BaseDialog<TreasureFairyDialogHomePrizeBinding>() {
|
||||
prizeAdapter = HomePrizeAdapter(isSingle)
|
||||
rvDelegate = RVDelegate.Builder<PrizeInfo>()
|
||||
.setAdapter(prizeAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setRecyclerView(binding?.recyclerView)
|
||||
.setLayoutManager(
|
||||
if (isSingle) {
|
||||
LinearLayoutManager(context)
|
||||
|
@@ -39,39 +39,39 @@ class MyFairyDialog : BaseDialog<TreasureFairyDialogMyFairyBinding>() {
|
||||
override fun init() {
|
||||
EventBus.getDefault().register(this)
|
||||
|
||||
binding.ivBack.setOnClickListener {
|
||||
binding?.ivBack?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.ivFairyTest.setOnClickListener {
|
||||
TestFairyDialog.newInstance().show(context)
|
||||
}
|
||||
binding.ivRecord.setOnClickListener {
|
||||
binding?.ivRecord?.setOnClickListener {
|
||||
MyFairyRecordDialog.newInstance().show(context)
|
||||
}
|
||||
binding.rg.setOnCheckedChangeListener { _, checkedId ->
|
||||
binding?.rg?.setOnCheckedChangeListener { _, checkedId ->
|
||||
when (checkedId) {
|
||||
R.id.rb_base -> binding.viewPager.currentItem = 0
|
||||
R.id.rb_legend -> binding.viewPager.currentItem = 1
|
||||
R.id.rb_base -> binding?.viewPager?.currentItem = 0
|
||||
R.id.rb_epic -> binding?.viewPager?.currentItem = 1
|
||||
R.id.rb_legend -> binding?.viewPager?.currentItem = 2
|
||||
}
|
||||
}
|
||||
binding.viewPager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
binding?.viewPager?.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
when (position) {
|
||||
0 -> binding.rg.check(R.id.rb_base)
|
||||
1 -> binding.rg.check(R.id.rb_legend)
|
||||
0 -> binding?.rg?.check(R.id.rb_base)
|
||||
1 -> binding?.rg?.check(R.id.rb_epic)
|
||||
2 -> binding?.rg?.check(R.id.rb_legend)
|
||||
}
|
||||
DemoCache.saveMyFairyIndex(position)
|
||||
}
|
||||
})
|
||||
binding.viewPager.adapter = RoomVPAdapter(
|
||||
binding?.viewPager?.adapter = RoomVPAdapter(
|
||||
childFragmentManager,
|
||||
listOf(
|
||||
MyFairyFragment.newInstance(MyFairyItemView.BASE),
|
||||
MyFairyFragment.newInstance(MyFairyItemView.EPIC),
|
||||
MyFairyFragment.newInstance(MyFairyItemView.LEGEND)
|
||||
)
|
||||
)
|
||||
|
||||
binding.viewPager.setCurrentItem(DemoCache.readMyFairyIndex(), false)
|
||||
binding?.viewPager?.setCurrentItem(DemoCache.readMyFairyIndex(), false)
|
||||
|
||||
viewModel.getMyFairyInfo()
|
||||
}
|
||||
|
@@ -1,56 +0,0 @@
|
||||
package com.yizhuan.erban.treasurefairy.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.TreasureFairyDialogResolveFairyResultBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.erban.treasurefairy.adapter.ResolveFairyResultAdapter
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ResolveInfo
|
||||
|
||||
class ResolveFairyResultDialog : BaseDialog<TreasureFairyDialogResolveFairyResultBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<ResolveInfo>
|
||||
private lateinit var prizeAdapter: ResolveFairyResultAdapter
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
override var gravity = Gravity.CENTER
|
||||
private val viewModel: FairyViewModel by activityViewModels()
|
||||
|
||||
companion object {
|
||||
fun newInstance(resolveInfo: ResolveInfo): ResolveFairyResultDialog {
|
||||
val args = Bundle()
|
||||
args.putSerializable("resolveInfo",resolveInfo)
|
||||
val fragment = ResolveFairyResultDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val resolveInfo by lazy { requireArguments().getSerializable("resolveInfo") as ResolveInfo }
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.tvClose.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
prizeAdapter = ResolveFairyResultAdapter()
|
||||
rvDelegate = RVDelegate.Builder<ResolveInfo>()
|
||||
.setAdapter(prizeAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setLayoutManager(
|
||||
LinearLayoutManager(context)
|
||||
)
|
||||
.build()
|
||||
|
||||
rvDelegate.setNewData(arrayListOf(resolveInfo))
|
||||
viewModel.cleanTestParam()
|
||||
viewModel.initDrawInfo()
|
||||
}
|
||||
|
||||
}
|
@@ -32,33 +32,33 @@ class TestFairyDialog : BaseDialog<TreasureFairyDialogTestFairyBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.ivBack.setOnClickListener {
|
||||
binding?.ivBack?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.tvRecord.setOnClickListener {
|
||||
binding?.tvRecord?.setOnClickListener {
|
||||
TestFairyRecordDialog.newInstance().show(context)
|
||||
}
|
||||
binding.rg.setOnCheckedChangeListener { _, checkedId ->
|
||||
binding?.rg?.setOnCheckedChangeListener { _, checkedId ->
|
||||
when (checkedId) {
|
||||
R.id.rb_epic -> binding.viewPager.currentItem = 0
|
||||
R.id.rb_legend -> binding.viewPager.currentItem = 1
|
||||
R.id.rb_epic -> binding?.viewPager?.currentItem = 0
|
||||
R.id.rb_legend -> binding?.viewPager?.currentItem = 1
|
||||
}
|
||||
}
|
||||
binding.viewPager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
binding?.viewPager?.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
when (position) {
|
||||
0 -> binding.rg.check(R.id.rb_epic)
|
||||
1 -> binding.rg.check(R.id.rb_legend)
|
||||
0 -> binding?.rg?.check(R.id.rb_epic)
|
||||
1 -> binding?.rg?.check(R.id.rb_legend)
|
||||
}
|
||||
viewModel.cleanTestParam()
|
||||
}
|
||||
})
|
||||
|
||||
binding.viewPager.adapter = RoomVPAdapter(
|
||||
binding?.viewPager?.adapter = RoomVPAdapter(
|
||||
childFragmentManager,
|
||||
listOf(
|
||||
TestFairyFragment.newInstance(MyFairyItemView.BASE),
|
||||
TestFairyFragment.newInstance(MyFairyItemView.LEGEND)
|
||||
TestFairyFragment.newInstance(MyFairyItemView.EPIC)
|
||||
)
|
||||
)
|
||||
viewModel.getMyFairyInfo()
|
||||
|
@@ -36,13 +36,13 @@ class TestFairyResultDialog : BaseDialog<TreasureFairyDialogTestFairyResultBindi
|
||||
private val fairyInfo by lazy { requireArguments().getSerializable("fairyInfo") as FairyInfo }
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.tvClose.setOnClickListener {
|
||||
binding?.tvClose?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
prizeAdapter = TestFairyResultAdapter()
|
||||
rvDelegate = RVDelegate.Builder<FairyInfo>()
|
||||
.setAdapter(prizeAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setRecyclerView(binding?.recyclerView)
|
||||
.setLayoutManager(
|
||||
LinearLayoutManager(context)
|
||||
)
|
||||
|
@@ -2,7 +2,6 @@ package com.yizhuan.erban.treasurefairy.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@@ -22,6 +21,7 @@ import com.yizhuan.xchat_android_core.utils.toast
|
||||
class ExchangeDebrisFragment :
|
||||
BaseViewBindingFragment<TreasureFairyFragmentExchangeDebrisBinding>() {
|
||||
|
||||
|
||||
companion object {
|
||||
fun newInstance(): ExchangeDebrisFragment {
|
||||
val args = Bundle()
|
||||
@@ -49,6 +49,7 @@ class ExchangeDebrisFragment :
|
||||
)
|
||||
.setLayoutManager(GridLayoutManager(context, 2, LinearLayoutManager.VERTICAL, false))
|
||||
.build()
|
||||
viewModel.getDebrisExchangeList()
|
||||
viewModel.debrisExchangeListLiveData.observe(viewLifecycleOwner) {
|
||||
rvDelegate.setNewData(it)
|
||||
}
|
||||
@@ -60,11 +61,8 @@ class ExchangeDebrisFragment :
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.getDebrisExchangeList()
|
||||
viewModel.getMyFairyInfo()
|
||||
|
||||
binding.llMyDebris.visibility = View.VISIBLE
|
||||
binding.rvMyFairy.visibility = View.GONE
|
||||
viewModel.myFairyInfoLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let {
|
||||
binding.tvDebrisNum.text = it.chipNum.toString()
|
||||
|
@@ -1,102 +0,0 @@
|
||||
package com.yizhuan.erban.treasurefairy.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.common.EmptyViewHelper
|
||||
import com.yizhuan.erban.databinding.TreasureFairyFragmentExchangeDebrisBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.erban.treasurefairy.adapter.ExchangeSummonAdapter
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
import com.yizhuan.erban.ui.utils.loadAvatar
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ExchangeGiftInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyInfo
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
|
||||
class ExchangeSummonFragment :
|
||||
BaseViewBindingFragment<TreasureFairyFragmentExchangeDebrisBinding>() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): ExchangeSummonFragment {
|
||||
val args = Bundle()
|
||||
val fragment = ExchangeSummonFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val viewModel: FairyViewModel by activityViewModels()
|
||||
private lateinit var rvDelegate: RVDelegate<ExchangeGiftInfo>
|
||||
private lateinit var exchangeSummonAdapter: ExchangeSummonAdapter
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
exchangeSummonAdapter = ExchangeSummonAdapter()
|
||||
rvDelegate = RVDelegate.Builder<ExchangeGiftInfo>()
|
||||
.setAdapter(exchangeSummonAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setEmptyView(
|
||||
EmptyViewHelper.createEmptyTextViewNoImage(
|
||||
context,
|
||||
getString(R.string.fairy_no_further_data_is_available)
|
||||
)
|
||||
)
|
||||
.setLayoutManager(GridLayoutManager(context, 2, LinearLayoutManager.VERTICAL, false))
|
||||
.build()
|
||||
viewModel.fairyCallInfoLiveData.observe(viewLifecycleOwner) {
|
||||
rvDelegate.setNewData(it)
|
||||
}
|
||||
exchangeSummonAdapter.setOnItemChildClickListener { _, _, position ->
|
||||
exchangeSummonAdapter.getItem(position)?.let {
|
||||
dialogManager.showTipsDialog("您將要兌換“${it.getPrizeName()}”", "兌換") {
|
||||
viewModel.debrisExchange(it.itemId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.getFairyCallList()
|
||||
viewModel.getMyFairyInfo()
|
||||
|
||||
viewModel.myFairyInfoLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let {
|
||||
binding.tvDebrisNum.text = it.chipNum.toString()
|
||||
}
|
||||
}
|
||||
|
||||
UserModel.get().cacheLoginUserInfo?.let {
|
||||
binding.ivAvatar.loadAvatar(it.avatar)
|
||||
binding.tvNickname.text = it.nick.subAndReplaceDot(7)
|
||||
}
|
||||
|
||||
viewModel.debrisExchangeLiveData.observe(viewLifecycleOwner) {
|
||||
it?.getContentIfNotHandled()?.let {
|
||||
"兌換成功~".toast()
|
||||
}
|
||||
}
|
||||
|
||||
val myFairyAdapter =
|
||||
object : BaseQuickAdapter<FairyInfo, BaseViewHolder>(R.layout.item_my_fairy) {
|
||||
override fun convert(helper: BaseViewHolder, item: FairyInfo) {
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_fairy), item.elfPicUrl)
|
||||
helper.setText(R.id.tv_count, item.elfNum.toString())
|
||||
}
|
||||
}
|
||||
binding.rvMyFairy.adapter = myFairyAdapter
|
||||
|
||||
viewModel.myFairyInfoLiveData.observe(this) {
|
||||
it?.let {
|
||||
myFairyAdapter.setNewData(it.highElves?.take(3))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -33,6 +33,8 @@ class MyFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentMyFairyBind
|
||||
binding.fairyItem0,
|
||||
binding.fairyItem1,
|
||||
binding.fairyItem2,
|
||||
binding.fairyItem3,
|
||||
binding.fairyItem4
|
||||
)
|
||||
fairyItems.forEach {
|
||||
it.setFairyType(fairyType)
|
||||
|
@@ -2,8 +2,6 @@ package com.yizhuan.erban.treasurefairy.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@@ -12,9 +10,7 @@ import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.common.EmptyViewHelper
|
||||
import com.yizhuan.erban.databinding.TreasureFairyFragmentTestFairyBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.erban.treasurefairy.adapter.ResolveFairyAdapter
|
||||
import com.yizhuan.erban.treasurefairy.adapter.TestFairyAdapter
|
||||
import com.yizhuan.erban.treasurefairy.dialog.ResolveFairyResultDialog
|
||||
import com.yizhuan.erban.treasurefairy.dialog.TestFairyResultDialog
|
||||
import com.yizhuan.erban.treasurefairy.view.MyFairyItemView
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
@@ -23,6 +19,7 @@ import com.yizhuan.xchat_android_core.treasurefairy.FairyInfo
|
||||
|
||||
class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairyBinding>() {
|
||||
|
||||
|
||||
companion object {
|
||||
fun newInstance(fairyType: Int): TestFairyFragment {
|
||||
val args = Bundle()
|
||||
@@ -37,7 +34,6 @@ class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairy
|
||||
private val viewModel: FairyViewModel by activityViewModels()
|
||||
private lateinit var rvDelegate: RVDelegate<FairyInfo>
|
||||
private lateinit var testFairyAdapter: TestFairyAdapter
|
||||
private lateinit var resolveFairyAdapter: ResolveFairyAdapter
|
||||
|
||||
private val showResultRunnable = Runnable {
|
||||
if (canShowResult) {
|
||||
@@ -55,69 +51,44 @@ class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairy
|
||||
resultNotShowed = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得精灵碎片
|
||||
*/
|
||||
private val showResolveResultRunnable = Runnable {
|
||||
if (canShowResult) {
|
||||
canShowResult = false
|
||||
binding.ivBegin.isEnabled = true
|
||||
viewModel.resolveResultLiveData.value?.peekContent()?.let {
|
||||
ResolveFairyResultDialog.newInstance(it).show(context)
|
||||
}
|
||||
} else {
|
||||
resultNotShowed = true
|
||||
}
|
||||
}
|
||||
private var canShowResult = false
|
||||
private var resultNotShowed = false
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
val fairyViews = listOf(
|
||||
binding.ivFairy0,
|
||||
binding.ivFairy1,
|
||||
binding.ivFairy2,
|
||||
binding.ivFairy3,
|
||||
binding.ivFairy4
|
||||
)
|
||||
val fairyResolveViews = listOf(binding.ivFairy3)
|
||||
val fairyViews = listOf(binding.ivFairy0, binding.ivFairy1, binding.ivFairy2)
|
||||
testFairyAdapter = TestFairyAdapter()
|
||||
resolveFairyAdapter = ResolveFairyAdapter()
|
||||
rvDelegate = RVDelegate.Builder<FairyInfo>()
|
||||
.setAdapter(if(fairyType == MyFairyItemView.BASE) resolveFairyAdapter else testFairyAdapter)
|
||||
.setEmptyView(
|
||||
EmptyViewHelper.createEmptyTextViewNoImage(
|
||||
context,
|
||||
getString(R.string.fairy_no_further_data_is_available)
|
||||
)
|
||||
)
|
||||
.setAdapter(testFairyAdapter)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyTextViewNoImage(
|
||||
context,
|
||||
getString(R.string.fairy_no_further_data_is_available)
|
||||
))
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setLayoutManager(GridLayoutManager(context, if(fairyType == MyFairyItemView.BASE) 6 else 3 , LinearLayoutManager.VERTICAL, false))
|
||||
.setLayoutManager(GridLayoutManager(context, 5, LinearLayoutManager.VERTICAL, false))
|
||||
.build()
|
||||
|
||||
viewModel.myFairyInfoLiveData.observe(viewLifecycleOwner) {
|
||||
val fairyInfos = it?.lowElves
|
||||
if(fairyType == MyFairyItemView.BASE) {
|
||||
val list = mutableListOf<FairyInfo>()
|
||||
it?.lowElves?.take(3)?.let { it1 -> list.addAll(it1) }
|
||||
it?.highElves?.take(3)?.let { it2 -> list.addAll(it2) }
|
||||
rvDelegate.setNewData(list)
|
||||
} else {
|
||||
rvDelegate.setNewData(fairyInfos?.take(3))
|
||||
val fairyInfos = it?.let {
|
||||
when (fairyType) {
|
||||
MyFairyItemView.EPIC -> {
|
||||
it.middleElves
|
||||
}
|
||||
else -> {
|
||||
it.lowElves
|
||||
}
|
||||
}
|
||||
}
|
||||
rvDelegate.setNewData(fairyInfos)
|
||||
}
|
||||
|
||||
resolveFairyAdapter.setOnItemClickListener { _, _, position ->
|
||||
resolveFairyAdapter.getItem(position)?.let {
|
||||
viewModel.addTestFairy(it, 1)
|
||||
}
|
||||
if (fairyType == MyFairyItemView.EPIC) {
|
||||
binding.tvTips.text = "點擊投入試煉傳說精靈"
|
||||
}
|
||||
|
||||
testFairyAdapter.setOnItemClickListener { _, _, position ->
|
||||
testFairyAdapter.getItem(position)?.let {
|
||||
viewModel.addTestFairy(it, 5)
|
||||
viewModel.addTestFairy(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,53 +97,20 @@ class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairy
|
||||
viewModel.minusTestFairy(index)
|
||||
}
|
||||
}
|
||||
fairyResolveViews.forEachIndexed { index, imageView ->
|
||||
imageView.setOnClickListener {
|
||||
viewModel.minusTestFairy(index)
|
||||
}
|
||||
}
|
||||
binding.tvReset.setOnClickListener {
|
||||
viewModel.cleanTestParam()
|
||||
}
|
||||
binding.tvOneKeyAdd.setOnClickListener {
|
||||
if (fairyType == MyFairyItemView.BASE) {
|
||||
viewModel.oneKeyAdd(resolveFairyAdapter.data, 1)
|
||||
} else {
|
||||
viewModel.oneKeyAdd(testFairyAdapter.data, 5)
|
||||
}
|
||||
viewModel.oneKeyAdd(testFairyAdapter.data)
|
||||
}
|
||||
|
||||
if (fairyType == MyFairyItemView.BASE) {
|
||||
if (fairyType == MyFairyItemView.EPIC) {
|
||||
binding.viewBgAnim.setBackgroundResource(R.drawable.treasure_fairy_bg_test_fairy_anim_legend)
|
||||
val p = binding.ivFairy3.layoutParams as ConstraintLayout.LayoutParams
|
||||
p.verticalBias = 0.9f
|
||||
binding.tvResolveTips.visibility = View.VISIBLE
|
||||
binding.tvResolveTips.text = getString(R.string.tips_fairy_resolve_low)
|
||||
binding.viewBgTop.setBackgroundResource(R.drawable.treasure_fairy_bg_test_fairy_legend)
|
||||
binding.ivBegin.setBackgroundResource(R.drawable.treasure_fairy_bg_resolve_fairy_begin)
|
||||
binding.tvTips.text = "點擊投入需要分解的精靈"
|
||||
} else {
|
||||
binding.viewBgAnim.setBackgroundResource(R.drawable.treasure_fairy_bg_test_fairy_anim_epic)
|
||||
val p = binding.ivFairy3.layoutParams as ConstraintLayout.LayoutParams
|
||||
p.verticalBias = 0.94f
|
||||
binding.tvResolveTips.visibility = View.GONE
|
||||
binding.viewBgTop.setBackgroundResource(R.drawable.treasure_fairy_bg_test_fairy)
|
||||
binding.ivBegin.setBackgroundResource(R.drawable.treasure_fairy_bg_test_fairy_begin)
|
||||
binding.tvTips.text = "點擊投入試煉傳說精靈"
|
||||
}
|
||||
|
||||
binding.ivBegin.setOnClickListener {
|
||||
if (fairyType == MyFairyItemView.BASE) {
|
||||
if (viewModel.resolveFairy()) {
|
||||
binding.animView.startPlay(
|
||||
requireContext().assets,
|
||||
"vap/test_fairy_anim_epic.mp4"
|
||||
)
|
||||
binding.ivBegin.isEnabled = false
|
||||
canShowResult = false
|
||||
binding.ivBegin.postDelayed(showResolveResultRunnable, 1800)
|
||||
}
|
||||
} else if (viewModel.testFairy(fairyType)) {
|
||||
if (viewModel.testFairy(fairyType)) {
|
||||
binding.animView.startPlay(
|
||||
requireContext().assets,
|
||||
if (fairyType == MyFairyItemView.BASE) {
|
||||
@@ -208,47 +146,15 @@ class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairy
|
||||
binding.ivBegin.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
//分解碎片
|
||||
viewModel.resolveResultLiveData.observe(viewLifecycleOwner) {
|
||||
it?.getContentIfNotHandled()?.let {
|
||||
canShowResult = true
|
||||
if (resultNotShowed) {
|
||||
showResultRunnable.run()
|
||||
}
|
||||
} ?: run {
|
||||
binding.ivBegin.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.compoundFairyInfosLiveData.observe(viewLifecycleOwner) {
|
||||
if (fairyType == MyFairyItemView.BASE) {
|
||||
fairyResolveViews.forEachIndexed { index, imageView ->
|
||||
it?.get(index)?.elfPicUrl?.let { elfPicUrl ->
|
||||
binding.tvResolveTips.text = getString(
|
||||
if (it[index].level == FairyInfo.LEVEL_HIGH) {
|
||||
R.string.tips_fairy_resolve_high
|
||||
} else {
|
||||
R.string.tips_fairy_resolve_low
|
||||
}
|
||||
)
|
||||
imageView.load(elfPicUrl)
|
||||
} ?: run {
|
||||
binding.tvResolveTips.text = getString(R.string.tips_fairy_resolve_low)
|
||||
imageView.setImageDrawable(null)
|
||||
}
|
||||
fairyViews.forEachIndexed { index, imageView ->
|
||||
it?.get(index)?.elfPicUrl?.let { elfPicUrl ->
|
||||
imageView.load(elfPicUrl)
|
||||
} ?: run {
|
||||
imageView.setImageDrawable(null)
|
||||
}
|
||||
resolveFairyAdapter.notifyDataSetChanged()
|
||||
} else {
|
||||
fairyViews.forEachIndexed { index, imageView ->
|
||||
it?.get(index)?.elfPicUrl?.let { elfPicUrl ->
|
||||
imageView.load(elfPicUrl)
|
||||
} ?: run {
|
||||
imageView.setImageDrawable(null)
|
||||
}
|
||||
}
|
||||
testFairyAdapter.notifyDataSetChanged()
|
||||
}
|
||||
testFairyAdapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,13 +22,13 @@ import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderAudioParty;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderChatHint;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderContent;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderP2PContactRecharge;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderFairy;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderGift;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderHello;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderLevel;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderLottery;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderOnline;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderP2PContactRecharge;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderRedPackage;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderRedPacket;
|
||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderSkill;
|
||||
@@ -44,6 +44,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.CarAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.CarveUpGoldThirdLevelAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.ChatHintAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.CpInviteAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.P2PContactRechargeAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.FairySendAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingFamilyAttachment;
|
||||
@@ -59,7 +60,6 @@ import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.NoticeAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.OpenRoomNotiAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.OpenSignInAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.P2PContactRechargeAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RedPacketAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.SkillMsgAttachment;
|
||||
|
@@ -3,25 +3,35 @@ package com.yizhuan.erban.ui.pay;
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.android.billingclient.api.AcknowledgePurchaseParams;
|
||||
import com.android.billingclient.api.AcknowledgePurchaseResponseListener;
|
||||
import com.android.billingclient.api.BillingClient;
|
||||
import com.android.billingclient.api.BillingClient.BillingResponseCode;
|
||||
import com.android.billingclient.api.BillingClient.SkuType;
|
||||
import com.android.billingclient.api.BillingClientStateListener;
|
||||
import com.android.billingclient.api.BillingFlowParams;
|
||||
import com.android.billingclient.api.BillingResult;
|
||||
import com.android.billingclient.api.ConsumeParams;
|
||||
import com.android.billingclient.api.ProductDetails;
|
||||
import com.android.billingclient.api.ProductDetailsResponseListener;
|
||||
import com.android.billingclient.api.ConsumeResponseListener;
|
||||
import com.android.billingclient.api.Purchase;
|
||||
import com.android.billingclient.api.Purchase.PurchasesResult;
|
||||
import com.android.billingclient.api.PurchasesUpdatedListener;
|
||||
import com.android.billingclient.api.QueryProductDetailsParams;
|
||||
import com.android.billingclient.api.QueryPurchasesParams;
|
||||
import com.android.billingclient.api.SkuDetails;
|
||||
import com.android.billingclient.api.SkuDetailsParams;
|
||||
import com.android.billingclient.api.SkuDetailsResponseListener;
|
||||
import com.yizhuan.erban.event.ChargeEvent;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class BillingManager implements PurchasesUpdatedListener {
|
||||
|
||||
@@ -45,6 +55,9 @@ public class BillingManager implements PurchasesUpdatedListener {
|
||||
/*商品列表*/
|
||||
private final List<Purchase> purchaseList = new ArrayList<>();
|
||||
|
||||
/*消耗令牌*/
|
||||
private Set<String> mTokensToBeConsumed;
|
||||
|
||||
/*监听接口*/
|
||||
public interface BillingUpdatesListener {
|
||||
void onBillingClientSetupFinished();
|
||||
@@ -96,24 +109,35 @@ public class BillingManager implements PurchasesUpdatedListener {
|
||||
|
||||
/*请求商品库存*/
|
||||
public void onQueryPurchases() {
|
||||
Runnable queryToExecute = () ->
|
||||
billingClient.queryPurchasesAsync(
|
||||
QueryPurchasesParams.newBuilder()
|
||||
.setProductType(BillingClient.ProductType.INAPP)
|
||||
.build(), this::onPurchasesUpdated);
|
||||
Runnable queryToExecute = () -> {
|
||||
//系统当前时间
|
||||
long time = System.currentTimeMillis();
|
||||
//请求内购商品
|
||||
PurchasesResult purchasesResult = billingClient.queryPurchases(SkuType.INAPP);
|
||||
onQueryPurchasesFinished(purchasesResult);
|
||||
};
|
||||
executeServiceRequest(queryToExecute);
|
||||
}
|
||||
|
||||
/*请求商品信息完成*/
|
||||
private void onQueryPurchasesFinished(PurchasesResult result) {
|
||||
if (billingClient == null || result.getResponseCode() != BillingResponseCode.OK) {
|
||||
Log.w(TAG, "billingClient is null or result code (" + result.getResponseCode()
|
||||
+ ") was bad - quitting");
|
||||
return;
|
||||
}
|
||||
purchaseList.clear();
|
||||
onPurchasesUpdated(result.getBillingResult(), result.getPurchasesList());
|
||||
}
|
||||
|
||||
/*更新商品*/
|
||||
@Override
|
||||
public void onPurchasesUpdated(BillingResult billingResult, List<Purchase> purchases) {
|
||||
Log.i(TAG, "billingResult.getResponseCode()==" + billingResult.getResponseCode());
|
||||
purchaseList.clear();
|
||||
//Log.i(TAG, "billingResult.getResponseCode()==" + billingResult.getResponseCode() + ",purchases.size()==" + purchases.size());
|
||||
|
||||
if (billingResult.getResponseCode() == BillingResponseCode.OK) {
|
||||
if (purchases != null) {
|
||||
for (Purchase purchase : purchases) {
|
||||
handlePurchase(purchase);
|
||||
}
|
||||
for (Purchase purchase : purchases) {
|
||||
handlePurchase(purchase);
|
||||
}
|
||||
mBillingUpdatesListener.onPurchasesUpdated(purchaseList);
|
||||
} else {
|
||||
@@ -154,46 +178,28 @@ public class BillingManager implements PurchasesUpdatedListener {
|
||||
}
|
||||
|
||||
/*查询内购商品详情*/
|
||||
public void querySkuDetailsAsync(final List<String> productIdList,
|
||||
final ProductDetailsResponseListener listener) {
|
||||
public void querySkuDetailsAsync(@SkuType final String itemType, final List<String> skuList,
|
||||
final SkuDetailsResponseListener listener) {
|
||||
Runnable queryRequest = () -> {
|
||||
ArrayList<QueryProductDetailsParams.Product> products = new ArrayList<>();
|
||||
for (String productId : productIdList) {
|
||||
products.add(QueryProductDetailsParams.Product.newBuilder()
|
||||
.setProductId(productId)
|
||||
.setProductType(BillingClient.ProductType.INAPP)
|
||||
.build());
|
||||
}
|
||||
QueryProductDetailsParams queryProductDetailsParams =
|
||||
QueryProductDetailsParams.newBuilder()
|
||||
.setProductList(products)
|
||||
.build();
|
||||
|
||||
billingClient.queryProductDetailsAsync(
|
||||
queryProductDetailsParams,
|
||||
listener
|
||||
);
|
||||
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
|
||||
params.setSkusList(skuList)
|
||||
.setType(itemType);
|
||||
billingClient.querySkuDetailsAsync(params.build(), listener);
|
||||
};
|
||||
executeServiceRequest(queryRequest);
|
||||
}
|
||||
|
||||
/*启动购买,订购流程*/
|
||||
public void initiatePurchaseFlow(final ProductDetails productDetails, String recordId) {
|
||||
public void initiatePurchaseFlow(final SkuDetails skuDetails, String recordId) {
|
||||
Runnable purchaseFlowRequest = () -> {
|
||||
BillingFlowParams.ProductDetailsParams p = BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
.setProductDetails(productDetails)
|
||||
.build();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
ProductDetails.OneTimePurchaseOfferDetails oneTimePurchaseOfferDetails = productDetails.getOneTimePurchaseOfferDetails();
|
||||
if (oneTimePurchaseOfferDetails != null) {
|
||||
jsonObject.put("p", oneTimePurchaseOfferDetails.getFormattedPrice());
|
||||
jsonObject.put("a", oneTimePurchaseOfferDetails.getPriceAmountMicros() / 10000);
|
||||
jsonObject.put("c", oneTimePurchaseOfferDetails.getPriceCurrencyCode());
|
||||
}
|
||||
jsonObject.put("p", skuDetails.getPrice());
|
||||
jsonObject.put("a", skuDetails.getPriceAmountMicros() / 10000);
|
||||
jsonObject.put("c", skuDetails.getPriceCurrencyCode());
|
||||
BillingFlowParams purchaseParams = BillingFlowParams.newBuilder()
|
||||
.setObfuscatedAccountId(recordId)
|
||||
.setObfuscatedProfileId(jsonObject.toJSONString())
|
||||
.setProductDetailsParamsList(List.of(p))
|
||||
.setSkuDetails(skuDetails)
|
||||
.build();
|
||||
BillingResult billingResult = billingClient.launchBillingFlow(mActivity, purchaseParams);
|
||||
Log.i(TAG, " initiatePurchaseFlow billingResult=" + billingResult.getResponseCode() + " " + billingResult.getDebugMessage());
|
||||
@@ -202,10 +208,28 @@ public class BillingManager implements PurchasesUpdatedListener {
|
||||
}
|
||||
|
||||
public void consumeAsync(final String purchaseToken) {
|
||||
if (mTokensToBeConsumed == null) {
|
||||
mTokensToBeConsumed = new HashSet<>();
|
||||
} else if (mTokensToBeConsumed.contains(purchaseToken)) {
|
||||
Log.i(TAG, "Token was already scheduled to be consumed - skipping...");
|
||||
return;
|
||||
}
|
||||
mTokensToBeConsumed.add(purchaseToken);
|
||||
|
||||
final ConsumeParams consumeParams = ConsumeParams.newBuilder().setPurchaseToken(purchaseToken).build();
|
||||
|
||||
executeServiceRequest(() -> billingClient.consumeAsync(consumeParams, (billingResult, s) ->
|
||||
mBillingUpdatesListener.onConsumeFinished(purchaseToken, billingResult.getResponseCode())));
|
||||
final ConsumeResponseListener consumeResponseListener = new ConsumeResponseListener() {
|
||||
@Override
|
||||
public void onConsumeResponse(@NonNull @NotNull BillingResult billingResult, @NonNull @NotNull String s) {
|
||||
mBillingUpdatesListener.onConsumeFinished(purchaseToken, billingResult.getResponseCode());
|
||||
}
|
||||
};
|
||||
executeServiceRequest(() -> billingClient.consumeAsync(consumeParams, consumeResponseListener));
|
||||
}
|
||||
|
||||
|
||||
public void acknowledgePurchase(AcknowledgePurchaseParams acknowledgePurchaseParams, AcknowledgePurchaseResponseListener Listener) {
|
||||
billingClient.acknowledgePurchase(acknowledgePurchaseParams, Listener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -24,8 +24,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.billingclient.api.BillingClient;
|
||||
import com.android.billingclient.api.ProductDetails;
|
||||
import com.android.billingclient.api.Purchase;
|
||||
import com.android.billingclient.api.SkuDetails;
|
||||
import com.appsflyer.AFInAppEventParameterName;
|
||||
import com.appsflyer.AFInAppEventType;
|
||||
import com.appsflyer.AppsFlyerLib;
|
||||
@@ -186,19 +186,19 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
|
||||
productKeys.add(chargeBean.getChargeProdId());
|
||||
}
|
||||
mChargeAdapter.setNewData(chargeBeanList);
|
||||
billingManager.querySkuDetailsAsync(productKeys, (billingResult, productDetails) -> {
|
||||
billingManager.querySkuDetailsAsync(BillingClient.SkuType.INAPP, productKeys, (billingResult, skuDetailsList) -> {
|
||||
if (billingResult.getResponseCode() != BillingClient.BillingResponseCode.OK) {
|
||||
Log.w(TAG, "Unsuccessful query for type: " + BillingClient.ProductType.INAPP
|
||||
Log.w(TAG, "Unsuccessful query for type: " + BillingClient.SkuType.INAPP
|
||||
+ ". Error code: " + billingResult.getResponseCode());
|
||||
getDialogManager().dismissDialog();
|
||||
toast(getString(R.string.Recharge_failure));
|
||||
} else if (productDetails.size() > 0) {
|
||||
} else if (skuDetailsList != null && skuDetailsList.size() > 0) {
|
||||
getDialogManager().dismissDialog();
|
||||
List<ChargeBean> showChargeList = new ArrayList<>();
|
||||
for (ChargeBean chargeBean : chargeBeanList) {
|
||||
for (ProductDetails product : productDetails) {
|
||||
if (product.getProductId().equals(chargeBean.getChargeProdId())) {
|
||||
chargeBean.setProductDetails(product);
|
||||
for (SkuDetails skuDetails : skuDetailsList) {
|
||||
if (skuDetails.getSku().equals(chargeBean.getChargeProdId())) {
|
||||
chargeBean.setSkuDetails(skuDetails);
|
||||
showChargeList.add(chargeBean);
|
||||
break;
|
||||
}
|
||||
@@ -221,28 +221,30 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
|
||||
purchase.getAccountIdentifiers() != null) {
|
||||
PayModel.get().verifyOrder(
|
||||
purchase.getAccountIdentifiers().getObfuscatedAccountId(),
|
||||
purchase.getProducts().get(0),
|
||||
purchase.getSkus().get(0),
|
||||
purchase.getPackageName(),
|
||||
purchase.getPurchaseToken())
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(token -> {
|
||||
.subscribe(
|
||||
token -> {
|
||||
//L.i("token=" + token);
|
||||
billingManager.consumeAsync(token);
|
||||
|
||||
ProductDetails productDetails = null;
|
||||
SkuDetails skuDetails = null;
|
||||
for (ChargeBean datum : mChargeAdapter.getData()) {
|
||||
if (datum.getChargeProdId().equals(purchase.getProducts().get(0))) {
|
||||
productDetails = datum.getProductDetails();
|
||||
if (datum.getChargeProdId().equals(purchase.getSkus().get(0))) {
|
||||
skuDetails = datum.getSkuDetails();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (productDetails != null) {
|
||||
if (skuDetails != null) {
|
||||
Map<String, Object> eventValue = new HashMap<>();
|
||||
eventValue.put(AFInAppEventParameterName.CONTENT_TYPE, "Gold");
|
||||
eventValue.put(AFInAppEventParameterName.QUANTITY, 1);
|
||||
eventValue.put(AFInAppEventParameterName.CONTENT_ID, purchase.getOrderId());
|
||||
eventValue.put(AFInAppEventParameterName.REVENUE, productDetails.getOneTimePurchaseOfferDetails().getPriceAmountMicros() / 1000000f);
|
||||
eventValue.put("Price", productDetails.getOneTimePurchaseOfferDetails().getFormattedPrice());
|
||||
eventValue.put(AFInAppEventParameterName.CURRENCY, productDetails.getOneTimePurchaseOfferDetails().getPriceCurrencyCode());
|
||||
eventValue.put(AFInAppEventParameterName.REVENUE, skuDetails.getPriceAmountMicros() / 1000000f);
|
||||
eventValue.put("Price", skuDetails.getPrice());
|
||||
eventValue.put(AFInAppEventParameterName.CURRENCY, skuDetails.getPriceCurrencyCode());
|
||||
AppsFlyerLib.getInstance().logEvent(getApplicationContext(), AFInAppEventType.PURCHASE, eventValue);
|
||||
}
|
||||
},
|
||||
@@ -267,12 +269,12 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
|
||||
|
||||
/*购买商品*/
|
||||
@SuppressLint("CheckResult")
|
||||
public void buyProduct(ProductDetails productDetails) {
|
||||
if (productDetails != null) {
|
||||
Log.d(TAG, "BuyProduct:" + productDetails.getProductId());
|
||||
PayModel.get().placeOrder(productDetails.getProductId())
|
||||
public void buyProduct(SkuDetails skuDetails) {
|
||||
if (skuDetails != null) {
|
||||
Log.d(TAG, "BuyProduct:" + skuDetails.getSku());
|
||||
PayModel.get().placeOrder(skuDetails.getSku())
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(recordId -> billingManager.initiatePurchaseFlow(productDetails, recordId.getRecordId()),
|
||||
.subscribe(recordId -> billingManager.initiatePurchaseFlow(skuDetails, recordId.getRecordId()),
|
||||
throwable -> {
|
||||
if (throwable instanceof FailReasonException) {
|
||||
FailReasonException failReasonException = (FailReasonException) throwable;
|
||||
@@ -340,8 +342,8 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
|
||||
}
|
||||
if (mChargePosition != -1) {
|
||||
ChargeBean bean = mChargeAdapter.getItem(mChargePosition);
|
||||
if (bean != null && bean.getProductDetails() != null) {
|
||||
buyProduct(bean.getProductDetails());
|
||||
if (bean != null && bean.getSkuDetails() != null) {
|
||||
buyProduct(bean.getSkuDetails());
|
||||
//点击充值
|
||||
HashMap<String, Object> map = new HashMap<>(3);
|
||||
map.put(IReportConstants.MONEY, bean.money);
|
||||
|
@@ -21,8 +21,8 @@ public class ChargeAdapter extends BaseQuickAdapter<ChargeBean, BaseViewHolder>
|
||||
if (chargeBean == null) return;
|
||||
baseViewHolder.getView(R.id.ll_bg).setSelected(chargeBean.isSelected);
|
||||
baseViewHolder.setText(R.id.tv_title, chargeBean.getProdName());
|
||||
if (chargeBean.getProductDetails() != null) {
|
||||
baseViewHolder.setText(R.id.item_charge_money, chargeBean.getProductDetails().getOneTimePurchaseOfferDetails().getFormattedPrice());
|
||||
if (chargeBean.getSkuDetails() != null) {
|
||||
baseViewHolder.setText(R.id.item_charge_money, chargeBean.getSkuDetails().getPrice());
|
||||
} else {
|
||||
baseViewHolder.setText(R.id.item_charge_money, "USD$" + chargeBean.getMoney());
|
||||
}
|
||||
|
@@ -316,7 +316,7 @@ public class ImageLoadUtils {
|
||||
GlideApp.with(context)
|
||||
.load(url)
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.placeholder(R.drawable.default_cover)
|
||||
.placeholder(R.drawable.default_avatar)
|
||||
.transform(new BlurTransformation(context, blur, scale))
|
||||
.into(imageView);
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ public class FairyDialogWebViewActivity extends CommonWebViewActivity {
|
||||
getWindow().setGravity(Gravity.BOTTOM);
|
||||
View layoutRoot = findViewById(R.id.ll_root);
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) layoutRoot.getLayoutParams();
|
||||
layoutParams.height = ScreenUtil.screenWidth * 1245 / 750;
|
||||
layoutParams.height = ScreenUtil.screenWidth * 1100 / 750;
|
||||
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutRoot.setLayoutParams(layoutParams);
|
||||
layoutTitleBar.setVisibility(View.GONE);
|
||||
|
@@ -1,92 +0,0 @@
|
||||
package com.yizhuan.erban.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.yizhuan.erban.R;
|
||||
|
||||
/**
|
||||
* @author wzq
|
||||
*/
|
||||
public class ShadowFrameLayout extends FrameLayout {
|
||||
|
||||
private Paint mShadowPaint;
|
||||
private float mCornerRadius;
|
||||
/**
|
||||
* 只有上面有阴影
|
||||
*/
|
||||
private boolean mShadowTop;
|
||||
|
||||
private float mShadowRadius;
|
||||
|
||||
private RectF mRectF;
|
||||
|
||||
public ShadowFrameLayout(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ShadowFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public ShadowFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShadowFrameLayout);
|
||||
int shadowColor = typedArray.getColor(R.styleable.ShadowFrameLayout_shadowColor,
|
||||
ContextCompat.getColor(context, R.color.color_1E686868));
|
||||
int backgroundColor = typedArray.getColor(R.styleable.ShadowFrameLayout_backgroundColor, Color.WHITE);
|
||||
mShadowRadius = typedArray.getDimension(R.styleable.ShadowFrameLayout_shadowRadius, 0);
|
||||
mCornerRadius = typedArray.getDimension(R.styleable.ShadowFrameLayout_cornerRadius, 0);
|
||||
mShadowTop = typedArray.getBoolean(R.styleable.ShadowFrameLayout_shadowTop, false);
|
||||
typedArray.recycle();
|
||||
|
||||
mShadowPaint = new Paint();
|
||||
mShadowPaint.setShadowLayer(mShadowRadius, 0, 0, shadowColor);
|
||||
mShadowPaint.setAntiAlias(true);
|
||||
mShadowPaint.setColor(backgroundColor);
|
||||
setLayerType(LAYER_TYPE_SOFTWARE, null);
|
||||
|
||||
mRectF = new RectF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundColor(@ColorInt int color) {
|
||||
mShadowPaint.setColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
int measuredWidth = getMeasuredWidth();
|
||||
int measuredHeight = getMeasuredHeight();
|
||||
if (mShadowTop) {
|
||||
// 矩形只有上方有阴影
|
||||
mRectF.set(0, mShadowRadius, measuredWidth, measuredHeight + mCornerRadius);
|
||||
} else {
|
||||
// 环绕阴影
|
||||
mRectF.set(mShadowRadius, mShadowRadius, measuredWidth - mShadowRadius, measuredHeight - mShadowRadius);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
canvas.drawRoundRect(mRectF, mCornerRadius, mCornerRadius, mShadowPaint);
|
||||
super.dispatchDraw(canvas);
|
||||
}
|
||||
}
|
@@ -14,8 +14,8 @@ import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.android.billingclient.api.BillingClient
|
||||
import com.android.billingclient.api.BillingResult
|
||||
import com.android.billingclient.api.ProductDetails
|
||||
import com.android.billingclient.api.Purchase
|
||||
import com.android.billingclient.api.SkuDetails
|
||||
import com.appsflyer.AFInAppEventParameterName
|
||||
import com.appsflyer.AFInAppEventType
|
||||
import com.appsflyer.AppsFlyerLib
|
||||
@@ -233,12 +233,12 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
|
||||
|
||||
binding.tvOpenVip.setOnClickListener {
|
||||
if (AppMetaDataUtil.getChannelID().equals(Constants.GOOGLE)) {
|
||||
if ((googleChargeBean?.productDetails?.oneTimePurchaseOfferDetails?.priceAmountMicros ?: "0") == "0") {
|
||||
if ((googleChargeBean?.skuDetails?.price ?: "0") == "0") {
|
||||
toast(getString(R.string.Recharge_failure))
|
||||
return@setOnClickListener
|
||||
}
|
||||
SelectPayTypeDialog.newInstance(
|
||||
googleChargeBean?.productDetails?.oneTimePurchaseOfferDetails?.formattedPrice ?: "0",
|
||||
googleChargeBean?.skuDetails?.price ?: "0",
|
||||
true,
|
||||
googleChargeBean?.getMoney() ?: 0.0
|
||||
)
|
||||
@@ -248,7 +248,7 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
|
||||
}
|
||||
setOnGoogleChargeClick {
|
||||
googleChargeBean?.let { charge ->
|
||||
buyProduct(charge.productDetails)
|
||||
buyProduct(charge.skuDetails)
|
||||
}
|
||||
}
|
||||
setOnChargeClick {
|
||||
@@ -396,18 +396,20 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
|
||||
chargeInfo?.let { chargeBean ->
|
||||
val productKeys: MutableList<String> = ArrayList()
|
||||
productKeys.add(chargeBean.getChargeProdId())
|
||||
billingManager?.querySkuDetailsAsync(productKeys) { billingResult: BillingResult, productDetails: List<ProductDetails> ->
|
||||
billingManager?.querySkuDetailsAsync(
|
||||
BillingClient.SkuType.INAPP, productKeys
|
||||
) { billingResult: BillingResult, skuDetailsList: List<SkuDetails>? ->
|
||||
if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
|
||||
Log.w(
|
||||
TAG,
|
||||
"Unsuccessful query for type: " + BillingClient.SkuType.INAPP
|
||||
+ ". Error code: " + billingResult.responseCode
|
||||
)
|
||||
} else if (productDetails.isNotEmpty()) {
|
||||
} else if (skuDetailsList != null && skuDetailsList.isNotEmpty()) {
|
||||
val showChargeList: MutableList<ChargeBean> = ArrayList()
|
||||
for (skuDetails in productDetails) {
|
||||
if (skuDetails.productId == chargeBean.getChargeProdId()) {
|
||||
chargeBean.productDetails = skuDetails
|
||||
for (skuDetails in skuDetailsList) {
|
||||
if (skuDetails.sku == chargeBean.getChargeProdId()) {
|
||||
chargeBean.skuDetails = skuDetails
|
||||
showChargeList.add(chargeBean)
|
||||
break
|
||||
}
|
||||
@@ -437,7 +439,7 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
|
||||
) {
|
||||
PayModel.get().verifyOrder(
|
||||
purchase.accountIdentifiers!!.obfuscatedAccountId,
|
||||
purchase.products[0],
|
||||
purchase.skus[0],
|
||||
purchase.packageName,
|
||||
purchase.purchaseToken
|
||||
)
|
||||
@@ -446,21 +448,21 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
|
||||
{ token: String? ->
|
||||
//L.i("token=" + token);
|
||||
billingManager?.consumeAsync(token)
|
||||
var skuDetails: ProductDetails? = null
|
||||
if (googleChargeBean?.getChargeProdId() == purchase.products[0]) {
|
||||
skuDetails = googleChargeBean?.productDetails
|
||||
var skuDetails: SkuDetails? = null
|
||||
if (googleChargeBean?.getChargeProdId() == purchase.skus[0]) {
|
||||
skuDetails = googleChargeBean?.skuDetails
|
||||
}
|
||||
if (skuDetails != null) {
|
||||
val eventValue: MutableMap<String, Any> =
|
||||
HashMap()
|
||||
eventValue[AFInAppEventParameterName.CONTENT_TYPE] = "Gold"
|
||||
eventValue[AFInAppEventParameterName.QUANTITY] = 1
|
||||
eventValue[AFInAppEventParameterName.CONTENT_ID] = purchase.orderId!!
|
||||
eventValue[AFInAppEventParameterName.CONTENT_ID] = purchase.orderId
|
||||
eventValue[AFInAppEventParameterName.REVENUE] =
|
||||
skuDetails.oneTimePurchaseOfferDetails?.priceAmountMicros!! / 1000000f
|
||||
eventValue["Price"] = skuDetails.oneTimePurchaseOfferDetails?.formattedPrice!!
|
||||
skuDetails.priceAmountMicros / 1000000f
|
||||
eventValue["Price"] = skuDetails.price
|
||||
eventValue[AFInAppEventParameterName.CURRENCY] =
|
||||
skuDetails.oneTimePurchaseOfferDetails?.priceCurrencyCode!!
|
||||
skuDetails.priceCurrencyCode
|
||||
AppsFlyerLib.getInstance().logEvent(
|
||||
applicationContext,
|
||||
AFInAppEventType.PURCHASE,
|
||||
@@ -488,15 +490,15 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
|
||||
|
||||
/*购买商品*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun buyProduct(productDetails: ProductDetails?) {
|
||||
if (productDetails != null) {
|
||||
Log.d(TAG, "BuyProduct:" + productDetails.productId)
|
||||
PayModel.get().placeOrder(productDetails.productId)
|
||||
fun buyProduct(skuDetails: SkuDetails?) {
|
||||
if (skuDetails != null) {
|
||||
Log.d(TAG, "BuyProduct:" + skuDetails.sku)
|
||||
PayModel.get().placeOrder(skuDetails.sku)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(
|
||||
{ recordId: PayRecordId ->
|
||||
billingManager?.initiatePurchaseFlow(
|
||||
productDetails,
|
||||
skuDetails,
|
||||
recordId.recordId
|
||||
)
|
||||
}
|
||||
|
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:color="@color/white" android:state_checked="true" />
|
||||
|
||||
<item android:color="@color/color_9168FA" />
|
||||
|
||||
</selector>
|
Before Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 290 B |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 764 B |
Before Width: | Height: | Size: 543 B |
Before Width: | Height: | Size: 428 B |
Before Width: | Height: | Size: 370 B |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 367 B |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 318 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 153 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 10 KiB |
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:angle="0"
|
||||
android:endColor="#ff284d5a"
|
||||
android:startColor="#ff17303c"
|
||||
android:type="linear"
|
||||
android:useLevel="true" />
|
||||
<stroke
|
||||
android:width="0.5dp"
|
||||
android:color="@color/color_white_60" />
|
||||
<corners
|
||||
android:radius="@dimen/dp_15" />
|
||||
</shape>
|
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#19ffffff" />
|
||||
<corners android:radius="@dimen/dp_10" />
|
||||
</shape>
|
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#19ffffff" />
|
||||
<corners android:radius="@dimen/dp_10" />
|
||||
<stroke
|
||||
android:width="0.5dp"
|
||||
android:color="@color/color_F2DE84" />
|
||||
</shape>
|
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="@dimen/dp_4" />
|
||||
<solid android:color="@color/color_365A65" />
|
||||
</shape>
|
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners android:radius="@dimen/dp_24" />
|
||||
|
||||
<gradient
|
||||
android:endColor="@color/color_CF70FF"
|
||||
android:startColor="#5AECFA" />
|
||||
|
||||
</shape>
|
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<solid android:color="@color/color_9168FA" />
|
||||
|
||||
<corners android:radius="@dimen/dp_6" />
|
||||
|
||||
</shape>
|
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners android:radius="@dimen/dp_6"/>
|
||||
|
||||
<solid android:color="@color/color_9E9EA8" />
|
||||
|
||||
</shape>
|
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners android:radius="@dimen/dp_6" />
|
||||
|
||||
<solid android:color="@color/color_F5F6FA" />
|
||||
</shape>
|
@@ -1,7 +0,0 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners android:radius="@dimen/dp_8" />
|
||||
|
||||
<solid android:color="@color/color_001338" />
|
||||
|
||||
</shape>
|