1
92
main/agconnect-services.json
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"agcgw":{
|
||||
"backurl":"connect-drcn.hispace.hicloud.com",
|
||||
"url":"connect-drcn.dbankcloud.cn",
|
||||
"websocketbackurl":"connect-ws-drcn.hispace.dbankcloud.com",
|
||||
"websocketurl":"connect-ws-drcn.hispace.dbankcloud.cn"
|
||||
},
|
||||
"agcgw_all":{
|
||||
"CN":"connect-drcn.dbankcloud.cn",
|
||||
"CN_back":"connect-drcn.hispace.hicloud.com",
|
||||
"DE":"connect-dre.dbankcloud.cn",
|
||||
"DE_back":"connect-dre.hispace.hicloud.com",
|
||||
"RU":"connect-drru.hispace.dbankcloud.ru",
|
||||
"RU_back":"connect-drru.hispace.dbankcloud.cn",
|
||||
"SG":"connect-dra.dbankcloud.cn",
|
||||
"SG_back":"connect-dra.hispace.hicloud.com"
|
||||
},
|
||||
"websocketgw_all":{
|
||||
"CN":"connect-ws-drcn.hispace.dbankcloud.cn",
|
||||
"CN_back":"connect-ws-drcn.hispace.dbankcloud.com",
|
||||
"DE":"connect-ws-dre.hispace.dbankcloud.cn",
|
||||
"DE_back":"connect-ws-dre.hispace.dbankcloud.com",
|
||||
"RU":"connect-ws-drru.hispace.dbankcloud.ru",
|
||||
"RU_back":"connect-ws-drru.hispace.dbankcloud.cn",
|
||||
"SG":"connect-ws-dra.hispace.dbankcloud.cn",
|
||||
"SG_back":"connect-ws-dra.hispace.dbankcloud.com"
|
||||
},
|
||||
"client":{
|
||||
"cp_id":"30086000612391734",
|
||||
"product_id":"99536292102564216",
|
||||
"client_id":"964994320723627840",
|
||||
"client_secret":"6D5FE29D85B967D3A66BDCD473641E4C7B5524F7F4935CA0EF4A842730C3402D",
|
||||
"project_id":"99536292102564216",
|
||||
"app_id":"106936673",
|
||||
"api_key":"DAEDADYGta/0O4ZSdrnug52NgC67/w/RIyTq9A8LyAY0+mp6g6XeJDbxugpluFPLAhaqjaMs5c0PLnRx14UzWbPPADgi1EqihbWLoA==",
|
||||
"package_name":"com.pandoralive.shayu"
|
||||
},
|
||||
"oauth_client":{
|
||||
"client_id":"106936673",
|
||||
"client_type":1
|
||||
},
|
||||
"app_info":{
|
||||
"app_id":"106936673",
|
||||
"package_name":"com.pandoralive.shayu"
|
||||
},
|
||||
"service":{
|
||||
"analytics":{
|
||||
"collector_url":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn",
|
||||
"collector_url_ru":"datacollector-drru.dt.dbankcloud.ru,datacollector-drru.dt.hicloud.com",
|
||||
"collector_url_sg":"datacollector-dra.dt.hicloud.com,datacollector-dra.dt.dbankcloud.cn",
|
||||
"collector_url_de":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn",
|
||||
"collector_url_cn":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn",
|
||||
"resource_id":"p1",
|
||||
"channel_id":""
|
||||
},
|
||||
"search":{
|
||||
"url":"https://search-drcn.cloud.huawei.com"
|
||||
},
|
||||
"cloudstorage":{
|
||||
"storage_url_sg_back":"https://agc-storage-dra.cloud.huawei.asia",
|
||||
"storage_url_ru_back":"https://agc-storage-drru.cloud.huawei.ru",
|
||||
"storage_url_ru":"https://agc-storage-drru.cloud.huawei.ru",
|
||||
"storage_url_de_back":"https://agc-storage-dre.cloud.huawei.eu",
|
||||
"storage_url_de":"https://ops-dre.agcstorage.link",
|
||||
"storage_url":"https://agc-storage-drcn.platform.dbankcloud.cn",
|
||||
"storage_url_sg":"https://ops-dra.agcstorage.link",
|
||||
"storage_url_cn_back":"https://agc-storage-drcn.cloud.huawei.com.cn",
|
||||
"storage_url_cn":"https://agc-storage-drcn.platform.dbankcloud.cn"
|
||||
},
|
||||
"ml":{
|
||||
"mlservice_url":"ml-api-drcn.ai.dbankcloud.com,ml-api-drcn.ai.dbankcloud.cn"
|
||||
}
|
||||
},
|
||||
"region":"CN",
|
||||
"configuration_version":"3.0",
|
||||
"appInfos":[
|
||||
{
|
||||
"package_name":"com.pandoralive.shayu",
|
||||
"client":{
|
||||
"app_id":"106936673"
|
||||
},
|
||||
"app_info":{
|
||||
"package_name":"com.pandoralive.shayu",
|
||||
"app_id":"106936673"
|
||||
},
|
||||
"oauth_client":{
|
||||
"client_type":1,
|
||||
"client_id":"106936673"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
89
main/build.gradle
Normal file
@@ -0,0 +1,89 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'img-optimizer'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
packagingOptions {
|
||||
pickFirst "lib/armeabi/libyuvutils.so"
|
||||
pickFirst "lib/arm64-v8a/libyuvutils.so"
|
||||
pickFirst "lib/armeabi-v7a/libyuvutils.so"
|
||||
pickFirst "lib/armeabi/libyuvtools.so"
|
||||
pickFirst "lib/arm64-v8a/libyuvtools.so"
|
||||
pickFirst "lib/armeabi-v7a/libyuvtools.so"
|
||||
exclude "lib/arm64-v8a/libmmcv_api_handgesture.so"
|
||||
exclude "lib/arm64-v8a/libmmcv_api_express.so"
|
||||
exclude "lib/arm64-v8a/libMediaEncoder.so"
|
||||
exclude "lib/arm64-v8a/libarcore_sdk_c.so"
|
||||
exclude "lib/arm64-v8a/libmediadecoder.so"
|
||||
exclude "lib/arm64-v8a/libMediaMuxer.so"
|
||||
exclude "lib/arm64-v8a/libarcore_sdk_jni.so"
|
||||
exclude "lib/arm64-v8a/libMediaUtils.so"
|
||||
exclude "lib/arm64-v8a/libcosmosffmpeg.so"
|
||||
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode rootProject.ext.android.versionCode
|
||||
versionName rootProject.ext.android.versionName
|
||||
manifestPlaceholders = rootProject.ext.manifestPlaceholders
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "arm64-v8a"
|
||||
}
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
aaptOptions {
|
||||
cruncherEnabled = false
|
||||
useNewCruncher = false
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
flatDir {
|
||||
dirs 'libs', '../libs'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compileOnly files('../libs/beautysdk-202202241203.aar')
|
||||
compileOnly files('../libs/svgaplayer-release-v1.2.1.aar')
|
||||
//直播
|
||||
api project(':live')
|
||||
//短视频
|
||||
api project(':video')
|
||||
api project(':common')
|
||||
api project(':FaceUnity')//新娱美颜
|
||||
api project(':Share')//分享
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
annotationProcessor rootProject.ext.dependencies["arouter-compiler"]
|
||||
api files('libs/OpenInstall_v2.3.0.jar')
|
||||
implementation project(path: ':lib_country_code')
|
||||
//抽屉菜单
|
||||
implementation 'com.justkiddingbaby:slidemenu:1.3.0'
|
||||
implementation 'com.xj.marqueeView:marqueeView:0.1.20'
|
||||
//引导层
|
||||
implementation 'com.binioter:guideview:1.0.0'
|
||||
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
|
||||
|
||||
}
|
||||
70
main/google-services.json
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "292494634914",
|
||||
"project_id": "pdlive-1631521064967",
|
||||
"storage_bucket": "pdlive-1631521064967.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:292494634914:android:d8db197d7e7a6c3a3a4cfb",
|
||||
"android_client_info": {
|
||||
"package_name": "com.pandoralive.shayu"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "292494634914-8nuhhoeo061ki1jevbcsrl7dfdl6dlm0.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.pandoralive.shayu",
|
||||
"certificate_hash": "38cc19306c9facee36a9224e9a4070bc0be15c7d"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "292494634914-ctr3fptp5mkv2qqr4gkgjo9uluq2joqb.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.pandoralive.shayu",
|
||||
"certificate_hash": "15fc5e70cf238323bf7111c8c627803985478e87"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "292494634914-ejtqvaj86a2lldv0di2pr3d5gngprahd.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.pandoralive.shayu",
|
||||
"certificate_hash": "b66dc8d21cfcf6c729577ddcf0c312b2a31ed872"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "292494634914-ha2kbgtclkv20hl3a1l8r7861a1a0m5i.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDVnuGnQzjI_vDrxh20Hv_S1OMUD7Vp3zU"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "292494634914-ha2kbgtclkv20hl3a1l8r7861a1a0m5i.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
},
|
||||
{
|
||||
"client_id": "292494634914-v9j4rei86q2pfh9as4seotb23vr2744a.apps.googleusercontent.com",
|
||||
"client_type": 2,
|
||||
"ios_info": {
|
||||
"bundle_id": "com.live.pd"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
244
main/img_optimizer.log
Normal file
@@ -0,0 +1,244 @@
|
||||
2019-11-01 14:00:08 info: Task optimizeMainRelease begin:
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:08 info: 118 images need to be optimized.
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:08 info: Succeed! 1978B-->1626B, 17.795753% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_follow_05.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:08 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_home_05.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 4324B-->2880B, 33.395004% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_list_no_data.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 1861B-->1406B, 24.44922% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_live_user_home_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 6172B-->3208B, 48.02333% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_me_msg.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_home_04.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_live_num.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 82891B-->35864B, 56.733543% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_bonus_top.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 1978B-->1626B, 17.795753% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_follow_04.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 2060B-->1716B, 16.69903% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_follow_06.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 6547B-->4195B, 35.92485% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_sex_male_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 803B-->693B, 13.69863% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_reg_pwd.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_home_06.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 573B-->341B, 40.488655% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_live_user_home_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_home_07.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 2091B-->1744B, 16.59493% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_follow_07.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 1895B-->1533B, 19.102901% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_follow_03.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_home_03.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 6492B-->4274B, 34.165127% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_list_head_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 6492B-->4276B, 34.13432% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_list_head_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:09 info: Succeed! 488B-->448B, 8.196721% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_invite_share_icon.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_home_02.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 1444B-->1097B, 24.030472% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_follow_02.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 1741B-->1371B, 21.252153% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_follow_00.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 768B-->701B, 8.723958% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_home_00.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 4974B-->3210B, 35.464417% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_start_live.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 9180B-->5835B, 36.43791% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_list_head_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 3013B-->2664B, 11.583139% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_recommend_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 256B-->164B, 35.9375% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_cash_delete.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 3324B-->2974B, 10.529483% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_recommend_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 401B-->244B, 39.15212% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_arrow_right_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 6944B-->4280B, 38.364056% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/bg_main_item_bottom.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_home_01.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 972B-->629B, 35.288067% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_follow_01.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_me_06.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 1850B-->1464B, 20.864864% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_list_medal_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_list_04.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 info: Succeed! 1274B-->1252B, 1.7268445% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_near_00.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:10 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_video_num.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 191932B-->83284B, 56.607548% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/bg_share_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_near_01.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_list_05.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 6737B-->4327B, 35.7726% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_sex_female_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 1689B-->1686B, 0.17761989% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_me_07.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 6135B-->3193B, 47.95436% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_me_wallet.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 2034B-->1494B, 26.548672% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_list_medal_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_me_05.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_list_07.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_near_03.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_near_location.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 21378B-->10197B, 52.30143% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/bg_share_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 8050B-->4356B, 45.8882% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/bg_share_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_near_02.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 1829B-->1763B, 3.6085293% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_list_06.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_me_04.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 2280B-->1607B, 29.517544% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_list_medal_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 1230B-->1045B, 15.04065% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_me_00.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 1634B-->1508B, 7.7111382% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_search.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 3471B-->2502B, 27.917027% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_live_type_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_list_02.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:11 info: Succeed! 1998B-->1847B, 7.5575576% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_near_06.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 1584B-->1452B, 8.333333% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_cash_ali.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 2011B-->1849B, 8.055694% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_near_07.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_list_03.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 2998B-->2368B, 21.01401% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_live_type_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_me_01.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 10494B-->4612B, 56.051075% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/bg_user_home_detail_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 930B-->822B, 11.612904% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_user_home_black.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 5157B-->3201B, 37.929028% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_sex_male.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_me_03.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 3111B-->2403B, 22.757956% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_live_type_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 429B-->288B, 32.867134% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_reg_phone.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_list_01.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 1901B-->1837B, 3.3666492% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_near_05.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 1876B-->1843B, 1.7590618% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_near_04.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 1031B-->922B, 10.57226% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_list_00.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 3009B-->2381B, 20.870722% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_live_type_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 9712B-->4471B, 53.96417% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/bg_user_home_detail_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_me_02.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_home_top_follow.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 6273B-->3214B, 48.764545% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_me_detail.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_cash_bank.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 628B-->436B, 30.573248% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_start_close.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 1329B-->1309B, 1.5048909% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_msg.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 2019B-->1883B, 6.7360077% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_near_08.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 info: Succeed! 817B-->777B, 4.895961% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_user_home_edit.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:12 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_home_top_live.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 18548B-->12938B, 30.245848% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_profit_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 814B-->470B, 42.26044% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_reg_code.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_me_08.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_user_home_share.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 1850B-->1769B, 4.3783784% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_list_08.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 784B-->684B, 12.755102% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_cash_radio_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_home_top_video.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 991B-->876B, 11.60444% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_cash_radio_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 846B-->494B, 41.607567% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_user_home_avatar_empty.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_user_home_share_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 5470B-->2984B, 45.4479% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_sex_female.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 20584B-->10339B, 49.771667% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/bg_list.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 2051B-->1507B, 26.523647% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_video_home_bottom.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 13761B-->6738B, 51.035534% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_bonus_4.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 5152B-->3188B, 38.121117% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_start_video.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 1838B-->1258B, 31.55604% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_class_all.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 31934B-->12480B, 60.919395% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/bg_main_me_top.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 8233B-->4313B, 47.613262% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_bonus_5.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:13 info: Succeed! 13361B-->5593B, 58.139362% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_start.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:14 info: Succeed! 1885B-->1208B, 35.91512% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_bonus_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:14 info: Succeed! 4957B-->3076B, 37.94634% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_bonus_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:14 info: Succeed! 15985B-->7056B, 55.858616% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_bonus_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:14 info: Succeed! 392B-->244B, 37.7551% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_arrow_right.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:14 info: Succeed! 2051B-->1318B, 35.738663% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_cash_wx.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:14 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_login_down.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:14 info: Succeed! 6116B-->3250B, 46.860695% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_me_shop.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:14 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_home_08.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:14 info: Succeed! 13746B-->7168B, 47.85392% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_charge_bg.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:14 info: Succeed! 2117B-->1770B, 16.391119% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_main_tab_follow_08.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:14 info: Succeed! 31262B-->23217B, 25.734118% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-mdpi/icon_bonus_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:15 info: Succeed! 1633120B-->675094B, 58.662315% saved! /Users/yaling/Documents/bayue/denglong_release4/main/src/main/res/mipmap-xxxhdpi/bg_login.png
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:15 info: Total: 118, Succeed: 84, Skipped: 34, Failed: 0, Saved: 1240.93359375KB
|
||||
----------------------------------------
|
||||
2019-11-01 14:00:15 info: Task optimizeMainRelease executed successfully.
|
||||
----------------------------------------
|
||||
BIN
main/libs/OpenInstall_v2.3.0.jar
Normal file
25
main/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/macpro/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
167
main/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.yunbao.main">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".MsgSettActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.OneLoginActivity" />
|
||||
<activity
|
||||
android:name=".activity.WeekWebViewActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.RewardActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.TestActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.BindUserActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.EntryActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.BuyVipActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MyWalletActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.ZhuangBanActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.RechargeActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LoginInvalidActivity"
|
||||
android:theme="@style/dialog2" />
|
||||
<activity
|
||||
android:name=".activity.LoginActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/noAnimationStyle"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.UserHomeActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.SettingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LanguageSettingActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="locale|layoutDirection|keyboard" />
|
||||
<activity
|
||||
android:name=".activity.SearchActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/CAppTheme" />
|
||||
<activity
|
||||
android:name=".activity.FollowActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.FansActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.EditProfileActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.EditSexActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.EditNameActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.EditSignActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MyImpressActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MyCoinActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MyVideoActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MyProfitActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.CashActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LiveClassActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.ModifyPwdActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.RegisterActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.FindPwdActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.RecommendActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.ThreeDistributActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MainListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.ChatActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.ChatRoomActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MyWebViewActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MyWebViewActivity2"
|
||||
android:screenOrientation="portrait" /> <!-- 融云消息列表界面 -->
|
||||
<activity
|
||||
android:name=".activity.PDLiveConversationListActivity"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/noAnimationStyle"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.MsgSettActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.CustomerServiceWebViewActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.RedPacketListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.RedPacketInfoActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.RedPacketUsersActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity android:name=".activity.UserAvatarSelectActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity android:name=".activity.BattlePassActivity" />
|
||||
|
||||
<activity android:name=".activity.MainHomeCommunityActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
BIN
main/src/main/assets/KSYResource/0_pink.png
Normal file
|
After Width: | Height: | Size: 158 KiB |
BIN
main/src/main/assets/KSYResource/0_ruddy2.png
Normal file
|
After Width: | Height: | Size: 131 KiB |
BIN
main/src/main/assets/KSYResource/10_sunshine_night.png
Normal file
|
After Width: | Height: | Size: 197 KiB |
BIN
main/src/main/assets/KSYResource/11_ruddy.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
main/src/main/assets/KSYResource/12_sunshine.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
main/src/main/assets/KSYResource/13_nature.png
Normal file
|
After Width: | Height: | Size: 771 KiB |
BIN
main/src/main/assets/KSYResource/1_freshy.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
main/src/main/assets/KSYResource/2_beauty.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
main/src/main/assets/KSYResource/3_sweety.png
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
main/src/main/assets/KSYResource/4_sepia.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
main/src/main/assets/KSYResource/5_blue.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
main/src/main/assets/KSYResource/6_nostalgia.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
main/src/main/assets/KSYResource/7_sakura.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
main/src/main/assets/KSYResource/8_sakura_night.png
Normal file
|
After Width: | Height: | Size: 226 KiB |
BIN
main/src/main/assets/KSYResource/9_ruddy_night.png
Normal file
|
After Width: | Height: | Size: 125 KiB |
BIN
main/src/main/assets/guide.svga
Normal file
BIN
main/src/main/assets/icoss.svga
Normal file
@@ -0,0 +1,256 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import static com.yunbao.common.utils.RouteUtil.PATH_COIN;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.BattlePassUserInfoBean;
|
||||
import com.yunbao.common.bean.LiveBattlePassRewardsBean;
|
||||
import com.yunbao.common.dialog.ActivateEliteBattleOrderPopupWindow;
|
||||
import com.yunbao.common.dialog.ActivityEndPopupWindow;
|
||||
import com.yunbao.common.dialog.LiberalBattlePassPopupWindow;
|
||||
import com.yunbao.common.dialog.PromotionElitePopupWindow;
|
||||
import com.yunbao.common.dialog.RuleOfWarPopupWindow;
|
||||
import com.yunbao.common.fragment.BaseFragment;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.event.BattlePassTypeEvent;
|
||||
import com.yunbao.main.fragment.BattlePassExchangeFragment;
|
||||
import com.yunbao.main.fragment.BattlePassMissionFragment;
|
||||
import com.yunbao.main.fragment.BattlePassRewardFragment;
|
||||
import com.yunbao.main.interfaces.BattlePassUserInfoListener;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 战令
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_BattlePassActivity)
|
||||
public class BattlePassActivity extends AbsActivity {
|
||||
ImageView rule, tab1, tab2, tab3;
|
||||
ViewPager2 viewPager;
|
||||
List<BaseFragment> fragments;
|
||||
TextView sessionView;
|
||||
TextView timeView;
|
||||
TextView levelView;
|
||||
TextView expText;
|
||||
ProgressBar levelProgressView;
|
||||
TextView integralView;
|
||||
Button moreIntegralButton;
|
||||
String enjoySpendMoney = "";
|
||||
String quintessenceSpendMoney = "";
|
||||
|
||||
BattlePassUserInfoBean data;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_battlepass;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
super.main(savedInstanceState);
|
||||
Bus.getOn(this);
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
fragments = new ArrayList<>();
|
||||
rule = findViewById(R.id.rule);
|
||||
tab1 = findViewById(R.id.tab_1);
|
||||
tab2 = findViewById(R.id.tab_2);
|
||||
tab3 = findViewById(R.id.tab_3);
|
||||
expText = findViewById(R.id.exp_text);
|
||||
viewPager = findViewById(R.id.context_layout);
|
||||
fragments.add(new BattlePassRewardFragment(() -> data));
|
||||
fragments.add(new BattlePassMissionFragment(() -> data));
|
||||
fragments.add(new BattlePassExchangeFragment(() -> data));
|
||||
viewPager.setAdapter(new FragmentStateAdapter(this) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
return fragments.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fragments.size();
|
||||
}
|
||||
});
|
||||
viewPager.setUserInputEnabled(false);
|
||||
ViewClicksAntiShake.clicksAntiShake(tab1, () -> clickView(0));
|
||||
ViewClicksAntiShake.clicksAntiShake(tab2, () -> clickView(1));
|
||||
ViewClicksAntiShake.clicksAntiShake(tab3, () -> clickView(2));
|
||||
|
||||
sessionView = findViewById(R.id.session);
|
||||
timeView = findViewById(R.id.time);
|
||||
levelView = findViewById(R.id.level);
|
||||
levelProgressView = findViewById(R.id.level_progress);
|
||||
integralView = findViewById(R.id.integral);
|
||||
moreIntegralButton = findViewById(R.id.more_integral);
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(moreIntegralButton, () -> {
|
||||
new XPopup.Builder(mContext)
|
||||
.enableDrag(false)
|
||||
.maxWidth(DeviceUtils.getScreenHeight(mContext) - DpUtil.dp2px(34))
|
||||
.asCustom(new PromotionElitePopupWindow(mContext,
|
||||
enjoySpendMoney,
|
||||
quintessenceSpendMoney,
|
||||
new LiberalBattlePassPopupWindow.LiberalBattlePassCallback() {
|
||||
@Override
|
||||
public void onCallback(int code, String msg) {
|
||||
if (code == 1001) {
|
||||
new DialogUitl.Builder(mContext)
|
||||
.setView(com.yunbao.live.R.layout.dialog_live_unfollow)
|
||||
.setConfirmString(getString(com.yunbao.live.R.string.charge))
|
||||
.setContent(getString(com.yunbao.live.R.string.insufficient_balance))
|
||||
.setClickCallback(new DialogUitl.SimpleCallback() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
ARouter.getInstance().build(PATH_COIN).withInt("p", 0).navigation();
|
||||
}
|
||||
}).build().show();
|
||||
return;
|
||||
}
|
||||
ToastUtil.show(msg);
|
||||
initData();
|
||||
}
|
||||
},
|
||||
String.valueOf(data.getLive_battle_pass_type().get(1).getId()),
|
||||
String.valueOf(data.getLive_battle_pass_type().get(2).getId())
|
||||
).setUserData(data)
|
||||
)
|
||||
.show();
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(rule, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
new XPopup.Builder(BattlePassActivity.this)
|
||||
.enableDrag(false)
|
||||
.maxWidth(DeviceUtils.getScreenHeight(BattlePassActivity.this) - DpUtil.dp2px(34))
|
||||
.asCustom(new RuleOfWarPopupWindow(
|
||||
BattlePassActivity.this
|
||||
))
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void clickView(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
tab1.setImageResource(R.mipmap.ic_zl_tab1);
|
||||
tab2.setImageResource(R.mipmap.ic_zl_tab2_unselect);
|
||||
tab3.setImageResource(R.mipmap.ic_zl_tab3_unselect);
|
||||
break;
|
||||
case 1:
|
||||
tab1.setImageResource(R.mipmap.ic_zl_tab1_unselect);
|
||||
tab2.setImageResource(R.mipmap.ic_zl_tab2);
|
||||
tab3.setImageResource(R.mipmap.ic_zl_tab3_unselect);
|
||||
break;
|
||||
case 2:
|
||||
tab1.setImageResource(R.mipmap.ic_zl_tab1_unselect);
|
||||
tab2.setImageResource(R.mipmap.ic_zl_tab2_unselect);
|
||||
tab3.setImageResource(R.mipmap.ic_zl_tab3);
|
||||
break;
|
||||
}
|
||||
viewPager.setCurrentItem(position, false);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void initData() {
|
||||
LiveNetManager.get(mContext)
|
||||
.getBattlePassUserInfo(new HttpCallback<BattlePassUserInfoBean>() {
|
||||
@Override
|
||||
public void onSuccess(BattlePassUserInfoBean data) {
|
||||
BattlePassActivity.this.data = data;
|
||||
sessionView.setText(data.getBattlePassName());
|
||||
timeView.setText(String.format("%s%s - %s",
|
||||
WordUtil.getNewString(R.string.battlepass_user_time),
|
||||
data.getStartTime(),
|
||||
data.getEndTime()
|
||||
));
|
||||
levelView.setText("Lv." + data.getLevel());
|
||||
expText.setText(data.getBattlePassExp() + "/" +
|
||||
(data.getNextLevelExp() == 0 ? data.getBattlePassExp() : data.getNextLevelExp()));
|
||||
levelProgressView.setMax(data.getNextLevelExp()-data.getLastLevelExp());
|
||||
levelProgressView.setProgress(data.getBattlePassExp()-data.getLastLevelExp());
|
||||
integralView.setText(String.format(WordUtil.getNewString(R.string.battlepass_user_my_integral), data.getPoints()));
|
||||
|
||||
for (LiveBattlePassRewardsBean.BattlePassType passType : data.getLive_battle_pass_type()) {
|
||||
if (passType.getId() == 2) {
|
||||
quintessenceSpendMoney = String.valueOf(passType.getDiamond_value());
|
||||
}
|
||||
if (passType.getId() == 3) {
|
||||
enjoySpendMoney = String.valueOf(passType.getDiamond_value());
|
||||
}
|
||||
}
|
||||
if (!data.isBattlePassStatus() && !SpUtil.getInstance().getBooleanValue("is_battle_pass_status")) {
|
||||
SpUtil.getInstance().setBooleanValue("is_battle_pass_status", true);//ActivityEndPopupWindow
|
||||
new XPopup.Builder(BattlePassActivity.this)
|
||||
.enableDrag(false)
|
||||
.maxWidth(DeviceUtils.getScreenHeight(BattlePassActivity.this) - DpUtil.dp2px(34))
|
||||
.asCustom(new ActivityEndPopupWindow(
|
||||
BattlePassActivity.this
|
||||
))
|
||||
.show();
|
||||
|
||||
}
|
||||
if (data.isBattlePassStatus()) {
|
||||
SpUtil.getInstance().removeValue("is_battle_pass_status");
|
||||
}
|
||||
fragments.get(viewPager.getCurrentItem()).updateData();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void event(BattlePassTypeEvent event) {
|
||||
if (event.getType() == 0) {
|
||||
initData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,524 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.DeviceUtils;
|
||||
import com.fm.openinstall.OpenInstall;
|
||||
import com.fm.openinstall.listener.AppInstallAdapter;
|
||||
import com.fm.openinstall.model.AppData;
|
||||
import com.sahooz.library.Country;
|
||||
import com.sahooz.library.CountryPicker;
|
||||
import com.sahooz.library.OnPick;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.event.EditProfileEvent;
|
||||
import com.yunbao.main.event.RegSuccessEvent;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 綁定手機號
|
||||
*/
|
||||
public class BindUserActivity extends AbsActivity {
|
||||
|
||||
private LinearLayout lt_first_bind;
|
||||
private EditText mEditPhone;
|
||||
private EditText mEditCode;
|
||||
private EditText mEditPwd1;
|
||||
private EditText mEditPwd2;
|
||||
private TextView mBtnCode;
|
||||
private View mBtnRegister;
|
||||
private Handler mHandler;
|
||||
private static final int TOTAL = 60;
|
||||
private int mCount = TOTAL;
|
||||
private String mGetCode;
|
||||
private String mGetCodeAgain;
|
||||
private Dialog mDialog;
|
||||
private boolean mFirstLogin;//是否是第一次登录
|
||||
private boolean mShowInvite;
|
||||
private String mPromoCode = "";//推广码
|
||||
private String mUuidDevice = "";//手机唯一标识符
|
||||
private int mPhoneMinLength = 5;//输入手机号的最小位数
|
||||
private TextView mTvCountryCode;
|
||||
private int mCountryCode = 852;//国家代码
|
||||
private ImageView mIvCountryCode;
|
||||
private LinearLayout lt_now_bind, lt_give, lt_password, lt_password2;
|
||||
private TextView tv_now_phone, tv_title;
|
||||
private Button btn_goto_updata;
|
||||
private String isBind = "0", mobile = "";
|
||||
private WebView webview;
|
||||
private WebSettings webSettings;
|
||||
private ArrayList<Country> allCountries = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_bind_user;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
// setTitle(mContext.getString(R.string.reg_register));
|
||||
getPromoCode();
|
||||
webview = (WebView) findViewById(R.id.webview);
|
||||
lt_first_bind = (LinearLayout) findViewById(R.id.lt_first_bind);
|
||||
lt_password = findViewById(R.id.lt_password);
|
||||
lt_password2 = findViewById(R.id.lt_password2);
|
||||
mEditPhone = (EditText) findViewById(R.id.edit_phone);
|
||||
mTvCountryCode = findViewById(R.id.tvCountryCode);
|
||||
mIvCountryCode = findViewById(R.id.ivCountryCode);
|
||||
mEditCode = (EditText) findViewById(R.id.edit_code);
|
||||
mEditPwd1 = (EditText) findViewById(R.id.edit_pwd_1);
|
||||
mEditPwd2 = (EditText) findViewById(R.id.edit_pwd_2);
|
||||
mBtnCode = (TextView) findViewById(R.id.btn_code);
|
||||
mBtnRegister = findViewById(R.id.btn_register);
|
||||
|
||||
lt_now_bind = findViewById(R.id.lt_now_bind);
|
||||
lt_give = findViewById(R.id.lt_give);
|
||||
tv_now_phone = findViewById(R.id.tv_now_phone);
|
||||
btn_goto_updata = findViewById(R.id.btn_goto_updata);
|
||||
tv_title = findViewById(R.id.tv_title);
|
||||
|
||||
mGetCode = mContext.getString(R.string.reg_get_code);
|
||||
mGetCodeAgain = mContext.getString(R.string.reg_get_code_again);
|
||||
mTvCountryCodeClick();
|
||||
mEditPhone.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (!TextUtils.isEmpty(s) && s.length() >= mPhoneMinLength) {
|
||||
mBtnCode.setEnabled(true);
|
||||
} else {
|
||||
mBtnCode.setEnabled(false);
|
||||
}
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
TextWatcher textWatcher = new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
};
|
||||
mEditCode.addTextChangedListener(textWatcher);
|
||||
mEditPwd1.addTextChangedListener(textWatcher);
|
||||
mEditPwd2.addTextChangedListener(textWatcher);
|
||||
mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
mCount--;
|
||||
if (mCount > 0) {
|
||||
mBtnCode.setText(mGetCodeAgain + "(" + mCount + "s)");
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessageDelayed(0, 1000);
|
||||
}
|
||||
} else {
|
||||
mBtnCode.setText(mGetCode);
|
||||
mCount = TOTAL;
|
||||
if (mBtnCode != null) {
|
||||
mBtnCode.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mDialog = DialogUitl.loadingDialog(mContext, getString(R.string.reg_register_ing));
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
isBind = getIntent().getStringExtra("isBind");
|
||||
mobile = getIntent().getStringExtra("mobile");
|
||||
if ("1".equals(isBind)) {
|
||||
lt_now_bind.setVisibility(View.VISIBLE);
|
||||
lt_first_bind.setVisibility(View.GONE);
|
||||
tv_now_phone.setText(mobile);
|
||||
} else {
|
||||
lt_now_bind.setVisibility(View.GONE);
|
||||
lt_first_bind.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
webSettings = webview.getSettings();
|
||||
webSettings.setUseWideViewPort(true);
|
||||
webSettings.setLoadWithOverviewMode(true);
|
||||
// 禁用缓存
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||
webview.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
view.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
// 开启js支持
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webview.addJavascriptInterface(new JsBridge(), "jsBridge");
|
||||
// 也可以加载本地html(webView.loadUrl("file:///android_asset/xxx.html"))
|
||||
webview.loadUrl(CommonAppConfig.HOST + "/h5/live/TCaptcha.html"+ "?isZh=" + (WordUtil.isNewZh() ? "1" : 0));
|
||||
|
||||
allCountries.clear();
|
||||
allCountries.addAll(Country.getAll(mContext, null));
|
||||
|
||||
String ct = IMLoginManager.get(mContext).getString("sys_user_area");
|
||||
ct = TextUtils.equals("中国", ct) ? "中国香港" : ct;
|
||||
for (int i = 0; i < allCountries.size(); i++) {
|
||||
if (allCountries.get(i).chs.equals(ct)) {
|
||||
String countryName = allCountries.get(i).name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) : countryName;
|
||||
mTvCountryCode.setText("+" + allCountries.get(i).code + " " + countryName);
|
||||
mCountryCode = allCountries.get(i).code;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void mTvCountryCodeClick() {
|
||||
mIvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
mTvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void changeEnable() {
|
||||
String phone = mEditPhone.getText().toString();
|
||||
String code = mEditCode.getText().toString();
|
||||
String pwd1 = mEditPwd1.getText().toString();
|
||||
String pwd2 = mEditPwd2.getText().toString();
|
||||
// mBtnRegister.setEnabled(!TextUtils.isEmpty(phone) && !TextUtils.isEmpty(code) && !TextUtils.isEmpty(pwd1) && !TextUtils.isEmpty(pwd2));
|
||||
}
|
||||
|
||||
private void showCountryCode() {
|
||||
CountryPicker.newInstance(null, new OnPick() {
|
||||
@Override
|
||||
public void onPick(Country country) {
|
||||
String countryName = country.name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) + "..." : countryName;
|
||||
mTvCountryCode.setText(" +" + country.code + " " + countryName);
|
||||
mCountryCode = country.code;
|
||||
}
|
||||
}).show(getSupportFragmentManager(), "country");
|
||||
}
|
||||
|
||||
|
||||
public void registerClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_code) {
|
||||
//获取验证码
|
||||
// getMessageCode();
|
||||
//获取邀请码
|
||||
// getPromoCode();
|
||||
webview.setVisibility(View.VISIBLE);
|
||||
//获取设备唯一标识符
|
||||
getUuidDevice();
|
||||
|
||||
} else if (i == R.id.btn_register) {
|
||||
register();
|
||||
} else if (i == R.id.btn_tip2) {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY1+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"),false);
|
||||
} else if (i == R.id.btn_tip3) {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY2+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"),false);
|
||||
} else if (i == R.id.btn_goto_updata) {
|
||||
lt_now_bind.setVisibility(View.GONE);
|
||||
lt_first_bind.setVisibility(View.VISIBLE);
|
||||
lt_give.setVisibility(View.GONE);
|
||||
lt_password.setVisibility(View.GONE);
|
||||
lt_password2.setVisibility(View.GONE);
|
||||
tv_title.setText(getResources().getString(R.string.bind_phone_updata_title));
|
||||
}
|
||||
}
|
||||
|
||||
private void getUuidDevice() {
|
||||
String uuid = DeviceUtils.getUniqueDeviceId();
|
||||
if (uuid != null) {
|
||||
mUuidDevice = uuid;
|
||||
}
|
||||
}
|
||||
|
||||
public class JsBridge {
|
||||
@JavascriptInterface
|
||||
public void getData(final String Randstr, final String Ticket) {
|
||||
((BindUserActivity) mContext).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i("tvss", Randstr);
|
||||
webview.setVisibility(View.GONE);
|
||||
//获取验证码
|
||||
getMessageCode(Randstr, Ticket);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短信验证码
|
||||
*/
|
||||
private void getMessageCode(String Randstr, String Ticket) {
|
||||
String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum))
|
||||
// {
|
||||
// mEditPhone.setError(mContext.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
mEditCode.requestFocus();
|
||||
MainHttpUtil.getRegisterCode(Randstr, Ticket, phoneNum, mCountryCode, mGetCodeCallback);
|
||||
}
|
||||
|
||||
private HttpCallback mGetCodeCallback = new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
mBtnCode.setEnabled(false);
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessage(0);
|
||||
}
|
||||
if (!TextUtils.isEmpty(msg) && msg.contains("123456")) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 注册并登陆
|
||||
*/
|
||||
private void register() {
|
||||
final String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum)) {
|
||||
// mEditPhone.setError(mContext.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
String code = mEditCode.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(code)) {
|
||||
mEditCode.setError(mContext.getString(R.string.reg_input_code));
|
||||
mEditCode.requestFocus();
|
||||
return;
|
||||
}
|
||||
if ("0".equals(isBind)) {
|
||||
final String pwd = mEditPwd1.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd)) {
|
||||
mEditPwd1.setError(mContext.getString(R.string.reg_input_pwd_1));
|
||||
mEditPwd1.requestFocus();
|
||||
return;
|
||||
}
|
||||
String pwd2 = mEditPwd2.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_input_pwd_2));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (!pwd.equals(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_pwd_error));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
// if (mDialog != null) {
|
||||
// mDialog.show();
|
||||
// }
|
||||
MainHttpUtil.bindPhone(phoneNum, mCountryCode, getIntent().getStringExtra("uid"), getIntent().getStringExtra("token"), pwd, pwd2, code, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
ToastUtil.show(msg);
|
||||
if (code == 0) {
|
||||
Bus.get().post(new EditProfileEvent());
|
||||
finish();
|
||||
}
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if ("1".equals(isBind)) {
|
||||
MainHttpUtil.updateBindMobile(phoneNum, mCountryCode, getIntent().getStringExtra("uid"), getIntent().getStringExtra("token"), code, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
ToastUtil.show(msg);
|
||||
if (code == 0) {
|
||||
Bus.get().post(new EditProfileEvent());
|
||||
finish();
|
||||
}
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//从网页获取推广码
|
||||
private void getPromoCode() {
|
||||
OpenInstall.getInstall(new AppInstallAdapter() {
|
||||
@Override
|
||||
public void onInstall(AppData appData) {
|
||||
//获取渠道数据
|
||||
String channelCode = appData.getChannel();
|
||||
//获取自定义数据
|
||||
if (appData.getData() != null && !appData.getData().equals("")) {
|
||||
JSONObject data = JSON.parseObject(appData.getData());
|
||||
mPromoCode = data.getString("admin_id") + "";
|
||||
Log.d("OpenInstall", "appData.getData()1111= " + mPromoCode);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void login(String phoneNum, String pwd) {
|
||||
String uuid = DeviceUtils.getUniqueDeviceId();
|
||||
MainHttpUtil.login(phoneNum, pwd, uuid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
String uid = obj.getString("id");
|
||||
String token = obj.getString("token");
|
||||
mFirstLogin = obj.getIntValue("isreg") == 1;
|
||||
mShowInvite = obj.getIntValue("isagent") == 1;
|
||||
CommonAppConfig.getInstance().setLoginInfo(uid, token, true);
|
||||
getBaseUserInfo();
|
||||
//友盟统计登录
|
||||
// MobclickAgent.onProfileSignIn(Constants.MOB_PHONE, uid);
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
private void getBaseUserInfo() {
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
if (bean != null) {
|
||||
if (mFirstLogin) {
|
||||
RecommendActivity.forward(mContext, mShowInvite);
|
||||
} else {
|
||||
MainActivity.forward(mContext, mShowInvite);
|
||||
}
|
||||
EventBus.getDefault().post(new RegSuccessEvent());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRegSuccessEvent(RegSuccessEvent e) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_REGISTER_CODE);
|
||||
MainHttpUtil.cancel(MainHttpConsts.REGISTER);
|
||||
MainHttpUtil.cancel(MainHttpConsts.LOGIN);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_BASE_INFO);
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mHandler = null;
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.yunbao.main.R;
|
||||
|
||||
public class BuyVipActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_buy_vip);
|
||||
}
|
||||
}
|
||||
168
main/src/main/java/com/yunbao/main/activity/CashActivity.java
Normal file
@@ -0,0 +1,168 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.CashAccountAdapter;
|
||||
import com.yunbao.main.bean.CashAccountBean;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.main.views.CashAccountViewHolder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/20.
|
||||
* 提现账户
|
||||
*/
|
||||
|
||||
public class CashActivity extends AbsActivity implements View.OnClickListener, CashAccountAdapter.ActionListener {
|
||||
|
||||
private CashAccountViewHolder mCashAccountViewHolder;
|
||||
private View mNoAccount;
|
||||
private RecyclerView mRecyclerView;
|
||||
private CashAccountAdapter mAdapter;
|
||||
private String mCashAccountId;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_cash;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Intent intent = getIntent();
|
||||
mCashAccountId = intent.getStringExtra(Constants.CASH_ACCOUNT_ID);
|
||||
if (mCashAccountId == null) {
|
||||
mCashAccountId = "";
|
||||
}
|
||||
findViewById(R.id.btn_add).setOnClickListener(this);
|
||||
mNoAccount = findViewById(R.id.no_account);
|
||||
mRecyclerView = findViewById(R.id.recyclerView);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mAdapter = new CashAccountAdapter(mContext, mCashAccountId);
|
||||
mAdapter.setActionListener(this);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
loadData();
|
||||
}
|
||||
|
||||
private void loadData() {
|
||||
MainHttpUtil.getCashAccountList(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
List<CashAccountBean> list = JSON.parseArray(Arrays.toString(info), CashAccountBean.class);
|
||||
if (list.size() > 0) {
|
||||
if (mNoAccount.getVisibility() == View.VISIBLE) {
|
||||
mNoAccount.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
mAdapter.setList(list);
|
||||
} else {
|
||||
if (mNoAccount.getVisibility() != View.VISIBLE) {
|
||||
mNoAccount.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_add) {
|
||||
addAccount();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void addAccount() {
|
||||
if (mCashAccountViewHolder == null) {
|
||||
mCashAccountViewHolder = new CashAccountViewHolder(mContext, (ViewGroup) findViewById(R.id.root));
|
||||
}
|
||||
mCashAccountViewHolder.addToParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (mCashAccountViewHolder != null && mCashAccountViewHolder.isShowed()) {
|
||||
mCashAccountViewHolder.removeFromParent();
|
||||
return;
|
||||
}
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
public void insertAccount(CashAccountBean cashAccountBean) {
|
||||
if (mAdapter != null) {
|
||||
if (mNoAccount.getVisibility() == View.VISIBLE) {
|
||||
mNoAccount.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
mAdapter.insertItem(cashAccountBean);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(CashAccountBean bean, int position) {
|
||||
if (!bean.getId().equals(mCashAccountId)) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put(Constants.CASH_ACCOUNT_ID, bean.getId());
|
||||
map.put(Constants.CASH_ACCOUNT, bean.getAccount());
|
||||
map.put(Constants.CASH_ACCOUNT_TYPE, String.valueOf(bean.getType()));
|
||||
SpUtil.getInstance().setMultiStringValue(map);
|
||||
}
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDelete(final CashAccountBean bean, final int position) {
|
||||
DialogUitl.showSimpleDialog(mContext,mContext.getString(R.string.cash_delete), new DialogUitl.SimpleCallback() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
MainHttpUtil.deleteCashAccount(bean.getId(), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
if (bean.getId().equals(mCashAccountId)) {
|
||||
SpUtil.getInstance().removeValue(Constants.CASH_ACCOUNT_ID, Constants.CASH_ACCOUNT, Constants.CASH_ACCOUNT_TYPE);
|
||||
}
|
||||
if (mAdapter != null) {
|
||||
mAdapter.removeItem(position);
|
||||
if (mAdapter.getItemCount() == 0) {
|
||||
if (mNoAccount.getVisibility() != View.VISIBLE) {
|
||||
mNoAccount.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_USER_ACCOUNT_LIST);
|
||||
MainHttpUtil.cancel(MainHttpConsts.ADD_CASH_ACCOUNT);
|
||||
MainHttpUtil.cancel(MainHttpConsts.DEL_CASH_ACCOUNT);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.live.views.ChatListViewHolder;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/24.
|
||||
*/
|
||||
|
||||
public class ChatActivity extends AbsActivity {
|
||||
|
||||
private ChatListViewHolder mChatListViewHolder;
|
||||
|
||||
public static void forward(Context context) {
|
||||
context.startActivity(new Intent(context, ChatActivity.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_chat_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
// mChatListViewHolder = new ChatListViewHolder(mContext, (ViewGroup) findViewById(R.id.root), ChatListViewHolder.TYPE_ACTIVITY);
|
||||
mChatListViewHolder = new ChatListViewHolder(mContext, (ViewGroup) findViewById(R.id.root), 0);
|
||||
// mChatListViewHolder.setActionListener(new ChatListViewHolder.ActionListener() {
|
||||
// @Override
|
||||
// public void onCloseClick() {
|
||||
// onBackPressed();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onItemClick(ImUserBean bean) {
|
||||
//// SystemMessageActivity.forward("1",mContext);
|
||||
//
|
||||
//// ChatRoomActivity.forward(mContext, bean, bean.getAttent() == 1, false);
|
||||
// }
|
||||
// });
|
||||
mChatListViewHolder.addToParent();
|
||||
mChatListViewHolder.loadData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mChatListViewHolder != null) {
|
||||
mChatListViewHolder.release();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.interfaces.ActivityResultCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.interfaces.KeyBoardHeightChangeListener;
|
||||
import com.yunbao.common.utils.KeyBoardHeightUtil;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/24.
|
||||
*/
|
||||
|
||||
public class ChatRoomActivity extends AbsActivity implements KeyBoardHeightChangeListener {
|
||||
|
||||
private ViewGroup mRoot;
|
||||
private ViewGroup mContianer;
|
||||
// private ChatRoomViewHolder mChatRoomViewHolder;
|
||||
private KeyBoardHeightUtil mKeyBoardHeightUtil;
|
||||
private ProcessImageUtil mImageUtil;
|
||||
private boolean mPaused;
|
||||
private boolean mFromUserHome;
|
||||
|
||||
public static void forward(Context context, UserBean userBean, boolean following, boolean fromUserHome) {
|
||||
// Intent intent = new Intent(context, ChatRoomActivity.class);
|
||||
// intent.putExtra(Constants.USER_BEAN, userBean);
|
||||
// intent.putExtra(Constants.FOLLOW, following);
|
||||
// intent.putExtra(Constants.IM_FROM_HOME, fromUserHome);
|
||||
// context.startActivity(intent);
|
||||
ToastUtil.show("私聊暫不可用");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_chat_room;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Intent intent = getIntent();
|
||||
UserBean userBean = intent.getParcelableExtra(Constants.USER_BEAN);
|
||||
if (userBean == null) {
|
||||
return;
|
||||
}
|
||||
boolean following = intent.getBooleanExtra(Constants.FOLLOW, false);
|
||||
mFromUserHome = intent.getBooleanExtra(Constants.IM_FROM_HOME, false);
|
||||
mRoot = (ViewGroup) findViewById(R.id.root);
|
||||
mContianer = (ViewGroup) findViewById(R.id.container);
|
||||
// mChatRoomViewHolder = new ChatRoomViewHolder(mContext, mContianer, userBean, following);
|
||||
// mChatRoomViewHolder.setActionListener(new ChatRoomActionListener() {
|
||||
// @Override
|
||||
// public void onCloseClick() {
|
||||
// superBackPressed();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onPopupWindowChanged(final int height) {
|
||||
// onKeyBoardChanged(height);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onChooseImageClick() {
|
||||
// checkReadWritePermissions();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onCameraClick() {
|
||||
// takePhoto();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onVoiceInputClick() {
|
||||
// checkVoiceRecordPermission(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// openVoiceInputDialog();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onLocationClick() {
|
||||
// checkLocationPermission();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onVoiceClick() {
|
||||
// checkVoiceRecordPermission(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// if (mChatRoomViewHolder != null) {
|
||||
// mChatRoomViewHolder.clickVoiceRecord();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ViewGroup getImageParentView() {
|
||||
// return mRoot;
|
||||
// }
|
||||
//
|
||||
//// @Override
|
||||
//// public void onImageClick() {
|
||||
////
|
||||
//// }
|
||||
//
|
||||
// });
|
||||
// mChatRoomViewHolder.addToParent();
|
||||
// mChatRoomViewHolder.loadData();
|
||||
// mImageUtil = new ProcessImageUtil(this);
|
||||
// mImageUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
// @Override
|
||||
// public void beforeCamera() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(File file) {
|
||||
// if (mChatRoomViewHolder != null) {
|
||||
// mChatRoomViewHolder.sendImage(file.getAbsolutePath());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// mKeyBoardHeightUtil = new KeyBoardHeightUtil(mContext, findViewById(android.R.id.content), this);
|
||||
// mRoot.postDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// if (mKeyBoardHeightUtil != null) {
|
||||
// mKeyBoardHeightUtil.start();
|
||||
// }
|
||||
// }
|
||||
// }, 500);
|
||||
}
|
||||
|
||||
private void onKeyBoardChanged(int keyboardHeight) {
|
||||
|
||||
// if (mRoot != null) {
|
||||
// FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mRoot.getLayoutParams();
|
||||
// if (params.bottomMargin != keyboardHeight) {
|
||||
// params.bottomMargin = keyboardHeight;
|
||||
// mRoot.setLayoutParams(params);
|
||||
// if (mChatRoomViewHolder != null) {
|
||||
// mChatRoomViewHolder.scrollToBottom();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// if (mChatRoomViewHolder != null) {
|
||||
// mChatRoomViewHolder.back();
|
||||
// } else {
|
||||
superBackPressed();
|
||||
// }
|
||||
}
|
||||
|
||||
private void release() {
|
||||
if (mKeyBoardHeightUtil != null) {
|
||||
mKeyBoardHeightUtil.release();
|
||||
}
|
||||
// if (mChatRoomViewHolder != null) {
|
||||
// mChatRoomViewHolder.refreshLastMessage();
|
||||
// mChatRoomViewHolder.release();
|
||||
// }
|
||||
if (mImageUtil != null) {
|
||||
mImageUtil.release();
|
||||
}
|
||||
mKeyBoardHeightUtil = null;
|
||||
// mChatRoomViewHolder = null;
|
||||
mImageUtil = null;
|
||||
}
|
||||
|
||||
public void superBackPressed() {
|
||||
release();
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
release();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onKeyBoardHeightChanged(int visibleHeight, int keyboardHeight) {
|
||||
if (mPaused) {
|
||||
return;
|
||||
}
|
||||
onKeyBoardChanged(keyboardHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSoftInputShowed() {
|
||||
if (mKeyBoardHeightUtil != null) {
|
||||
return mKeyBoardHeightUtil.isSoftInputShowed();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 聊天时候选择图片,检查读写权限
|
||||
*/
|
||||
private void checkReadWritePermissions() {
|
||||
if (mImageUtil == null) {
|
||||
return;
|
||||
}
|
||||
mImageUtil.requestPermissions(
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
forwardChooseImage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 前往选择图片页面
|
||||
*/
|
||||
private void forwardChooseImage() {
|
||||
if (mImageUtil == null) {
|
||||
return;
|
||||
}
|
||||
// mImageUtil.startActivityForResult(new Intent(mContext, ChatChooseImageActivity.class), new ActivityResultCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(Intent intent) {
|
||||
// if (intent != null) {
|
||||
// String imagePath = intent.getStringExtra(Constants.SELECT_IMAGE_PATH);
|
||||
// if (mChatRoomViewHolder != null) {
|
||||
// mChatRoomViewHolder.sendImage(imagePath);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拍照
|
||||
*/
|
||||
private void takePhoto() {
|
||||
if (mImageUtil != null) {
|
||||
mImageUtil.getImageByCamera(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送位置的时候检查定位权限
|
||||
*/
|
||||
private void checkLocationPermission() {
|
||||
if (mImageUtil == null) {
|
||||
return;
|
||||
}
|
||||
mImageUtil.requestPermissions(
|
||||
new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
forwardLocation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 前往发送位置页面
|
||||
*/
|
||||
private void forwardLocation() {
|
||||
if (mImageUtil == null) {
|
||||
return;
|
||||
}
|
||||
// mImageUtil.startActivityForResult(new Intent(mContext, LocationActivity.class), new ActivityResultCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(Intent intent) {
|
||||
// if (intent != null) {
|
||||
// double lat = intent.getDoubleExtra(Constants.LAT, 0);
|
||||
// double lng = intent.getDoubleExtra(Constants.LNG, 0);
|
||||
// int scale = intent.getIntExtra(Constants.SCALE, 0);
|
||||
// String address = intent.getStringExtra(Constants.ADDRESS);
|
||||
// if (lat > 0 && lng > 0 && scale > 0 && !TextUtils.isEmpty(address)) {
|
||||
// if (mChatRoomViewHolder != null) {
|
||||
// mChatRoomViewHolder.sendLocation(lat, lng, scale, address);
|
||||
// }
|
||||
// } else {
|
||||
// ToastUtil.show(mContext.getString(R.string.im_get_location_failed));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查录音权限
|
||||
*/
|
||||
private void checkVoiceRecordPermission(Runnable runnable) {
|
||||
if (mImageUtil == null) {
|
||||
return;
|
||||
}
|
||||
mImageUtil.requestPermissions(
|
||||
new String[]{
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.RECORD_AUDIO},
|
||||
runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开语音输入窗口
|
||||
*/
|
||||
private void openVoiceInputDialog() {
|
||||
// ChatVoiceInputDialog fragment = new ChatVoiceInputDialog();
|
||||
// fragment.setChatRoomViewHolder(mChatRoomViewHolder);
|
||||
// fragment.show(getSupportFragmentManager(), "ChatVoiceInputDialog");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mPaused = true;
|
||||
// if (mChatRoomViewHolder != null) {
|
||||
// mChatRoomViewHolder.onPause();
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mPaused = false;
|
||||
// if (mChatRoomViewHolder != null) {
|
||||
// mChatRoomViewHolder.onResume();
|
||||
// }
|
||||
}
|
||||
|
||||
public boolean isFromUserHome() {
|
||||
return mFromUserHome;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.opensource.svgaplayer.SVGACallback;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.utils.AndroidBug5497Workaround;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.share.ui.InvitePopDialog;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* 专门给客服页面的WebView
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_CS)
|
||||
public class CustomerServiceWebViewActivity extends AbsActivity {
|
||||
private ProgressBar mProgressBar;
|
||||
private WebView mWebView;
|
||||
private final int CHOOSE = 100;//Android 5.0以下的
|
||||
private final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
|
||||
private ValueCallback<Uri> mValueCallback;
|
||||
private ValueCallback<Uri[]> mValueCallback2;
|
||||
private FrameLayout rootView;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_webview_cs;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
super.main();
|
||||
Bus.getOn(this);
|
||||
String url = getIntent().getStringExtra(Constants.URL);
|
||||
L.e("H5-------->" + url);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
rootView = findViewById(R.id.webView_root);
|
||||
mWebView = findViewById(R.id.webView);
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
/*params.topMargin = DpUtil.dp2px(1);
|
||||
if (getNavigationBarHeight(mContext) != 0) {
|
||||
params.bottomMargin = getNavigationBarHeight(mContext);
|
||||
}*/
|
||||
//mWebView.setLayoutParams(params);
|
||||
// mWebView.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
setTitle(view.getTitle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
||||
super.onReceivedError(view, errorCode, description, failingUrl);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||
super.onReceivedHttpError(view, request, errorResponse);
|
||||
// 这个方法在6.0才出现
|
||||
int statusCode = errorResponse.getStatusCode();
|
||||
Log.e("WebView", "code = " + statusCode + " failingUrl:" + request.getUrl());
|
||||
}
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
Intent intent = fileChooserParams.createIntent();
|
||||
startActivityForResult(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject");
|
||||
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
String appCachePath = mContext.getCacheDir().getAbsolutePath();
|
||||
// mWebView.getSettings().setAppCachePath(appCachePath);
|
||||
mWebView.getSettings().setAllowFileAccess(true);
|
||||
//mWebView.getSettings().setUseWideViewPort(true); // 关键点
|
||||
mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件
|
||||
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
mWebView.loadUrl(url);
|
||||
AndroidBug5497Workaround.assistActivity(mWebView);
|
||||
}
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(Intent.createChooser(intent, mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
switch (requestCode) {
|
||||
case CHOOSE://5.0以下选择图片后的回调
|
||||
processResult(resultCode, intent);
|
||||
break;
|
||||
case CHOOSE_ANDROID_5://5.0以上选择图片后的回调
|
||||
processResultAndroid5(resultCode, intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void processResult(int resultCode, Intent intent) {
|
||||
if (mValueCallback == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
Uri result = intent.getData();
|
||||
mValueCallback.onReceiveValue(result);
|
||||
} else {
|
||||
mValueCallback.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback = null;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void processResultAndroid5(int resultCode, Intent intent) {
|
||||
if (mValueCallback2 == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
mValueCallback2.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
|
||||
} else {
|
||||
mValueCallback2.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback2 = null;
|
||||
}
|
||||
|
||||
protected boolean canGoBack() {
|
||||
if (!isKefu(mWebView.getUrl()==null?"":mWebView.getUrl())) {
|
||||
mWebView.loadUrl("javascript:userBackShowPraise()");
|
||||
return false;
|
||||
}
|
||||
// return mWebView != null && mWebView.canGoBack();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!isKefu(mWebView.getUrl()==null?"":mWebView.getUrl())) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
//ToastUtil.showDebug("调用js userBackShowPraise");
|
||||
mWebView.loadUrl("javascript:userBackShowPraise()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
onBackPressed();
|
||||
return false;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.destroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
|
||||
if (!TextUtils.isEmpty(event.getMethod())) {
|
||||
if (TextUtils.equals(event.getMethod(), "androidOpeningNoble")) {
|
||||
try {
|
||||
SVGAImageView svga = new SVGAImageView(mContext);
|
||||
rootView.addView(svga);
|
||||
new SVGAParser(mContext).parse(new URL(event.getSvg()), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
svga.setVisibility(View.VISIBLE);
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
svga.setImageDrawable(drawable);
|
||||
svga.setLoops(1);
|
||||
SVGAViewUtils.playEndClear(svga);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
svga.setCallback(new SVGACallback() {
|
||||
@Override
|
||||
public void onPause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinished() {
|
||||
svga.clear();
|
||||
svga.setVisibility(View.GONE);
|
||||
rootView.removeView(svga);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRepeat() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStep(int i, double v) {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (event.getMethod().equals("androidInviteShare")) {
|
||||
new InvitePopDialog(mContext)
|
||||
.setUrl(event.getData())
|
||||
.showDialog();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/29.
|
||||
* 设置昵称
|
||||
*/
|
||||
|
||||
public class EditNameActivity extends AbsActivity implements View.OnClickListener {
|
||||
|
||||
private EditText mEditText;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_edit_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.edit_profile_update_nickname));
|
||||
mEditText = (EditText) findViewById(R.id.edit);
|
||||
mEditText.setFilters(new InputFilter[]{
|
||||
new InputFilter.LengthFilter(8)
|
||||
});
|
||||
findViewById(R.id.btn_save).setOnClickListener(this);
|
||||
String content = getIntent().getStringExtra(Constants.NICK_NAME);
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
if (content.length() > 8) {
|
||||
content = content.substring(0, 8);
|
||||
}
|
||||
mEditText.setText(content);
|
||||
mEditText.setSelection(content.length());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
final String content = mEditText.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
ToastUtil.show(R.string.edit_profile_name_empty);
|
||||
return;
|
||||
}
|
||||
MainHttpUtil.updateFields("{\"user_nicename\":\"" + content + "\"}", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
if (info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
ToastUtil.show(obj.getString("msg"));
|
||||
UserBean u = CommonAppConfig.getInstance().getUserBean();
|
||||
if (u != null) {
|
||||
u.setUserNiceName(content);
|
||||
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
|
||||
v2TIMUserFullInfo.setNickname(content);
|
||||
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
}
|
||||
});
|
||||
}
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra(Constants.NICK_NAME, content);
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
}else if (code == 2001){
|
||||
//余额不足,跳转支付页面
|
||||
RouteUtil.forwardMyCoin(mContext);
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.UPDATE_FIELDS);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,804 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.lxj.xpopup.interfaces.XPopupCallback;
|
||||
import com.lzy.okgo.model.Response;
|
||||
import com.sahooz.library.Country;
|
||||
import com.sahooz.library.CountryPicker;
|
||||
import com.sahooz.library.OnPick;
|
||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.event.UpdateFieldEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.JsonBean;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.ActivityResultCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.CityUtil;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.CompleteInformationPopup;
|
||||
import com.yunbao.common.views.UpdateSexPopup;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.event.EditProfileEvent;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.qqtheme.framework.entity.City;
|
||||
import cn.qqtheme.framework.entity.County;
|
||||
import cn.qqtheme.framework.entity.Province;
|
||||
import cn.qqtheme.framework.picker.AddressPicker;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/29.
|
||||
* 我的 编辑资料
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_EDITPROFILE)
|
||||
public class EditProfileActivity extends AbsActivity {
|
||||
|
||||
private ImageView mAvatar;
|
||||
private TextView mName;
|
||||
private TextView mSign;
|
||||
private TextView mBirthday;
|
||||
private TextView mSex;
|
||||
private TextView mCity;
|
||||
private TextView tv_bind_phone;
|
||||
private ProcessImageUtil mImageUtil;
|
||||
private UserBean mUserBean;
|
||||
private String mProvinceVal;
|
||||
private String mCityVal;
|
||||
private String mZoneVal;
|
||||
private boolean isInto = true;
|
||||
private String isBind = "0", mobile = "";
|
||||
private boolean isName = false;
|
||||
private View viewProgress1, viewProgress2, viewProgress3;
|
||||
private FrameLayout completeInformation, completeInformation1, completeInformation2, completeInformation3;
|
||||
private TextView information, information1, information2, information3, submit;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_edit_profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
setTitle(mContext.getString(R.string.edit_profile));
|
||||
mAvatar = (ImageView) findViewById(R.id.avatar);
|
||||
mName = (TextView) findViewById(R.id.name);
|
||||
mSign = (TextView) findViewById(R.id.sign);
|
||||
mBirthday = (TextView) findViewById(R.id.birthday);
|
||||
mSex = (TextView) findViewById(R.id.sex);
|
||||
mCity = (TextView) findViewById(R.id.city);
|
||||
tv_bind_phone = (TextView) findViewById(R.id.tv_bind_phone);
|
||||
viewProgress1 = findViewById(R.id.view_progress1);
|
||||
viewProgress2 = findViewById(R.id.view_progress2);
|
||||
viewProgress3 = findViewById(R.id.view_progress3);
|
||||
completeInformation = findViewById(R.id.complete_information);
|
||||
completeInformation1 = findViewById(R.id.complete_information1);
|
||||
completeInformation2 = findViewById(R.id.complete_information2);
|
||||
completeInformation3 = findViewById(R.id.complete_information3);
|
||||
information = findViewById(R.id.information);
|
||||
information1 = findViewById(R.id.information1);
|
||||
information2 = findViewById(R.id.information2);
|
||||
information3 = findViewById(R.id.information3);
|
||||
submit = findViewById(R.id.submit);
|
||||
mImageUtil = new ProcessImageUtil(this);
|
||||
mImageUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
@Override
|
||||
public void beforeCamera() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
|
||||
if (file != null) {
|
||||
System.err.println("头像---->收到头像文件 file = "+file.getAbsolutePath()+" | length = "+file.length());
|
||||
if (file.getName().contains(".gif")){
|
||||
ToastUtil.show(WordUtil.isNewZh()?"暫不支持該文件":"This file is not supported");
|
||||
}else {
|
||||
ImgLoader.display(mContext, file, mAvatar);
|
||||
MainHttpUtil.updateAvatar(file, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
System.err.println("头像---->上传头像文件成功");
|
||||
Log.e("updateAvatar", "code:" + code + " msg:" + msg + " info[0]:" + info[0].toString());
|
||||
if (code == 0 && info.length > 0) {
|
||||
ToastUtil.show(R.string.edit_profile_update_avatar_success);
|
||||
UserBean bean = CommonAppConfig.getInstance().getUserBean();
|
||||
if (bean != null) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
bean.setAvatar(obj.getString("avatar"));
|
||||
bean.setAvatarThumb(obj.getString("avatarThumb"));
|
||||
mUserBean.setAvatar(obj.getString("avatar"));
|
||||
mUserBean.setAvatarThumb(obj.getString("avatarThumb"));
|
||||
|
||||
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
|
||||
v2TIMUserFullInfo.setFaceUrl(obj.getString("avatarThumb"));
|
||||
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
}
|
||||
});
|
||||
}
|
||||
EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<JsonBean> response) {
|
||||
super.onError(response);
|
||||
Log.e("updateAvatar", "onFailure");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
mUserBean = CommonAppConfig.getInstance().getUserBean();
|
||||
if (mUserBean != null) {
|
||||
showData(mUserBean);
|
||||
} else {
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean u) {
|
||||
mUserBean = u;
|
||||
showData(u);
|
||||
}
|
||||
});
|
||||
}
|
||||
ViewClicksAntiShake.clicksAntiShake(submit, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
LiveNetManager.get(mContext).
|
||||
userInfoTask(new com.yunbao.common.http.base.HttpCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
ToastUtil.show(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
new XPopup.Builder(mContext)
|
||||
.setPopupCallback(new XPopupCallback() {
|
||||
@Override
|
||||
public void onCreated(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(BasePopupView popupView) {
|
||||
submit.setText(R.string.live_task_item_complete_true);
|
||||
submit.setBackgroundResource(R.mipmap.bg_submit_cancel);
|
||||
submit.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
userModel.seUserInfoComplete(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDismiss(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed(BasePopupView popupView) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickOutside(BasePopupView popupView) {
|
||||
|
||||
}
|
||||
})
|
||||
.asCustom(new CompleteInformationPopup(mContext, false,
|
||||
new CompleteInformationPopup.CompleteInformationCallBack() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSure() {
|
||||
|
||||
}
|
||||
}))
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (userModel.getUserInfoComplete() == 1) {
|
||||
finish();
|
||||
} else {
|
||||
new XPopup.Builder(mContext)
|
||||
.asCustom(new CompleteInformationPopup(mContext, true, new CompleteInformationPopup.CompleteInformationCallBack() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSure() {
|
||||
finish();
|
||||
}
|
||||
}))
|
||||
.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void getTaskType() {
|
||||
MainHttpUtil.getUserFrontTaskType(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (info != null) {
|
||||
if (info.length > 0) {
|
||||
if (info[0].equals("0")) {
|
||||
isInto = false;
|
||||
} else {
|
||||
isInto = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void editProfileClick(View v) {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_avatar) {
|
||||
if (isInto) {
|
||||
editAvatar();
|
||||
} else {
|
||||
showTaskDialog();
|
||||
}
|
||||
} else if (i == R.id.btn_name) {
|
||||
if (isInto) {
|
||||
forwardName();
|
||||
isName = true;
|
||||
} else {
|
||||
showTaskDialog();
|
||||
}
|
||||
|
||||
} else if (i == R.id.btn_sign) {
|
||||
if (isInto) {
|
||||
forwardSign();
|
||||
} else {
|
||||
showTaskDialog();
|
||||
}
|
||||
} else if (i == R.id.btn_birthday) {
|
||||
editBirthday();
|
||||
|
||||
} else if (i == R.id.btn_sex) {
|
||||
// forwardSex();
|
||||
new XPopup.Builder(mContext)
|
||||
.asCustom(new UpdateSexPopup(mContext, userModel.getSex(), new UpdateSexPopup.UpdateSexCallBack() {
|
||||
@Override
|
||||
public void onSex(int sex) {
|
||||
MainHttpUtil.updateFields("{\"sex\":\"" + sex + "\"}", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
ToastUtil.show(obj.getString("msg"));
|
||||
userModel.setSex(sex);
|
||||
showData(userModel);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}))
|
||||
.show();
|
||||
} else if (i == R.id.btn_city) {
|
||||
CountryPicker.newInstance(null, new OnPick() {
|
||||
@Override
|
||||
public void onPick(final Country country) {
|
||||
mCity.setText(country.name);
|
||||
MainHttpUtil.updateFields("{\"location\":\"" + country.name + "\"}", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
if (info.length > 0) {
|
||||
UserBean u = CommonAppConfig.getInstance().getUserBean();
|
||||
if (u != null) {
|
||||
u.setLocation(country.name);
|
||||
}
|
||||
if (userModel != null) {
|
||||
userModel.setLocation(country.name);
|
||||
}
|
||||
|
||||
showData(userModel);
|
||||
EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
}
|
||||
ToastUtil.show(obj.getString("msg"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}).show(getSupportFragmentManager(), "country");
|
||||
} else if (i == R.id.rt_bind_phone) {
|
||||
startActivity(new Intent(mContext, BindUserActivity.class)
|
||||
.putExtra("uid", CommonAppConfig.getInstance().getUid())
|
||||
.putExtra("token", CommonAppConfig.getInstance().getToken())
|
||||
.putExtra("isBind", isBind)
|
||||
.putExtra("mobile", mobile));
|
||||
}
|
||||
}
|
||||
|
||||
private void showTaskDialog() {
|
||||
final Dialog dialog = new Dialog(EditProfileActivity.this, com.yunbao.live.R.style.dialog);
|
||||
dialog.setContentView(R.layout.dialog_task);
|
||||
dialog.setCancelable(true);
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
|
||||
dialog.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.findViewById(R.id.tv_into).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=task&a=index&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&tabIndex=1";
|
||||
WebViewActivity.forward(mContext, url,false);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void editAvatar() {
|
||||
DialogUitl.showStringArrayDialog(mContext, new Integer[]{
|
||||
R.string.camera, R.string.alumb, R.string.me_edit_avatar_system}, new DialogUitl.StringArrayDialogCallback() {
|
||||
@Override
|
||||
public void onItemClick(String text, int tag) {
|
||||
if ((Integer.parseInt(IMLoginManager.get(mContext).getUserInfo().getLevel()) < 5 && tag != R.string.me_edit_avatar_system)//等级小于5并且不是选择系统头像
|
||||
&& !IMLoginManager.get(mContext).getUserInfo().anchorUserType()//非主播
|
||||
) {
|
||||
ToastUtil.show(R.string.me_edit_avatar_system_tip);
|
||||
return;
|
||||
}
|
||||
if (tag == R.string.camera) {
|
||||
mImageUtil.getImageByCamera();
|
||||
} else if (tag == R.string.alumb) {
|
||||
mImageUtil.getImageByAlumb();
|
||||
} else {
|
||||
RouteUtil.forwardUserAvatarSelect();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void forwardName() {
|
||||
if (mUserBean == null) {
|
||||
return;
|
||||
}
|
||||
Constants.myIntoIndex = 2;
|
||||
Intent intent = new Intent(mContext, MyWebViewActivity2.class);
|
||||
intent.putExtra(Constants.URL, CommonAppConfig.HOST + "/h5/table/Modify-information.html" + "?token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : 0));
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void forwardSign() {
|
||||
if (mUserBean == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(mContext, EditSignActivity.class);
|
||||
intent.putExtra(Constants.SIGN, mUserBean.getSignature());
|
||||
mImageUtil.startActivityForResult(intent, new ActivityResultCallback() {
|
||||
@Override
|
||||
public void onSuccess(Intent intent) {
|
||||
if (intent != null) {
|
||||
String sign = intent.getStringExtra(Constants.SIGN);
|
||||
mUserBean.setSignature(sign);
|
||||
mSign.setText(sign);
|
||||
EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void editBirthday() {
|
||||
if (mUserBean == null) {
|
||||
return;
|
||||
}
|
||||
DialogUitl.showDatePickerDialog(mContext, new DialogUitl.DataPickerCallback() {
|
||||
@Override
|
||||
public void onConfirmClick(final String date) {
|
||||
MainHttpUtil.updateFields("{\"birthday\":\"" + date + "\"}", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
if (info.length > 0) {
|
||||
ToastUtil.show(JSON.parseObject(info[0]).getString("msg"));
|
||||
mUserBean.setBirthday(date);
|
||||
mBirthday.setText(date);
|
||||
|
||||
if (userModel != null) {
|
||||
userModel.setBirthday(date);
|
||||
}
|
||||
|
||||
showData(userModel);
|
||||
EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void forwardSex() {
|
||||
if (mUserBean == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(mContext, EditSexActivity.class);
|
||||
intent.putExtra(Constants.SEX, mUserBean.getSex());
|
||||
mImageUtil.startActivityForResult(intent, new ActivityResultCallback() {
|
||||
@Override
|
||||
public void onSuccess(Intent intent) {
|
||||
if (intent != null) {
|
||||
int sex = intent.getIntExtra(Constants.SEX, 0);
|
||||
if (sex == 1) {
|
||||
mSex.setText(R.string.sex_male);
|
||||
mUserBean.setSex(sex);
|
||||
} else if (sex == 2) {
|
||||
mSex.setText(R.string.sex_female);
|
||||
mUserBean.setSex(sex);
|
||||
}
|
||||
EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (mImageUtil != null) {
|
||||
mImageUtil.release();
|
||||
}
|
||||
MainHttpUtil.cancel(MainHttpConsts.UPDATE_AVATAR);
|
||||
MainHttpUtil.cancel(MainHttpConsts.UPDATE_FIELDS);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEditProfileEvent(EditProfileEvent event) {
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean u) {
|
||||
showData(u);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private UserBean userModel;
|
||||
|
||||
private void showData(UserBean u) {
|
||||
userModel = u;
|
||||
int index = 0;
|
||||
String birthday = u.getBirthday();
|
||||
String location = u.getLocation();
|
||||
String bindPhone = u.getMobile();
|
||||
String sex = "";
|
||||
if (u.getSex() == 1) {
|
||||
sex = mContext.getString(R.string.sex_male);
|
||||
} else if (u.getSex() == 2) {
|
||||
sex = mContext.getString(R.string.sex_female);
|
||||
}
|
||||
if (!TextUtils.isEmpty(bindPhone)) {
|
||||
index = index + 1;
|
||||
}
|
||||
if (!TextUtils.isEmpty(location)) {
|
||||
index = index + 1;
|
||||
}
|
||||
if (!TextUtils.isEmpty(birthday)) {
|
||||
index = index + 1;
|
||||
}
|
||||
if (!TextUtils.isEmpty(sex)) {
|
||||
index = index + 1;
|
||||
}
|
||||
if (index == 0) {
|
||||
completeInformation.setBackgroundResource(R.mipmap.bg_complete_information_progress);
|
||||
completeInformation1.setBackgroundResource(R.mipmap.bg_complete_information_progress);
|
||||
completeInformation2.setBackgroundResource(R.mipmap.bg_complete_information_progress);
|
||||
completeInformation3.setBackgroundResource(R.mipmap.bg_complete_information_progress);
|
||||
information.setVisibility(View.VISIBLE);
|
||||
information1.setVisibility(View.VISIBLE);
|
||||
information2.setVisibility(View.VISIBLE);
|
||||
information3.setVisibility(View.VISIBLE);
|
||||
viewProgress1.setBackgroundColor(Color.parseColor("#DEE4F1"));
|
||||
viewProgress2.setBackgroundColor(Color.parseColor("#DEE4F1"));
|
||||
viewProgress3.setBackgroundColor(Color.parseColor("#DEE4F1"));
|
||||
submit.setText(R.string.to_complete);
|
||||
submit.setTextColor(Color.parseColor("#ffffff"));
|
||||
} else if (index == 1) {
|
||||
completeInformation.setBackgroundResource(R.mipmap.bg_complete_information_progress2);
|
||||
completeInformation1.setBackgroundResource(R.mipmap.bg_complete_information_progress);
|
||||
completeInformation2.setBackgroundResource(R.mipmap.bg_complete_information_progress);
|
||||
completeInformation3.setBackgroundResource(R.mipmap.bg_complete_information_progress);
|
||||
information.setVisibility(View.INVISIBLE);
|
||||
information1.setVisibility(View.VISIBLE);
|
||||
information2.setVisibility(View.VISIBLE);
|
||||
information3.setVisibility(View.VISIBLE);
|
||||
viewProgress1.setBackgroundColor(Color.parseColor("#DEE4F1"));
|
||||
viewProgress2.setBackgroundColor(Color.parseColor("#DEE4F1"));
|
||||
viewProgress3.setBackgroundColor(Color.parseColor("#DEE4F1"));
|
||||
submit.setText(R.string.to_complete);
|
||||
submit.setTextColor(Color.parseColor("#ffffff"));
|
||||
} else if (index == 2) {
|
||||
information.setVisibility(View.INVISIBLE);
|
||||
information1.setVisibility(View.INVISIBLE);
|
||||
information2.setVisibility(View.VISIBLE);
|
||||
information3.setVisibility(View.VISIBLE);
|
||||
completeInformation1.setBackgroundResource(R.mipmap.bg_complete_information_progress2);
|
||||
completeInformation.setBackgroundResource(R.mipmap.bg_complete_information_progress2);
|
||||
completeInformation2.setBackgroundResource(R.mipmap.bg_complete_information_progress);
|
||||
completeInformation3.setBackgroundResource(R.mipmap.bg_complete_information_progress);
|
||||
viewProgress1.setBackgroundColor(Color.parseColor("#FFE5D0"));
|
||||
viewProgress2.setBackgroundColor(Color.parseColor("#DEE4F1"));
|
||||
viewProgress3.setBackgroundColor(Color.parseColor("#DEE4F1"));
|
||||
submit.setText(R.string.to_complete);
|
||||
submit.setTextColor(Color.parseColor("#ffffff"));
|
||||
} else if (index == 3) {
|
||||
information.setVisibility(View.INVISIBLE);
|
||||
information1.setVisibility(View.INVISIBLE);
|
||||
information2.setVisibility(View.INVISIBLE);
|
||||
information3.setVisibility(View.VISIBLE);
|
||||
completeInformation.setBackgroundResource(R.mipmap.bg_complete_information_progress2);
|
||||
completeInformation1.setBackgroundResource(R.mipmap.bg_complete_information_progress2);
|
||||
completeInformation2.setBackgroundResource(R.mipmap.bg_complete_information_progress2);
|
||||
completeInformation3.setBackgroundResource(R.mipmap.bg_complete_information_progress);
|
||||
viewProgress1.setBackgroundColor(Color.parseColor("#FFE5D0"));
|
||||
viewProgress2.setBackgroundColor(Color.parseColor("#FFE5D0"));
|
||||
viewProgress3.setBackgroundColor(Color.parseColor("#DEE4F1"));
|
||||
submit.setText(R.string.to_complete);
|
||||
submit.setTextColor(Color.parseColor("#ffffff"));
|
||||
} else if (index == 4) {
|
||||
information.setVisibility(View.INVISIBLE);
|
||||
information1.setVisibility(View.INVISIBLE);
|
||||
information2.setVisibility(View.INVISIBLE);
|
||||
information3.setVisibility(View.INVISIBLE);
|
||||
completeInformation.setBackgroundResource(R.mipmap.bg_complete_information_progress2);
|
||||
completeInformation1.setBackgroundResource(R.mipmap.bg_complete_information_progress2);
|
||||
completeInformation2.setBackgroundResource(R.mipmap.bg_complete_information_progress2);
|
||||
completeInformation3.setBackgroundResource(R.mipmap.bg_complete_information_progress2);
|
||||
viewProgress1.setBackgroundColor(Color.parseColor("#FFE5D0"));
|
||||
viewProgress2.setBackgroundColor(Color.parseColor("#FFE5D0"));
|
||||
viewProgress3.setBackgroundColor(Color.parseColor("#FFE5D0"));
|
||||
submit.setText(R.string.to_receive);
|
||||
submit.setTextColor(Color.parseColor("#935902"));
|
||||
submit.setEnabled(true);
|
||||
}
|
||||
ImgLoader.displayAvatar(mContext, u.getAvatar(), mAvatar);
|
||||
mName.setText(u.getUserNiceName());
|
||||
mSign.setText(u.getSignature());
|
||||
mBirthday.setText(u.getBirthday());
|
||||
if (u.getSex() == 0) {
|
||||
mSex.setText("");
|
||||
} else if (u.getSex() == 1) {
|
||||
mSex.setText(R.string.sex_male);
|
||||
} else if (u.getSex() == 2) {
|
||||
mSex.setText(R.string.sex_female);
|
||||
}
|
||||
|
||||
mCity.setText(u.getLocation());
|
||||
if ("1".equals(u.getIs_bind())) {
|
||||
mobile = u.getMobile();
|
||||
tv_bind_phone.setText(mobile);
|
||||
isBind = "1";
|
||||
} else {
|
||||
tv_bind_phone.setHint(getResources().getString(R.string.bind_phone_text));
|
||||
isBind = "0";
|
||||
}
|
||||
if (u.getUserInfoComplete() == 1) {
|
||||
submit.setText(R.string.live_task_item_complete_true);
|
||||
submit.setBackgroundResource(R.mipmap.bg_submit_cancel);
|
||||
submit.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
submit.setEnabled(false);
|
||||
} else {
|
||||
if (index < 4) {
|
||||
submit.setText(R.string.to_complete);
|
||||
submit.setBackgroundResource(R.mipmap.bg_submit);
|
||||
submit.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
submit.setEnabled(false);
|
||||
} else {
|
||||
submit.setText(R.string.to_receive);
|
||||
submit.setBackgroundResource(R.mipmap.bg_submit);
|
||||
submit.setTextColor(Color.parseColor("#935902"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 选择城市
|
||||
*/
|
||||
private void chooseCity() {
|
||||
ArrayList<Province> list = CityUtil.getInstance().getCityList();
|
||||
if (list == null || list.size() == 0) {
|
||||
final Dialog loading = DialogUitl.loadingDialog(mContext);
|
||||
loading.show();
|
||||
CityUtil.getInstance().getCityListFromAssets(new CommonCallback<ArrayList<Province>>() {
|
||||
@Override
|
||||
public void callback(ArrayList<Province> newList) {
|
||||
loading.dismiss();
|
||||
if (newList != null) {
|
||||
showChooseCityDialog(newList);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
showChooseCityDialog(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择城市
|
||||
*/
|
||||
private void showChooseCityDialog(ArrayList<Province> list) {
|
||||
String province = mProvinceVal;
|
||||
String city = mCityVal;
|
||||
String district = mZoneVal;
|
||||
if (TextUtils.isEmpty(province)) {
|
||||
province = CommonAppConfig.getInstance().getProvince();
|
||||
}
|
||||
if (TextUtils.isEmpty(city)) {
|
||||
city = CommonAppConfig.getInstance().getCity();
|
||||
}
|
||||
if (TextUtils.isEmpty(district)) {
|
||||
district = CommonAppConfig.getInstance().getDistrict();
|
||||
}
|
||||
DialogUitl.showCityChooseDialog(this, list, province, city, district, new AddressPicker.OnAddressPickListener() {
|
||||
@Override
|
||||
public void onAddressPicked(Province province, final City city, County county) {
|
||||
String provinceName = province.getAreaName();
|
||||
String cityName = city.getAreaName();
|
||||
String zoneName = county.getAreaName();
|
||||
mProvinceVal = provinceName;
|
||||
mCityVal = cityName;
|
||||
mZoneVal = zoneName;
|
||||
final String location = StringUtil.contact(mProvinceVal, mCityVal, mZoneVal);
|
||||
if (mCity != null) {
|
||||
mCity.setText(location);
|
||||
}
|
||||
|
||||
MainHttpUtil.updateFields("{\"location\":\"" + location + "\"}", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
if (info.length > 0) {
|
||||
UserBean u = CommonAppConfig.getInstance().getUserBean();
|
||||
if (u != null) {
|
||||
u.setLocation(location);
|
||||
}
|
||||
EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
}
|
||||
ToastUtil.show(obj.getString("msg"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (Constants.isShowPage != -1) {
|
||||
finish();
|
||||
}
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean u) {
|
||||
if (u != null && "1".equals(u.getIs_bind())) {
|
||||
mobile = u.getMobile();
|
||||
tv_bind_phone.setText(mobile);
|
||||
isBind = "1";
|
||||
} else {
|
||||
tv_bind_phone.setHint(getResources().getString(R.string.bind_phone_text));
|
||||
isBind = "0";
|
||||
}
|
||||
}
|
||||
});
|
||||
// getTaskType();
|
||||
if (isName) {
|
||||
isName = false;
|
||||
MainHttpUtil.getBaseInfo(CommonAppConfig.getInstance().getUid(), CommonAppConfig.getInstance().getToken(), new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
if (bean != null) {
|
||||
CommonAppConfig.getInstance().setLoginInfo(CommonAppConfig.getInstance().getUid(), CommonAppConfig.getInstance().getToken(), false);
|
||||
mUserBean = CommonAppConfig.getInstance().getUserBean();
|
||||
mName.setText(mUserBean.getUserNiceName());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.RadioButton;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/29.
|
||||
* 设置性别
|
||||
*/
|
||||
|
||||
public class EditSexActivity extends AbsActivity implements View.OnClickListener {
|
||||
|
||||
private RadioButton mBtnMale;
|
||||
private RadioButton mBtnFeMale;
|
||||
private int mSex;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_edit_sex;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.edit_profile_sex));
|
||||
mBtnMale = (RadioButton)findViewById(R.id.btn_male);
|
||||
mBtnFeMale = (RadioButton)findViewById(R.id.btn_female);
|
||||
mBtnMale.setOnClickListener(this);
|
||||
mBtnFeMale.setOnClickListener(this);
|
||||
mSex = getIntent().getIntExtra(Constants.SEX, Constants.SEX_MALE);
|
||||
if (mSex == Constants.SEX_FEMALE) {
|
||||
mBtnFeMale.setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(!canClick()){
|
||||
return;
|
||||
}
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_male) {
|
||||
setSex(Constants.SEX_MALE);
|
||||
|
||||
} else if (i == R.id.btn_female) {
|
||||
setSex(Constants.SEX_FEMALE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void setSex(int sex) {
|
||||
if (mSex == sex) {
|
||||
return;
|
||||
}
|
||||
mSex = sex;
|
||||
MainHttpUtil.updateFields("{\"sex\":\"" + sex + "\"}", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
ToastUtil.show(obj.getString("msg"));
|
||||
if (mSex == Constants.SEX_MALE) {
|
||||
mBtnMale.setChecked(true);
|
||||
} else {
|
||||
mBtnFeMale.setChecked(true);
|
||||
}
|
||||
UserBean u = CommonAppConfig.getInstance().getUserBean();
|
||||
if (u != null) {
|
||||
u.setSex(mSex);
|
||||
}
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra(Constants.SEX, mSex);
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.UPDATE_FIELDS);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/29.
|
||||
* 设置签名
|
||||
*/
|
||||
|
||||
public class EditSignActivity extends AbsActivity implements View.OnClickListener {
|
||||
|
||||
private EditText mEditText;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_edit_sign;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.edit_profile_update_sign));
|
||||
mEditText = (EditText) findViewById(R.id.edit);
|
||||
mEditText.setFilters(new InputFilter[]{
|
||||
new InputFilter.LengthFilter(20)
|
||||
});
|
||||
findViewById(R.id.btn_save).setOnClickListener(this);
|
||||
String content = getIntent().getStringExtra(Constants.SIGN);
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
if (content.length() > 20) {
|
||||
content = content.substring(0, 20);
|
||||
}
|
||||
mEditText.setText(content);
|
||||
mEditText.setSelection(content.length());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
final String content = mEditText.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
ToastUtil.show(R.string.edit_profile_sign_empty);
|
||||
return;
|
||||
}
|
||||
MainHttpUtil.updateFields("{\"signature\":\"" + content + "\"}", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
if (info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
ToastUtil.show(obj.getString("msg"));
|
||||
UserBean u = CommonAppConfig.getInstance().getUserBean();
|
||||
// if (u != null) {
|
||||
// u.setUserNiceName(content);
|
||||
// }
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra(Constants.SIGN, content);
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.UPDATE_FIELDS);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
754
main/src/main/java/com/yunbao/main/activity/EntryActivity.java
Normal file
@@ -0,0 +1,754 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.home_zdy_img_cn;
|
||||
import static com.yunbao.common.CommonAppContext.home_zdy_img_us;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.Signature;
|
||||
import android.graphics.Paint;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.Settings;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.DeviceUtils;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.facebook.AccessToken;
|
||||
import com.facebook.CallbackManager;
|
||||
import com.facebook.FacebookCallback;
|
||||
import com.facebook.FacebookException;
|
||||
import com.facebook.Profile;
|
||||
import com.facebook.ProfileTracker;
|
||||
import com.facebook.login.LoginManager;
|
||||
import com.facebook.login.LoginResult;
|
||||
import com.fm.openinstall.OpenInstall;
|
||||
import com.fm.openinstall.listener.AppInstallAdapter;
|
||||
import com.fm.openinstall.model.AppData;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignIn;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
|
||||
import com.google.android.gms.common.api.ApiException;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.linecorp.linesdk.Scope;
|
||||
import com.linecorp.linesdk.auth.LineAuthenticationParams;
|
||||
import com.linecorp.linesdk.auth.LineLoginApi;
|
||||
import com.linecorp.linesdk.auth.LineLoginResult;
|
||||
import com.twitter.sdk.android.core.Callback;
|
||||
import com.twitter.sdk.android.core.DefaultLogger;
|
||||
import com.twitter.sdk.android.core.Result;
|
||||
import com.twitter.sdk.android.core.Twitter;
|
||||
import com.twitter.sdk.android.core.TwitterAuthConfig;
|
||||
import com.twitter.sdk.android.core.TwitterAuthToken;
|
||||
import com.twitter.sdk.android.core.TwitterConfig;
|
||||
import com.twitter.sdk.android.core.TwitterException;
|
||||
import com.twitter.sdk.android.core.TwitterSession;
|
||||
import com.twitter.sdk.android.core.identity.TwitterLoginButton;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.FaceBookUpModel;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.LoginData;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.http.main.MainNetManager;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.dialog.LoginTipsDialog;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
|
||||
/**
|
||||
* 入口
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_ENTRY)
|
||||
public class EntryActivity extends AppCompatActivity {
|
||||
|
||||
private VideoView video_view;
|
||||
private ImageView btn_phone, btn_line, btn_twitter;
|
||||
private TextView btn_tip, btn_tip1, tv_customer;
|
||||
private TwitterLoginButton tt_login_button;
|
||||
private LinearLayout btn_google;
|
||||
public static Activity activity;
|
||||
private static String mLoginType = Constants.MOB_PHONE;//登录方式
|
||||
public String mPromoCode = "", UserID = "";//推广码
|
||||
|
||||
private String mUuidDevice = "";//手机唯一标识符
|
||||
private static boolean mFirstLogin;//是否是第一次登录
|
||||
private static boolean mShowInvite;//显示邀请码弹窗
|
||||
private static Context Contexts;
|
||||
private ImageView img_view;
|
||||
private GoogleSignInClient mGoogleSignInClient;
|
||||
private LinearLayout lt_btn_twitter, lt_btn_facebook, lt_customer;
|
||||
private String kefuUrl = "";
|
||||
private boolean mBtnClick = false;
|
||||
private Dialog loginLoadingDialog;
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void close(String str) {
|
||||
if ("close_login".equals(str)) {
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置透明状态栏
|
||||
*/
|
||||
private void setStatusBar() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Window window = getWindow();
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Get_hash_key() {
|
||||
PackageInfo info;
|
||||
try {
|
||||
info = getPackageManager().getPackageInfo("com.pandoralive.shayu", PackageManager.GET_SIGNATURES);
|
||||
for (Signature signature : info.signatures) {
|
||||
MessageDigest md;
|
||||
md = MessageDigest.getInstance("SHA");
|
||||
md.update(signature.toByteArray());
|
||||
String something = new String(Base64.encode(md.digest(), 0));
|
||||
//String something = new String(Base64.encodeBytes(md.digest()));
|
||||
Log.e("hash key", something);
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e1) {
|
||||
Log.e("name not found", e1.toString());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
Log.e("no such an algorithm", e.toString());
|
||||
} catch (Exception e) {
|
||||
Log.e("exception", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_entry);
|
||||
if (getIntent().getBooleanExtra("forwardEntry", false)) {
|
||||
IMLoginManager.get(this).logout(this);
|
||||
ToastUtil.show(R.string.login_invalid);
|
||||
}
|
||||
Get_hash_key();
|
||||
activity = this;
|
||||
Contexts = this;
|
||||
setStatusBar();
|
||||
lt_btn_facebook = findViewById(R.id.lt_btn_facebook);
|
||||
lt_btn_twitter = findViewById(R.id.lt_btn_twitter);
|
||||
btn_tip = findViewById(R.id.btn_tip);
|
||||
btn_tip1 = findViewById(R.id.btn_tip1);
|
||||
|
||||
img_view = findViewById(R.id.img_view);
|
||||
|
||||
btn_google = findViewById(R.id.btn_google);
|
||||
btn_twitter = findViewById(R.id.btn_twitter);
|
||||
tt_login_button = findViewById(R.id.tt_login_button);
|
||||
|
||||
tv_customer = findViewById(R.id.tv_customer);
|
||||
btn_phone = findViewById(R.id.btn_phone);
|
||||
btn_line = findViewById(R.id.btn_line);
|
||||
lt_customer = findViewById(R.id.lt_customer);
|
||||
|
||||
btn_tip.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
|
||||
btn_tip.getPaint().setAntiAlias(true);
|
||||
|
||||
btn_tip1.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
|
||||
btn_tip1.getPaint().setAntiAlias(true);
|
||||
|
||||
btn_tip1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
WebViewActivity.forward(EntryActivity.this, HtmlConfig.LOGIN_PRIVCAY+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"),false);
|
||||
}
|
||||
});
|
||||
|
||||
btn_tip.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
WebViewActivity.forward(EntryActivity.this, HtmlConfig.LOGIN_PRIVCAY1+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"),false);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
btn_phone.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LoginTipsDialog loginTipsDialog = new LoginTipsDialog();
|
||||
loginTipsDialog.show(getSupportFragmentManager(), "LoginTipsDialog");
|
||||
}
|
||||
});
|
||||
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
getPromoCode();
|
||||
getUuidDevice();
|
||||
video_view = findViewById(R.id.video_view);
|
||||
video_view.setVideoPath(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.login_video) + "");
|
||||
video_view.start();
|
||||
video_view.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
video_view.setVideoPath(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.login_video) + "");
|
||||
video_view.start();
|
||||
}
|
||||
});
|
||||
video_view.setOnErrorListener(new MediaPlayer.OnErrorListener() {
|
||||
@Override
|
||||
public boolean onError(MediaPlayer mp, int what, int extra) {
|
||||
video_view.stopPlayback(); //播放异常,则停止播放,防止弹窗使界面阻塞
|
||||
img_view.setVisibility(View.VISIBLE);
|
||||
video_view.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
lt_btn_facebook.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (isBtnClick()) {
|
||||
return;
|
||||
}
|
||||
timerOutBtn(view);
|
||||
MainNetManager.get(EntryActivity.this)
|
||||
.FaceBookUp(new com.yunbao.common.http.base.HttpCallback<FaceBookUpModel>() {
|
||||
@Override
|
||||
public void onSuccess(FaceBookUpModel data) {
|
||||
if (data.getType().equals("0")) {
|
||||
LoginManager.getInstance().logInWithReadPermissions(EntryActivity.this, Arrays.asList("public_profile"));
|
||||
} else {
|
||||
WebViewActivity.forward(EntryActivity.this, data.getLink() + "?",false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(WordUtil.isNewZh()?"抱歉!出錯了!":"i \\'m sorry! An error occurred");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
|
||||
@Override
|
||||
public void onSuccess(LoginResult loginResult) {
|
||||
updateUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(FacebookException error) {
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
});
|
||||
|
||||
googleLoginSet();
|
||||
twitterLoginSet();
|
||||
|
||||
btn_google.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isBtnClick()) {
|
||||
return;
|
||||
}
|
||||
timerOutBtn(v);
|
||||
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
|
||||
startActivityForResult(signInIntent, 1002);
|
||||
}
|
||||
});
|
||||
|
||||
lt_btn_twitter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isBtnClick()) {
|
||||
return;
|
||||
}
|
||||
timerOutBtn(v);
|
||||
tt_login_button.performClick();
|
||||
}
|
||||
});
|
||||
|
||||
tt_login_button.setCallback(new Callback<TwitterSession>() {
|
||||
@Override
|
||||
public void success(Result<TwitterSession> result) {
|
||||
// Do something with result, which provides a TwitterSession for making API calls
|
||||
//result里面包含了用户的信息,我们可以从中取出token,tokenSecret
|
||||
//(如果我们有自己的后台服务器,发送这两个到我们自己的后台,后台再去验证)
|
||||
TwitterAuthToken authToken = result.data.getAuthToken();
|
||||
String token = authToken.token;
|
||||
String appId = "24315541";
|
||||
String tokenSecret = authToken.secret;
|
||||
|
||||
final String userName = result.data.getUserName();
|
||||
|
||||
LoginData data = new LoginData();
|
||||
data.setAvatar("");
|
||||
data.setNickName(userName);
|
||||
data.setOpenID(token);
|
||||
data.setType("twitter");
|
||||
|
||||
loginBuyThird(data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failure(TwitterException exception) {
|
||||
Log.i("Log", "TwitterException = " + exception);
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
});
|
||||
findViewById(R.id.btn_line).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (isBtnClick()) {
|
||||
return;
|
||||
}
|
||||
timerOutBtn(view);
|
||||
try {
|
||||
// App-to-app login
|
||||
Intent loginIntent = LineLoginApi.getLoginIntent(
|
||||
view.getContext(),
|
||||
"1657504168",
|
||||
new LineAuthenticationParams.Builder()
|
||||
.scopes(Arrays.asList(Scope.PROFILE))
|
||||
// .nonce("<a randomly-generated string>") // nonce can be used to improve security
|
||||
.build());
|
||||
startActivityForResult(loginIntent, 1001);
|
||||
} catch (Exception e) {
|
||||
Log.e("ERROR", e.toString());
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
getUrl();
|
||||
|
||||
lt_customer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!"".equals(kefuUrl)) {
|
||||
Constants.LoginKefu = true;
|
||||
// WebViewActivity.forward(EntryActivity.this, kefuUrl, false);
|
||||
RouteUtil.forwardCustomerService(kefuUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getUrl() {
|
||||
MainHttpUtil.getCustomerService(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (info != null) {
|
||||
if (info.length > 0) {
|
||||
kefuUrl = info[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void twitterLoginSet() {
|
||||
TwitterConfig config = new TwitterConfig.Builder(this)
|
||||
.logger(new DefaultLogger(Log.DEBUG))
|
||||
.twitterAuthConfig(new TwitterAuthConfig(getResources().getString(R.string.twitter_key), getResources().getString(R.string.twitter_secret)))
|
||||
.debug(true)
|
||||
.build();
|
||||
Twitter.initialize(config);
|
||||
}
|
||||
|
||||
private void googleLoginSet() {
|
||||
//TODO Google登录
|
||||
//配置登录以请求用户的ID,电子邮件地址和基本配置文件.ID和基本配置文件包含在DEFAULT_SIGN_IN中.
|
||||
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
|
||||
.requestEmail()
|
||||
// .requestIdToken("AIzaSyDVnuGnQzjI_vDrxh20Hv_S1OMUD7Vp3zU")
|
||||
.build();
|
||||
//使用gso指定的选项构建一个GoogleSignInClient.
|
||||
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
|
||||
|
||||
}
|
||||
|
||||
private void requestPermission() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {//30
|
||||
// 先判断有没有权限
|
||||
if (!Environment.isExternalStorageManager()) {
|
||||
//跳转到设置界面引导用户打开
|
||||
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
|
||||
intent.setData(Uri.parse("package:" + getPackageName()));
|
||||
startActivityForResult(intent, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CallbackManager callbackManager = CallbackManager.Factory.create();
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
Log.i("ttts1", requestCode + "a " + resultCode);
|
||||
|
||||
if (requestCode == 1001) {//line登录
|
||||
LineLoginResult result = LineLoginApi.getLoginResultFromIntent(data);
|
||||
Log.i("ttts", result.getResponseCode() + "");
|
||||
switch (result.getResponseCode()) {
|
||||
case SUCCESS:
|
||||
// Login successful
|
||||
String accessToken = result.getLineCredential().getAccessToken().getTokenString();
|
||||
LoginData re_data = new LoginData();
|
||||
re_data.setOpenID(result.getLineProfile().getUserId());
|
||||
if (result.getLineProfile().getPictureUrl() != null) {
|
||||
re_data.setAvatar("" + result.getLineProfile().getPictureUrl().toString());
|
||||
}
|
||||
re_data.setNickName(result.getLineProfile().getDisplayName());
|
||||
re_data.setType("line");
|
||||
loginBuyThird(re_data);
|
||||
break;
|
||||
case CANCEL:
|
||||
// Login canceled by user
|
||||
Log.e("ERROR", "LINE Login Canceled by user.");
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
break;
|
||||
default:
|
||||
// Login canceled due to other error
|
||||
Log.e("ERROR", "Login FAILED!");
|
||||
Log.e("ERROR", result.getErrorData().toString());
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
} else if (requestCode == 1000) {//判断权限
|
||||
if (Environment.isExternalStorageManager()) {
|
||||
//自己的操作
|
||||
} else {
|
||||
|
||||
}
|
||||
} else if (requestCode == 1002) {//google登录
|
||||
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
|
||||
handleSignInResult(task);
|
||||
} else {
|
||||
tt_login_button.onActivityResult(requestCode, resultCode, data);//twitter登录回调
|
||||
callbackManager.onActivityResult(requestCode, resultCode, data);//facebook登录回调
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
}
|
||||
|
||||
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
|
||||
try {
|
||||
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
|
||||
//account里可以直接获取到ID,name,和头像
|
||||
String idToken = account.getIdToken();
|
||||
account.getFamilyName();
|
||||
account.getGivenName();
|
||||
|
||||
LoginData data = new LoginData();
|
||||
data.setAvatar("");
|
||||
data.setNickName(account.getDisplayName());
|
||||
data.setOpenID(account.getId());
|
||||
data.setType("google");
|
||||
|
||||
loginBuyThird(data);
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
Log.i("Log", "ApiException = " + e);
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
boolean enableButtons = AccessToken.getCurrentAccessToken() != null;
|
||||
Profile profile = Profile.getCurrentProfile();
|
||||
if (profile == null) {
|
||||
ProfileTracker tracker = new ProfileTracker() {
|
||||
|
||||
@Override
|
||||
protected void onCurrentProfileChanged(@Nullable Profile pf, @Nullable Profile profile1) {
|
||||
if (!enableButtons) {
|
||||
stopTracking();
|
||||
return;
|
||||
}
|
||||
if (pf != null) {
|
||||
loginFaceBookUpdateUI(pf);
|
||||
} else if (profile1 != null) {
|
||||
loginFaceBookUpdateUI(profile1);
|
||||
} else {
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
stopTracking();
|
||||
}
|
||||
};
|
||||
tracker.startTracking();
|
||||
} else {
|
||||
if (enableButtons) {
|
||||
loginFaceBookUpdateUI(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loginFaceBookUpdateUI(Profile profile) {
|
||||
LoginData data = new LoginData();
|
||||
data.setAvatar(profile.getProfilePictureUri(150, 150).toString());
|
||||
data.setNickName(profile.getName());
|
||||
data.setOpenID(AccessToken.getCurrentAccessToken().getUserId());
|
||||
data.setType("facebook");
|
||||
loginBuyThird(data);
|
||||
}
|
||||
|
||||
//从网页获取推广码
|
||||
private void getPromoCode() {
|
||||
OpenInstall.getInstall(new AppInstallAdapter() {
|
||||
@Override
|
||||
public void onInstall(AppData appData) {
|
||||
//获取渠道数据
|
||||
String channelCode = appData.getChannel();
|
||||
Log.d("OpenInstall", "appData.getData()= " + appData.getData());
|
||||
//获取自定义数据
|
||||
if (appData.getData() != null && !appData.getData().equals("")) {
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
|
||||
} else {
|
||||
JSONObject data = JSON.parseObject(appData.getData());
|
||||
mPromoCode = data.getString("admin_id") + "";
|
||||
UserID = data.getString("user_id") + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void getUuidDevice() {
|
||||
mUuidDevice = DeviceUtils.getUniqueDeviceId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
video_view.start();
|
||||
|
||||
}
|
||||
|
||||
public static void ToLogin() {
|
||||
activity.startActivity(new Intent(activity, LoginActivity.class));
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
private static final String EMAIL = "email";
|
||||
|
||||
/**
|
||||
* 三方登录
|
||||
*/
|
||||
private void loginBuyThird(LoginData data) {
|
||||
mLoginType = data.getType();
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
mPromoCode = "";
|
||||
}
|
||||
MainHttpUtil.loginByThird(UserID, data.getOpenID(), mPromoCode, mUuidDevice, data.getNickName(), data.getAvatar(), data.getType(), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
onLoginSuccess(code, msg, info);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//登录成功!
|
||||
private void onLoginSuccess(int code, String msg, String[] info) {
|
||||
Log.e("他", code + "code" + info.toString());
|
||||
if (code == 0 && info.length > 0) {
|
||||
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
String uid = obj.getString("id");
|
||||
String token = obj.getString("token");
|
||||
if (obj.containsKey("need_bind") && obj.getString("need_bind").equals("0")) {
|
||||
mFirstLogin = obj.getIntValue("first_login") == 1;
|
||||
mShowInvite = obj.getIntValue("isagent") == 1;
|
||||
CommonAppConfig.getInstance().setLoginInfo(uid, token, true);
|
||||
//设置登录信息
|
||||
IMLoginModel model = GsonUtils.fromJson(info[0], IMLoginModel.class);
|
||||
IMLoginManager.get(activity).setupLoginUser(model);
|
||||
//融云连接服务器
|
||||
RongcloudIMManager.connectIM(activity);
|
||||
getBaseUserInfo();
|
||||
|
||||
} else {
|
||||
Contexts.startActivity(new Intent(Contexts, BindUserActivity.class).putExtra("uid", uid).putExtra("token", token));
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show(msg + "11212");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
private void getBaseUserInfo() {
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
|
||||
if (mFirstLogin) {
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
EntryActivity.this.startActivity(new Intent(EntryActivity.this, OneLoginActivity.class));
|
||||
} else {
|
||||
HttpClient.getInstance().post("Home.getRandJoinAnchor", "Home.getRandJoinAnchor")
|
||||
.execute(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (info[0] != null) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
IMLoginManager.get(EntryActivity.this).setNewUserGif(true);
|
||||
IMLoginManager.get(EntryActivity.this).setisNewUserOne(true);
|
||||
MainActivity.forward(EntryActivity.this, false);
|
||||
gotoLive(obj.getString("anchor_id"));
|
||||
if (obj.containsKey("home_zdy_img_us")) {
|
||||
home_zdy_img_us = obj.getString("home_zdy_img_us");
|
||||
home_zdy_img_cn = obj.getString("home_zdy_img_cn");
|
||||
}
|
||||
if (obj.containsKey("home_zdy_pop")) {
|
||||
NoviceInstructorManager.get(activity).setHomeZdyPop(obj.getString(
|
||||
"home_zdy_pop"));
|
||||
}
|
||||
|
||||
} else {
|
||||
MainActivity.forward(EntryActivity.this, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
MainActivity.forward(EntryActivity.this, false);
|
||||
}
|
||||
EntryActivity.activity.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
new LiveRoomCheckLivePresenter(activity, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
NoviceInstructorManager.get(activity).setFrist(false);
|
||||
|
||||
|
||||
} else {
|
||||
MainActivity.forward(EntryActivity.this, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void timerOutBtn(View btn) {
|
||||
if (mBtnClick) {
|
||||
return;
|
||||
}
|
||||
loginLoadingDialog = DialogUitl.loadingDialog(EntryActivity.this, getString(R.string.login_wait));
|
||||
loginLoadingDialog.show();
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
mBtnClick = false;
|
||||
if (loginLoadingDialog != null) {
|
||||
loginLoadingDialog.dismiss();
|
||||
loginLoadingDialog = null;
|
||||
}
|
||||
}
|
||||
}, 3000);
|
||||
mBtnClick = true;
|
||||
}
|
||||
|
||||
private boolean isBtnClick() {
|
||||
if (mBtnClick) {
|
||||
ToastUtil.show("請稍後再試");
|
||||
}
|
||||
return mBtnClick;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (loginLoadingDialog != null) {
|
||||
if (loginLoadingDialog.isShowing()) {
|
||||
loginLoadingDialog.dismiss();
|
||||
}
|
||||
loginLoadingDialog = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
132
main/src/main/java/com/yunbao/main/activity/FansActivity.java
Normal file
@@ -0,0 +1,132 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.event.FollowEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.bean.SearchUserBean;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.SearchAdapter;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/29.
|
||||
* 我的粉丝 TA的粉丝
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_FANSACTIVITY)
|
||||
public class FansActivity extends AbsActivity implements OnItemClickListener<SearchUserBean> {
|
||||
|
||||
public static void forward(Context context, String toUid) {
|
||||
Intent intent = new Intent(context, FansActivity.class);
|
||||
intent.putExtra(Constants.TO_UID, toUid);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
private CommonRefreshView mRefreshView;
|
||||
private SearchAdapter mAdapter;
|
||||
private String mToUid;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_fans;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
mToUid = getIntent().getStringExtra(Constants.TO_UID);
|
||||
if (TextUtils.isEmpty(mToUid)) {
|
||||
return;
|
||||
}
|
||||
mRefreshView = findViewById(R.id.refreshView);
|
||||
if (mToUid.equals(CommonAppConfig.getInstance().getUid())) {
|
||||
setTitle(mContext.getString(R.string.fans_my_fans));
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_fans);
|
||||
} else {
|
||||
setTitle(mContext.getString(R.string.fans_ta_fans));
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_fans_2);
|
||||
}
|
||||
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<SearchUserBean>() {
|
||||
@Override
|
||||
public RefreshAdapter<SearchUserBean> getAdapter() {
|
||||
if (mAdapter == null) {
|
||||
mAdapter = new SearchAdapter(mContext, Constants.FOLLOW_FROM_FANS);
|
||||
mAdapter.setOnItemClickListener(FansActivity.this);
|
||||
}
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
MainHttpUtil.getFansList(mToUid, p, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchUserBean> processData(String[] info) {
|
||||
return JSON.parseArray(Arrays.toString(info), SearchUserBean.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshSuccess(List<SearchUserBean> list, int listCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreSuccess(List<SearchUserBean> loadItemList, int loadItemCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
EventBus.getDefault().register(this);
|
||||
mRefreshView.initData();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onFollowEvent(FollowEvent e) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.updateItem(e.getToUid(), e.getIsAttention());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_FANS_LIST);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(SearchUserBean bean, int position) {
|
||||
RouteUtil.forwardUserHome(mContext, bean.getId(), 0);
|
||||
}
|
||||
}
|
||||
425
main/src/main/java/com/yunbao/main/activity/FindPwdActivity.java
Normal file
@@ -0,0 +1,425 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.DeviceUtils;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.sahooz.library.Country;
|
||||
import com.sahooz.library.CountryPicker;
|
||||
import com.sahooz.library.OnPick;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.ValidatePhoneUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.event.RegSuccessEvent;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/25.
|
||||
*/
|
||||
|
||||
public class FindPwdActivity extends AbsActivity {
|
||||
|
||||
private EditText mEditPhone;
|
||||
private EditText mEditCode;
|
||||
private EditText mEditPwd1;
|
||||
private EditText mEditPwd2;
|
||||
private TextView mBtnCode;
|
||||
private View mBtnRegister;
|
||||
private Handler mHandler;
|
||||
private static final int TOTAL = 60;
|
||||
private int mCount = TOTAL;
|
||||
private String mGetCode;
|
||||
private String mGetCodeAgain;
|
||||
private Dialog mDialog;
|
||||
private int mPhoneMinLength=5;//输入手机号的最小位数
|
||||
private int mCountryCode = 852;//国家代码
|
||||
private ImageView mIvCountryCode;
|
||||
private TextView mTvCountryCode;
|
||||
private WebView webview;
|
||||
private WebSettings webSettings;
|
||||
private ArrayList<Country> allCountries = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_find_pwd;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.find_pwd_forget));
|
||||
mEditPhone = (EditText) findViewById(R.id.edit_phone);
|
||||
mEditCode = (EditText) findViewById(R.id.edit_code);
|
||||
mIvCountryCode =findViewById(R.id.ivCountryCode);
|
||||
mTvCountryCode=findViewById(R.id.tvCountryCode);
|
||||
webview = (WebView)findViewById(R.id.webview);
|
||||
initView();
|
||||
mEditPwd1 = (EditText) findViewById(R.id.edit_pwd_1);
|
||||
mEditPwd2 = (EditText) findViewById(R.id.edit_pwd_2);
|
||||
mBtnCode = (TextView) findViewById(R.id.btn_code);
|
||||
mBtnRegister = findViewById(R.id.btn_register);
|
||||
mGetCode =mContext.getString(R.string.reg_get_code);
|
||||
mGetCodeAgain =mContext.getString(R.string.reg_get_code_again);
|
||||
mTvCountryCodeClick();
|
||||
mEditPhone.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (!TextUtils.isEmpty(s) && s.length() >= mPhoneMinLength) {
|
||||
mBtnCode.setEnabled(true);
|
||||
} else {
|
||||
mBtnCode.setEnabled(false);
|
||||
}
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
TextWatcher textWatcher = new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
};
|
||||
mEditCode.addTextChangedListener(textWatcher);
|
||||
mEditPwd1.addTextChangedListener(textWatcher);
|
||||
mEditPwd2.addTextChangedListener(textWatcher);
|
||||
mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
mCount--;
|
||||
if (mCount > 0) {
|
||||
mBtnCode.setText(mGetCodeAgain + "(" + mCount + "s)");
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessageDelayed(0, 1000);
|
||||
}
|
||||
} else {
|
||||
mBtnCode.setText(mGetCode);
|
||||
mCount = TOTAL;
|
||||
if (mBtnCode != null) {
|
||||
mBtnCode.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mDialog = DialogUitl.loadingDialog(mContext);
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
|
||||
allCountries.clear();
|
||||
allCountries.addAll(Country.getAll(mContext, null));
|
||||
|
||||
String ct = IMLoginManager.get(mContext).getString("sys_user_area");
|
||||
ct = TextUtils.equals("中国", ct) ? "中国香港" : ct;
|
||||
for (int i = 0; i < allCountries.size(); i++) {
|
||||
if (allCountries.get(i).chs.equals(ct)) {
|
||||
String countryName = allCountries.get(i).name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) : countryName;
|
||||
mTvCountryCode.setText("+" + allCountries.get(i).code + " " + countryName);
|
||||
mCountryCode = allCountries.get(i).code;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void mTvCountryCodeClick() {
|
||||
mIvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
mTvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public class JsBridge {
|
||||
@JavascriptInterface
|
||||
public void getData(final String Randstr, final String Ticket) {
|
||||
|
||||
((FindPwdActivity) mContext).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i("tvss",Randstr);
|
||||
webview.setVisibility(View.GONE);
|
||||
//获取验证码
|
||||
getCode(Randstr,Ticket);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
webview = (WebView) findViewById(R.id.webview);
|
||||
webSettings = webview.getSettings();
|
||||
webSettings.setUseWideViewPort(true);
|
||||
webSettings.setLoadWithOverviewMode(true);
|
||||
// 禁用缓存
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||
webview.setWebViewClient(new WebViewClient(){
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
view.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
// 开启js支持
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webview.addJavascriptInterface(new JsBridge(), "jsBridge");
|
||||
// 也可以加载本地html(webView.loadUrl("file:///android_asset/xxx.html"))
|
||||
webview.loadUrl(CommonAppConfig.HOST + "/h5/live/TCaptcha.html"+ "?isZh=" + (WordUtil.isNewZh() ? "1" : 0));
|
||||
}
|
||||
|
||||
private void showCountryCode(){
|
||||
CountryPicker.newInstance(null, new OnPick() {
|
||||
@Override
|
||||
public void onPick(Country country) {
|
||||
String countryName = country.name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) + "..." : countryName;
|
||||
mTvCountryCode.setText(" +" + country.code + " " + countryName);
|
||||
mCountryCode=country.code;
|
||||
}
|
||||
}).show(getSupportFragmentManager(), "country");
|
||||
}
|
||||
|
||||
private void changeEnable() {
|
||||
String phone = mEditPhone.getText().toString();
|
||||
String code = mEditCode.getText().toString();
|
||||
String pwd1 = mEditPwd1.getText().toString();
|
||||
String pwd2 = mEditPwd2.getText().toString();
|
||||
mBtnRegister.setEnabled(!TextUtils.isEmpty(phone) && !TextUtils.isEmpty(code) && !TextUtils.isEmpty(pwd1) && !TextUtils.isEmpty(pwd2));
|
||||
}
|
||||
|
||||
public void registerClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_code) {
|
||||
webview.setVisibility(View.VISIBLE);
|
||||
} else if (i == R.id.btn_register) {
|
||||
register();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证码
|
||||
*/
|
||||
private void getCode(String Randstr,String Ticket) {
|
||||
String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum)) {
|
||||
// mEditPhone.setError(mContext.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
mEditCode.requestFocus();
|
||||
MainHttpUtil.getRegisterCode(Randstr,Ticket,phoneNum,mCountryCode, mGetCodeCallback);
|
||||
}
|
||||
|
||||
private HttpCallback mGetCodeCallback = new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
mBtnCode.setEnabled(false);
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessage(0);
|
||||
}
|
||||
if (!TextUtils.isEmpty(msg) && msg.contains("123456")) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 注册并登陆
|
||||
*/
|
||||
private void register() {
|
||||
final String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum)) {
|
||||
// mEditPhone.setError(mContext.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
String code = mEditCode.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(code)) {
|
||||
mEditCode.setError(mContext.getString(R.string.reg_input_code));
|
||||
mEditCode.requestFocus();
|
||||
return;
|
||||
}
|
||||
final String pwd = mEditPwd1.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd)) {
|
||||
mEditPwd1.setError(mContext.getString(R.string.reg_input_pwd_1));
|
||||
mEditPwd1.requestFocus();
|
||||
return;
|
||||
}
|
||||
String pwd2 = mEditPwd2.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_input_pwd_2));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (!pwd.equals(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_pwd_error));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (mDialog != null) {
|
||||
mDialog.show();
|
||||
}
|
||||
MainHttpUtil.findPwd(phoneNum, pwd, pwd2, code, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
login(phoneNum, pwd);
|
||||
} else {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
if (!TextUtils.isEmpty(msg)) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void login(String phoneNum, String pwd) {
|
||||
String uuid= DeviceUtils.getUniqueDeviceId();
|
||||
MainHttpUtil.login(phoneNum, pwd,uuid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
String uid = obj.getString("id");
|
||||
String token = obj.getString("token");
|
||||
IMLoginModel model = GsonUtils.fromJson(info[0], IMLoginModel.class);
|
||||
CommonAppConfig.getInstance().setLoginInfo(uid, token, true);
|
||||
getBaseUserInfo();
|
||||
} else {
|
||||
if (!TextUtils.isEmpty(msg)) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
private void getBaseUserInfo() {
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
if (bean != null) {
|
||||
MainActivity.forward(mContext);
|
||||
EventBus.getDefault().post(new RegSuccessEvent());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRegSuccessEvent(RegSuccessEvent e) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_FIND_PWD_CODE);
|
||||
MainHttpUtil.cancel(MainHttpConsts.FIND_PWD);
|
||||
MainHttpUtil.cancel(MainHttpConsts.LOGIN);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_BASE_INFO);
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mHandler = null;
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
152
main/src/main/java/com/yunbao/main/activity/FollowActivity.java
Normal file
@@ -0,0 +1,152 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.event.FollowEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.SearchAdapter;
|
||||
import com.yunbao.live.bean.SearchUserBean;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/29.
|
||||
* 我的关注 TA的关注
|
||||
*/
|
||||
|
||||
public class FollowActivity extends AbsActivity implements OnItemClickListener<SearchUserBean> {
|
||||
|
||||
public static void forward(Context context,String toUid,int isBlack){
|
||||
Intent intent = new Intent(context, FollowActivity.class);
|
||||
intent.putExtra(Constants.TO_UID, toUid);
|
||||
intent.putExtra(Constants.isBlack, isBlack);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
private CommonRefreshView mRefreshView;
|
||||
private SearchAdapter mAdapter;
|
||||
private String mToUid;
|
||||
private int isBlack;
|
||||
private int intoIndex = 0;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_follow;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
mToUid = getIntent().getStringExtra(Constants.TO_UID);
|
||||
isBlack = getIntent().getIntExtra(Constants.isBlack,0);
|
||||
if (TextUtils.isEmpty(mToUid)) {
|
||||
return;
|
||||
}
|
||||
mRefreshView = findViewById(R.id.refreshView);
|
||||
if(isBlack == 1){
|
||||
setTitle(mContext.getString(R.string.my_black));
|
||||
} else if (mToUid.equals(CommonAppConfig.getInstance().getUid())) {
|
||||
setTitle(mContext.getString(R.string.follow_my_follow));
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_follow);
|
||||
} else {
|
||||
setTitle(mContext.getString(R.string.follow_ta_follow));
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_follow_2);
|
||||
}
|
||||
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<SearchUserBean>() {
|
||||
@Override
|
||||
public RefreshAdapter<SearchUserBean> getAdapter() {
|
||||
if (mAdapter == null) {
|
||||
mAdapter = new SearchAdapter(mContext, Constants.FOLLOW_FROM_FOLLOW);
|
||||
mAdapter.setOnItemClickListener(FollowActivity.this);
|
||||
}
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
if(isBlack == 1){
|
||||
MainHttpUtil.getBlackList(p, callback);
|
||||
}else {
|
||||
MainHttpUtil.getFollowList(mToUid, p, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchUserBean> processData(String[] info) {
|
||||
return JSON.parseArray(Arrays.toString(info), SearchUserBean.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshSuccess(List<SearchUserBean> list, int listCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreSuccess(List<SearchUserBean> loadItemList, int loadItemCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
EventBus.getDefault().register(this);
|
||||
mRefreshView.initData();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onFollowEvent(FollowEvent e) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.updateItem(e.getToUid(), e.getIsAttention());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_FOLLOW_LIST);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(SearchUserBean bean, int position) {
|
||||
RouteUtil.forwardUserHome(mContext, bean.getId(),0);
|
||||
intoIndex = 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if(intoIndex == 1){
|
||||
intoIndex = 0;
|
||||
mRefreshView.initData();
|
||||
}
|
||||
}
|
||||
}
|
||||
188
main/src/main/java/com/yunbao/main/activity/GoogleFragment.java
Normal file
@@ -0,0 +1,188 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
|
||||
import static com.yunbao.main.activity.MyWalletActivity.dis;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.facebook.appevents.AppEventsConstants;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.GoogleUtils;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class GoogleFragment extends Fragment {
|
||||
|
||||
private long lastClickTime = 0;
|
||||
private static final long INTERVAL_TIME = 1500;
|
||||
|
||||
private View view;
|
||||
public static String mOrderid, mProductId, MoneyUsds;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
String adid = null;
|
||||
|
||||
GoogleUtils googleUtils;
|
||||
|
||||
boolean isGoogleService = true;
|
||||
|
||||
public GoogleFragment() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//通过参数中的布局填充获取对应布局
|
||||
view = inflater.inflate(R.layout.activity_recharge, container, false);
|
||||
|
||||
assert getArguments() != null;
|
||||
url = getArguments().getString("url");
|
||||
|
||||
if (StringUtil.isEmpty(url)) {
|
||||
Log.e(TAG, "URL为空");
|
||||
return view;
|
||||
}
|
||||
rlWebview = (WebView) view.findViewById(R.id.rlWebview);
|
||||
Log.e("ttt", url);
|
||||
rlWebview.loadUrl(url);
|
||||
|
||||
googleUtils = new GoogleUtils(getActivity());
|
||||
|
||||
// 验证是否已在此设备上安装并启用Google Play服务,以及此设备上安装的旧版本是否为此客户端所需的版本
|
||||
if (googleUtils.getGoogleService()) {
|
||||
isGoogleService = true;
|
||||
// 支持Google服务
|
||||
initGooglePay();
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
adid = googleUtils.getAdid();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
WebSettings webSettings = rlWebview.getSettings();
|
||||
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setTextZoom(100);
|
||||
webSettings.setUseWideViewPort(true);
|
||||
|
||||
webSettings.setJavaScriptEnabled(true); // 是否开启JS支持
|
||||
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
|
||||
webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕大小
|
||||
webSettings.setSupportZoom(true); // 是否支持缩放
|
||||
webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放
|
||||
|
||||
rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
|
||||
|
||||
TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview);
|
||||
|
||||
rlWebview.setWebViewClient(testWebViewClient);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
String TAG = "GooglePay";
|
||||
|
||||
private void initGooglePay() {
|
||||
googleUtils = new GoogleUtils(getActivity());
|
||||
googleUtils.initGooglePay();
|
||||
}
|
||||
|
||||
private Handler payHandler = new Handler();
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidNewGoToGooglePay(String ProductId, String OrderNumber, String MoneyUsd) {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - lastClickTime > INTERVAL_TIME) {
|
||||
mProductId = ProductId;
|
||||
mOrderid = OrderNumber;
|
||||
MoneyUsds = MoneyUsd;
|
||||
|
||||
googleUtils.setBillingListener(new GoogleUtils.GoogleBillingListener() {
|
||||
@Override
|
||||
public void onPaySuccess(String token, String orderId) {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CommonHttpUtil.notifyGoogle(token, orderId, mProductId, mOrderid, adid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
Bundle params = new Bundle();
|
||||
params.putString("currency", "HKD");
|
||||
params.putString("money", MoneyUsds);
|
||||
Bundle fb_params = new Bundle();
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD");
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId);
|
||||
//Google官方充值通知
|
||||
Bundle google_params = new Bundle();
|
||||
google_params.putString("currency", "HKD");
|
||||
google_params.putString("product_id", mProductId);
|
||||
google_params.putString("transaction_id", mOrderid);
|
||||
google_params.putString("value", MoneyUsds);
|
||||
google_params.putString("price", MoneyUsds);
|
||||
google_params.putString("quantity", "1");
|
||||
dis();
|
||||
ToastUtil.show(getString(R.string.pay_suc));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPayFailed(String msg) {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
googleUtils.purchase(mProductId);
|
||||
}
|
||||
lastClickTime = currentTime;
|
||||
|
||||
Log.e(TAG, "ProductId" + ProductId + "OrderNumber" + OrderNumber + "MoneyUsd" + MoneyUsd);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidMethodBack() {
|
||||
getActivity().onBackPressed();
|
||||
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidGoBack() {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void release() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
117
main/src/main/java/com/yunbao/main/activity/HuaWeiFragment.java
Normal file
@@ -0,0 +1,117 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
|
||||
import static com.yunbao.main.activity.MyWalletActivity.orderId;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.yunbao.common.pay.hw.HwBuilder;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class HuaWeiFragment extends Fragment {
|
||||
private long lastClickTime = 0;
|
||||
private static final long INTERVAL_TIME = 1500;
|
||||
private View view;
|
||||
public static String mOrderid, mProductId, MoneyUsds;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
String adid = null;
|
||||
|
||||
public HuaWeiFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//通过参数中的布局填充获取对应布局
|
||||
view = inflater.inflate(R.layout.activity_recharge, container, false);
|
||||
|
||||
assert getArguments() != null;
|
||||
url = getArguments().getString("url");
|
||||
|
||||
if (StringUtil.isEmpty(url)) {
|
||||
Log.e(TAG, "URL为空");
|
||||
return view;
|
||||
}
|
||||
rlWebview = (WebView) view.findViewById(R.id.rlWebview);
|
||||
Log.e("ttt", url);
|
||||
rlWebview.loadUrl(url);
|
||||
WebSettings webSettings = rlWebview.getSettings();
|
||||
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setTextZoom(100);
|
||||
webSettings.setUseWideViewPort(true);
|
||||
|
||||
webSettings.setJavaScriptEnabled(true); // 是否开启JS支持
|
||||
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
|
||||
webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕大小
|
||||
webSettings.setSupportZoom(true); // 是否支持缩放
|
||||
webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放
|
||||
|
||||
rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
|
||||
|
||||
TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview);
|
||||
|
||||
rlWebview.setWebViewClient(testWebViewClient);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
String TAG = "HuaWeiPay";
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidNewGoToGooglePay(String ProductId, String OrderNumber, String MoneyUsd) {
|
||||
Log.e(TAG, "ProductId:" + ProductId + " OrderNumber:" + OrderNumber + " MoneyUsd:" + MoneyUsd);
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - lastClickTime > INTERVAL_TIME) {
|
||||
if (ProductId.equals("zs640")) {
|
||||
ProductId = "zs0640";
|
||||
}
|
||||
mProductId = ProductId;
|
||||
mOrderid = OrderNumber;
|
||||
MoneyUsds = MoneyUsd;
|
||||
orderId = OrderNumber;
|
||||
|
||||
HwBuilder hwBuilder = new HwBuilder(getActivity());
|
||||
hwBuilder.pay(mProductId);
|
||||
}
|
||||
lastClickTime = currentTime;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidMethodBack() {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidGoBack() {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.utils.LanguageUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Stack;
|
||||
|
||||
public class LanguageSettingActivity extends AbsActivity {
|
||||
private LinearLayout traditionalChinese, english;
|
||||
private ImageView imgTraditionalChinese, imgEnglish;
|
||||
private Locale locale;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_language_sett;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
super.main();
|
||||
locale = IMLoginManager.get(mContext).getLocaleLanguage();
|
||||
if (locale == Locale.SIMPLIFIED_CHINESE) {
|
||||
findViewById(R.id.img_english).setVisibility(View.GONE);
|
||||
findViewById(R.id.img_traditional_chinese).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
findViewById(R.id.img_english).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.img_traditional_chinese).setVisibility(View.GONE);
|
||||
}
|
||||
traditionalChinese = findViewById(R.id.traditional_chinese);
|
||||
english = findViewById(R.id.english);
|
||||
imgEnglish = findViewById(R.id.img_english);
|
||||
imgTraditionalChinese = findViewById(R.id.img_traditional_chinese);
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_photo_btn_cancel), () -> onBackPressed());
|
||||
ViewClicksAntiShake.clicksAntiShake(traditionalChinese, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
locale = Locale.SIMPLIFIED_CHINESE;
|
||||
findViewById(R.id.img_english).setVisibility(View.GONE);
|
||||
findViewById(R.id.img_traditional_chinese).setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(english, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
locale = new Locale("en", "rUS");
|
||||
findViewById(R.id.img_english).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.img_traditional_chinese).setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.complete), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
changeAllActivitysLanguage(locale);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void changeAllActivitysLanguage(Locale locale) {
|
||||
Stack<Activity> allActivityStacks = AppManager.getInstance().getAllActivityStacks();
|
||||
for (int i = 0; i < allActivityStacks.size(); i++) {
|
||||
if (!(allActivityStacks.get(i) instanceof LanguageSettingActivity)) {
|
||||
allActivityStacks.get(i).finish();
|
||||
}
|
||||
}
|
||||
IMLoginManager.get(mContext).setLanguage(locale != Locale.SIMPLIFIED_CHINESE);
|
||||
startActivity(new Intent(mContext, MainActivity.class));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.custom.ItemDecoration;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.live.utils.LiveStorge;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.MainHomeFollowAdapter;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/27.
|
||||
*/
|
||||
|
||||
public class LiveClassActivity extends AbsActivity implements OnItemClickListener<LiveBean> {
|
||||
|
||||
private int mClassId;
|
||||
private CommonRefreshView mRefreshView;
|
||||
private MainHomeFollowAdapter mAdapter;
|
||||
|
||||
public static void forward(Context context, int classId, String className) {
|
||||
Intent intent = new Intent(context, LiveClassActivity.class);
|
||||
intent.putExtra(Constants.CLASS_ID, classId);
|
||||
intent.putExtra(Constants.CLASS_NAME, className);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_live_class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Intent intent = getIntent();
|
||||
mClassId = intent.getIntExtra(Constants.CLASS_ID, -1);
|
||||
if (mClassId < 0) {
|
||||
return;
|
||||
}
|
||||
String liveClassName = intent.getStringExtra(Constants.CLASS_NAME);
|
||||
setTitle(liveClassName);
|
||||
mRefreshView = findViewById(R.id.refreshView);
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_live_class);
|
||||
mRefreshView.setLayoutManager(new GridLayoutManager(mContext, 2, GridLayoutManager.VERTICAL, false));
|
||||
ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 5, 0);
|
||||
decoration.setOnlySetItemOffsetsButNoDraw(true);
|
||||
mRefreshView.setItemDecoration(decoration);
|
||||
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<LiveBean>() {
|
||||
@Override
|
||||
public RefreshAdapter<LiveBean> getAdapter() {
|
||||
if (mAdapter == null) {
|
||||
mAdapter = new MainHomeFollowAdapter(mContext);
|
||||
mAdapter.setOnItemClickListener(LiveClassActivity.this);
|
||||
}
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
MainHttpUtil.getClassLive(mClassId, p, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LiveBean> processData(String[] info) {
|
||||
return JSON.parseArray(Arrays.toString(info), LiveBean.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshSuccess(List<LiveBean> list, int listCount) {
|
||||
if (CommonAppConfig.LIVE_ROOM_SCROLL) {
|
||||
LiveStorge.getInstance().put(Constants.LIVE_CLASS_PREFIX + mClassId, list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreSuccess(List<LiveBean> loadItemList, int loadItemCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(LiveBean bean, int position) {
|
||||
watchLive(bean, position);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 观看直播
|
||||
*/
|
||||
public void watchLive(LiveBean liveBean, int position) {
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
LiveStorge.getInstance().remove(Constants.LIVE_CLASS_PREFIX + mClassId);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_CLASS_LIVE);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mRefreshView.initData();
|
||||
}
|
||||
|
||||
}
|
||||
416
main/src/main/java/com/yunbao/main/activity/LoginActivity.java
Normal file
@@ -0,0 +1,416 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.home_zdy_img_cn;
|
||||
import static com.yunbao.common.CommonAppContext.home_zdy_img_us;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.DeviceUtils;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.fm.openinstall.OpenInstall;
|
||||
import com.fm.openinstall.listener.AppInstallAdapter;
|
||||
import com.fm.openinstall.model.AppData;
|
||||
import com.lzy.okgo.model.Response;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.UserAreaBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.fragment.LoadingDialog;
|
||||
import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.http.JsonBean;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.event.RegSuccessEvent;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/17.
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_LOGIN)
|
||||
public class LoginActivity extends AbsActivity {
|
||||
|
||||
private View mRoot;
|
||||
// private ImageView mBg;
|
||||
private ObjectAnimator mAnimator;
|
||||
private EditText mEditPhone;
|
||||
private EditText mEditPwd;
|
||||
private View mBtnLogin;
|
||||
private RecyclerView mRecyclerView;
|
||||
// private MobLoginUtil mLoginUtil;
|
||||
private boolean mFirstLogin;//是否是第一次登录
|
||||
private static boolean mShowInvite;//显示邀请码弹窗
|
||||
private static String mLoginType = Constants.MOB_PHONE;//登录方式
|
||||
private String mPromoCode = "";//推广码
|
||||
private String mUuidDevice = "";//手机唯一标识符
|
||||
static String phoneNum;
|
||||
static String pwd;
|
||||
private static Context Contexts;
|
||||
Activity activity;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_login;
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRegSuccessEvent(RegSuccessEvent e) {
|
||||
if (!isFinishing()) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
EventBus.getDefault().register(this);
|
||||
initUserArea();
|
||||
mRoot = findViewById(R.id.root);
|
||||
Contexts = this;
|
||||
activity = this;
|
||||
OpenInstall.getInstall(new AppInstallAdapter() {
|
||||
@Override
|
||||
public void onInstall(AppData appData) {
|
||||
//获取渠道数据
|
||||
String channelCode = appData.getChannel();
|
||||
//获取自定义数据
|
||||
String bindData = appData.getData();
|
||||
Log.d("OpenInstall", "getInstall : installData = " + appData.toString());
|
||||
}
|
||||
});
|
||||
|
||||
mEditPhone = (EditText) findViewById(R.id.edit_phone);
|
||||
mEditPwd = (EditText) findViewById(R.id.edit_pwd);
|
||||
mBtnLogin = findViewById(R.id.btn_login);
|
||||
findViewById(R.id.btn_back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//finish();
|
||||
RouteUtil.forwardEntry2();
|
||||
}
|
||||
});
|
||||
|
||||
TextWatcher textWatcher = new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
String phone = mEditPhone.getText().toString();
|
||||
String pwd = mEditPwd.getText().toString();
|
||||
mBtnLogin.setEnabled(!TextUtils.isEmpty(phone) && !TextUtils.isEmpty(pwd));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
};
|
||||
mEditPhone.addTextChangedListener(textWatcher);
|
||||
mEditPwd.addTextChangedListener(textWatcher);
|
||||
boolean otherLoginType = false;
|
||||
ConfigBean configBean = CommonAppConfig.getInstance().getConfig();
|
||||
if (!otherLoginType) {
|
||||
findViewById(R.id.other_login_tip).setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
getUuidDevice();
|
||||
getPromoCode();
|
||||
}
|
||||
|
||||
|
||||
public static void forward() {
|
||||
Intent intent = new Intent(CommonAppContext.sInstance, LoginActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
CommonAppContext.sInstance.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
public void loginClick(View v) {
|
||||
ViewClicksAntiShake.clicksAntiShake(v, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_login) {
|
||||
login();
|
||||
|
||||
} else if (i == R.id.btn_register) {
|
||||
register();
|
||||
} else if (i == R.id.btn_forget_pwd) {
|
||||
forgetPwd();
|
||||
|
||||
} else if (i == R.id.btn_tip) {
|
||||
forwardTip();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//注册
|
||||
private void register() {
|
||||
startActivity(new Intent(mContext, RegisterActivity.class));
|
||||
}
|
||||
|
||||
//忘记密码
|
||||
private void forgetPwd() {
|
||||
startActivity(new Intent(mContext, FindPwdActivity.class));
|
||||
}
|
||||
|
||||
private LoadingDialog loadingDialog;
|
||||
|
||||
//手机号密码登录
|
||||
private void login() {
|
||||
phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.login_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
pwd = mEditPwd.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd)) {
|
||||
mEditPwd.setError(mContext.getString(R.string.login_input_pwd));
|
||||
mEditPwd.requestFocus();
|
||||
return;
|
||||
}
|
||||
mLoginType = Constants.MOB_PHONE;
|
||||
String uuid = DeviceUtils.getUniqueDeviceId();
|
||||
loadingDialog = new LoadingDialog();
|
||||
loadingDialog.show(getSupportFragmentManager(), "LoadingDialog");
|
||||
loadingDialog.setShowText(getString(R.string.login_ing));
|
||||
MainHttpUtil.login(phoneNum, pwd, uuid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
onLoginSuccess(code, msg, info);
|
||||
}
|
||||
});
|
||||
hideKeyboard(mEditPwd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 强隐键盘
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
private void hideKeyboard(View view) {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
//登录即代表同意服务和隐私条款
|
||||
private void forwardTip() {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.LOGIN_PRIVCAY+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"),false);
|
||||
}
|
||||
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
NoviceInstructorManager.get(activity).setFrist(false);
|
||||
|
||||
} else {
|
||||
MainActivity.forward(LoginActivity.this, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//登录成功!
|
||||
private void onLoginSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
String uid = obj.getString("id");
|
||||
String token = obj.getString("token");
|
||||
mFirstLogin = obj.getIntValue("first_login") == 1;
|
||||
mShowInvite = obj.getIntValue("isagent") == 1;
|
||||
CommonAppConfig.getInstance().setLoginInfo(uid, token, true);
|
||||
//设置登录信息
|
||||
IMLoginModel model = GsonUtils.fromJson(info[0], IMLoginModel.class);
|
||||
IMLoginManager.get(activity).setupLoginUser(model);
|
||||
getBaseUserInfo();
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
loadingDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
private void getBaseUserInfo() {
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
//融云连接服务器
|
||||
RongcloudIMManager.connectIM(activity);
|
||||
HttpClient.getInstance().post("Home.getRandJoinAnchor", "Home.getRandJoinAnchor")
|
||||
.execute(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (info != null && info.length > 0 && info[0] != null && mFirstLogin) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
if (obj.containsKey("home_zdy_img_us")) {
|
||||
home_zdy_img_us = obj.getString("home_zdy_img_us");
|
||||
home_zdy_img_cn = obj.getString("home_zdy_img_cn");
|
||||
}
|
||||
MainActivity.forward(LoginActivity.this, false);
|
||||
gotoLive(obj.getString("anchor_id"));
|
||||
IMLoginManager.get(mContext).setisNewUserOne(true);
|
||||
IMLoginManager.get(mContext).setNewUserGif(true);
|
||||
if (obj.containsKey("home_zdy_pop")) {
|
||||
NoviceInstructorManager.get(mContext).setHomeZdyPop(obj.getString("home_zdy_pop"));
|
||||
}
|
||||
} else {
|
||||
MainActivity.forward(LoginActivity.this, false);
|
||||
}
|
||||
loadingDialog.dismiss();
|
||||
finish();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<JsonBean> response) {
|
||||
super.onError(response);
|
||||
String message = response.message();
|
||||
System.out.println(">>>>>" + message);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void close(String str) {
|
||||
if ("close_login".equals(str)) {
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * 三方登录
|
||||
// */
|
||||
// private void loginBuyThird(LoginData data) {
|
||||
// mLoginType = data.getType();
|
||||
// MainHttpUtil.loginByThird(data.getOpenID(), mPromoCode, mUuidDevice, data.getNickName(), data.getAvatar(), data.getType(), new HttpCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(int code, String msg, String[] info) {
|
||||
// onLoginSuccess(code, msg, info);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
//从网页获取推广码
|
||||
private void getPromoCode() {
|
||||
OpenInstall.getInstall(new AppInstallAdapter() {
|
||||
@Override
|
||||
public void onInstall(AppData appData) {
|
||||
//获取渠道数据
|
||||
String channelCode = appData.getChannel();
|
||||
//获取自定义数据
|
||||
if (appData.getData() != null) {
|
||||
mPromoCode = appData.getData();
|
||||
}
|
||||
Log.d("OpenInstall", "appData.getData()= " + appData.getData());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getUuidDevice() {
|
||||
mUuidDevice = DeviceUtils.getUniqueDeviceId();
|
||||
}
|
||||
|
||||
private void initUserArea() {
|
||||
LiveNetManager.get(mContext).getUserArea(new com.yunbao.common.http.base.HttpCallback<UserAreaBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserAreaBean data) {
|
||||
IMLoginManager.get(mContext).put("sys_user_area", data.getArea());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mAnimator != null) {
|
||||
mAnimator.cancel();
|
||||
}
|
||||
mAnimator = null;
|
||||
EventBus.getDefault().unregister(this);
|
||||
MainHttpUtil.cancel(MainHttpConsts.LOGIN);
|
||||
CommonHttpUtil.cancel(CommonHttpConsts.GET_QQ_LOGIN_UNION_ID);
|
||||
MainHttpUtil.cancel(MainHttpConsts.LOGIN_BY_THIRD);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_BASE_INFO);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
RouteUtil.forwardEntry2();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.event.LoginInvalidEvent;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2017/10/9.
|
||||
* 登录失效的时候以dialog形式弹出的activity
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_LOGIN_INVALID)
|
||||
public class LoginInvalidActivity extends AbsActivity implements View.OnClickListener {
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_login_invalid;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
TextView textView = (TextView) findViewById(R.id.content);
|
||||
String tip = getIntent().getStringExtra(Constants.TIP);
|
||||
textView.setText(tip);
|
||||
findViewById(R.id.btn_confirm).setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
EventBus.getDefault().post(new LoginInvalidEvent());
|
||||
CommonAppConfig.getInstance().clearLoginInfo();
|
||||
IMLoginManager.get(this).logout(this);
|
||||
LoginActivity.forward();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
//super.onBackPressed();
|
||||
}
|
||||
}
|
||||
1509
main/src/main/java/com/yunbao/main/activity/MainActivity.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.views.floatingview.APPEasyFloat;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.fragment.MainHomeCommunityVideoFragment;
|
||||
|
||||
/**
|
||||
* 短剧
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_COMMUNITY_Activity)
|
||||
public class MainHomeCommunityActivity extends AbsActivity {
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_main_home_community;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Window window = getWindow();
|
||||
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
|
||||
MainHomeCommunityVideoFragment communityVideoFragment = new MainHomeCommunityVideoFragment();
|
||||
FragmentManager FM = getSupportFragmentManager();//获取管理器
|
||||
FragmentTransaction FT = FM.beginTransaction();//获取启动器
|
||||
FT.replace(R.id.fragment, communityVideoFragment);//替换碎片
|
||||
FT.addToBackStack(null);//是否启动回退栈
|
||||
FT.commit();//提交
|
||||
//判断是否有直播悬浮窗,有直接关闭
|
||||
if (EasyFloat.isShow("LiveFloatView")) {
|
||||
EasyFloat.dismiss("LiveFloatView", true);
|
||||
}
|
||||
APPEasyFloat.getInstance().dismiss(mContext);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.adapter.ViewPagerAdapter;
|
||||
import com.yunbao.common.bean.NobleRankHideUserListModel;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.custom.MyRadioButton;
|
||||
import com.yunbao.common.event.FollowEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.CommonIconUtil;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.MainListAdapter;
|
||||
import com.yunbao.main.bean.ListBean;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.main.views.AbsMainListChildViewHolder;
|
||||
import com.yunbao.main.views.MainListBoxBlindViewHolder;
|
||||
import com.yunbao.main.views.MainListContributeViewHolder;
|
||||
import com.yunbao.main.views.MainListProfitViewHolder;
|
||||
import com.yunbao.main.views.MyClipPagerTitleView;
|
||||
|
||||
import net.lucode.hackware.magicindicator.MagicIndicator;
|
||||
import net.lucode.hackware.magicindicator.ViewPagerHelper;
|
||||
import net.lucode.hackware.magicindicator.buildins.UIUtil;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ClipPagerTitleView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
|
||||
public class MainListActivity extends AbsActivity implements OnItemClickListener<ListBean> {
|
||||
private static final int PAGE_COUNT = 3;
|
||||
public static final String DAY = "day";
|
||||
public static final String WEEK = "week";
|
||||
public static final String MONTH = "month";
|
||||
public static final String TOTAL = "total";
|
||||
protected String mType;
|
||||
|
||||
private List<FrameLayout> mViewList;
|
||||
private AbsMainListChildViewHolder[] mViewHolders;
|
||||
private MagicIndicator mIndicator;
|
||||
private ViewPager mViewPager;
|
||||
private List<String> outRankHide = new ArrayList<>();
|
||||
public MainListAdapter mAdapter;
|
||||
private RadioButton mDay, mWeek;
|
||||
private int position;
|
||||
private ImageView mBack;
|
||||
private RadioGroup radioGroup;
|
||||
|
||||
|
||||
public static void forward(Context context, int p) {
|
||||
context.startActivity(new Intent(context, MainListActivity.class).putExtra("p", p));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.view_main_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
|
||||
mViewList = new ArrayList<>();
|
||||
for (int i = 0; i < PAGE_COUNT; i++) {
|
||||
FrameLayout frameLayout = new FrameLayout(mContext);
|
||||
frameLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
mViewList.add(frameLayout);
|
||||
}
|
||||
mViewHolders = new AbsMainListChildViewHolder[PAGE_COUNT];
|
||||
|
||||
mIndicator = (MagicIndicator) findViewById(R.id.indicator);
|
||||
final String[] titles = new String[]{
|
||||
(mContext.getString(R.string.glamour_list)),
|
||||
(mContext.getString(R.string.magnificent_list)),
|
||||
(mContext.getString(R.string.blind_box_list))
|
||||
};
|
||||
CommonNavigator commonNavigator = new CommonNavigator(mContext);
|
||||
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return titles.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int index) {
|
||||
|
||||
MyClipPagerTitleView clipPagerTitleView = new MyClipPagerTitleView(context);
|
||||
clipPagerTitleView.setText(titles[index]);
|
||||
clipPagerTitleView.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
clipPagerTitleView.setClipColor(Color.parseColor("#FFFFFF"));
|
||||
clipPagerTitleView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mIndicator.onPageSelected(index);
|
||||
mViewPager.setCurrentItem(index);
|
||||
}
|
||||
});
|
||||
|
||||
return clipPagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setLineWidth(DpUtil.dp2px(14));
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setColors(Color.parseColor("#FFFFFF"));
|
||||
return indicator;
|
||||
}
|
||||
});
|
||||
mIndicator.setNavigator(commonNavigator);
|
||||
|
||||
//默认选择第几个
|
||||
mIndicator.onPageSelected(getIntent().getIntExtra("p", 0));
|
||||
//加载数据
|
||||
loadData();
|
||||
EventBus.getDefault().register(MainListActivity.this);
|
||||
//获取隐身的用户的ID
|
||||
LiveNetManager.get(mContext)
|
||||
.getNobleRankHideUserList(new HttpCallback<NobleRankHideUserListModel>() {
|
||||
@Override
|
||||
public void onSuccess(NobleRankHideUserListModel data) {
|
||||
outRankHide = data.getOutRankHide();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show( mContext.getString(R.string.net_error));
|
||||
}
|
||||
});
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mType = DAY;
|
||||
mViewPager = (ViewPager) findViewById(R.id.viewPager);
|
||||
mBack = findViewById(R.id.btn_back);
|
||||
mDay = findViewById(R.id.btn_day);
|
||||
mWeek = findViewById(R.id.btn_week);
|
||||
radioGroup = findViewById(R.id.radioGroup);
|
||||
|
||||
mViewPager.setOffscreenPageLimit(PAGE_COUNT - 1);
|
||||
mViewPager.setAdapter(new ViewPagerAdapter(mViewList));
|
||||
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
MainListActivity.this.position = position;
|
||||
mDay.setChecked(true);
|
||||
setRadioColor(position, mDay, mWeek);
|
||||
loadPageData(position, DAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
});
|
||||
mDay.setOnClickListener(v -> {
|
||||
loadPageData(position, DAY);
|
||||
setRadioColor(mViewPager.getCurrentItem(),mDay,mWeek);
|
||||
});
|
||||
mWeek.setOnClickListener(v -> {
|
||||
loadPageData(position, WEEK);
|
||||
setRadioColor(mViewPager.getCurrentItem(),mWeek,mDay);
|
||||
});
|
||||
mBack.setOnClickListener(v -> {
|
||||
finish();
|
||||
});
|
||||
ViewPagerHelper.bind(mIndicator, mViewPager);
|
||||
mViewPager.setCurrentItem(getIntent().getIntExtra("p", 0));
|
||||
loadPageData(0, DAY);
|
||||
}
|
||||
|
||||
private void setRadioColor(int position, RadioButton select, RadioButton unSelect) {
|
||||
if (position == 0) {
|
||||
select.setTextColor(Color.parseColor("#FF82C1"));
|
||||
unSelect.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
} else if (position == 1){
|
||||
select.setTextColor(Color.parseColor("#7BBAFF"));
|
||||
unSelect.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
}else if (position == 2){
|
||||
select.setTextColor(Color.parseColor("#ff9072"));
|
||||
unSelect.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadPageData(int position, String rank) {
|
||||
if (mViewHolders == null) {
|
||||
return;
|
||||
}
|
||||
AbsMainListChildViewHolder vh = mViewHolders[position];
|
||||
if (vh == null) {
|
||||
if (mViewList != null && position < mViewList.size()) {
|
||||
FrameLayout parent = mViewList.get(position);
|
||||
if (parent == null) {
|
||||
return;
|
||||
}
|
||||
if (position == 0) {
|
||||
vh = new MainListProfitViewHolder(mContext, parent);
|
||||
vh.setAppbarColor(Color.parseColor("#FF73C3"));
|
||||
} else if (position == 1) {
|
||||
MainListContributeViewHolder mContributeViewHolder = new MainListContributeViewHolder(mContext, parent);
|
||||
mContributeViewHolder.setHide(outRankHide);
|
||||
vh = mContributeViewHolder;
|
||||
vh.setAppbarColor(Color.parseColor("#73B2FF"));
|
||||
}else if (position == 2) {
|
||||
MainListBoxBlindViewHolder mainListBoxBlindViewHolder = new MainListBoxBlindViewHolder(mContext,parent);
|
||||
mainListBoxBlindViewHolder.setHide(outRankHide);
|
||||
vh = mainListBoxBlindViewHolder;
|
||||
vh.setAppbarColor(Color.parseColor("#ff9072"));
|
||||
}
|
||||
if (vh == null) {
|
||||
return;
|
||||
}
|
||||
vh.setAppbarListener(isShow -> {
|
||||
if (isShow) {
|
||||
radioGroup.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
radioGroup.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
mViewHolders[position] = vh;
|
||||
vh.addToParent();
|
||||
vh.subscribeActivityLifeCycle();
|
||||
}
|
||||
|
||||
}
|
||||
if (vh != null) {
|
||||
vh.setType(position, rank);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void loadData() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(MainListActivity.this);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onFollowEvent(FollowEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(ListBean bean, int position) {
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/7.
|
||||
* 重置密码
|
||||
*/
|
||||
|
||||
public class ModifyPwdActivity extends AbsActivity implements View.OnClickListener {
|
||||
|
||||
private EditText mEditOld;
|
||||
private EditText mEditNew;
|
||||
private EditText mEditConfirm;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_modify_pwd;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.modify_pwd));
|
||||
mEditOld = (EditText) findViewById(R.id.edit_old);
|
||||
mEditNew = (EditText)findViewById(R.id.edit_new);
|
||||
mEditConfirm = (EditText)findViewById(R.id.edit_confirm);
|
||||
findViewById(R.id.btn_confirm).setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
modify();
|
||||
}
|
||||
|
||||
private void modify() {
|
||||
String pwdOld = mEditOld.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwdOld)) {
|
||||
mEditOld.setError(mContext.getString(R.string.modify_pwd_old_1));
|
||||
return;
|
||||
}
|
||||
String pwdNew = mEditNew.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwdNew)) {
|
||||
mEditNew.setError(mContext.getString(R.string.modify_pwd_new_1));
|
||||
return;
|
||||
}
|
||||
String pwdConfirm = mEditConfirm.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwdConfirm)) {
|
||||
mEditConfirm.setError(mContext.getString(R.string.modify_pwd_confirm_1));
|
||||
return;
|
||||
}
|
||||
if (!pwdNew.equals(pwdConfirm)) {
|
||||
mEditConfirm.setError(mContext.getString(R.string.reg_pwd_error));
|
||||
return;
|
||||
}
|
||||
MainHttpUtil.modifyPwd(pwdOld, pwdNew, pwdConfirm, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
ToastUtil.show(JSON.parseObject(info[0]).getString("msg"));
|
||||
finish();
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.MODIFY_PWD);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
270
main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java
Normal file
@@ -0,0 +1,270 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.MsgSwitchDetailModel;
|
||||
import com.yunbao.common.http.ResponseData;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.main.MainNetManager;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.MsgFollowAdapter;
|
||||
|
||||
public class MsgSettActivity extends AbsActivity {
|
||||
|
||||
ImageView dt_switch, hdd_switch, lt_switch, xt_switch, kb_switch, privateChatMessageSwitch;
|
||||
public static final String SWITCH_PRIVATE_CHAT_MSG = "private_chat_message_switch";
|
||||
|
||||
RecyclerView follow_list;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_msg_sett;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
super.main();
|
||||
setTitle(getString(R.string.alerts));
|
||||
follow_list = (RecyclerView) findViewById(R.id.follow_list);
|
||||
dt_switch = (ImageView) findViewById(R.id.dt_switch);
|
||||
hdd_switch = (ImageView) findViewById(R.id.hdd_switch);
|
||||
lt_switch = (ImageView) findViewById(R.id.lt_switch);
|
||||
xt_switch = (ImageView) findViewById(R.id.xt_switch);
|
||||
kb_switch = (ImageView) findViewById(R.id.kb_switch);
|
||||
privateChatMessageSwitch = findViewById(R.id.private_chat_switch);
|
||||
getData();
|
||||
dt_switch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//打开的
|
||||
if (dt_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
if (setMsgMasterSwitch("2", "1")) {
|
||||
dt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
;
|
||||
} else {
|
||||
if (setMsgMasterSwitch("1", "1")) {
|
||||
dt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
hdd_switch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//打开的
|
||||
if (hdd_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
if (setMsgMasterSwitch("2", "2")) {
|
||||
hdd_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
;
|
||||
} else {
|
||||
if (setMsgMasterSwitch("1", "2")) {
|
||||
hdd_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
lt_switch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//打开的
|
||||
if (lt_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
if (setMsgMasterSwitch("2", "3")) {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
;
|
||||
} else {
|
||||
if (setMsgMasterSwitch("1", "3")) {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
xt_switch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//打开的
|
||||
if (xt_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
if (setMsgMasterSwitch("2", "4")) {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
;
|
||||
} else {
|
||||
if (setMsgMasterSwitch("1", "4")) {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
follow_list.setVisibility(View.GONE);
|
||||
kb_switch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int is = 1;
|
||||
//打开的
|
||||
if (kb_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
is = 2;
|
||||
} else {
|
||||
is = 1;
|
||||
}
|
||||
MainNetManager.get(mContext).setBeginShowMsgSwitch(is + "", "1", "", new HttpCallback<ResponseData>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseData data) {
|
||||
|
||||
Log.e("ds", data.getCode() + "");
|
||||
if (data.getCode() == 200) {
|
||||
Log.e("ds", kb_switch.getDrawable().getCurrent().getConstantState() + "");
|
||||
if (kb_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
kb_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
follow_list.setVisibility(View.GONE);
|
||||
} else {
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
Log.e("ds", kb_switch.getDrawable().getCurrent().getConstantState() + "11" + error);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
/* privateChatMessageSwitch.setOnClickListener(view -> {
|
||||
if (privateChatMessageSwitch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())){
|
||||
if(setMsgMasterSwitch("2","5")){
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
}else{
|
||||
if(setMsgMasterSwitch("1","5")){
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
}
|
||||
});*/
|
||||
privateChatMessageSwitch.setOnClickListener(view -> {
|
||||
if (privateChatMessageSwitch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_off);
|
||||
SpUtil.getInstance().setBooleanValue(SWITCH_PRIVATE_CHAT_MSG, false);
|
||||
} else {
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_on);
|
||||
SpUtil.getInstance().setBooleanValue(SWITCH_PRIVATE_CHAT_MSG, true);
|
||||
}
|
||||
});
|
||||
|
||||
follow_list.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
follow_list.setHasFixedSize(true);
|
||||
follow_list.setNestedScrollingEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
public void getData() {
|
||||
MainNetManager.get(mContext)
|
||||
.getMsgSwitchDetail(new HttpCallback<MsgSwitchDetailModel>() {
|
||||
@Override
|
||||
public void onSuccess(MsgSwitchDetailModel data) {
|
||||
|
||||
if (data.getDynamic_msg_switch().equals("2")) {
|
||||
dt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
dt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
if (data.getInteraction_show_msg_switch().equals("2")) {
|
||||
hdd_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
hdd_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
if (data.getChat_msg_switch().equals("2")) {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
if (data.getChat_msg_switch().equals("2")) {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
if (data.getSystem_msg_switch().equals("2")) {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
if (data.getSystem_msg_switch().equals("2")) {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.getFollowList().size(); i++) {
|
||||
if (!data.getFollowList().get(i).getStatus().equals("2")) {
|
||||
kb_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
follow_list.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (SpUtil.getInstance().getBooleanValue(SWITCH_PRIVATE_CHAT_MSG)) {
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_on);
|
||||
} else {
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
|
||||
MsgFollowAdapter topAdapter = new MsgFollowAdapter(MsgSettActivity.this, data.getFollowList());
|
||||
follow_list.setAdapter(topAdapter);
|
||||
follow_list.setVisibility(View.VISIBLE);
|
||||
kb_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(mContext.getString(R.string.net_error));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean ret = false;
|
||||
|
||||
public boolean setMsgMasterSwitch(String status, String type) {
|
||||
ret = false;
|
||||
MainNetManager.get(mContext).setMsgMasterSwitch(status, type, new HttpCallback<ResponseData>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseData data) {
|
||||
|
||||
if (data.getCode() == 200) {
|
||||
ret = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
331
main/src/main/java/com/yunbao/main/activity/MyCoinActivity.java
Normal file
@@ -0,0 +1,331 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.CoinBean;
|
||||
import com.yunbao.common.bean.CoinPayBean;
|
||||
import com.yunbao.common.custom.ItemDecoration;
|
||||
import com.yunbao.common.event.CoinChangeEvent;
|
||||
import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.pay.PayCallback;
|
||||
import com.yunbao.common.pay.PayPresenter;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.CoinAdapter;
|
||||
import com.yunbao.main.adapter.CoinPayAdapter;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/23.
|
||||
* 充值
|
||||
*/
|
||||
//@Route(path = RouteUtil.PATH_COIN)
|
||||
public class MyCoinActivity extends AbsActivity implements OnItemClickListener<CoinBean>, View.OnClickListener {
|
||||
|
||||
private SwipeRefreshLayout mRefreshLayout;
|
||||
private RecyclerView mRecyclerView;
|
||||
private RecyclerView mPayRecyclerView;
|
||||
private CoinAdapter mAdapter;
|
||||
private CoinPayAdapter mPayAdapter;
|
||||
private TextView mBalance;
|
||||
private long mBalanceValue;
|
||||
private TextView mTvGoldCoinNum;
|
||||
private long mGoldCoinNum;
|
||||
private boolean mFirstLoad = true;
|
||||
private PayPresenter mPayPresenter;
|
||||
private String mCoinName;
|
||||
private String mGoldCoinName;
|
||||
List<CoinBean> listPro;//商品列表
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_coin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
// setTitle(mContext.getString(R.string.wallet));
|
||||
mRefreshLayout = findViewById(R.id.refreshLayout);
|
||||
mRefreshLayout.setColorSchemeResources(com.yunbao.video.R.color.global);
|
||||
mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
loadData();
|
||||
}
|
||||
});
|
||||
mCoinName = CommonAppConfig.getInstance().getCoinName();
|
||||
mGoldCoinName = CommonAppConfig.getInstance().getGoldCoinName();
|
||||
mRecyclerView = findViewById(R.id.recyclerView);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, 3, GridLayoutManager.VERTICAL, false);
|
||||
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
if (position == 0) {
|
||||
return 3;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
mRecyclerView.setLayoutManager(gridLayoutManager);
|
||||
ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 5, 20);
|
||||
decoration.setOnlySetItemOffsetsButNoDraw(true);
|
||||
mRecyclerView.addItemDecoration(decoration);
|
||||
|
||||
TextView coinNameTextView = findViewById(R.id.coin_name);
|
||||
coinNameTextView.setText(String.format(mContext.getString(R.string.wallet_coin_name), mCoinName));
|
||||
//我的金币
|
||||
TextView goldCoinNameTV = findViewById(R.id.tvMyGoldName);
|
||||
goldCoinNameTV.setText(String.format(mContext.getString(R.string.wallet_gold_name), mGoldCoinName));
|
||||
mBalance = findViewById(R.id.coin);
|
||||
mTvGoldCoinNum = findViewById(R.id.tvGoldCoinNum);
|
||||
View btnChargeExplain = findViewById(R.id.btn_charge_explain);
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
btnChargeExplain.setVisibility(View.GONE);
|
||||
} else {
|
||||
btnChargeExplain.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
mAdapter = new CoinAdapter(mContext, mGoldCoinName);
|
||||
mAdapter.setOnItemClickListener(this);
|
||||
mAdapter.setContactView(findViewById(R.id.top));
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
findViewById(R.id.btn_tip).setOnClickListener(this);
|
||||
findViewById(R.id.btn_charge_explain).setOnClickListener(this);
|
||||
View headView = mAdapter.getHeadView();
|
||||
mPayRecyclerView = headView.findViewById(R.id.pay_recyclerView);
|
||||
mPayRecyclerView.setVisibility(View.VISIBLE);
|
||||
|
||||
ItemDecoration decoration2 = new ItemDecoration(mContext, 0x00000000, 14, 10);
|
||||
decoration2.setOnlySetItemOffsetsButNoDraw(true);
|
||||
mPayRecyclerView.addItemDecoration(decoration2);
|
||||
mPayRecyclerView.setLayoutManager(new GridLayoutManager(mContext, 2, GridLayoutManager.VERTICAL, false));
|
||||
mPayAdapter = new CoinPayAdapter(mContext);
|
||||
mPayRecyclerView.setAdapter(mPayAdapter);
|
||||
mPayPresenter = new PayPresenter(this);
|
||||
mPayPresenter.setServiceNameAli(Constants.PAY_BUY_COIN_ALI);
|
||||
mPayPresenter.setServiceNameWx(Constants.PAY_BUY_COIN_WX);
|
||||
mPayPresenter.setAliCallbackUrl(HtmlConfig.ALI_PAY_COIN_URL);
|
||||
mPayPresenter.setPayCallback(new PayCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (mPayPresenter != null) {
|
||||
mPayPresenter.checkPayResult();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed() {
|
||||
}
|
||||
});
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
loadData();
|
||||
}
|
||||
|
||||
|
||||
private void loadData() {
|
||||
CommonHttpUtil.getBalance(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
try {
|
||||
String coin = obj.getString("coin");
|
||||
mBalanceValue = Long.parseLong(coin);
|
||||
mBalance.setText(coin);
|
||||
|
||||
String goldNum = obj.getString("gold");
|
||||
mGoldCoinNum = Long.parseLong(goldNum);
|
||||
mTvGoldCoinNum.setText(goldNum);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//支付方式列表
|
||||
List<CoinPayBean> payList = JSON.parseArray(obj.getString("paylist"), CoinPayBean.class);
|
||||
if (mPayAdapter != null) {
|
||||
mPayAdapter.setList(payList);
|
||||
}
|
||||
//商品列表
|
||||
listPro = JSON.parseArray(obj.getString("rules"), CoinBean.class);
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setList(listPro);
|
||||
}
|
||||
if (payList != null && payList.size() > 0) {
|
||||
if ("google".equals(payList.get(0).getId()) && payList.get(0).isChecked()) {
|
||||
EventBus.getDefault().post(payList.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
if (mPayPresenter != null) {
|
||||
mPayPresenter.setBalanceValue(mBalanceValue);
|
||||
mPayPresenter.setAliPartner(obj.getString("aliapp_partner"));
|
||||
mPayPresenter.setAliSellerId(obj.getString("aliapp_seller_id"));
|
||||
mPayPresenter.setAliPrivateKey(obj.getString("aliapp_key_android"));
|
||||
mPayPresenter.setWxAppID(obj.getString("wx_appid"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
if (mRefreshLayout != null) {
|
||||
mRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(CoinBean bean, int position) {
|
||||
if (mPayPresenter == null) {
|
||||
return;
|
||||
}
|
||||
if (mPayAdapter == null) {
|
||||
ToastUtil.show(R.string.wallet_tip_5);
|
||||
return;
|
||||
}
|
||||
CoinPayBean coinPayBean = mPayAdapter.getPayCoinPayBean();
|
||||
if (coinPayBean == null) {
|
||||
ToastUtil.show(R.string.wallet_tip_5);
|
||||
return;
|
||||
}
|
||||
|
||||
String href = coinPayBean.getHref();
|
||||
if (TextUtils.isEmpty(href)) {
|
||||
String money = bean.getMoney();
|
||||
String goodsName = StringUtil.contact(bean.getCoin(), mCoinName);
|
||||
String orderParams = StringUtil.contact("&uid=", CommonAppConfig.getInstance().getUid(), "&changeid=", bean.getId(), "&coin=", bean.getCoin());
|
||||
// if(coinPayBean.getId().equals(Constants.PAY_TYPE_HW)
|
||||
// || coinPayBean.getId().equals(Constants.PAY_TYPE_PAYSSION)
|
||||
// || coinPayBean.getId().equals(Constants.PAY_TYPE_PAYPAL)
|
||||
// || coinPayBean.getId().equals(Constants.PAY_TYPE_GOOGLE)){
|
||||
// orderParams=StringUtil.contact(orderParams,
|
||||
// "&money=", bean.getMoney_usd()
|
||||
// );
|
||||
// }else{
|
||||
// orderParams=StringUtil.contact(orderParams,
|
||||
// "&money=", money
|
||||
// );
|
||||
// }
|
||||
|
||||
orderParams = StringUtil.contact(orderParams, "&money=", bean.getMoney_usd());
|
||||
mPayPresenter.pay(coinPayBean.getId(), "5", goodsName, orderParams);
|
||||
|
||||
} else {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(href));
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onCoinChangeEvent(CoinChangeEvent e) {
|
||||
if (mBalance != null) {
|
||||
mBalance.setText(e.getCoin());
|
||||
}
|
||||
//更新金币
|
||||
if (mTvGoldCoinNum != null) {
|
||||
mTvGoldCoinNum.setText(e.getGoldCoinNum());
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGoogleLimitEvent(CoinPayBean bean) {
|
||||
if (listPro == null || listPro.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
int size = listPro.size();
|
||||
int indexTmp;
|
||||
if (bean != null) {
|
||||
//谷歌支付不显示大额价格
|
||||
if ("google".equals(bean.getId())) {
|
||||
String numS = bean.getPriceNum();
|
||||
int num = 7;
|
||||
if (numS != null && !numS.isEmpty()) {
|
||||
try {
|
||||
num = Integer.parseInt(bean.getPriceNum());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
indexTmp = num;
|
||||
} else {
|
||||
indexTmp = size;
|
||||
}
|
||||
if (indexTmp <= size) {
|
||||
List<CoinBean> listTmp = listPro.subList(0, indexTmp);
|
||||
mAdapter.setList(listTmp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_tip) {
|
||||
//充值协议
|
||||
WebViewActivity.forward(mContext, HtmlConfig.CHARGE_PRIVCAY + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"), false);
|
||||
} else if (i == R.id.btn_charge_explain) {
|
||||
//充值说明
|
||||
WebViewActivity.forward(mContext, HtmlConfig.CHARGE_EXPLAIN + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
CommonHttpUtil.cancel(CommonHttpConsts.GET_BALANCE);
|
||||
CommonHttpUtil.cancel(CommonHttpConsts.GET_ALI_ORDER);
|
||||
CommonHttpUtil.cancel(CommonHttpConsts.GET_WX_ORDER);
|
||||
if (mRefreshLayout != null) {
|
||||
mRefreshLayout.setOnRefreshListener(null);
|
||||
}
|
||||
mRefreshLayout = null;
|
||||
if (mPayPresenter != null) {
|
||||
mPayPresenter.release();
|
||||
}
|
||||
mPayPresenter = null;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.bean.ImpressBean;
|
||||
import com.yunbao.live.custom.MyTextView;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/15.
|
||||
* 我收到的主播印象
|
||||
*/
|
||||
|
||||
public class MyImpressActivity extends AbsActivity {
|
||||
|
||||
private LinearLayout mGroup;
|
||||
private TextView mTip;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_my_impress;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.impress));
|
||||
mGroup = (LinearLayout) findViewById(R.id.group);
|
||||
mTip = (TextView) findViewById(R.id.tip);
|
||||
MainHttpUtil.getMyImpress(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
if (info.length > 0) {
|
||||
List<ImpressBean> list = JSON.parseArray(Arrays.toString(info), ImpressBean.class);
|
||||
int line = 0;
|
||||
int fromIndex = 0;
|
||||
boolean hasNext = true;
|
||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
while (hasNext) {
|
||||
LinearLayout linearLayout = (LinearLayout) inflater.inflate(R.layout.view_impress_line, mGroup, false);
|
||||
int endIndex = line % 2 == 0 ? fromIndex + 3 : fromIndex + 2;
|
||||
if (endIndex >= list.size()) {
|
||||
endIndex = list.size();
|
||||
hasNext = false;
|
||||
}
|
||||
for (int i = fromIndex; i < endIndex; i++) {
|
||||
MyTextView item = (MyTextView) inflater.inflate(R.layout.view_impress_item, linearLayout, false);
|
||||
ImpressBean bean = list.get(i);
|
||||
bean.setCheck(1);
|
||||
item.setBean(bean, true);
|
||||
linearLayout.addView(item);
|
||||
}
|
||||
fromIndex = endIndex;
|
||||
line++;
|
||||
mGroup.addView(linearLayout);
|
||||
}
|
||||
} else {
|
||||
mTip.setText(mContext.getString(R.string.impress_tip_3));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_MY_IMPRESS);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.main.utils.MainIconUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/20.
|
||||
*/
|
||||
|
||||
public class MyProfitActivity extends AbsActivity implements View.OnClickListener {
|
||||
|
||||
private TextView mAllName;//总映票数TextView
|
||||
private TextView mAll;//总映票数
|
||||
private TextView mCanName;//可提取映票数TextView
|
||||
private TextView mCan;//可提取映票数
|
||||
private TextView mGetName;//输入要提取的映票数
|
||||
private TextView mMoney;
|
||||
private TextView mTip;//温馨提示
|
||||
private EditText mEdit;
|
||||
private int mRate;
|
||||
private long mMaxCanMoney;//可提取映票数
|
||||
private View mChooseTip;
|
||||
private View mAccountGroup;
|
||||
private ImageView mAccountIcon;
|
||||
private TextView mAccount;
|
||||
private String mAccountID;
|
||||
private String mVotesName;
|
||||
private View mBtnCash;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_my_profit;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
mAllName = (TextView) findViewById(R.id.all_name);
|
||||
mAll = (TextView) findViewById(R.id.all);
|
||||
mCanName = (TextView) findViewById(R.id.can_name);
|
||||
mCan = (TextView) findViewById(R.id.can);
|
||||
mGetName = (TextView) findViewById(R.id.get_name);
|
||||
mTip = (TextView) findViewById(R.id.tip);
|
||||
mMoney = (TextView) findViewById(R.id.money);
|
||||
mEdit = findViewById(R.id.edit);
|
||||
mEdit.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (s.length() > 0) {
|
||||
long i = Long.parseLong(s.toString());
|
||||
if (i > mMaxCanMoney) {
|
||||
i = mMaxCanMoney;
|
||||
s = String.valueOf(mMaxCanMoney);
|
||||
mEdit.setText(s);
|
||||
mEdit.setSelection(s.length());
|
||||
}
|
||||
if (mRate != 0) {
|
||||
mMoney.setText("¥" + (i / mRate));
|
||||
}
|
||||
mBtnCash.setEnabled(true);
|
||||
} else {
|
||||
mMoney.setText("¥");
|
||||
mBtnCash.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
mVotesName = CommonAppConfig.getInstance().getVotesName();
|
||||
mAllName.setText(String.format(mContext.getString(R.string.profit_tip_1), mVotesName));
|
||||
mCanName.setText(String.format(mContext.getString(R.string.profit_tip_2), mVotesName));
|
||||
mGetName.setText(String.format(mContext.getString(R.string.profit_tip_3), mVotesName));
|
||||
mBtnCash = findViewById(R.id.btn_cash);
|
||||
mBtnCash.setOnClickListener(this);
|
||||
findViewById(R.id.btn_choose_account).setOnClickListener(this);
|
||||
findViewById(R.id.btn_cash_record).setOnClickListener(this);
|
||||
mChooseTip = findViewById(R.id.choose_tip);
|
||||
mAccountGroup = findViewById(R.id.account_group);
|
||||
mAccountIcon = findViewById(R.id.account_icon);
|
||||
mAccount = findViewById(R.id.account);
|
||||
loadData();
|
||||
}
|
||||
|
||||
|
||||
private void loadData() {
|
||||
MainHttpUtil.getProfit(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
try {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
mAll.setText(obj.getString("votestotal"));
|
||||
mTip.setText(obj.getString("tips"));
|
||||
String votes = obj.getString("votes");
|
||||
mCan.setText(votes);
|
||||
if (votes.contains(".")) {
|
||||
votes = votes.substring(0, votes.indexOf('.'));
|
||||
}
|
||||
mMaxCanMoney = Long.parseLong(votes);
|
||||
mRate = obj.getIntValue("cash_rate");
|
||||
} catch (Exception e) {
|
||||
L.e("提现接口错误------>" + e.getClass() + "------>" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_cash) {
|
||||
cash();
|
||||
|
||||
} else if (i == R.id.btn_choose_account) {
|
||||
chooseAccount();
|
||||
|
||||
} else if (i == R.id.btn_cash_record) {
|
||||
cashRecord();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现记录
|
||||
*/
|
||||
private void cashRecord() {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.CASH_RECORD + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"),false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提现
|
||||
*/
|
||||
private void cash() {
|
||||
String votes = mEdit.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(votes)) {
|
||||
ToastUtil.show(String.format(mContext.getString(R.string.profit_coin_empty), mVotesName));
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(mAccountID)) {
|
||||
ToastUtil.show(R.string.profit_choose_account);
|
||||
return;
|
||||
}
|
||||
MainHttpUtil.doCash(votes, mAccountID, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择账户
|
||||
*/
|
||||
private void chooseAccount() {
|
||||
Intent intent = new Intent(mContext, CashActivity.class);
|
||||
intent.putExtra(Constants.CASH_ACCOUNT_ID, mAccountID);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
getAccount();
|
||||
}
|
||||
|
||||
private void getAccount() {
|
||||
String[] values = SpUtil.getInstance().getMultiStringValue(Constants.CASH_ACCOUNT_ID, Constants.CASH_ACCOUNT, Constants.CASH_ACCOUNT_TYPE);
|
||||
if (values != null && values.length == 3) {
|
||||
String accountId = values[0];
|
||||
String account = values[1];
|
||||
String type = values[2];
|
||||
if (!TextUtils.isEmpty(accountId) && !TextUtils.isEmpty(account) && !TextUtils.isEmpty(type)) {
|
||||
if (mChooseTip.getVisibility() == View.VISIBLE) {
|
||||
mChooseTip.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
if (mAccountGroup.getVisibility() != View.VISIBLE) {
|
||||
mAccountGroup.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mAccountID = accountId;
|
||||
mAccountIcon.setImageResource(MainIconUtil.getCashTypeIcon(Integer.parseInt(type)));
|
||||
mAccount.setText(account);
|
||||
} else {
|
||||
if (mAccountGroup.getVisibility() == View.VISIBLE) {
|
||||
mAccountGroup.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
if (mChooseTip.getVisibility() != View.VISIBLE) {
|
||||
mChooseTip.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mAccountID = null;
|
||||
}
|
||||
} else {
|
||||
if (mAccountGroup.getVisibility() == View.VISIBLE) {
|
||||
mAccountGroup.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
if (mChooseTip.getVisibility() != View.VISIBLE) {
|
||||
mChooseTip.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mAccountID = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.DO_CASH);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_PROFIT);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.VideoHomeViewHolder;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/12/14.
|
||||
*/
|
||||
|
||||
public class MyVideoActivity extends AbsActivity {
|
||||
|
||||
private VideoHomeViewHolder mVideoHomeViewHolder;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_my_video;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.video_my_video));
|
||||
mVideoHomeViewHolder = new VideoHomeViewHolder(mContext, (ViewGroup) findViewById(R.id.container), CommonAppConfig.getInstance().getUid());
|
||||
mVideoHomeViewHolder.addToParent();
|
||||
mVideoHomeViewHolder.subscribeActivityLifeCycle();
|
||||
mVideoHomeViewHolder.loadData();
|
||||
}
|
||||
|
||||
private void release(){
|
||||
if(mVideoHomeViewHolder!=null){
|
||||
mVideoHomeViewHolder.release();
|
||||
}
|
||||
mVideoHomeViewHolder=null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
release();
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
release();
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,503 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.fragment.LoadingDialog;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.pay.hw.HwBuilder;
|
||||
import com.yunbao.common.pay.samsung.SamsungUtil;
|
||||
import com.yunbao.common.utils.GoogleUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.main.utils.HXLinePagerIndicator;
|
||||
|
||||
import net.lucode.hackware.magicindicator.MagicIndicator;
|
||||
import net.lucode.hackware.magicindicator.ViewPagerHelper;
|
||||
import net.lucode.hackware.magicindicator.buildins.UIUtil;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@Route(path = RouteUtil.PATH_COIN)
|
||||
public class MyWalletActivity extends AbsActivity {
|
||||
ViewPager vp_content;
|
||||
static MyWalletActivity mw;
|
||||
Fragment[] fragments = null;
|
||||
private Handler payHandler = new Handler();
|
||||
public static String orderId;
|
||||
|
||||
HwBuilder hwBuilder;
|
||||
GoogleUtils googleUtils;
|
||||
|
||||
LoadingDialog loadingDialog;
|
||||
SamsungUtil samsungUtil;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_my_wallet;
|
||||
}
|
||||
|
||||
protected void main() {
|
||||
|
||||
super.main();
|
||||
mw = MyWalletActivity.this;
|
||||
setTitle(mContext.getString(R.string.wallet));
|
||||
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
googleUtils = new GoogleUtils(mContext);
|
||||
googleUtils.initGooglePay();
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
hwBuilder = new HwBuilder(MyWalletActivity.this);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
samsungUtil = SamsungUtil.newInstance(mContext);
|
||||
samsungUtil.init();
|
||||
}else{
|
||||
googleUtils = new GoogleUtils(mContext);
|
||||
googleUtils.initGooglePay();
|
||||
}
|
||||
|
||||
|
||||
vp_content = (ViewPager) findViewById(R.id.vp_content);
|
||||
TextView rView = (TextView) findViewById(R.id.rView);
|
||||
findViewById(R.id.redPacketMain).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.redPacketMain).setOnClickListener(v -> {
|
||||
RouteUtil.forwardRedPacketList();
|
||||
});
|
||||
rView.setOnClickListener(v -> {
|
||||
loadingDialog = new LoadingDialog();
|
||||
loadingDialog.show(getSupportFragmentManager(), "LoadingDialog");
|
||||
loadingDialog.setShowText(getString(R.string.order_query));
|
||||
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
googleUtils.setQueryPurchaseListener(mContext, new GoogleUtils.QueryPurchasesListener() {
|
||||
@Override
|
||||
public void onResult(JSONObject obj) {
|
||||
try {
|
||||
int code = obj.getInt("querySize");
|
||||
if (code == 0) {
|
||||
payHandler.post(runnable1);
|
||||
payHandler.postDelayed(runnable2, 1000);
|
||||
} else {
|
||||
JSONArray tokenList = obj.getJSONArray("tokenList");
|
||||
JSONArray orderList = obj.getJSONArray("orderList");
|
||||
String tradeNo = obj.getString("tradeNo");
|
||||
|
||||
for (int i = 0; i < tokenList.length(); i++) {
|
||||
int finalI = i;
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//谷歌掉单处理
|
||||
try {
|
||||
CommonHttpUtil.Google_sec_pay(tokenList.getString(finalI), orderList.getString(finalI), tradeNo, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (finalI == tokenList.length() - 1) {
|
||||
loadingDialog.setShowText(getString(R.string.order_query_success));
|
||||
loadingDialog.dismiss();
|
||||
}
|
||||
ToastUtil.show("充值已到账");
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
googleUtils.queryPurchasesAsync();
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
hwBuilder.consume();
|
||||
payHandler.post(runnable1);
|
||||
payHandler.postDelayed(runnable2, 1000);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
samsungUtil.query();
|
||||
payHandler.post(runnable1);
|
||||
payHandler.postDelayed(runnable2, 2000);
|
||||
} else {
|
||||
payHandler.post(runnable1);
|
||||
payHandler.postDelayed(runnable2, 1000);
|
||||
}
|
||||
});
|
||||
|
||||
WalletFragment walletFragment = null;
|
||||
|
||||
GoogleFragment googleFragment1 = null;
|
||||
GoogleFragment googleFragment2 = null;
|
||||
|
||||
HuaWeiFragment huaWeiFragment1 = null;
|
||||
HuaWeiFragment huaWeiFragment2 = null;
|
||||
|
||||
SamsungFragment samsungFragment1 = null;
|
||||
SamsungFragment samsungFragment2 = null;
|
||||
|
||||
final String[] titles = {mContext.getString(R.string.diamond), mContext.getString(R.string.coins), mContext.getString(R.string.golden_beans)};
|
||||
if (getIntent().getStringExtra("tag") != null) {
|
||||
Log.i("tss", "首充");
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
//google
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
//华为
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
huaWeiFragment1 = new HuaWeiFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment1.setArguments(bundle1);
|
||||
|
||||
huaWeiFragment2 = new HuaWeiFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
samsungFragment1 = new SamsungFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment1.setArguments(bundle1);
|
||||
|
||||
samsungFragment2 = new SamsungFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment2.setArguments(bundle2);
|
||||
} else {
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
}
|
||||
} else {
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
huaWeiFragment1 = new HuaWeiFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment1.setArguments(bundle1);
|
||||
|
||||
huaWeiFragment2 = new HuaWeiFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
samsungFragment1 = new SamsungFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment1.setArguments(bundle1);
|
||||
|
||||
samsungFragment2 = new SamsungFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment2.setArguments(bundle2);
|
||||
} else {
|
||||
Log.i("tss", "不是首充");
|
||||
//链接版本
|
||||
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
}
|
||||
}
|
||||
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
fragments = new Fragment[]{googleFragment1, googleFragment2, walletFragment};
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
fragments = new Fragment[]{huaWeiFragment1, huaWeiFragment2, walletFragment};
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
fragments = new Fragment[]{samsungFragment1, samsungFragment2, walletFragment};
|
||||
} else {
|
||||
fragments = new Fragment[]{googleFragment1, googleFragment2, walletFragment};
|
||||
}
|
||||
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator);
|
||||
CommonNavigator commonNavigator = new CommonNavigator(this);
|
||||
commonNavigator.setAdjustMode(true);
|
||||
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return titles == null ? 0 : titles.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int index) {
|
||||
ColorTransitionPagerTitleView colorTransitionPagerTitleView = new ColorTransitionPagerTitleView(context);
|
||||
colorTransitionPagerTitleView.setNormalColor(Color.GRAY);
|
||||
colorTransitionPagerTitleView.setSelectedColor(Color.BLACK);
|
||||
colorTransitionPagerTitleView.setTextAppearance(MyWalletActivity.this, R.style.TabLayoutTextStyle);
|
||||
colorTransitionPagerTitleView.setText(titles[index]);
|
||||
colorTransitionPagerTitleView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
vp_content.setCurrentItem(index);
|
||||
if (index == 0) {
|
||||
MobclickAgent.onEvent(mContext, "recharge_zs", "用户在充值页面选择左右切换到钻石或者点到钻石");
|
||||
} else if (index == 1) {
|
||||
MobclickAgent.onEvent(mContext, "recharge_xb", "用户在充值页面选择左右切换到星币或者点到星币");
|
||||
} else if (index == 2) {
|
||||
MobclickAgent.onEvent(mContext, "recharge_jd", "用户在充值页面选择左右切换到金豆或者点到金豆");
|
||||
}
|
||||
}
|
||||
});
|
||||
return colorTransitionPagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
HXLinePagerIndicator indicator = new HXLinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(UIUtil.dip2px(context, 4));
|
||||
indicator.setLineWidth(UIUtil.dip2px(context, 20));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(context, 3));
|
||||
indicator.setStartInterpolator(new AccelerateInterpolator());
|
||||
indicator.setEndInterpolator(new DecelerateInterpolator(2.0f));
|
||||
return indicator;
|
||||
}
|
||||
});
|
||||
magicIndicator.setNavigator(commonNavigator);
|
||||
|
||||
//每项只进入一次
|
||||
vp_content.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
return fragments[position];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return fragments.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
return titles[position];
|
||||
}
|
||||
});
|
||||
ViewPagerHelper.bind(magicIndicator, vp_content);
|
||||
magicIndicator.onPageSelected(getIntent().getIntExtra("p", 0));
|
||||
vp_content.setCurrentItem(getIntent().getIntExtra("p", 0));
|
||||
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
if (hwBuilder != null) {
|
||||
hwBuilder.consume();
|
||||
}
|
||||
}
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
if (samsungUtil != null) {
|
||||
samsungUtil.query();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Runnable runnable1 = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadingDialog.setHintText(getString(R.string.order_query_success));
|
||||
}
|
||||
};
|
||||
|
||||
private Runnable runnable2 = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (loadingDialog != null) {
|
||||
if (loadingDialog.isShow) {
|
||||
loadingDialog.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
CommonHttpUtil.cancel("Charge.Google_sec_pay");
|
||||
if (payHandler != null) {
|
||||
payHandler.removeCallbacks(runnable1);
|
||||
payHandler.removeCallbacks(runnable2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
CommonHttpUtil.cancel("Charge.Google_sec_pay");
|
||||
if (payHandler != null) {
|
||||
payHandler.removeCallbacks(runnable1);
|
||||
payHandler.removeCallbacks(runnable2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 6666) {
|
||||
if (data == null) {
|
||||
Log.e("TAG", "onActivityResult__data is null");
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject object = hwBuilder.getPayResult(data);
|
||||
|
||||
int code;
|
||||
String inAppPurchaseData;
|
||||
String inAppPurchaseDataSignature;
|
||||
try {
|
||||
code = object.getInt("code");
|
||||
Log.e("TAG", "code:" + code);
|
||||
|
||||
if (hwBuilder != null) {
|
||||
hwBuilder.consume();
|
||||
}
|
||||
|
||||
switch (code) {
|
||||
case 60000:
|
||||
ToastUtil.show(getString(R.string.pay_cancel));
|
||||
break;
|
||||
case -1:
|
||||
case 60051:
|
||||
ToastUtil.show(getString(R.string.pay_fail));
|
||||
break;
|
||||
case 0:
|
||||
ToastUtil.show(getString(R.string.pay_suc));
|
||||
inAppPurchaseData = object.getString("inAppPurchaseData");
|
||||
inAppPurchaseDataSignature = object.getString("inAppPurchaseDataSignature");
|
||||
MainHttpUtil.hwNotify(inAppPurchaseData, inAppPurchaseDataSignature, orderId, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void dis() {
|
||||
mw.finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,613 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.event.LiveRoomChangeEvent;
|
||||
import com.yunbao.common.event.MainHomeCommunityToChatEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.interfaces.ActivityResultCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.MicStatusManager;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.views.LiveRoomViewHolder;
|
||||
import com.yunbao.main.dialog.EncourageDialog;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.share.ui.SharePopDialog;
|
||||
import com.yunbao.video.activity.VideoPlayActivity;
|
||||
import com.yunbao.video.utils.VideoStorge;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Created by Chen Haoxuan on 2022/4/19.
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_MYWEBVIEWACTIVTITY)
|
||||
public class MyWebViewActivity extends AbsActivity {
|
||||
|
||||
private FrameLayout ft_title;
|
||||
private ImageView btnEdit;
|
||||
private ProgressBar mProgressBar;
|
||||
private WebView mWebView;
|
||||
private final int CHOOSE = 100;//Android 5.0以下的
|
||||
private final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
|
||||
private ValueCallback<Uri> mValueCallback;
|
||||
private ValueCallback<Uri[]> mValueCallback2;
|
||||
private int indexInto = 0;
|
||||
private View v_spacing;
|
||||
private String urlNow = "";
|
||||
private ProcessImageUtil mImageUtil;
|
||||
private boolean isUpdataUser = false;
|
||||
private MyWebViewActivity mContext;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_webview_my;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
mContext = this;
|
||||
urlNow = getIntent().getStringExtra(Constants.URL);
|
||||
Log.e("bb22", "1121212");
|
||||
if (!"".endsWith(Constants.myUrl)) {
|
||||
urlNow = Constants.myUrl;
|
||||
}
|
||||
LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
btnEdit = (ImageView) findViewById(R.id.btn_edit);
|
||||
ft_title = (FrameLayout) findViewById(R.id.ft_title);
|
||||
v_spacing = (View) findViewById(R.id.v_spacing);
|
||||
|
||||
mWebView = new WebView(mContext);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
rootView.addView(mWebView);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5--------1>" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
if (Constants.myIntoIndex != 3) {
|
||||
setTitle(view.getTitle());
|
||||
}
|
||||
if (url.contains("for")) {
|
||||
mWebView.loadUrl("javascript:goAnchorTab()");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
WebChromeClient.FileChooserParams mFileChooserParams;
|
||||
mFileChooserParams = fileChooserParams;
|
||||
String at = Arrays.toString(mFileChooserParams.getAcceptTypes());
|
||||
String type;
|
||||
if (at.contains("image/")) {//图片
|
||||
type = "image/*";
|
||||
} else if (at.contains("video/")) {
|
||||
type = "video/*";
|
||||
} else {
|
||||
type = "*/*";
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType(type);
|
||||
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||
startActivityForResult(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView).setPageClose(true), "androidObject");
|
||||
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
String appCachePath = mContext.getCacheDir().getAbsolutePath();
|
||||
// mWebView.getSettings().setAppCachePath(appCachePath);
|
||||
mWebView.getSettings().setAllowFileAccess(true);
|
||||
mWebView.getSettings().setUseWideViewPort(true); // 关键点
|
||||
mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
if (!urlNow.contains("&isZh")) {
|
||||
urlNow = urlNow + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
|
||||
}
|
||||
Log.e("MyH5", urlNow);
|
||||
mWebView.loadUrl(urlNow);
|
||||
|
||||
if (Constants.myIntoIndex == 2) {
|
||||
ft_title.setVisibility(View.GONE);
|
||||
btnEdit.setVisibility(View.GONE);
|
||||
v_spacing.setVisibility(View.VISIBLE);
|
||||
btnEdit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
} else if (Constants.myIntoIndex == 1) {
|
||||
v_spacing.setVisibility(View.GONE);
|
||||
} else if (Constants.myIntoIndex == 3) {
|
||||
setTitle(getResources().getString(R.string.main_start_dynamics));
|
||||
btnEdit.setVisibility(View.GONE);
|
||||
ft_title.setVisibility(View.VISIBLE);
|
||||
v_spacing.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
btnEdit.setVisibility(View.GONE);
|
||||
ft_title.setVisibility(View.VISIBLE);
|
||||
v_spacing.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
init();
|
||||
updataImg();
|
||||
}
|
||||
|
||||
|
||||
private LiveRoomCheckLivePresenter mCheckLivePresenter;
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
|
||||
if (LiveRoomViewHolder.mHandler != null) {
|
||||
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
if (!"".endsWith(Constants.mStream)) {
|
||||
finish();
|
||||
if (MicStatusManager.getInstance().isMic(liveUid)) {
|
||||
MicStatusManager.getInstance().showDownMicDialog(mContext);
|
||||
return;
|
||||
}
|
||||
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)).setLiveEnd(true));
|
||||
} else {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void updataImg() {
|
||||
mImageUtil = new ProcessImageUtil(this);
|
||||
mImageUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
@Override
|
||||
public void beforeCamera() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
if (file != null) {
|
||||
MainHttpUtil.updateAvatar(file, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
ToastUtil.show(com.yunbao.main.R.string.edit_profile_update_avatar_success);
|
||||
UserBean bean = CommonAppConfig.getInstance().getUserBean();
|
||||
if (bean != null) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
bean.setAvatar(obj.getString("avatar"));
|
||||
bean.setAvatarThumb(obj.getString("avatarThumb"));
|
||||
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
|
||||
v2TIMUserFullInfo.setFaceUrl(obj.getString("avatarThumb"));
|
||||
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void forwardSign() {
|
||||
UserBean mUserBean = CommonAppConfig.getInstance().getUserBean();
|
||||
if (mUserBean == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(mContext, EditSignActivity.class);
|
||||
intent.putExtra(Constants.SIGN, mUserBean.getSignature());
|
||||
mImageUtil.startActivityForResult(intent, new ActivityResultCallback() {
|
||||
@Override
|
||||
public void onSuccess(Intent intent) {
|
||||
if (intent != null) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(Intent.createChooser(intent, mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
switch (requestCode) {
|
||||
case CHOOSE://5.0以下选择图片后的回调
|
||||
processResult(resultCode, intent);
|
||||
break;
|
||||
case CHOOSE_ANDROID_5://5.0以上选择图片后的回调
|
||||
processResultAndroid5(resultCode, intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void processResult(int resultCode, Intent intent) {
|
||||
if (mValueCallback == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
Uri result = intent.getData();
|
||||
mValueCallback.onReceiveValue(result);
|
||||
} else {
|
||||
mValueCallback.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback = null;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void processResultAndroid5(int resultCode, Intent intent) {
|
||||
if (mValueCallback2 == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
String dataString = intent.getDataString();
|
||||
ClipData clipData = intent.getClipData();
|
||||
Uri[] results = null;
|
||||
if (clipData != null) {
|
||||
results = new Uri[clipData.getItemCount()];
|
||||
for (int i = 0; i < clipData.getItemCount(); i++) {
|
||||
ClipData.Item item = clipData.getItemAt(i);
|
||||
results[i] = item.getUri();
|
||||
}
|
||||
}
|
||||
if (dataString != null) {
|
||||
results = new Uri[]{Uri.parse(dataString)};
|
||||
}
|
||||
mValueCallback2.onReceiveValue(results);
|
||||
} else {
|
||||
mValueCallback2.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback2 = null;
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url, boolean addArgs) {
|
||||
if (addArgs) {
|
||||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0");
|
||||
}
|
||||
Intent intent = new Intent(context, MyWebViewActivity.class);
|
||||
intent.putExtra(Constants.URL, url);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url) {
|
||||
forward(context, url, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.destroy();
|
||||
}
|
||||
if (mImageUtil != null) {
|
||||
mImageUtil.release();
|
||||
}
|
||||
Constants.myIntoIndex = 0;
|
||||
Constants.myUrl = "";
|
||||
Constants.mStream = "";
|
||||
Constants.chatActionUrl = "";
|
||||
indexInto = 0;
|
||||
EventBus.getDefault().post("isCloseNavigation");
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
if (Constants.myIntoIndex == 2 && mWebView != null && indexInto == 1) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String method = "reload()";//拼接参数,就可以把数据传递给js
|
||||
mWebView.evaluateJavascript(method, new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String value) {
|
||||
// Log.i("qcl0228", "js返回的数据" + value);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
mWebView.loadUrl("javascript:reload()");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mWebView.reload();
|
||||
}
|
||||
}, 100);
|
||||
|
||||
indexInto = 0;
|
||||
}
|
||||
|
||||
if (isUpdataUser) {
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
isUpdataUser = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
super.onResume();
|
||||
|
||||
}
|
||||
|
||||
private void closeFinger() {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String method = "Left()";//拼接参数,就可以把数据传递给js
|
||||
mWebView.evaluateJavascript(method, new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String value) {
|
||||
Log.i("Log", "Left()js返回" + value);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
mWebView.loadUrl("javascript:Left()");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
closeFinger();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
|
||||
if (!TextUtils.isEmpty(event.getMethod())) {
|
||||
if (TextUtils.equals(event.getMethod(), "androidCommunityGift")) {
|
||||
Constants.nowPostsId = event.getPostsId();
|
||||
EncourageDialog fragment = new EncourageDialog();
|
||||
fragment.setId(event.getPostsId());
|
||||
fragment.show(((MyWebViewActivity) mContext).getSupportFragmentManager(), "EncourageDialog");
|
||||
} else if (TextUtils.equals(event.getMethod(), "modifyMydata")) {
|
||||
indexInto = event.getIndexInto();
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) {
|
||||
//看直播
|
||||
gotoLive(event.getLiveId());
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidClickSayHiBack")) {
|
||||
Constants.firstInto = 0;
|
||||
EventBus.getDefault().post(new MainHomeCommunityToChatEvent().setTargetId(event.getUserId()));
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidPlayVideo")) {
|
||||
VideoStorge.getInstance().put(Constants.VIDEO_COMMUNITY, event.getVideoBeanList());
|
||||
VideoPlayActivity.forward(mContext, event.getPosition(), Constants.VIDEO_COMMUNITY, 1);
|
||||
} else if (TextUtils.equals(event.getMethod(), "openUpdataName")) {
|
||||
isUpdataUser = event.isUpdataUser();
|
||||
} else if (TextUtils.equals(event.getMethod(), "openUpdataAutograph")) {
|
||||
isUpdataUser = true;
|
||||
forwardSign();
|
||||
} else if (TextUtils.equals(event.getMethod(), "openUpdataAvater")) {
|
||||
isUpdataUser = true;
|
||||
DialogUitl.showStringArrayDialog(mContext, new Integer[]{
|
||||
com.yunbao.main.R.string.camera, com.yunbao.main.R.string.alumb}, new DialogUitl.StringArrayDialogCallback() {
|
||||
@Override
|
||||
public void onItemClick(String text, int tag) {
|
||||
if (tag == com.yunbao.main.R.string.camera) {
|
||||
mImageUtil.getImageByCamera();
|
||||
} else {
|
||||
mImageUtil.getImageByAlumb();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidCommunityShare")) {
|
||||
JSONObject json = JSONObject.parseObject(event.getData());
|
||||
new SharePopDialog(mContext)
|
||||
.setShareLink(CommonAppConfig.HOST + json.getString("link"))
|
||||
.setAnchorAvatar(json.getString("avatar"))
|
||||
.showDialog();
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidCancelAnchorAttention")) {
|
||||
if (!StringUtil.isEmpty(LiveAudienceActivity.is_fans)) {
|
||||
LiveAudienceActivity.is_fans = "-2";
|
||||
LiveRoomViewHolder.setFansNum(LiveAudienceActivity.fansNum - 1);
|
||||
IMLoginManager.get(mContext).upDataUserInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.MicStatusManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.activity.SystemMessageActivity;
|
||||
import com.yunbao.common.event.LiveRoomChangeEvent;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.live.views.LiveRoomViewHolder;
|
||||
import com.yunbao.main.dialog.EncourageDialog;
|
||||
import com.yunbao.video.activity.VideoPlayActivity;
|
||||
import com.yunbao.video.utils.VideoStorge;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Created by Chen Haoxuan on 2022/4/19.
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_MYWEBVIEWACTIVTITY2)
|
||||
public class MyWebViewActivity2 extends AbsActivity {
|
||||
|
||||
private FrameLayout ft_title;
|
||||
private ImageView btnEdit;
|
||||
private ProgressBar mProgressBar;
|
||||
private WebView mWebView;
|
||||
private final int CHOOSE = 100;//Android 5.0以下的
|
||||
private final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
|
||||
private ValueCallback<Uri> mValueCallback;
|
||||
private ValueCallback<Uri[]> mValueCallback2;
|
||||
private int indexInto = 0;
|
||||
private View v_spacing;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_webview_my;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
String url = getIntent().getStringExtra(Constants.URL);
|
||||
LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
btnEdit = (ImageView) findViewById(R.id.btn_edit);
|
||||
ft_title = (FrameLayout) findViewById(R.id.ft_title);
|
||||
v_spacing = (View) findViewById(R.id.v_spacing);
|
||||
|
||||
mWebView = new WebView(mContext);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
rootView.addView(mWebView);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5--------1>" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
if (Constants.myIntoIndex != 3) {
|
||||
setTitle(view.getTitle());
|
||||
}
|
||||
if (url.contains("for")) {
|
||||
mWebView.loadUrl("javascript:goAnchorTab()");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
FileChooserParams mFileChooserParams;
|
||||
mFileChooserParams = fileChooserParams;
|
||||
String at = Arrays.toString(mFileChooserParams.getAcceptTypes());
|
||||
String type;
|
||||
if (at.contains("image/")) {//图片
|
||||
type = "image/*";
|
||||
} else if (at.contains("video/")) {
|
||||
type = "video/*";
|
||||
} else {
|
||||
type = "*/*";
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType(type);
|
||||
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||
startActivityForResult(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView)
|
||||
.setPageClose(true)
|
||||
.setLiveZhuangBana(false), "androidObject");
|
||||
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
String appCachePath = mContext.getCacheDir().getAbsolutePath();
|
||||
// mWebView.getSettings().setAppCachePath(appCachePath);
|
||||
mWebView.getSettings().setAllowFileAccess(true);
|
||||
mWebView.getSettings().setUseWideViewPort(true); // 关键点
|
||||
mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
|
||||
if (Constants.myIntoIndex == 2) {
|
||||
ft_title.setVisibility(View.GONE);
|
||||
btnEdit.setVisibility(View.GONE);
|
||||
v_spacing.setVisibility(View.VISIBLE);
|
||||
btnEdit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
} else if (Constants.myIntoIndex == 1) {
|
||||
v_spacing.setVisibility(View.GONE);
|
||||
} else if (Constants.myIntoIndex == 3) {
|
||||
setTitle(getResources().getString(R.string.main_start_dynamics));
|
||||
btnEdit.setVisibility(View.GONE);
|
||||
ft_title.setVisibility(View.VISIBLE);
|
||||
v_spacing.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
btnEdit.setVisibility(View.GONE);
|
||||
ft_title.setVisibility(View.VISIBLE);
|
||||
v_spacing.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
private LiveRoomCheckLivePresenter mCheckLivePresenter;
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
|
||||
if (LiveRoomViewHolder.mHandler != null) {
|
||||
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
if (!"".endsWith(Constants.mStream)) {
|
||||
finish();
|
||||
if(MicStatusManager.getInstance().isMic(liveUid)){
|
||||
MicStatusManager.getInstance().showDownMicDialog(mContext);
|
||||
return;
|
||||
}
|
||||
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)));
|
||||
} else {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(Intent.createChooser(intent,mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
switch (requestCode) {
|
||||
case CHOOSE://5.0以下选择图片后的回调
|
||||
processResult(resultCode, intent);
|
||||
break;
|
||||
case CHOOSE_ANDROID_5://5.0以上选择图片后的回调
|
||||
processResultAndroid5(resultCode, intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void processResult(int resultCode, Intent intent) {
|
||||
if (mValueCallback == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
Uri result = intent.getData();
|
||||
mValueCallback.onReceiveValue(result);
|
||||
} else {
|
||||
mValueCallback.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback = null;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void processResultAndroid5(int resultCode, Intent intent) {
|
||||
if (mValueCallback2 == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
String dataString = intent.getDataString();
|
||||
ClipData clipData = intent.getClipData();
|
||||
Uri[] results = null;
|
||||
if (clipData != null) {
|
||||
results = new Uri[clipData.getItemCount()];
|
||||
for (int i = 0; i < clipData.getItemCount(); i++) {
|
||||
ClipData.Item item = clipData.getItemAt(i);
|
||||
results[i] = item.getUri();
|
||||
}
|
||||
}
|
||||
if (dataString != null) {
|
||||
results = new Uri[]{Uri.parse(dataString)};
|
||||
}
|
||||
mValueCallback2.onReceiveValue(results);
|
||||
} else {
|
||||
mValueCallback2.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback2 = null;
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url, boolean addArgs) {
|
||||
if (addArgs) {
|
||||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0");
|
||||
}
|
||||
Intent intent = new Intent(context, MyWebViewActivity2.class);
|
||||
intent.putExtra(Constants.URL, url);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url) {
|
||||
forward(context, url, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.destroy();
|
||||
}
|
||||
Constants.myIntoIndex = 0;
|
||||
Constants.myUrl = "";
|
||||
Constants.mStream = "";
|
||||
Constants.chatActionUrl = "";
|
||||
indexInto = 0;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
if (Constants.myIntoIndex == 2 && mWebView != null && indexInto == 1) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String method = "reload()";//拼接参数,就可以把数据传递给js
|
||||
mWebView.evaluateJavascript(method, new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String value) {
|
||||
// Log.i("qcl0228", "js返回的数据" + value);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
mWebView.loadUrl("javascript:reload()");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
indexInto = 0;
|
||||
}
|
||||
super.onResume();
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
|
||||
if (!TextUtils.isEmpty(event.getMethod())) {
|
||||
Constants.nowPostsId = event.getPostsId();
|
||||
EncourageDialog fragment = new EncourageDialog();
|
||||
fragment.show(((MyWebViewActivity2) mContext).getSupportFragmentManager(), "EncourageDialog");
|
||||
} else if (TextUtils.equals(event.getMethod(), "modifyMydata")) {
|
||||
indexInto = event.getIndexInto();
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) {
|
||||
//看直播
|
||||
gotoLive(event.getLiveId());
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidClickSayHiBack")) {
|
||||
Constants.firstInto = 0;
|
||||
SystemMessageActivity.forward(mContext, "-2", event.getUserId(), event.getName(), event.getImage());
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidPlayVideo")) {
|
||||
VideoStorge.getInstance().put(Constants.VIDEO_COMMUNITY, event.getVideoBeanList());
|
||||
VideoPlayActivity.forward(mContext, event.getPosition(), Constants.VIDEO_COMMUNITY, 1);
|
||||
} else if (TextUtils.equals(event.getMethod(), "openWebView")) {
|
||||
ZhuangBanActivity.forward(mContext, event.getData(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.dialog.OneLoginDialog;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class OneLoginActivity extends AbsActivity {
|
||||
|
||||
RoundedImageView avatar;
|
||||
EditText edit_user, edit_code;
|
||||
Button btn_enter;
|
||||
|
||||
public static OneLoginActivity act;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_one_login;
|
||||
}
|
||||
|
||||
private ProcessImageUtil mImageUtil;
|
||||
|
||||
private void updataImg() {
|
||||
|
||||
DialogUitl.showStringArrayDialog(mContext, new Integer[]{
|
||||
R.string.camera, R.string.alumb}, new DialogUitl.StringArrayDialogCallback() {
|
||||
@Override
|
||||
public void onItemClick(String text, int tag) {
|
||||
if (tag == R.string.camera) {
|
||||
mImageUtil.getImageByCamera();
|
||||
} else {
|
||||
mImageUtil.getImageByAlumb();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
super.main();
|
||||
act = this;
|
||||
avatar = (RoundedImageView) findViewById(R.id.avatar);
|
||||
edit_user = (EditText) findViewById(R.id.edit_user);
|
||||
edit_code = (EditText) findViewById(R.id.edit_code);
|
||||
btn_enter = (Button) findViewById(R.id.btn_enter);
|
||||
mImageUtil = new ProcessImageUtil(this);
|
||||
mImageUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
@Override
|
||||
public void beforeCamera() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
if (file != null) {
|
||||
MainHttpUtil.updateAvatar(file, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
ToastUtil.show(R.string.edit_profile_update_avatar_success);
|
||||
UserBean bean = CommonAppConfig.getInstance().getUserBean();
|
||||
if (bean != null) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
bean.setAvatar(obj.getString("avatar"));
|
||||
bean.setAvatarThumb(obj.getString("avatarThumb"));
|
||||
ImgLoader.displayAvatar(mContext, CommonAppConfig.getInstance().getUserBean().getAvatar(), avatar);
|
||||
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
|
||||
v2TIMUserFullInfo.setFaceUrl(obj.getString("avatarThumb"));
|
||||
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
}
|
||||
});
|
||||
ImgLoader.displayAvatar(mContext, CommonAppConfig.getInstance().getUserBean().getAvatar(), avatar);
|
||||
|
||||
edit_user.setText(CommonAppConfig.getInstance().getUserBean().getUserNiceName());
|
||||
|
||||
avatar.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// ToastUtil.show("1111");
|
||||
// updataImg();
|
||||
}
|
||||
});
|
||||
|
||||
btn_enter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OneLoginDialog fragment = new OneLoginDialog();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("name", edit_user.getText().toString() + "");
|
||||
bundle.putString("code", edit_code.getText().toString() + "");
|
||||
fragment.setArguments(bundle);
|
||||
fragment.show(getSupportFragmentManager(), "OneLoginDialog");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,606 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.isReady;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.binioter.guideview.Guide;
|
||||
import com.binioter.guideview.GuideBuilder;
|
||||
import com.facebook.appevents.AppEventsLogger;
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.ImUserInfoModel;
|
||||
import com.yunbao.common.custom.TabButtonGroup;
|
||||
import com.yunbao.common.event.MessageIMEvent;
|
||||
import com.yunbao.common.event.UpdateTablePointMe;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ProcessResultUtil;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.activity.SystemMessageActivity;
|
||||
import com.yunbao.live.bean.ImUserBean;
|
||||
import com.yunbao.live.http.ImHttpUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.SystemMessageAdapter;
|
||||
import com.yunbao.main.dialog.MainStartDialogFragment;
|
||||
import com.yunbao.main.event.PDLiveConversationListEvent;
|
||||
import com.yunbao.main.manager.imrongcloud.ConversationIMListManager;
|
||||
import com.yunbao.main.views.MessageGuideView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.conversationlist.ConversationListFragment;
|
||||
|
||||
/**
|
||||
* pdlive消息中心
|
||||
*/
|
||||
public class PDLiveConversationListActivity extends AbsActivity implements View.OnClickListener {
|
||||
//菜单
|
||||
private TabButtonGroup mTabButtonGroup;
|
||||
public static String CLASSNAME = "PDLiveConversationListActivity", MESSAGENUMBER = "messageNumber", NUMBERME = "numberMe", POP = "pop";
|
||||
private PDLiveConversationListActivity mContext;
|
||||
private ConversationListFragment conversationListFragment;
|
||||
private FrameLayout container;
|
||||
private long mLastClickBackTime;//上次点击back键的时间
|
||||
private TextView redPoint;
|
||||
private View redpointMe;
|
||||
private SystemMessageAdapter messageAdapter;
|
||||
private TextView textNewsNotice, textNewsInteraction, textNewsOnline;
|
||||
private ProcessResultUtil mProcessResultUtil;
|
||||
private ImageView newsIconClearance;
|
||||
private Handler netHandler = new Handler();
|
||||
private String type = null;
|
||||
private List<ImUserBean> listUserBean = new ArrayList<>();
|
||||
private LinearLayout topLayout, ltNodataMsg;
|
||||
private ImageView imgNewsNotice, imgNewsInteraction, imgNewsOnline;
|
||||
|
||||
@Override
|
||||
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_conversation_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
super.main();
|
||||
EventBus.getDefault().register(this);
|
||||
mContext = this;
|
||||
initView();
|
||||
initData();
|
||||
|
||||
}
|
||||
|
||||
//展示引导层
|
||||
private void showGuideView() {
|
||||
MessageGuideView guideView = new MessageGuideView(this);
|
||||
//top_noback
|
||||
GuideBuilder builder = new GuideBuilder();
|
||||
builder.setTargetView(topLayout)
|
||||
.setAlpha(180)
|
||||
.setHighTargetCorner(20)
|
||||
.setHighTargetPadding(10);
|
||||
builder.setOverlayTarget(true);
|
||||
builder.setAutoDismiss(false);
|
||||
|
||||
builder.addComponent(guideView);
|
||||
Guide guide = builder.createGuide();
|
||||
guide.show(this);
|
||||
//引导界面设置
|
||||
View container = guideView.getContainer();
|
||||
SVGAImageView guidSvga = container.findViewById(R.id.guide_svga);
|
||||
LinearLayout guideLayout = container.findViewById(R.id.guide_layout);
|
||||
ImageView politicalInstructor = container.findViewById(R.id.political_instructor);
|
||||
//设置界面宽度
|
||||
ViewGroup.LayoutParams layoutParams = guideLayout.getLayoutParams();
|
||||
layoutParams.width = DeviceUtils.getScreenWidth(mContext);
|
||||
guideLayout.setLayoutParams(layoutParams);
|
||||
//设置svga动图
|
||||
new SVGAParser(mContext).decodeFromAssets("guide.svga", new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
guidSvga.setImageDrawable(drawable);
|
||||
SVGAViewUtils.playEndClear(guidSvga, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
Log.e("errqs", "errl");
|
||||
}
|
||||
}, null);
|
||||
//点击事件
|
||||
ViewClicksAntiShake.clicksAntiShake(politicalInstructor, () -> {
|
||||
String targetId = ConversationIMListManager.get(mContext).getTargetId();
|
||||
if (!TextUtils.isEmpty(targetId)) {
|
||||
ConversationIMListManager.get(mContext).jumpConversation(mContext, targetId);
|
||||
guide.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化控件
|
||||
*/
|
||||
private void initView() {
|
||||
//菜单
|
||||
mTabButtonGroup = findViewById(R.id.tab_group);
|
||||
container = findViewById(R.id.container);
|
||||
redPoint = findViewById(R.id.v_table_redpoint);
|
||||
redpointMe = findViewById(R.id.v_table_redpoint_me);
|
||||
textNewsNotice = findViewById(R.id.text_news_notice);
|
||||
textNewsInteraction = findViewById(R.id.text_news_interaction);
|
||||
textNewsOnline = findViewById(R.id.text_news_online);
|
||||
newsIconClearance = findViewById(R.id.news_icon_clearance);
|
||||
topLayout = findViewById(R.id.top_layout);
|
||||
ltNodataMsg = findViewById(R.id.lt_nodata_msg);
|
||||
imgNewsNotice = findViewById(R.id.img_news_notice);
|
||||
imgNewsInteraction = findViewById(R.id.img_news_interaction);
|
||||
imgNewsOnline = findViewById(R.id.img_news_online);
|
||||
mTabButtonGroup.setCurPosition(2);
|
||||
findViewById(R.id.btn_start).setOnClickListener(v -> {
|
||||
//防止重新加载多个
|
||||
showStartDialog();
|
||||
});
|
||||
//选中监听
|
||||
mTabButtonGroup.addTabButtonGroupChangeListener((view, index) -> {
|
||||
Log.e(CLASSNAME, "onPageSelected:" + index);
|
||||
if (index != 2) {
|
||||
EasyFloat.hide("PDLiveConversationList");
|
||||
//打开主页菜单,关闭消息中心
|
||||
EventBus.getDefault().post(new PDLiveConversationListEvent().setPage(index));
|
||||
//防止重新加载多个
|
||||
startActivity(new Intent(mContext, MainActivity.class));
|
||||
|
||||
}
|
||||
});
|
||||
newsIconClearance.setOnClickListener(this);
|
||||
container.post(() -> {
|
||||
String homeZdyPop = getIntent().getStringExtra(POP);
|
||||
if (TextUtils.equals(homeZdyPop, "1")) {
|
||||
showGuideView();
|
||||
NoviceInstructorManager.get(mContext).setHomeZdyPop("");
|
||||
}
|
||||
|
||||
});
|
||||
if (EasyFloat.isShow("LiveFloatView")) {
|
||||
EasyFloat.show("LiveFloatView");
|
||||
}
|
||||
}
|
||||
|
||||
private void showStartDialog() {
|
||||
if (isReady == true) {
|
||||
MainStartDialogFragment dialogFragment = new MainStartDialogFragment();
|
||||
dialogFragment.setMainStartChooseCallback(true, this);
|
||||
dialogFragment.show(getSupportFragmentManager(), "MainStartDialogFragment");
|
||||
} else {
|
||||
ToastUtil.show("正在初始化,請稍等....");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
private void initData() {
|
||||
IMLoginManager.get(mContext).checkInstructor();
|
||||
mProcessResultUtil = new ProcessResultUtil(this);
|
||||
netHandler.post(imUserInfoRunnable);
|
||||
if (IMLoginManager.get(mContext).hintChat()) {
|
||||
container.setVisibility(View.GONE);
|
||||
ltNodataMsg.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
container.setVisibility(View.VISIBLE);
|
||||
ltNodataMsg.setVisibility(View.GONE);
|
||||
//展示会话列表
|
||||
conversationListFragment = new ConversationListFragment();
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.container, conversationListFragment);
|
||||
transaction.commit();
|
||||
//自定义空数据背景View
|
||||
conversationListFragment.setEmptyView(com.yunbao.live.R.layout.view_layout_msg);
|
||||
//刷新列表内用户信息
|
||||
ConversationIMListManager.get(mContext).addUserInfoProvider();
|
||||
}
|
||||
|
||||
|
||||
//消息中心
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
if (bundle != null) {
|
||||
int messageNumber = bundle.getInt(MESSAGENUMBER, 0);
|
||||
int numberMe = bundle.getInt(NUMBERME, 0);
|
||||
onMessageIMEvent(new MessageIMEvent().setNumber(messageNumber));
|
||||
onUpdateFieldEvent(new UpdateTablePointMe(numberMe));
|
||||
}
|
||||
//获取一下系统通知
|
||||
MessageIMManager.get(this).getSystemMessages();
|
||||
}
|
||||
|
||||
/**
|
||||
* 系統消息獲取
|
||||
*/
|
||||
private Runnable imUserInfoRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//获取系统消息列表
|
||||
ImHttpUtil.getImUserInfo("", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
runOnUiThread(() -> {
|
||||
listUserBean = JSON.parseArray(Arrays.toString(info), ImUserBean.class);
|
||||
for (ImUserBean userBean : listUserBean) {
|
||||
switch (userBean.getType()) {
|
||||
//官方通知
|
||||
case "1":
|
||||
if (TextUtils.isEmpty(userBean.getNum()) || TextUtils.equals("0", userBean.getNum())) {
|
||||
textNewsNotice.setVisibility(View.GONE);
|
||||
} else {
|
||||
textNewsNotice.setVisibility(View.VISIBLE);
|
||||
textNewsNotice.setText(userBean.getNum());
|
||||
}
|
||||
ImgLoader.display(mContext, userBean.getNewImage(), imgNewsNotice);
|
||||
ViewClicksAntiShake.clicksAntiShake(imgNewsNotice, () -> {
|
||||
type = userBean.getType();
|
||||
netHandler.post(systemNumberRunnable);
|
||||
startActivity(new Intent(mContext, SystemMessageActivity.class)
|
||||
.putExtra("type", userBean.getType())
|
||||
.putExtra("uid", "")
|
||||
.putExtra("title", userBean.getTitle())
|
||||
.putExtra("headImg", ""));
|
||||
});
|
||||
break;
|
||||
//互動消息
|
||||
case "2":
|
||||
if (TextUtils.isEmpty(userBean.getNum()) || TextUtils.equals("0", userBean.getNum())) {
|
||||
textNewsInteraction.setVisibility(View.GONE);
|
||||
} else {
|
||||
textNewsInteraction.setVisibility(View.VISIBLE);
|
||||
textNewsInteraction.setText(userBean.getNum());
|
||||
}
|
||||
ImgLoader.display(mContext, userBean.getNewImage(), imgNewsInteraction);
|
||||
ViewClicksAntiShake.clicksAntiShake(imgNewsInteraction, () -> {
|
||||
type = userBean.getType();
|
||||
netHandler.post(systemNumberRunnable);
|
||||
startActivity(new Intent(mContext, SystemMessageActivity.class)
|
||||
.putExtra("type", userBean.getType())
|
||||
.putExtra("uid", "")
|
||||
.putExtra("title", userBean.getTitle())
|
||||
.putExtra("headImg", ""));
|
||||
});
|
||||
break;
|
||||
//在線客服
|
||||
case "3":
|
||||
if (TextUtils.isEmpty(userBean.getNum()) || TextUtils.equals("0", userBean.getNum())) {
|
||||
textNewsOnline.setVisibility(View.GONE);
|
||||
} else {
|
||||
textNewsOnline.setVisibility(View.VISIBLE);
|
||||
textNewsOnline.setText(userBean.getNum());
|
||||
}
|
||||
ImgLoader.display(mContext, userBean.getNewImage(), imgNewsOnline);
|
||||
ViewClicksAntiShake.clicksAntiShake(imgNewsOnline, () -> {
|
||||
type = userBean.getType();
|
||||
netHandler.post(systemNumberRunnable);
|
||||
AppEventsLogger.newLogger(mContext).logEvent("FB_customer_service");
|
||||
if (userBean.getLink() != null && !"".equals(userBean.getLink())) {
|
||||
WebViewActivity.forward(mContext, userBean.getLink(),false);
|
||||
} else {
|
||||
startActivity(new Intent(mContext, SystemMessageActivity.class)
|
||||
.putExtra("type", userBean.getType())
|
||||
.putExtra("uid", "")
|
||||
.putExtra("title", userBean.getTitle())
|
||||
.putExtra("headImg", ""));
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
//修改小紅點
|
||||
private Runnable systemNumberRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(() -> {
|
||||
int systemNumber = 0;
|
||||
for (ImUserBean userBean : listUserBean) {
|
||||
//未读消息数
|
||||
String number = userBean.getNum();
|
||||
|
||||
switch (userBean.getType()) {
|
||||
//官方通知
|
||||
case "1":
|
||||
if (TextUtils.equals(type, userBean.getType())) {
|
||||
number = null;
|
||||
textNewsNotice.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
//互動消息
|
||||
case "2":
|
||||
if (TextUtils.equals(type, userBean.getType())) {
|
||||
number = null;
|
||||
textNewsInteraction.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
//在線客服
|
||||
case "3":
|
||||
if (TextUtils.equals(type, userBean.getType())) {
|
||||
number = null;
|
||||
textNewsOnline.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//未读消息不为空并且大于0
|
||||
try {
|
||||
if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) {
|
||||
systemNumber = Integer.parseInt(number) + systemNumber;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
systemNumber = systemNumber + 0;
|
||||
}
|
||||
|
||||
}
|
||||
type = null;
|
||||
MessageIMManager.get(mContext).setSystemNumber(systemNumber);
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 添加头部系统消息
|
||||
*
|
||||
* @param listUserBean 数据源
|
||||
*/
|
||||
private void addSystemMessagesView(List<ImUserBean> listUserBean) {
|
||||
//倒序展示
|
||||
Collections.reverse(listUserBean);
|
||||
//展示会话列表
|
||||
conversationListFragment = new ConversationListFragment();
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.container, conversationListFragment);
|
||||
transaction.commit();
|
||||
//自定义空数据背景View
|
||||
conversationListFragment.setEmptyView(com.yunbao.live.R.layout.view_layout_msg);
|
||||
//初始化系统消息界面
|
||||
View rootView = LayoutInflater.from(mContext).inflate(R.layout.view_system_message, null, true);
|
||||
RecyclerView systemMessageList = rootView.findViewById(R.id.system_message_list);
|
||||
messageAdapter = new SystemMessageAdapter(mContext);
|
||||
messageAdapter.addDataAll(listUserBean);
|
||||
systemMessageList.setHasFixedSize(false);
|
||||
systemMessageList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, true));
|
||||
systemMessageList.setAdapter(messageAdapter);
|
||||
conversationListFragment.addHeaderView(rootView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ViewClicksAntiShake.clicksAntiShake(v, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
//清除全部消息
|
||||
if (v.getId() == R.id.news_icon_clearance) {
|
||||
DialogUitl.showSimpleDialog(mContext, null, getString(R.string.clear_unread_messages), false, new DialogUitl.SimpleCallback3() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog) {
|
||||
LiveNetManager.get(mContext)
|
||||
.setMessageReadAll(new com.yunbao.common.http.base.HttpCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
textNewsNotice.setVisibility(View.GONE);
|
||||
textNewsInteraction.setVisibility(View.GONE);
|
||||
textNewsOnline.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show( mContext.getString(R.string.net_error));
|
||||
}
|
||||
});
|
||||
MessageIMManager.get(mContext).setSystemNumber(0);
|
||||
EventBus.getDefault().post(new MessageIMEvent().setNumber(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mTabButtonGroup != null) {
|
||||
mTabButtonGroup.cancelAnim();
|
||||
}
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
long curTime = System.currentTimeMillis();
|
||||
if (curTime - mLastClickBackTime > 2000) {
|
||||
mLastClickBackTime = curTime;
|
||||
ToastUtil.show(WordUtil.getNewString(R.string.main_click_next_exit));
|
||||
} else {
|
||||
EventBus.getDefault().post(new PDLiveConversationListEvent().setPage(11));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onMessageIMEvent(MessageIMEvent event) {
|
||||
if (redPoint == null) return;
|
||||
if (event.getNumber() > 0) {
|
||||
if (event.getNumber() > 99) {
|
||||
redPoint.setText(String.valueOf("99+"));
|
||||
} else {
|
||||
redPoint.setText(String.valueOf(event.getNumber()));
|
||||
}
|
||||
redPoint.setVisibility(View.VISIBLE);
|
||||
|
||||
} else {
|
||||
redPoint.setVisibility(View.GONE);
|
||||
redPoint.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
//红点(我的)
|
||||
public void onUpdateFieldEvent(UpdateTablePointMe updateTablePointMe) {
|
||||
//不需要展示【我的】紅點
|
||||
/* if (redpointMe == null) return;
|
||||
if (updateTablePointMe.getPoint() == 0) {
|
||||
redpointMe.setVisibility(View.GONE);
|
||||
} else {
|
||||
redpointMe.setVisibility(View.VISIBLE);
|
||||
}*/
|
||||
}
|
||||
|
||||
//更新系統消息
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onImUserInfoModel(ImUserInfoModel model) {
|
||||
messageAdapter.upDataMessage(model);
|
||||
int systemNumber = 0;
|
||||
for (ImUserBean userBean : listUserBean) {
|
||||
//未读消息数
|
||||
String number = userBean.getNum();
|
||||
//未读消息不为空并且大于0
|
||||
try {
|
||||
if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) {
|
||||
systemNumber = Integer.parseInt(number) + systemNumber;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
systemNumber = systemNumber + 0;
|
||||
}
|
||||
}
|
||||
switch (model.getType()) {
|
||||
//官方通知
|
||||
case "1":
|
||||
if (textNewsNotice.getVisibility() == View.GONE) {
|
||||
textNewsNotice.setVisibility(View.GONE);
|
||||
textNewsNotice.setText("");
|
||||
} else {
|
||||
String number = textNewsNotice.getText().toString().trim();
|
||||
int numberInt = Integer.parseInt(number) + 1;
|
||||
textNewsNotice.setVisibility(View.VISIBLE);
|
||||
textNewsNotice.setText(String.valueOf(numberInt));
|
||||
}
|
||||
|
||||
break;
|
||||
//互動消息
|
||||
case "2":
|
||||
if (textNewsInteraction.getVisibility() == View.GONE) {
|
||||
textNewsInteraction.setVisibility(View.GONE);
|
||||
textNewsInteraction.setText("");
|
||||
} else {
|
||||
String number = textNewsInteraction.getText().toString().trim();
|
||||
int numberInt = Integer.parseInt(number) + 1;
|
||||
textNewsInteraction.setVisibility(View.VISIBLE);
|
||||
textNewsInteraction.setText(String.valueOf(numberInt));
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
//在線客服
|
||||
case "3":
|
||||
if (textNewsOnline.getVisibility() == View.GONE) {
|
||||
textNewsOnline.setVisibility(View.GONE);
|
||||
textNewsOnline.setText("");
|
||||
} else {
|
||||
String number = textNewsOnline.getText().toString().trim();
|
||||
int numberInt = Integer.parseInt(number) + 1;
|
||||
textNewsOnline.setVisibility(View.VISIBLE);
|
||||
textNewsOnline.setText(String.valueOf(numberInt));
|
||||
}
|
||||
break;
|
||||
}
|
||||
systemNumber = systemNumber + 1;
|
||||
MessageIMManager.get(mContext).setSystemNumber(systemNumber);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import static android.util.Log.i;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
//充值h5
|
||||
public class RechargeActivity extends AbsActivity {
|
||||
|
||||
private WebView rlWebview;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
initView();
|
||||
rlWebview.loadUrl(getIntent().getStringExtra("url"));
|
||||
i("tag", getIntent().getStringExtra("url"));
|
||||
WebSettings webSettings = rlWebview.getSettings();
|
||||
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setTextZoom(100);
|
||||
webSettings.setUseWideViewPort(true);
|
||||
|
||||
webSettings.setJavaScriptEnabled(true); // 是否开启JS支持
|
||||
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
|
||||
|
||||
rlWebview.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, rlWebview).setPageClose(true), "androidObject");
|
||||
|
||||
TestWebViewClient testWebViewClient = new TestWebViewClient(this, rlWebview);
|
||||
|
||||
rlWebview.setWebViewClient(testWebViewClient);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_recharge;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
rlWebview = (WebView) findViewById(R.id.rlWebview);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.RecommendAdapter;
|
||||
import com.yunbao.main.bean.RecommendBean;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/11/2.
|
||||
*/
|
||||
|
||||
public class RecommendActivity extends AbsActivity implements View.OnClickListener {
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private RecommendAdapter mAdapter;
|
||||
private boolean mShowInvite;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_recommend;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
mShowInvite = getIntent().getBooleanExtra(Constants.SHOW_INVITE, false);
|
||||
findViewById(R.id.btn_enter).setOnClickListener(this);
|
||||
findViewById(R.id.btn_skip).setOnClickListener(this);
|
||||
mRecyclerView = findViewById(R.id.recyclerView);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new GridLayoutManager(mContext, 3, GridLayoutManager.VERTICAL, false));
|
||||
MainHttpUtil.getRecommend(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
List<RecommendBean> list = JSON.parseArray(Arrays.toString(info), RecommendBean.class);
|
||||
if (mAdapter == null) {
|
||||
mAdapter = new RecommendAdapter(mContext, list);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void forward(Context context, boolean showInvite) {
|
||||
Intent intent = new Intent(context, RecommendActivity.class);
|
||||
intent.putExtra(Constants.SHOW_INVITE, showInvite);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_enter) {
|
||||
enter();
|
||||
|
||||
} else if (i == R.id.btn_skip) {
|
||||
skip();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void enter() {
|
||||
if (mAdapter == null) {
|
||||
skip();
|
||||
return;
|
||||
}
|
||||
String uids = mAdapter.getCheckedUid();
|
||||
if (TextUtils.isEmpty(uids)) {
|
||||
skip();
|
||||
return;
|
||||
}
|
||||
MainHttpUtil.recommendFollow(uids, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
skip();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳过
|
||||
*/
|
||||
private void skip() {
|
||||
MainActivity.forward(mContext, mShowInvite);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
skip();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_RECOMMEND);
|
||||
MainHttpUtil.cancel(MainHttpConsts.RECOMMEND_FOLLOW);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.RedPacketListBean;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
@Route(path = RouteUtil.PATH_RED_PACKET_INFO)
|
||||
public class RedPacketInfoActivity extends AbsActivity implements View.OnClickListener {
|
||||
private RedPacketListBean bean;
|
||||
private ImageView icon;
|
||||
private ImageView gold;
|
||||
private TextView title;
|
||||
private TextView money;
|
||||
private TextView status;
|
||||
private TextView info;
|
||||
private TextView time;
|
||||
private TextView model;
|
||||
private TextView backAccountText;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_red_packet_info;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void main() {
|
||||
super.main();
|
||||
bean = (RedPacketListBean) getIntent().getSerializableExtra("bean");
|
||||
icon = findViewById(R.id.icon);
|
||||
title = findViewById(R.id.title);
|
||||
money = findViewById(R.id.money);
|
||||
status = findViewById(R.id.red_packet_status);
|
||||
info = findViewById(R.id.red_packet_info);
|
||||
time = findViewById(R.id.red_packet_timer);
|
||||
model = findViewById(R.id.red_packet_model);
|
||||
gold = findViewById(R.id.gold_icon);
|
||||
backAccountText = findViewById(R.id.backAccountText);
|
||||
findViewById(R.id.btn_back).setOnClickListener(this);
|
||||
info.setOnClickListener(this);
|
||||
|
||||
title.setText(bean.getLiveNicename());
|
||||
time.setText(bean.getCreateTime());
|
||||
|
||||
money.setText("-" + bean.getAmountDiamond());
|
||||
money.setTextColor(Color.parseColor("#000000"));
|
||||
icon.setImageResource(R.mipmap.diamond);
|
||||
|
||||
if (bean.getCurrentStatus() == RedPacketListBean.RED_PACKET_CURRENT_STATUS_SUCCESS) {
|
||||
status.setText(R.string.red_packet_info_status_success);
|
||||
} else {
|
||||
status.setText(mContext.getString(R.string.red_packet_info_status_timeout));
|
||||
}
|
||||
if (bean.getRedPacketStatus() == 1 && bean.getAmountRefund() == 0) {
|
||||
gold.setVisibility(View.GONE);
|
||||
backAccountText.setText(mContext.getString(R.string.red_packet_info_residue_none));
|
||||
} else {
|
||||
gold.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (bean.getRedPacketStatus() == 2 && bean.getAmountRefund() == 0) {
|
||||
gold.setImageResource(R.mipmap.diamond);
|
||||
backAccountText.setText(" +" + bean.getAmountDiamond()+"\n" + mContext.getString(R.string.red_packet_info_residue_back));
|
||||
} else if (bean.getRedPacketStatus() == 2 && bean.getAmountRefund() > 0) {
|
||||
gold.setImageResource(R.mipmap.gold_coin);
|
||||
backAccountText.setText(" +" + bean.getAmountRefund() +"\n"+ mContext.getString(R.string.red_packet_info_residue_back));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.red_packet_info) {
|
||||
RouteUtil.forwardRedPacketUser(bean.getId());
|
||||
} else if (id == R.id.btn_back) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.RedPacketListBean;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.RedPacketListRecyclerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Route(path = RouteUtil.PATH_RED_PACKET_LIST)
|
||||
public class RedPacketListActivity extends AbsActivity {
|
||||
private RecyclerView recyclerView;
|
||||
private RedPacketListRecyclerAdapter adapter;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_red_packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main() {
|
||||
super.main();
|
||||
((TextView) findViewById(R.id.titleView)).setText(mContext.getString(R.string.red_packet_list_title));
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
|
||||
adapter = new RedPacketListRecyclerAdapter(this);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||
recyclerView.setAdapter(adapter);
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
LiveNetManager.get(mContext)
|
||||
.getRedPacketList(new HttpCallback<List<RedPacketListBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<RedPacketListBean> data) {
|
||||
adapter.setList(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.RedPacketDetailsBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.RedPacketUserRecyclerAdapter;
|
||||
|
||||
@Route(path = RouteUtil.PATH_RED_PACKET_USER)
|
||||
public class RedPacketUsersActivity extends AbsActivity implements View.OnClickListener{
|
||||
private RecyclerView recyclerView;
|
||||
private RedPacketUserRecyclerAdapter adapter;
|
||||
private int redPacketId;
|
||||
|
||||
private RoundedImageView avatar;
|
||||
private TextView title;
|
||||
private TextView money;
|
||||
private ImageView icon;
|
||||
private TextView open;
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_red_packet_users;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
super.main();
|
||||
findViewById(R.id.btn_back).setOnClickListener(this);
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
avatar = findViewById(R.id.avatar);
|
||||
title = findViewById(R.id.title);
|
||||
money = findViewById(R.id.money);
|
||||
icon = findViewById(R.id.icon);
|
||||
open = findViewById(R.id.open_packet);
|
||||
redPacketId=getIntent().getIntExtra("id",0);
|
||||
adapter = new RedPacketUserRecyclerAdapter(this);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||
recyclerView.setAdapter(adapter);
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id=v.getId();
|
||||
if(id==R.id.btn_back){
|
||||
finish();
|
||||
}
|
||||
}
|
||||
private void initData() {
|
||||
LiveNetManager.get(mContext)
|
||||
.getRedPacketUserList(redPacketId, new HttpCallback<RedPacketDetailsBean>() {
|
||||
@Override
|
||||
public void onSuccess(RedPacketDetailsBean data) {
|
||||
setData(data);
|
||||
adapter.setList(data.getDetails());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void setData(RedPacketDetailsBean bean){
|
||||
ImgLoader.display(mContext,bean.getAvatarThumb(),avatar);
|
||||
title.setText(bean.getNiceName());
|
||||
money.setText(bean.getDiamond()+"");
|
||||
open.setText(mContext.getString(R.string.red_packet_user_tips)+" "+bean.getAlready()+"/"+bean.getQuantity());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,568 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.home_zdy_img_cn;
|
||||
import static com.yunbao.common.CommonAppContext.home_zdy_img_us;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.DeviceUtils;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.fm.openinstall.OpenInstall;
|
||||
import com.fm.openinstall.listener.AppInstallAdapter;
|
||||
import com.fm.openinstall.model.AppData;
|
||||
import com.sahooz.library.Country;
|
||||
import com.sahooz.library.CountryPicker;
|
||||
import com.sahooz.library.OnPick;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.event.RegSuccessEvent;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/25.
|
||||
*/
|
||||
|
||||
public class RegisterActivity extends AbsActivity {
|
||||
|
||||
private EditText mEditPhone;
|
||||
private EditText mEditCode;
|
||||
private EditText mEditPwd1;
|
||||
private EditText mEditPwd2;
|
||||
private EditText edit_invitecode_2;
|
||||
private TextView mBtnCode;
|
||||
private View mBtnRegister;
|
||||
private Handler mHandler;
|
||||
private static final int TOTAL = 60;
|
||||
private int mCount = TOTAL;
|
||||
private String mGetCode;
|
||||
private String mGetCodeAgain;
|
||||
private Dialog mDialog;
|
||||
private boolean mFirstLogin;//是否是第一次登录
|
||||
private boolean mShowInvite;
|
||||
private String mPromoCode = "";//推广码
|
||||
private String UserID = "";//用户推广码
|
||||
private String mUuidDevice = "";//手机唯一标识符
|
||||
private int mPhoneMinLength = 5;//输入手机号的最小位数
|
||||
private TextView mTvCountryCode;
|
||||
private int mCountryCode = 852;//国家代码
|
||||
private ImageView mIvCountryCode;
|
||||
private WebView webview;
|
||||
private WebSettings webSettings;
|
||||
private LinearLayout yqm_view;
|
||||
private ArrayList<Country> allCountries = new ArrayList<>();
|
||||
private RegisterActivity activity;
|
||||
//网络请求的回执
|
||||
private Handler netHandler = new Handler();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_register;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
activity = this;
|
||||
mEditPhone = (EditText) findViewById(R.id.edit_phone);
|
||||
webview = (WebView) findViewById(R.id.webview);
|
||||
initView();
|
||||
mTvCountryCode = findViewById(R.id.tvCountryCode);
|
||||
mIvCountryCode = findViewById(R.id.ivCountryCode);
|
||||
mEditCode = (EditText) findViewById(R.id.edit_code);
|
||||
mEditPwd1 = (EditText) findViewById(R.id.edit_pwd_1);
|
||||
mEditPwd2 = (EditText) findViewById(R.id.edit_pwd_2);
|
||||
mBtnCode = (TextView) findViewById(R.id.btn_code);
|
||||
mBtnRegister = findViewById(R.id.btn_register);
|
||||
edit_invitecode_2 = (EditText) findViewById(R.id.edit_invitecode_2);
|
||||
yqm_view = (LinearLayout) findViewById(R.id.yqm_view);
|
||||
//获取设备唯一标识符
|
||||
getUuidDevice();
|
||||
getPromoCode();
|
||||
|
||||
mGetCode = mContext.getString(R.string.reg_get_code);
|
||||
mGetCodeAgain = mContext.getString(R.string.reg_get_code_again);
|
||||
mTvCountryCodeClick();
|
||||
mEditPhone.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (!TextUtils.isEmpty(s) && s.length() >= mPhoneMinLength) {
|
||||
mBtnCode.setEnabled(true);
|
||||
} else {
|
||||
mBtnCode.setEnabled(false);
|
||||
}
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
TextWatcher textWatcher = new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
};
|
||||
mEditCode.addTextChangedListener(textWatcher);
|
||||
mEditPwd1.addTextChangedListener(textWatcher);
|
||||
mEditPwd2.addTextChangedListener(textWatcher);
|
||||
mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
mCount--;
|
||||
if (mCount > 0) {
|
||||
mBtnCode.setText(mGetCodeAgain + "(" + mCount + "s)");
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessageDelayed(0, 1000);
|
||||
}
|
||||
} else {
|
||||
mBtnCode.setText(mGetCode);
|
||||
mCount = TOTAL;
|
||||
if (mBtnCode != null) {
|
||||
mBtnCode.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mDialog = DialogUitl.loadingDialog(mContext, getString(R.string.reg_register_ing));
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
allCountries.clear();
|
||||
allCountries.addAll(Country.getAll(mContext, null));
|
||||
|
||||
//String ct = Locale.getDefault().getCountry();
|
||||
String ct = IMLoginManager.get(mContext).getString("sys_user_area");
|
||||
ct = TextUtils.equals("中国", ct) ? "中国香港" : ct;
|
||||
for (int i = 0; i < allCountries.size(); i++) {
|
||||
if (allCountries.get(i).chs.equals(ct)) {
|
||||
String countryName = allCountries.get(i).name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) : countryName;
|
||||
mTvCountryCode.setText("+" + allCountries.get(i).code + " " + countryName);
|
||||
mCountryCode = allCountries.get(i).code;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class JsBridge {
|
||||
@JavascriptInterface
|
||||
public void getData(final String Randstr, final String Ticket) {
|
||||
|
||||
((RegisterActivity) mContext).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i("tvss", Randstr);
|
||||
webview.setVisibility(View.GONE);
|
||||
//获取验证码
|
||||
getMessageCode(Randstr, Ticket);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
webview = (WebView) findViewById(R.id.webview);
|
||||
webSettings = webview.getSettings();
|
||||
webSettings.setUseWideViewPort(true);
|
||||
webSettings.setLoadWithOverviewMode(true);
|
||||
// 禁用缓存
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||
webview.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
view.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
// 开启js支持
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webview.addJavascriptInterface(new JsBridge(), "jsBridge");
|
||||
// 也可以加载本地html(webView.loadUrl("file:///android_asset/xxx.html"))
|
||||
webview.loadUrl(CommonAppConfig.HOST + "/h5/live/TCaptcha.html" + "?isZh=" + (WordUtil.isNewZh() ? "1" : 0));
|
||||
}
|
||||
|
||||
|
||||
private void mTvCountryCodeClick() {
|
||||
mIvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
mTvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void changeEnable() {
|
||||
}
|
||||
|
||||
private void showCountryCode() {
|
||||
CountryPicker.newInstance(null, new OnPick() {
|
||||
@Override
|
||||
public void onPick(Country country) {
|
||||
String countryName = country.name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) + "..." : countryName;
|
||||
mTvCountryCode.setText(" +" + country.code + " " + countryName);
|
||||
mCountryCode = country.code;
|
||||
}
|
||||
}).show(getSupportFragmentManager(), "country");
|
||||
}
|
||||
|
||||
public void registerClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_code) {
|
||||
webview.setVisibility(View.VISIBLE);
|
||||
|
||||
} else if (i == R.id.btn_register) {
|
||||
register();
|
||||
} else if (i == R.id.btn_tip2) {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY1 + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"), false);
|
||||
} else if (i == R.id.btn_tip3) {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY2 + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"), false);
|
||||
}
|
||||
}
|
||||
|
||||
private void getUuidDevice() {
|
||||
String uuid = DeviceUtils.getUniqueDeviceId();
|
||||
if (uuid != null) {
|
||||
mUuidDevice = uuid;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短信验证码
|
||||
*/
|
||||
private void getMessageCode(String Randstr, String Ticket) {
|
||||
String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
mEditCode.requestFocus();
|
||||
MainHttpUtil.getRegisterCode(Randstr, Ticket, phoneNum, mCountryCode, mGetCodeCallback);
|
||||
}
|
||||
|
||||
private HttpCallback mGetCodeCallback = new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
mBtnCode.setEnabled(false);
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessage(0);
|
||||
}
|
||||
if (!TextUtils.isEmpty(msg) && msg.contains("123456")) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 注册并登陆
|
||||
*/
|
||||
private void register() {
|
||||
final String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
String code = mEditCode.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(code)) {
|
||||
mEditCode.setError(mContext.getString(R.string.reg_input_code));
|
||||
mEditCode.requestFocus();
|
||||
return;
|
||||
}
|
||||
final String pwd = mEditPwd1.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd)) {
|
||||
mEditPwd1.setError(mContext.getString(R.string.reg_input_pwd_1));
|
||||
mEditPwd1.requestFocus();
|
||||
return;
|
||||
}
|
||||
String pwd2 = mEditPwd2.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_input_pwd_2));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (!pwd.equals(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_pwd_error));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (mDialog != null) {
|
||||
mDialog.show();
|
||||
}
|
||||
String ti = "";
|
||||
if (edit_invitecode_2.getText().toString().trim().equals("此設備已註冊")) {
|
||||
ti = "";
|
||||
} else {
|
||||
ti = edit_invitecode_2.getText().toString().trim();
|
||||
}
|
||||
MainHttpUtil.register(UserID, ti, phoneNum, mPromoCode, mUuidDevice, mCountryCode, pwd, pwd2, code, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
//注册成功
|
||||
login(phoneNum, pwd, mUuidDevice);
|
||||
OpenInstall.reportRegister();
|
||||
} else {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//从网页获取推广码
|
||||
private void getPromoCode() {
|
||||
|
||||
OpenInstall.getInstall(new AppInstallAdapter() {
|
||||
@Override
|
||||
public void onInstall(AppData appData) {
|
||||
//获取渠道数据
|
||||
String channelCode = appData.getChannel();
|
||||
//获取自定义数据
|
||||
if (appData.getData() != null && !appData.getData().equals("")) {
|
||||
JSONObject data = JSON.parseObject(appData.getData());
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2|| CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
yqm_view.setVisibility(View.VISIBLE);
|
||||
MainHttpUtil.getDeviceLoginType(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 201) {
|
||||
edit_invitecode_2.setText("此設備已註冊");
|
||||
edit_invitecode_2.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
yqm_view.setVisibility(View.GONE);
|
||||
//推广的码
|
||||
mPromoCode = data.getString("admin_id") + "";
|
||||
//用户的码
|
||||
UserID = data.getString("user_id") + "";
|
||||
}
|
||||
Log.d("OpenInstall", UserID + "appData.getData()1111= " + mPromoCode);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void login(String phoneNum, String pwd, String uuid) {
|
||||
MainHttpUtil.login(phoneNum, pwd, uuid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
String uid = obj.getString("id");
|
||||
String token = obj.getString("token");
|
||||
mFirstLogin = obj.getIntValue("first_login") == 1;
|
||||
mShowInvite = obj.getIntValue("isagent") == 1;
|
||||
CommonAppConfig.getInstance().setLoginInfo(uid, token, true);
|
||||
//设置登录信息
|
||||
IMLoginModel model = GsonUtils.fromJson(info[0], IMLoginModel.class);
|
||||
IMLoginManager.get(activity).setupLoginUser(model);
|
||||
//融云连接服务器
|
||||
RongcloudIMManager.connectIM(activity);
|
||||
getBaseUserInfo();
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
private void getBaseUserInfo() {
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
if (bean != null) {
|
||||
netHandler.post(getRandJoinAnchor);
|
||||
// EventBus.getDefault().post(new RegSuccessEvent());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户自动签到
|
||||
*/
|
||||
private Runnable getRandJoinAnchor = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IMLoginModel userInfo = IMLoginManager.get(activity).getUserInfo();
|
||||
HttpClient.getInstance().post("Home.getRandJoinAnchor", "Home.getRandJoinAnchor").params("uid", userInfo.getId()).params("token", userInfo.getToken()).execute(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (info[0] != null) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
IMLoginManager.get(activity).setisNewUserOne(true);
|
||||
IMLoginManager.get(activity).setNewUserGif(true);
|
||||
if (obj.containsKey("home_zdy_img_us")) {
|
||||
home_zdy_img_us = obj.getString("home_zdy_img_us");
|
||||
home_zdy_img_cn = obj.getString("home_zdy_img_cn");
|
||||
}
|
||||
gotoLive(obj.getString("anchor_id"));
|
||||
if (obj.containsKey("home_zdy_pop")) {
|
||||
NoviceInstructorManager.get(mContext).setHomeZdyPop(obj.getString("home_zdy_pop"));
|
||||
}
|
||||
jumpMain(false);
|
||||
} else {
|
||||
jumpMain(false);
|
||||
}
|
||||
EventBus.getDefault().post(new RegSuccessEvent());
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private void jumpMain(boolean showInvite) {
|
||||
Intent intent = new Intent(activity, MainActivity.class);
|
||||
intent.putExtra(Constants.SHOW_INVITE, showInvite);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
NoviceInstructorManager.get(mContext).setFrist(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
MainActivity.forward(RegisterActivity.this, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRegSuccessEvent(RegSuccessEvent e) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_REGISTER_CODE);
|
||||
MainHttpUtil.cancel(MainHttpConsts.REGISTER);
|
||||
MainHttpUtil.cancel(MainHttpConsts.LOGIN);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_BASE_INFO);
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mHandler = null;
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
434
main/src/main/java/com/yunbao/main/activity/RewardActivity.java
Normal file
@@ -0,0 +1,434 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.opensource.svgaplayer.SVGACallback;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.ActivityResultCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.share.ui.InvitePopDialog;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
|
||||
@Route(path = RouteUtil.PATH_REWARD)
|
||||
public class RewardActivity extends AbsActivity {
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private WebView mWebView;
|
||||
private final int CHOOSE = 100;//Android 5.0以下的
|
||||
private final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
|
||||
private ValueCallback<Uri> mValueCallback;
|
||||
private ValueCallback<Uri[]> mValueCallback2;
|
||||
private SVGAImageView svga;
|
||||
private ProcessImageUtil mImageUtil;
|
||||
private boolean isUpdataUser = false;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_reward;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
String url = getIntent().getStringExtra(Constants.URL);
|
||||
L.e("H5---10>" + url);
|
||||
LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
svga = (SVGAImageView) findViewById(R.id.svga);
|
||||
mWebView = new WebView(mContext);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
rootView.addView(mWebView);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
setTitle(view.getTitle());
|
||||
}
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
Intent intent = fileChooserParams.createIntent();
|
||||
startActivityForResult(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持
|
||||
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView)
|
||||
.setPageClose(true)
|
||||
.setLiveZhuangBana(false), "androidObject");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
|
||||
updataImg();
|
||||
}
|
||||
|
||||
|
||||
private void updataImg() {
|
||||
mImageUtil = new ProcessImageUtil(this);
|
||||
mImageUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
@Override
|
||||
public void beforeCamera() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
if (file != null) {
|
||||
MainHttpUtil.updateAvatar(file, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
ToastUtil.show(com.yunbao.main.R.string.edit_profile_update_avatar_success);
|
||||
UserBean bean = CommonAppConfig.getInstance().getUserBean();
|
||||
if (bean != null) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
bean.setAvatar(obj.getString("avatar"));
|
||||
bean.setAvatarThumb(obj.getString("avatarThumb"));
|
||||
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
|
||||
v2TIMUserFullInfo.setFaceUrl(obj.getString("avatarThumb"));
|
||||
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void forwardSign() {
|
||||
UserBean mUserBean = CommonAppConfig.getInstance().getUserBean();
|
||||
if (mUserBean == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(mContext, EditSignActivity.class);
|
||||
intent.putExtra(Constants.SIGN, mUserBean.getSignature());
|
||||
mImageUtil.startActivityForResult(intent, new ActivityResultCallback() {
|
||||
@Override
|
||||
public void onSuccess(Intent intent) {
|
||||
if (intent != null) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(Intent.createChooser(intent,mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
switch (requestCode) {
|
||||
case CHOOSE://5.0以下选择图片后的回调
|
||||
processResult(resultCode, intent);
|
||||
break;
|
||||
case CHOOSE_ANDROID_5://5.0以上选择图片后的回调
|
||||
processResultAndroid5(resultCode, intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void processResult(int resultCode, Intent intent) {
|
||||
if (mValueCallback == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
Uri result = intent.getData();
|
||||
mValueCallback.onReceiveValue(result);
|
||||
} else {
|
||||
mValueCallback.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback = null;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void processResultAndroid5(int resultCode, Intent intent) {
|
||||
if (mValueCallback2 == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
mValueCallback2.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
|
||||
} else {
|
||||
mValueCallback2.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback2 = null;
|
||||
}
|
||||
|
||||
protected boolean canGoBack() {
|
||||
return mWebView != null && mWebView.canGoBack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isNeedExitActivity()) {
|
||||
finish();
|
||||
} else {
|
||||
if (canGoBack()) {
|
||||
mWebView.goBack();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isNeedExitActivity() {
|
||||
if (mWebView != null) {
|
||||
String url = mWebView.getUrl();
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
return url.contains("g=Appapi&m=Auth&a=success")//身份认证成功页面
|
||||
|| url.contains("g=Appapi&m=Family&a=home");//家族申请提交成功页面
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url, boolean addArgs) {
|
||||
if (addArgs) {
|
||||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken();
|
||||
}
|
||||
Intent intent = new Intent(context, RewardActivity.class);
|
||||
Log.i("tag", url);
|
||||
intent.putExtra(Constants.URL, url+ "&isZh=" + ((IMLoginManager.get(CommonAppContext.sInstance.getBaseContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url) {
|
||||
forward(context, url, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.destroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (Constants.isShowPage != -1) {
|
||||
finish();
|
||||
}
|
||||
if (isUpdataUser) {
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
isUpdataUser = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
|
||||
if (!TextUtils.isEmpty(event.getMethod())) {
|
||||
if (TextUtils.equals(event.getMethod(), "androidOpeningNoble")) {
|
||||
try {
|
||||
new SVGAParser(mContext).parse(new URL(event.getSvg()), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
svga.setVisibility(View.VISIBLE);
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
svga.setImageDrawable(drawable);
|
||||
svga.setLoops(1);
|
||||
SVGAViewUtils.playEndClear(svga);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
svga.setCallback(new SVGACallback() {
|
||||
@Override
|
||||
public void onPause() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinished() {
|
||||
svga.clear();
|
||||
svga.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRepeat() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStep(int i, double v) {
|
||||
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (TextUtils.equals(event.getMethod(), "openUpdataName")) {
|
||||
isUpdataUser = event.isUpdataUser();
|
||||
Constants.myIntoIndex = 2;
|
||||
} else if (TextUtils.equals(event.getMethod(), "openUpdataAvater")) {
|
||||
isUpdataUser = true;
|
||||
RouteUtil.forwardEditProfileActivity();
|
||||
} else if (TextUtils.equals(event.getMethod(), "openUpdataAutograph")) {
|
||||
isUpdataUser = true;
|
||||
forwardSign();
|
||||
}else if (event.getMethod().equals("androidInviteShare")) {
|
||||
new InvitePopDialog(mContext)
|
||||
.setUrl(event.getData())
|
||||
.showDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
164
main/src/main/java/com/yunbao/main/activity/SamsungFragment.java
Normal file
@@ -0,0 +1,164 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
|
||||
import static com.yunbao.main.activity.MyWalletActivity.dis;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.facebook.appevents.AppEventsConstants;
|
||||
import com.samsung.android.sdk.iap.lib.helper.HelperDefine;
|
||||
import com.samsung.android.sdk.iap.lib.listener.OnPaymentListener;
|
||||
import com.samsung.android.sdk.iap.lib.vo.ErrorVo;
|
||||
import com.samsung.android.sdk.iap.lib.vo.PurchaseVo;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.pay.samsung.SamsungUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class SamsungFragment extends Fragment {
|
||||
|
||||
private long lastClickTime = 0;
|
||||
private static final long INTERVAL_TIME = 1500;
|
||||
|
||||
private View view;
|
||||
public static String mOrderid, mProductId, MoneyUsds;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
SamsungUtil samsungUtil;
|
||||
|
||||
public SamsungFragment() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//通过参数中的布局填充获取对应布局
|
||||
view = inflater.inflate(R.layout.activity_recharge, container, false);
|
||||
|
||||
assert getArguments() != null;
|
||||
url = getArguments().getString("url");
|
||||
|
||||
if (StringUtil.isEmpty(url)) {
|
||||
Log.e(TAG, "URL为空");
|
||||
return view;
|
||||
}
|
||||
rlWebview = (WebView) view.findViewById(R.id.rlWebview);
|
||||
Log.e("ttt", url);
|
||||
rlWebview.loadUrl(url);
|
||||
initSamsung();
|
||||
WebSettings webSettings = rlWebview.getSettings();
|
||||
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setTextZoom(100);
|
||||
webSettings.setUseWideViewPort(true);
|
||||
|
||||
webSettings.setJavaScriptEnabled(true); // 是否开启JS支持
|
||||
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
|
||||
webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕大小
|
||||
webSettings.setSupportZoom(true); // 是否支持缩放
|
||||
webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放
|
||||
|
||||
rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
|
||||
|
||||
TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview);
|
||||
|
||||
rlWebview.setWebViewClient(testWebViewClient);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
String TAG = "SamsungPay";
|
||||
|
||||
private void initSamsung() {
|
||||
samsungUtil = new SamsungUtil(getActivity());
|
||||
samsungUtil.dispose();
|
||||
samsungUtil.init();
|
||||
}
|
||||
|
||||
private Handler payHandler = new Handler();
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidNewGoToGooglePay(String ProductId, String OrderNumber, String MoneyUsd) {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - lastClickTime > INTERVAL_TIME) {
|
||||
mProductId = ProductId;
|
||||
mOrderid = OrderNumber;
|
||||
MoneyUsds = MoneyUsd;
|
||||
|
||||
SamsungUtil.newInstance(getActivity()).buy(mProductId, new OnPaymentListener() {
|
||||
@Override
|
||||
public void onPayment(ErrorVo _errorVO, PurchaseVo _purchaseVO) {
|
||||
if (_purchaseVO != null) {
|
||||
SamsungUtil.newInstance(getActivity()).consume(_purchaseVO.getPurchaseId());
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// CommonHttpUtil.notifySamsung(_purchaseVO.getPurchaseId(), mOrderid, new HttpCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(int code, String msg, String[] info) {
|
||||
// if (code == 0) {
|
||||
// ToastUtil.show(getString(R.string.pay_suc));
|
||||
// dis();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (_errorVO.getErrorCode() == HelperDefine.IAP_PAYMENT_IS_CANCELED) {
|
||||
ToastUtil.show(getString(R.string.pay_cancel));
|
||||
} else {
|
||||
ToastUtil.show(_errorVO.getErrorString());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
lastClickTime = currentTime;
|
||||
|
||||
Log.e(TAG, "ProductId" + ProductId + "OrderNumber" + OrderNumber + "MoneyUsd" + MoneyUsd);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidMethodBack() {
|
||||
getActivity().onBackPressed();
|
||||
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidGoBack() {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void release() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
233
main/src/main/java/com/yunbao/main/activity/SearchActivity.java
Normal file
@@ -0,0 +1,233 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.event.CloseEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.manager.SearchHistoryRecordManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.WordsTypeUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.event.JumpUserHomeEvent;
|
||||
import com.yunbao.main.fragment.SearchRecommendFragment;
|
||||
import com.yunbao.main.fragment.SearchResultsFragment;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/25.
|
||||
*/
|
||||
|
||||
public class SearchActivity extends AbsActivity {
|
||||
private EditText mEditText;
|
||||
private InputMethodManager imm;
|
||||
|
||||
public static void forward(Context context) {
|
||||
context.startActivity(new Intent(context, SearchActivity.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_search;
|
||||
}
|
||||
|
||||
|
||||
//历史记录
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
//進入頁面首先展示推薦頁面
|
||||
SearchRecommendFragment searchRecommendFragment = new SearchRecommendFragment();
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.context_layout, searchRecommendFragment);
|
||||
transaction.commit();
|
||||
mEditText = findViewById(R.id.edit);
|
||||
findViewById(R.id.btn_delete).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mEditText.setText("");
|
||||
}
|
||||
});
|
||||
findViewById(R.id.btn_delete).setVisibility(View.GONE);
|
||||
mEditText.setOnEditorActionListener(onEditorActionListener);
|
||||
mEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (!s.toString().trim().isEmpty()) {
|
||||
findViewById(R.id.btn_delete).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
//退出检索页面保存搜索记录
|
||||
findViewById(R.id.btn_back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//检索关键字
|
||||
String searchKey = mEditText.getText().toString().trim();
|
||||
if (!TextUtils.isEmpty(searchKey)) {
|
||||
//保存检索历史记录
|
||||
SearchHistoryRecordManager.get(mContext).addHistoryRecord(WordsTypeUtil.changeSimplified(searchKey), WordsTypeUtil.changeTraditional(searchKey));
|
||||
}
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
//检索关键字
|
||||
String searchKey = mEditText.getText().toString().trim();
|
||||
if (!TextUtils.isEmpty(searchKey)) {
|
||||
|
||||
//保存检索历史记录
|
||||
SearchHistoryRecordManager.get(mContext).addHistoryRecord(WordsTypeUtil.changeSimplified(searchKey), WordsTypeUtil.changeTraditional(searchKey));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
//检索关键字
|
||||
String searchKey = mEditText.getText().toString().trim();
|
||||
if (!TextUtils.isEmpty(searchKey)) {
|
||||
//保存检索历史记录
|
||||
SearchHistoryRecordManager.get(mContext).addHistoryRecord(WordsTypeUtil.changeSimplified(searchKey), WordsTypeUtil.changeTraditional(searchKey));
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
TextView.OnEditorActionListener onEditorActionListener = new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||
// 保存关键词到本地数据库
|
||||
String search_word = mEditText.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(search_word.trim())) {
|
||||
//檢索推薦頁面
|
||||
SearchRecommendFragment searchRecommendFragment = new SearchRecommendFragment();
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.context_layout, searchRecommendFragment);
|
||||
transaction.commit();
|
||||
} else {
|
||||
//展示檢索頁面
|
||||
SearchResultsFragment searchResultsFragment = new SearchResultsFragment();
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("searchKey", search_word.toString());
|
||||
searchResultsFragment.setArguments(bundle);
|
||||
transaction.replace(R.id.context_layout, searchResultsFragment);
|
||||
transaction.commit();
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 跳转用户首页
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJumpUserHome(JumpUserHomeEvent event) {
|
||||
LiveHttpUtil.getLiveInfo(event.getModel().getId() + "", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
//跳转到个人资料
|
||||
if (imm != null && mEditText != null) {
|
||||
imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
|
||||
RouteUtil.forwardUserHome(mContext, String.valueOf(event.getModel().getId()), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onChip(String chip) {
|
||||
mEditText.setText(chip);
|
||||
//展示檢索頁面
|
||||
SearchResultsFragment searchResultsFragment = new SearchResultsFragment();
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("searchKey", chip);
|
||||
searchResultsFragment.setArguments(bundle);
|
||||
transaction.replace(R.id.context_layout, searchResultsFragment);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onClose(CloseEvent event) {
|
||||
if (!isFinishing()) {
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
}
|
||||
414
main/src/main/java/com/yunbao/main/activity/SettingActivity.java
Normal file
@@ -0,0 +1,414 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import static com.yunbao.common.Constants.SETTING_CLEAR_CACHE;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lzf.easyfloat.interfaces.OnPermissionResult;
|
||||
import com.lzf.easyfloat.permission.PermissionUtils;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.APKManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.GlideCatchUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.VersionUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.APKUpdateCustomPopup;
|
||||
import com.yunbao.common.views.floatingview.APPEasyFloat;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.SettingAdapter;
|
||||
import com.yunbao.main.bean.SettingBean;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/30.
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_SETTING)
|
||||
public class SettingActivity extends AbsActivity implements OnItemClickListener<SettingBean> {
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private Handler mHandler;
|
||||
private SettingAdapter mAdapter;
|
||||
private ImageView studioGiftEffects, studioRideEffects, upSlideSettings, appWindow, systemWindow;
|
||||
private ImageView liveNotifySettings;
|
||||
private boolean giftEffect, mountEffect, slide, isFloat;
|
||||
private TextView systemHit, reward;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_setting;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.set_up));
|
||||
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
|
||||
studioGiftEffects = findViewById(R.id.studio_gift_effects);
|
||||
studioRideEffects = findViewById(R.id.studio_ride_effects);
|
||||
upSlideSettings = findViewById(R.id.up_slide_settings);
|
||||
liveNotifySettings = findViewById(R.id.live_notify_settings);
|
||||
appWindow = findViewById(R.id.app_window);
|
||||
reward = findViewById(R.id.reward);
|
||||
systemHit = findViewById(R.id.system_hit);
|
||||
systemWindow = findViewById(R.id.system_window);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
IMLoginModel model = IMLoginManager.get(mContext).getUserInfo();
|
||||
reward.setVisibility(model.getIsBind() == 1 ? View.GONE : View.VISIBLE);
|
||||
giftEffect = IMLoginManager.get(mContext).isGiftEffect();
|
||||
mountEffect = IMLoginManager.get(mContext).isMountEffect();
|
||||
MainHttpUtil.getSettingList(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
List<SettingBean> list = JSON.parseArray(Arrays.toString(info), SettingBean.class);
|
||||
SettingBean data1 = new SettingBean();
|
||||
data1.setId(19);
|
||||
data1.setName(mContext.getString(R.string.versions));
|
||||
list.add(data1);
|
||||
|
||||
SettingBean data2 = new SettingBean();
|
||||
data2.setId(25);
|
||||
data2.setName(mContext.getString(R.string.check_the_new_version));
|
||||
list.add(data2);
|
||||
|
||||
SettingBean bean = new SettingBean();
|
||||
bean.setName(mContext.getString(R.string.setting_exit));
|
||||
bean.setLast(true);
|
||||
list.add(bean);
|
||||
|
||||
mAdapter = new SettingAdapter(mContext, list, VersionUtil.getVersion(), getCacheSize());
|
||||
mAdapter.setOnItemClickListener(SettingActivity.this);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
});
|
||||
//跳转自己
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.individual_set), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteUtil.forwardEditProfileActivity();
|
||||
}
|
||||
});
|
||||
|
||||
//黑名单
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.blacklist), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
FollowActivity.forward(mContext, CommonAppConfig.getInstance().getUid(), 1);
|
||||
}
|
||||
});
|
||||
//修改密码
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.change_the_password), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
forwardModifyPwd();
|
||||
}
|
||||
});
|
||||
//消息通知
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.alerts), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
startActivity(new Intent(SettingActivity.this, MsgSettActivity.class));
|
||||
}
|
||||
});
|
||||
//语言设置
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.language_setting), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
startActivity(new Intent(SettingActivity.this, LanguageSettingActivity.class));
|
||||
}
|
||||
});
|
||||
//屏蔽礼物特效
|
||||
ViewClicksAntiShake.clicksAntiShake(studioGiftEffects, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
giftEffect = !giftEffect;
|
||||
if (giftEffect) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, studioGiftEffects);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, studioGiftEffects);
|
||||
}
|
||||
//更新特效开关
|
||||
IMLoginManager.get(mContext).setGiftEffect(giftEffect);
|
||||
}
|
||||
|
||||
});
|
||||
//屏蔽礼物特效
|
||||
ViewClicksAntiShake.clicksAntiShake(studioRideEffects, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
mountEffect = !mountEffect;
|
||||
if (mountEffect) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, studioRideEffects);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, studioRideEffects);
|
||||
}
|
||||
//更新特效开关
|
||||
IMLoginManager.get(mContext).setMountEffect(mountEffect);
|
||||
}
|
||||
});
|
||||
//直播间滚动
|
||||
ViewClicksAntiShake.clicksAntiShake(upSlideSettings, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
slide = !slide;
|
||||
if (slide) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, upSlideSettings);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, upSlideSettings);
|
||||
}
|
||||
//滑动设置
|
||||
IMLoginManager.get(mContext).initSlide(slide);
|
||||
}
|
||||
});
|
||||
//APP内小窗
|
||||
ViewClicksAntiShake.clicksAntiShake(appWindow, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
isFloat = !isFloat;
|
||||
if (!isFloat) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, appWindow);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, appWindow);
|
||||
}
|
||||
//更新特效开关
|
||||
IMLoginManager.get(mContext).initFloat(isFloat);
|
||||
APPEasyFloat.getInstance().dismiss(mContext);
|
||||
}
|
||||
});
|
||||
//系统悬浮窗
|
||||
ViewClicksAntiShake.clicksAntiShake(systemWindow, () -> {
|
||||
PermissionUtils.requestPermission(mContext, new OnPermissionResult() {
|
||||
@Override
|
||||
public void permissionResult(boolean isFloat) {
|
||||
if (!isFloat) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, systemWindow);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, systemWindow);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
//系统悬浮窗
|
||||
ViewClicksAntiShake.clicksAntiShake(systemHit, () -> {
|
||||
PermissionUtils.requestPermission(mContext, new OnPermissionResult() {
|
||||
@Override
|
||||
public void permissionResult(boolean isFloat) {
|
||||
if (!isFloat) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, systemWindow);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, systemWindow);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
ViewClicksAntiShake.clicksAntiShake(liveNotifySettings, () -> {
|
||||
boolean isTrue = IMLoginManager.get(mContext).isLiveNotifySettings();
|
||||
if (isTrue) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, liveNotifySettings);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, liveNotifySettings);
|
||||
}
|
||||
IMLoginManager.get(mContext).setLiveNotifySettings(!isTrue);
|
||||
});
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder(getString(com.yunbao.common.R.string.system_window_hint));
|
||||
String goTo = getString(com.yunbao.common.R.string.to_open_the);
|
||||
int star = builder.length();
|
||||
int end = star + goTo.length();
|
||||
builder.append(goTo);
|
||||
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#ffaf08")),
|
||||
star, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
systemHit.setText(builder);
|
||||
boolean floatPermission = PermissionUtils.checkPermission(mContext);
|
||||
if (!floatPermission) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, systemWindow);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, systemWindow);
|
||||
}
|
||||
isFloat = IMLoginManager.get(mContext).isFloat();
|
||||
if (!isFloat) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, appWindow);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, appWindow);
|
||||
}
|
||||
slide = IMLoginManager.get(mContext).isSlide();
|
||||
if (slide) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, upSlideSettings);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, upSlideSettings);
|
||||
}
|
||||
if (giftEffect) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, studioGiftEffects);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, studioGiftEffects);
|
||||
}
|
||||
if (mountEffect) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, studioRideEffects);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, studioRideEffects);
|
||||
}
|
||||
if(IMLoginManager.get(mContext).isLiveNotifySettings()){
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, liveNotifySettings);
|
||||
}else{
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, liveNotifySettings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onItemClick(SettingBean bean, int position) {
|
||||
String href = bean.getHref();
|
||||
if (TextUtils.isEmpty(href)) {
|
||||
if (bean.isLast()) {//退出登录
|
||||
logout();
|
||||
} else if (bean.getId() == Constants.SETTING_MODIFY_PWD) {//修改密码
|
||||
forwardModifyPwd();
|
||||
} else if (bean.getId() == Constants.SETTING_UPDATE_ID) {//检查更新
|
||||
checkVersion();
|
||||
} else if (bean.getId() == Constants.SETTING_ISBLACK) {//拉黑列表
|
||||
FollowActivity.forward(mContext, CommonAppConfig.getInstance().getUid(), 1);
|
||||
} else if (bean.getId() == SETTING_CLEAR_CACHE) {//清除缓存
|
||||
clearCache(position);
|
||||
} else if (bean.getId() == 21) {//清除缓存
|
||||
startActivity(new Intent(SettingActivity.this, MsgSettActivity.class));
|
||||
} else if (bean.getId() == 25) {//版本更新
|
||||
if (!APKManager.get().getApkVerNew()) {
|
||||
new XPopup.Builder(mContext)
|
||||
.asCustom(new APKUpdateCustomPopup(mContext, true))
|
||||
.show();
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (bean.getId() == 17) {//意见反馈要在url上加版本号和设备号
|
||||
href += "&version=" + android.os.Build.VERSION.RELEASE + "&model=" + android.os.Build.MODEL;
|
||||
}
|
||||
WebViewActivity.forward(mContext, href,false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查更新
|
||||
*/
|
||||
private void checkVersion() {
|
||||
// CommonAppConfig.getInstance().getConfig(new CommonCallback<ConfigBean>() {
|
||||
// @Override
|
||||
// public void callback(ConfigBean configBean) {
|
||||
// if (configBean != null) {
|
||||
// if (VersionUtil.isLatest(configBean.getVersion())) {
|
||||
// ToastUtil.show(R.string.version_latest);
|
||||
// } else {
|
||||
// VersionUtil.showDialog(mContext, configBean, configBean.getDownloadApkUrl());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
private void logout() {
|
||||
IMLoginManager.get(this).logout(this);
|
||||
CommonAppConfig.getInstance().clearLoginInfo();
|
||||
RCRTCEngine.getInstance().unInit();
|
||||
RongIMClient.getInstance().logout();
|
||||
Intent intent = new Intent(SettingActivity.this, EntryActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
Constants.firstInto = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
private void forwardModifyPwd() {
|
||||
startActivity(new Intent(mContext, ModifyPwdActivity.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
*/
|
||||
private String getCacheSize() {
|
||||
return GlideCatchUtil.getInstance().getCacheSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
*/
|
||||
private void clearCache(final int position) {
|
||||
final Dialog dialog = DialogUitl.loadingDialog(mContext, getString(R.string.setting_clear_cache_ing));
|
||||
dialog.show();
|
||||
GlideCatchUtil.getInstance().clearImageAllCache();
|
||||
File gifGiftDir = new File(CommonAppConfig.GIF_PATH);
|
||||
if (gifGiftDir.exists() && gifGiftDir.length() > 0) {
|
||||
gifGiftDir.delete();
|
||||
}
|
||||
if (mHandler == null) {
|
||||
mHandler = new Handler();
|
||||
}
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setCacheString(getCacheSize());
|
||||
mAdapter.notifyItemChanged(position);
|
||||
}
|
||||
ToastUtil.show(mContext.getString(R.string.setting_clear_cache));
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mHandler = null;
|
||||
}
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_SETTING_LIST);
|
||||
CommonHttpUtil.cancel(CommonHttpConsts.GET_CONFIG);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.yunbao.share.platform.FacebookShare;
|
||||
import com.yunbao.share.platform.MessengerShare;
|
||||
|
||||
|
||||
public class TestActivity extends AppCompatActivity {
|
||||
private TextView contextLayout;
|
||||
private ListView listView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
listView = new ListView(this);
|
||||
setContentView(listView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
Log.i("分享log", "onActivityResult() called with: requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data.getAction() + "]");
|
||||
if (FacebookShare.callbackManager != null) {
|
||||
FacebookShare.callbackManager.onActivityResult(requestCode, resultCode, data);
|
||||
} else if (MessengerShare.callbackManager != null) {
|
||||
MessengerShare.callbackManager.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.BitmapUtil;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ProcessResultUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.dialog.LiveShareDialogFragment;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2019/4/29.
|
||||
* 三级分销
|
||||
*/
|
||||
|
||||
public class ThreeDistributActivity extends AbsActivity implements View.OnClickListener, LiveShareDialogFragment.ActionListener {
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private WebView mWebView;
|
||||
private final int CHOOSE = 100;//Android 5.0以下的
|
||||
private final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
|
||||
private ValueCallback<Uri> mValueCallback;
|
||||
private ValueCallback<Uri[]> mValueCallback2;
|
||||
private TextView mInviteCode;//邀请码
|
||||
private View mContainer;
|
||||
private ImageView mQrCode;//二维码
|
||||
private File mShareImageFile;//分享图片文件
|
||||
private ProcessResultUtil mProcessResultUtil;
|
||||
// private MobShareUtil mMobShareUtil;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_three_distribut;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
mProcessResultUtil = new ProcessResultUtil(this);
|
||||
Intent intent = getIntent();
|
||||
setTitle(intent.getStringExtra(Constants.TIP));
|
||||
mContainer = findViewById(R.id.share_container);
|
||||
ImageView mAppIcon = findViewById(R.id.app_icon);
|
||||
TextView mAppName = findViewById(R.id.app_name);
|
||||
CommonAppConfig appConfig = CommonAppConfig.getInstance();
|
||||
mAppIcon.setImageResource(appConfig.getAppIconRes());
|
||||
mAppName.setText(appConfig.getAppName());
|
||||
ImageView avatar = findViewById(R.id.avatar);
|
||||
TextView name = findViewById(R.id.name);
|
||||
TextView idVal = findViewById(R.id.id_val);
|
||||
ImageView avatar2 = findViewById(R.id.avatar_2);
|
||||
mInviteCode = findViewById(R.id.invite_code);
|
||||
mQrCode = findViewById(R.id.qr_code);
|
||||
findViewById(R.id.btn_share).setOnClickListener(this);
|
||||
UserBean u = appConfig.getUserBean();
|
||||
if (u != null) {
|
||||
ImgLoader.displayAvatar(mContext, u.getAvatar(), avatar);
|
||||
ImgLoader.displayAvatar(mContext, u.getAvatar(), avatar2);
|
||||
name.setText(u.getUserNiceName());
|
||||
idVal.setText(StringUtil.contact("ID:", u.getId()));
|
||||
}
|
||||
|
||||
|
||||
String url = intent.getStringExtra(Constants.URL);
|
||||
L.e("H5---11>" + url);
|
||||
LinearLayout container = (LinearLayout) findViewById(R.id.container);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
mWebView = new WebView(mContext);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
container.addView(mWebView);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
Intent intent = fileChooserParams.createIntent();
|
||||
startActivityForResult(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
|
||||
MainHttpUtil.getQrCode(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
if (mInviteCode != null) {
|
||||
mInviteCode.setText(obj.getString("code"));
|
||||
}
|
||||
if (mQrCode != null) {
|
||||
ImgLoader.display(mContext, obj.getString("qr"), mQrCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(Intent.createChooser(intent,mContext.getString(com.yunbao.common.R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
switch (requestCode) {
|
||||
case CHOOSE://5.0以下选择图片后的回调
|
||||
processResult(resultCode, intent);
|
||||
break;
|
||||
case CHOOSE_ANDROID_5://5.0以上选择图片后的回调
|
||||
processResultAndroid5(resultCode, intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void processResult(int resultCode, Intent intent) {
|
||||
if (mValueCallback == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
Uri result = intent.getData();
|
||||
mValueCallback.onReceiveValue(result);
|
||||
} else {
|
||||
mValueCallback.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback = null;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void processResultAndroid5(int resultCode, Intent intent) {
|
||||
if (mValueCallback2 == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
mValueCallback2.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
|
||||
} else {
|
||||
mValueCallback2.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback2 = null;
|
||||
}
|
||||
|
||||
protected boolean canGoBack() {
|
||||
return mWebView != null && mWebView.canGoBack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isNeedExitActivity()) {
|
||||
finish();
|
||||
} else {
|
||||
if (canGoBack()) {
|
||||
mWebView.goBack();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isNeedExitActivity() {
|
||||
if (mWebView != null) {
|
||||
String url = mWebView.getUrl();
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
return url.contains("g=Appapi&m=Auth&a=success")//身份认证成功页面
|
||||
|| url.contains("g=Appapi&m=Family&a=home");//家族申请提交成功页面
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static void forward(Context context, String title, String url) {
|
||||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0");
|
||||
Intent intent = new Intent(context, ThreeDistributActivity.class);
|
||||
intent.putExtra(Constants.URL, url);
|
||||
intent.putExtra(Constants.TIP, title);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mProcessResultUtil != null) {
|
||||
mProcessResultUtil.release();
|
||||
}
|
||||
mProcessResultUtil = null;
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_QR_CODE);
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.destroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(com.yunbao.common.R.string.copy_success));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成分享图片
|
||||
*/
|
||||
private void saveBitmapFile() {
|
||||
String[] permissions;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
permissions=new String[]{
|
||||
Manifest.permission.READ_MEDIA_IMAGES
|
||||
};
|
||||
}else{
|
||||
permissions=new String[]{
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
};
|
||||
}
|
||||
mProcessResultUtil.requestPermissions(permissions, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mContainer == null) {
|
||||
return;
|
||||
}
|
||||
mContainer.setDrawingCacheEnabled(true);
|
||||
Bitmap bitmap = mContainer.getDrawingCache();
|
||||
bitmap = Bitmap.createBitmap(bitmap);
|
||||
mContainer.setDrawingCacheEnabled(false);
|
||||
File dir = new File(CommonAppConfig.CAMERA_IMAGE_PATH);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
mShareImageFile = new File(dir, Constants.SHARE_QR_CODE_FILE);
|
||||
boolean result = BitmapUtil.getInstance().saveBitmap(bitmap, mShareImageFile);
|
||||
if (result) {
|
||||
if (bitmap != null && !bitmap.isRecycled()) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
LiveShareDialogFragment fragment = new LiveShareDialogFragment();
|
||||
fragment.setNoLink(true);
|
||||
fragment.setActionListener(ThreeDistributActivity.this);
|
||||
fragment.show(getSupportFragmentManager(), "LiveShareDialogFragment");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.btn_share) {
|
||||
saveBitmapFile();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(String type) {
|
||||
if (mShareImageFile == null) {
|
||||
return;
|
||||
}
|
||||
// if (mMobShareUtil == null) {
|
||||
// mMobShareUtil = new MobShareUtil();
|
||||
// }
|
||||
// mMobShareUtil.shareImage(mContext,type, mShareImageFile.getPath(), null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.UserAvatarSelectBean;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.UserAvatarSelectAdapter;
|
||||
import com.yunbao.main.event.EditProfileEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Route(path = RouteUtil.PATH_SELECT_AVATAR)
|
||||
public class UserAvatarSelectActivity extends AbsActivity {
|
||||
RecyclerView recyclerView;
|
||||
UserAvatarSelectAdapter adapter;
|
||||
TextView titleView;
|
||||
View submit;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_user_select_avatar;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
super.main();
|
||||
titleView = findViewById(R.id.titleView);
|
||||
submit = findViewById(R.id.send);
|
||||
titleView.setText(mContext.getString(R.string.me_edit_avatar_title));
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
adapter = new UserAvatarSelectAdapter(mContext);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(mContext, 3));
|
||||
recyclerView.setAdapter(adapter);
|
||||
initData();
|
||||
|
||||
submit.setOnClickListener(v -> {
|
||||
int id = adapter.getSelect();
|
||||
if (id > -1) {
|
||||
adapter.setDef(id);
|
||||
LiveNetManager.get(mContext)
|
||||
.setSystemUserAvatar(id, new HttpCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
ToastUtil.show(data);
|
||||
IMLoginManager.get(mContext).upDataUserInfo();
|
||||
Bus.get().post(new EditProfileEvent());
|
||||
submit.setBackgroundResource(R.drawable.bg_item_live_send_details_gift_unselect);
|
||||
submit.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
adapter.setOnClickListener(new OnItemClickListener<Integer>() {
|
||||
@Override
|
||||
public void onItemClick(Integer bean, int position) {
|
||||
if (bean == position) {
|
||||
submit.setBackgroundResource(R.drawable.bg_item_live_send_details_gift_unselect);
|
||||
submit.setEnabled(false);
|
||||
} else {
|
||||
submit.setBackgroundResource(R.drawable.bg_item_live_send_details_gift);
|
||||
submit.setEnabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
LiveNetManager.get(mContext)
|
||||
.getSystemUserAvatar(new HttpCallback<List<UserAvatarSelectBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<UserAvatarSelectBean> data) {
|
||||
adapter.setList(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
adapter.setList(new ArrayList<>());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.live.activity.LiveAddImpressActivity;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.main.views.UserHomeViewHolder2;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/25.
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_USER_HOME)
|
||||
public class UserHomeActivity extends AbsActivity {
|
||||
|
||||
private UserHomeViewHolder2 mUserHomeViewHolder;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_empty;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isStatusBarWhite() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Intent intent = getIntent();
|
||||
String toUid = intent.getStringExtra(Constants.TO_UID);
|
||||
if (TextUtils.isEmpty(toUid)) {
|
||||
return;
|
||||
}
|
||||
boolean fromLiveRoom = intent.getBooleanExtra(Constants.FROM_LIVE_ROOM, false);
|
||||
String fromLiveUid = fromLiveRoom ? intent.getStringExtra(Constants.LIVE_UID) : null;
|
||||
mUserHomeViewHolder = new UserHomeViewHolder2(mContext, (ViewGroup) findViewById(R.id.container), toUid, fromLiveRoom,fromLiveUid);
|
||||
mUserHomeViewHolder.addToParent();
|
||||
mUserHomeViewHolder.subscribeActivityLifeCycle();
|
||||
mUserHomeViewHolder.loadData();
|
||||
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
UserBean userBean = CommonAppConfig.getInstance().getUserBean();
|
||||
userBean = bean;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void addImpress(String toUid) {
|
||||
Intent intent = new Intent(mContext, LiveAddImpressActivity.class);
|
||||
intent.putExtra(Constants.TO_UID, toUid);
|
||||
startActivityForResult(intent, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == 100 && resultCode == RESULT_OK) {
|
||||
if (mUserHomeViewHolder != null) {
|
||||
mUserHomeViewHolder.refreshImpress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mUserHomeViewHolder != null) {
|
||||
mUserHomeViewHolder.release();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class WalletFragment extends Fragment {
|
||||
|
||||
|
||||
private View view;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
|
||||
public WalletFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//通过参数中的布局填充获取对应布局
|
||||
|
||||
assert getArguments() != null;
|
||||
url = getArguments().getString("url");
|
||||
|
||||
view = inflater.inflate(R.layout.activity_recharge, container, false);
|
||||
rlWebview = (WebView) view.findViewById(R.id.rlWebview);
|
||||
Log.e("ttt", url);
|
||||
rlWebview.loadUrl(url);
|
||||
|
||||
|
||||
WebSettings webSettings = rlWebview.getSettings();
|
||||
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setTextZoom(100);
|
||||
webSettings.setUseWideViewPort(true);
|
||||
|
||||
webSettings.setJavaScriptEnabled(true); // 是否开启JS支持
|
||||
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
|
||||
|
||||
rlWebview.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(getActivity(), rlWebview).setPageClose(true), "androidObject");
|
||||
|
||||
TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview);
|
||||
|
||||
rlWebview.setWebViewClient(testWebViewClient);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.activity.WebViewActivityMedal;
|
||||
import com.yunbao.live.dialog.LiveUserDialogFragment;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
public class WeekWebViewActivity extends AbsActivity {
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private WebView mWebView;
|
||||
private final int CHOOSE = 100;//Android 5.0以下的
|
||||
private final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
|
||||
private ValueCallback<Uri> mValueCallback;
|
||||
private ValueCallback<Uri[]> mValueCallback2;
|
||||
private ImageView mIvQuestion;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_week_web_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
String url = getIntent().getStringExtra(Constants.URL);
|
||||
L.e("H5---6>" + url);
|
||||
LinearLayout rootView = (LinearLayout) findViewById(com.yunbao.common.R.id.rootView);
|
||||
mIvQuestion = findViewById(com.yunbao.common.R.id.btn_question);
|
||||
mProgressBar = (ProgressBar) findViewById(com.yunbao.common.R.id.progressbar);
|
||||
mWebView = new WebView(mContext);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
rootView.addView(mWebView);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
setTitle(view.getTitle());
|
||||
}
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
Intent intent = fileChooserParams.createIntent();
|
||||
startActivityForResult(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView).setPageClose(true), "androidObject");
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
}
|
||||
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
RouteUtil.forwardUserHome(mContext, live_id, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 显示个人资料弹窗
|
||||
*/
|
||||
private void showUserDialog(String toUid, String liveId) {
|
||||
if (!TextUtils.isEmpty(liveId) && !TextUtils.isEmpty(toUid)) {
|
||||
LiveUserDialogFragment fragment = new LiveUserDialogFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Constants.LIVE_UID, liveId);
|
||||
bundle.putString(Constants.STREAM, "");
|
||||
bundle.putString(Constants.TO_UID, toUid);
|
||||
fragment.setArguments(bundle);
|
||||
fragment.show(((WebViewActivityMedal) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
|
||||
}
|
||||
}
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(Intent.createChooser(intent,mContext.getString(com.yunbao.common.R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
switch (requestCode) {
|
||||
case CHOOSE://5.0以下选择图片后的回调
|
||||
processResult(resultCode, intent);
|
||||
break;
|
||||
case CHOOSE_ANDROID_5://5.0以上选择图片后的回调
|
||||
processResultAndroid5(resultCode, intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void processResult(int resultCode, Intent intent) {
|
||||
if (mValueCallback == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
Uri result = intent.getData();
|
||||
mValueCallback.onReceiveValue(result);
|
||||
} else {
|
||||
mValueCallback.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback = null;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void processResultAndroid5(int resultCode, Intent intent) {
|
||||
if (mValueCallback2 == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
mValueCallback2.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
|
||||
} else {
|
||||
mValueCallback2.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback2 = null;
|
||||
}
|
||||
|
||||
protected boolean canGoBack() {
|
||||
return mWebView != null && mWebView.canGoBack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isNeedExitActivity()) {
|
||||
finish();
|
||||
} else {
|
||||
if (canGoBack()) {
|
||||
mWebView.goBack();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isNeedExitActivity() {
|
||||
if (mWebView != null) {
|
||||
String url = mWebView.getUrl();
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
return url.contains("g=Appapi&m=Auth&a=success")//身份认证成功页面
|
||||
|| url.contains("g=Appapi&m=Family&a=home");//家族申请提交成功页面
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url, boolean addArgs) {
|
||||
if (addArgs) {
|
||||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0");
|
||||
}
|
||||
Intent intent = new Intent(context, WeekWebViewActivity.class);
|
||||
intent.putExtra(Constants.URL, url);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url) {
|
||||
forward(context, url, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.destroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(com.yunbao.common.R.string.copy_success));
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
|
||||
if (!TextUtils.isEmpty(event.getMethod())) {
|
||||
if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) {
|
||||
//看直播
|
||||
gotoLive(event.getLiveId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,422 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.opensource.svgaplayer.SVGACallback;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.AndroidBug5497Workaround;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.MicStatusManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
|
||||
@Route(path = RouteUtil.PATH_ZHUANGBANACTIVITY)
|
||||
public class ZhuangBanActivity extends AbsActivity {
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private WebView mWebView;
|
||||
private final int CHOOSE = 100;//Android 5.0以下的
|
||||
private final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
|
||||
private ValueCallback<Uri> mValueCallback;
|
||||
private ValueCallback<Uri[]> mValueCallback2;
|
||||
private SVGAImageView svga;
|
||||
private View v_spacing;
|
||||
private LinearLayout lt_title;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_zhuang_ban;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
String url = getIntent().getStringExtra(Constants.URL);
|
||||
String titleString = getIntent().getStringExtra("title");
|
||||
if (!"".equals(Constants.myPackageUrl)) {
|
||||
url = Constants.myPackageUrl;
|
||||
}
|
||||
v_spacing = (View) findViewById(R.id.v_spacing);
|
||||
lt_title = (LinearLayout) findViewById(R.id.lt_title);
|
||||
LinearLayout rootView = (LinearLayout) findViewById(com.yunbao.live.R.id.rootView);
|
||||
if (getIntent().hasExtra("title")) {
|
||||
if (TextUtils.isEmpty(titleString)) {
|
||||
lt_title.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (TextUtils.equals(titleString, "blank")) {
|
||||
lt_title.setVisibility(View.GONE);
|
||||
} else {
|
||||
lt_title.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
L.e("H5---5>" + url);
|
||||
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
svga = (SVGAImageView) findViewById(R.id.svga);
|
||||
mWebView = new WebView(mContext);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
params.bottomMargin = DpUtil.dp2px(15);
|
||||
mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
rootView.addView(mWebView);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
if (TextUtils.isEmpty(titleString)) {
|
||||
setTitle(view.getTitle());
|
||||
} else {
|
||||
setTitle(titleString);
|
||||
}
|
||||
int height = view.getMeasuredHeight();
|
||||
Log.e("网页高度", height + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||
super.onReceivedHttpError(view, request, errorResponse);
|
||||
}
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
Intent intent = fileChooserParams.createIntent();
|
||||
startActivityForResult(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持
|
||||
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView)
|
||||
.setPageClose(true)
|
||||
.setLiveZhuangBana(false), "androidObject");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
AndroidBug5497Workaround.assistActivity(this);
|
||||
}
|
||||
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(Intent.createChooser(intent, mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
switch (requestCode) {
|
||||
case CHOOSE://5.0以下选择图片后的回调
|
||||
processResult(resultCode, intent);
|
||||
break;
|
||||
case CHOOSE_ANDROID_5://5.0以上选择图片后的回调
|
||||
processResultAndroid5(resultCode, intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void processResult(int resultCode, Intent intent) {
|
||||
if (mValueCallback == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
Uri result = intent.getData();
|
||||
mValueCallback.onReceiveValue(result);
|
||||
} else {
|
||||
mValueCallback.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback = null;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void processResultAndroid5(int resultCode, Intent intent) {
|
||||
if (mValueCallback2 == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
mValueCallback2.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
|
||||
} else {
|
||||
mValueCallback2.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback2 = null;
|
||||
}
|
||||
|
||||
protected boolean canGoBack() {
|
||||
return mWebView != null && mWebView.canGoBack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isNeedExitActivity()) {
|
||||
finish();
|
||||
} else {
|
||||
if (canGoBack()) {
|
||||
mWebView.goBack();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isNeedExitActivity() {
|
||||
if (mWebView != null) {
|
||||
String url = mWebView.getUrl();
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
return url.contains("g=Appapi&m=Auth&a=success")//身份认证成功页面
|
||||
|| url.contains("g=Appapi&m=Family&a=home");//家族申请提交成功页面
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url, boolean addArgs) {
|
||||
if (addArgs) {
|
||||
if (url.contains("?")) {
|
||||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0");
|
||||
} else {
|
||||
url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0");
|
||||
}
|
||||
|
||||
}
|
||||
Intent intent = new Intent(context, ZhuangBanActivity.class);
|
||||
Log.i("tag1212", url);
|
||||
intent.putExtra(Constants.URL, url + "&isZh=" + ((IMLoginManager.get(CommonAppContext.sInstance.getBaseContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
if (url.contains("Noble/index.html") || url.contains("Grade/index.html")) {
|
||||
intent.putExtra("title", "");
|
||||
}
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url) {
|
||||
forward(context, url, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.destroy();
|
||||
}
|
||||
Constants.myPackageUrl = "";
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (Constants.isShowPage != -1) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
|
||||
if (!TextUtils.isEmpty(event.getMethod())) {
|
||||
if (TextUtils.equals(event.getMethod(), "androidOpeningNoble")) {
|
||||
try {
|
||||
new SVGAParser(mContext).parse(new URL(event.getSvg()), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
svga.setVisibility(View.VISIBLE);
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
svga.setImageDrawable(drawable);
|
||||
svga.setLoops(1);
|
||||
SVGAViewUtils.playEndClear(svga);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
svga.setCallback(new SVGACallback() {
|
||||
@Override
|
||||
public void onPause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinished() {
|
||||
svga.clear();
|
||||
svga.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRepeat() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStep(int i, double v) {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) {
|
||||
//看直播
|
||||
gotoLive(event.getLiveId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id + "", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
if (MicStatusManager.getInstance().isMic(liveUid)) {
|
||||
MicStatusManager.getInstance().showDownMicDialog(mContext);
|
||||
return;
|
||||
}
|
||||
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
RouteUtil.forwardUserHome(mContext, String.valueOf(live_id), 0);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.bean.BattlePassPoints;
|
||||
import com.yunbao.common.dialog.WarOrderExchangeDetailsPopupWindow;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BattlePassExchangeAdapter extends RecyclerView.Adapter<BattlePassExchangeAdapter.VH> {
|
||||
private Context mContext;
|
||||
List<BattlePassPoints> mList = new ArrayList<>();
|
||||
int point;
|
||||
OnItemClickListener<BattlePassPoints> onItemClickListener;
|
||||
|
||||
public BattlePassExchangeAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setPoint(int point) {
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
public void setList(List<BattlePassPoints> mList) {
|
||||
this.mList = mList;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<BattlePassPoints> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BattlePassExchangeAdapter.VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new BattlePassExchangeAdapter.VH(LayoutInflater.from(mContext).inflate(R.layout.item_battlepass_exchange, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull BattlePassExchangeAdapter.VH holder, int position) {
|
||||
holder.setData(mList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
public class VH extends RecyclerView.ViewHolder {
|
||||
private ImageView icon;
|
||||
private ImageView indicator;
|
||||
private TextView title;
|
||||
private TextView content;
|
||||
private Button submit;
|
||||
private View mark;
|
||||
private TextView markText;
|
||||
|
||||
LinearLayout topMoneySubscript;
|
||||
TextView topMoney;
|
||||
ImageView topMoneyIcon;
|
||||
|
||||
|
||||
public VH(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
icon = itemView.findViewById(R.id.tab_1);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
content = itemView.findViewById(R.id.content);
|
||||
submit = itemView.findViewById(R.id.submit);
|
||||
indicator = itemView.findViewById(R.id.indicator);
|
||||
mark = itemView.findViewById(R.id.mark_layout);
|
||||
markText = itemView.findViewById(R.id.mark_text);
|
||||
indicator.setVisibility(View.GONE);
|
||||
|
||||
topMoney = itemView.findViewById(R.id.top_money_text);
|
||||
topMoneyIcon = itemView.findViewById(R.id.top_money_icon);
|
||||
topMoneySubscript = itemView.findViewById(R.id.top_money_layout);
|
||||
}
|
||||
|
||||
public void setData(BattlePassPoints battlePassPoints) {
|
||||
ImgLoader.display(mContext, battlePassPoints.getImageUrl(), icon);
|
||||
title.setText(battlePassPoints.getRewardsName());
|
||||
content.setText(battlePassPoints.getPointsThresholdText());
|
||||
if (StringUtil.isEmpty(battlePassPoints.getExchangeMark())) {
|
||||
mark.setVisibility(View.GONE);
|
||||
} else {
|
||||
mark.setVisibility(View.VISIBLE);
|
||||
markText.setText(battlePassPoints.getExchangeMark());
|
||||
}
|
||||
submit.setOnClickListener(null);
|
||||
topMoneyIcon.setVisibility(View.VISIBLE);
|
||||
switch (battlePassPoints.getSendGiftType()) {
|
||||
case 0:
|
||||
topMoneyIcon.setImageResource(R.mipmap.diamond);
|
||||
break;
|
||||
case 1:
|
||||
topMoneyIcon.setImageResource(R.mipmap.gold_coin);
|
||||
break;
|
||||
default:
|
||||
topMoneyIcon.setVisibility(View.GONE);
|
||||
}
|
||||
topMoney.setText(String.valueOf(battlePassPoints.getSendGiftNeedcoin()));
|
||||
if (battlePassPoints.getSendGiftType() == 999) {
|
||||
topMoneySubscript.setVisibility(View.VISIBLE);
|
||||
topMoney.setText(String.format("%s%s", battlePassPoints.getRestrictTime(), WordUtil.isNewZh() ? "天" : "Days"));
|
||||
if (battlePassPoints.getRestrictTime() == 0) {
|
||||
topMoney.setText(WordUtil.isNewZh() ? "永久" : "Forever");
|
||||
topMoneySubscript.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (battlePassPoints.getExchangeStatus() == 1) {
|
||||
submit.setText(WordUtil.getNewString(R.string.battlepass_exchange_submit_lock));
|
||||
submit.setBackgroundResource(R.mipmap.bg_zl_battlepass_exchange_btn_lock);
|
||||
submit.setTextColor(Color.parseColor("#E4E5E8"));
|
||||
return;
|
||||
}
|
||||
if (battlePassPoints.getUserQuintyCount() == battlePassPoints.getExchangeQuantity()) {
|
||||
submit.setTextColor(Color.parseColor("#5773B1"));
|
||||
submit.setText(WordUtil.getNewString(R.string.battlepass_exchange_submit_exchange));
|
||||
submit.setBackgroundResource(R.mipmap.bg_zl_battlepass_exchange_btn_over);
|
||||
return;
|
||||
} else {
|
||||
submit.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
submit.setText(String.format("%s\n(%s/%s)",
|
||||
WordUtil.getNewString(R.string.battlepass_exchange_submit_unexchange),
|
||||
battlePassPoints.getUserQuintyCount(),
|
||||
battlePassPoints.getExchangeQuantity()
|
||||
));
|
||||
submit.setBackgroundResource(R.mipmap.bg_zl_battlepass_exchange_btn_exchange);
|
||||
}
|
||||
ViewClicksAntiShake.clicksAntiShake(submit, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
new XPopup.Builder(mContext)
|
||||
.enableDrag(false)
|
||||
.maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34))
|
||||
.asCustom(new WarOrderExchangeDetailsPopupWindow(mContext,
|
||||
battlePassPoints.getExchangeQuantity() - battlePassPoints.getUserQuintyCount(),
|
||||
point,
|
||||
Integer.parseInt(battlePassPoints.getPointsThreshold()),
|
||||
battlePassPoints.getImageUrl(),
|
||||
String.valueOf(battlePassPoints.getId()),
|
||||
new WarOrderExchangeDetailsPopupWindow.WarOrderExchangeDetailsCallback() {
|
||||
@Override
|
||||
public void onCallback(int code, String msg) {
|
||||
ToastUtil.show(msg);
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(battlePassPoints, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
))
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.bean.BattlePassTask;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.dialog.OrderLevelPopupWindow;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.AutoSplitTextView;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BattlePassMissionAdapter extends RecyclerView.Adapter<BattlePassMissionAdapter.VH> {
|
||||
private Context mContext;
|
||||
private List<BattlePassTask.Task> mList = new ArrayList<>();
|
||||
private OnItemClickListener<BattlePassTask.Task> onItemClickListener;
|
||||
|
||||
public BattlePassMissionAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setList(List<BattlePassTask.Task> mList) {
|
||||
this.mList = mList;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<BattlePassTask.Task> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (mList.get(position).getId() < 0) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BattlePassMissionAdapter.VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == 0) {
|
||||
return new BattlePassMissionAdapter.TypeOfTitle(LayoutInflater.from(mContext).inflate(R.layout.item_battlepass_mission_type_title, parent, false));
|
||||
}
|
||||
return new BattlePassMissionAdapter.TypeOfMission(LayoutInflater.from(mContext).inflate(R.layout.item_battlepass_mission_type_mission, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull BattlePassMissionAdapter.VH holder, int position) {
|
||||
holder.setData(mList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
public static abstract class VH extends RecyclerView.ViewHolder {
|
||||
protected static final int SUBMIT_BUY = 0;
|
||||
protected static final int SUBMIT_FINISHED = 1;
|
||||
protected static final int SUBMIT_OVER = 2;
|
||||
protected static final int SUBMIT_DEF = 3;
|
||||
|
||||
public VH(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
public abstract void setData(BattlePassTask.Task task);
|
||||
}
|
||||
|
||||
private static class TypeOfTitle extends VH {
|
||||
TextView title;
|
||||
|
||||
public TypeOfTitle(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(BattlePassTask.Task task) {
|
||||
if (task.getId() == -1) {
|
||||
title.setText(WordUtil.getNewString(R.string.battlepass_mission_line_title_daily));
|
||||
} else if (task.getId() == -2) {
|
||||
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) title.getLayoutParams();
|
||||
params.topMargin=DpUtil.dp2px(20);
|
||||
title.setLayoutParams(params);
|
||||
title.setText(WordUtil.getNewString(R.string.battlepass_mission_line_title_season));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class TypeOfMission extends VH {
|
||||
ImageView icon;
|
||||
AutoSplitTextView title;
|
||||
TextView content;
|
||||
Button submit;
|
||||
|
||||
|
||||
public TypeOfMission(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
icon = itemView.findViewById(R.id.icon);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
content = itemView.findViewById(R.id.content);
|
||||
submit = itemView.findViewById(R.id.submit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(BattlePassTask.Task task) {
|
||||
/* if (task.getId() == 1) {
|
||||
task.setReceivedTask(1);
|
||||
task.setUserTaskSuccess(1);
|
||||
task.setNotReceivedTask(0);
|
||||
}
|
||||
if (task.getId() == 2) {
|
||||
task.setUserTaskSuccess(2);
|
||||
task.setReceivedTask(5);
|
||||
task.setNotReceivedTask(5);
|
||||
}*/
|
||||
if (task.getTaskSuccess() > 0) {
|
||||
String format = String.format("%s(%s/%s)",
|
||||
task.getNameText(),
|
||||
task.getUserTaskSuccess(),
|
||||
task.getTaskSuccess());
|
||||
title.setAutoText(format);
|
||||
} else {
|
||||
title.setText(task.getNameText());
|
||||
}
|
||||
content.setText(task.getRemarkText());
|
||||
ImgLoader.display(itemView.getContext(), task.getImagePath(), icon);
|
||||
submit.setTag(SUBMIT_DEF);
|
||||
submit.setText(WordUtil.getNewString(R.string.battlepass_mission_submit_btn_unfinished));
|
||||
submit.setBackgroundResource(R.drawable.bg_battlepass_mission_btn_unfinished);
|
||||
submit.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
if (task.isBuy()) {
|
||||
submit.setText(WordUtil.getNewString(R.string.battlepass_mission_submit_btn_buy));
|
||||
submit.setBackgroundResource(R.drawable.bg_battlepass_mission_btn_buy);
|
||||
submit.setTag(SUBMIT_BUY);
|
||||
} else {
|
||||
if (task.getNotReceivedTask() > 0) {
|
||||
submit.setText(WordUtil.getNewString(R.string.battlepass_mission_submit_btn_finished));
|
||||
submit.setBackgroundResource(R.drawable.bg_battlepass_mission_btn_finished);
|
||||
submit.setTag(SUBMIT_FINISHED);
|
||||
}
|
||||
if (task.getNotReceivedTask() == 0 && task.getTaskSuccess() == task.getUserTaskSuccess()) {
|
||||
submit.setText(WordUtil.getNewString(R.string.battlepass_mission_submit_btn_over));
|
||||
submit.setBackgroundResource(R.drawable.bg_battlepass_mission_btn_over);
|
||||
submit.setTag(SUBMIT_OVER);
|
||||
submit.setTextColor(Color.parseColor("#0D21B2"));
|
||||
}
|
||||
}
|
||||
ViewClicksAntiShake.clicksAntiShake(submit, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if ((int) submit.getTag() == SUBMIT_FINISHED) {
|
||||
subTask(task);
|
||||
}
|
||||
if ((int) submit.getTag() == SUBMIT_BUY) {
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(task, -2);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void subTask(BattlePassTask.Task task) {
|
||||
LiveNetManager.get(itemView.getContext())
|
||||
.getBattlePassTaskOver(String.valueOf(task.getId()), new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
ToastUtil.show( data.getMsg());
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(task, data.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(task, -1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,386 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import static com.yunbao.common.utils.RouteUtil.PATH_COIN;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.bean.BattlePassUserInfoBean;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.LiveBattlePassRewardsBean;
|
||||
import com.yunbao.common.dialog.ActivateEliteBattleOrderPopupWindow;
|
||||
import com.yunbao.common.dialog.LiberalBattlePassPopupWindow;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.event.BattlePassTypeEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class BattlePassRewardAdapter extends RecyclerView.Adapter<BattlePassRewardAdapter.VH> {
|
||||
private Context mContext;
|
||||
private List<Map<Integer, LiveBattlePassRewardsBean.LiveBattlePassReward>> mList = new ArrayList<>();
|
||||
private int userLevel;
|
||||
private BattlePassUserInfoBean userType;
|
||||
private String quintessenceSpendMoney, enjoySpendMoney;
|
||||
private OnItemClickListener<LiveBattlePassRewardsBean.LiveBattlePassReward> onItemClickListener;
|
||||
|
||||
public void setList(List<Map<Integer, LiveBattlePassRewardsBean.LiveBattlePassReward>> mList) {
|
||||
this.mList = mList;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<LiveBattlePassRewardsBean.LiveBattlePassReward> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
public void setUserLevel(int userLevel) {
|
||||
this.userLevel = userLevel;
|
||||
}
|
||||
|
||||
public void setUserType(BattlePassUserInfoBean userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public BattlePassRewardAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new VH(LayoutInflater.from(mContext).inflate(R.layout.item_battlepass_reward_type_top, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull VH holder, int position) {
|
||||
holder.setData(mList.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
public void setQuintessenceSpendMoney(String quintessenceSpendMoney) {
|
||||
this.quintessenceSpendMoney = quintessenceSpendMoney;
|
||||
}
|
||||
|
||||
public void setEnjoySpendMoney(String enjoySpendMoney) {
|
||||
this.enjoySpendMoney = enjoySpendMoney;
|
||||
}
|
||||
|
||||
public class VH extends RecyclerView.ViewHolder {
|
||||
View lineBg, line, point;
|
||||
View tab1Layout, tab2Layout, tab3Layout;
|
||||
Button lv;
|
||||
ImageView tab1, tab2, tab3;
|
||||
ImageView tab1Unlock, tab2Unlock, tab3Unlock;
|
||||
ImageView tab1Mask, tab2Mask, tab3Mask;
|
||||
ImageView tab1Subscript, tab2Subscript, tab3Subscript;
|
||||
ImageView tab1Received, tab2Received, tab3Received;
|
||||
TextView tab1Title, tab2Title, tab3Title;
|
||||
|
||||
LinearLayout tab1TopMoneySubscript, tab2TopMoneySubscript, tab3TopMoneySubscript;
|
||||
TextView tab1TopMoney, tab2TopMoney, tab3TopMoney;
|
||||
ImageView tab1TopMoneyIcon, tab2TopMoneyIcon, tab3TopMoneyIcon;
|
||||
|
||||
|
||||
Map<Integer, LiveBattlePassRewardsBean.LiveBattlePassReward> data;
|
||||
|
||||
public VH(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
lineBg = itemView.findViewById(R.id.line_bg);
|
||||
line = itemView.findViewById(R.id.line);
|
||||
point = itemView.findViewById(R.id.point);
|
||||
lv = itemView.findViewById(R.id.reward_lv);
|
||||
tab1Layout = itemView.findViewById(R.id.tab_1_layout);
|
||||
tab2Layout = itemView.findViewById(R.id.tab_2_layout);
|
||||
tab3Layout = itemView.findViewById(R.id.tab_3_layout);
|
||||
tab1 = itemView.findViewById(R.id.tab_1);
|
||||
tab2 = itemView.findViewById(R.id.tab_2);
|
||||
tab3 = itemView.findViewById(R.id.tab_3);
|
||||
tab1Unlock = itemView.findViewById(R.id.tab_1_item_unlock);
|
||||
tab2Unlock = itemView.findViewById(R.id.tab_2_item_unlock);
|
||||
tab3Unlock = itemView.findViewById(R.id.tab_3_item_unlock);
|
||||
tab1Mask = itemView.findViewById(R.id.tab_1_unlock);
|
||||
tab2Mask = itemView.findViewById(R.id.tab_2_unlock);
|
||||
tab3Mask = itemView.findViewById(R.id.tab_3_unlock);
|
||||
tab1Subscript = itemView.findViewById(R.id.tab_1_subscript);
|
||||
tab2Subscript = itemView.findViewById(R.id.tab_2_subscript);
|
||||
tab3Subscript = itemView.findViewById(R.id.tab_3_subscript);
|
||||
tab1Title = itemView.findViewById(R.id.tab_1_title);
|
||||
tab2Title = itemView.findViewById(R.id.tab_2_title);
|
||||
tab3Title = itemView.findViewById(R.id.tab_3_title);
|
||||
tab1Received = itemView.findViewById(R.id.tab_1_item_received);
|
||||
tab2Received = itemView.findViewById(R.id.tab_2_item_received);
|
||||
tab3Received = itemView.findViewById(R.id.tab_3_item_received);
|
||||
tab1TopMoneySubscript = itemView.findViewById(R.id.tab_1_top_money_layout);
|
||||
tab2TopMoneySubscript = itemView.findViewById(R.id.tab_2_top_money_layout);
|
||||
tab3TopMoneySubscript = itemView.findViewById(R.id.tab_3_top_money_layout);
|
||||
tab1TopMoney = itemView.findViewById(R.id.tab_1_top_money_text);
|
||||
tab2TopMoney = itemView.findViewById(R.id.tab_2_top_money_text);
|
||||
tab3TopMoney = itemView.findViewById(R.id.tab_3_top_money_text);
|
||||
tab1TopMoneyIcon = itemView.findViewById(R.id.tab_1_top_money_icon);
|
||||
tab2TopMoneyIcon = itemView.findViewById(R.id.tab_2_top_money_icon);
|
||||
tab3TopMoneyIcon = itemView.findViewById(R.id.tab_3_top_money_icon);
|
||||
}
|
||||
|
||||
int level = 0;
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void setData(Map<Integer, LiveBattlePassRewardsBean.LiveBattlePassReward> data, int position) {
|
||||
this.data = data;
|
||||
for (LiveBattlePassRewardsBean.LiveBattlePassReward value : data.values()) {
|
||||
if (value.getId() > 0) {
|
||||
level = value.getLiveBattlePassLevel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (position == 0) {
|
||||
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) lineBg.getLayoutParams();
|
||||
ConstraintLayout.LayoutParams params1 = (ConstraintLayout.LayoutParams) line.getLayoutParams();
|
||||
params.topMargin = DpUtil.dp2px(3);
|
||||
params1.topMargin = DpUtil.dp2px(3);
|
||||
} else {
|
||||
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) lineBg.getLayoutParams();
|
||||
ConstraintLayout.LayoutParams params1 = (ConstraintLayout.LayoutParams) line.getLayoutParams();
|
||||
params.topMargin = DpUtil.dp2px(0);
|
||||
params1.topMargin = DpUtil.dp2px(0);
|
||||
}
|
||||
setVisibility(View.GONE, -1, tab1Unlock, tab1Unlock, tab1Unlock);
|
||||
setVisibility(View.GONE, -1, tab1Subscript, tab2Subscript, tab3Subscript);
|
||||
setVisibility(View.VISIBLE, -1, tab1Layout, tab2Layout, tab3Layout);
|
||||
setVisibility(View.VISIBLE, -1, tab1, tab2, tab3);
|
||||
setVisibility(View.VISIBLE, -1, tab1Mask, tab2Mask, tab3Mask);
|
||||
ConstraintLayout.LayoutParams _params = (ConstraintLayout.LayoutParams) line.getLayoutParams();
|
||||
_params.bottomMargin = DpUtil.dp2px(0);
|
||||
line.setLayoutParams(_params);
|
||||
|
||||
line.setVisibility(View.GONE);
|
||||
point.setVisibility(View.GONE);
|
||||
if (userLevel > level && userLevel < userType.getMaxLevel()) {
|
||||
setVisibility(View.GONE, -1, tab1Mask, tab2Mask, tab3Mask);
|
||||
point.setVisibility(View.GONE);
|
||||
line.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (userLevel == level && userLevel < userType.getMaxLevel()) {
|
||||
setVisibility(View.GONE, -1, tab1Mask, tab2Mask, tab3Mask);
|
||||
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) line.getLayoutParams();
|
||||
params.bottomMargin = DpUtil.dp2px(70);
|
||||
line.setVisibility(View.VISIBLE);
|
||||
point.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (userLevel >= userType.getMaxLevel()) {
|
||||
setVisibility(View.GONE, -1, tab1Mask, tab2Mask, tab3Mask);
|
||||
line.setVisibility(View.VISIBLE);
|
||||
point.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
getAllView((reward, view) -> ImgLoader.display(mContext, reward.getImageUrl(), view), tab1, tab2, tab3);
|
||||
getAllView(((reward, view) -> {
|
||||
if (userLevel < level) {
|
||||
view.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (reward.getLock() == 1) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
}), tab1Unlock, tab2Unlock, tab3Unlock);
|
||||
getAllView(((reward, view) -> {
|
||||
lv.setText("V" + reward.getLiveBattlePassLevel());
|
||||
lv.setTag(reward);
|
||||
view.setText(reward.getRewardName());
|
||||
}), tab1Title, tab2Title, tab3Title);
|
||||
getAllView(((reward, view) -> {
|
||||
if (reward.getReceived() == 1) {
|
||||
view.setVisibility(View.GONE);
|
||||
} else {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}), tab1Received, tab2Received, tab3Received);
|
||||
getAllView(((reward, view) -> {
|
||||
ViewClicksAntiShake.clicksAntiShake(view, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
getReward(reward);
|
||||
}
|
||||
});
|
||||
}), tab1, tab2, tab3);
|
||||
getAllView(((reward, view) -> {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
switch (reward.getSendGiftType()) {
|
||||
case 0:
|
||||
view.setImageResource(R.mipmap.diamond);
|
||||
break;
|
||||
case 1:
|
||||
view.setImageResource(R.mipmap.gold_coin);
|
||||
break;
|
||||
default:
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
}), tab1TopMoneyIcon, tab2TopMoneyIcon, tab3TopMoneyIcon);
|
||||
getAllView(((reward, view) -> {
|
||||
view.setText(String.valueOf(reward.getSendRewardNeedcoin()));
|
||||
((View)view.getParent()).setVisibility(View.VISIBLE);
|
||||
if (reward.getSendGiftType() == 999) {
|
||||
view.setText(reward.getSendRewardRestrictTime() + (WordUtil.isNewZh() ? "天" : "Days"));
|
||||
if (reward.getSendRewardRestrictTime().equals("0")) {
|
||||
view.setText(WordUtil.isNewZh()?"永久":"Forever");
|
||||
((View)view.getParent()).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}), tab1TopMoney, tab2TopMoney, tab3TopMoney);
|
||||
}
|
||||
|
||||
private void getReward(LiveBattlePassRewardsBean.LiveBattlePassReward reward) {
|
||||
System.err.println(reward);
|
||||
if (userLevel < reward.getLiveBattlePassLevel()) {
|
||||
ToastUtil.show(WordUtil.getNewString(R.string.battlepass_reward_item_lock));
|
||||
return;
|
||||
}
|
||||
if (reward.getLock() == 1) {
|
||||
//ToastUtil.show("锁了");
|
||||
if (reward.getLiveBattlePassTypeId() == 2) {
|
||||
showBuyType(true);
|
||||
} else {
|
||||
showBuyType(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (reward.getReceived() == 2) {
|
||||
return;
|
||||
}
|
||||
switch (reward.getLiveBattlePassTypeId()) {
|
||||
case 1:
|
||||
if (userType.getBattlePassUserRecords1() == 1) {
|
||||
ToastUtil.show("没购买");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (userType.getBattlePassUserRecords2() == 1) {
|
||||
ToastUtil.show("没购买");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (userType.getBattlePassUserRecords3() == 1) {
|
||||
ToastUtil.show("没购买");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
LiveNetManager.get(mContext)
|
||||
.getRewards(String.valueOf(reward.getLiveBattlePassLevel()), String.valueOf(reward.getId()), new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
ToastUtil.show(data.getMsg());
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(reward, reward.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(reward, reward.getId());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setVisibility(int visibility, int position, View... views) {
|
||||
if (position == -1) {
|
||||
for (View view : views) {
|
||||
view.setVisibility(visibility);
|
||||
}
|
||||
} else {
|
||||
views[position].setVisibility(visibility);
|
||||
}
|
||||
}
|
||||
|
||||
private <T> void getAllView(ViewData<T> viewData, T... views) {
|
||||
getView(1, viewData, views);
|
||||
getView(2, viewData, views);
|
||||
getView(3, viewData, views);
|
||||
}
|
||||
|
||||
private <T> void getView(int type, ViewData<T> viewData, T... views) {
|
||||
if (data.containsKey(type) && data.get(type) != null && Objects.requireNonNull(data.get(type)).getId() != 0) {
|
||||
viewData.onData(data.get(type), views[type - 1]);
|
||||
setVisibility(View.VISIBLE, type - 1, tab1Layout, tab2Layout, tab3Layout);
|
||||
} else {
|
||||
setVisibility(View.INVISIBLE, type - 1, tab1Layout, tab2Layout, tab3Layout);
|
||||
}
|
||||
}
|
||||
|
||||
private void showBuyType(boolean is) {
|
||||
int id = is ? userType.getLive_battle_pass_type().get(1).getId() : userType.getLive_battle_pass_type().get(2).getId();
|
||||
new XPopup.Builder(itemView.getContext())
|
||||
.enableDrag(false)
|
||||
.maxWidth(DeviceUtils.getScreenHeight((Activity) itemView.getContext()) - DpUtil.dp2px(34))
|
||||
.asCustom(new ActivateEliteBattleOrderPopupWindow(
|
||||
itemView.getContext(),
|
||||
is ? quintessenceSpendMoney : enjoySpendMoney,
|
||||
is,
|
||||
new LiberalBattlePassPopupWindow.LiberalBattlePassCallback() {
|
||||
@Override
|
||||
public void onCallback(int code, String msg) {
|
||||
if (code == 1001) {
|
||||
new DialogUitl.Builder(itemView.getContext())
|
||||
.setView(com.yunbao.live.R.layout.dialog_live_unfollow)
|
||||
.setConfirmString(itemView.getContext().getString(com.yunbao.live.R.string.charge))
|
||||
.setContent(itemView.getContext().getString(com.yunbao.live.R.string.insufficient_balance))
|
||||
.setClickCallback(new DialogUitl.SimpleCallback() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
ARouter.getInstance().build(PATH_COIN).withInt("p", 0).navigation();
|
||||
}
|
||||
}).build().show();
|
||||
return;
|
||||
}
|
||||
ToastUtil.show(msg);
|
||||
Bus.get().post(new BattlePassTypeEvent(0));
|
||||
}
|
||||
},
|
||||
String.valueOf(id)
|
||||
))
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
private interface ViewData<T> {
|
||||
void onData(LiveBattlePassRewardsBean.LiveBattlePassReward reward, T view);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.bean.CashAccountBean;
|
||||
import com.yunbao.main.utils.MainIconUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/23.
|
||||
*/
|
||||
|
||||
public class CashAccountAdapter extends RecyclerView.Adapter<CashAccountAdapter.Vh> {
|
||||
|
||||
private List<CashAccountBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private View.OnClickListener mDeleteClickListener;
|
||||
private ActionListener mActionListener;
|
||||
private String mCashAccountId;
|
||||
|
||||
public CashAccountAdapter(Context context, String cashAccountId) {
|
||||
mList = new ArrayList<>();
|
||||
mCashAccountId = cashAccountId;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null && mActionListener != null) {
|
||||
int position = (int) tag;
|
||||
mActionListener.onItemClick(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
};
|
||||
mDeleteClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null && mActionListener != null) {
|
||||
int position = (int) tag;
|
||||
mActionListener.onItemDelete(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_cash_account, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh holder, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position, @NonNull List<Object> payloads) {
|
||||
Object payload = payloads.size() > 0 ? payloads.get(0) : null;
|
||||
vh.setData(mList.get(position), position, payload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
|
||||
public void removeItem(int position) {
|
||||
mList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, mList.size(), Constants.PAYLOAD);
|
||||
}
|
||||
|
||||
public void insertItem(CashAccountBean bean) {
|
||||
int position = mList.size();
|
||||
mList.add(bean);
|
||||
notifyItemInserted(position);
|
||||
}
|
||||
|
||||
public void setActionListener(ActionListener actionListener) {
|
||||
mActionListener = actionListener;
|
||||
}
|
||||
|
||||
public void setList(List<CashAccountBean> list) {
|
||||
mList.clear();
|
||||
mList.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
RadioButton mRadioButton;
|
||||
ImageView mIcon;
|
||||
TextView mAccount;
|
||||
View mBtnDelete;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mRadioButton = (RadioButton) itemView.findViewById(R.id.radioButton);
|
||||
mIcon = (ImageView) itemView.findViewById(R.id.icon);
|
||||
mAccount = itemView.findViewById(R.id.account);
|
||||
mBtnDelete = itemView.findViewById(R.id.btn_delete);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
mBtnDelete.setOnClickListener(mDeleteClickListener);
|
||||
}
|
||||
|
||||
void setData(CashAccountBean bean, int position, Object payload) {
|
||||
itemView.setTag(position);
|
||||
mBtnDelete.setTag(position);
|
||||
if (payload == null) {
|
||||
mIcon.setImageResource(MainIconUtil.getCashTypeIcon(bean.getType()));
|
||||
mAccount.setText(bean.getAccount());
|
||||
}
|
||||
mRadioButton.setChecked(bean.getId().equals(mCashAccountId));
|
||||
}
|
||||
}
|
||||
|
||||
public interface ActionListener {
|
||||
void onItemClick(CashAccountBean bean, int position);
|
||||
|
||||
void onItemDelete(CashAccountBean bean, int position);
|
||||
}
|
||||
|
||||
}
|
||||
219
main/src/main/java/com/yunbao/main/adapter/CoinAdapter.java
Normal file
@@ -0,0 +1,219 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.CoinBean;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/23.
|
||||
*/
|
||||
|
||||
public class CoinAdapter extends RecyclerView.Adapter {
|
||||
|
||||
private static final int HEAD = -1;
|
||||
private String mCoinName;
|
||||
private List<CoinBean> mList;
|
||||
private String mGiveString;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<CoinBean> mOnItemClickListener;
|
||||
private View mHeadView;
|
||||
private Drawable mCheckedDrawable;
|
||||
private Drawable mUnCheckedDrawable;
|
||||
private int mCheckedPosition = -1;
|
||||
private int mHeadHeight;
|
||||
private int mScrollY;
|
||||
private View mContactView;
|
||||
|
||||
public CoinAdapter(Context context, String coinName) {
|
||||
mHeadHeight = DpUtil.dp2px(120);
|
||||
mCoinName = coinName;
|
||||
mList = new ArrayList<>();
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mHeadView = mInflater.inflate(R.layout.item_coin_head, null);
|
||||
mHeadView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
mGiveString =context.getString(R.string.coin_give);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
int positon = (int) tag;
|
||||
CoinBean bean = mList.get(positon);
|
||||
if (mCheckedPosition != positon) {
|
||||
if (mCheckedPosition >= 0 && mCheckedPosition < mList.size()) {
|
||||
mList.get(mCheckedPosition).setChecked(false);
|
||||
notifyItemChanged(mCheckedPosition + 1, Constants.PAYLOAD);
|
||||
}
|
||||
bean.setChecked(true);
|
||||
notifyItemChanged(positon + 1, Constants.PAYLOAD);
|
||||
mCheckedPosition = positon;
|
||||
}
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, positon);
|
||||
}
|
||||
}
|
||||
};
|
||||
mCheckedDrawable = ContextCompat.getDrawable(context, R.drawable.bg_coin_item_1);
|
||||
mUnCheckedDrawable = ContextCompat.getDrawable(context, R.drawable.bg_coin_item_0);
|
||||
}
|
||||
|
||||
|
||||
public void setList(List<CoinBean> list) {
|
||||
if (list != null && list.size() > 0) {
|
||||
mList.clear();
|
||||
mList.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<CoinBean> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == 0) {
|
||||
return HEAD;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == HEAD) {
|
||||
ViewParent viewParent = mHeadView.getParent();
|
||||
if (viewParent != null) {
|
||||
((ViewGroup) viewParent).removeView(mHeadView);
|
||||
}
|
||||
HeadVh headVh = new HeadVh(mHeadView);
|
||||
headVh.setIsRecyclable(false);
|
||||
return headVh;
|
||||
}
|
||||
return new Vh(mInflater.inflate(R.layout.item_coin, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position, @NonNull List payloads) {
|
||||
Object payload = payloads.size() > 0 ? payloads.get(0) : null;
|
||||
if (vh instanceof Vh) {
|
||||
((Vh) vh).setData(mList.get(position - 1), position - 1, payload);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size() + 1;
|
||||
}
|
||||
|
||||
|
||||
class HeadVh extends RecyclerView.ViewHolder {
|
||||
|
||||
public HeadVh(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView mCoin;
|
||||
TextView mMoney;
|
||||
TextView mGive;
|
||||
View mGiveGroup;
|
||||
View mBg;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mCoin = itemView.findViewById(R.id.coin);
|
||||
mMoney = itemView.findViewById(R.id.money);
|
||||
mGive = itemView.findViewById(R.id.give);
|
||||
mGiveGroup = itemView.findViewById(R.id.give_group);
|
||||
mBg = itemView.findViewById(R.id.bg);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(CoinBean bean, int position, Object payload) {
|
||||
if (payload == null) {
|
||||
itemView.setTag(position);
|
||||
mCoin.setText(bean.getCoin());
|
||||
mMoney.setText("¥" + bean.getMoney());
|
||||
if (!"0".equals(bean.getGive())) {
|
||||
if (mGiveGroup.getVisibility() != View.VISIBLE) {
|
||||
mGiveGroup.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mGive.setText(mGiveString + bean.getGive() + mCoinName);
|
||||
} else {
|
||||
if (mGiveGroup.getVisibility() == View.VISIBLE) {
|
||||
mGiveGroup.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
mBg.setBackground(bean.isChecked() ? mCheckedDrawable : mUnCheckedDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public View getHeadView() {
|
||||
return mHeadView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
mScrollY += dy;
|
||||
if (mContactView != null) {
|
||||
int targetScrollY = -mScrollY;
|
||||
if (targetScrollY < -mHeadHeight) {
|
||||
targetScrollY = -mHeadHeight;
|
||||
}
|
||||
if (targetScrollY > 0) {
|
||||
targetScrollY = 0;
|
||||
}
|
||||
if (mContactView.getTranslationY() != targetScrollY) {
|
||||
mContactView.setTranslationY(targetScrollY);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setContactView(View contactView) {
|
||||
mContactView = contactView;
|
||||
}
|
||||
}
|
||||
160
main/src/main/java/com/yunbao/main/adapter/CoinPayAdapter.java
Normal file
@@ -0,0 +1,160 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.CoinPayBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2019/4/11.
|
||||
*/
|
||||
|
||||
public class CoinPayAdapter extends RecyclerView.Adapter<CoinPayAdapter.Vh> {
|
||||
|
||||
private Context mContext;
|
||||
private List<CoinPayBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private int mCheckedPosition;
|
||||
|
||||
public CoinPayAdapter(Context context) {
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mList = new ArrayList<>();
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
int position = (int) tag;
|
||||
if (mCheckedPosition != position) {
|
||||
if (mCheckedPosition >= 0 && mCheckedPosition < mList.size()) {
|
||||
mList.get(mCheckedPosition).setChecked(false);
|
||||
notifyItemChanged(mCheckedPosition, Constants.PAYLOAD);
|
||||
}
|
||||
mList.get(position).setChecked(true);
|
||||
EventBus.getDefault().post(mList.get(position));
|
||||
notifyItemChanged(position, Constants.PAYLOAD);
|
||||
mCheckedPosition = position;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setList(List<CoinPayBean> list) {
|
||||
if (list != null && list.size() > 0) {
|
||||
mList.clear();
|
||||
if (mCheckedPosition >= 0 && mCheckedPosition < list.size()) {
|
||||
list.get(mCheckedPosition).setChecked(true);
|
||||
}
|
||||
mList.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_coin_pay2, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position, @NonNull List<Object> payloads) {
|
||||
Object payload = payloads.size() > 0 ? payloads.get(0) : null;
|
||||
vh.setData(mList.get(position), position, payload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView mName;
|
||||
ImageView mThumb;
|
||||
ImageView mWrap;
|
||||
TextView mGive;
|
||||
View mGiveGroup;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mName = itemView.findViewById(R.id.name);
|
||||
mThumb = itemView.findViewById(R.id.thumb);
|
||||
mWrap = itemView.findViewById(R.id.wrap);
|
||||
mGive = itemView.findViewById(R.id.give);
|
||||
mGiveGroup = itemView.findViewById(R.id.give_group);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(CoinPayBean bean, int position, Object payload) {
|
||||
if (payload == null) {
|
||||
itemView.setTag(position);
|
||||
mName.setText(bean.getName());
|
||||
ImgLoader.display(mContext, bean.getThumb(), mThumb);
|
||||
|
||||
//大额
|
||||
if (bean.getPayDesc()!=null && !bean.getPayDesc().isEmpty()){
|
||||
mGiveGroup.setVisibility(View.VISIBLE);
|
||||
mGive.setText(bean.getPayDesc());
|
||||
}else {
|
||||
mGiveGroup.setVisibility(View.GONE);
|
||||
mGive.setText("");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (bean.isChecked()) {
|
||||
if (mWrap.getVisibility() != View.VISIBLE) {
|
||||
mWrap.setVisibility(View.VISIBLE);
|
||||
if (bean.getId().equals(Constants.PAY_TYPE_PAYSSION)){
|
||||
// mWrap.setImageResource(R.mipmap.icon_coin_wrap_recommend);
|
||||
mWrap.setImageResource(R.mipmap.icon_coin_wrap);
|
||||
}
|
||||
else {
|
||||
mWrap.setImageResource(R.mipmap.icon_coin_wrap);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mWrap.getVisibility() == View.VISIBLE) {
|
||||
mWrap.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public CoinPayBean getPayCoinPayBean() {
|
||||
if (mList != null && mList.size() > 0) {
|
||||
if (mCheckedPosition >= 0 && mCheckedPosition < mList.size()) {
|
||||
CoinPayBean bean = mList.get(mCheckedPosition);
|
||||
if (bean != null) {
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class CommonAdapter <T> extends MultiItemTypeAdapter<T>
|
||||
{
|
||||
protected Context mContext;
|
||||
protected int mLayoutId;
|
||||
protected List<T> mDatas;
|
||||
protected LayoutInflater mInflater;
|
||||
|
||||
public CommonAdapter(final Context context, final int layoutId, List<T> datas)
|
||||
{
|
||||
super(context, datas);
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mLayoutId = layoutId;
|
||||
mDatas = datas;
|
||||
|
||||
addItemViewDelegate(new ItemViewDelegate<T>()
|
||||
{
|
||||
@Override
|
||||
public int getItemViewLayoutId()
|
||||
{
|
||||
return layoutId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForViewType( T item, int position)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(ViewHolder holder, T t, int position)
|
||||
{
|
||||
CommonAdapter.this.convert(holder, t, position);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract void convert(ViewHolder holder, T t, int position);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import android.transition.TransitionValues;
|
||||
|
||||
public class FullAdToBannerTransition extends ChangeBounds {
|
||||
|
||||
private static final String ALPHA = "android:faderay:alpha";
|
||||
|
||||
private final float startAlpha;
|
||||
private final float endAlpha;
|
||||
|
||||
public FullAdToBannerTransition(final float startAlpha, final float endAlpha, final TimeInterpolator timeInterpolator) {
|
||||
this.startAlpha = startAlpha;
|
||||
this.endAlpha = endAlpha;
|
||||
setInterpolator(timeInterpolator);
|
||||
setDuration(1000);
|
||||
setStartDelay(500);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void captureStartValues(final TransitionValues transitionValues) {
|
||||
super.captureStartValues(transitionValues);
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureEndValues(final TransitionValues transitionValues) {
|
||||
super.captureEndValues(transitionValues);
|
||||
captureValues(transitionValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
|
||||
Animator animator = super.createAnimator(sceneRoot, startValues, endValues);
|
||||
ObjectAnimator fade = ObjectAnimator.ofFloat(endValues.view, View.ALPHA, startAlpha, endAlpha);
|
||||
return mergeAnimators(animator, fade);
|
||||
}
|
||||
|
||||
private void captureValues(final TransitionValues transitionValues) {
|
||||
transitionValues.values.put(ALPHA, transitionValues.view.getAlpha());
|
||||
}
|
||||
|
||||
private Animator mergeAnimators(Animator animator1, Animator animator2) {
|
||||
if (animator1 == null) {
|
||||
return animator2;
|
||||
} else if (animator2 == null) {
|
||||
return animator1;
|
||||
} else {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(animator1, animator2);
|
||||
return animatorSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
|
||||
public interface ItemViewDelegate<T>
|
||||
{
|
||||
|
||||
int getItemViewLayoutId();
|
||||
|
||||
boolean isForViewType(T item, int position);
|
||||
|
||||
void convert(ViewHolder holder, T t, int position);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import androidx.collection.SparseArrayCompat;
|
||||
|
||||
public class ItemViewDelegateManager<T> {
|
||||
SparseArrayCompat<ItemViewDelegate<T>> delegates = new SparseArrayCompat();
|
||||
|
||||
public int getItemViewDelegateCount() {
|
||||
return delegates.size();
|
||||
}
|
||||
|
||||
public ItemViewDelegateManager<T> addDelegate(ItemViewDelegate<T> delegate) {
|
||||
int viewType = delegates.size();
|
||||
if (delegate != null) {
|
||||
delegates.put(viewType, delegate);
|
||||
viewType++;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemViewDelegateManager<T> addDelegate(int viewType, ItemViewDelegate<T> delegate) {
|
||||
if (delegates.get(viewType) != null) {
|
||||
throw new IllegalArgumentException(
|
||||
"An ItemViewDelegate is already registered for the viewType = "
|
||||
+ viewType
|
||||
+ ". Already registered ItemViewDelegate is "
|
||||
+ delegates.get(viewType));
|
||||
}
|
||||
delegates.put(viewType, delegate);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemViewDelegateManager<T> removeDelegate(ItemViewDelegate<T> delegate) {
|
||||
if (delegate == null) {
|
||||
throw new NullPointerException("ItemViewDelegate is null");
|
||||
}
|
||||
int indexToRemove = delegates.indexOfValue(delegate);
|
||||
|
||||
if (indexToRemove >= 0) {
|
||||
delegates.removeAt(indexToRemove);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemViewDelegateManager<T> removeDelegate(int itemType) {
|
||||
int indexToRemove = delegates.indexOfKey(itemType);
|
||||
|
||||
if (indexToRemove >= 0) {
|
||||
delegates.removeAt(indexToRemove);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getItemViewType(T item, int position) {
|
||||
int delegatesCount = delegates.size();
|
||||
for (int i = delegatesCount - 1; i >= 0; i--) {
|
||||
ItemViewDelegate<T> delegate = delegates.valueAt(i);
|
||||
if (delegate.isForViewType(item, position)) {
|
||||
return delegates.keyAt(i);
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"No ItemViewDelegate added that matches position=" + position + " in data source");
|
||||
}
|
||||
|
||||
public void convert(ViewHolder holder, T item, int position) {
|
||||
int delegatesCount = delegates.size();
|
||||
for (int i = 0; i < delegatesCount; i++) {
|
||||
ItemViewDelegate<T> delegate = delegates.valueAt(i);
|
||||
|
||||
if (delegate.isForViewType(item, position)) {
|
||||
delegate.convert(holder, item, position);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"No ItemViewDelegateManager added that matches position=" + position + " in data source");
|
||||
}
|
||||
|
||||
|
||||
public ItemViewDelegate getItemViewDelegate(int viewType) {
|
||||
return delegates.get(viewType);
|
||||
}
|
||||
|
||||
public int getItemViewLayoutId(int viewType) {
|
||||
return getItemViewDelegate(viewType).getItemViewLayoutId();
|
||||
}
|
||||
|
||||
public int getItemViewType(ItemViewDelegate itemViewDelegate) {
|
||||
return delegates.indexOfValue(itemViewDelegate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.yunbao.main.R;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/22.
|
||||
*/
|
||||
|
||||
public class LoginTypeAdapter extends RecyclerView.Adapter<LoginTypeAdapter.Vh> {
|
||||
|
||||
// private List<MobBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
// private OnItemClickListener<MobBean> mOnItemClickListener;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
|
||||
// public LoginTypeAdapter(Context context, List<MobBean> list) {
|
||||
// mList = list;
|
||||
// mInflater = LayoutInflater.from(context);
|
||||
// mOnClickListener = new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// Object tag = v.getTag();
|
||||
// if (tag != null) {
|
||||
// int position = (int) tag;
|
||||
// if (mOnItemClickListener != null) {
|
||||
// mOnItemClickListener.onItemClick(mList.get(position), position);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_login_type, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position) {
|
||||
// vh.setData(mList.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
// return mList.size();
|
||||
return 0;
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mImg;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mImg =(ImageView) itemView.findViewById(R.id.img);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
// void setData(MobBean bean, int position) {
|
||||
// itemView.setTag(position);
|
||||
// mImg.setImageResource(bean.getIcon1());
|
||||
// }
|
||||
}
|
||||
|
||||
// public void setOnItemClickListener(OnItemClickListener<MobBean> onItemClickListener) {
|
||||
// mOnItemClickListener = onItemClickListener;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.main.utils.MainIconUtil;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/26.
|
||||
*/
|
||||
|
||||
public class MainHomeFollowAdapter extends RefreshAdapter<LiveBean> {
|
||||
|
||||
|
||||
private View.OnClickListener mOnClickListener;
|
||||
|
||||
public MainHomeFollowAdapter(Context context) {
|
||||
super(context);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(!canClick()){
|
||||
return;
|
||||
}
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_main_home_follow, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
((Vh) vh).setData(mList.get(position), position);
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mCover;
|
||||
ImageView mAvatar;
|
||||
TextView mName;
|
||||
TextView mTitle;
|
||||
TextView mNum;
|
||||
ImageView mType;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mCover = (ImageView) itemView.findViewById(R.id.cover);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mTitle = (TextView) itemView.findViewById(R.id.title);
|
||||
mNum = (TextView) itemView.findViewById(R.id.num);
|
||||
mType = (ImageView) itemView.findViewById(R.id.type);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(LiveBean bean, int position) {
|
||||
itemView.setTag(position);
|
||||
ImgLoader.display(mContext,bean.getThumb(), mCover);
|
||||
ImgLoader.display(mContext,bean.getAvatar(), mAvatar);
|
||||
mName.setText(bean.getUserNiceName());
|
||||
if (TextUtils.isEmpty(bean.getTitle())) {
|
||||
if (mTitle.getVisibility() == View.VISIBLE) {
|
||||
mTitle.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
if (mTitle.getVisibility() != View.VISIBLE) {
|
||||
mTitle.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mTitle.setText(bean.getTitle());
|
||||
}
|
||||
mNum.setText(bean.getNums());
|
||||
if ("1".equals(bean.getIslive())){
|
||||
//直播中
|
||||
mType.setImageResource(MainIconUtil.getLiveTypeIcon(bean.getType()));
|
||||
}
|
||||
else {
|
||||
//休息中
|
||||
mType.setImageResource(MainIconUtil.getLiveTypeIcon(Constants.LIVE_TYPE_RESTING));
|
||||
}
|
||||
// mType.setImageResource(MainIconUtil.getLiveTypeIcon(bean.getType()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.os.CountDownTimer;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.WeekListBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.MainHomeLiveItemViewHolder;
|
||||
import com.yunbao.main.views.MainHomeLiveWeekItemViewHolder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/26.
|
||||
* 首页 直播
|
||||
*/
|
||||
|
||||
public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
|
||||
|
||||
private static final int HEAD = 0;
|
||||
private static final int LEFT = 1;
|
||||
private static final int RIGHT = 2;
|
||||
private final int WEEKLAYOUT = 5005;
|
||||
private View mHeadView;
|
||||
private Context context;
|
||||
private int Height;
|
||||
private int getWeekIntIndex = 0;
|
||||
|
||||
public MainHomeLiveAdapter(Context context, int h) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
this.Height = h;
|
||||
mHeadView = mInflater.inflate(R.layout.item_main_home_live_head, null, false);
|
||||
mHeadView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DpUtil.dp2px(120)));
|
||||
}
|
||||
|
||||
public View getHeadView() {
|
||||
return mHeadView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == 0) {
|
||||
return HEAD;
|
||||
} else if (position > 0) {
|
||||
LiveBean mode = mList.get(position - 1);
|
||||
if (TextUtils.equals(mode.getIs_week(), "1")) {
|
||||
return WEEKLAYOUT;
|
||||
} else {
|
||||
if (position % 2 == 0) {
|
||||
return RIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
return LEFT;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
//创建列表不同的布局文件
|
||||
switch (viewType) {
|
||||
case HEAD:
|
||||
ViewParent viewParent = mHeadView.getParent();
|
||||
if (viewParent != null) {
|
||||
((ViewGroup) viewParent).removeView(mHeadView);
|
||||
}
|
||||
HeadVh headVh = new HeadVh(mHeadView);
|
||||
headVh.setIsRecyclable(false);
|
||||
return headVh;
|
||||
case WEEKLAYOUT:
|
||||
return new MainHomeLiveWeekItemViewHolder(mInflater.inflate(R.layout.item_main_home_lives, parent, false));
|
||||
default:
|
||||
return new MainHomeLiveItemViewHolder(mInflater.inflate(R.layout.item_main_home_lives, parent, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDetachedFromWindow(@NonNull RecyclerView.ViewHolder holder) {
|
||||
//局部刷新周星榜svaga
|
||||
if (holder instanceof MainHomeLiveWeekItemViewHolder) {
|
||||
((MainHomeLiveWeekItemViewHolder) holder).upSvga();
|
||||
}
|
||||
super.onViewDetachedFromWindow(holder);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
if (vh instanceof MainHomeLiveWeekItemViewHolder) {
|
||||
((MainHomeLiveWeekItemViewHolder) vh).loadViewDate(mList.get(position - 1), position - 1, Height, new MainHomeLiveWeekItemViewHolder.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(LiveBean bean, int position) {
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, position);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (vh instanceof MainHomeLiveItemViewHolder) {
|
||||
((MainHomeLiveItemViewHolder) vh).loadViewDate(mList.get(position - 1), position - 1, Height, new MainHomeLiveItemViewHolder.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(LiveBean bean, int position) {
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, position);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return super.getItemCount() + 1;
|
||||
}
|
||||
|
||||
class HeadVh extends RecyclerView.ViewHolder {
|
||||
|
||||
public HeadVh(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int weekListIndex = 0;
|
||||
public CountDownTimer countDownTimer;
|
||||
|
||||
private void setAction(ImageView imageView, int time, TextView mTitle, TextView name2, List<WeekListBean> mWeekListBean) {
|
||||
ImgLoader.display(mContext, mWeekListBean.get(weekListIndex).getAnchor_avatar(), imageView);
|
||||
|
||||
name2.setText(mWeekListBean.get(weekListIndex).getAnchor_name());
|
||||
|
||||
imageView.setAlpha(1f);
|
||||
ObjectAnimator mWeekAnimator;
|
||||
mWeekAnimator = ObjectAnimator.ofFloat(imageView, "alpha", 1f, 1f);//渐变
|
||||
mWeekAnimator.setDuration(time * 1000);
|
||||
mWeekAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
mWeekAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
imageView.setAlpha(1 - animation.getAnimatedFraction());
|
||||
if (Constants.getWeekIntIndex != getWeekIntIndex) {
|
||||
mWeekAnimator.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
mWeekAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
weekListIndex = weekListIndex + 1;
|
||||
if (weekListIndex > mWeekListBean.size() - 1) {
|
||||
weekListIndex = 0;
|
||||
}
|
||||
if (Constants.getWeekIntIndex != getWeekIntIndex) {
|
||||
mWeekAnimator.cancel();
|
||||
} else {
|
||||
setAction(imageView, Integer.valueOf(mWeekListBean.get(weekListIndex).getSeconds()), mTitle, name2, mWeekListBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
mWeekAnimator.start();
|
||||
}
|
||||
|
||||
public void setWeekList(List<WeekListBean> weekListBean) {
|
||||
}
|
||||
|
||||
public void moveWeekList() {
|
||||
}
|
||||
|
||||
public void clearAnimator() {
|
||||
}
|
||||
|
||||
//获取周星榜数据
|
||||
private void getUserHotList(SVGAImageView week_svga, LinearLayout live_info_view, LinearLayout lt_week_list, ImageView img_week_head, TextView mTitle, TextView name2, int position, List<WeekListBean> mWeekListBean) {
|
||||
|
||||
if (mWeekListBean != null && mWeekListBean.size() > 0) {
|
||||
try {
|
||||
new SVGAParser(mContext).decodeFromAssets("week_bg.svga", new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
week_svga.setImageDrawable(drawable);
|
||||
SVGAViewUtils.playEndClear(week_svga);
|
||||
Log.e("MainHomeLiveAdapter", position + " ***************" + "onComplete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
}, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
live_info_view.setVisibility(View.GONE);
|
||||
lt_week_list.setVisibility(View.VISIBLE);
|
||||
weekListIndex = 0;
|
||||
setAction(img_week_head, Integer.valueOf(mWeekListBean.get(0).getSeconds()), mTitle, name2, mWeekListBean);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.common.bean.LiveClassBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/25.
|
||||
*/
|
||||
|
||||
public class MainHomeLiveClassAdapter extends RecyclerView.Adapter<MainHomeLiveClassAdapter.Vh> {
|
||||
|
||||
private Context mContext;
|
||||
private List<LiveClassBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<LiveClassBean> mOnItemClickListener;
|
||||
private boolean mDialog;
|
||||
|
||||
public MainHomeLiveClassAdapter(Context context, List<LiveClassBean> list, boolean dialog) {
|
||||
mContext = context;
|
||||
mList = list;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mDialog = dialog;
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
LiveClassBean bean = mList.get(position);
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<LiveClassBean> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
int res = mDialog ? R.layout.item_main_home_live_class : R.layout.item_main_home_live_class_2;
|
||||
return new Vh(mInflater.inflate(res, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position) {
|
||||
vh.setData(mList.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
ImageView mImg;
|
||||
TextView mName;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mImg = (ImageView) itemView.findViewById(R.id.img);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(LiveClassBean bean, int position) {
|
||||
itemView.setTag(position);
|
||||
if (bean.isAll()) {
|
||||
mImg.setImageResource(R.mipmap.icon_main_class_all);
|
||||
} else {
|
||||
ImgLoader.display(mContext, bean.getThumb(), mImg);
|
||||
}
|
||||
mName.setText(bean.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.yunbao.common.bean.WeekListBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 周榜轮播图适配器
|
||||
*/
|
||||
public class MainHomeLiveWeekAdapter implements ItemViewDelegate<WeekListBean> {
|
||||
public MainHomeLiveWeekAdapter() {
|
||||
}
|
||||
|
||||
public MainHomeLiveWeekAdapter(Context context, List<WeekListBean> getmWeekList) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewLayoutId() {
|
||||
return R.layout.view_live_week_item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForViewType(WeekListBean item, int position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(ViewHolder holder, WeekListBean weekListBean, int position) {
|
||||
ImageView weekLive = holder.getView(R.id.week_live);
|
||||
ImgLoader.display2(holder.getConvertView().getContext(), weekListBean.getAnchor_avatar(), weekLive);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.LiveClassBean;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MainHomeLivesClassAdapter extends RecyclerView.Adapter<MainHomeLivesClassAdapter.Vh> {
|
||||
|
||||
private Context mContext;
|
||||
private List<LiveClassBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<LiveClassBean> mOnItemClickListener;
|
||||
|
||||
//选中的
|
||||
public static int choice = 0;
|
||||
|
||||
public MainHomeLivesClassAdapter(Context context, List<LiveClassBean> list, boolean dialog) {
|
||||
mContext = context;
|
||||
mList = list;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
LiveClassBean bean = mList.get(position);
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<LiveClassBean> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MainHomeLivesClassAdapter.Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
int res = R.layout.item_main_home_lives_class;
|
||||
return new MainHomeLivesClassAdapter.Vh(mInflater.inflate(res, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MainHomeLivesClassAdapter.Vh vh, int position) {
|
||||
vh.setData(mList.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
TextView mName;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mName = (TextView) itemView.findViewById(R.id.tv_class_name);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
void setData(LiveClassBean bean, int position) {
|
||||
itemView.setTag(position);
|
||||
Locale locale;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
locale = mContext.getResources().getConfiguration().getLocales().get(0);
|
||||
} else {
|
||||
locale = mContext.getResources().getConfiguration().locale;
|
||||
}
|
||||
if (locale.getLanguage().equals("zh")) {
|
||||
mName.setText(bean.getChinese());
|
||||
} else {
|
||||
mName.setText(bean.getEnglish());
|
||||
}
|
||||
|
||||
if (position == choice) {
|
||||
mName.setBackgroundResource(R.drawable.button_ffc621);
|
||||
mName.setTextColor(Color.parseColor("#7d77fc"));
|
||||
} else {
|
||||
mName.setBackgroundResource(R.drawable.button_cbd5e0);
|
||||
mName.setTextColor(Color.parseColor("#484D68"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.jakewharton.rxbinding3.view.RxView;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.xj.marqueeview.MarqueeView;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.formatBigNum;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.utils.MainIconUtil;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import kotlin.Unit;
|
||||
|
||||
/**
|
||||
* 关注和推荐的适配器
|
||||
*/
|
||||
public class MainHomeRemFollLiveAdapter extends RefreshAdapter<LiveBean> {
|
||||
|
||||
|
||||
private Context context;
|
||||
private int Height;
|
||||
|
||||
public MainHomeRemFollLiveAdapter(Context context, int h) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
Log.e("t1", h + "屏1");
|
||||
this.Height = h;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_main_home_lives, parent, false));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
if (vh instanceof Vh) {
|
||||
((Vh) vh).setData(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
LinearLayout live_info_view;
|
||||
ImageView mCover;
|
||||
TextView mName;
|
||||
TextView mTitle;
|
||||
TextView mNum;
|
||||
ImageView mType;
|
||||
ImageView live_type;
|
||||
ImageView viewBg;
|
||||
ImageView mLiveIco;
|
||||
TextView mLiveState;
|
||||
MarqueeView mRvRankingList;
|
||||
ImageView PkAvatar;
|
||||
ImageView Pkico;
|
||||
ImageView dr_pk_ico;
|
||||
View views;
|
||||
ImageView bgs;
|
||||
private View redPacket;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
redPacket = itemView.findViewById(R.id.red_packet);
|
||||
live_info_view = (LinearLayout) itemView.findViewById(R.id.live_info_view);
|
||||
mCover = (ImageView) itemView.findViewById(R.id.cover);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mTitle = (TextView) itemView.findViewById(R.id.title);
|
||||
mNum = (TextView) itemView.findViewById(R.id.num);
|
||||
mType = (ImageView) itemView.findViewById(R.id.type);
|
||||
mLiveIco = (ImageView) itemView.findViewById(R.id.tv_live_ico);
|
||||
PkAvatar = (ImageView) itemView.findViewById(R.id.pk_avatar);
|
||||
Pkico = (ImageView) itemView.findViewById(R.id.pk_ico);
|
||||
dr_pk_ico = (ImageView) itemView.findViewById(R.id.dr_pk_ico);
|
||||
mLiveState = (TextView) itemView.findViewById(R.id.tv_live_state);
|
||||
mRvRankingList = (MarqueeView) itemView.findViewById(R.id.rv_ranking_list);
|
||||
live_type = (ImageView) itemView.findViewById(R.id.live_type);
|
||||
views = itemView.findViewById(R.id.views);
|
||||
bgs = itemView.findViewById(R.id.bgs);
|
||||
viewBg = (ImageView) itemView.findViewById(R.id.view_bg);
|
||||
RxView.clicks(itemView)
|
||||
.throttleFirst(2, TimeUnit.SECONDS) // 才发送 2s内第1次点击按钮的事件
|
||||
.subscribe(new Observer<Unit>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Unit unit) {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
Object tag = itemView.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void setData(LiveBean bean, int position) {
|
||||
itemView.setTag(position);
|
||||
mRvRankingList.setVisibility(View.VISIBLE);
|
||||
live_info_view.setVisibility(View.VISIBLE);
|
||||
live_type.setImageDrawable(null);
|
||||
viewBg.setVisibility(View.GONE);
|
||||
//皇帝
|
||||
if (bean.getRecommendcardtype().equals("1")) {
|
||||
viewBg.setImageResource(R.mipmap.emperor_recommendation);
|
||||
viewBg.setVisibility(View.VISIBLE);
|
||||
//超皇
|
||||
} else if (bean.getRecommendcardtype().equals("2")) {
|
||||
viewBg.setImageResource(R.mipmap.superemperor_recommendation);
|
||||
viewBg.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewBg.setVisibility(View.GONE);
|
||||
}
|
||||
if (bean.getContent_pic_size_two() != null && !bean.getContent_pic_size_two().equals("") && Height <= 1920) {
|
||||
Log.e("t1", position + "嗯" + Height + "111啊" + bean.getContent_pic_size_two());
|
||||
|
||||
Picasso.with(mContext)
|
||||
.load(bean.getContent_pic_size_two())
|
||||
.into(live_type);
|
||||
} else if (bean.getContent_pic_size_three() != null && !bean.getContent_pic_size_three().equals("") && Height > 1920) {
|
||||
Log.e("t1", position + "222啊" + Height + bean.getContent_pic_size_three());
|
||||
Picasso.with(mContext)
|
||||
.load(bean.getContent_pic_size_three())
|
||||
.into(live_type);
|
||||
}
|
||||
|
||||
|
||||
live_info_view.setVisibility(View.GONE);
|
||||
live_info_view.setVisibility(View.VISIBLE);
|
||||
mRvRankingList.setVisibility(View.GONE);
|
||||
bgs.setVisibility(View.GONE);
|
||||
if (bean.getIs_week() != null && bean.getIs_week().equals("1")) {
|
||||
ImgLoader.display(mContext, bean.getImg(), mCover);
|
||||
bgs.setVisibility(View.GONE);
|
||||
} else {
|
||||
ImgLoader.display(mContext, bean.getThumb(), mCover);
|
||||
bgs.setVisibility(View.VISIBLE);
|
||||
}
|
||||
Pkico.setVisibility(View.GONE);
|
||||
PkAvatar.setVisibility(View.GONE);
|
||||
dr_pk_ico.setVisibility(View.GONE);
|
||||
if (bean.getDrpk_status() != null && bean.getDrpk_status().equals("1")) {
|
||||
dr_pk_ico.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (bean.getPk_avatar_thumb() != null && !bean.getPk_avatar_thumb().equals("")) {
|
||||
ImgLoader.display(mContext, bean.getPk_avatar_thumb(), PkAvatar);
|
||||
Pkico.setVisibility(View.VISIBLE);
|
||||
PkAvatar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mName.setText(bean.getUserNiceName());
|
||||
if (TextUtils.isEmpty(bean.getTitle())) {
|
||||
if (mTitle.getVisibility() == View.VISIBLE) {
|
||||
mTitle.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
if (mTitle.getVisibility() != View.VISIBLE) {
|
||||
mTitle.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mTitle.setText(bean.getTitle());
|
||||
}
|
||||
mNum.setText(formatBigNum.formatBigNum(bean.getHot_num()));
|
||||
views.setVisibility(View.GONE);
|
||||
if ("1".equals(bean.getIslive())) {
|
||||
views.setVisibility(View.VISIBLE);
|
||||
//直播中
|
||||
mType.setImageResource(MainIconUtil.getLiveTypeIcon(bean.getType()));
|
||||
mType.setVisibility(View.VISIBLE);
|
||||
mLiveIco.setImageResource(R.mipmap.icon_main_rest_work);
|
||||
mNum.setVisibility(View.VISIBLE);
|
||||
live_type.setVisibility(View.VISIBLE);
|
||||
mLiveState.setText(mContext.getString(R.string.lives_state));
|
||||
} else {
|
||||
views.setVisibility(View.VISIBLE);
|
||||
//休息中
|
||||
mType.setImageResource(MainIconUtil.getLiveTypeIcon(Constants.LIVE_TYPE_RESTING));
|
||||
mType.setVisibility(View.GONE);
|
||||
mLiveIco.setImageResource(R.mipmap.icon_main_rest_spot);
|
||||
mLiveState.setText(mContext.getString(R.string.rest_state));
|
||||
live_type.setVisibility(View.GONE);
|
||||
mNum.setVisibility(View.GONE);
|
||||
}
|
||||
if (bean.getIs_week() != null && bean.getIs_week().equals("1")) {
|
||||
views.setVisibility(View.GONE);
|
||||
}
|
||||
if (bean.getRedPacketStatus() == 1) {
|
||||
redPacket.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
redPacket.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.common.bean.VideoBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/26.
|
||||
*/
|
||||
|
||||
public class MainHomeVideoAdapter extends RefreshAdapter<VideoBean> {
|
||||
|
||||
|
||||
private View.OnClickListener mOnClickListener;
|
||||
|
||||
public MainHomeVideoAdapter(Context context) {
|
||||
super(context);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_main_home_video, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position, @NonNull List payloads) {
|
||||
Object payload = payloads.size() > 0 ? payloads.get(0) : null;
|
||||
((Vh) vh).setData(mList.get(position), position, payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除视频
|
||||
*/
|
||||
public void deleteVideo(String videoId) {
|
||||
if (TextUtils.isEmpty(videoId)) {
|
||||
return;
|
||||
}
|
||||
int position = -1;
|
||||
for (int i = 0, size = mList.size(); i < size; i++) {
|
||||
if (videoId.equals(mList.get(i).getId())) {
|
||||
position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (position >= 0) {
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, mList.size(), Constants.PAYLOAD);
|
||||
}
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mCover;
|
||||
ImageView mAvatar;
|
||||
TextView mName;
|
||||
TextView mTitle;
|
||||
TextView mNum;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mCover = (ImageView) itemView.findViewById(R.id.cover);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mTitle = (TextView) itemView.findViewById(R.id.title);
|
||||
mNum = (TextView) itemView.findViewById(R.id.num);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(VideoBean bean, int position, Object payload) {
|
||||
itemView.setTag(position);
|
||||
ImgLoader.display(mContext,bean.getThumb(), mCover);
|
||||
mTitle.setText(bean.getTitle());
|
||||
mNum.setText(bean.getViewNum());
|
||||
UserBean userBean = bean.getUserBean();
|
||||
if (userBean != null) {
|
||||
ImgLoader.display(mContext,userBean.getAvatar(), mAvatar);
|
||||
mName.setText(userBean.getUserNiceName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
321
main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java
Normal file
@@ -0,0 +1,321 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.LevelBean;
|
||||
import com.yunbao.common.custom.MyRadioButton;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.utils.CommonIconUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.bean.ListBean;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/27.
|
||||
*/
|
||||
|
||||
public class MainListAdapter extends RefreshAdapter<ListBean> {
|
||||
public static final int TYPE_PROFIT = 1;//收益榜
|
||||
public static final int TYPE_CONTRIBUTE = 0;//贡献榜
|
||||
private String mFollow;
|
||||
private String mFollowing;
|
||||
private View.OnClickListener mFollowClickListener2;
|
||||
private View.OnClickListener mItemClickListener;
|
||||
private List<ListBean> mTopList;
|
||||
private int mType;
|
||||
private List<String> outRankHide = new ArrayList<>();
|
||||
protected int isRankOne;//是否为魅力榜 (第一个tab)
|
||||
|
||||
|
||||
public MainListAdapter(Context context, int type) {
|
||||
super(context);
|
||||
mType = type;
|
||||
mTopList = new ArrayList<>();
|
||||
mFollow = (mContext.getString(R.string.follow));
|
||||
mFollowing =mContext.getString(R.string.following);
|
||||
mItemClickListener = v -> {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null && mOnItemClickListener != null) {
|
||||
ListBean model = (ListBean) tag;
|
||||
if (model.isHide()) {
|
||||
ToastUtil.show(R.string.can_not_go);
|
||||
} else {
|
||||
mOnItemClickListener.onItemClick(model, 0);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
mFollowClickListener2 = v -> {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
final int position = (int) tag;
|
||||
final ListBean bean = mList.get(position);
|
||||
CommonHttpUtil.setAttention(bean.getUid(), new CommonCallback<Integer>() {
|
||||
@Override
|
||||
public void callback(Integer bean) {
|
||||
if (bean != null && bean == 1) {
|
||||
v.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public void setRankOne(int rankOne) {
|
||||
isRankOne = rankOne;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mList != null && mTopList.size() > 0) {
|
||||
return mList.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearData() {
|
||||
mTopList.clear();
|
||||
super.clearData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertList(List<ListBean> list) {
|
||||
if (mRecyclerView != null && mList != null && list != null && list.size() > 0) {
|
||||
int p = mList.size() + 1;
|
||||
mList.addAll(list);
|
||||
notifyItemRangeInserted(p, list.size());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshData(List<ListBean> list) {
|
||||
for (ListBean model : list) {
|
||||
for (String hideId : outRankHide) {
|
||||
if (!model.isHide())
|
||||
model.setHide(TextUtils.equals(model.getUid(), hideId));
|
||||
}
|
||||
}
|
||||
mTopList.clear();
|
||||
|
||||
int size = list.size();
|
||||
if (size > 0) {
|
||||
mTopList.add(list.get(0));
|
||||
}
|
||||
if (size > 1) {
|
||||
mTopList.add(list.get(1));
|
||||
}
|
||||
if (size > 2) {
|
||||
mTopList.add(list.get(2));
|
||||
}
|
||||
if (size <= 3) {
|
||||
list = new ArrayList<>();
|
||||
} else {
|
||||
list = list.subList(3, list.size());
|
||||
}
|
||||
super.refreshData(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_main_list, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position, @NonNull List payloads) {
|
||||
Object payload = payloads.size() > 0 ? payloads.get(0) : null;
|
||||
((Vh) vh).setData(mList.get(position), position, payload);
|
||||
}
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView mOrder;
|
||||
ImageView mAvatar;
|
||||
TextView mName;
|
||||
TextView mVotes;
|
||||
MyRadioButton mBtnFollow;
|
||||
ImageView mSex;
|
||||
ImageView mLevel;
|
||||
SVGAImageView svga;
|
||||
GifImageView liveing;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mOrder = (TextView) itemView.findViewById(R.id.order);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
liveing = itemView.findViewById(R.id.liveing);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mVotes = (TextView) itemView.findViewById(R.id.votes);
|
||||
mSex = itemView.findViewById(R.id.sex);
|
||||
mLevel = itemView.findViewById(R.id.level);
|
||||
svga = itemView.findViewById(R.id.svga);
|
||||
mBtnFollow = (MyRadioButton) itemView.findViewById(R.id.btn_follow);
|
||||
mBtnFollow.setOnClickListener(mFollowClickListener2);
|
||||
itemView.setOnClickListener(mItemClickListener);
|
||||
}
|
||||
|
||||
void setData(ListBean bean, int position, Object payload) {
|
||||
if (payload == null) {
|
||||
svga.setVisibility(View.INVISIBLE);
|
||||
if (bean.getDress_head() != null) {
|
||||
if (bean.getDress_head().contains("svga")) {
|
||||
svga.setVisibility(View.VISIBLE);
|
||||
try {
|
||||
new SVGAParser(mContext).parse(new URL(bean.getDress_head()), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
svga.setImageDrawable(drawable);
|
||||
SVGAViewUtils.playEndClear(svga, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Log.e("eee", bean.getDress_head());
|
||||
ImgLoader.display(mContext, bean.getDress_head(), svga);
|
||||
}
|
||||
}
|
||||
itemView.setTag(bean);
|
||||
mOrder.setText("" + (position + 4));
|
||||
if (bean.isHide()) {
|
||||
mName.setText(mContext.getString(R.string.mystery_man));
|
||||
ImgLoader.display(mContext, R.mipmap.hide, mAvatar);
|
||||
mSex.setVisibility(View.GONE);
|
||||
} else {
|
||||
ImgLoader.display(mContext, bean.getAvatar(), mAvatar);
|
||||
mName.setText(bean.getUserNiceName());
|
||||
mSex.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
mVotes.setText(bean.getTotalCoinFormat() + " ");
|
||||
mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
|
||||
// LevelBean levelBean = null;
|
||||
// if (mType == TYPE_PROFIT) {
|
||||
// levelBean = CommonAppConfig.getInstance().getAnchorLevel(bean.getLevelAnchor());
|
||||
// } else {
|
||||
// levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel());
|
||||
// }
|
||||
// if (levelBean != null) {
|
||||
// ImgLoader.display(mContext, levelBean.getThumb(), mLevel);
|
||||
// }
|
||||
}
|
||||
liveing.setVisibility(View.INVISIBLE);
|
||||
if (bean.getIslive() == 1) {
|
||||
liveing.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
liveing.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
mBtnFollow.setVisibility(bean.isHide() ? View.GONE : View.VISIBLE);
|
||||
svga.setVisibility(bean.isHide() ? View.INVISIBLE : View.VISIBLE);
|
||||
mBtnFollow.setTag(position);
|
||||
if (bean.getAttention() == 1) {
|
||||
mBtnFollow.doChecked(true);
|
||||
mBtnFollow.setText(mFollowing);
|
||||
mBtnFollow.setBackgroundResource(R.drawable.background_dbdbdb);
|
||||
mBtnFollow.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBtnFollow.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
mBtnFollow.doChecked(false);
|
||||
mBtnFollow.setText(mFollow);
|
||||
if(isRankOne==0){
|
||||
mBtnFollow.setBackgroundResource(R.drawable.background_ff82c1);
|
||||
mBtnFollow.setTextColor(Color.parseColor("#FF82C1"));
|
||||
}else if(isRankOne==1){
|
||||
mBtnFollow.setBackgroundResource(R.drawable.background_ff7bbaff);
|
||||
mBtnFollow.setTextColor(Color.parseColor("#7BBAFF"));
|
||||
}else if(isRankOne==2){
|
||||
mBtnFollow.setBackgroundResource(R.drawable.background_ffff9072);
|
||||
mBtnFollow.setTextColor(Color.parseColor("#ff9072"));
|
||||
}
|
||||
}
|
||||
mSex.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updateItem(String id, int attention) {
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
for (ListBean bean : mTopList) {
|
||||
if (bean != null && id.equals(bean.getUid())) {
|
||||
bean.setAttention(attention);
|
||||
notifyDataSetChanged();
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int i = 0, size = mList.size(); i < size; i++) {
|
||||
ListBean bean = mList.get(i);
|
||||
if (bean != null && id.equals(bean.getUid())) {
|
||||
bean.setAttention(attention);
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置隐藏数据
|
||||
*
|
||||
* @param outRankHide
|
||||
*/
|
||||
public void setHide(List<String> outRankHide) {
|
||||
this.outRankHide = outRankHide;
|
||||
for (ListBean model : mList) {
|
||||
for (String hideId : outRankHide) {
|
||||
if (!model.isHide())
|
||||
model.setHide(TextUtils.equals(model.getUid(), hideId));
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
130
main/src/main/java/com/yunbao/main/adapter/MainMeAdapter.java
Normal file
@@ -0,0 +1,130 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.UserItemBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/28.
|
||||
*/
|
||||
|
||||
public class MainMeAdapter extends RecyclerView.Adapter<MainMeAdapter.Vh> {
|
||||
|
||||
private static final int NORMAL = 0;
|
||||
private static final int GROUP_LAST = 1;
|
||||
private static final int ALL_LAST = 2;
|
||||
|
||||
private Context mContext;
|
||||
private List<UserItemBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private OnItemClickListener<UserItemBean> mOnItemClickListener;
|
||||
|
||||
public MainMeAdapter(Context context, List<UserItemBean> list) {
|
||||
mContext = context;
|
||||
mList = list;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<UserItemBean> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
UserItemBean bean = mList.get(position);
|
||||
if (bean.isGroupLast()) {
|
||||
return GROUP_LAST;
|
||||
} else if (bean.isAllLast()) {
|
||||
return ALL_LAST;
|
||||
} else {
|
||||
return NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setList(List<UserItemBean> list) {
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
boolean changed = false;
|
||||
if (mList.size() != list.size()) {
|
||||
changed = true;
|
||||
} else {
|
||||
for (int i = 0, size = mList.size(); i < size; i++) {
|
||||
if (!mList.get(i).equals(list.get(i))) {
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
mList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
int res = 0;
|
||||
// if (viewType == GROUP_LAST) {
|
||||
// res = R.layout.item_main_me_1;//竖向单列表
|
||||
// } else if (viewType == ALL_LAST) {
|
||||
res = R.layout.item_main_me_2;//横向4列
|
||||
// } else {
|
||||
// res = R.layout.item_main_me_0;
|
||||
// }
|
||||
return new Vh(mInflater.inflate(res, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position) {
|
||||
vh.setData(mList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mThumb;
|
||||
TextView mName;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mThumb = (ImageView) itemView.findViewById(R.id.thumb);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView, () -> {
|
||||
Object tag = itemView.getTag();
|
||||
if (tag != null) {
|
||||
UserItemBean bean = (UserItemBean) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void setData(UserItemBean bean) {
|
||||
itemView.setTag(bean);
|
||||
ImgLoader.display(mContext, bean.getThumb(), mThumb);
|
||||
mName.setText(bean.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.utils.MainIconUtil;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/26.
|
||||
*/
|
||||
|
||||
public class MainNearNearAdapter extends RefreshAdapter<LiveBean> {
|
||||
|
||||
|
||||
private View.OnClickListener mOnClickListener;
|
||||
|
||||
public MainNearNearAdapter(Context context) {
|
||||
super(context);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_main_near_near, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
((Vh) vh).setData(mList.get(position), position);
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mCover;
|
||||
ImageView mAvatar;
|
||||
TextView mName;
|
||||
TextView mTitle;
|
||||
TextView mDistance;
|
||||
ImageView mType;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mCover = (ImageView) itemView.findViewById(R.id.cover);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mTitle = (TextView) itemView.findViewById(R.id.title);
|
||||
mDistance = (TextView) itemView.findViewById(R.id.distance);
|
||||
mType = (ImageView) itemView.findViewById(R.id.type);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(LiveBean bean, int position) {
|
||||
itemView.setTag(position);
|
||||
ImgLoader.display(mContext,bean.getThumb(), mCover);
|
||||
ImgLoader.display(mContext,bean.getAvatar(), mAvatar);
|
||||
mName.setText(bean.getUserNiceName());
|
||||
if (TextUtils.isEmpty(bean.getTitle())) {
|
||||
if (mTitle.getVisibility() == View.VISIBLE) {
|
||||
mTitle.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
if (mTitle.getVisibility() != View.VISIBLE) {
|
||||
mTitle.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mTitle.setText(bean.getTitle());
|
||||
}
|
||||
mDistance.setText(bean.getDistance());
|
||||
mType.setImageResource(MainIconUtil.getLiveTypeIcon(bean.getType()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
125
main/src/main/java/com/yunbao/main/adapter/MsgFollowAdapter.java
Normal file
@@ -0,0 +1,125 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.yunbao.common.bean.MsgSwitchDetailModel;
|
||||
import com.yunbao.common.bean.MsgSwitchFollowlModel;
|
||||
import com.yunbao.common.bean.UserItemBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.ResponseData;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.main.MainNetManager;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MsgFollowAdapter extends RecyclerView.Adapter<MsgFollowAdapter.Vh> {
|
||||
|
||||
private Activity mContext;
|
||||
private List<MsgSwitchFollowlModel> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private OnItemClickListener<MsgSwitchFollowlModel> mOnItemClickListener;
|
||||
public MsgFollowAdapter(Activity context, List<MsgSwitchFollowlModel> list) {
|
||||
mContext = context;
|
||||
mList = list;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<MsgSwitchFollowlModel> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
return new Vh(mInflater.inflate( R.layout.item_msg_follow, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh holder, int position) {
|
||||
holder.setData(mList.get(position),position);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
RoundedImageView avatar;
|
||||
TextView anchor_name;
|
||||
ImageView sb_switch;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
avatar = (RoundedImageView) itemView.findViewById(R.id.avatar);
|
||||
anchor_name = (TextView) itemView.findViewById(R.id.anchor_name);
|
||||
sb_switch = (ImageView) itemView.findViewById(R.id.sb_switch);
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView, () -> {
|
||||
Object tag = itemView.getTag();
|
||||
if (tag != null) {
|
||||
MsgSwitchFollowlModel bean = (MsgSwitchFollowlModel) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
String is = "1";
|
||||
void setData(MsgSwitchFollowlModel bean,int position) {
|
||||
itemView.setTag(bean);
|
||||
ImgLoader.display(mContext, bean.getAvatar(), avatar);
|
||||
anchor_name.setText(bean.getUser_nicename());
|
||||
if(bean.getStatus().equals("2")) {
|
||||
is = "1";
|
||||
sb_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
}else{
|
||||
is = "2";
|
||||
sb_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
sb_switch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MainNetManager.get(mContext).setBeginShowMsgSwitch(is + "", "", bean.getLiveuid(), new HttpCallback<ResponseData>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseData data) {
|
||||
if(data.getCode() == 200){
|
||||
mList.get(position).setStatus(is);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show( mContext.getString(R.string.net_error));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by zhy on 16/4/9.
|
||||
*/
|
||||
public class MultiItemTypeAdapter<T> extends RecyclerView.Adapter<ViewHolder> {
|
||||
protected Context mContext;
|
||||
protected List<T> mDatas;
|
||||
|
||||
protected ItemViewDelegateManager mItemViewDelegateManager;
|
||||
protected OnItemClickListener mOnItemClickListener;
|
||||
|
||||
|
||||
public MultiItemTypeAdapter(Context context, List<T> datas) {
|
||||
mContext = context;
|
||||
mDatas = datas;
|
||||
mItemViewDelegateManager = new ItemViewDelegateManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (!useItemViewDelegateManager()) return super.getItemViewType(position);
|
||||
return mItemViewDelegateManager.getItemViewType(mDatas.get(position), position);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
ItemViewDelegate itemViewDelegate = mItemViewDelegateManager.getItemViewDelegate(viewType);
|
||||
int layoutId = itemViewDelegate.getItemViewLayoutId();
|
||||
ViewHolder holder = ViewHolder.createViewHolder(mContext, parent, layoutId);
|
||||
onViewHolderCreated(holder,holder.getConvertView());
|
||||
setListener(parent, holder, viewType);
|
||||
return holder;
|
||||
}
|
||||
|
||||
public void onViewHolderCreated(ViewHolder holder,View itemView){
|
||||
|
||||
}
|
||||
|
||||
public void convert(ViewHolder holder, T t) {
|
||||
mItemViewDelegateManager.convert(holder, t, holder.getAdapterPosition());
|
||||
}
|
||||
|
||||
protected boolean isEnabled(int viewType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected void setListener(final ViewGroup parent, final ViewHolder viewHolder, int viewType) {
|
||||
if (!isEnabled(viewType)) return;
|
||||
viewHolder.getConvertView().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mOnItemClickListener != null) {
|
||||
int position = viewHolder.getAdapterPosition();
|
||||
mOnItemClickListener.onItemClick(v, viewHolder , position);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.getConvertView().setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
if (mOnItemClickListener != null) {
|
||||
int position = viewHolder.getAdapterPosition();
|
||||
return mOnItemClickListener.onItemLongClick(v, viewHolder, position);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
convert(holder, mDatas.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
int itemCount = mDatas.size();
|
||||
return itemCount;
|
||||
}
|
||||
|
||||
|
||||
public List<T> getDatas() {
|
||||
return mDatas;
|
||||
}
|
||||
|
||||
public MultiItemTypeAdapter addItemViewDelegate(ItemViewDelegate<T> itemViewDelegate) {
|
||||
mItemViewDelegateManager.addDelegate(itemViewDelegate);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MultiItemTypeAdapter addItemViewDelegate(int viewType, ItemViewDelegate<T> itemViewDelegate) {
|
||||
mItemViewDelegateManager.addDelegate(viewType, itemViewDelegate);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected boolean useItemViewDelegateManager() {
|
||||
return mItemViewDelegateManager.getItemViewDelegateCount() > 0;
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(View view, RecyclerView.ViewHolder holder, int position);
|
||||
|
||||
boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, int position);
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
|
||||
this.mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.xj.marqueeview.base.CommonAdapter;
|
||||
import com.xj.marqueeview.base.ViewHolder;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页排行榜
|
||||
*/
|
||||
public class RankingListAdapter extends CommonAdapter<List> {
|
||||
|
||||
|
||||
private TextView className,className1;
|
||||
private ImageView ico1;
|
||||
private ImageView ico2;
|
||||
private ImageView ico3;
|
||||
private Context contexts;
|
||||
public RankingListAdapter(Context context, List<List> datas) {
|
||||
super(context, R.layout.item_ranking_list, datas);
|
||||
contexts = context;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void convert(ViewHolder viewHolder, List item, int position) {
|
||||
className = (TextView) viewHolder.getView(R.id.class_name);
|
||||
className1 = (TextView) viewHolder.getView(R.id.class_name1);
|
||||
ico1 = (ImageView) viewHolder.getView(R.id.ico1);
|
||||
ico2 = (ImageView) viewHolder.getView(R.id.ico2);
|
||||
ico3 = (ImageView) viewHolder.getView(R.id.ico3);
|
||||
if(position==0){
|
||||
className.setText("豪氣榜");
|
||||
className1.setText("Rich list");
|
||||
}else{
|
||||
className.setText("魅力榜");
|
||||
className1.setText("Glamour list");
|
||||
}
|
||||
|
||||
for (int j = 0; j<item.size(); j++) {
|
||||
if(j==0){
|
||||
ImgLoader.displayAvatar(contexts,item.get(j).toString(), ico1);
|
||||
}else if (j==1){
|
||||
ImgLoader.displayAvatar(contexts,item.get(j).toString(), ico2);
|
||||
}else if(j == 2){
|
||||
ImgLoader.displayAvatar(contexts,item.get(j).toString(), ico3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||