Compare commits
91 Commits
main
...
develop_re
| Author | SHA1 | Date |
|---|---|---|
|
|
68f1119b4a | |
|
|
a95b8b84e9 | |
|
|
2dc819f916 | |
|
|
ce0d5084ba | |
|
|
1988f2448c | |
|
|
0f06e04a4e | |
|
|
3f10238136 | |
|
|
b7ca0babe5 | |
|
|
47020ca736 | |
|
|
b143f6a67d | |
|
|
f934dd66ae | |
|
|
435faca163 | |
|
|
6dd6502c5a | |
|
|
09d74032a9 | |
|
|
fedae8b98f | |
|
|
fb1c6011e0 | |
|
|
f4b10782f0 | |
|
|
b8d848e0bf | |
|
|
2e2f37c586 | |
|
|
dc65bd0562 | |
|
|
6831cfa898 | |
|
|
9bf2e8fef0 | |
|
|
4feda5f879 | |
|
|
4c4500b895 | |
|
|
81ab5823ec | |
|
|
294100b146 | |
|
|
2b8b0fb38d | |
|
|
9e2b880a32 | |
|
|
57ae7ff4ff | |
|
|
95742607a0 | |
|
|
f2cbc14727 | |
|
|
47e4d3dba5 | |
|
|
abe2f0ab90 | |
|
|
3b0abf5235 | |
|
|
9189b845ef | |
|
|
929a95ed9c | |
|
|
0991ab3993 | |
|
|
4ff522f3cd | |
|
|
a6c56d6539 | |
|
|
d7be7c30cb | |
|
|
66bcd4eb51 | |
|
|
114f7befbc | |
|
|
0bf9922be7 | |
|
|
e6c0220019 | |
|
|
ff0ee2d612 | |
|
|
82ff8c5c51 | |
|
|
77d93b0211 | |
|
|
3c081c230a | |
|
|
e93d76f316 | |
|
|
483fa7e930 | |
|
|
ca1f3662b0 | |
|
|
460270212d | |
|
|
ef8d084744 | |
|
|
797d1c01a9 | |
|
|
554eaf31a3 | |
|
|
9d8fc70c10 | |
|
|
16efb504e3 | |
|
|
62db69b1d4 | |
|
|
93543545c5 | |
|
|
32d201030d | |
|
|
6f650df200 | |
|
|
0e034f340d | |
|
|
b07c1cf4ab | |
|
|
0b0805d6bc | |
|
|
da56a8cb42 | |
|
|
97f9a39e95 | |
|
|
a063466f15 | |
|
|
dc7ff87e33 | |
|
|
63d636ff1a | |
|
|
1542db851e | |
|
|
f4aebf8e9c | |
|
|
6ea2af01fe | |
|
|
738b0b3ae9 | |
|
|
5fdf3a4ad9 | |
|
|
e00bf1da76 | |
|
|
f5162cb3a8 | |
|
|
df87261b62 | |
|
|
58b33b9399 | |
|
|
8b37a63a4a | |
|
|
cfe4acbb78 | |
|
|
a8ab37a17b | |
|
|
86214129b6 | |
|
|
fc7fd9d578 | |
|
|
b099f4cd99 | |
|
|
9efe53bf0d | |
|
|
cb1e475a83 | |
|
|
de9f003d26 | |
|
|
df332187d6 | |
|
|
88c2d8cf34 | |
|
|
3eb186063f | |
|
|
5a15d7d997 |
|
|
@ -18,4 +18,49 @@
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
# If you keep the line number information, uncomment this to
|
||||||
# hide the original source file name.
|
# hide the original source file name.
|
||||||
#-renamesourcefileattribute SourceFile
|
#-renamesourcefileattribute SourceFile
|
||||||
|
|
||||||
|
# 保持 Android 四大组件等系统类
|
||||||
|
-keep public class * extends android.app.Activity
|
||||||
|
-keep public class * extends android.app.Service
|
||||||
|
-keep public class * extends android.content.BroadcastReceiver
|
||||||
|
-keep public class * extends android.content.ContentProvider
|
||||||
|
-keep public class * extends android.app.Application
|
||||||
|
|
||||||
|
# 保持 Native 方法不被混淆
|
||||||
|
-keepclasseswithmembernames class * {
|
||||||
|
native <methods>;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 保持 Parcelable 序列化类不被混淆
|
||||||
|
-keep class * implements android.os.Parcelable {
|
||||||
|
public static final android.os.Parcelable$Creator *;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 保持 Serializable 序列化的类成员不被混淆
|
||||||
|
-keepclassmembers class * implements java.io.Serializable {
|
||||||
|
static final long serialVersionUID;
|
||||||
|
private static final java.io.ObjectStreamField[] serialPersistentFields;
|
||||||
|
private void writeObject(java.io.ObjectOutputStream);
|
||||||
|
private void readObject(java.io.ObjectInputStream);
|
||||||
|
java.lang.Object writeReplace();
|
||||||
|
java.lang.Object readResolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
# 保持自定义 View 的构造方法不被混淆(用于 XML 布局)
|
||||||
|
-keep public class * extends android.view.View {
|
||||||
|
public <init>(android.content.Context);
|
||||||
|
public <init>(android.content.Context, android.util.AttributeSet);
|
||||||
|
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||||
|
public void set*(...);
|
||||||
|
}
|
||||||
|
|
||||||
|
# 保持枚举类不被混淆
|
||||||
|
-keepclassmembers enum * {
|
||||||
|
public static **[] values();
|
||||||
|
public static ** valueOf(java.lang.String);
|
||||||
|
}
|
||||||
|
|
||||||
|
# 保持由 JSON 转换的 Bean 类(或者你的数据模型类)不被混淆
|
||||||
|
-keep class com.gamedog.vididin.beans.** { *; }
|
||||||
|
-keep class com.gamedog.vididin.router.** { *; }
|
||||||
|
|
@ -2,7 +2,15 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.camera"
|
||||||
|
android:required="false" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".VidiDinApp"
|
android:name=".VidiDinApp"
|
||||||
|
|
@ -16,10 +24,10 @@
|
||||||
android:theme="@style/Theme.Architectureandroid">
|
android:theme="@style/Theme.Architectureandroid">
|
||||||
<activity
|
<activity
|
||||||
android:name=".main.MainActivity"
|
android:name=".main.MainActivity"
|
||||||
android:exported="true">
|
android:exported="true"
|
||||||
|
android:launchMode="singleTask">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
@ -35,6 +43,7 @@
|
||||||
<activity android:name=".features.feedback.FeedbackActivity" android:exported="false" />
|
<activity android:name=".features.feedback.FeedbackActivity" android:exported="false" />
|
||||||
<activity android:name=".features.withdrawrecord.WithdrawRecordActivity" android:exported="false" />
|
<activity android:name=".features.withdrawrecord.WithdrawRecordActivity" android:exported="false" />
|
||||||
<activity android:name=".features.privacy.PrivacyActivity" android:exported="false" />
|
<activity android:name=".features.privacy.PrivacyActivity" android:exported="false" />
|
||||||
|
<activity android:name=".features.watchad.WatchAdActivity" android:exported="false" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -46,6 +55,19 @@
|
||||||
android:name="com.gamedog.vididin.router.RouterInitializer"
|
android:name="com.gamedog.vididin.router.RouterInitializer"
|
||||||
android:value="androidx.startup" />
|
android:value="androidx.startup" />
|
||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
|
|
||||||
|
<receiver
|
||||||
|
android:name=".manager.DateChangeReceiver"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.DATE_CHANGED" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
@ -4,7 +4,10 @@
|
||||||
"module_name": "任务中心",
|
"module_name": "任务中心",
|
||||||
"page_path": "底部第二个页签",
|
"page_path": "底部第二个页签",
|
||||||
"layout_style": "上下滑动长页面",
|
"layout_style": "上下滑动长页面",
|
||||||
"currency_display": ["金币账户", "巴西雷亚尔现金账户"]
|
"currency_display": [
|
||||||
|
"金币账户",
|
||||||
|
"巴西雷亚尔现金账户"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"task_categories": [
|
"task_categories": [
|
||||||
{
|
{
|
||||||
|
|
@ -50,13 +53,34 @@
|
||||||
"target_action": "用户每日完成签到操作(支持广告补签)",
|
"target_action": "用户每日完成签到操作(支持广告补签)",
|
||||||
"reward_type": "金币",
|
"reward_type": "金币",
|
||||||
"reward_details": [
|
"reward_details": [
|
||||||
{"day": 1, "value": 100},
|
{
|
||||||
{"day": 2, "value": 300},
|
"day": 1,
|
||||||
{"day": 3, "value": 300},
|
"value": 100
|
||||||
{"day": 4, "value": 500},
|
},
|
||||||
{"day": 5, "value": 300},
|
{
|
||||||
{"day": 6, "value": 300},
|
"day": 2,
|
||||||
{"day": 7, "value": 800}
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day": 3,
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day": 4,
|
||||||
|
"value": 500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day": 5,
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day": 6,
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day": 7,
|
||||||
|
"value": 800
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"support_makeup": true,
|
"support_makeup": true,
|
||||||
"makeup_method": "观看15-30秒激励视频",
|
"makeup_method": "观看15-30秒激励视频",
|
||||||
|
|
@ -78,13 +102,34 @@
|
||||||
"target_action": "用户当日完成签到操作",
|
"target_action": "用户当日完成签到操作",
|
||||||
"reward_type": "金币",
|
"reward_type": "金币",
|
||||||
"reward_details": [
|
"reward_details": [
|
||||||
{"day": 1, "value": 100},
|
{
|
||||||
{"day": 2, "value": 300},
|
"day": 1,
|
||||||
{"day": 3, "value": 300},
|
"value": 100
|
||||||
{"day": 4, "value": 500},
|
},
|
||||||
{"day": 5, "value": 300},
|
{
|
||||||
{"day": 6, "value": 300},
|
"day": 2,
|
||||||
{"day": 7, "value": 500}
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day": 3,
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day": 4,
|
||||||
|
"value": 500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day": 5,
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day": 6,
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day": 7,
|
||||||
|
"value": 500
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"double_reward_method": "观看15-30秒激励视频",
|
"double_reward_method": "观看15-30秒激励视频",
|
||||||
"support_makeup": true,
|
"support_makeup": true,
|
||||||
|
|
@ -99,9 +144,18 @@
|
||||||
"target_action": "用户累计观看短视频",
|
"target_action": "用户累计观看短视频",
|
||||||
"reward_type": "金币",
|
"reward_type": "金币",
|
||||||
"reward_details": [
|
"reward_details": [
|
||||||
{"target_count": 10, "value": 100},
|
{
|
||||||
{"target_count": 20, "value": 150},
|
"target_count": 10,
|
||||||
{"target_count": 30, "value": 200}
|
"value": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target_count": 20,
|
||||||
|
"value": 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target_count": 30,
|
||||||
|
"value": 200
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"reward_stackable": true,
|
"reward_stackable": true,
|
||||||
"is_one_time": false,
|
"is_one_time": false,
|
||||||
|
|
@ -114,9 +168,18 @@
|
||||||
"target_action": "用户累计观看激励视频",
|
"target_action": "用户累计观看激励视频",
|
||||||
"reward_type": "金币",
|
"reward_type": "金币",
|
||||||
"reward_details": [
|
"reward_details": [
|
||||||
{"target_count": 1, "value": 100},
|
{
|
||||||
{"target_count": 5, "value": 150},
|
"target_count": 1,
|
||||||
{"target_count": 10, "value": 200}
|
"value": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target_count": 5,
|
||||||
|
"value": 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target_count": 10,
|
||||||
|
"value": 200
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"daily_limit": 10,
|
"daily_limit": 10,
|
||||||
"reward_stackable": true,
|
"reward_stackable": true,
|
||||||
|
|
@ -125,6 +188,104 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"box_task": {
|
||||||
|
"category_id": "bonuses_task",
|
||||||
|
"category_name": "福利宝箱(Prémios únicos)",
|
||||||
|
"valid_period": "每个宝箱持续3天,完成对应任务即可领取现金奖励。",
|
||||||
|
"display_priority": 3,
|
||||||
|
"chests": [
|
||||||
|
{
|
||||||
|
"chest_id": "1",
|
||||||
|
"chest_name": "福利宝箱1",
|
||||||
|
"chest_desc": "完成福利宝箱1的全部任务后,获得R$0.1现金奖励",
|
||||||
|
"duration_days": 3,
|
||||||
|
"reward_type": "货币",
|
||||||
|
"reward_value": 0.1,
|
||||||
|
"is_one_time": true,
|
||||||
|
"status": "active",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"task_id": "chest1_task1",
|
||||||
|
"task_name": "观看1个广告",
|
||||||
|
"required_count": 1,
|
||||||
|
"task_type": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"task_id": "chest1_task2",
|
||||||
|
"task_name": "观看3个视频",
|
||||||
|
"required_count": 3,
|
||||||
|
"task_type": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"task_id": "chest1_task3",
|
||||||
|
"task_name": "完成1次签到",
|
||||||
|
"required_count": 1,
|
||||||
|
"task_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"chest_id": "2",
|
||||||
|
"chest_name": "福利宝箱2",
|
||||||
|
"chest_desc": "完成福利宝箱2的全部任务后,获得R$1现金奖励",
|
||||||
|
"duration_days": 3,
|
||||||
|
"reward_type": "货币",
|
||||||
|
"reward_value": 1,
|
||||||
|
"is_one_time": true,
|
||||||
|
"status": "locked",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"task_id": "chest2_task1",
|
||||||
|
"task_name": "观看15个广告",
|
||||||
|
"required_count": 15,
|
||||||
|
"task_type": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"task_id": "chest2_task2",
|
||||||
|
"task_name": "观看30个视频",
|
||||||
|
"required_count": 30,
|
||||||
|
"task_type": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"task_id": "chest2_task3",
|
||||||
|
"task_name": "参与1次0元购",
|
||||||
|
"required_count": 1,
|
||||||
|
"task_type": 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"chest_id": "3",
|
||||||
|
"chest_name": "福利宝箱3",
|
||||||
|
"chest_desc": "完成福利宝箱3的全部任务后,获得R$2现金奖励",
|
||||||
|
"duration_days": 3,
|
||||||
|
"reward_type": "货币",
|
||||||
|
"reward_value": 2,
|
||||||
|
"is_one_time": true,
|
||||||
|
"status": "locked",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"task_id": "chest3_task1",
|
||||||
|
"task_name": "观看30个广告",
|
||||||
|
"required_count": 30,
|
||||||
|
"task_type": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"task_id": "chest3_task2",
|
||||||
|
"task_name": "观看50个视频",
|
||||||
|
"required_count": 50,
|
||||||
|
"task_type": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"task_id": "chest3_task3",
|
||||||
|
"task_name": "参与10次0元购",
|
||||||
|
"required_count": 10,
|
||||||
|
"task_type": 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,130 @@
|
||||||
|
{
|
||||||
|
"task_module_config": {
|
||||||
|
"basic_info": {
|
||||||
|
"module_name": "任务中心",
|
||||||
|
"page_path": "底部第二个页签",
|
||||||
|
"layout_style": "上下滑动长页面",
|
||||||
|
"currency_display": ["金币账户", "巴西雷亚尔现金账户"]
|
||||||
|
},
|
||||||
|
"task_categories": [
|
||||||
|
{
|
||||||
|
"category_id": "newbie_task",
|
||||||
|
"category_name": "新手任务(Missão Para Iniciantes)",
|
||||||
|
"valid_period": "注册后7天内",
|
||||||
|
"display_priority": 1,
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"task_id": "newbie_first_withdraw",
|
||||||
|
"task_name": "完成第一次提现",
|
||||||
|
"task_desc": "完成首次提现操作(0.1 BRL门槛),即可获得100金币奖励",
|
||||||
|
"target_action": "用户完成首次提现流程(含绑定Pix账户、观看广告)",
|
||||||
|
"reward_type": "金币",
|
||||||
|
"reward_value": 100,
|
||||||
|
"is_one_time": true,
|
||||||
|
"status": "active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"task_id": "newbie_push_notify",
|
||||||
|
"task_name": "开启消息推送",
|
||||||
|
"task_desc": "启用APP消息推送权限,实时获取任务更新与奖励通知",
|
||||||
|
"target_action": "用户授权APP系统推送通知",
|
||||||
|
"reward_type": "金币",
|
||||||
|
"reward_value": 300,
|
||||||
|
"is_one_time": true,
|
||||||
|
"status": "active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"task_id": "newbie_join_discord",
|
||||||
|
"task_name": "加入Discord社区",
|
||||||
|
"task_desc": "通过APP内链接加入官方Discord社区,获取专属活动与客服支持",
|
||||||
|
"target_action": "用户通过指定链接成功加入Discord社区",
|
||||||
|
"reward_type": "金币",
|
||||||
|
"reward_value": 200,
|
||||||
|
"is_one_time": true,
|
||||||
|
"status": "active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"task_id": "newbie_7day_checkin",
|
||||||
|
"task_name": "7日连续签到",
|
||||||
|
"task_desc": "连续7天完成签到,奖励逐级递增,第7天最高可得800金币",
|
||||||
|
"target_action": "用户每日完成签到操作(支持广告补签)",
|
||||||
|
"reward_type": "金币",
|
||||||
|
"reward_details": [
|
||||||
|
{"day": 1, "value": 100},
|
||||||
|
{"day": 2, "value": 300},
|
||||||
|
{"day": 3, "value": 300},
|
||||||
|
{"day": 4, "value": 500},
|
||||||
|
{"day": 5, "value": 300},
|
||||||
|
{"day": 6, "value": 300},
|
||||||
|
{"day": 7, "value": 800}
|
||||||
|
],
|
||||||
|
"support_makeup": true,
|
||||||
|
"makeup_method": "观看15-30秒激励视频",
|
||||||
|
"is_one_time": true,
|
||||||
|
"status": "active"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"category_id": "daily_task",
|
||||||
|
"category_name": "日常任务(Missão Diária)",
|
||||||
|
"valid_period": "每日凌晨00:00重置",
|
||||||
|
"display_priority": 2,
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"task_id": "daily_checkin",
|
||||||
|
"task_name": "每日签到",
|
||||||
|
"task_desc": "每日签到可获金币,7天为一周期,奖励循环递增(支持双倍广告奖励)",
|
||||||
|
"target_action": "用户当日完成签到操作",
|
||||||
|
"reward_type": "金币",
|
||||||
|
"reward_details": [
|
||||||
|
{"day": 1, "value": 100},
|
||||||
|
{"day": 2, "value": 300},
|
||||||
|
{"day": 3, "value": 300},
|
||||||
|
{"day": 4, "value": 500},
|
||||||
|
{"day": 5, "value": 300},
|
||||||
|
{"day": 6, "value": 300},
|
||||||
|
{"day": 7, "value": 500}
|
||||||
|
],
|
||||||
|
"double_reward_method": "观看15-30秒激励视频",
|
||||||
|
"support_makeup": true,
|
||||||
|
"makeup_method": "观看15-30秒激励视频",
|
||||||
|
"is_one_time": false,
|
||||||
|
"status": "active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"task_id": "daily_video_ladder",
|
||||||
|
"task_name": "阶梯观看视频",
|
||||||
|
"task_desc": "累计观看指定数量短视频,分3档领取奖励(与基础观看收益叠加)",
|
||||||
|
"target_action": "用户累计观看短视频",
|
||||||
|
"reward_type": "金币",
|
||||||
|
"reward_details": [
|
||||||
|
{"target_count": 10, "value": 100},
|
||||||
|
{"target_count": 20, "value": 150},
|
||||||
|
{"target_count": 30, "value": 200}
|
||||||
|
],
|
||||||
|
"reward_stackable": true,
|
||||||
|
"is_one_time": false,
|
||||||
|
"status": "active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"task_id": "daily_ad_ladder",
|
||||||
|
"task_name": "阶梯观看激励视频",
|
||||||
|
"task_desc": "累计观看指定数量激励视频,分3档领取奖励(每日上限10次)",
|
||||||
|
"target_action": "用户累计观看激励视频",
|
||||||
|
"reward_type": "金币",
|
||||||
|
"reward_details": [
|
||||||
|
{"target_count": 1, "value": 100},
|
||||||
|
{"target_count": 5, "value": 150},
|
||||||
|
{"target_count": 10, "value": 200}
|
||||||
|
],
|
||||||
|
"daily_limit": 10,
|
||||||
|
"reward_stackable": true,
|
||||||
|
"is_one_time": false,
|
||||||
|
"status": "active"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
package com.gamedog.vididin
|
|
||||||
|
|
||||||
object VidiConst {
|
|
||||||
/**
|
|
||||||
* 描述:网络常量
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
const val URL_YOUTUBE_API = "https://www.googleapis.com"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述:其他常量
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
const val YOUTUBE_API_KEY = "AIzaSyBm9k2lS_j7Fdd43NEPkcfikJRotup5DMY"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.gamedog.vididin
|
||||||
|
|
||||||
|
object VidiConst {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const val URL_DISCORD: String = "https://www.baidu.com"
|
||||||
|
const val URL_GAME: String = "https://www.baidu.com"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述:网络常量
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const val URL_YOUTUBE_API_OLD = "https://www.googleapis.com"
|
||||||
|
|
||||||
|
const val URL_YOUTUBE_API = "https://vd.rsappinc.com"
|
||||||
|
|
||||||
|
const val URL_ZERO_BUY: String = "https://jt.3idiotstudio.com"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述:其他常量
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const val YOUTUBE_API_KEY = "AIzaSyBm9k2lS_j7Fdd43NEPkcfikJRotup5DMY"
|
||||||
|
|
||||||
|
const val GOLD_IN_CONFIG: String = "金币"
|
||||||
|
|
||||||
|
const val PER_CASH_COST_GOLD_NUM = 1000
|
||||||
|
const val WATCH_AD_REWARD_GOLD = 200
|
||||||
|
|
||||||
|
const val ZEROBUY_SECRET: String = "1f04c57a"
|
||||||
|
const val ZEROBUY_APPID: String = "com.vididin.real.money.game"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -6,4 +6,36 @@ object VididinEvents {
|
||||||
const val Event_Account_Cash_Changed = 602
|
const val Event_Account_Cash_Changed = 602
|
||||||
const val Event_Account_Bank_Info_Changed = 603
|
const val Event_Account_Bank_Info_Changed = 603
|
||||||
|
|
||||||
|
|
||||||
|
const val Event_HOME_WATCH_Time_TICK = 700
|
||||||
|
const val Event_Finish_One_Video = 701
|
||||||
|
const val Event_Finish_One_Ad = 702
|
||||||
|
const val Event_Finish_One_Sign = 703
|
||||||
|
const val Event_Finish_One_Zerobuy = 704
|
||||||
|
|
||||||
|
const val EVENT_DAILY_WATCHED_VIDEO_NUM_CHANGED = 705
|
||||||
|
const val EVENT_DAILY_WATCHED_AD_NUM_CHANGED = 706
|
||||||
|
|
||||||
|
const val EVENT_BOX_TASK_STATE_CHANGED = 707
|
||||||
|
const val EVENT_NEWBIE_NOTIFY_TASK_CHANGED = 708
|
||||||
|
const val EVENT_NEWBIE_FIRST_WITHDRAW_TASK_CHANGED = 709
|
||||||
|
const val EVENT_NEWBIE_DISCORD_TASK_CHANGED = 710
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const val Event_AD_TASK_TYPE_Convert_Gold_2_Cash = 800
|
||||||
|
const val Event_AD_TASK_TYPE_Watch_Ad_Earn_Gold = 801
|
||||||
|
const val Event_AD_TASK_TYPE_Watch_Ad_Daily = 802
|
||||||
|
const val Event_AD_TASK_TYPE_Withdraw = 803
|
||||||
|
const val Event_AD_TASK_TYPE_Complement = 804
|
||||||
|
const val Event_AD_TASK_TYPE_BOX_TASK = 805
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// UI jump related
|
||||||
|
const val EVENT_JUMP_2_FIRST_WITHDRAW = 900
|
||||||
|
const val EVENT_JUMP_2_VIDEO = 901
|
||||||
|
const val EVENT_JUMP_2_SIGN= 902
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -103,10 +103,10 @@ class MainTabsAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun ViewBinding.onTabClickAgainHandle(index: Int) {
|
private fun ViewBinding.onTabClickAgainHandle(index: Int) {
|
||||||
val currentFragment = mainFragmentStateAdapter.getFragmentByIndex(index)
|
val currentFragment = mainFragmentStateAdapter.getFragmentByIndex(index)
|
||||||
if (currentFragment is OnTabClickRefreshListener) {
|
if (currentFragment is OnTabClickRefreshListener) {
|
||||||
// 刷新 - 展示Loading
|
|
||||||
currentFragment.onTabClickRefresh(object : OnTabClickRefreshFinishListener {
|
currentFragment.onTabClickRefresh(object : OnTabClickRefreshFinishListener {
|
||||||
override fun onTabClickRefreshFinish() {
|
override fun onTabClickRefreshFinish() {
|
||||||
setTabStyle(1)
|
setTabStyle(1)
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ interface YoutubeApi {
|
||||||
): ResYoutubePlayList
|
): ResYoutubePlayList
|
||||||
|
|
||||||
@GET("/youtube/v3/videos")
|
@GET("/youtube/v3/videos")
|
||||||
suspend fun getVideoList(
|
suspend fun getVideoList_old(
|
||||||
@Query("part") part: String= URLEncoder.encode("snippet", "UTF-8"),
|
@Query("part") part: String= URLEncoder.encode("snippet", "UTF-8"),
|
||||||
@Query("key") key: String= VidiConst.YOUTUBE_API_KEY,
|
@Query("key") key: String= VidiConst.YOUTUBE_API_KEY,
|
||||||
@Query("videoDuration") videoDuration: String= "short",
|
@Query("videoDuration") videoDuration: String= "short",
|
||||||
|
|
@ -56,10 +56,9 @@ interface YoutubeApi {
|
||||||
): ResYoutubePlayList
|
): ResYoutubePlayList
|
||||||
|
|
||||||
|
|
||||||
/*
|
@GET("/videos")
|
||||||
https://www.googleapis.com/youtube/v3/videos?part=id&chart=mostPopular®ionCode=BR&maxResults=10&key=AIzaSyBm9k2lS_j7Fdd43NEPkcfikJRotup5DMY
|
suspend fun getVideoList(
|
||||||
https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics&chart=mostPopular®ionCode=BR&maxResults=10&key=AIzaSyBm9k2lS_j7Fdd43NEPkcfikJRotup5DMY
|
@Query("video") video: String? = URLEncoder.encode("", "UTF-8"),
|
||||||
*/
|
): ResYoutubePlayList
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,13 +2,17 @@ package com.gamedog.vididin.beans
|
||||||
|
|
||||||
|
|
||||||
data class Account(
|
data class Account(
|
||||||
|
var userId: Int = 0,
|
||||||
val accountId: String,
|
val accountId: String,
|
||||||
val deviceUUId: String,
|
val deviceUUId: String,
|
||||||
val token: String="",
|
val token: String="",
|
||||||
val createdAt: Long,
|
val createdAt: Long,
|
||||||
|
@Volatile
|
||||||
var goldCount: Long = 0L,
|
var goldCount: Long = 0L,
|
||||||
|
@Volatile
|
||||||
var cashCount: Float = 0F,
|
var cashCount: Float = 0F,
|
||||||
var bankInfo: BankInfo? = null,
|
var bankInfo: BankInfo? = null,
|
||||||
|
val zeroBuyServerSecret: String = "",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.gamedog.vididin.beans
|
||||||
|
|
||||||
|
data class RecordCash(
|
||||||
|
val id: Long,
|
||||||
|
val dateTime: String,
|
||||||
|
val status: TransactionStatus,
|
||||||
|
val statusText: String,
|
||||||
|
val description: String,
|
||||||
|
val amount: String,
|
||||||
|
val amountColor: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
enum class TransactionStatus {
|
||||||
|
SUCCESS, FAILED, PROCESSING, REDEEM
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.gamedog.vididin.beans
|
||||||
|
|
||||||
|
data class RecordGold(
|
||||||
|
val id: Long,
|
||||||
|
val dateTime: String,
|
||||||
|
val status: TransactionStatus,
|
||||||
|
val statusText: String,
|
||||||
|
val description: String,
|
||||||
|
val amount: String,
|
||||||
|
val amountColor: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
|
@ -5,92 +5,20 @@ import com.ama.core.model.BaseFragmentStateDiffItem
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class ResYoutubeChannel(
|
|
||||||
val id: String,
|
|
||||||
val name: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ResYoutubePlayList (
|
data class ResYoutubePlayList (
|
||||||
val kind: String,
|
val videos: List<YoutubeVideo>,
|
||||||
val etag: String, // TODO - this is Etag type
|
|
||||||
val nextPageToken: String,
|
|
||||||
val prevPageToken: String,
|
|
||||||
val pageInfo: PageInfo,
|
|
||||||
val items: List<YoutubeVideo>,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class PageInfo(
|
|
||||||
val totalResults: Int,
|
|
||||||
val resultsPerPage: Int,
|
|
||||||
)
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class YoutubeVideo(
|
data class YoutubeVideo(
|
||||||
val kind: String,
|
|
||||||
val etag: String,
|
|
||||||
val id: String,
|
val id: String,
|
||||||
val snippet: Snippet,
|
val channel_title: String,
|
||||||
val status: Status,
|
val description: String,
|
||||||
|
|
||||||
val contentDetails: ContentDetails,
|
|
||||||
val player: Player,
|
|
||||||
val localizations: Localizations,
|
|
||||||
) : BaseFragmentStateDiffItem {
|
) : BaseFragmentStateDiffItem {
|
||||||
override fun getPrimaryKey() = id
|
override fun getPrimaryKey() = id
|
||||||
override fun getItemId() = id.hashCode().toLong()
|
override fun getItemId() = id.hashCode().toLong()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class ContentDetails(
|
|
||||||
val itemCount: Int,
|
|
||||||
)
|
|
||||||
@Serializable
|
|
||||||
data class Player(
|
|
||||||
val embedHtml: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class Localizations(
|
|
||||||
val title: String,
|
|
||||||
val description: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class Snippet(
|
|
||||||
val publishedAt: String,
|
|
||||||
val channelId: String,
|
|
||||||
val title: String,
|
|
||||||
val description: String,
|
|
||||||
//val thumbnails: Thumbnail,
|
|
||||||
val channelTitle: String,
|
|
||||||
val defaultLanguage: String,
|
|
||||||
val localized: Localized,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class Localized(
|
|
||||||
val title: String,
|
|
||||||
val description: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class Thumbnail(
|
|
||||||
val standard: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class Status(
|
|
||||||
val privacyStatus: String,
|
|
||||||
val podcastStatus: Int,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
package com.gamedog.vididin.beans
|
||||||
|
|
||||||
|
|
||||||
|
import com.ama.core.model.BaseFragmentStateDiffItem
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ResYoutubeChannel(
|
||||||
|
val id: String,
|
||||||
|
val name: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ResYoutubePlayList (
|
||||||
|
val kind: String,
|
||||||
|
val etag: String, // TODO - this is Etag type
|
||||||
|
val nextPageToken: String,
|
||||||
|
val prevPageToken: String,
|
||||||
|
val pageInfo: PageInfo,
|
||||||
|
val items: List<YoutubeVideo>,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class PageInfo(
|
||||||
|
val totalResults: Int,
|
||||||
|
val resultsPerPage: Int,
|
||||||
|
)
|
||||||
|
@Serializable
|
||||||
|
data class YoutubeVideo(
|
||||||
|
val kind: String,
|
||||||
|
val etag: String,
|
||||||
|
val id: String,
|
||||||
|
val snippet: Snippet,
|
||||||
|
val status: Status,
|
||||||
|
|
||||||
|
val contentDetails: ContentDetails,
|
||||||
|
val player: Player,
|
||||||
|
val localizations: Localizations,
|
||||||
|
) : BaseFragmentStateDiffItem {
|
||||||
|
override fun getPrimaryKey() = id
|
||||||
|
override fun getItemId() = id.hashCode().toLong()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ContentDetails(
|
||||||
|
val itemCount: Int,
|
||||||
|
)
|
||||||
|
@Serializable
|
||||||
|
data class Player(
|
||||||
|
val embedHtml: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Localizations(
|
||||||
|
val title: String,
|
||||||
|
val description: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Snippet(
|
||||||
|
val publishedAt: String,
|
||||||
|
val channelId: String,
|
||||||
|
val title: String,
|
||||||
|
val description: String,
|
||||||
|
//val thumbnails: Thumbnail,
|
||||||
|
val channelTitle: String,
|
||||||
|
val defaultLanguage: String,
|
||||||
|
val localized: Localized,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Localized(
|
||||||
|
val title: String,
|
||||||
|
val description: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Thumbnail(
|
||||||
|
val standard: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Status(
|
||||||
|
val privacyStatus: String,
|
||||||
|
val podcastStatus: Int,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.gamedog.vididin.beans
|
||||||
|
|
||||||
|
|
||||||
|
data class ZeroBuyResp (
|
||||||
|
val Code: Int,
|
||||||
|
val Message: String,
|
||||||
|
|
||||||
|
val UserId: Int,
|
||||||
|
val CurrentPurchases: String,
|
||||||
|
val FinishedPurchases: String,
|
||||||
|
var mCurrentList: List<ZeroBuyItem>?,
|
||||||
|
var mFinishedList: List<ZeroBuyItem>?,
|
||||||
|
val Content: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
data class ZeroBuyItem (
|
||||||
|
val id:Int = 0,
|
||||||
|
val title: String? = null,
|
||||||
|
val start_time:Long = 0,
|
||||||
|
val end_time:Long = 0,
|
||||||
|
val target_num:Int = 0,
|
||||||
|
val cost:Int = 0,
|
||||||
|
val price: String? = null,
|
||||||
|
val image:Int = 0,
|
||||||
|
val current_users: List<Int>? = null,
|
||||||
|
val winners: List<Int>? = null,
|
||||||
|
val redeem_code: String? = null,
|
||||||
|
val completed: Boolean = false,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -12,12 +12,14 @@ import com.gamedog.vididin.router.DefaultFeedbackRouter
|
||||||
import com.gamedog.vididin.router.DefaultPrivacyRouter
|
import com.gamedog.vididin.router.DefaultPrivacyRouter
|
||||||
import com.gamedog.vididin.router.DefaultSplashRouter
|
import com.gamedog.vididin.router.DefaultSplashRouter
|
||||||
import com.gamedog.vididin.router.DefaultVersionRouter
|
import com.gamedog.vididin.router.DefaultVersionRouter
|
||||||
|
import com.gamedog.vididin.router.DefaultWatchAdRouter
|
||||||
import com.gamedog.vididin.router.DefaultWithdrawRecordRouter
|
import com.gamedog.vididin.router.DefaultWithdrawRecordRouter
|
||||||
import com.gamedog.vididin.router.IRouterFeedback
|
import com.gamedog.vididin.router.IRouterFeedback
|
||||||
import com.gamedog.vididin.router.IRouterPrivacy
|
import com.gamedog.vididin.router.IRouterPrivacy
|
||||||
import com.gamedog.vididin.router.IRouterSplash
|
import com.gamedog.vididin.router.IRouterSplash
|
||||||
import com.gamedog.vididin.router.IRouterVersion
|
import com.gamedog.vididin.router.IRouterVersion
|
||||||
import com.gamedog.vididin.router.IRouterWithdrawRecord
|
import com.gamedog.vididin.router.IRouterWithdrawRecord
|
||||||
|
import com.gamedog.vididin.router.IRouterWatchAd
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
|
|
@ -98,4 +100,12 @@ object VersionModule {
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideRouter(): IRouterVersion = DefaultVersionRouter()
|
fun provideRouter(): IRouterVersion = DefaultVersionRouter()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@InstallIn(SingletonComponent::class)
|
||||||
|
object WatchAd {
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideRouter(): IRouterWatchAd = DefaultWatchAdRouter()
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,8 @@ package com.gamedog.vididin.core.network.di
|
||||||
|
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import com.ama.core.architecture.util.DeviceUtil
|
||||||
|
import com.gamedog.vididin.request.RequestUtil
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.MediaType.Companion.toMediaType
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
|
|
@ -24,26 +26,23 @@ class GlobalInterceptor : Interceptor {
|
||||||
val emptyBody = "{}".toRequestBody("application/json;charset=utf-8".toMediaType())
|
val emptyBody = "{}".toRequestBody("application/json;charset=utf-8".toMediaType())
|
||||||
val requestBody = if (bodyStr.isNotBlank()) request.body else emptyBody
|
val requestBody = if (bodyStr.isNotBlank()) request.body else emptyBody
|
||||||
|
|
||||||
|
val timeSec = RequestUtil.getTimestampSec()
|
||||||
|
|
||||||
val headersBuilder = Headers.Builder()
|
val requestBuilder = chain.request().newBuilder()
|
||||||
/*
|
.addHeader("User-Agent", "Android")
|
||||||
.add("authorazation", "Bearer xxxxx")
|
.addHeader("Accept-Language", Locale.getDefault().toLanguageTag())
|
||||||
.add("AUTH_DID", AppUtils.getAndroidID())
|
.addHeader("Content-Type", "application/json")
|
||||||
.add("platform", AppConstant.APP_CLIENT)
|
.addHeader("Accept", "application/json")
|
||||||
.add("Authorization", "Bearer xxx")
|
.addHeader("Accept-Charset", "utf-8")
|
||||||
.add("versionNum", "100")
|
// server real defined
|
||||||
*/
|
.addHeader("ApplicationId", RequestUtil.Request_APPId)
|
||||||
.add("User-Agent", "Android")
|
.addHeader("Timestamp", timeSec.toString())
|
||||||
.add("Accept-Language", Locale.getDefault().toLanguageTag())
|
.addHeader("Sign", RequestUtil.getRequestSign(timeSec))
|
||||||
.add("Content-Type", "application/json")
|
.addHeader("DeviceId", DeviceUtil.generateDeviceId())
|
||||||
.add("Accept", "application/json")
|
.addHeader("authorazation", "Bearer xxxxx")
|
||||||
.add("Accept-Charset", "utf-8")
|
|
||||||
|
|
||||||
|
request = requestBuilder.build()
|
||||||
|
|
||||||
val headers = headersBuilder.build()
|
|
||||||
request = chain.request().newBuilder()
|
|
||||||
.headers(headers)
|
|
||||||
.build()
|
|
||||||
val response = chain.proceed(request)
|
val response = chain.proceed(request)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
package com.gamedog.vididin.core.network.di
|
||||||
|
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import com.ama.core.architecture.util.DeviceUtil
|
||||||
|
import com.gamedog.vididin.request.RequestUtil
|
||||||
|
import okhttp3.Headers
|
||||||
|
import okhttp3.Interceptor
|
||||||
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.RequestBody
|
||||||
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
|
import okhttp3.Response
|
||||||
|
import okhttp3.ResponseBody
|
||||||
|
import okhttp3.ResponseBody.Companion.asResponseBody
|
||||||
|
import okio.Buffer
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
|
||||||
|
class GlobalInterceptor2 : Interceptor {
|
||||||
|
|
||||||
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
|
var request = chain.request()
|
||||||
|
val bodyStr = readBody(chain.request().body)
|
||||||
|
val emptyBody = "{}".toRequestBody("application/json;charset=utf-8".toMediaType())
|
||||||
|
val requestBody = if (bodyStr.isNotBlank()) request.body else emptyBody
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
val requestBuilder = chain.request().newBuilder()
|
||||||
|
.addHeader("User-Agent", "Android")
|
||||||
|
.addHeader("Accept-Language", Locale.getDefault().toLanguageTag())
|
||||||
|
.addHeader("Content-Type", "application/json")
|
||||||
|
.addHeader("Accept", "application/json")
|
||||||
|
.addHeader("Accept-Charset", "utf-8")
|
||||||
|
// server real defined
|
||||||
|
.addHeader("ApplicationId", RequestUtil.Request_ZeroBuy_APPId)
|
||||||
|
.addHeader("DeviceId", DeviceUtil.generateDeviceId())
|
||||||
|
.addHeader("authorazation", "Bearer xxxxx")
|
||||||
|
|
||||||
|
request = requestBuilder.build()
|
||||||
|
|
||||||
|
val response = chain.proceed(request)
|
||||||
|
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
try {
|
||||||
|
val contentStr = clone(response.body)?.string()
|
||||||
|
Log.d("RetroLog" ,
|
||||||
|
"""
|
||||||
|
———————————————— 请求 Start ——————————————————————————————
|
||||||
|
${request.url}
|
||||||
|
******** 请求头 ${request.method} ********:
|
||||||
|
${getRequestHeadersString(request)}
|
||||||
|
******** 请求体(当post等时) ********:
|
||||||
|
${readBody(requestBody)}
|
||||||
|
******** 请求响应 ********:
|
||||||
|
$contentStr
|
||||||
|
———————————————— 请求 End ———————————————————————————————
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.d("RetroLog" , "GlobalInterceptor request.exception : ${e.localizedMessage}}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun getRequestHeadersString(request: Request): String {
|
||||||
|
val headers = request.headers
|
||||||
|
val headerCount = headers.size
|
||||||
|
|
||||||
|
val sb = StringBuilder()
|
||||||
|
for (i in 0 until headerCount) {
|
||||||
|
val key = headers.name(i)
|
||||||
|
val value = headers.value(i)
|
||||||
|
sb.append("$key=$value\n")
|
||||||
|
}
|
||||||
|
return sb.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun readBody(body: RequestBody?): String {
|
||||||
|
val buffer = Buffer()
|
||||||
|
body?.writeTo(buffer)
|
||||||
|
return buffer.readUtf8()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Throws(IOException::class)
|
||||||
|
private fun clone(body: ResponseBody?): ResponseBody? {
|
||||||
|
val source = body?.source()
|
||||||
|
if (source?.request(Long.MAX_VALUE) == true) throw IOException("body too long!")
|
||||||
|
val bufferedCopy = source?.buffer?.clone()
|
||||||
|
return bufferedCopy?.asResponseBody(body.contentType(), body.contentLength())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -45,7 +45,6 @@ internal object NetworkModule {
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun providesRetrofit(
|
fun providesRetrofit(
|
||||||
networkJson: Json,
|
|
||||||
okhttpCallFactory: dagger.Lazy<Call.Factory>,
|
okhttpCallFactory: dagger.Lazy<Call.Factory>,
|
||||||
): Retrofit {
|
): Retrofit {
|
||||||
return Retrofit.Builder()
|
return Retrofit.Builder()
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import com.gamedog.vididin.router.IRouterPrivacy
|
||||||
import com.gamedog.vididin.router.IRouterSplash
|
import com.gamedog.vididin.router.IRouterSplash
|
||||||
import com.gamedog.vididin.router.IRouterVersion
|
import com.gamedog.vididin.router.IRouterVersion
|
||||||
import com.gamedog.vididin.router.IRouterWithdrawRecord
|
import com.gamedog.vididin.router.IRouterWithdrawRecord
|
||||||
|
import com.gamedog.vididin.router.IRouterWatchAd
|
||||||
import dagger.hilt.EntryPoint
|
import dagger.hilt.EntryPoint
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
|
|
@ -38,6 +39,7 @@ interface RouterEntryPoint {
|
||||||
fun feedbackRouter(): IRouterFeedback
|
fun feedbackRouter(): IRouterFeedback
|
||||||
fun splashRouter(): IRouterSplash
|
fun splashRouter(): IRouterSplash
|
||||||
fun withdrawRecordRouter(): IRouterWithdrawRecord
|
fun withdrawRecordRouter(): IRouterWithdrawRecord
|
||||||
|
fun watchAdRouter(): IRouterWatchAd
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,33 @@ package com.gamedog.vididin.features.benefit
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import com.ama.core.architecture.appBase.AppViewsActivity
|
import com.ama.core.architecture.appBase.AppViewsActivity
|
||||||
|
import com.ama.core.architecture.ext.toast
|
||||||
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
|
import com.ama.core.architecture.util.ResUtil
|
||||||
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
|
import com.gamedog.vididin.R
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
|
import com.gamedog.vididin.features.benefit.widget.BenefitTaskItemView
|
||||||
|
import com.gamedog.vididin.main.fragments.task.DailySignDialog
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
|
import com.gamedog.vididin.manager.TaskManager
|
||||||
|
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_AD
|
||||||
|
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_VIDEO
|
||||||
|
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_SIGN
|
||||||
|
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_ZERO_BUY
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlin.getValue
|
import kotlin.getValue
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_FINISH
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_CLAIMED
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_EXPIRED
|
||||||
|
import com.gamedog.vididin.router.Router
|
||||||
import com.gamedog.vididin.databinding.ActivityBenefitBinding as ViewBinding
|
import com.gamedog.vididin.databinding.ActivityBenefitBinding as ViewBinding
|
||||||
import com.gamedog.vididin.main.MainUiState as UiState
|
import com.gamedog.vididin.main.MainUiState as UiState
|
||||||
import com.gamedog.vididin.main.MainViewModel as ViewModel
|
import com.gamedog.vididin.main.MainViewModel as ViewModel
|
||||||
|
|
@ -16,6 +38,8 @@ import com.gamedog.vididin.main.MainViewModel as ViewModel
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class BenefitActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabStyleListener {
|
class BenefitActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabStyleListener {
|
||||||
|
|
||||||
|
private val mSubTaskViewList = mutableListOf<BenefitTaskItemView>()
|
||||||
|
|
||||||
|
|
||||||
override val mViewModel: ViewModel by viewModels()
|
override val mViewModel: ViewModel by viewModels()
|
||||||
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
||||||
|
|
@ -26,21 +50,20 @@ class BenefitActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
|
|
||||||
|
|
||||||
override fun ViewBinding.initViews() {
|
override fun ViewBinding.initViews() {
|
||||||
|
titlebar.setTitleText(R.string.benefit)
|
||||||
taskItem1.setActionFun {
|
initViewsByTaskState()
|
||||||
gotoWatchVideo()
|
|
||||||
}
|
|
||||||
taskItem2.setActionFun {
|
|
||||||
gotoWatchVideo()
|
|
||||||
}
|
|
||||||
taskItem3.setActionFun {
|
|
||||||
gotoWatchVideo()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initListeners() {
|
|
||||||
|
|
||||||
|
|
||||||
|
override fun ViewBinding.initListeners() {
|
||||||
|
registerEvents({ data->
|
||||||
|
when (data?.mEventType) {
|
||||||
|
VididinEvents.EVENT_BOX_TASK_STATE_CHANGED -> {
|
||||||
|
updateUI()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, VididinEvents.EVENT_BOX_TASK_STATE_CHANGED)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initObservers() {
|
override fun ViewBinding.initObservers() {
|
||||||
|
|
@ -56,10 +79,182 @@ class BenefitActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun gotoWatchVideo() {
|
private fun initViewsByTaskState() {
|
||||||
//TODO("Not yet implemented")
|
initAddSubTaskViews()
|
||||||
|
updateSubTasksUI()
|
||||||
|
updateTopBoxesUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateUI() {
|
||||||
|
updateSubTasksUI()
|
||||||
|
updateTopBoxesUI()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initAddSubTaskViews() {
|
||||||
|
val taskStateHelper = TaskManager.instance().boxTaskStatus()
|
||||||
|
val currentBoxState = taskStateHelper.getStatusBean().tasks[taskStateHelper.getCurrentBoxIndex()]
|
||||||
|
|
||||||
|
currentBoxState.tasks.forEachIndexed { index, subTask ->
|
||||||
|
val separateLine = View(this@BenefitActivity)
|
||||||
|
separateLine.setBackgroundResource(R.color.gray_f2)
|
||||||
|
binding.llSubTaskContainer.addView(separateLine, ViewGroup.LayoutParams.MATCH_PARENT, ResUtil.getPixelSize(R.dimen.dp1))
|
||||||
|
|
||||||
|
val subTaskView = BenefitTaskItemView(this@BenefitActivity)
|
||||||
|
subTaskView.setActionFun { handleActionButClicked(subTask.task_type) }
|
||||||
|
val subViewParam = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
|
subViewParam.topMargin = ResUtil.getPixelSize(R.dimen.dp10)
|
||||||
|
subViewParam.bottomMargin = ResUtil.getPixelSize(R.dimen.dp10)
|
||||||
|
binding.llSubTaskContainer.addView(subTaskView, subViewParam)
|
||||||
|
|
||||||
|
mSubTaskViewList.add(subTaskView)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleActionButClicked(taskType: Int) {
|
||||||
|
when (taskType) {
|
||||||
|
BOX_SUB_TASK_TYPE_AD -> {
|
||||||
|
Router.WatchAd.startActivity(this@BenefitActivity, VididinEvents.Event_AD_TASK_TYPE_BOX_TASK, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
BOX_SUB_TASK_TYPE_SIGN -> {
|
||||||
|
DailySignDialog(this@BenefitActivity).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
BOX_SUB_TASK_TYPE_VIDEO -> {
|
||||||
|
finish()
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.EVENT_JUMP_2_VIDEO, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
BOX_SUB_TASK_TYPE_ZERO_BUY -> {
|
||||||
|
Router.ZeroBuy.startActivity(this@BenefitActivity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateSubTasksUI() {
|
||||||
|
val taskStateHelper = TaskManager.instance().boxTaskStatus()
|
||||||
|
val currentBoxIndex = taskStateHelper.getCurrentBoxIndex()
|
||||||
|
val subTaskStateList = taskStateHelper.getStatusBean().tasks[currentBoxIndex].tasks
|
||||||
|
|
||||||
|
if (subTaskStateList.size == mSubTaskViewList.size) {
|
||||||
|
mSubTaskViewList.forEachIndexed { index, view ->
|
||||||
|
view.updateUIByState(subTaskStateList[index], currentBoxIndex,index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateTopBoxesUI() {
|
||||||
|
val taskStateHelper = TaskManager.instance().boxTaskStatus()
|
||||||
|
val boxStateList = taskStateHelper.getStatusBean().tasks
|
||||||
|
|
||||||
|
with (binding) {
|
||||||
|
boxStateList.forEachIndexed { index, curBoxState ->
|
||||||
|
val stateEnum = taskStateHelper.getBoxStateEnum(index)
|
||||||
|
if (index == 0) {
|
||||||
|
ivSubtask1.setImageResource(getIconResByState(stateEnum))
|
||||||
|
tvSubtask1State.setText(getStrResByState(stateEnum))
|
||||||
|
tvSubtask1State.setTextColor(getStrColorByState(stateEnum))
|
||||||
|
|
||||||
|
with (tvSubtask1Reward) {
|
||||||
|
compoundDrawablePadding = if (stateEnum == STATE_FINISH || stateEnum == STATE_CLAIMED) 0 else ResUtil.getPixelSize(R.dimen.dp3)
|
||||||
|
val tvRewardIcon = getRewardTvDrawableRes(stateEnum)
|
||||||
|
setCompoundDrawables(ResUtil.getDrawable(tvRewardIcon), null, null, null)
|
||||||
|
val needShowNum = R.mipmap.icon_check_mark != tvRewardIcon
|
||||||
|
setText(if (needShowNum) { ResUtil.getString(R.string.cash) + " " + curBoxState.reward_value} else "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index == 1) {
|
||||||
|
ivSubtask2.setImageResource(getIconResByState(stateEnum))
|
||||||
|
tvSubtask2State.setText(getStrResByState(stateEnum))
|
||||||
|
tvSubtask2State.setTextColor(getStrColorByState(stateEnum))
|
||||||
|
|
||||||
|
with (tvSubtask2Reward) {
|
||||||
|
compoundDrawablePadding = if (stateEnum == STATE_FINISH || stateEnum == STATE_CLAIMED) 0 else ResUtil.getPixelSize(R.dimen.dp3)
|
||||||
|
val tvRewardIcon = getRewardTvDrawableRes(stateEnum)
|
||||||
|
setCompoundDrawables(ResUtil.getDrawable(tvRewardIcon), null, null, null)
|
||||||
|
val needShowNum = R.mipmap.icon_check_mark != tvRewardIcon
|
||||||
|
setText(if (needShowNum) { ResUtil.getString(R.string.cash) + " " + curBoxState.reward_value} else "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index == 2) {
|
||||||
|
ivSubtask3.setImageResource(getIconResByState(stateEnum))
|
||||||
|
tvSubtask3State.setText(getStrResByState(stateEnum))
|
||||||
|
tvSubtask3State.setTextColor(getStrColorByState(stateEnum))
|
||||||
|
|
||||||
|
with (tvSubtask3Reward) {
|
||||||
|
compoundDrawablePadding = if (stateEnum == STATE_FINISH || stateEnum == STATE_CLAIMED) 0 else ResUtil.getPixelSize(R.dimen.dp3)
|
||||||
|
val tvRewardIcon = getRewardTvDrawableRes(stateEnum)
|
||||||
|
setCompoundDrawables(ResUtil.getDrawable(tvRewardIcon), null, null, null)
|
||||||
|
val needShowNum = R.mipmap.icon_check_mark != tvRewardIcon
|
||||||
|
setText(if (needShowNum) { ResUtil.getString(R.string.cash) + " " + curBoxState.reward_value} else "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val couldClaimCashNum = taskStateHelper.getCouldClaimCashNum()
|
||||||
|
with (tvResgatar) {
|
||||||
|
if (couldClaimCashNum > 0) {
|
||||||
|
setBackgroundResource(R.mipmap.icon_but_bg_green)
|
||||||
|
isClickable = true
|
||||||
|
} else {
|
||||||
|
setBackgroundResource(R.mipmap.but_bg_grady)
|
||||||
|
isClickable = false
|
||||||
|
}
|
||||||
|
|
||||||
|
setOnClickListener {
|
||||||
|
if (taskStateHelper.executeClaimCash()) {
|
||||||
|
AndroidUtil.showToast(String.format(ResUtil.getString(R.string.has_claim_box_cash_hint), couldClaimCashNum))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 总进度条, 奖励金额
|
||||||
|
val totalProgress = taskStateHelper.getCurrentBoxTotalProgress()
|
||||||
|
progressTasks.setProgress(totalProgress)
|
||||||
|
tvProgressNum.text = "($totalProgress%)"
|
||||||
|
tvHintRewardNum.text = buildString {
|
||||||
|
append(ResUtil.getString(R.string.cash))
|
||||||
|
append(" ")
|
||||||
|
append(taskStateHelper.getStatusBean().tasks[taskStateHelper.getCurrentBoxIndex()].reward_value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getIconResByState(state: Int): Int {
|
||||||
|
when (state) {
|
||||||
|
STATE_EXPIRED -> return R.mipmap.benefit_item_expired
|
||||||
|
STATE_FINISH, STATE_CLAIMED -> return R.mipmap.benefit_item_finished
|
||||||
|
else -> return R.mipmap.benefit_item_ongoing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getStrResByState(state: Int): Int {
|
||||||
|
when (state) {
|
||||||
|
STATE_EXPIRED -> return R.string.expired
|
||||||
|
STATE_FINISH, STATE_CLAIMED -> return R.string.finished
|
||||||
|
else -> return R.string.ongoing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getStrColorByState(state: Int): Int {
|
||||||
|
when (state) {
|
||||||
|
STATE_EXPIRED -> return R.color.gray_60
|
||||||
|
STATE_FINISH, STATE_CLAIMED -> return R.color.green_39
|
||||||
|
else -> return R.color.red_5c
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getRewardTvDrawableRes(state: Int): Int {
|
||||||
|
when (state) {
|
||||||
|
STATE_EXPIRED -> return R.mipmap.icon_cash_s_disable
|
||||||
|
STATE_FINISH, STATE_CLAIMED -> return R.mipmap.icon_check_mark
|
||||||
|
else -> return R.mipmap.icon_cash_s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,10 @@ import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
|
import com.gamedog.vididin.R
|
||||||
import com.gamedog.vididin.databinding.BenefitTaskItemViewBinding
|
import com.gamedog.vididin.databinding.BenefitTaskItemViewBinding
|
||||||
|
import com.gamedog.vididin.manager.TaskManager
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateBoxSub
|
||||||
|
|
||||||
|
|
||||||
class BenefitTaskItemView @JvmOverloads constructor(
|
class BenefitTaskItemView @JvmOverloads constructor(
|
||||||
|
|
@ -40,11 +43,29 @@ class BenefitTaskItemView @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setProgressInfo(progress: String) {
|
fun updateUIByState(subTaskState: TaskStateBoxSub, boxIndex: Int, subTaskIndex: Int) {
|
||||||
mBinding.tvProgressInfo.text = progress
|
with (mBinding) {
|
||||||
|
val finishNum = if (subTaskState.finishedNum > subTaskState.required_count) subTaskState.required_count else subTaskState.finishedNum
|
||||||
|
val progressNum: Int = finishNum * 100 / subTaskState.required_count
|
||||||
|
|
||||||
|
//ivItemIcon.setImageResource(R.mipmap.icon_cash_s)
|
||||||
|
tvItemTitle.setText(TaskManager.instance().boxTaskStatus().getSubTaskHintStrRes(boxIndex, subTaskIndex))
|
||||||
|
progressBar.setProgress(progressNum)
|
||||||
|
tvProgressInfo.text = "($finishNum/${subTaskState.required_count})"
|
||||||
|
|
||||||
|
with (tvAction) {
|
||||||
|
if (progressNum < 100) {
|
||||||
|
isClickable = true
|
||||||
|
setBackgroundResource( R.drawable.bg_benefit_item_action_bg)
|
||||||
|
setText(R.string.go_and_do)
|
||||||
|
} else {
|
||||||
|
isClickable = false
|
||||||
|
setBackgroundResource( R.drawable.bg_sub_task_disable)
|
||||||
|
setText(R.string.finished)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -28,17 +28,14 @@ class PrivacyActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
with(binding) {
|
with(binding) {
|
||||||
titlebar.setBackIconColor(R.color.black)
|
titlebar.setBackIconColor(R.color.black)
|
||||||
titlebar.setTitleText(R.string.privacy, R.color.black)
|
titlebar.setTitleText(R.string.privacy, R.color.black)
|
||||||
|
|
||||||
|
webView.loadUrl("https://www.baidu.com")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initWindowInsets() {
|
override fun ViewBinding.initWindowInsets() {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(contentRoot) { v, insets ->
|
setImmerseRootView(contentRoot)
|
||||||
val systemBars =
|
|
||||||
insets.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout())
|
|
||||||
v.updatePadding(top = systemBars.top)
|
|
||||||
insets
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initListeners() {
|
override fun ViewBinding.initListeners() {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import com.ama.core.architecture.appBase.AppViewsActivity
|
import com.ama.core.architecture.appBase.AppViewsActivity
|
||||||
import com.gamedog.vididin.R
|
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlin.getValue
|
import kotlin.getValue
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,8 @@ import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.core.view.ViewCompat
|
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
import androidx.core.view.updatePadding
|
|
||||||
import com.ama.core.architecture.appBase.AppViewsActivity
|
import com.ama.core.architecture.appBase.AppViewsActivity
|
||||||
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
|
@ -28,17 +26,15 @@ class VersionActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
with(binding) {
|
with(binding) {
|
||||||
titlebar.setBackIconColor(R.color.black)
|
titlebar.setBackIconColor(R.color.black)
|
||||||
titlebar.setTitleText(R.string.version, R.color.black)
|
titlebar.setTitleText(R.string.version, R.color.black)
|
||||||
|
|
||||||
|
|
||||||
|
tvVersion.text = AndroidUtil.getAppVersionInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initWindowInsets() {
|
override fun ViewBinding.initWindowInsets() {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(contentRoot) { v, insets ->
|
setImmerseRootView(contentRoot)
|
||||||
val systemBars =
|
|
||||||
insets.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout())
|
|
||||||
v.updatePadding(top = systemBars.top)
|
|
||||||
insets
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initListeners() {
|
override fun ViewBinding.initListeners() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
package com.gamedog.vididin.features.watchad
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.CountDownTimer
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import androidx.activity.addCallback
|
||||||
|
import androidx.activity.viewModels
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.core.view.updatePadding
|
||||||
|
import com.ama.core.architecture.appBase.AppViewsActivity
|
||||||
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.gamedog.vididin.VidiConst
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
|
import com.gamedog.vididin.main.fragments.task.DailySignSuccessDialog
|
||||||
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import kotlin.getValue
|
||||||
|
import com.gamedog.vididin.databinding.ActivityWatchAdBinding as ViewBinding
|
||||||
|
import com.gamedog.vididin.main.MainUiState as UiState
|
||||||
|
import com.gamedog.vididin.main.MainViewModel as ViewModel
|
||||||
|
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class WatchAdActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabStyleListener {
|
||||||
|
|
||||||
|
override val mViewModel: ViewModel by viewModels()
|
||||||
|
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
||||||
|
|
||||||
|
|
||||||
|
private lateinit var mCountDownTimer: CountDownTimer
|
||||||
|
private var mTaskType: Int = 0
|
||||||
|
private var mTaskData: String? = null
|
||||||
|
|
||||||
|
override fun ViewBinding.initViews() {
|
||||||
|
with(binding) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.initWindowInsets() {
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(contentRoot) { v, insets ->
|
||||||
|
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout())
|
||||||
|
v.updatePadding(top = systemBars.top)
|
||||||
|
insets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.initListeners() {
|
||||||
|
onBackPressedDispatcher.addCallback(this@WatchAdActivity) {
|
||||||
|
AndroidUtil.showToast("Can't exit while watching video")
|
||||||
|
}
|
||||||
|
|
||||||
|
stateCounter()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun notifyAdWatchFinish() {
|
||||||
|
NotifyMan.instance().sendEvent(mTaskType, null)
|
||||||
|
|
||||||
|
if (mTaskType != VididinEvents.Event_AD_TASK_TYPE_Watch_Ad_Earn_Gold) {
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.Event_Finish_One_Ad, NotifyMan.NotifyData(1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun stateCounter() {
|
||||||
|
mCountDownTimer = object : CountDownTimer(3000, 1000) {
|
||||||
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
|
val secondsRemaining = millisUntilFinished / 1000
|
||||||
|
binding.tvAdCounter.text = "${secondsRemaining}"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFinish() {
|
||||||
|
notifyAdWatchFinish()
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mCountDownTimer.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun readIntent(intent: Intent) {
|
||||||
|
super.readIntent(intent)
|
||||||
|
mTaskType = intent.getIntExtra(KEY_TASK_TYPE, 0)
|
||||||
|
mTaskData = intent.getStringExtra(KEY_TASK_DATA)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
mCountDownTimer.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.initObservers() {
|
||||||
|
//TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.onUiStateCollect(uiState: UiState) {
|
||||||
|
//TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTabIsDarkFont(isDarkFont: Boolean) {
|
||||||
|
//TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val KEY_TASK_TYPE = "KEY_TASK_TYPE"
|
||||||
|
private val KEY_TASK_DATA = "KEY_TASK_DATA"
|
||||||
|
|
||||||
|
internal fun startActivity(activity: Activity, taskType: Int, taskDataJson: String?) {
|
||||||
|
val intent = Intent(activity.applicationContext, WatchAdActivity::class.java)
|
||||||
|
intent.putExtra(KEY_TASK_TYPE, taskType)
|
||||||
|
intent.putExtra(KEY_TASK_DATA, taskDataJson)
|
||||||
|
activity.startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -48,4 +48,12 @@ object BankUtil {
|
||||||
val remainder = sum % 11
|
val remainder = sum % 11
|
||||||
return if (remainder < 2) 0 else 11 - remainder
|
return if (remainder < 2) 0 else 11 - remainder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun executeWithDraw() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -8,7 +8,6 @@ import com.ama.core.architecture.appBase.AppViewsActivity
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
import com.gamedog.vididin.VididinEvents
|
import com.gamedog.vididin.VididinEvents
|
||||||
import com.gamedog.vididin.beans.Account
|
|
||||||
import com.gamedog.vididin.core.login.login.AccountManager
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
import com.gamedog.vididin.features.withdraw.widget.WithDrawItemView
|
import com.gamedog.vididin.features.withdraw.widget.WithDrawItemView
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
|
|
@ -36,6 +35,8 @@ class WithDrawActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), On
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initViews() {
|
override fun ViewBinding.initViews() {
|
||||||
|
titlebar.setTitleText(R.string.sacar)
|
||||||
|
|
||||||
mItemViewList.add(withdraw01)
|
mItemViewList.add(withdraw01)
|
||||||
mItemViewList.add(withdraw10)
|
mItemViewList.add(withdraw10)
|
||||||
mItemViewList.add(withdraw20)
|
mItemViewList.add(withdraw20)
|
||||||
|
|
@ -73,7 +74,7 @@ class WithDrawActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), On
|
||||||
updateUIItemSelectStates(itemIndex)
|
updateUIItemSelectStates(itemIndex)
|
||||||
})
|
})
|
||||||
|
|
||||||
withdrawPix2.setIconAndText(R.mipmap.pix2, R.string.pix2, {
|
withdrawPix2.setIconAndText(R.mipmap.pix2_big, R.string.pix2, {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -85,8 +86,11 @@ class WithDrawActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), On
|
||||||
when(this) {
|
when(this) {
|
||||||
tvSacar -> {
|
tvSacar -> {
|
||||||
val hasBindBank = AccountManager.hasValidBankInfo()
|
val hasBindBank = AccountManager.hasValidBankInfo()
|
||||||
|
val cashNum = mItemViewList.get(mCurSelectedIndex).getCashNum()
|
||||||
if (!hasBindBank) {
|
if (!hasBindBank) {
|
||||||
WithdrawBindBankDialog(this@WithDrawActivity).show()
|
WithdrawBindBankDialog(this@WithDrawActivity).setWithDrawCashNum(cashNum).show()
|
||||||
|
} else {
|
||||||
|
WithdrawInfoConfirmDialog(this@WithDrawActivity).setWithDrawCashNum(cashNum).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.gamedog.vididin.features.withdraw
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
|
|
@ -11,10 +12,11 @@ import com.ama.core.architecture.widget.BindingDialog
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
import com.gamedog.vididin.core.login.login.AccountManager
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
import com.gamedog.vididin.databinding.DialogWithdrawBindingBankBinding as ViewBinding
|
import com.gamedog.vididin.databinding.DialogWithdrawBindingBankBinding as ViewBinding
|
||||||
import com.gamedog.vididin.router.Router
|
|
||||||
|
|
||||||
|
|
||||||
class WithdrawBindBankDialog(context: Context) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
class WithdrawBindBankDialog(activity: Activity) : BindingDialog<ViewBinding>(activity, ViewBinding::inflate) {
|
||||||
|
|
||||||
|
private var mWithdrawCashNum: Float = 0F
|
||||||
|
|
||||||
init {
|
init {
|
||||||
build()
|
build()
|
||||||
|
|
@ -36,6 +38,8 @@ class WithdrawBindBankDialog(context: Context) : BindingDialog<ViewBinding>(cont
|
||||||
|
|
||||||
tvConfirm -> {
|
tvConfirm -> {
|
||||||
saveBankAccount(mBinding.tvCpfEdit.text.toString().trim())
|
saveBankAccount(mBinding.tvCpfEdit.text.toString().trim())
|
||||||
|
WithdrawInfoConfirmDialog(mActivity).setWithDrawCashNum(mWithdrawCashNum).show()
|
||||||
|
dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -90,14 +94,17 @@ class WithdrawBindBankDialog(context: Context) : BindingDialog<ViewBinding>(cont
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotoWatchVideo() {
|
|
||||||
ownerActivity?.let { Router.Withdraw.startActivity(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetachedFromWindow() {
|
override fun onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow()
|
super.onDetachedFromWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setWithDrawCashNum(withdrawNum: Float): WithdrawBindBankDialog {
|
||||||
|
mWithdrawCashNum = withdrawNum
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
package com.gamedog.vididin.features.withdraw
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
|
||||||
import com.ama.core.architecture.widget.BindingDialog
|
|
||||||
import com.gamedog.vididin.databinding.DialogWithdrawBindingBankFinishBinding as ViewBinding
|
|
||||||
import com.gamedog.vididin.router.Router
|
|
||||||
|
|
||||||
|
|
||||||
class WithdrawBindBankFinishDialog(context: Context) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
build()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun build() {
|
|
||||||
with()
|
|
||||||
setCenter()
|
|
||||||
setMaskValue(0.8f)
|
|
||||||
setCanCancel(false)
|
|
||||||
|
|
||||||
mBinding.run {
|
|
||||||
setOnClickBatch(tvConfirm, ivClose) {
|
|
||||||
when (this) {
|
|
||||||
tvConfirm, ivClose -> {
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun gotoWatchVideo() {
|
|
||||||
ownerActivity?.let { Router.Withdraw.startActivity(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
package com.gamedog.vididin.features.withdraw
|
package com.gamedog.vididin.features.withdraw
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context
|
import android.app.Activity
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.widget.BindingDialog
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
import com.gamedog.vididin.databinding.DialogWithdrawFailBinding as ViewBinding
|
import com.gamedog.vididin.databinding.DialogWithdrawFailBinding as ViewBinding
|
||||||
import com.gamedog.vididin.router.Router
|
import com.gamedog.vididin.router.Router
|
||||||
|
|
||||||
|
|
||||||
class WithdrawFailDialog(context: Context) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
class WithdrawFailDialog(context: Activity) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
build()
|
build()
|
||||||
|
|
@ -22,18 +22,27 @@ class WithdrawFailDialog(context: Context) : BindingDialog<ViewBinding>(context,
|
||||||
setCanCancel(false)
|
setCanCancel(false)
|
||||||
|
|
||||||
mBinding.run {
|
mBinding.run {
|
||||||
setOnClickBatch(tvConfirm, ivClose) {
|
setOnClickBatch(tvActionFeedback, tvActionConfirm, ivClose) {
|
||||||
when (this) {
|
when (this) {
|
||||||
tvConfirm, ivClose -> {
|
ivClose -> {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
tvActionFeedback -> {
|
||||||
|
gotoFeedback()
|
||||||
|
}
|
||||||
|
|
||||||
|
tvActionConfirm -> {
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun gotoWatchVideo() {
|
private fun gotoFeedback() {
|
||||||
ownerActivity?.let { Router.Withdraw.startActivity(it) }
|
Router.Feedback.startActivity(mActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.gamedog.vididin.features.withdraw
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import com.ama.core.architecture.util.ResUtil
|
||||||
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
|
import com.gamedog.vididin.R
|
||||||
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
|
import com.gamedog.vididin.databinding.DialogWithdrawInfoConfirmBinding as ViewBinding
|
||||||
|
import com.gamedog.vididin.router.Router
|
||||||
|
|
||||||
|
|
||||||
|
class WithdrawInfoConfirmDialog(context: Activity) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
||||||
|
|
||||||
|
private var mWithdrawCashNum: Float = 0F
|
||||||
|
|
||||||
|
init {
|
||||||
|
build()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun build() {
|
||||||
|
with()
|
||||||
|
setCenter()
|
||||||
|
setMaskValue(0.8f)
|
||||||
|
setCanCancel(false)
|
||||||
|
|
||||||
|
mBinding.run {
|
||||||
|
setOnClickBatch(tvActionAlter, tvActionApply, ivClose) {
|
||||||
|
when (this) {
|
||||||
|
ivClose -> {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
tvActionAlter -> {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
tvActionApply -> {
|
||||||
|
WithdrawWatchAdDialog(mActivity).show()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun gotoWatchVideo() {
|
||||||
|
Router.Withdraw.startActivity(mActivity)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setWithDrawCashNum(withdrawNum: Float): WithdrawInfoConfirmDialog {
|
||||||
|
mWithdrawCashNum = withdrawNum
|
||||||
|
|
||||||
|
mBinding.tvCashNum.text = buildString {
|
||||||
|
append(ResUtil.getString(R.string.cash))
|
||||||
|
append(" ")
|
||||||
|
append(mWithdrawCashNum)
|
||||||
|
}
|
||||||
|
mBinding.tvCpfAccount.text = AccountManager.getBankInfo()?.bankAccount
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
package com.gamedog.vididin.features.withdraw
|
package com.gamedog.vididin.features.withdraw
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.widget.BindingDialog
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
import com.gamedog.vididin.databinding.DialogWithdrawSuccessBinding as ViewBinding
|
import com.gamedog.vididin.databinding.DialogWithdrawSuccessBinding as ViewBinding
|
||||||
import com.gamedog.vididin.router.Router
|
|
||||||
|
|
||||||
|
|
||||||
class WithdrawSuccessDialog(context: Context) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
class WithdrawSuccessDialog(context: Activity) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
build()
|
build()
|
||||||
|
|
@ -22,21 +22,17 @@ class WithdrawSuccessDialog(context: Context) : BindingDialog<ViewBinding>(conte
|
||||||
setCanCancel(false)
|
setCanCancel(false)
|
||||||
|
|
||||||
mBinding.run {
|
mBinding.run {
|
||||||
setOnClickBatch(tvConfirm, ivClose) {
|
setOnClickBatch(flAction, ivClose) {
|
||||||
when (this) {
|
when (this) {
|
||||||
tvConfirm, ivClose -> {
|
ivClose -> {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
flAction -> {
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotoWatchVideo() {
|
|
||||||
ownerActivity?.let { Router.Withdraw.startActivity(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.gamedog.vididin.features.withdraw
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
|
import com.gamedog.vididin.R
|
||||||
|
import com.gamedog.vididin.databinding.DialogWithdrawWatchAdBinding as ViewBinding
|
||||||
|
|
||||||
|
|
||||||
|
class WithdrawWatchAdDialog(context: Activity) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
||||||
|
|
||||||
|
private var mWithdrawCashNum: Float = 0F
|
||||||
|
|
||||||
|
init {
|
||||||
|
build()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun build() {
|
||||||
|
with()
|
||||||
|
setCenter()
|
||||||
|
setMaskValue(0.8f)
|
||||||
|
setCanCancel(false)
|
||||||
|
|
||||||
|
mBinding.run {
|
||||||
|
progressBar.setBarColor(R.color.blue_ba, R.color.blue_ff)
|
||||||
|
|
||||||
|
setOnClickBatch(flAction, ivClose) {
|
||||||
|
when (this) {
|
||||||
|
ivClose -> {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
flAction -> {
|
||||||
|
gotoWatchVideo()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun gotoWatchVideo() {
|
||||||
|
// TODO -
|
||||||
|
//Router.Withdraw.startActivity(mActivity)
|
||||||
|
|
||||||
|
WithdrawFailDialog(mActivity).show()
|
||||||
|
WithdrawSuccessDialog(mActivity).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -54,5 +54,9 @@ class WithDrawItemView @JvmOverloads constructor(
|
||||||
mBinding.root.setBackgroundResource(if (mIsSelected) R.drawable.withdraw_item_bg_selected else R.drawable.withdraw_item_bg_unselected)
|
mBinding.root.setBackgroundResource(if (mIsSelected) R.drawable.withdraw_item_bg_selected else R.drawable.withdraw_item_bg_unselected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getCashNum(): Float {
|
||||||
|
return mCashNum
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.gamedog.vididin.features.withdrawrecord
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.gamedog.vididin.beans.RecordCash
|
||||||
|
import com.gamedog.vididin.databinding.FragmentWithdrawRecordCashItemBinding as ViewBinding
|
||||||
|
|
||||||
|
class RecordCashRvAdapter : ListAdapter<RecordCash, RecordCashRvAdapter.ViewHolder>(DiffCallback()) {
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
val binding = ViewBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||||
|
return ViewHolder(binding)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
holder.bind(getItem(position))
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class ViewHolder(private val binding: ViewBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||||
|
fun bind(transaction: RecordCash) {
|
||||||
|
binding.tvDate.text = transaction.dateTime
|
||||||
|
binding.tvTitle.text = transaction.statusText
|
||||||
|
binding.tvDescription.text = transaction.description
|
||||||
|
binding.tvAmount.text = transaction.amount
|
||||||
|
binding.tvAmount.setTextColor(ContextCompat.getColor(binding.root.context, transaction.amountColor))
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DiffCallback : DiffUtil.ItemCallback<RecordCash>() {
|
||||||
|
override fun areItemsTheSame(oldItem: RecordCash, newItem: RecordCash): Boolean {
|
||||||
|
return oldItem.id == newItem.id
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun areContentsTheSame(oldItem: RecordCash, newItem: RecordCash): Boolean {
|
||||||
|
return oldItem == newItem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.gamedog.vididin.features.withdrawrecord
|
||||||
|
|
||||||
|
|
||||||
|
import com.ama.core.architecture.appBase.vm.AppViewModel
|
||||||
|
import com.gamedog.vididin.beans.RecordCash
|
||||||
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.flowOf
|
||||||
|
import javax.inject.Inject
|
||||||
|
import com.gamedog.vididin.features.withdrawrecord.RecordCashUiState as UiState
|
||||||
|
|
||||||
|
|
||||||
|
@HiltViewModel
|
||||||
|
class RecordCashViewModel @Inject constructor() : AppViewModel<UiState>() {
|
||||||
|
override val uiStateInitialValue: UiState = UiState()
|
||||||
|
override val uiStateFlow: Flow<UiState> = flowOf()
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
data class RecordCashUiState(
|
||||||
|
val mRecordList: MutableList<RecordCash> = mutableListOf()
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.gamedog.vididin.features.withdrawrecord
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.gamedog.vididin.beans.RecordGold
|
||||||
|
import com.gamedog.vididin.databinding.FragmentWithdrawRecordGoldItemBinding as ViewBinding
|
||||||
|
|
||||||
|
class RecordGoldRvAdapter : ListAdapter<RecordGold, RecordGoldRvAdapter.ViewHolder>(DiffCallback()) {
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
val binding = ViewBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||||
|
return ViewHolder(binding)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
holder.bind(getItem(position))
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class ViewHolder(private val binding: ViewBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||||
|
fun bind(transaction: RecordGold) {
|
||||||
|
binding.tvDate.text = transaction.dateTime
|
||||||
|
binding.tvTitle.text = transaction.statusText
|
||||||
|
binding.tvDescription.text = transaction.description
|
||||||
|
binding.tvAmount.text = transaction.amount
|
||||||
|
binding.tvAmount.setTextColor(ContextCompat.getColor(binding.root.context, transaction.amountColor))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DiffCallback : DiffUtil.ItemCallback<RecordGold>() {
|
||||||
|
override fun areItemsTheSame(oldItem: RecordGold, newItem: RecordGold): Boolean {
|
||||||
|
return oldItem.id == newItem.id
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun areContentsTheSame(oldItem: RecordGold, newItem: RecordGold): Boolean {
|
||||||
|
return oldItem == newItem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.gamedog.vididin.features.withdrawrecord
|
||||||
|
|
||||||
|
|
||||||
|
import com.ama.core.architecture.appBase.vm.AppViewModel
|
||||||
|
import com.gamedog.vididin.beans.RecordGold
|
||||||
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.flowOf
|
||||||
|
import javax.inject.Inject
|
||||||
|
import com.gamedog.vididin.features.withdrawrecord.RecordGoldUiState as UiState
|
||||||
|
|
||||||
|
|
||||||
|
@HiltViewModel
|
||||||
|
class RecordGoldViewModel @Inject constructor() : AppViewModel<UiState>() {
|
||||||
|
override val uiStateInitialValue: UiState = UiState()
|
||||||
|
override val uiStateFlow: Flow<UiState> = flowOf()
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
data class RecordGoldUiState(
|
||||||
|
val mRecordList: MutableList<RecordGold> = mutableListOf()
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.gamedog.vididin.features.withdrawrecord
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
|
import com.gamedog.vididin.features.withdrawrecord.fragments.CashRecordFragment
|
||||||
|
import com.gamedog.vididin.features.withdrawrecord.fragments.GoldRecordFragment
|
||||||
|
|
||||||
|
class ViewPagerAdapter(fragmentActivity: FragmentActivity) : FragmentStateAdapter(fragmentActivity) {
|
||||||
|
|
||||||
|
override fun getItemCount(): Int = 2
|
||||||
|
|
||||||
|
override fun createFragment(position: Int): Fragment {
|
||||||
|
return when (position) {
|
||||||
|
0 -> CashRecordFragment()
|
||||||
|
1 -> GoldRecordFragment()
|
||||||
|
else -> throw IllegalArgumentException("Invalid position: $position")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -8,8 +8,12 @@ import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import com.ama.core.architecture.appBase.AppViewsActivity
|
import com.ama.core.architecture.appBase.AppViewsActivity
|
||||||
|
import com.ama.core.architecture.util.ResUtil
|
||||||
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
|
import com.google.android.material.tabs.TabLayout
|
||||||
|
import com.google.android.material.tabs.TabLayoutMediator
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlin.getValue
|
import kotlin.getValue
|
||||||
import com.gamedog.vididin.databinding.ActivityWithdrawRecordBinding as ViewBinding
|
import com.gamedog.vididin.databinding.ActivityWithdrawRecordBinding as ViewBinding
|
||||||
|
|
@ -26,8 +30,15 @@ class WithdrawRecordActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>
|
||||||
override fun ViewBinding.initViews() {
|
override fun ViewBinding.initViews() {
|
||||||
|
|
||||||
with(binding) {
|
with(binding) {
|
||||||
titlebar.setBackIconColor(R.color.black)
|
setupViewPager()
|
||||||
titlebar.setTitleText(R.string.title_cash_record, R.color.black)
|
|
||||||
|
setOnClickBatch(ivBack) {
|
||||||
|
when (this) {
|
||||||
|
ivBack -> {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -58,10 +69,45 @@ class WithdrawRecordActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun setupViewPager() {
|
||||||
|
val adapter = ViewPagerAdapter(this)
|
||||||
|
binding.viewPager.adapter = adapter
|
||||||
|
|
||||||
|
with (binding.tabLayout) {
|
||||||
|
addOnTabSelectedListener(object: TabLayout.OnTabSelectedListener {
|
||||||
|
override fun onTabSelected(tab: TabLayout.Tab?) {
|
||||||
|
setTabTextColors(ResUtil.getColor(R.color.black),
|
||||||
|
ResUtil.getColor(if (selectedTabPosition == 0) R.color.green_39 else R.color.yellow_0b))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTabUnselected(tab: TabLayout.Tab?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTabReselected(tab: TabLayout.Tab?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
|
||||||
|
tab.text = when (position) {
|
||||||
|
0 -> ResUtil.getString(R.string.record_cash_title)
|
||||||
|
1 -> ResUtil.getString(R.string.record_gold_title)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}.attach()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
internal fun startActivity(activity: Activity) {
|
internal fun startActivity(activity: Activity) {
|
||||||
activity.startActivity(Intent(activity.applicationContext, WithdrawRecordActivity::class.java))
|
activity.startActivity(Intent(activity.applicationContext, WithdrawRecordActivity::class.java))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
package com.gamedog.vididin.features.withdrawrecord.fragments
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.viewModels
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.ama.core.architecture.appBase.AppViewsFragment
|
||||||
|
import com.ama.core.architecture.appBase.OnFragmentBackgroundListener
|
||||||
|
import com.ama.core.architecture.util.setStatusBarDarkFont
|
||||||
|
import com.gamedog.vididin.R
|
||||||
|
import com.gamedog.vididin.beans.RecordCash
|
||||||
|
import com.gamedog.vididin.beans.TransactionStatus
|
||||||
|
import com.gamedog.vididin.features.withdrawrecord.RecordCashRvAdapter
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import kotlin.getValue
|
||||||
|
import com.gamedog.vididin.databinding.FragmentWithdrawRecordCashBinding as ViewBinding
|
||||||
|
import com.gamedog.vididin.features.withdrawrecord.RecordCashUiState as UiState
|
||||||
|
import com.gamedog.vididin.features.withdrawrecord.RecordCashViewModel as ViewModel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class CashRecordFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(),
|
||||||
|
OnFragmentBackgroundListener {
|
||||||
|
private lateinit var mAdapter: RecordCashRvAdapter
|
||||||
|
override val mViewModel: ViewModel by viewModels()
|
||||||
|
override var isBackgroundBright: Boolean = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private var isStatusBarDarkFont = false
|
||||||
|
|
||||||
|
override fun inflateViewBinding(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
) = ViewBinding.inflate(inflater, container, false)
|
||||||
|
|
||||||
|
override fun ViewBinding.initWindowInsets() {
|
||||||
|
binding?.root?.let { setImmerseRootView(it) }
|
||||||
|
isStatusBarDarkFont = true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.initViews() {
|
||||||
|
setupRecyclerView()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.initListeners() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.initObservers() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.onUiStateCollect(uiState: UiState) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
setStatusBarDarkFont(isDarkFont = isStatusBarDarkFont)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun setupRecyclerView() {
|
||||||
|
mAdapter = RecordCashRvAdapter()
|
||||||
|
binding?.recyclerView?.adapter = mAdapter
|
||||||
|
binding?.recyclerView?.layoutManager = LinearLayoutManager(requireContext())
|
||||||
|
|
||||||
|
// 模拟数据
|
||||||
|
val transactions = listOf(
|
||||||
|
RecordCash(
|
||||||
|
id = 1,
|
||||||
|
dateTime = "2025/10/31 17:30",
|
||||||
|
status = TransactionStatus.SUCCESS,
|
||||||
|
statusText = "Sucesso",
|
||||||
|
description = "Você solicitou o saque com sucesso!",
|
||||||
|
amount = "-R$ 0,1",
|
||||||
|
amountColor = R.color.red_11
|
||||||
|
),
|
||||||
|
RecordCash(
|
||||||
|
id = 2,
|
||||||
|
dateTime = "2025/10/31 17:30",
|
||||||
|
status = TransactionStatus.FAILED,
|
||||||
|
statusText = "Falhou",
|
||||||
|
description = "Você solicitou o saque com sucesso!",
|
||||||
|
amount = "-R$ 0,0",
|
||||||
|
amountColor = R.color.red_11
|
||||||
|
),
|
||||||
|
RecordCash(
|
||||||
|
id = 3,
|
||||||
|
dateTime = "2025/10/31 17:30",
|
||||||
|
status = TransactionStatus.PROCESSING,
|
||||||
|
statusText = "Em processamento...",
|
||||||
|
description = "Você solicitou o saque com sucesso!",
|
||||||
|
amount = "-R$ 10,0",
|
||||||
|
amountColor = R.color.red_11
|
||||||
|
),
|
||||||
|
RecordCash(
|
||||||
|
id = 4,
|
||||||
|
dateTime = "2025/10/31 17:30",
|
||||||
|
status = TransactionStatus.REDEEM,
|
||||||
|
statusText = "Resgatar",
|
||||||
|
description = "Você resgatou 4980 moedas",
|
||||||
|
amount = "+R$ 10,0",
|
||||||
|
amountColor = R.color.green_39
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
mAdapter.submitList(transactions)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
internal fun newInstance() = CashRecordFragment()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
package com.gamedog.vididin.features.withdrawrecord.fragments
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.viewModels
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.ama.core.architecture.appBase.AppViewsFragment
|
||||||
|
import com.ama.core.architecture.appBase.OnFragmentBackgroundListener
|
||||||
|
import com.ama.core.architecture.util.setStatusBarDarkFont
|
||||||
|
import com.gamedog.vididin.R
|
||||||
|
import com.gamedog.vididin.beans.RecordGold
|
||||||
|
import com.gamedog.vididin.beans.TransactionStatus
|
||||||
|
import com.gamedog.vididin.features.withdrawrecord.RecordCashRvAdapter
|
||||||
|
import com.gamedog.vididin.features.withdrawrecord.RecordGoldRvAdapter
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import kotlin.getValue
|
||||||
|
import com.gamedog.vididin.databinding.FragmentWithdrawRecordGoldBinding as ViewBinding
|
||||||
|
import com.gamedog.vididin.features.withdrawrecord.RecordGoldUiState as UiState
|
||||||
|
import com.gamedog.vididin.features.withdrawrecord.RecordGoldViewModel as ViewModel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class GoldRecordFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(),
|
||||||
|
OnFragmentBackgroundListener {
|
||||||
|
private lateinit var mAdapter: RecordGoldRvAdapter
|
||||||
|
override val mViewModel: ViewModel by viewModels()
|
||||||
|
override var isBackgroundBright: Boolean = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private var isStatusBarDarkFont = false
|
||||||
|
|
||||||
|
override fun inflateViewBinding(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
) = ViewBinding.inflate(inflater, container, false)
|
||||||
|
|
||||||
|
override fun ViewBinding.initWindowInsets() {
|
||||||
|
binding?.root?.let { setImmerseRootView(it) }
|
||||||
|
isStatusBarDarkFont = true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.initViews() {
|
||||||
|
setupRecyclerView()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.initListeners() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.initObservers() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun ViewBinding.onUiStateCollect(uiState: UiState) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
setStatusBarDarkFont(isDarkFont = isStatusBarDarkFont)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun setupRecyclerView() {
|
||||||
|
mAdapter = RecordGoldRvAdapter()
|
||||||
|
binding?.recyclerView?.adapter = mAdapter
|
||||||
|
binding?.recyclerView?.layoutManager = LinearLayoutManager(requireContext())
|
||||||
|
|
||||||
|
// 模拟数据
|
||||||
|
val transactions = listOf(
|
||||||
|
RecordGold(
|
||||||
|
id = 1,
|
||||||
|
dateTime = "2025/10/31 17:30",
|
||||||
|
status = TransactionStatus.SUCCESS,
|
||||||
|
statusText = "Sucesso",
|
||||||
|
description = "Você solicitou o saque com sucesso!",
|
||||||
|
amount = "-R$ 0,1",
|
||||||
|
amountColor = R.color.red_11
|
||||||
|
),
|
||||||
|
RecordGold(
|
||||||
|
id = 2,
|
||||||
|
dateTime = "2025/10/31 17:30",
|
||||||
|
status = TransactionStatus.FAILED,
|
||||||
|
statusText = "Falhou",
|
||||||
|
description = "Você solicitou o saque com sucesso!",
|
||||||
|
amount = "-R$ 0,0",
|
||||||
|
amountColor = R.color.red_11
|
||||||
|
),
|
||||||
|
RecordGold(
|
||||||
|
id = 3,
|
||||||
|
dateTime = "2025/10/31 17:30",
|
||||||
|
status = TransactionStatus.PROCESSING,
|
||||||
|
statusText = "Em processamento...",
|
||||||
|
description = "Você solicitou o saque com sucesso!",
|
||||||
|
amount = "-R$ 10,0",
|
||||||
|
amountColor = R.color.red_11
|
||||||
|
),
|
||||||
|
RecordGold(
|
||||||
|
id = 4,
|
||||||
|
dateTime = "2025/10/31 17:30",
|
||||||
|
status = TransactionStatus.REDEEM,
|
||||||
|
statusText = "Resgatar",
|
||||||
|
description = "Você resgatou 4980 moedas",
|
||||||
|
amount = "+R$ 10,0",
|
||||||
|
amountColor = R.color.green_39
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
mAdapter.submitList(transactions)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
internal fun newInstance() = CashRecordFragment()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,25 +4,32 @@ import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.core.view.updatePadding
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import com.ama.core.architecture.appBase.AppViewsActivity
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import com.ama.core.architecture.appBase.AppViewsEmptyViewModelActivity
|
||||||
|
import com.ama.core.architecture.util.CommonItemDecoration
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.beans.ZeroBuyResp
|
||||||
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
|
import com.gamedog.vididin.features.zero.dialogs.ZeroBuyRulesDialog
|
||||||
import com.gamedog.vididin.router.Router
|
import com.gamedog.vididin.router.Router
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlin.getValue
|
import kotlinx.coroutines.launch
|
||||||
|
import com.gamedog.vididin.netbase.Result
|
||||||
import com.gamedog.vididin.databinding.ActivityZerobuyBinding as ViewBinding
|
import com.gamedog.vididin.databinding.ActivityZerobuyBinding as ViewBinding
|
||||||
import com.gamedog.vididin.main.MainUiState as UiState
|
|
||||||
import com.gamedog.vididin.main.MainViewModel as ViewModel
|
|
||||||
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class ZeroBuyActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabStyleListener {
|
class ZeroBuyActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
||||||
|
private val viewModel: ZeroBuyViewModel by viewModels()
|
||||||
|
private lateinit var mAdapter: ZeroItemAdapter
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override val mViewModel: ViewModel by viewModels()
|
|
||||||
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
||||||
|
|
||||||
override fun ViewBinding.initViews() {
|
override fun ViewBinding.initViews() {
|
||||||
|
|
@ -38,11 +45,22 @@ class ZeroBuyActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tvZeroGoldNum.text = AccountManager.getGold().toString()
|
||||||
|
|
||||||
titlebar.setTitleText(R.string.zero_buy)
|
titlebar.setTitleText(R.string.zero_buy)
|
||||||
titlebar.addRightIcon(R.mipmap.icon_question_mark, {
|
titlebar.addRightIcon(R.mipmap.icon_question_mark, {
|
||||||
showHintInfo()
|
showHintInfo()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
with(recyclerView) {
|
||||||
|
mAdapter = ZeroItemAdapter()
|
||||||
|
adapter = mAdapter
|
||||||
|
layoutManager = GridLayoutManager(this@ZeroBuyActivity, 2)
|
||||||
|
addItemDecoration(
|
||||||
|
CommonItemDecoration.create(horizontalSpace = 45, verticalSpace = 45)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -50,12 +68,7 @@ class ZeroBuyActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initWindowInsets() {
|
override fun ViewBinding.initWindowInsets() {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(contentRoot) { v, insets ->
|
setImmerseRootView(contentRoot)
|
||||||
val systemBars =
|
|
||||||
insets.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout())
|
|
||||||
v.updatePadding(top = systemBars.top)
|
|
||||||
insets
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showHintInfo() {
|
private fun showHintInfo() {
|
||||||
|
|
@ -64,26 +77,47 @@ class ZeroBuyActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
|
|
||||||
override fun ViewBinding.initListeners() {
|
override fun ViewBinding.initListeners() {
|
||||||
//TODO("Not yet implemented")
|
//TODO("Not yet implemented")
|
||||||
|
requestData()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initObservers() {
|
override fun ViewBinding.initObservers() {
|
||||||
//TODO("Not yet implemented")
|
//TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.onUiStateCollect(uiState: UiState) {
|
|
||||||
//TODO("Not yet implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onTabIsDarkFont(isDarkFont: Boolean) {
|
|
||||||
//TODO("Not yet implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun gotoLotteryRecords() {
|
private fun gotoLotteryRecords() {
|
||||||
Router.WinRecord.startActivity(this)
|
Router.WinRecord.startActivity(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------- start -----------------------------
|
||||||
|
|
||||||
|
|
||||||
|
private fun requestData() {
|
||||||
|
lifecycleScope.launch {
|
||||||
|
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||||
|
viewModel.ZeroBuyListData.collect { result ->
|
||||||
|
when (result) {
|
||||||
|
is Result.Loading -> { }
|
||||||
|
is Result.Success -> updateUIs(result.data)
|
||||||
|
is Result.Error -> { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel.requestZeroBuyInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private fun updateUIs(data: ZeroBuyResp) {
|
||||||
|
mAdapter.submitList(data.mCurrentList)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------- end -----------------------------
|
||||||
companion object {
|
companion object {
|
||||||
internal fun startActivity(activity: Activity) {
|
internal fun startActivity(activity: Activity) {
|
||||||
activity.startActivity(Intent(activity.applicationContext, ZeroBuyActivity::class.java))
|
activity.startActivity(Intent(activity.applicationContext, ZeroBuyActivity::class.java))
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
package com.gamedog.vididin.features.zero
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
|
import com.ama.core.architecture.util.DeviceUtil
|
||||||
|
import com.ama.core.architecture.util.SpUtil
|
||||||
|
import com.gamedog.vididin.VidiConst
|
||||||
|
import com.gamedog.vididin.beans.ZeroBuyItem
|
||||||
|
import com.gamedog.vididin.beans.ZeroBuyResp
|
||||||
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
|
import com.gamedog.vididin.netbase.NetworkUtil
|
||||||
|
import com.gamedog.vididin.netbase.Result
|
||||||
|
import com.gamedog.vididin.request.RequestUtil
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class ZeroBuyViewModel : ViewModel() {
|
||||||
|
private val _ZeroBuyListData = MutableStateFlow<Result<ZeroBuyResp>>(Result.Loading)
|
||||||
|
val ZeroBuyListData: StateFlow<Result<ZeroBuyResp>> = _ZeroBuyListData.asStateFlow()
|
||||||
|
|
||||||
|
private val _ZeroBuySecretData = MutableStateFlow<Result<String>>(Result.Loading)
|
||||||
|
val ZeroBuySecretData: StateFlow<Result<String>> = _ZeroBuySecretData.asStateFlow()
|
||||||
|
|
||||||
|
|
||||||
|
fun requestZeroBuySecret() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
_ZeroBuySecretData.value = Result.Loading
|
||||||
|
val operationVal = 1
|
||||||
|
val curTimeSec = System.currentTimeMillis()/1000
|
||||||
|
val signStr = RequestUtil.getZeroBuyRequestSign(curTimeSec, operationVal)
|
||||||
|
val requestHeaders = mapOf("Operation" to operationVal.toString(), "Timestamp" to curTimeSec.toString(), "Sign" to signStr)
|
||||||
|
|
||||||
|
val result = NetworkUtil.get("${VidiConst.URL_ZERO_BUY}/anynameisok", requestHeaders)
|
||||||
|
|
||||||
|
when (result) {
|
||||||
|
is Result.Success -> {
|
||||||
|
val respObj = AndroidUtil.json2Object<String>(result.data.string())
|
||||||
|
_ZeroBuySecretData.value = Result.Success(respObj!!)
|
||||||
|
}
|
||||||
|
is Result.Error -> {
|
||||||
|
_ZeroBuySecretData.value = Result.Error(result.exception, result.message)
|
||||||
|
}
|
||||||
|
else -> { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun requestZeroBuyInfo() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
_ZeroBuyListData.value = Result.Loading
|
||||||
|
|
||||||
|
val operationVal = 0
|
||||||
|
val curTimeSec = System.currentTimeMillis()/1000
|
||||||
|
val signStr = RequestUtil.getZeroBuyRequestSign(curTimeSec, operationVal)
|
||||||
|
val requestHeaders = mapOf("Operation" to operationVal.toString(), "Timestamp" to curTimeSec.toString(), "Sign" to signStr)
|
||||||
|
val requestParams = mutableMapOf("AppId" to VidiConst.ZEROBUY_APPID, "DeviceId" to DeviceUtil.generateDeviceId())
|
||||||
|
val userId = AccountManager.getAccount()?.userId?: 0
|
||||||
|
if (userId > 0) {
|
||||||
|
requestParams.put("UserId", userId.toString())
|
||||||
|
}
|
||||||
|
val joinZeroBuyItemIds = SpUtil.instance().getList<Int>(SpUtil.KEY_ZEROBUY_JOINED_ACTIVITY_IDS)
|
||||||
|
if (joinZeroBuyItemIds.isNotEmpty()) {
|
||||||
|
requestParams.put("JoinedPurchaseIds", AndroidUtil.object2Json(joinZeroBuyItemIds))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val result = NetworkUtil.get("${VidiConst.URL_ZERO_BUY}/anynameisok", requestHeaders, requestParams)
|
||||||
|
when (result) {
|
||||||
|
is Result.Success -> {
|
||||||
|
val respObj = AndroidUtil.json2Object<ZeroBuyResp>(result.data.string())?.apply {
|
||||||
|
mCurrentList = AndroidUtil.json2Object<List<ZeroBuyItem>>(CurrentPurchases)
|
||||||
|
mFinishedList = AndroidUtil.json2Object<List<ZeroBuyItem>>(FinishedPurchases)
|
||||||
|
}
|
||||||
|
|
||||||
|
respObj?.UserId?.let {
|
||||||
|
if (userId <= 0) {
|
||||||
|
AccountManager.saveUserIdInfo(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO - when to record joined activity Ids
|
||||||
|
/*respObj?.Join?.let {
|
||||||
|
if (userId <= 0) {
|
||||||
|
AccountManager.saveUserIdInfo(it)
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
_ZeroBuyListData.value = Result.Success(respObj!!)
|
||||||
|
}
|
||||||
|
is Result.Error -> {
|
||||||
|
_ZeroBuyListData.value = Result.Error(result.exception, result.message)
|
||||||
|
}
|
||||||
|
else -> { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.gamedog.vididin.features.zero
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.gamedog.vididin.R
|
||||||
|
import com.gamedog.vididin.beans.ZeroBuyItem
|
||||||
|
import com.gamedog.vididin.databinding.LayoutItemZerobuyBinding as ViewBinding
|
||||||
|
|
||||||
|
class ZeroItemAdapter : ListAdapter<ZeroBuyItem, ZeroItemAdapter.ViewHolder>(DiffCallback()) {
|
||||||
|
|
||||||
|
private val mBgResList = listOf<Int>(R.mipmap.zero_bg_item_sub1, R.mipmap.zero_bg_item_sub2, R.mipmap.zero_bg_item_sub3, R.mipmap.zero_bg_item_sub4)
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
val binding = ViewBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||||
|
return ViewHolder(binding)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
holder.bind(getItem(position))
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class ViewHolder(private val binding: ViewBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||||
|
fun bind(item: ZeroBuyItem) {
|
||||||
|
binding.tvTitle.text = item.title
|
||||||
|
binding.tvJoinedNum.text = item.current_users?.size.toString()
|
||||||
|
binding.tvPeopleTotal.text = "/${item.target_num}"
|
||||||
|
binding.tvJoinGoldNum.text = item.cost.toString()
|
||||||
|
binding.ivBgType.setImageResource(mBgResList[item.image])
|
||||||
|
binding.tvRewardCashNum.text = item.price
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DiffCallback : DiffUtil.ItemCallback<ZeroBuyItem>() {
|
||||||
|
override fun areItemsTheSame(oldItem: ZeroBuyItem, newItem: ZeroBuyItem): Boolean {
|
||||||
|
return oldItem.id == newItem.id
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun areContentsTheSame(oldItem: ZeroBuyItem, newItem: ZeroBuyItem): Boolean {
|
||||||
|
return oldItem == newItem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
package com.gamedog.vididin.features.zero
|
package com.gamedog.vididin.features.zero.dialogs
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context
|
import android.app.Activity
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.widget.BindingDialog
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
import com.gamedog.vididin.databinding.DialogZeroBuyFailBinding as ViewBinding
|
import com.gamedog.vididin.databinding.DialogZeroBuyFailBinding as ViewBinding
|
||||||
import com.gamedog.vididin.router.Router
|
import com.gamedog.vididin.router.Router
|
||||||
|
|
||||||
|
|
||||||
class ZeroBuyFailDialog(context: Context) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
class ZeroBuyFailDialog(context: Activity) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
build()
|
build()
|
||||||
|
|
@ -33,7 +33,7 @@ class ZeroBuyFailDialog(context: Context) : BindingDialog<ViewBinding>(context,
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotoWatchVideo() {
|
private fun gotoWatchVideo() {
|
||||||
ownerActivity?.let { Router.Withdraw.startActivity(it) }
|
Router.Withdraw.startActivity(mActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
package com.gamedog.vididin.features.zero
|
package com.gamedog.vididin.features.zero.dialogs
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context
|
import android.app.Activity
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.widget.BindingDialog
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
import com.gamedog.vididin.databinding.DialogZeroBuyNotWinBinding as ViewBinding
|
import com.gamedog.vididin.databinding.DialogZeroBuyNotWinBinding as ViewBinding
|
||||||
import com.gamedog.vididin.router.Router
|
import com.gamedog.vididin.router.Router
|
||||||
|
|
||||||
|
|
||||||
class ZeroBuyNotWinDialog(context: Context) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
class ZeroBuyNotWinDialog(context: Activity) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
build()
|
build()
|
||||||
|
|
@ -33,7 +33,7 @@ class ZeroBuyNotWinDialog(context: Context) : BindingDialog<ViewBinding>(context
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotoWatchVideo() {
|
private fun gotoWatchVideo() {
|
||||||
ownerActivity?.let { Router.Withdraw.startActivity(it) }
|
Router.Withdraw.startActivity(mActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
package com.gamedog.vididin.features.zero
|
package com.gamedog.vididin.features.zero.dialogs
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context
|
import android.app.Activity
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.widget.BindingDialog
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
import com.gamedog.vididin.databinding.DialogZeroBuyRuleBinding as ViewBinding
|
import com.gamedog.vididin.databinding.DialogZeroBuyRuleBinding as ViewBinding
|
||||||
import com.gamedog.vididin.router.Router
|
import com.gamedog.vididin.router.Router
|
||||||
|
|
||||||
|
|
||||||
class ZeroBuyRulesDialog(context: Context) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
class ZeroBuyRulesDialog(context: Activity) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
build()
|
build()
|
||||||
|
|
@ -33,7 +33,7 @@ class ZeroBuyRulesDialog(context: Context) : BindingDialog<ViewBinding>(context,
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotoWatchVideo() {
|
private fun gotoWatchVideo() {
|
||||||
ownerActivity?.let { Router.Withdraw.startActivity(it) }
|
Router.Withdraw.startActivity(mActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
package com.gamedog.vididin.features.zero
|
package com.gamedog.vididin.features.zero.dialogs
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context
|
import android.app.Activity
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.widget.BindingDialog
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
import com.gamedog.vididin.databinding.DialogZeroBuyWinBinding as ViewBinding
|
import com.gamedog.vididin.databinding.DialogZeroBuyWinBinding as ViewBinding
|
||||||
import com.gamedog.vididin.router.Router
|
import com.gamedog.vididin.router.Router
|
||||||
|
|
||||||
|
|
||||||
class ZeroBuyWinDialog(context: Context) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
class ZeroBuyWinDialog(context: Activity) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
build()
|
build()
|
||||||
|
|
@ -33,7 +33,7 @@ class ZeroBuyWinDialog(context: Context) : BindingDialog<ViewBinding>(context, V
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotoWatchVideo() {
|
private fun gotoWatchVideo() {
|
||||||
ownerActivity?.let { Router.Withdraw.startActivity(it) }
|
Router.Withdraw.startActivity(mActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,16 +1,21 @@
|
||||||
package com.gamedog.vididin.core.login.login
|
package com.gamedog.vididin.core.login.login
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
import com.ama.core.architecture.util.DateUtil
|
import com.ama.core.architecture.util.DateUtil
|
||||||
import com.ama.core.architecture.util.DeviceUtil
|
import com.ama.core.architecture.util.DeviceUtil
|
||||||
import com.ama.core.architecture.util.SpUtil
|
import com.ama.core.architecture.util.SpUtil
|
||||||
import com.ama.core.architecture.util.eventbus.NotifyMan
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.gamedog.vididin.VidiConst
|
||||||
import com.gamedog.vididin.VididinEvents
|
import com.gamedog.vididin.VididinEvents
|
||||||
import com.gamedog.vididin.beans.Account
|
import com.gamedog.vididin.beans.Account
|
||||||
import com.gamedog.vididin.beans.BankInfo
|
import com.gamedog.vididin.beans.BankInfo
|
||||||
|
import kotlinx.coroutines.sync.Mutex
|
||||||
|
|
||||||
|
|
||||||
object AccountManager {
|
object AccountManager {
|
||||||
|
|
||||||
|
private val mutex = Mutex()
|
||||||
|
|
||||||
private val mAccount: Account? by lazy {
|
private val mAccount: Account? by lazy {
|
||||||
var account = SpUtil.instance().getObject<Account>(SpUtil.KEY_ACCOUNT)
|
var account = SpUtil.instance().getObject<Account>(SpUtil.KEY_ACCOUNT)
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
|
|
@ -39,12 +44,14 @@ object AccountManager {
|
||||||
return mAccount?.cashCount ?: 0F
|
return mAccount?.cashCount ?: 0F
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
fun addGold(newGold: Int) {
|
fun addGold(newGold: Int) {
|
||||||
mAccount?.goldCount += newGold
|
mAccount?.goldCount += newGold
|
||||||
saveAccountInfo()
|
saveAccountInfo()
|
||||||
NotifyMan.instance().sendEvent(VididinEvents.Event_Account_Gold_Changed, null)
|
NotifyMan.instance().sendEvent(VididinEvents.Event_Account_Gold_Changed, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
fun addCash(newCash: Float) {
|
fun addCash(newCash: Float) {
|
||||||
mAccount?.cashCount += newCash
|
mAccount?.cashCount += newCash
|
||||||
saveAccountInfo()
|
saveAccountInfo()
|
||||||
|
|
@ -71,5 +78,37 @@ object AccountManager {
|
||||||
VididinEvents.Event_Account_Bank_Info_Changed, NotifyMan.NotifyData(bankAccount))
|
VididinEvents.Event_Account_Bank_Info_Changed, NotifyMan.NotifyData(bankAccount))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun convertGold2Cash(): Boolean {
|
||||||
|
try {
|
||||||
|
val couldCovertCashTotal = mAccount?.goldCount?.div(VidiConst.PER_CASH_COST_GOLD_NUM) ?: 0L
|
||||||
|
if (couldCovertCashTotal > 0) {
|
||||||
|
val costGoldNum = couldCovertCashTotal * VidiConst.PER_CASH_COST_GOLD_NUM
|
||||||
|
mAccount?.goldCount?.let {
|
||||||
|
if (it > costGoldNum) {
|
||||||
|
addGold(-1 * costGoldNum.toInt())
|
||||||
|
addCash(couldCovertCashTotal.toFloat())
|
||||||
|
AndroidUtil.showToast("Has convert $costGoldNum gold to $couldCovertCashTotal cash.")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
AndroidUtil.showToast("You don't have enough gold.")
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saveUserIdInfo(userId: Int) {
|
||||||
|
mAccount?.let {
|
||||||
|
it.userId = userId
|
||||||
|
saveAccountInfo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
package com.gamedog.vididin.main
|
package com.gamedog.vididin.main
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.widget.BindingDialog
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
import com.gamedog.vididin.databinding.DialogBeginnerGiftBinding
|
import com.gamedog.vididin.databinding.DialogBeginnerGiftBinding
|
||||||
import com.gamedog.vididin.router.Router
|
import com.gamedog.vididin.router.Router
|
||||||
|
|
||||||
|
|
||||||
class BeginnerGiftDialog(context: Context) : BindingDialog<DialogBeginnerGiftBinding>(context, DialogBeginnerGiftBinding::inflate) {
|
class BeginnerGiftDialog(activity: Activity) : BindingDialog<DialogBeginnerGiftBinding>(activity, DialogBeginnerGiftBinding::inflate) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
build()
|
build()
|
||||||
|
|
@ -25,7 +26,10 @@ class BeginnerGiftDialog(context: Context) : BindingDialog<DialogBeginnerGiftBin
|
||||||
setOnClickBatch(tvAction) {
|
setOnClickBatch(tvAction) {
|
||||||
when (this) {
|
when (this) {
|
||||||
tvAction -> {
|
tvAction -> {
|
||||||
gotoWatchVideo()
|
if (mActivity is MainActivity) {
|
||||||
|
(mActivity as MainActivity).switchTab(1)
|
||||||
|
}
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.EVENT_JUMP_2_FIRST_WITHDRAW, null)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +38,7 @@ class BeginnerGiftDialog(context: Context) : BindingDialog<DialogBeginnerGiftBin
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotoWatchVideo() {
|
private fun gotoWatchVideo() {
|
||||||
ownerActivity?.let { Router.Withdraw.startActivity(it) }
|
Router.Withdraw.startActivity(mActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package com.gamedog.vididin.main
|
package com.gamedog.vididin.main
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import com.ama.core.common.util.asSafe
|
import com.ama.core.common.util.asSafe
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
|
@ -18,9 +21,13 @@ import com.ama.core.architecture.util.bindViewPager2
|
||||||
import com.ama.core.architecture.util.setCommonNavigator
|
import com.ama.core.architecture.util.setCommonNavigator
|
||||||
import com.ama.core.architecture.util.setDataOrAdapter
|
import com.ama.core.architecture.util.setDataOrAdapter
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
|
import com.gamedog.vididin.VidiConst
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
import com.gamedog.vididin.adapter.MainTabsAdapter
|
import com.gamedog.vididin.adapter.MainTabsAdapter
|
||||||
import com.gamedog.vididin.adapter.MainViewPagerAdapter
|
import com.gamedog.vididin.adapter.MainViewPagerAdapter
|
||||||
|
import com.gamedog.vididin.main.fragments.task.DailySignSuccessDialog
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
|
import com.gamedog.vididin.manager.DateChangeReceiver
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlin.getValue
|
import kotlin.getValue
|
||||||
import com.gamedog.vididin.databinding.ActivityMainBinding as ViewBinding
|
import com.gamedog.vididin.databinding.ActivityMainBinding as ViewBinding
|
||||||
|
|
@ -36,6 +43,8 @@ class MainActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabS
|
||||||
override val mViewModel: ViewModel by viewModels()
|
override val mViewModel: ViewModel by viewModels()
|
||||||
private lateinit var navigatorAdapter: MainTabsAdapter
|
private lateinit var navigatorAdapter: MainTabsAdapter
|
||||||
private val fragmentStateAdapter by lazy { MainViewPagerAdapter(this) }
|
private val fragmentStateAdapter by lazy { MainViewPagerAdapter(this) }
|
||||||
|
private lateinit var mDateChangeReceiver: DateChangeReceiver
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
||||||
|
|
@ -54,6 +63,7 @@ class MainActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun ViewBinding.initViews() {
|
override fun ViewBinding.initViews() {
|
||||||
content.foreground.alpha = 0
|
content.foreground.alpha = 0
|
||||||
navigatorAdapter = MainTabsAdapter(
|
navigatorAdapter = MainTabsAdapter(
|
||||||
|
|
@ -71,6 +81,10 @@ class MainActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabS
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initListeners() {
|
override fun ViewBinding.initListeners() {
|
||||||
|
mDateChangeReceiver = DateChangeReceiver()
|
||||||
|
val filter = IntentFilter(Intent.ACTION_DATE_CHANGED)
|
||||||
|
registerReceiver(mDateChangeReceiver, filter)
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this@MainActivity) {
|
onBackPressedDispatcher.addCallback(this@MainActivity) {
|
||||||
if (mViewModel.canBack) {
|
if (mViewModel.canBack) {
|
||||||
finish()
|
finish()
|
||||||
|
|
@ -97,6 +111,19 @@ class MainActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabS
|
||||||
onTabIsDarkFont(isBackgroundBright)
|
onTabIsDarkFont(isBackgroundBright)
|
||||||
}
|
}
|
||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
|
registerEvents( { data->
|
||||||
|
when (data?.mEventType) {
|
||||||
|
VididinEvents.Event_AD_TASK_TYPE_Watch_Ad_Earn_Gold-> {
|
||||||
|
DailySignSuccessDialog(this@MainActivity).initData(VidiConst.WATCH_AD_REWARD_GOLD.toInt(), false).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
VididinEvents.EVENT_JUMP_2_VIDEO-> {
|
||||||
|
switchTab(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, VididinEvents.Event_AD_TASK_TYPE_Watch_Ad_Earn_Gold, VididinEvents.EVENT_JUMP_2_VIDEO)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initObservers() {
|
override fun ViewBinding.initObservers() {
|
||||||
|
|
@ -114,7 +141,20 @@ class MainActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabS
|
||||||
super.onResume()
|
super.onResume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
unregisterReceiver(mDateChangeReceiver)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onTabIsDarkFont(isDarkFont: Boolean) {
|
override fun onTabIsDarkFont(isDarkFont: Boolean) {
|
||||||
navigatorAdapter.setIsDarkFont(isDarkFont)
|
navigatorAdapter.setIsDarkFont(isDarkFont)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun switchTab(itemIndex: Int) {
|
||||||
|
binding.viewPager2.setCurrentItem(itemIndex, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
package com.gamedog.vididin.main
|
package com.gamedog.vididin.main
|
||||||
|
|
||||||
import android.content.Context
|
import android.app.Activity
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.widget.BindingDialog
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
import com.gamedog.vididin.databinding.DialogWatchVideoBinding
|
import com.gamedog.vididin.databinding.DialogWatchVideoBinding
|
||||||
import com.gamedog.vididin.main.fragments.task.RewardDetail
|
import com.gamedog.vididin.router.Router
|
||||||
|
|
||||||
|
|
||||||
class WatchVideoDialog(context: Context) : BindingDialog<DialogWatchVideoBinding>(context, DialogWatchVideoBinding::inflate) {
|
class WatchAdDialog(context: Activity, private val mTaskType: Int, private val mGoldNum: Int? = 0,
|
||||||
private lateinit var mDataList: List<RewardDetail>
|
private val mTaskDataJson: String? = "")
|
||||||
|
: BindingDialog<DialogWatchVideoBinding>(context, DialogWatchVideoBinding::inflate) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
build()
|
build()
|
||||||
|
|
@ -29,15 +30,17 @@ class WatchVideoDialog(context: Context) : BindingDialog<DialogWatchVideoBinding
|
||||||
}
|
}
|
||||||
flAction -> {
|
flAction -> {
|
||||||
gotoWatchVideo()
|
gotoWatchVideo()
|
||||||
dismiss()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tvGoldNum.text = "+$mGoldNum"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotoWatchVideo() {
|
private fun gotoWatchVideo() {
|
||||||
|
Router.WatchAd.startActivity(mActivity, mTaskType, mTaskDataJson)
|
||||||
|
dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -15,10 +15,14 @@ import com.ama.core.architecture.appBase.AppViewsFragment
|
||||||
import com.ama.core.architecture.appBase.OnFragmentBackgroundListener
|
import com.ama.core.architecture.appBase.OnFragmentBackgroundListener
|
||||||
import com.ama.core.architecture.util.setStatusBarDarkFont
|
import com.ama.core.architecture.util.setStatusBarDarkFont
|
||||||
import com.ama.core.common.util.asSafe
|
import com.ama.core.common.util.asSafe
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
import com.gamedog.vididin.main.fragments.home.HomeFragmentStateAdapter
|
import com.gamedog.vididin.main.fragments.home.HomeFragmentStateAdapter
|
||||||
import com.gamedog.vididin.main.fragments.home.fragment.HomeItemFragment
|
import com.gamedog.vididin.main.fragments.home.fragment.HomeItemFragment
|
||||||
import com.gamedog.vididin.main.interfaces.OnSwitchTabListener
|
import com.gamedog.vididin.main.interfaces.OnSwitchTabListener
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
|
import com.gamedog.vididin.youtubestatistic.RewardConst
|
||||||
|
import com.gamedog.vididin.youtubestatistic.RewardConst.Companion.Check_Interval_MS
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.getValue
|
import kotlin.getValue
|
||||||
|
|
@ -31,6 +35,7 @@ import com.gamedog.vididin.main.fragments.home.YoutubeUiState as UiState
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class HomeFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnSwitchTabListener, OnFragmentBackgroundListener {
|
class HomeFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnSwitchTabListener, OnFragmentBackgroundListener {
|
||||||
|
|
||||||
|
private var mTotalMs: Long = 0L
|
||||||
override val mViewModel: ViewModel by viewModels()
|
override val mViewModel: ViewModel by viewModels()
|
||||||
override var isBackgroundBright: Boolean = true
|
override var isBackgroundBright: Boolean = true
|
||||||
|
|
||||||
|
|
@ -54,15 +59,35 @@ class HomeFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnSwit
|
||||||
viewPager2.setPageTransformer { _, _ -> }
|
viewPager2.setPageTransformer { _, _ -> }
|
||||||
viewPager2.offscreenPageLimit = 1
|
viewPager2.offscreenPageLimit = 1
|
||||||
viewPager2.adapter = mViewPagerAdapter
|
viewPager2.adapter = mViewPagerAdapter
|
||||||
|
|
||||||
|
registerEvents({
|
||||||
|
handleWatchTimeTick()
|
||||||
|
}, VididinEvents.Event_HOME_WATCH_Time_TICK,)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleWatchTimeTick() {
|
||||||
|
mTotalMs += Check_Interval_MS
|
||||||
|
|
||||||
|
if (mTotalMs < RewardConst.HOME_WATCH_DURATION) {
|
||||||
|
binding?.dragIconView?.setProgress(mTotalMs * 100/RewardConst.HOME_WATCH_DURATION)
|
||||||
|
} else {
|
||||||
|
mTotalMs = 0L
|
||||||
|
binding?.dragIconView?.setProgress(mTotalMs * 100/ RewardConst.HOME_WATCH_DURATION)
|
||||||
|
AccountManager.addGold(RewardConst.HOME_WATCH_REWARD_NUM)
|
||||||
|
binding?.dragIconView?.showRewardGoldAnim()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initListeners() {
|
override fun ViewBinding.initListeners() {
|
||||||
viewPager2.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
viewPager2.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
super.onPageSelected(position)
|
super.onPageSelected(position)
|
||||||
setHomeTabStyle(mViewPagerAdapter.getFragmentByIndex(position))
|
val fragment = mViewPagerAdapter.getFragmentByIndex(position)
|
||||||
val curFragment: HomeItemFragment = mViewPagerAdapter.getFragmentByIndex(position) as HomeItemFragment
|
if (fragment != null) {
|
||||||
curFragment.loadVideo()
|
setHomeTabStyle(fragment)
|
||||||
|
val curFragment: HomeItemFragment = fragment as HomeItemFragment
|
||||||
|
curFragment.loadVideo()
|
||||||
|
}
|
||||||
|
|
||||||
// load more
|
// load more
|
||||||
if (mViewPagerAdapter.itemCount > 0 && position == mViewPagerAdapter.itemCount - 2) {
|
if (mViewPagerAdapter.itemCount > 0 && position == mViewPagerAdapter.itemCount - 2) {
|
||||||
|
|
@ -91,8 +116,21 @@ class HomeFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnSwit
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.onUiStateCollect(uiState: UiState) {
|
override fun ViewBinding.onUiStateCollect(uiState: UiState) {
|
||||||
|
/*val videoList = mutableListOf<YoutubeVideo>()
|
||||||
|
if (uiState.playLists == null) {
|
||||||
|
videoList.add(YoutubeVideo("TegalxCm1LA", "111", "bbbbb"))
|
||||||
|
videoList.add(YoutubeVideo("KA54UCs3E_4", "222", "bbbbb"))
|
||||||
|
videoList.add(YoutubeVideo("_bAxHM7O_9k", "333", "bbbbb"))
|
||||||
|
videoList.add(YoutubeVideo("6vAYPVTGs90", "444", "bbbbb"))
|
||||||
|
videoList.add(YoutubeVideo("bLAfi6cWcoI", "555", "bbbbb"))
|
||||||
|
videoList.add(YoutubeVideo("WX1MvqCzQ2k", "666", "bbbbb"))
|
||||||
|
videoList.add(YoutubeVideo("nkRPma2F4s4", "777", "bbbbb"))
|
||||||
|
videoList.add(YoutubeVideo("ssosMzYpQgc", "888", "bbbbb"))
|
||||||
|
videoList.add(YoutubeVideo("1sXHOCQcbwc", "999", "bbbbb"))
|
||||||
|
mViewPagerAdapter.submitList(videoList)
|
||||||
|
return
|
||||||
|
}*/
|
||||||
mViewPagerAdapter.submitList(uiState.playLists)
|
mViewPagerAdapter.submitList(uiState.playLists)
|
||||||
//viewPager2.setDataOrAdapter(uiState.playLists, 1) { mViewPagerAdapter }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package com.gamedog.vididin.main.fragments
|
package com.gamedog.vididin.main.fragments
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
|
|
@ -9,20 +12,29 @@ import androidx.fragment.app.viewModels
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.ama.core.architecture.appBase.AppViewsFragment
|
import com.ama.core.architecture.appBase.AppViewsFragment
|
||||||
import com.ama.core.architecture.appBase.OnFragmentBackgroundListener
|
import com.ama.core.architecture.appBase.OnFragmentBackgroundListener
|
||||||
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
import com.ama.core.architecture.util.ResUtil
|
import com.ama.core.architecture.util.ResUtil
|
||||||
import com.ama.core.architecture.util.eventbus.NotifyMan
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.ama.core.architecture.util.permission.PermissionUtil
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.util.setStatusBarDarkFont
|
import com.ama.core.architecture.util.setStatusBarDarkFont
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
|
import com.gamedog.vididin.VidiConst
|
||||||
import com.gamedog.vididin.VididinEvents
|
import com.gamedog.vididin.VididinEvents
|
||||||
import com.gamedog.vididin.core.login.login.AccountManager
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
import com.gamedog.vididin.main.WatchVideoDialog
|
import com.gamedog.vididin.main.MainActivity
|
||||||
|
import com.gamedog.vididin.main.WatchAdDialog
|
||||||
import com.gamedog.vididin.main.fragments.task.DailySignDialog
|
import com.gamedog.vididin.main.fragments.task.DailySignDialog
|
||||||
|
import com.gamedog.vididin.main.fragments.task.DailySignSuccessDialog
|
||||||
import com.gamedog.vididin.main.fragments.task.TaskBean
|
import com.gamedog.vididin.main.fragments.task.TaskBean
|
||||||
|
import com.gamedog.vididin.main.fragments.task.widget.DailyTaskItemView
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabClickAgainListener
|
import com.gamedog.vididin.main.interfaces.OnTabClickAgainListener
|
||||||
import com.gamedog.vididin.manager.TaskManager
|
import com.gamedog.vididin.manager.TaskManager
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_FINISH
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_ONGOING
|
||||||
import com.gamedog.vididin.router.Router
|
import com.gamedog.vididin.router.Router
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import kotlinx.coroutines.Runnable
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.getValue
|
import kotlin.getValue
|
||||||
import com.gamedog.vididin.databinding.VididinappFeatureMessageFragmentMessageBinding as ViewBinding
|
import com.gamedog.vididin.databinding.VididinappFeatureMessageFragmentMessageBinding as ViewBinding
|
||||||
|
|
@ -34,10 +46,14 @@ import com.gamedog.vididin.main.fragments.home.YoutubeUiState as UiState
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTabClickAgainListener, OnFragmentBackgroundListener {
|
class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTabClickAgainListener, OnFragmentBackgroundListener {
|
||||||
|
|
||||||
|
|
||||||
private var mTaskConfig: TaskBean? = null
|
private var mTaskConfig: TaskBean? = null
|
||||||
override val mViewModel: ViewModel by viewModels()
|
override val mViewModel: ViewModel by viewModels()
|
||||||
override var isBackgroundBright: Boolean = true
|
override var isBackgroundBright: Boolean = true
|
||||||
|
|
||||||
|
private val mDailyWatchVideoViewList = mutableListOf<DailyTaskItemView>()
|
||||||
|
private val mDailyWatchAdViewList = mutableListOf<DailyTaskItemView>()
|
||||||
|
|
||||||
|
|
||||||
override fun inflateViewBinding(
|
override fun inflateViewBinding(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
|
|
@ -56,30 +72,31 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
|
|
||||||
override fun ViewBinding.initViews() {
|
override fun ViewBinding.initViews() {
|
||||||
with(binding) {
|
with(binding) {
|
||||||
setOnClickBatch(ivGotoDailySign, llTaskBenefit, llTaskWatchVideo, llTaskGame, llTaskZerobuy, tvWatchVideo, tvWithdraw) {
|
setOnClickBatch(ivGotoDailySign, llTaskBenefit, llTaskWatchAd, llTaskGame,
|
||||||
|
llTaskZerobuy, tvWatchVideoForConvertGoldToCash, tvWithdraw) {
|
||||||
when(this) {
|
when(this) {
|
||||||
ivGotoDailySign->{
|
ivGotoDailySign->{
|
||||||
DailySignDialog(context).show()
|
DailySignDialog(requireActivity()).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
llTaskBenefit->{
|
llTaskBenefit->{
|
||||||
Router.Benefit.startActivity(requireActivity())
|
Router.Benefit.startActivity(requireActivity())
|
||||||
}
|
}
|
||||||
|
|
||||||
llTaskWatchVideo->{
|
llTaskWatchAd->{
|
||||||
WatchVideoDialog(requireContext()).show()
|
WatchAdDialog(requireActivity(), VididinEvents.Event_AD_TASK_TYPE_Watch_Ad_Earn_Gold, 200).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
llTaskGame->{
|
llTaskGame->{
|
||||||
|
AndroidUtil.openUrl(VidiConst.URL_GAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
llTaskZerobuy->{
|
llTaskZerobuy->{
|
||||||
Router.ZeroBuy.startActivity(requireActivity())
|
Router.ZeroBuy.startActivity(requireActivity())
|
||||||
}
|
}
|
||||||
|
|
||||||
tvWatchVideo->{
|
tvWatchVideoForConvertGoldToCash->{
|
||||||
WatchVideoDialog(requireContext()).show()
|
WatchAdDialog(requireActivity(), VididinEvents.Event_AD_TASK_TYPE_Convert_Gold_2_Cash, null).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
tvWithdraw->{
|
tvWithdraw->{
|
||||||
|
|
@ -90,51 +107,30 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
beginnerTaskWithdraw.initUI(R.mipmap.icon_cash_s, R.string.beginner_withdraw_title, R.string.beginner_withdraw_desc,R.string.resgatar)
|
with(beginnerTaskWithdraw) {
|
||||||
beginnerTaskWithdraw.setRewardIcon(R.mipmap.icon_cash_s)
|
initUI(R.mipmap.icon_cash_s, R.string.beginner_withdraw_title, R.string.resgatar)
|
||||||
beginnerTaskWithdraw.setRewardTextStyle(21, R.color.green_39)
|
//setRewardTextStyle(21, R.color.green_39)
|
||||||
beginnerTaskWithdraw.setActionFun {
|
updateNewBieFirstWithdrawUI()
|
||||||
gotoWithDraw()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
beginnerTaskDiscord.initUI(R.mipmap.icon_dicord, R.string.beginner_discord_title, R.string.beginner_discord_desc,R.string.resgatar)
|
|
||||||
beginnerTaskDiscord.setActionFun {
|
with(beginnerTaskDiscord) {
|
||||||
gotoDiscord()
|
initUI(R.mipmap.icon_dicord, R.string.beginner_discord_title,R.string.resgatar)
|
||||||
|
updateNewBieDiscordUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
beginnerTaskEnableNotify.initUI(R.mipmap.icon_notify, R.string.beginner_notify_title, R.string.beginner_notify_desc,R.string.Resgatado)
|
with(beginnerTaskEnableNotify) {
|
||||||
beginnerTaskEnableNotify.setActionFun {
|
initUI(R.mipmap.icon_notify, R.string.beginner_notify_title,R.string.Resgatado)
|
||||||
gotoNotification()
|
updateNewBieNotifyUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
dailyTaskWatch1.initUI(R.mipmap.icon_video_task, R.string.daily_video_task_title, 1, R.string.resgatar)
|
|
||||||
dailyTaskWatch1.setActionFun {
|
|
||||||
gotoWithVideo()
|
|
||||||
}
|
|
||||||
|
|
||||||
dailyTaskWatch5.initUI(R.mipmap.icon_video_task, R.string.daily_video_task_title, 5, R.string.go_and_do)
|
|
||||||
dailyTaskWatch5.setActionFun {
|
|
||||||
gotoWithVideo()
|
|
||||||
}
|
|
||||||
|
|
||||||
dailyTaskWatch10.initUI(R.mipmap.icon_video_task, R.string.daily_video_task_title, 10, R.string.go_and_do)
|
|
||||||
dailyTaskWatch10.setActionFun {
|
|
||||||
gotoWithVideo()
|
|
||||||
}
|
|
||||||
|
|
||||||
dailyTaskWatch20.initUI(R.mipmap.icon_video_task, R.string.daily_video_task_title, 20, R.string.go_and_do)
|
|
||||||
dailyTaskWatch20.setActionFun {
|
|
||||||
gotoWithVideo()
|
|
||||||
}
|
|
||||||
|
|
||||||
dailyTaskWatch30.initUI(R.mipmap.icon_video_task, R.string.daily_video_task_title, 30, R.string.go_and_do)
|
|
||||||
dailyTaskWatch30.setActionFun {
|
|
||||||
gotoWithVideo()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
addDailySubTasks()
|
||||||
|
|
||||||
updateUIGoldTotal()
|
updateUIGoldTotal()
|
||||||
updateUICashTotal()
|
updateUICashTotal()
|
||||||
|
updateDailyWatchVideoUI()
|
||||||
|
updateDailyWatchAdUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
|
|
@ -142,6 +138,60 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addDailySubTasks() {
|
||||||
|
//1. 阶梯广告
|
||||||
|
val dailyWatchAdTask = TaskManager.instance().getDailyAdTask()
|
||||||
|
if (dailyWatchAdTask != null && dailyWatchAdTask.status == "active"
|
||||||
|
&& dailyWatchAdTask.reward_details.isNotEmpty()) {
|
||||||
|
|
||||||
|
dailyWatchAdTask.reward_details.forEachIndexed { index, detail ->
|
||||||
|
val watchTaskItemView = DailyTaskItemView(requireActivity())
|
||||||
|
watchTaskItemView.setActionFun {
|
||||||
|
handleDailyAdButClicked(index)
|
||||||
|
}
|
||||||
|
mDailyWatchAdViewList.add(watchTaskItemView)
|
||||||
|
|
||||||
|
binding?.dailyTasksContainer!!.run {
|
||||||
|
watchTaskItemView.initUI(R.mipmap.icon_ad, R.string.daily_ad_task_title,
|
||||||
|
detail.target_count, detail.value)
|
||||||
|
|
||||||
|
addView(watchTaskItemView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||||
|
if (true) {
|
||||||
|
val separateLine = View(requireActivity())
|
||||||
|
separateLine.setBackgroundResource(R.color.gray_f2)
|
||||||
|
addView(separateLine, LinearLayout.LayoutParams.MATCH_PARENT, ResUtil.getPixelSize(R.dimen.dp1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//2. 阶梯视频
|
||||||
|
val dailyWatchVideoTask = TaskManager.instance().getDailyVideoTask()
|
||||||
|
if (dailyWatchVideoTask != null && dailyWatchVideoTask.status == "active"
|
||||||
|
&& dailyWatchVideoTask.reward_details.isNotEmpty()) {
|
||||||
|
|
||||||
|
dailyWatchVideoTask.reward_details.forEachIndexed {index, detail ->
|
||||||
|
val watchTaskItemView = DailyTaskItemView(requireActivity())
|
||||||
|
watchTaskItemView.setActionFun {
|
||||||
|
handleDailyVideoButClicked(index)
|
||||||
|
}
|
||||||
|
mDailyWatchVideoViewList.add(watchTaskItemView)
|
||||||
|
|
||||||
|
binding?.dailyTasksContainer!!.run {
|
||||||
|
watchTaskItemView.initUI(R.mipmap.icon_video_task, R.string.daily_video_task_title,
|
||||||
|
detail.target_count, detail.value)
|
||||||
|
|
||||||
|
addView(watchTaskItemView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||||
|
if (index != dailyWatchVideoTask.reward_details.size - 1) {
|
||||||
|
val separateLine = View(requireActivity())
|
||||||
|
separateLine.setBackgroundResource(R.color.gray_f2)
|
||||||
|
addView(separateLine, LinearLayout.LayoutParams.MATCH_PARENT, ResUtil.getPixelSize(R.dimen.dp1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateUICashTotal() {
|
private fun updateUICashTotal() {
|
||||||
binding?.tvCashTotal?.text = buildString {
|
binding?.tvCashTotal?.text = buildString {
|
||||||
append(ResUtil.getString(R.string.cash))
|
append(ResUtil.getString(R.string.cash))
|
||||||
|
|
@ -150,6 +200,22 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateDailyWatchVideoUI() {
|
||||||
|
val statusBean = TaskManager.instance().dailyWatchVideoStatus().getStatusBean()
|
||||||
|
val subTaskStatusList = statusBean.getSubTaskRewardState()
|
||||||
|
mDailyWatchVideoViewList.forEachIndexed { index, view ->
|
||||||
|
view.updateProgress(statusBean.getTodayWatchedCount(), subTaskStatusList[index].state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateDailyWatchAdUI() {
|
||||||
|
val statusBean = TaskManager.instance().dailyWatchAdStatus().getStatusBean()
|
||||||
|
val subTaskStatusList = statusBean.getSubTaskRewardState()
|
||||||
|
mDailyWatchAdViewList.forEachIndexed { index, view ->
|
||||||
|
view.updateProgress(statusBean.getTodayWatchedCount(), subTaskStatusList[index].state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateUIGoldTotal() {
|
private fun updateUIGoldTotal() {
|
||||||
binding?.tvGoldTotal?.text = AccountManager.getGold().toString()
|
binding?.tvGoldTotal?.text = AccountManager.getGold().toString()
|
||||||
}
|
}
|
||||||
|
|
@ -168,12 +234,49 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
VididinEvents.Event_Account_Cash_Changed -> {
|
VididinEvents.Event_Account_Cash_Changed -> {
|
||||||
updateUICashTotal()
|
updateUICashTotal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VididinEvents.EVENT_DAILY_WATCHED_VIDEO_NUM_CHANGED -> {
|
||||||
|
updateDailyWatchVideoUI()
|
||||||
|
}
|
||||||
|
|
||||||
|
VididinEvents.EVENT_DAILY_WATCHED_AD_NUM_CHANGED -> {
|
||||||
|
updateDailyWatchAdUI()
|
||||||
|
}
|
||||||
|
|
||||||
|
VididinEvents.EVENT_JUMP_2_FIRST_WITHDRAW -> {
|
||||||
|
binding?.newbieContainer?.postDelayed(object : Runnable {
|
||||||
|
override fun run() {
|
||||||
|
scroll2FirstWithdraw()
|
||||||
|
}
|
||||||
|
},1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
VididinEvents.EVENT_NEWBIE_DISCORD_TASK_CHANGED -> {
|
||||||
|
updateNewBieDiscordUI()
|
||||||
|
}
|
||||||
|
|
||||||
|
VididinEvents.EVENT_NEWBIE_NOTIFY_TASK_CHANGED -> {
|
||||||
|
updateNewBieNotifyUI()
|
||||||
|
}
|
||||||
|
|
||||||
|
VididinEvents.EVENT_NEWBIE_FIRST_WITHDRAW_TASK_CHANGED -> {
|
||||||
|
updateNewBieFirstWithdrawUI()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}, VididinEvents.Event_Sign_State_Changed, VididinEvents.Event_Account_Cash_Changed, VididinEvents.Event_Account_Gold_Changed)
|
}, VididinEvents.Event_Sign_State_Changed, VididinEvents.Event_Account_Cash_Changed,
|
||||||
|
VididinEvents.Event_Account_Gold_Changed, VididinEvents.EVENT_DAILY_WATCHED_VIDEO_NUM_CHANGED,
|
||||||
|
VididinEvents.EVENT_DAILY_WATCHED_AD_NUM_CHANGED, VididinEvents.EVENT_JUMP_2_FIRST_WITHDRAW,
|
||||||
|
VididinEvents.EVENT_NEWBIE_DISCORD_TASK_CHANGED, VididinEvents.EVENT_NEWBIE_NOTIFY_TASK_CHANGED,
|
||||||
|
VididinEvents.EVENT_NEWBIE_FIRST_WITHDRAW_TASK_CHANGED,)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun scroll2FirstWithdraw() {
|
||||||
|
binding?.newbieContainer?.let { binding?.scrollView?.scroll2ChildView(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateDailySignButUI() {
|
private fun updateDailySignButUI() {
|
||||||
val hasFinishAllSignWork = TaskManager.instance().isDailySignAllOperationDone()
|
val hasFinishAllSignWork = TaskManager.instance().dailySignStatus().isDailySignAllOperationDone()
|
||||||
|
|
||||||
binding?.ivGotoDailySign?.apply {
|
binding?.ivGotoDailySign?.apply {
|
||||||
setText(
|
setText(
|
||||||
|
|
@ -187,6 +290,58 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateNewBieFirstWithdrawUI() {
|
||||||
|
with(binding?.beginnerTaskWithdraw!!) {
|
||||||
|
setActionFun {
|
||||||
|
gotoWithDraw()
|
||||||
|
}
|
||||||
|
val stateBean = TaskManager.instance().newbieFirstWithdrawStatus().getStatusBean()
|
||||||
|
setTaskStateInfo(
|
||||||
|
stateBean.rewardGoldNum.toString(),
|
||||||
|
if (stateBean.hasClaimReward) R.string.finished else R.string.go_and_do,
|
||||||
|
ResUtil.getString(R.string.beginner_withdraw_desc),
|
||||||
|
stateBean.hasClaimReward
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateNewBieDiscordUI() {
|
||||||
|
with(binding?.beginnerTaskDiscord!!) {
|
||||||
|
setActionFun {
|
||||||
|
gotoDiscord()
|
||||||
|
}
|
||||||
|
val stateBean = TaskManager.instance().newbieJoinDiscordStatus().getStatusBean()
|
||||||
|
setTaskStateInfo(
|
||||||
|
stateBean.rewardGoldNum.toString(),
|
||||||
|
if (stateBean.hasClaimReward) R.string.finished else R.string.go_and_do,
|
||||||
|
String.format(ResUtil.getString(R.string.beginner_discord_desc), stateBean.rewardGoldNum),
|
||||||
|
stateBean.hasClaimReward
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateNewBieNotifyUI() {
|
||||||
|
with(binding?.beginnerTaskEnableNotify!!) {
|
||||||
|
val isNotifyEnable = AndroidUtil.isNotificationEnabled()
|
||||||
|
val stateBean = TaskManager.instance().newbieEnableNotifyStatus().getStatusBean()
|
||||||
|
setActionFun {
|
||||||
|
if (!isNotifyEnable) {
|
||||||
|
gotoNotification()
|
||||||
|
} else {
|
||||||
|
if (TaskManager.instance().newbieEnableNotifyStatus().claimReward()) {
|
||||||
|
DailySignSuccessDialog(requireActivity()).initData(stateBean.rewardGoldNum, false).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val actionButRes = if (stateBean.hasClaimReward) R.string.Resgatado else (if (isNotifyEnable) R.string.resgatar else R.string.go_and_do)
|
||||||
|
setTaskStateInfo(stateBean.rewardGoldNum.toString(), actionButRes,
|
||||||
|
String.format(ResUtil.getString(R.string.beginner_notify_desc), stateBean.rewardGoldNum), stateBean.hasClaimReward)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override fun ViewBinding.initObservers() {
|
override fun ViewBinding.initObservers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -211,15 +366,59 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotoDiscord() {
|
private fun gotoDiscord() {
|
||||||
//TODO("Not yet implemented")
|
AndroidUtil.openUrl(VidiConst.URL_DISCORD)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotoNotification() {
|
private fun gotoNotification() {
|
||||||
//TODO("Not yet implemented")
|
PermissionUtil.checkPermission(Manifest.permission.POST_NOTIFICATIONS, object : PermissionUtil.ICallback() {
|
||||||
|
override fun onAllGranted() {
|
||||||
|
AndroidUtil.openAppNotifySettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPartialGranted() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAllRejected() {
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotoWithVideo() {
|
|
||||||
//TODO("Not yet implemented")
|
private fun handleDailyVideoButClicked(itemIndex: Int) {
|
||||||
|
val subTaskList = TaskManager.instance().dailyWatchVideoStatus().getStatusBean().getSubTaskRewardState()
|
||||||
|
if (itemIndex >= 0 && itemIndex < subTaskList.size) {
|
||||||
|
val subTaskState = subTaskList[itemIndex]
|
||||||
|
when (subTaskState.state) {
|
||||||
|
STATE_ONGOING -> {
|
||||||
|
val activity = requireActivity()
|
||||||
|
if (activity is MainActivity) {
|
||||||
|
activity.switchTab(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
STATE_FINISH -> {
|
||||||
|
if (TaskManager.instance().dailyWatchVideoStatus().claimSubTaskReward(itemIndex)) {
|
||||||
|
DailySignSuccessDialog(requireActivity()).initData(subTaskState.mRewardNum, false).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleDailyAdButClicked(itemIndex: Int) {
|
||||||
|
val subTaskList = TaskManager.instance().dailyWatchAdStatus().getStatusBean().getSubTaskRewardState()
|
||||||
|
if (itemIndex >= 0 && itemIndex < subTaskList.size) {
|
||||||
|
val subTaskState = subTaskList[itemIndex]
|
||||||
|
when (subTaskState.state) {
|
||||||
|
STATE_ONGOING -> {
|
||||||
|
WatchAdDialog(requireActivity(), VididinEvents.Event_AD_TASK_TYPE_Watch_Ad_Daily, null).show()
|
||||||
|
}
|
||||||
|
STATE_FINISH -> {
|
||||||
|
if (TaskManager.instance().dailyWatchAdStatus().claimSubTaskReward(itemIndex)) {
|
||||||
|
DailySignSuccessDialog(requireActivity()).initData(subTaskState.mRewardNum, false).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,6 @@ class DefaultYoutubeDatasource @Inject constructor(retrofit: Retrofit) : Youtube
|
||||||
override suspend fun getChannels(
|
override suspend fun getChannels(
|
||||||
) = shopApi.getChannelList()
|
) = shopApi.getChannelList()
|
||||||
|
|
||||||
override suspend fun getVideoList(pageToken: String?) = shopApi.getVideoList(pageToken = pageToken)
|
override suspend fun getVideoList(lastVideoId: String?) = shopApi.getVideoList(video = lastVideoId)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -20,7 +20,7 @@ class DefaultYoutubeRepository @Inject constructor(
|
||||||
page: Int,
|
page: Int,
|
||||||
size: Int
|
size: Int
|
||||||
): ResYoutubePlayList {
|
): ResYoutubePlayList {
|
||||||
return network.getVideoList(mRespPlayList?.nextPageToken)
|
return network.getVideoList(mRespPlayList?.videos?.last()?.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getChannelList(
|
override suspend fun getChannelList(
|
||||||
|
|
@ -35,7 +35,7 @@ class DefaultYoutubeRepository @Inject constructor(
|
||||||
pageSize: Int
|
pageSize: Int
|
||||||
): List<YoutubeVideo>? {
|
): List<YoutubeVideo>? {
|
||||||
mRespPlayList = getVideoList(key, pageSize)
|
mRespPlayList = getVideoList(key, pageSize)
|
||||||
return mRespPlayList?.items
|
return mRespPlayList?.videos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package com.gamedog.vididin.main.fragments.home.fragment
|
package com.gamedog.vididin.main.fragments.home.fragment
|
||||||
|
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
|
@ -9,15 +11,21 @@ import android.view.animation.AlphaAnimation
|
||||||
import android.view.animation.Animation
|
import android.view.animation.Animation
|
||||||
import android.view.animation.AnimationSet
|
import android.view.animation.AnimationSet
|
||||||
import android.view.animation.ScaleAnimation
|
import android.view.animation.ScaleAnimation
|
||||||
|
import android.widget.FrameLayout
|
||||||
import androidx.annotation.NonNull
|
import androidx.annotation.NonNull
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.ama.core.architecture.appBase.AppViewsEmptyViewModelFragment
|
import com.ama.core.architecture.appBase.AppViewsEmptyViewModelFragment
|
||||||
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.common.widget.PopMenuIconView
|
import com.ama.core.common.widget.PopMenuIconView
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
|
import com.gamedog.vididin.VidiConst
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
import com.gamedog.vididin.beans.YoutubeVideo
|
import com.gamedog.vididin.beans.YoutubeVideo
|
||||||
import com.gamedog.vididin.main.WatchVideoDialog
|
import com.gamedog.vididin.main.WatchAdDialog
|
||||||
import com.gamedog.vididin.router.Router
|
import com.gamedog.vididin.router.Router
|
||||||
import com.gamedog.vididin.widget.MyPlayerControlView
|
import com.gamedog.vididin.widget.MyPlayerControlView
|
||||||
|
import com.gamedog.vididin.youtubestatistic.TickerTimer
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.PlayerConstants
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.PlayerConstants
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener
|
||||||
|
|
@ -27,13 +35,15 @@ import com.gamedog.vididin.databinding.VididinappFeatureHomeItemLayoutBinding as
|
||||||
|
|
||||||
|
|
||||||
class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
|
private var mMaskBitmap: Bitmap? = null
|
||||||
private var mPlayerView: YouTubePlayerView? = null
|
private var mPlayerView: YouTubePlayerView? = null
|
||||||
private var mIsStared = false
|
|
||||||
private var mPlayer: YouTubePlayer? = null
|
private var mPlayer: YouTubePlayer? = null
|
||||||
private var mVideoData: YoutubeVideo? = null
|
private var mVideoData: YoutubeVideo? = null
|
||||||
private var mIsPlaying: Boolean = false
|
private var mIsPlaying: Boolean = false
|
||||||
|
private var mIsIntroExpand: Boolean = false
|
||||||
private var mCurPlayedSecond: Float = 0F
|
private var mCurPlayedSecond: Float = 0F
|
||||||
private var mTotalDuration: Float = -1F
|
private var mTotalDuration: Float = 0F
|
||||||
|
private val mTickerTimer = TickerTimer()
|
||||||
|
|
||||||
|
|
||||||
override fun inflateViewBinding(
|
override fun inflateViewBinding(
|
||||||
|
|
@ -43,16 +53,14 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
|
|
||||||
|
|
||||||
override fun ViewBinding.initViews() {
|
override fun ViewBinding.initViews() {
|
||||||
maskView.setOnClickListener {
|
|
||||||
if (mIsPlaying) mPlayer?.pause() else mPlayer?.play()
|
|
||||||
}
|
|
||||||
|
|
||||||
playIcon.setOnClickListener {
|
playIcon.setOnClickListener {
|
||||||
if (mIsPlaying) mPlayer?.pause() else mPlayer?.play()
|
if (mIsPlaying) mPlayer?.pause() else mPlayer?.play()
|
||||||
}
|
}
|
||||||
|
|
||||||
tvVideoFrom.text = mVideoData?.snippet?.localized?.title
|
tvVideoFrom.text = mVideoData?.channel_title
|
||||||
tvVideoIntro.text = mVideoData?.snippet?.localized?.description
|
tvVideoIntro.text = mVideoData?.description
|
||||||
|
ivIntroExpand.isVisible = tvVideoIntro.lineCount > 2
|
||||||
|
|
||||||
|
|
||||||
popMenu.setMenuList(
|
popMenu.setMenuList(
|
||||||
mutableListOf(
|
mutableListOf(
|
||||||
|
|
@ -60,23 +68,34 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
Router.Benefit.startActivity(requireActivity())
|
Router.Benefit.startActivity(requireActivity())
|
||||||
},
|
},
|
||||||
PopMenuIconView.MenuItem(R.mipmap.home_menu_2) {
|
PopMenuIconView.MenuItem(R.mipmap.home_menu_2) {
|
||||||
WatchVideoDialog(requireContext()).show()
|
WatchAdDialog(requireActivity(), VididinEvents.Event_AD_TASK_TYPE_Watch_Ad_Earn_Gold, null).show()
|
||||||
},
|
},
|
||||||
PopMenuIconView.MenuItem(R.mipmap.home_menu_3) {
|
PopMenuIconView.MenuItem(R.mipmap.home_menu_3) {
|
||||||
|
AndroidUtil.openUrl(VidiConst.URL_GAME)
|
||||||
},
|
},
|
||||||
PopMenuIconView.MenuItem(R.mipmap.home_menu_4) {
|
PopMenuIconView.MenuItem(R.mipmap.home_menu_4) {
|
||||||
Router.Benefit.startActivity(requireActivity())
|
Router.Benefit.startActivity(requireActivity())
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|
||||||
|
setOnClickBatch(ivIntroExpand, clickMaskView) {
|
||||||
|
when (this) {
|
||||||
|
clickMaskView -> {
|
||||||
|
if (mIsPlaying) mPlayer?.pause() else mPlayer?.play()
|
||||||
|
}
|
||||||
|
|
||||||
|
ivIntroExpand -> {
|
||||||
|
mIsIntroExpand = !mIsIntroExpand
|
||||||
|
tvVideoIntro.maxLines = if (mIsIntroExpand) 8 else 2
|
||||||
|
ivIntroExpand.setImageResource(if (mIsIntroExpand) R.mipmap.arrow_down else R.mipmap.arrow_up)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun ViewBinding.initListeners() {
|
override fun ViewBinding.initListeners() {
|
||||||
ivStar.setOnClickListener {
|
|
||||||
mIsStared = !mIsStared
|
|
||||||
ivStar.setImageResource(if (mIsStared) R.mipmap.home_star else R.mipmap.home_star_undo)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,13 +103,35 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
mMaskBitmap?.recycle()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun playVideo() {
|
||||||
|
if (mPlayer != null && mVideoData != null && !mVideoData?.id.isNullOrEmpty()) {
|
||||||
|
mPlayer?.loadOrCueVideo(
|
||||||
|
lifecycle,
|
||||||
|
mVideoData!!.id,
|
||||||
|
0f
|
||||||
|
)
|
||||||
|
|
||||||
|
/*mPlayerView?.isVisible?.let {
|
||||||
|
if (!it) {
|
||||||
|
mPlayer?.pause()
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun loadVideo() {
|
fun loadVideo() {
|
||||||
if (null == mPlayerView) {
|
if (null == mPlayerView) {
|
||||||
mPlayerView = YouTubePlayerView(requireContext())
|
mPlayerView = YouTubePlayerView(requireContext())
|
||||||
binding!!.playerContainer.addView(mPlayerView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
val layoutParam = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||||
|
layoutParam.gravity = Gravity.CENTER
|
||||||
|
binding!!.playerContainer.addView(mPlayerView, layoutParam)
|
||||||
lifecycle.addObserver(mPlayerView!!)
|
lifecycle.addObserver(mPlayerView!!)
|
||||||
mPlayerView?.enableAutomaticInitialization = true
|
mPlayerView?.enableAutomaticInitialization = true
|
||||||
}
|
}
|
||||||
|
|
@ -104,17 +145,7 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
val playerUiController = MyPlayerControlView(playerView, youTubePlayer)
|
val playerUiController = MyPlayerControlView(playerView, youTubePlayer)
|
||||||
playerView.setCustomPlayerUi(playerUiController.rootView)
|
playerView.setCustomPlayerUi(playerUiController.rootView)
|
||||||
|
|
||||||
if (mVideoData != null && !mVideoData?.id.isNullOrEmpty()) {
|
playVideo()
|
||||||
youTubePlayer.loadOrCueVideo(
|
|
||||||
lifecycle,
|
|
||||||
mVideoData!!.id,
|
|
||||||
0f
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!playerView.isVisible) {
|
|
||||||
youTubePlayer.pause()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCurrentSecond(youTubePlayer: YouTubePlayer, second: Float) {
|
override fun onCurrentSecond(youTubePlayer: YouTubePlayer, second: Float) {
|
||||||
|
|
@ -126,6 +157,7 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
override fun onVideoDuration(youTubePlayer: YouTubePlayer, duration: Float) {
|
override fun onVideoDuration(youTubePlayer: YouTubePlayer, duration: Float) {
|
||||||
super.onVideoDuration(youTubePlayer, duration)
|
super.onVideoDuration(youTubePlayer, duration)
|
||||||
mTotalDuration = duration
|
mTotalDuration = duration
|
||||||
|
mTickerTimer.setVideoInfo(mVideoData!!.id, (1000L * mTotalDuration).toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStateChange(
|
override fun onStateChange(
|
||||||
|
|
@ -147,9 +179,11 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
}
|
}
|
||||||
PlayerConstants.PlayerState.ENDED -> {
|
PlayerConstants.PlayerState.ENDED -> {
|
||||||
togglePlayingState(false)
|
togglePlayingState(false)
|
||||||
|
playVideo()
|
||||||
}
|
}
|
||||||
PlayerConstants.PlayerState.BUFFERING -> {
|
PlayerConstants.PlayerState.BUFFERING -> {
|
||||||
togglePlayingState(false)
|
binding?.circlePb?.isVisible = true
|
||||||
|
//showLoading(true)
|
||||||
}
|
}
|
||||||
PlayerConstants.PlayerState.VIDEO_CUED -> {
|
PlayerConstants.PlayerState.VIDEO_CUED -> {
|
||||||
togglePlayingState(false)
|
togglePlayingState(false)
|
||||||
|
|
@ -159,14 +193,38 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun generateThumbAndSet() {
|
||||||
|
// capturePlayerView And Show as thumb
|
||||||
|
mPlayerView?.let {
|
||||||
|
mMaskBitmap?.recycle()
|
||||||
|
|
||||||
|
mMaskBitmap = AndroidUtil.getThumbOfView(it)
|
||||||
|
mMaskBitmap?.let {
|
||||||
|
binding?.ivMask?.setImageBitmap(mMaskBitmap)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun togglePlayingState(isPlaying: Boolean) {
|
private fun togglePlayingState(isPlaying: Boolean) {
|
||||||
if (mIsPlaying != isPlaying) {
|
if (mIsPlaying != isPlaying) {
|
||||||
mIsPlaying = isPlaying
|
mIsPlaying = isPlaying
|
||||||
|
if (!mIsPlaying) {
|
||||||
|
generateThumbAndSet()
|
||||||
|
} else {
|
||||||
|
binding?.circlePb?.isVisible = false
|
||||||
|
}
|
||||||
|
|
||||||
|
binding?.ivMask?.isVisible = !mIsPlaying
|
||||||
|
binding?.playerContainer?.isVisible = mIsPlaying
|
||||||
|
|
||||||
if (mIsPlaying) {
|
if (mIsPlaying) {
|
||||||
hidePlayIconAnim()
|
hidePlayIconAnim()
|
||||||
} else {
|
} else {
|
||||||
showPlayIconAnim()
|
showPlayIconAnim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mIsPlaying) mTickerTimer.start() else mTickerTimer.pause()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.gamedog.vididin.main.fragments.task
|
package com.gamedog.vididin.main.fragments.task
|
||||||
|
|
||||||
import android.content.Context
|
import android.app.Activity
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.widget.BindingDialog
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
|
|
@ -9,7 +9,7 @@ import com.gamedog.vididin.manager.TaskManager
|
||||||
import com.gamedog.vididin.widget.DailySignItemView
|
import com.gamedog.vididin.widget.DailySignItemView
|
||||||
|
|
||||||
|
|
||||||
class DailySignDialog(context: Context) : BindingDialog<DialogDailySignBinding>(context, DialogDailySignBinding::inflate) {
|
class DailySignDialog(context: Activity) : BindingDialog<DialogDailySignBinding>(context, DialogDailySignBinding::inflate) {
|
||||||
private var mCurDayIndex: Int = 0
|
private var mCurDayIndex: Int = 0
|
||||||
private var mConfigList: List<RewardDetail>? = emptyList()
|
private var mConfigList: List<RewardDetail>? = emptyList()
|
||||||
private var mSignItemViewList: MutableList<DailySignItemView> = mutableListOf()
|
private var mSignItemViewList: MutableList<DailySignItemView> = mutableListOf()
|
||||||
|
|
@ -56,16 +56,16 @@ class DailySignDialog(context: Context) : BindingDialog<DialogDailySignBinding>(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clickedNormalSign() {
|
private fun clickedNormalSign() {
|
||||||
if (TaskManager.instance().executeDailySign(mCurDayIndex, false, false)) {
|
if (TaskManager.instance().dailySignStatus().executeDailySign(mCurDayIndex, false, false)) {
|
||||||
DailySignSuccessDialog(context).initData(mConfigList?.get(mCurDayIndex)?.value, true).show()
|
DailySignSuccessDialog(mActivity).initData(mConfigList?.get(mCurDayIndex)?.value, true).show()
|
||||||
updateUI(mCurDayIndex)
|
updateUI(mCurDayIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clickedAdSingleBut() {
|
private fun clickedAdSingleBut() {
|
||||||
startAdTask("signalAd", {
|
startAdTask("signalAd", {
|
||||||
if (TaskManager.instance().executeDailySign(mCurDayIndex, false, true)) {
|
if (TaskManager.instance().dailySignStatus().executeDailySign(mCurDayIndex, false, true)) {
|
||||||
DailySignSuccessDialog(context).initData(mConfigList?.get(mCurDayIndex)?.value, false).show()
|
DailySignSuccessDialog(mActivity).initData(mConfigList?.get(mCurDayIndex)?.value, false).show()
|
||||||
updateUI(mCurDayIndex)
|
updateUI(mCurDayIndex)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -73,8 +73,8 @@ class DailySignDialog(context: Context) : BindingDialog<DialogDailySignBinding>(
|
||||||
|
|
||||||
private fun clickedAdDoubleBut() {
|
private fun clickedAdDoubleBut() {
|
||||||
startAdTask("doubleAd", {
|
startAdTask("doubleAd", {
|
||||||
if (TaskManager.instance().executeDailySign(mCurDayIndex, true, true)) {
|
if (TaskManager.instance().dailySignStatus().executeDailySign(mCurDayIndex, true, true)) {
|
||||||
DailySignSuccessDialog(context).initData((mConfigList?.get(mCurDayIndex)?.value)?.times(
|
DailySignSuccessDialog(mActivity).initData((mConfigList?.get(mCurDayIndex)?.value)?.times(
|
||||||
2
|
2
|
||||||
), false).show()
|
), false).show()
|
||||||
updateUI(mCurDayIndex)
|
updateUI(mCurDayIndex)
|
||||||
|
|
@ -83,11 +83,11 @@ class DailySignDialog(context: Context) : BindingDialog<DialogDailySignBinding>(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clickedComplementSign() {
|
private fun clickedComplementSign() {
|
||||||
val firstForgotSignDayIndex = TaskManager.instance().getForgotSignFirstDayIndex()
|
val firstForgotSignDayIndex = TaskManager.instance().dailySignStatus().getForgotSignFirstDayIndex()
|
||||||
if (firstForgotSignDayIndex > 0) {
|
if (firstForgotSignDayIndex > 0) {
|
||||||
startAdTask("complementAd", {
|
startAdTask("complementAd", {
|
||||||
if (TaskManager.instance().executeDailySign(firstForgotSignDayIndex, false, false)){
|
if (TaskManager.instance().dailySignStatus().executeDailySign(firstForgotSignDayIndex, false, false)){
|
||||||
DailySignSuccessDialog(context).initData(mConfigList?.get(firstForgotSignDayIndex)?.value, false).show()
|
DailySignSuccessDialog(mActivity).initData(mConfigList?.get(firstForgotSignDayIndex)?.value, false).show()
|
||||||
updateUI(firstForgotSignDayIndex)
|
updateUI(firstForgotSignDayIndex)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -120,14 +120,14 @@ class DailySignDialog(context: Context) : BindingDialog<DialogDailySignBinding>(
|
||||||
mConfigList?.let {
|
mConfigList?.let {
|
||||||
mSignItemViewList.forEachIndexed { index, itemView->
|
mSignItemViewList.forEachIndexed { index, itemView->
|
||||||
itemView.setData(mConfigList!![index],
|
itemView.setData(mConfigList!![index],
|
||||||
TaskManager.instance().getDailySignStateBean(index))
|
TaskManager.instance().dailySignStatus().getDailySignStateBean(index))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initSignState() {
|
private fun initSignState() {
|
||||||
mCurDayIndex = TaskManager.instance().getCurDayIndexOfDailyCheckIn()
|
mCurDayIndex = TaskManager.instance().dailySignStatus().getCurDayIndexOfDailyCheckIn()
|
||||||
mSignItemViewList[mCurDayIndex].setSelectState(true)
|
mSignItemViewList[mCurDayIndex].setSelectState(true)
|
||||||
updateUI(mCurDayIndex)
|
updateUI(mCurDayIndex)
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +140,7 @@ class DailySignDialog(context: Context) : BindingDialog<DialogDailySignBinding>(
|
||||||
|
|
||||||
|
|
||||||
mBinding.tvSignedTotal.text = buildString {
|
mBinding.tvSignedTotal.text = buildString {
|
||||||
append(TaskManager.instance().getSignDaysTotal())
|
append(TaskManager.instance().dailySignStatus().getSignDaysTotal())
|
||||||
append("/7")
|
append("/7")
|
||||||
}
|
}
|
||||||
mSignItemViewList[signedDayIndex].updateUI()
|
mSignItemViewList[signedDayIndex].updateUI()
|
||||||
|
|
@ -162,7 +162,7 @@ class DailySignDialog(context: Context) : BindingDialog<DialogDailySignBinding>(
|
||||||
mConfigList?.get(mCurDayIndex)?.value
|
mConfigList?.get(mCurDayIndex)?.value
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val forgotSignDays = TaskManager.instance().getForgotSignDays()
|
val forgotSignDays = TaskManager.instance().dailySignStatus().getForgotSignDays()
|
||||||
if (forgotSignDays > 0) {
|
if (forgotSignDays > 0) {
|
||||||
mBinding.actionNormalTwoButs.isVisible = false
|
mBinding.actionNormalTwoButs.isVisible = false
|
||||||
mBinding.actionWatchAd.isVisible = false
|
mBinding.actionWatchAd.isVisible = false
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.gamedog.vididin.main.fragments.task
|
package com.gamedog.vididin.main.fragments.task
|
||||||
|
|
||||||
import android.content.Context
|
import android.app.Activity
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.widget.BindingDialog
|
import com.ama.core.architecture.widget.BindingDialog
|
||||||
import com.gamedog.vididin.databinding.DialogDailySignSuccessBinding as ViewBinding
|
import com.gamedog.vididin.databinding.DialogDailySignSuccessBinding as ViewBinding
|
||||||
|
|
||||||
|
|
||||||
class DailySignSuccessDialog(context: Context) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
|
class DailySignSuccessDialog(activity: Activity) : BindingDialog<ViewBinding>(activity, ViewBinding::inflate) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
build()
|
build()
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ data class TaskBean(
|
||||||
|
|
||||||
data class TaskModuleConfig(
|
data class TaskModuleConfig(
|
||||||
val basic_info: BasicInfo,
|
val basic_info: BasicInfo,
|
||||||
val task_categories: List<TaskCategory>
|
val task_categories: List<TaskCategory>,
|
||||||
|
val box_task: BoxTaskRoot
|
||||||
) {
|
) {
|
||||||
fun getTaskCategoryById(categoryId: String): TaskCategory? {
|
fun getTaskCategoryById(categoryId: String): TaskCategory? {
|
||||||
return task_categories.find { it.category_id == categoryId }
|
return task_categories.find { it.category_id == categoryId }
|
||||||
|
|
@ -53,4 +54,33 @@ data class RewardDetail(
|
||||||
val day: Int,
|
val day: Int,
|
||||||
val target_count: Int,
|
val target_count: Int,
|
||||||
val value: Int
|
val value: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------- 宝箱任务配置 -----------------------------
|
||||||
|
data class BoxSubTask(
|
||||||
|
val task_id: String,
|
||||||
|
val task_name: String,
|
||||||
|
val required_count: Int,
|
||||||
|
val task_type: Int,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class BoxTask(
|
||||||
|
val chest_id: String,
|
||||||
|
val chest_name: String,
|
||||||
|
val duration_days: Int,
|
||||||
|
val reward_type: String,
|
||||||
|
val reward_value: Float,
|
||||||
|
val is_one_time: Boolean,
|
||||||
|
val status: String,
|
||||||
|
val tasks: List<BoxSubTask>,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class BoxTaskRoot(
|
||||||
|
val category_id: String,
|
||||||
|
val category_name: String,
|
||||||
|
val valid_period: String,
|
||||||
|
val display_priority: String,
|
||||||
|
val chests: List<BoxTask>,
|
||||||
)
|
)
|
||||||
|
|
@ -114,7 +114,7 @@ class WeekStatusView @JvmOverloads constructor(
|
||||||
override fun onDraw(canvas: Canvas) {
|
override fun onDraw(canvas: Canvas) {
|
||||||
super.onDraw(canvas)
|
super.onDraw(canvas)
|
||||||
|
|
||||||
val dayStateList = TaskManager.instance().getDayStateList()
|
val dayStateList = TaskManager.instance().dailySignStatus().getDayStateList()
|
||||||
if (dayStateList.isEmpty()) return
|
if (dayStateList.isEmpty()) return
|
||||||
|
|
||||||
val totalWidth = measuredWidth.toFloat()
|
val totalWidth = measuredWidth.toFloat()
|
||||||
|
|
@ -140,7 +140,7 @@ class WeekStatusView @JvmOverloads constructor(
|
||||||
|
|
||||||
// reward text
|
// reward text
|
||||||
textPaint.textSize = rewardTextSize
|
textPaint.textSize = rewardTextSize
|
||||||
val rewardNum = TaskManager.instance().getRewardNumOfDailySign(index)
|
val rewardNum = TaskManager.instance().dailySignStatus().getRewardNumOfDailySign(index)
|
||||||
textPaint.color = if (dayStatus.hasSigned) rewardTextSignedColor else rewardTextColor
|
textPaint.color = if (dayStatus.hasSigned) rewardTextSignedColor else rewardTextColor
|
||||||
canvas.drawText(rewardNum.toString(), centerX, vertiMagin + dayTextSize + componentGap + 2*circleRadius + componentGap, textPaint)
|
canvas.drawText(rewardNum.toString(), centerX, vertiMagin + dayTextSize + componentGap + 2*circleRadius + componentGap, textPaint)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,10 @@ import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
|
import com.gamedog.vididin.R
|
||||||
|
import com.gamedog.vididin.VidiConst
|
||||||
import com.gamedog.vididin.databinding.BeginnerTaskItemViewBinding
|
import com.gamedog.vididin.databinding.BeginnerTaskItemViewBinding
|
||||||
|
import com.gamedog.vididin.main.fragments.task.Task
|
||||||
|
|
||||||
|
|
||||||
class BeginnerTaskItemView @JvmOverloads constructor(
|
class BeginnerTaskItemView @JvmOverloads constructor(
|
||||||
|
|
@ -31,20 +34,17 @@ class BeginnerTaskItemView @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun initUI(titleIconRes: Int, titleRes: Int, desRes: Int, actionRes: Int) {
|
fun initUI(titleIconRes: Int, titleRes: Int, actionRes: Int) {
|
||||||
mBinding.ivItemIcon.setImageResource(titleIconRes)
|
mBinding.ivItemIcon.setImageResource(titleIconRes)
|
||||||
mBinding.tvItemTitle.setText(titleRes)
|
mBinding.tvItemTitle.setText(titleRes)
|
||||||
mBinding.tvAction.setText(actionRes)
|
mBinding.tvAction.setText(actionRes)
|
||||||
mBinding.tvItemDescrible.setText(desRes)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setRewardNum(rewardNum: String) {
|
fun setRewardInfo(taskReward: Task) {
|
||||||
mBinding.tvRewardNum.text = rewardNum
|
val isRewardGold = VidiConst.GOLD_IN_CONFIG == taskReward.reward_type;
|
||||||
}
|
mBinding.ivRewardIcon.setImageResource(if (isRewardGold) R.mipmap.icon_glod_small else R.mipmap.icon_cash_s)
|
||||||
|
mBinding.tvRewardNum.text = taskReward.reward_value.toString()
|
||||||
fun setRewardIcon(iconRes: Int) {
|
|
||||||
mBinding.ivRewardIcon.setImageResource(iconRes)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -57,5 +57,20 @@ class BeginnerTaskItemView @JvmOverloads constructor(
|
||||||
mBinding.tvRewardNum.setTextColor(color)
|
mBinding.tvRewardNum.setTextColor(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setTaskStateInfo(
|
||||||
|
rewardNum: String,
|
||||||
|
textRes: Int,
|
||||||
|
describleStr: String,
|
||||||
|
hasClaimReward: Boolean
|
||||||
|
) {
|
||||||
|
mBinding.tvRewardNum.text = rewardNum
|
||||||
|
mBinding.tvAction.setText(textRes)
|
||||||
|
mBinding.tvItemDescrible.text = describleStr
|
||||||
|
mBinding.tvAction.isClickable = !hasClaimReward
|
||||||
|
if (hasClaimReward) {
|
||||||
|
mBinding.tvAction.setBackgroundResource(R.drawable.bg_sub_task_disable)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,7 +6,11 @@ import android.view.LayoutInflater
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.ama.core.architecture.util.ResUtil
|
import com.ama.core.architecture.util.ResUtil
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
|
import com.gamedog.vididin.R
|
||||||
import com.gamedog.vididin.databinding.DailyTaskItemViewBinding
|
import com.gamedog.vididin.databinding.DailyTaskItemViewBinding
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_CLAIMED
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_FINISH
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_ONGOING
|
||||||
|
|
||||||
|
|
||||||
class DailyTaskItemView @JvmOverloads constructor(
|
class DailyTaskItemView @JvmOverloads constructor(
|
||||||
|
|
@ -14,8 +18,10 @@ class DailyTaskItemView @JvmOverloads constructor(
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
defStyleAttr: Int = 0
|
defStyleAttr: Int = 0
|
||||||
) : LinearLayout(context, attrs, defStyleAttr) {
|
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||||
|
private var mRewardNum: Int = 0
|
||||||
|
private var mNeedWatchTotal: Int = 0
|
||||||
private lateinit var mAction: () -> Unit
|
private lateinit var mAction: () -> Unit
|
||||||
private lateinit var mBinding: DailyTaskItemViewBinding
|
private var mBinding: DailyTaskItemViewBinding
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
@ -33,20 +39,49 @@ class DailyTaskItemView @JvmOverloads constructor(
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun initUI(titleIconRes: Int, titleRes: Int, videosNum: Int, actionRes: Int) {
|
fun initUI(titleIconRes: Int, titleRes: Int, videosNum: Int, goldReward: Int) {
|
||||||
|
mRewardNum = goldReward
|
||||||
|
mNeedWatchTotal = videosNum
|
||||||
|
|
||||||
mBinding.ivItemIcon.setImageResource(titleIconRes)
|
mBinding.ivItemIcon.setImageResource(titleIconRes)
|
||||||
mBinding.tvItemTitle.text = String.format(ResUtil.getString(titleRes), videosNum)
|
mBinding.tvItemTitle.text = String.format(ResUtil.getString(titleRes), videosNum)
|
||||||
mBinding.tvAction.setText(actionRes)
|
mBinding.tvRewardNum.text = "+$goldReward"
|
||||||
|
mBinding.tvItemProgress.text = "(0/$videosNum)"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setProgressText(progress: Int, progressText: String) {
|
fun updateProgress(watchedCount: Int, subTaskState: Int) {
|
||||||
mBinding.tvItemProgress.text = progressText
|
doUpdateProgress(watchedCount)
|
||||||
mBinding.itemProgress.setProgress(progress)
|
|
||||||
|
with(mBinding.tvAction) {
|
||||||
|
when(subTaskState) {
|
||||||
|
STATE_ONGOING -> {
|
||||||
|
setText(R.string.go_and_do)
|
||||||
|
setBackgroundResource(R.drawable.bg_sub_task_normal)
|
||||||
|
isClickable = true
|
||||||
|
alpha = 1F
|
||||||
|
}
|
||||||
|
|
||||||
|
STATE_FINISH -> {
|
||||||
|
setText(R.string.resgatar)
|
||||||
|
setBackgroundResource(R.drawable.bg_sub_task_normal)
|
||||||
|
isClickable = true
|
||||||
|
alpha = 1F
|
||||||
|
}
|
||||||
|
|
||||||
|
STATE_CLAIMED -> {
|
||||||
|
setText(R.string.Resgatado)
|
||||||
|
setBackgroundResource(R.drawable.bg_sub_task_disable)
|
||||||
|
isClickable = false
|
||||||
|
alpha = 0.4F
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setRewardInfo(rewardIconRes: Int, rewardNum: Int) {
|
private fun doUpdateProgress(finishNum: Int) {
|
||||||
mBinding.tvRewardNum.text = "" + rewardNum
|
val properShowNumForCurSubTask = if (finishNum > mNeedWatchTotal) mNeedWatchTotal else finishNum
|
||||||
mBinding.ivRewardIcon.setImageResource(rewardIconRes)
|
mBinding.tvItemProgress.text = "($properShowNumForCurSubTask/$mNeedWatchTotal)"
|
||||||
|
mBinding.itemProgress.setProgress(100*properShowNumForCurSubTask/mNeedWatchTotal)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setActionFun(action: ()->Unit) {
|
fun setActionFun(action: ()->Unit) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.gamedog.vididin.manager
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
|
||||||
|
class DateChangeReceiver : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
if (intent.action == Intent.ACTION_DATE_CHANGED) {
|
||||||
|
TaskManager.instance().onDateChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,13 +1,21 @@
|
||||||
package com.gamedog.vididin.manager
|
package com.gamedog.vididin.manager
|
||||||
|
|
||||||
import com.ama.core.architecture.util.DateUtil
|
|
||||||
import com.ama.core.architecture.util.FileUtil
|
import com.ama.core.architecture.util.FileUtil
|
||||||
import com.ama.core.architecture.util.SpUtil
|
|
||||||
import com.ama.core.architecture.util.eventbus.NotifyMan
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.gamedog.vididin.VidiConst
|
||||||
import com.gamedog.vididin.VididinEvents
|
import com.gamedog.vididin.VididinEvents
|
||||||
import com.gamedog.vididin.core.login.login.AccountManager
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
|
import com.gamedog.vididin.main.fragments.task.BoxTaskRoot
|
||||||
import com.gamedog.vididin.main.fragments.task.Task
|
import com.gamedog.vididin.main.fragments.task.Task
|
||||||
import com.gamedog.vididin.main.fragments.task.TaskBean
|
import com.gamedog.vididin.main.fragments.task.TaskBean
|
||||||
|
import com.gamedog.vididin.manager.helpers.BoxTaskHelper
|
||||||
|
import com.gamedog.vididin.manager.helpers.DailySignTaskHelper
|
||||||
|
import com.gamedog.vididin.manager.helpers.DailyWatchAdTaskHelper
|
||||||
|
import com.gamedog.vididin.manager.helpers.DailyWatchVideoTaskHelper
|
||||||
|
import com.gamedog.vididin.manager.helpers.NewbieEnableNotifyHelper
|
||||||
|
import com.gamedog.vididin.manager.helpers.NewbieFirstWithdrawHelper
|
||||||
|
import com.gamedog.vididin.manager.helpers.NewbieJoinDiscordHelper
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
|
|
@ -31,6 +39,24 @@ class TaskManager private constructor() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 宝箱子任务类型对应
|
||||||
|
const val BOX_SUB_TASK_TYPE_AD = 1
|
||||||
|
const val BOX_SUB_TASK_TYPE_VIDEO = 2
|
||||||
|
const val BOX_SUB_TASK_TYPE_SIGN = 3
|
||||||
|
const val BOX_SUB_TASK_TYPE_ZERO_BUY = 4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var instance: TaskManager? = null
|
private var instance: TaskManager? = null
|
||||||
|
|
||||||
|
|
@ -44,26 +70,52 @@ class TaskManager private constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private var mCurDayIndexDailySign: Int = 0
|
|
||||||
private val mutex = Mutex()
|
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var initialized = false
|
private var initialized = false
|
||||||
private var mTaskConfig: TaskBean? = null
|
private val mutex = Mutex()
|
||||||
private var mDailySignData: DailySignBean = DailySignBean()
|
|
||||||
private val mGson = GsonBuilder().create()
|
private val mGson = GsonBuilder().create()
|
||||||
|
private var mTaskConfig: TaskBean? = null
|
||||||
|
|
||||||
|
|
||||||
|
private val mDailySignTaskHelper by lazy { DailySignTaskHelper() }
|
||||||
|
private val mDailyWatchVideoTaskHelper by lazy { DailyWatchVideoTaskHelper() }
|
||||||
|
private val mDailyWatchAdTaskHelper by lazy { DailyWatchAdTaskHelper() }
|
||||||
|
private val mBoxHelper by lazy { BoxTaskHelper() }
|
||||||
|
private val mNewbieJoinDiscordHelper by lazy { NewbieJoinDiscordHelper() }
|
||||||
|
private val mNewbieEnableNotifyHelper by lazy { NewbieEnableNotifyHelper() }
|
||||||
|
private val mNewbieFirstWithdrawHelper by lazy { NewbieFirstWithdrawHelper() }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
loadTaskConfigAsync()
|
loadTaskConfigAsync()
|
||||||
|
registerEvents()
|
||||||
|
|
||||||
// TODO - remove test code
|
// TODO - remove test code
|
||||||
if (true) {
|
if (true) {
|
||||||
generateTestDailySignTestBean()
|
mDailySignTaskHelper.generateTestDailySignTestBean()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun registerEvents() {
|
||||||
|
NotifyMan.instance().register(object : NotifyMan.ICallback(true) {
|
||||||
|
override fun onEvent(data: NotifyMan.NotifyData<*>?) {
|
||||||
|
when (data?.mEventType) {
|
||||||
|
VididinEvents.Event_AD_TASK_TYPE_Convert_Gold_2_Cash -> {
|
||||||
|
AccountManager.convertGold2Cash()
|
||||||
|
}
|
||||||
|
|
||||||
|
VididinEvents.Event_AD_TASK_TYPE_Watch_Ad_Earn_Gold -> {
|
||||||
|
AccountManager.addGold(VidiConst.WATCH_AD_REWARD_GOLD)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, VididinEvents.Event_AD_TASK_TYPE_Convert_Gold_2_Cash, VididinEvents.Event_AD_TASK_TYPE_Watch_Ad_Earn_Gold)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
suspend fun getTaskConfig(): TaskBean? = mutex.withLock {
|
suspend fun getTaskConfig(): TaskBean? = mutex.withLock {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
|
|
@ -77,9 +129,7 @@ class TaskManager private constructor() {
|
||||||
mutex.withLock {
|
mutex.withLock {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
loadTaskConfigFromAsset()
|
loadTaskConfigFromAsset()
|
||||||
loadTaskStatesFromSp()
|
initHelpers()
|
||||||
|
|
||||||
initCalculate()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -93,20 +143,54 @@ class TaskManager private constructor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun initHelpers() {
|
||||||
private suspend fun loadTaskStatesFromSp() {
|
mDailySignTaskHelper.setConfigDatas(getDailyCheckInTask()!!)
|
||||||
return withContext(Dispatchers.IO) {
|
mDailyWatchVideoTaskHelper.setConfigDatas(getDailyVideoTask()!!)
|
||||||
val taskStateBeanInSp = SpUtil.instance().getObject<DailySignBean>(SpUtil.KEY_TASK_BEAN)
|
mDailyWatchAdTaskHelper.setConfigDatas(getDailyAdTask()!!)
|
||||||
if (taskStateBeanInSp == null) {
|
mNewbieJoinDiscordHelper.setConfigDatas(getNewbieJoinDiscordTask()!!)
|
||||||
SpUtil.instance().putObject(SpUtil.KEY_TASK_BEAN, mDailySignData)
|
mNewbieEnableNotifyHelper.setConfigDatas(getNewbieEnableNotifyTask()!!)
|
||||||
} else {
|
mNewbieFirstWithdrawHelper.setConfigDatas(getNewbieFirstWithdrawTask()!!)
|
||||||
mDailySignData = taskStateBeanInSp
|
mBoxHelper.setConfigDatas(getBoxTaskConfig()!!)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initCalculate() {
|
fun onDateChanged() {
|
||||||
|
mDailySignTaskHelper.onDateChanged()
|
||||||
|
mDailyWatchVideoTaskHelper.onDateChanged()
|
||||||
|
mDailyWatchAdTaskHelper.onDateChanged()
|
||||||
|
mBoxHelper.onDateChanged()
|
||||||
|
mNewbieJoinDiscordHelper.onDateChanged()
|
||||||
|
mNewbieEnableNotifyHelper.onDateChanged()
|
||||||
|
mNewbieFirstWithdrawHelper.onDateChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------- Tasks Getter ------------------------------
|
||||||
|
fun dailySignStatus(): DailySignTaskHelper {
|
||||||
|
return mDailySignTaskHelper
|
||||||
|
}
|
||||||
|
|
||||||
|
fun dailyWatchVideoStatus(): DailyWatchVideoTaskHelper {
|
||||||
|
return mDailyWatchVideoTaskHelper
|
||||||
|
}
|
||||||
|
|
||||||
|
fun dailyWatchAdStatus(): DailyWatchAdTaskHelper {
|
||||||
|
return mDailyWatchAdTaskHelper
|
||||||
|
}
|
||||||
|
|
||||||
|
fun boxTaskStatus(): BoxTaskHelper {
|
||||||
|
return mBoxHelper
|
||||||
|
}
|
||||||
|
|
||||||
|
fun newbieJoinDiscordStatus(): NewbieJoinDiscordHelper {
|
||||||
|
return mNewbieJoinDiscordHelper
|
||||||
|
}
|
||||||
|
|
||||||
|
fun newbieEnableNotifyStatus(): NewbieEnableNotifyHelper {
|
||||||
|
return mNewbieEnableNotifyHelper
|
||||||
|
}
|
||||||
|
|
||||||
|
fun newbieFirstWithdrawStatus(): NewbieFirstWithdrawHelper {
|
||||||
|
return mNewbieFirstWithdrawHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -144,126 +228,17 @@ class TaskManager private constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 宝箱任务
|
||||||
|
fun getBoxTaskConfig(): BoxTaskRoot? {
|
||||||
//----------------------------- 每日签到 -----------------------------//
|
return mTaskConfig?.task_module_config?.box_task
|
||||||
|
|
||||||
fun getHomeWatchDurationRewardNum(): Int {
|
|
||||||
return 28; // TODO - mTaskConfigBean.xxxx
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun getCurDayIndexOfDailyCheckIn() : Int {
|
|
||||||
var dayIndexOfPeriod = 0
|
|
||||||
|
|
||||||
val periodStartMs = mDailySignData.startMs
|
|
||||||
if (periodStartMs > 0) {
|
|
||||||
dayIndexOfPeriod = DateUtil.getPassedDayNum(periodStartMs, DateUtil.getCurTimeMs())
|
|
||||||
if (dayIndexOfPeriod > 6) {
|
|
||||||
mDailySignData.startMs = DateUtil.getCurTimeMs()
|
|
||||||
SpUtil.instance().putObject(SpUtil.KEY_TASK_BEAN, mDailySignData)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mDailySignData.startMs = DateUtil.getCurTimeMs()
|
|
||||||
SpUtil.instance().putObject(SpUtil.KEY_TASK_BEAN, mDailySignData)
|
|
||||||
}
|
|
||||||
|
|
||||||
mCurDayIndexDailySign = dayIndexOfPeriod
|
|
||||||
return dayIndexOfPeriod
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getDailySignStateBean(dayIndex: Int): DailySignDayInfoBean {
|
|
||||||
return mDailySignData.signStateList[dayIndex]
|
|
||||||
}
|
|
||||||
|
|
||||||
fun executeDailySign(dayIndex: Int, isDoubleReward: Boolean, isByAd: Boolean) : Boolean {
|
|
||||||
val daySignState = mDailySignData.signStateList[dayIndex]
|
|
||||||
|
|
||||||
if (!daySignState.hasSigned || (dayIndex == mCurDayIndexDailySign && !daySignState.hasWatchedAd)) {
|
|
||||||
val dayReward = getDailyCheckInTask()?.reward_details?.get(dayIndex)?.value ?: 0
|
|
||||||
val finalReward = if (isDoubleReward) 2*dayReward else dayReward
|
|
||||||
daySignState.hasRewardedNum += finalReward
|
|
||||||
daySignState.hasSigned = true
|
|
||||||
daySignState.hasWatchedAd = isByAd
|
|
||||||
saveDailySignInfo()
|
|
||||||
AccountManager.addGold(finalReward)
|
|
||||||
notifySignStateChanged(Pair(dayIndex, daySignState))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun notifySignStateChanged(dataPair: Pair<Int, DailySignDayInfoBean>) {
|
|
||||||
NotifyMan.instance().sendEvent(VididinEvents.Event_Sign_State_Changed, NotifyMan.NotifyData(dataPair))
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun saveDailySignInfo() {
|
|
||||||
SpUtil.instance().putObject(SpUtil.KEY_DAILY_SIGN, mDailySignData)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun generateTestDailySignTestBean() {
|
|
||||||
mDailySignData = DailySignBean().apply {
|
|
||||||
startMs = DateUtil.getCurTimeMs() - 4 * DateUtil.MS_NUM_ONE_DAY
|
|
||||||
signStateList.clear()
|
|
||||||
signStateList.add(DailySignDayInfoBean(hasSigned = true, hasWatchedAd = true))
|
|
||||||
signStateList.add(DailySignDayInfoBean(hasSigned = false, hasWatchedAd = false))
|
|
||||||
signStateList.add(DailySignDayInfoBean(hasSigned = true, hasWatchedAd = false))
|
|
||||||
signStateList.add(DailySignDayInfoBean(hasSigned = false, hasWatchedAd = false))
|
|
||||||
signStateList.add(DailySignDayInfoBean(hasSigned = false, hasWatchedAd = false))
|
|
||||||
signStateList.add(DailySignDayInfoBean(hasSigned = false, hasWatchedAd = false))
|
|
||||||
signStateList.add(DailySignDayInfoBean(hasSigned = false, hasWatchedAd = false))
|
|
||||||
}
|
|
||||||
|
|
||||||
SpUtil.instance().putObject(SpUtil.KEY_TASK_BEAN, mDailySignData)
|
|
||||||
AccountManager.saveBankAccount(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getForgotSignDays(): Int {
|
|
||||||
var forgotSignDays = 0
|
|
||||||
val curDayIndex = getCurDayIndexOfDailyCheckIn()
|
|
||||||
mDailySignData.signStateList.forEachIndexed { index, item->
|
|
||||||
if (!item.hasSigned && index < curDayIndex) {
|
|
||||||
forgotSignDays++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return forgotSignDays
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getSignDaysTotal(): Int {
|
|
||||||
var signDays = 0
|
|
||||||
mDailySignData.signStateList.forEachIndexed { index, item->
|
|
||||||
if (item.hasSigned) {
|
|
||||||
signDays++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return signDays
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getForgotSignFirstDayIndex(): Int {
|
|
||||||
val curDayIndex = getCurDayIndexOfDailyCheckIn()
|
|
||||||
mDailySignData.signStateList.forEachIndexed { index, item->
|
|
||||||
if (!item.hasSigned && index < curDayIndex) {
|
|
||||||
return index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun getDayStateList(): List<DailySignDayInfoBean> {
|
|
||||||
return mDailySignData.signStateList
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getRewardNumOfDailySign(dayIndex: Int) : Int {
|
|
||||||
return getDailyCheckInTask()?.reward_details?.get(dayIndex)?.value ?: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isDailySignAllOperationDone(): Boolean {
|
|
||||||
val curDayState = getDailySignStateBean(mCurDayIndexDailySign)
|
|
||||||
return curDayState.hasSigned && curDayState.hasWatchedAd && getForgotSignFirstDayIndex() <= 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.gamedog.vididin.manager.helpers
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.DateUtil
|
||||||
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
|
import com.gamedog.vididin.main.fragments.task.Task
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseDailyTaskState
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_CLAIMED
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_FINISH
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_ONGOING
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateWatchVideo
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateWatchAd
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
abstract class BaseDailyTaskHelper<T : BaseDailyTaskState> : BaseTaskHelper<T, Task>() {
|
||||||
|
|
||||||
|
abstract protected fun notifyEvents()
|
||||||
|
abstract protected fun generateTodayTask()
|
||||||
|
|
||||||
|
fun claimSubTaskReward(subTaskIndex: Int) : Boolean {
|
||||||
|
if (subTaskIndex >= 0 && subTaskIndex < mStateBean.getSubTaskRewardState().size) {
|
||||||
|
try {
|
||||||
|
val subTask = mStateBean.getSubTaskRewardState()[subTaskIndex]
|
||||||
|
if (subTask.state == STATE_FINISH) {
|
||||||
|
AccountManager.addGold(subTask.mRewardNum)
|
||||||
|
subTask.state = STATE_CLAIMED
|
||||||
|
saveState2Sp()
|
||||||
|
notifyEvents()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDateChanged() {
|
||||||
|
super.onDateChanged()
|
||||||
|
generateTodayTask()
|
||||||
|
notifyEvents()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected fun calculateNewState() {
|
||||||
|
val todayWatchedCount = mStateBean.getTodayWatchedCount()
|
||||||
|
|
||||||
|
mStateBean.getSubTaskRewardState().forEachIndexed { index, subTaskState ->
|
||||||
|
val targetCount = subTaskState.mTargetAdCount
|
||||||
|
when(subTaskState.state) {
|
||||||
|
STATE_ONGOING -> {
|
||||||
|
if (todayWatchedCount >= targetCount) {
|
||||||
|
subTaskState.state = STATE_FINISH
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected fun isTodayStatusBean(stateBean: TaskStateWatchAd): Boolean {
|
||||||
|
return DateUtil.isToday(stateBean.todayMs)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun isTodayStatusBean(stateBean: TaskStateWatchVideo): Boolean {
|
||||||
|
return DateUtil.isToday(stateBean.todayMs)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.gamedog.vididin.manager.helpers
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.SpUtil
|
||||||
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
|
abstract class BaseTaskHelper<T: Any, C: Any> {
|
||||||
|
abstract val mSpKey: String
|
||||||
|
protected lateinit var mStateBean: T
|
||||||
|
protected lateinit var mTaskConfig: C
|
||||||
|
private var mEventCallback: NotifyMan.ICallback? = null
|
||||||
|
|
||||||
|
abstract fun loadTaskFromSp()
|
||||||
|
|
||||||
|
suspend fun setConfigDatas(taskConfig: C) {
|
||||||
|
mTaskConfig = taskConfig
|
||||||
|
|
||||||
|
return withContext(Dispatchers.IO) {
|
||||||
|
loadTaskFromSp()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun onDateChanged() {
|
||||||
|
// TODO - sub class override this methods if daily task
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected fun registerEvents(onEvents: ((NotifyMan.NotifyData<*>?)->Unit), vararg eventTypes: Int) {
|
||||||
|
if (mEventCallback == null) {
|
||||||
|
mEventCallback = object : NotifyMan.ICallback(true) {
|
||||||
|
override fun onEvent(data: NotifyMan.NotifyData<*>?) {
|
||||||
|
onEvents.invoke(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NotifyMan.instance().register(mEventCallback, *eventTypes)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun saveState2Sp() {
|
||||||
|
SpUtil.instance().putObject(mSpKey, mStateBean)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getStatusBean() : T {
|
||||||
|
return mStateBean
|
||||||
|
}
|
||||||
|
|
||||||
|
fun release() {
|
||||||
|
NotifyMan.instance().unregister(mEventCallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,287 @@
|
||||||
|
package com.gamedog.vididin.manager.helpers
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.DateUtil
|
||||||
|
import com.ama.core.architecture.util.SpUtil
|
||||||
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.gamedog.vididin.R
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
|
import com.gamedog.vididin.main.fragments.task.BoxTaskRoot
|
||||||
|
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_ZERO_BUY
|
||||||
|
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_SIGN
|
||||||
|
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_AD
|
||||||
|
import com.gamedog.vididin.manager.TaskManager.Companion.BOX_SUB_TASK_TYPE_VIDEO
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateBox
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateBoxRoot
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateBoxSub
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_FINISH
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_ONGOING
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_CLAIMED
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_EXPIRED
|
||||||
|
|
||||||
|
|
||||||
|
class BoxTaskHelper: BaseTaskHelper<TaskStateBoxRoot, BoxTaskRoot>() {
|
||||||
|
|
||||||
|
override val mSpKey = SpUtil.KEY_TASK_BOX
|
||||||
|
|
||||||
|
init {
|
||||||
|
registerEvents( { eventData->
|
||||||
|
when (eventData?.mEventType) {
|
||||||
|
VididinEvents.Event_Finish_One_Ad -> {
|
||||||
|
handleEvents(BOX_SUB_TASK_TYPE_AD)
|
||||||
|
}
|
||||||
|
|
||||||
|
VididinEvents.Event_Finish_One_Video -> {
|
||||||
|
handleEvents(BOX_SUB_TASK_TYPE_VIDEO)
|
||||||
|
}
|
||||||
|
|
||||||
|
VididinEvents.Event_Finish_One_Sign -> {
|
||||||
|
handleEvents(BOX_SUB_TASK_TYPE_SIGN)
|
||||||
|
}
|
||||||
|
|
||||||
|
VididinEvents.Event_Finish_One_Zerobuy -> {
|
||||||
|
handleEvents(BOX_SUB_TASK_TYPE_ZERO_BUY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, VididinEvents.Event_Finish_One_Ad, VididinEvents.Event_Finish_One_Video,
|
||||||
|
VididinEvents.Event_Finish_One_Sign, VididinEvents.Event_Finish_One_Zerobuy)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun loadTaskFromSp() {
|
||||||
|
val taskStateBeanInSp = SpUtil.instance().getObject<TaskStateBoxRoot>(mSpKey)
|
||||||
|
if (taskStateBeanInSp == null || isBoxRootTaskExpired(taskStateBeanInSp)) {
|
||||||
|
mStateBean = generateStateBeanFromConfig()
|
||||||
|
saveState2Sp()
|
||||||
|
} else {
|
||||||
|
mStateBean = taskStateBeanInSp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun generateStateBeanFromConfig(): TaskStateBoxRoot {
|
||||||
|
val boxStateList = mutableListOf<TaskStateBox>()
|
||||||
|
mTaskConfig.chests.forEachIndexed { index, task ->
|
||||||
|
val boxSubTaskStateList = mutableListOf<TaskStateBoxSub>()
|
||||||
|
task.tasks.forEachIndexed { index, task ->
|
||||||
|
boxSubTaskStateList.add(TaskStateBoxSub(task.task_id,
|
||||||
|
task.task_name, task.required_count, task.task_type))
|
||||||
|
}
|
||||||
|
|
||||||
|
boxStateList.add(TaskStateBox(task.chest_id, task.chest_name, task.duration_days,
|
||||||
|
task.reward_type, task.reward_value, task.is_one_time, task.status, boxSubTaskStateList))
|
||||||
|
}
|
||||||
|
|
||||||
|
return TaskStateBoxRoot(DateUtil.getTodayStartTimeMs(), boxStateList)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
private fun handleEvents(taskType: Int) {
|
||||||
|
val currentBoxIndex = getCurrentBoxIndex()
|
||||||
|
if (!isBoxAllFinished(currentBoxIndex)) {
|
||||||
|
getCurrentBoxState()?.tasks?.forEachIndexed { index, subTask->
|
||||||
|
if (taskType == subTask.task_type
|
||||||
|
&& !isBoxSubTaskFinished(currentBoxIndex, index)) {
|
||||||
|
subTask.finishedNum++
|
||||||
|
saveState2Sp()
|
||||||
|
|
||||||
|
notifyEvent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun notifyEvent() {
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.EVENT_BOX_TASK_STATE_CHANGED, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun isBoxRootTaskExpired(taskStateBoxRoot: TaskStateBoxRoot): Boolean {
|
||||||
|
var totalDurationDays = 0
|
||||||
|
taskStateBoxRoot.tasks.forEach {
|
||||||
|
totalDurationDays += it.duration_days
|
||||||
|
}
|
||||||
|
return DateUtil.isPeriodExpired(taskStateBoxRoot.startMs, totalDurationDays)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isBoxTaskExpired(boxIndex: Int): Boolean {
|
||||||
|
if (boxIndex >= 0 && boxIndex < mStateBean.tasks.size) {
|
||||||
|
val curBoxState = mStateBean.tasks[boxIndex]
|
||||||
|
return DateUtil.isPeriodExpired(mStateBean.startMs, curBoxState.duration_days)
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isBoxAllTasksFinish(boxIndex: Int) : Boolean {
|
||||||
|
if (boxIndex >= 0 && boxIndex < mStateBean.tasks.size) {
|
||||||
|
val curBoxState = mStateBean.tasks[boxIndex]
|
||||||
|
|
||||||
|
curBoxState.tasks.forEach {
|
||||||
|
if (it.required_count > it.finishedNum) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCurrentBoxIndex(): Int {
|
||||||
|
val boxRootStartMs = mStateBean.startMs
|
||||||
|
|
||||||
|
mStateBean.tasks.forEachIndexed { index, box ->
|
||||||
|
if (!DateUtil.isPeriodExpired(boxRootStartMs, box.duration_days)) {
|
||||||
|
return index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCurrentBoxState(): TaskStateBox? {
|
||||||
|
val currentBoxIndex = getCurrentBoxIndex()
|
||||||
|
|
||||||
|
if (currentBoxIndex >= 0 && currentBoxIndex < mStateBean.tasks.size) {
|
||||||
|
return mStateBean.tasks[currentBoxIndex]
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isBoxAllFinished(boxIndex: Int) : Boolean {
|
||||||
|
val stateEnum = getBoxStateEnum(boxIndex)
|
||||||
|
return stateEnum == STATE_FINISH || stateEnum == STATE_CLAIMED
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isBoxSubTaskFinished(boxIndex: Int, subTaskIndex: Int) : Boolean {
|
||||||
|
val subTaskState = mStateBean.tasks[boxIndex].tasks[subTaskIndex]
|
||||||
|
return subTaskState.finishedNum >= subTaskState.required_count
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBoxStateEnum(boxIndex: Int): Int {
|
||||||
|
if (boxIndex >= 0 && boxIndex < mStateBean.tasks.size) {
|
||||||
|
val curBoxState = mStateBean.tasks[boxIndex]
|
||||||
|
|
||||||
|
if (curBoxState.hasClaimedReward) {
|
||||||
|
return STATE_CLAIMED
|
||||||
|
} else {
|
||||||
|
if (isBoxAllTasksFinish(boxIndex)) {
|
||||||
|
return STATE_FINISH
|
||||||
|
} else {
|
||||||
|
if (isBoxTaskExpired(boxIndex)) {
|
||||||
|
return STATE_EXPIRED
|
||||||
|
} else {
|
||||||
|
return STATE_ONGOING
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCouldClaimCashNum(): Float {
|
||||||
|
var waitClaimCashNum = 0F
|
||||||
|
mStateBean.tasks.forEachIndexed { index, box ->
|
||||||
|
if (getBoxStateEnum(index) == STATE_FINISH) {
|
||||||
|
waitClaimCashNum += box.reward_value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return waitClaimCashNum
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSubTaskHintStrRes(boxIndex: Int, subTaskIndex: Int): Int {
|
||||||
|
when (boxIndex) {
|
||||||
|
0-> {
|
||||||
|
when (subTaskIndex) {
|
||||||
|
0-> {
|
||||||
|
return R.string.box_subtask_hint_1_1
|
||||||
|
}
|
||||||
|
|
||||||
|
1-> {
|
||||||
|
return R.string.box_subtask_hint_1_2
|
||||||
|
}
|
||||||
|
|
||||||
|
2-> {
|
||||||
|
return R.string.box_subtask_hint_1_3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1-> {
|
||||||
|
when (subTaskIndex) {
|
||||||
|
0-> {
|
||||||
|
return R.string.box_subtask_hint_2_1
|
||||||
|
}
|
||||||
|
|
||||||
|
1-> {
|
||||||
|
return R.string.box_subtask_hint_2_2
|
||||||
|
}
|
||||||
|
|
||||||
|
2-> {
|
||||||
|
return R.string.box_subtask_hint_2_3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
2-> {
|
||||||
|
when (subTaskIndex) {
|
||||||
|
0-> {
|
||||||
|
return R.string.box_subtask_hint_3_1
|
||||||
|
}
|
||||||
|
|
||||||
|
1-> {
|
||||||
|
return R.string.box_subtask_hint_3_2
|
||||||
|
}
|
||||||
|
|
||||||
|
2-> {
|
||||||
|
return R.string.box_subtask_hint_3_3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCurrentBoxTotalProgress(): Int {
|
||||||
|
val currentBoxIndex = getCurrentBoxIndex()
|
||||||
|
val boxList = mStateBean.tasks
|
||||||
|
if (currentBoxIndex >= 0 && currentBoxIndex < boxList.size) {
|
||||||
|
var totalFinished = 0
|
||||||
|
var totalRequired = 0
|
||||||
|
val currentBox = boxList[currentBoxIndex]
|
||||||
|
|
||||||
|
currentBox.tasks.forEach {
|
||||||
|
totalFinished += it.finishedNum
|
||||||
|
totalRequired += it.required_count
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalRequired > 0) {
|
||||||
|
val totalProgress = (100 * totalFinished) / totalRequired
|
||||||
|
return if (totalProgress > 100) 100 else totalProgress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun executeClaimCash(): Boolean {
|
||||||
|
try {
|
||||||
|
val couldClaimCashNum = getCouldClaimCashNum()
|
||||||
|
if (couldClaimCashNum > 0F) {
|
||||||
|
AccountManager.addCash(couldClaimCashNum)
|
||||||
|
mStateBean.tasks.forEachIndexed { index, box ->
|
||||||
|
if (getBoxStateEnum(index) == STATE_FINISH) {
|
||||||
|
box.hasClaimedReward = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
saveState2Sp()
|
||||||
|
notifyEvent()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,135 @@
|
||||||
|
package com.gamedog.vididin.manager.helpers
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.DateUtil
|
||||||
|
import com.ama.core.architecture.util.SpUtil
|
||||||
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
|
import com.gamedog.vididin.main.fragments.task.Task
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskDailySignBean
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.DailySignDayInfoBean
|
||||||
|
|
||||||
|
|
||||||
|
class DailySignTaskHelper : BaseTaskHelper<TaskDailySignBean, Task>() {
|
||||||
|
private var mCurDayIndexDailySign: Int = 0
|
||||||
|
override val mSpKey = SpUtil.KEY_TASK_BEAN
|
||||||
|
|
||||||
|
|
||||||
|
override fun loadTaskFromSp() {
|
||||||
|
val taskStateBeanInSp = SpUtil.instance().getObject<TaskDailySignBean>(mSpKey)
|
||||||
|
if (taskStateBeanInSp == null) {
|
||||||
|
mStateBean = TaskDailySignBean()
|
||||||
|
saveState2Sp()
|
||||||
|
} else {
|
||||||
|
mStateBean = taskStateBeanInSp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCurDayIndexOfDailyCheckIn() : Int {
|
||||||
|
var dayIndexOfPeriod = 0
|
||||||
|
|
||||||
|
val periodStartMs = mStateBean.startDurationMs
|
||||||
|
if (periodStartMs > 0) {
|
||||||
|
dayIndexOfPeriod = DateUtil.getPassedDayNum(periodStartMs, DateUtil.getCurTimeMs())
|
||||||
|
if (dayIndexOfPeriod > 6) {
|
||||||
|
mStateBean?.startDurationMs = DateUtil.getCurTimeMs()
|
||||||
|
saveState2Sp()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mStateBean?.startDurationMs = DateUtil.getCurTimeMs()
|
||||||
|
saveState2Sp()
|
||||||
|
}
|
||||||
|
|
||||||
|
mCurDayIndexDailySign = dayIndexOfPeriod
|
||||||
|
return dayIndexOfPeriod
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDailySignStateBean(dayIndex: Int): DailySignDayInfoBean {
|
||||||
|
return mStateBean.signStateList[dayIndex]
|
||||||
|
}
|
||||||
|
|
||||||
|
fun executeDailySign(dayIndex: Int, isDoubleReward: Boolean, isByAd: Boolean) : Boolean {
|
||||||
|
val daySignState = mStateBean.signStateList[dayIndex]
|
||||||
|
|
||||||
|
if (!daySignState.hasSigned || (dayIndex == mCurDayIndexDailySign && !daySignState.hasWatchedAd)) {
|
||||||
|
val dayReward = getRewardNumOfDailySign(dayIndex)
|
||||||
|
val finalReward = if (isDoubleReward) 2*dayReward else dayReward
|
||||||
|
daySignState.hasRewardedNum += finalReward
|
||||||
|
daySignState.hasSigned = true
|
||||||
|
daySignState.hasWatchedAd = isByAd
|
||||||
|
saveState2Sp()
|
||||||
|
AccountManager.addGold(finalReward)
|
||||||
|
notifySignStateChanged(Pair(dayIndex, daySignState))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun notifySignStateChanged(dataPair: Pair<Int, DailySignDayInfoBean>) {
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.Event_Sign_State_Changed, NotifyMan.NotifyData(dataPair))
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.Event_Finish_One_Sign, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun generateTestDailySignTestBean() {
|
||||||
|
mStateBean = TaskDailySignBean().apply {
|
||||||
|
startDurationMs = DateUtil.getCurTimeMs() - 4 * DateUtil.MS_NUM_ONE_DAY
|
||||||
|
signStateList.clear()
|
||||||
|
signStateList.add(DailySignDayInfoBean(hasSigned = true, hasWatchedAd = true))
|
||||||
|
signStateList.add(DailySignDayInfoBean(hasSigned = false, hasWatchedAd = false))
|
||||||
|
signStateList.add(DailySignDayInfoBean(hasSigned = true, hasWatchedAd = false))
|
||||||
|
signStateList.add(DailySignDayInfoBean(hasSigned = false, hasWatchedAd = false))
|
||||||
|
signStateList.add(DailySignDayInfoBean(hasSigned = false, hasWatchedAd = false))
|
||||||
|
signStateList.add(DailySignDayInfoBean(hasSigned = false, hasWatchedAd = false))
|
||||||
|
signStateList.add(DailySignDayInfoBean(hasSigned = false, hasWatchedAd = false))
|
||||||
|
}
|
||||||
|
|
||||||
|
saveState2Sp()
|
||||||
|
AccountManager.saveBankAccount(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getForgotSignDays(): Int {
|
||||||
|
var forgotSignDays = 0
|
||||||
|
val curDayIndex = getCurDayIndexOfDailyCheckIn()
|
||||||
|
mStateBean.signStateList.forEachIndexed { index, item->
|
||||||
|
if (!item.hasSigned && index < curDayIndex) {
|
||||||
|
forgotSignDays++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return forgotSignDays
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSignDaysTotal(): Int {
|
||||||
|
var signDays = 0
|
||||||
|
mStateBean.signStateList.forEachIndexed { index, item->
|
||||||
|
if (item.hasSigned) {
|
||||||
|
signDays++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return signDays
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getForgotSignFirstDayIndex(): Int {
|
||||||
|
val curDayIndex = getCurDayIndexOfDailyCheckIn()
|
||||||
|
mStateBean.signStateList.forEachIndexed { index, item->
|
||||||
|
if (!item.hasSigned && index < curDayIndex) {
|
||||||
|
return index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun getDayStateList(): List<DailySignDayInfoBean> {
|
||||||
|
return mStateBean.signStateList
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getRewardNumOfDailySign(dayIndex: Int) : Int {
|
||||||
|
return mTaskConfig.reward_details[dayIndex].value
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isDailySignAllOperationDone(): Boolean {
|
||||||
|
val curDayState = getDailySignStateBean(mCurDayIndexDailySign)
|
||||||
|
return curDayState.hasSigned && curDayState.hasWatchedAd && getForgotSignFirstDayIndex() <= 0
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.gamedog.vididin.manager.helpers
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.DateUtil
|
||||||
|
import com.ama.core.architecture.util.SpUtil
|
||||||
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateWatchAd
|
||||||
|
|
||||||
|
|
||||||
|
class DailyWatchAdTaskHelper : BaseDailyTaskHelper<TaskStateWatchAd>() {
|
||||||
|
|
||||||
|
override val mSpKey = SpUtil.KEY_DAILY_WATCH_AD_FOR_GOLD
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
registerEvents( { eventData->
|
||||||
|
val watchedAdNum: Int = eventData?.mData as Int
|
||||||
|
handleOneAdWatched(watchedAdNum)
|
||||||
|
}, VididinEvents.Event_Finish_One_Ad)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun loadTaskFromSp() {
|
||||||
|
val spStateBean = SpUtil.instance().getObject<TaskStateWatchAd>(mSpKey)
|
||||||
|
if (spStateBean == null || !isTodayStatusBean(spStateBean)) {
|
||||||
|
generateTodayTask()
|
||||||
|
} else {
|
||||||
|
mStateBean = spStateBean
|
||||||
|
notifyEvents()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun generateTodayTask() {
|
||||||
|
mStateBean = TaskStateWatchAd(DateUtil.getCurTimeMs())
|
||||||
|
mStateBean.initSubTaskRewardList(mTaskConfig.reward_details)
|
||||||
|
saveState2Sp()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun notifyEvents() {
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.EVENT_DAILY_WATCHED_AD_NUM_CHANGED, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleOneAdWatched(newAdWatchedNum: Int) {
|
||||||
|
mStateBean.run {
|
||||||
|
if (!isAllTaskFinish()) {
|
||||||
|
addWatchedCount(newAdWatchedNum)
|
||||||
|
calculateNewState()
|
||||||
|
saveState2Sp()
|
||||||
|
notifyEvents()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.gamedog.vididin.manager.helpers
|
||||||
|
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.DateUtil
|
||||||
|
import com.ama.core.architecture.util.SpUtil
|
||||||
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateWatchAd
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateWatchVideo
|
||||||
|
|
||||||
|
|
||||||
|
class DailyWatchVideoTaskHelper : BaseDailyTaskHelper<TaskStateWatchVideo>() {
|
||||||
|
|
||||||
|
override val mSpKey = SpUtil.KEY_DAILY_WATCH_VIDEO
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
registerEvents( { eventData->
|
||||||
|
val dataPair: Pair<String, Long> = eventData?.mData as Pair<String, Long>
|
||||||
|
handleOneVideoWatched(dataPair)
|
||||||
|
}, VididinEvents.Event_Finish_One_Video)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun loadTaskFromSp() {
|
||||||
|
val spStateBean = SpUtil.instance().getObject<TaskStateWatchVideo>(mSpKey)
|
||||||
|
if (spStateBean == null || !isTodayStatusBean(spStateBean)) {
|
||||||
|
generateTodayTask()
|
||||||
|
} else {
|
||||||
|
mStateBean = spStateBean
|
||||||
|
notifyEvents()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun generateTodayTask() {
|
||||||
|
mStateBean = TaskStateWatchVideo(DateUtil.getCurTimeMs())
|
||||||
|
mStateBean.initSubTaskRewardList(mTaskConfig.reward_details)
|
||||||
|
saveState2Sp()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun notifyEvents() {
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.EVENT_DAILY_WATCHED_VIDEO_NUM_CHANGED, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun handleOneVideoWatched(dataPair: Pair<String, Long>) {
|
||||||
|
mStateBean.run {
|
||||||
|
if (!isAllTaskFinish()) {
|
||||||
|
if (addWatchedVideoInfo(dataPair)) {
|
||||||
|
calculateNewState()
|
||||||
|
saveState2Sp()
|
||||||
|
notifyEvents()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.gamedog.vididin.manager.helpers
|
||||||
|
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.SpUtil
|
||||||
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
|
import com.gamedog.vididin.main.fragments.task.Task
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateNewBieEnableNotify
|
||||||
|
|
||||||
|
class NewbieEnableNotifyHelper: BaseTaskHelper<TaskStateNewBieEnableNotify, Task>() {
|
||||||
|
|
||||||
|
override val mSpKey = SpUtil.KEY_NEWBIE_ENABLE_NOTIFY
|
||||||
|
|
||||||
|
|
||||||
|
override fun loadTaskFromSp() {
|
||||||
|
val taskStateBeanInSp = SpUtil.instance().getObject<TaskStateNewBieEnableNotify>(mSpKey)
|
||||||
|
if (taskStateBeanInSp == null) {
|
||||||
|
mStateBean = generateStateBeanFromConfig()
|
||||||
|
saveState2Sp()
|
||||||
|
} else {
|
||||||
|
mStateBean = taskStateBeanInSp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun generateStateBeanFromConfig(): TaskStateNewBieEnableNotify {
|
||||||
|
return TaskStateNewBieEnableNotify(mTaskConfig.reward_value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun claimReward() : Boolean {
|
||||||
|
if (!mStateBean.hasClaimReward) {
|
||||||
|
AccountManager.addGold(mStateBean.rewardGoldNum)
|
||||||
|
mStateBean.hasClaimReward = true
|
||||||
|
saveState2Sp()
|
||||||
|
notifyStateChangeEvent()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun notifyStateChangeEvent() {
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.EVENT_NEWBIE_NOTIFY_TASK_CHANGED, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.gamedog.vididin.manager.helpers
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.SpUtil
|
||||||
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
|
import com.gamedog.vididin.main.fragments.task.Task
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateNewBieFirstWithDraw
|
||||||
|
|
||||||
|
class NewbieFirstWithdrawHelper: BaseTaskHelper<TaskStateNewBieFirstWithDraw, Task>() {
|
||||||
|
|
||||||
|
override val mSpKey = SpUtil.KEY_NEWBIE_FIRST_WITHDRAW
|
||||||
|
|
||||||
|
override fun loadTaskFromSp() {
|
||||||
|
val taskStateBeanInSp = SpUtil.instance().getObject<TaskStateNewBieFirstWithDraw>(mSpKey)
|
||||||
|
if (taskStateBeanInSp == null) {
|
||||||
|
mStateBean = generateStateBeanFromConfig()
|
||||||
|
saveState2Sp()
|
||||||
|
} else {
|
||||||
|
mStateBean = taskStateBeanInSp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun generateStateBeanFromConfig(): TaskStateNewBieFirstWithDraw {
|
||||||
|
return TaskStateNewBieFirstWithDraw(mTaskConfig.reward_value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun claimReward(): Boolean {
|
||||||
|
if (!mStateBean.hasClaimReward) {
|
||||||
|
AccountManager.addGold(mStateBean.rewardGoldNum)
|
||||||
|
mStateBean.hasClaimReward = true
|
||||||
|
saveState2Sp()
|
||||||
|
notifyStateChangeEvent()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun notifyStateChangeEvent() {
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.EVENT_NEWBIE_FIRST_WITHDRAW_TASK_CHANGED, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.gamedog.vididin.manager.helpers
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.SpUtil
|
||||||
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
|
import com.gamedog.vididin.core.login.login.AccountManager
|
||||||
|
import com.gamedog.vididin.main.fragments.task.Task
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.TaskStateNewBieJoinDiscord
|
||||||
|
|
||||||
|
class NewbieJoinDiscordHelper: BaseTaskHelper<TaskStateNewBieJoinDiscord, Task>() {
|
||||||
|
|
||||||
|
override val mSpKey = SpUtil.KEY_NEWBIE_JOIN_DISCORD
|
||||||
|
|
||||||
|
override fun loadTaskFromSp() {
|
||||||
|
val taskStateBeanInSp = SpUtil.instance().getObject<TaskStateNewBieJoinDiscord>(mSpKey)
|
||||||
|
if (taskStateBeanInSp == null) {
|
||||||
|
mStateBean = generateStateBeanFromConfig()
|
||||||
|
saveState2Sp()
|
||||||
|
} else {
|
||||||
|
mStateBean = taskStateBeanInSp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun generateStateBeanFromConfig(): TaskStateNewBieJoinDiscord {
|
||||||
|
return TaskStateNewBieJoinDiscord(mTaskConfig.reward_value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun claimReward() : Boolean {
|
||||||
|
if (!mStateBean.hasClaimReward) {
|
||||||
|
AccountManager.addGold(mStateBean.rewardGoldNum)
|
||||||
|
mStateBean.hasClaimReward = true
|
||||||
|
saveState2Sp()
|
||||||
|
notifyStateChangeEvent()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun notifyStateChangeEvent() {
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.EVENT_NEWBIE_DISCORD_TASK_CHANGED, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.gamedog.vididin.manager.taskbeans
|
||||||
|
|
||||||
|
import com.gamedog.vididin.main.fragments.task.RewardDetail
|
||||||
|
import com.gamedog.vididin.manager.taskbeans.BaseTaskState.Companion.STATE_ONGOING
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlin.collections.forEach
|
||||||
|
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
abstract class BaseDailyTaskState : BaseTaskState() {
|
||||||
|
protected val mSubTaskRewardState: MutableList<SubDailyTaskBean> = mutableListOf()
|
||||||
|
|
||||||
|
abstract fun getTodayWatchedCount(): Int
|
||||||
|
abstract fun addWatchedCount(newWatchedNum: Int)
|
||||||
|
abstract fun addWatchedVideoInfo(dataPair: Pair<String, Long>): Boolean
|
||||||
|
|
||||||
|
|
||||||
|
fun getSubTaskRewardState(): List<SubDailyTaskBean> {
|
||||||
|
return mSubTaskRewardState
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isAllTaskFinish(): Boolean {
|
||||||
|
return mSubTaskRewardState.all { it.state >= STATE_CLAIMED }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun initSubTaskRewardList(subTasks: List<RewardDetail>) {
|
||||||
|
mSubTaskRewardState.clear()
|
||||||
|
|
||||||
|
subTasks.forEach {
|
||||||
|
mSubTaskRewardState.add(SubDailyTaskBean(it.value, it.target_count, STATE_ONGOING))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data class SubDailyTaskBean(
|
||||||
|
val mRewardNum: Int,
|
||||||
|
val mTargetAdCount: Int,
|
||||||
|
var state: Int = STATE_ONGOING,)
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.gamedog.vididin.manager.taskbeans
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
abstract class BaseTaskState {
|
||||||
|
companion object {
|
||||||
|
const val STATE_ONGOING = 0
|
||||||
|
const val STATE_FINISH = 1
|
||||||
|
const val STATE_CLAIMED = 2
|
||||||
|
const val STATE_EXPIRED = 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,22 +1,12 @@
|
||||||
package com.gamedog.vididin.manager
|
package com.gamedog.vididin.manager.taskbeans
|
||||||
|
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
|
|
||||||
|
data class TaskDailySignBean(
|
||||||
|
var startDurationMs: Long = 0,
|
||||||
data class DailySignBean(
|
|
||||||
var startMs: Long = 0,
|
|
||||||
val signStateList: MutableList<DailySignDayInfoBean> = mutableListOf()
|
val signStateList: MutableList<DailySignDayInfoBean> = mutableListOf()
|
||||||
|
): BaseTaskState() {
|
||||||
): Serializable {
|
|
||||||
companion object{
|
|
||||||
const val SIGN_STATE_ENABLE = 1
|
|
||||||
const val SIGN_STATE_DISABLE = 2
|
|
||||||
const val SIGN_STATE_DONE = 3
|
|
||||||
const val SIGN_STATE_FORGOT = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
signStateList.add(DailySignDayInfoBean())
|
signStateList.add(DailySignDayInfoBean())
|
||||||
signStateList.add(DailySignDayInfoBean())
|
signStateList.add(DailySignDayInfoBean())
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.gamedog.vididin.manager.taskbeans
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data class TaskStateBoxRoot(
|
||||||
|
val startMs: Long = 0,
|
||||||
|
val tasks: List<TaskStateBox>
|
||||||
|
): Serializable
|
||||||
|
|
||||||
|
data class TaskStateBox(
|
||||||
|
val chest_id: String,
|
||||||
|
val chest_name: String,
|
||||||
|
val duration_days: Int,
|
||||||
|
val reward_type: String,
|
||||||
|
val reward_value: Float,
|
||||||
|
val is_one_time: Boolean,
|
||||||
|
val status: String,
|
||||||
|
val tasks: List<TaskStateBoxSub>,
|
||||||
|
|
||||||
|
// new added
|
||||||
|
var hasClaimedReward: Boolean = false,
|
||||||
|
): Serializable
|
||||||
|
|
||||||
|
data class TaskStateBoxSub(
|
||||||
|
val task_id: String,
|
||||||
|
val task_name: String,
|
||||||
|
val required_count: Int,
|
||||||
|
val task_type: Int, // This added by self for decide which task should be execute, detail see: #TaskManager.companion
|
||||||
|
|
||||||
|
// new added
|
||||||
|
var finishedNum: Int = 0,
|
||||||
|
): Serializable
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.gamedog.vididin.manager.taskbeans
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data class TaskStateNewBieEnableNotify(
|
||||||
|
var rewardGoldNum: Int,
|
||||||
|
var hasClaimReward: Boolean = false,
|
||||||
|
): Serializable {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.gamedog.vididin.manager.taskbeans
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data class TaskStateNewBieFirstWithDraw(
|
||||||
|
var rewardGoldNum: Int,
|
||||||
|
var hasClaimReward: Boolean = false,
|
||||||
|
): Serializable {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.gamedog.vididin.manager.taskbeans
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data class TaskStateNewBieJoinDiscord(
|
||||||
|
var rewardGoldNum: Int,
|
||||||
|
var hasClaimReward: Boolean = false,
|
||||||
|
): Serializable {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.gamedog.vididin.manager.taskbeans
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data class TaskStateWatchAd(
|
||||||
|
var todayMs: Long = 0,
|
||||||
|
): BaseDailyTaskState() {
|
||||||
|
private var mWatchAdCount: Int = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
override fun addWatchedCount(newWatchedNum: Int) {
|
||||||
|
if (newWatchedNum > 0) {
|
||||||
|
mWatchAdCount += newWatchedNum
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addWatchedVideoInfo(dataPair: Pair<String, Long>): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getTodayWatchedCount(): Int {
|
||||||
|
return mWatchAdCount
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.gamedog.vididin.manager.taskbeans
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
|
|
||||||
|
data class TaskStateWatchVideo(
|
||||||
|
var todayMs: Long = 0,
|
||||||
|
): BaseDailyTaskState() {
|
||||||
|
|
||||||
|
private val mWatchedMap = ConcurrentHashMap<String, Long>()
|
||||||
|
|
||||||
|
override fun addWatchedVideoInfo(dataPair: Pair<String, Long>): Boolean {
|
||||||
|
if (!mWatchedMap.contains(dataPair.first)) {
|
||||||
|
mWatchedMap.put(dataPair.first, dataPair.second)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addWatchedCount(newWatchedNum: Int) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getTodayWatchedCount(): Int {
|
||||||
|
return mWatchedMap.size
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.gamedog.vididin.netbase
|
||||||
|
|
||||||
|
import okhttp3.ResponseBody
|
||||||
|
import retrofit2.http.Body
|
||||||
|
import retrofit2.http.FieldMap
|
||||||
|
import retrofit2.http.FormUrlEncoded
|
||||||
|
import retrofit2.http.GET
|
||||||
|
import retrofit2.http.HeaderMap
|
||||||
|
import retrofit2.http.POST
|
||||||
|
import retrofit2.http.QueryMap
|
||||||
|
import retrofit2.http.Url
|
||||||
|
|
||||||
|
interface ApiService {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
suspend fun getRequest(
|
||||||
|
@Url url: String,
|
||||||
|
@HeaderMap headers: Map<String, String> = emptyMap(),
|
||||||
|
@QueryMap params: Map<String, String> = emptyMap()
|
||||||
|
): ResponseBody
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST
|
||||||
|
suspend fun postRequest(
|
||||||
|
@Url url: String,
|
||||||
|
@HeaderMap headers: Map<String, String> = emptyMap(),
|
||||||
|
@FieldMap params: Map<String, String> = emptyMap()
|
||||||
|
): ResponseBody
|
||||||
|
|
||||||
|
@POST
|
||||||
|
suspend fun postJsonRequest(
|
||||||
|
@Url url: String,
|
||||||
|
@HeaderMap headers: Map<String, String> = emptyMap(),
|
||||||
|
@Body body: Any
|
||||||
|
): ResponseBody
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.gamedog.vididin.netbase
|
||||||
|
|
||||||
|
import okhttp3.ResponseBody
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
object NetworkUtil {
|
||||||
|
|
||||||
|
private val apiService: ApiService by lazy {
|
||||||
|
RetrofitUtil.getRetrofitInstance().create(ApiService::class.java)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun get(
|
||||||
|
url: String,
|
||||||
|
headers: Map<String, String> = emptyMap(),
|
||||||
|
params: Map<String, String> = emptyMap()
|
||||||
|
): Result<ResponseBody> {
|
||||||
|
return executeRequest {
|
||||||
|
apiService.getRequest(url, headers, params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun post(
|
||||||
|
url: String,
|
||||||
|
headers: Map<String, String> = emptyMap(),
|
||||||
|
params: Map<String, String> = emptyMap()
|
||||||
|
): Result<ResponseBody> {
|
||||||
|
return executeRequest {
|
||||||
|
apiService.postRequest(url, headers, params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun postJson(
|
||||||
|
url: String,
|
||||||
|
body: Any,
|
||||||
|
headers: Map<String, String> = emptyMap()
|
||||||
|
): Result<ResponseBody> {
|
||||||
|
return executeRequest {
|
||||||
|
apiService.postJsonRequest(url, headers, body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private suspend fun <T> executeRequest(requestBlock: suspend () -> T): Result<T> {
|
||||||
|
return try {
|
||||||
|
Result.Success(requestBlock())
|
||||||
|
} catch (e: IOException) {
|
||||||
|
Result.Error(e, "网络连接失败,请检查网络设置")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Result.Error(e, "未知错误: ${e.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.gamedog.vididin.netbase
|
||||||
|
|
||||||
|
sealed class Result<out T> {
|
||||||
|
data class Success<out T>(val data: T) : Result<T>()
|
||||||
|
data class Error(val exception: Throwable, val message: String = exception.message ?: "Unknown error") : Result<Nothing>()
|
||||||
|
object Loading : Result<Nothing>()
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.gamedog.vididin.netbase
|
||||||
|
|
||||||
|
import com.gamedog.vididin.VidiConst
|
||||||
|
import com.gamedog.vididin.core.network.di.GlobalInterceptor
|
||||||
|
import com.gamedog.vididin.core.network.di.GlobalInterceptor2
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import retrofit2.Retrofit
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
object RetrofitUtil {
|
||||||
|
|
||||||
|
private var retrofit: Retrofit? = null
|
||||||
|
private const val DEFAULT_BASE_URL = VidiConst.URL_ZERO_BUY
|
||||||
|
|
||||||
|
|
||||||
|
fun getRetrofitInstance(baseUrl: String = DEFAULT_BASE_URL, headers: Map<String, String> = emptyMap()): Retrofit {
|
||||||
|
return retrofit ?: createRetrofit(baseUrl, headers).also { retrofit = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createRetrofit(baseUrl: String, headers: Map<String, String>): Retrofit {
|
||||||
|
val okHttpClient = OkHttpClient.Builder().apply {
|
||||||
|
// add request custom head
|
||||||
|
if (headers.isNotEmpty()) {
|
||||||
|
addInterceptor { chain ->
|
||||||
|
val originalRequest = chain.request()
|
||||||
|
val requestBuilder = originalRequest.newBuilder()
|
||||||
|
headers.forEach { (key, value) ->
|
||||||
|
requestBuilder.addHeader(key, value)
|
||||||
|
}
|
||||||
|
chain.proceed(requestBuilder.build())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO - only enable in debug mode
|
||||||
|
addInterceptor(GlobalInterceptor2())
|
||||||
|
|
||||||
|
connectTimeout(30, TimeUnit.SECONDS)
|
||||||
|
readTimeout(30, TimeUnit.SECONDS)
|
||||||
|
writeTimeout(30, TimeUnit.SECONDS)
|
||||||
|
}.build()
|
||||||
|
|
||||||
|
return Retrofit.Builder()
|
||||||
|
.baseUrl(baseUrl)
|
||||||
|
.client(okHttpClient)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.gamedog.vididin.request
|
||||||
|
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.DeviceUtil
|
||||||
|
import com.ama.core.architecture.util.MD5Util
|
||||||
|
import com.gamedog.vididin.VidiConst
|
||||||
|
|
||||||
|
class RequestUtil private constructor(){
|
||||||
|
companion object {
|
||||||
|
const val Request_APPId = "video1"
|
||||||
|
const val Request_Sceret = "secret1"
|
||||||
|
|
||||||
|
const val Request_ZeroBuy_APPId = "com.vididin.real.money.game"
|
||||||
|
|
||||||
|
fun getTimestampSec(): Long {
|
||||||
|
return System.currentTimeMillis()/1000
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getRequestSign(timeSec: Long): String {
|
||||||
|
val signOrigin = "$Request_APPId-${timeSec}-$Request_Sceret"
|
||||||
|
return MD5Util.md5(signOrigin)?:""
|
||||||
|
}
|
||||||
|
|
||||||
|
// applicationId-timestamp-deviceId-operation-secret
|
||||||
|
fun getZeroBuyRequestSign(timeSec: Long, operation: Int): String {
|
||||||
|
var signOrigin = "${VidiConst.ZEROBUY_APPID}-${timeSec}-${DeviceUtil.generateDeviceId()}-$operation-${VidiConst.ZEROBUY_SECRET}"
|
||||||
|
return MD5Util.md5(signOrigin)?:""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -39,7 +39,11 @@ object Router : RouterContract {
|
||||||
get() = routerEntryPoint.feedbackRouter()
|
get() = routerEntryPoint.feedbackRouter()
|
||||||
override val WithdrawRecord: IRouterWithdrawRecord
|
override val WithdrawRecord: IRouterWithdrawRecord
|
||||||
get() = routerEntryPoint.withdrawRecordRouter()
|
get() = routerEntryPoint.withdrawRecordRouter()
|
||||||
|
|
||||||
override val Splash: IRouterSplash
|
override val Splash: IRouterSplash
|
||||||
get() = routerEntryPoint.splashRouter()
|
get() = routerEntryPoint.splashRouter()
|
||||||
|
|
||||||
|
override val WatchAd: IRouterWatchAd
|
||||||
|
get() = routerEntryPoint.watchAdRouter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,5 +27,7 @@ interface RouterContract {
|
||||||
val Feedback: IRouterFeedback
|
val Feedback: IRouterFeedback
|
||||||
val WithdrawRecord: IRouterWithdrawRecord
|
val WithdrawRecord: IRouterWithdrawRecord
|
||||||
val Splash: IRouterSplash
|
val Splash: IRouterSplash
|
||||||
|
val WatchAd: IRouterWatchAd
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ import com.gamedog.vididin.features.feedback.FeedbackActivity
|
||||||
import com.gamedog.vididin.features.privacy.PrivacyActivity
|
import com.gamedog.vididin.features.privacy.PrivacyActivity
|
||||||
import com.gamedog.vididin.features.splash.SplashActivity
|
import com.gamedog.vididin.features.splash.SplashActivity
|
||||||
import com.gamedog.vididin.features.version.VersionActivity
|
import com.gamedog.vididin.features.version.VersionActivity
|
||||||
|
import com.gamedog.vididin.features.watchad.WatchAdActivity
|
||||||
import com.gamedog.vididin.features.withdrawrecord.WithdrawRecordActivity
|
import com.gamedog.vididin.features.withdrawrecord.WithdrawRecordActivity
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -38,3 +39,9 @@ class DefaultVersionRouter: IRouterVersion {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DefaultWatchAdRouter: IRouterWatchAd {
|
||||||
|
override fun startActivity(activity: Activity, taskType: Int, taskDataJson: String?) {
|
||||||
|
WatchAdActivity.Companion.startActivity(activity, taskType, taskDataJson)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,8 @@ interface IRouterSplash {
|
||||||
fun startActivity(activity: Activity)
|
fun startActivity(activity: Activity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IRouterWatchAd {
|
||||||
|
fun startActivity(activity: Activity, taskType: Int, taskDataJson: String?)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import com.ama.core.architecture.util.ResUtil
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
import com.gamedog.vididin.databinding.DailySignItemBinding
|
import com.gamedog.vididin.databinding.DailySignItemBinding
|
||||||
import com.gamedog.vididin.main.fragments.task.RewardDetail
|
import com.gamedog.vididin.main.fragments.task.RewardDetail
|
||||||
import com.gamedog.vididin.manager.DailySignDayInfoBean
|
import com.gamedog.vididin.manager.taskbeans.DailySignDayInfoBean
|
||||||
import kotlin.run
|
import kotlin.run
|
||||||
|
|
||||||
class DailySignItemView @JvmOverloads constructor(
|
class DailySignItemView @JvmOverloads constructor(
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import android.view.LayoutInflater
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.gamedog.vididin.databinding.LayoutDragIconViewBinding
|
import com.gamedog.vididin.databinding.LayoutDragIconViewBinding
|
||||||
import com.gamedog.vididin.manager.TaskManager
|
|
||||||
|
|
||||||
class HomeDragIconView @JvmOverloads constructor(
|
class HomeDragIconView @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
|
@ -24,45 +23,36 @@ class HomeDragIconView @JvmOverloads constructor(
|
||||||
init {
|
init {
|
||||||
mBinding = LayoutDragIconViewBinding.inflate(LayoutInflater.from(context), this, true)
|
mBinding = LayoutDragIconViewBinding.inflate(LayoutInflater.from(context), this, true)
|
||||||
mBinding.run {
|
mBinding.run {
|
||||||
progressBar.setProgressListener { progress->
|
|
||||||
if (progress >= 100) {
|
|
||||||
tvGoldNum.text = buildString {
|
|
||||||
append("+")
|
|
||||||
append(TaskManager.instance().getHomeWatchDurationRewardNum())
|
|
||||||
}
|
|
||||||
|
|
||||||
executeGoldNumAnim()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun executeGoldNumAnim() {
|
fun showRewardGoldAnim() {
|
||||||
val animView = mBinding.llGoldRoot
|
val animView = mBinding.llGoldRoot
|
||||||
|
|
||||||
val alphaAnimator = ObjectAnimator.ofFloat(
|
val alphaAnimator = ObjectAnimator.ofFloat(
|
||||||
animView,
|
animView,
|
||||||
"alpha",
|
"alpha",
|
||||||
0.5f, 1.0f, 0.5f
|
0.5f, 1.0f
|
||||||
).apply {
|
).apply {
|
||||||
duration = 500
|
duration = 1500
|
||||||
}
|
}
|
||||||
|
|
||||||
val scaleXAnimator = ObjectAnimator.ofFloat(
|
val scaleXAnimator = ObjectAnimator.ofFloat(
|
||||||
animView,
|
animView,
|
||||||
"scaleX",
|
"scaleX",
|
||||||
0.5f, 1.0f, 0.5f
|
0.5f, 1.1f, 1F
|
||||||
).apply {
|
).apply {
|
||||||
duration = 500
|
duration = 1500
|
||||||
}
|
}
|
||||||
|
|
||||||
val scaleYAnimator = ObjectAnimator.ofFloat(
|
val scaleYAnimator = ObjectAnimator.ofFloat(
|
||||||
animView,
|
animView,
|
||||||
"scaleY",
|
"scaleY",
|
||||||
0.5f, 1.0f, 0.5f
|
0.5f, 1.1f, 1F
|
||||||
).apply {
|
).apply {
|
||||||
duration = 500
|
duration = 1500
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -70,13 +60,15 @@ class HomeDragIconView @JvmOverloads constructor(
|
||||||
animatorSet.playTogether(alphaAnimator, scaleXAnimator, scaleYAnimator)
|
animatorSet.playTogether(alphaAnimator, scaleXAnimator, scaleYAnimator)
|
||||||
animatorSet.addListener(object : Animator.AnimatorListener {
|
animatorSet.addListener(object : Animator.AnimatorListener {
|
||||||
override fun onAnimationCancel(animation: Animator) {
|
override fun onAnimationCancel(animation: Animator) {
|
||||||
animView.isVisible = false
|
postDelayed({
|
||||||
mBinding.progressBar.setProgress(0)
|
animView.visibility = INVISIBLE
|
||||||
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAnimationEnd(animation: Animator) {
|
override fun onAnimationEnd(animation: Animator) {
|
||||||
animView.isVisible = false
|
postDelayed({
|
||||||
mBinding.progressBar.setProgress(0)
|
animView.visibility = INVISIBLE
|
||||||
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAnimationRepeat(animation: Animator) {
|
override fun onAnimationRepeat(animation: Animator) {
|
||||||
|
|
@ -84,12 +76,18 @@ class HomeDragIconView @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAnimationStart(animation: Animator) {
|
override fun onAnimationStart(animation: Animator) {
|
||||||
|
animView.isVisible = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
animatorSet.start()
|
animatorSet.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun setProgress(progress: Long) {
|
||||||
|
mBinding.progressBar.setProgress(progress.toInt())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.gamedog.vididin.youtubestatistic
|
||||||
|
|
||||||
|
class RewardConst {
|
||||||
|
companion object {
|
||||||
|
const val HOME_WATCH_DURATION = 5 * 1000L
|
||||||
|
const val HOME_WATCH_REWARD_NUM = 28
|
||||||
|
const val FINISH_RATIO = 0.05F // TODO - temp value, should be 0.8F
|
||||||
|
const val Check_Interval_MS = 50L
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,200 @@
|
||||||
|
package com.gamedog.vididin.youtubestatistic
|
||||||
|
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
|
import com.gamedog.vididin.VididinEvents
|
||||||
|
import com.gamedog.vididin.youtubestatistic.RewardConst.Companion.Check_Interval_MS
|
||||||
|
|
||||||
|
|
||||||
|
class TickerTimer() {
|
||||||
|
|
||||||
|
private var mTotalMs = 0L
|
||||||
|
private var mHasFinishCurVideo = false
|
||||||
|
private var mVideoId: String? = null
|
||||||
|
private var mVideoDurationMs: Long = 0
|
||||||
|
|
||||||
|
|
||||||
|
private val mCountHandler: Handler by lazy {
|
||||||
|
Handler(Looper.getMainLooper())
|
||||||
|
}
|
||||||
|
private val mCounterRunnable by lazy {
|
||||||
|
object : Runnable {
|
||||||
|
override fun run() {
|
||||||
|
if (isRunning) {
|
||||||
|
handleNewTick()
|
||||||
|
mCountHandler.postDelayed(this, Check_Interval_MS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
private var isRunning = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun setVideoInfo(videoId: String, videoDurationMs: Long) {
|
||||||
|
mVideoId = videoId
|
||||||
|
mVideoDurationMs = videoDurationMs
|
||||||
|
}
|
||||||
|
|
||||||
|
fun start() {
|
||||||
|
isRunning = true
|
||||||
|
mCountHandler.postDelayed(mCounterRunnable, Check_Interval_MS)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun handleNewTick() {
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.Event_HOME_WATCH_Time_TICK, null)
|
||||||
|
|
||||||
|
if (!mHasFinishCurVideo && mVideoDurationMs > 0L) {
|
||||||
|
mTotalMs += Check_Interval_MS
|
||||||
|
if (mTotalMs >= RewardConst.FINISH_RATIO * mVideoDurationMs) {
|
||||||
|
mHasFinishCurVideo = true
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.Event_Finish_One_Video,
|
||||||
|
NotifyMan.NotifyData(Pair(mVideoId, System.currentTimeMillis())))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun pause() {
|
||||||
|
if (!isRunning) return
|
||||||
|
isRunning = false
|
||||||
|
mCountHandler.removeCallbacks(mCounterRunnable)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun release() {
|
||||||
|
isRunning = false
|
||||||
|
mCounterRunnable.let { mCountHandler.removeCallbacks(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*private var mStartMs = 0L
|
||||||
|
private var mTotalMs = 0L
|
||||||
|
private var mHasFinishCurVideo = false
|
||||||
|
private var mVideoId: String? = null
|
||||||
|
private var mVideoDurationMs: Long = 0
|
||||||
|
|
||||||
|
|
||||||
|
private val mCountHandler: Handler by lazy {
|
||||||
|
Handler(Looper.getMainLooper())
|
||||||
|
}
|
||||||
|
private val mCounterRunnable by lazy {
|
||||||
|
object : Runnable {
|
||||||
|
override fun run() {
|
||||||
|
if (isRunning) {
|
||||||
|
if (mVideoDurationMs > 0L && mStartMs <= 0) {
|
||||||
|
mStartMs = SystemClock.elapsedRealtime()
|
||||||
|
}
|
||||||
|
|
||||||
|
handleNewTick()
|
||||||
|
mCountHandler.postDelayed(this, Check_Interval_MS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
private var isRunning = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun setVideoInfo(videoId: String, videoDurationMs: Long) {
|
||||||
|
mVideoId = videoId
|
||||||
|
mVideoDurationMs = videoDurationMs
|
||||||
|
}
|
||||||
|
|
||||||
|
fun start() {
|
||||||
|
isRunning = true
|
||||||
|
if (mVideoDurationMs > 0L && mStartMs <= 0) {
|
||||||
|
mStartMs = SystemClock.elapsedRealtime()
|
||||||
|
}
|
||||||
|
mCountHandler.postDelayed(mCounterRunnable, Check_Interval_MS)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun handleNewTick() {
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.Event_HOME_WATCH_Time_TICK, null)
|
||||||
|
|
||||||
|
if (!mHasFinishCurVideo && mStartMs > 0L && mVideoDurationMs > 0L) {
|
||||||
|
mTotalMs += (SystemClock.elapsedRealtime() - mStartMs)
|
||||||
|
if (mTotalMs >= RewardConst.FINISH_RATIO * mVideoDurationMs) {
|
||||||
|
mHasFinishCurVideo = true
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.Event_Finish_Video,
|
||||||
|
NotifyMan.NotifyData(Pair(mVideoId, System.currentTimeMillis())))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun pause() {
|
||||||
|
if (!isRunning) return
|
||||||
|
isRunning = false
|
||||||
|
mCountHandler.removeCallbacks(mCounterRunnable)
|
||||||
|
mStartMs = 0L
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun release() {
|
||||||
|
isRunning = false
|
||||||
|
mCounterRunnable.let { mCountHandler.removeCallbacks(it) }
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
private val mHandlerThread = HandlerThread("HomeCountTimeThread")
|
||||||
|
private val mCountHandler: Handler by lazy {
|
||||||
|
Handler(mHandlerThread.looper)
|
||||||
|
}
|
||||||
|
private val mCounterRunnable by lazy {
|
||||||
|
object : Runnable {
|
||||||
|
override fun run() {
|
||||||
|
if (isRunning) {
|
||||||
|
handleNewTick()
|
||||||
|
mCountHandler.postDelayed(this, Notify_Interval_MS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
private var isRunning = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val HOME_WATCH_DURATION = 5 * 1000L
|
||||||
|
const val Notify_Interval_MS = 50L
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
mHandlerThread.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun start() {
|
||||||
|
isRunning = true
|
||||||
|
mCountHandler.postDelayed(mCounterRunnable, Notify_Interval_MS)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun handleNewTick() {
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.Event_HOME_WATCH_Time_TICK, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun pause() {
|
||||||
|
if (!isRunning) return
|
||||||
|
isRunning = false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun release() {
|
||||||
|
isRunning = false
|
||||||
|
mCounterRunnable.let { mCountHandler.removeCallbacks(it) }
|
||||||
|
mHandlerThread.quitSafely()
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape android:shape="rectangle"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<stroke android:width="2dp" android:color="#fff2f2f2" />
|
||||||
|
<solid android:color="@color/red_e0" />
|
||||||
|
<corners android:topLeftRadius="15dp" android:topRightRadius="15dp" android:bottomLeftRadius="15dp" android:bottomRightRadius="15dp" />
|
||||||
|
</shape>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape android:shape="rectangle"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<stroke android:width="2dp" android:color="#fff2f2f2" />
|
||||||
|
<solid android:color="@color/transparent" />
|
||||||
|
<corners android:topLeftRadius="15dp" android:topRightRadius="15dp" android:bottomLeftRadius="15dp" android:bottomRightRadius="15dp" />
|
||||||
|
</shape>
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue