androidx版本首次提交
81
main/build.gradle
Normal file
@@ -0,0 +1,81 @@
|
||||
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(dir: 'libs', include: ['*.jar'])
|
||||
//直播
|
||||
api project(':live')
|
||||
//短视频
|
||||
api project(':video')
|
||||
api project(':common')
|
||||
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.google.android.gms:play-services-auth:15.0.0'
|
||||
|
||||
}
|
||||
62
main/google-services.json
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"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.pdlive.shayu"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "292494634914-ctr3fptp5mkv2qqr4gkgjo9uluq2joqb.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.pdlive.shayu",
|
||||
"certificate_hash": "15fc5e70cf238323bf7111c8c627803985478e87"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "292494634914-ejtqvaj86a2lldv0di2pr3d5gngprahd.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.pdlive.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
|
||||
127
main/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.yunbao.main">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".activity.OneLoginActivity"></activity>
|
||||
<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.GooglePayActivity"
|
||||
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:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.UserHomeActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.SettingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.SearchActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<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" />
|
||||
</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/icoss.svga
Normal file
@@ -0,0 +1,499 @@
|
||||
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.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 綁定手機號
|
||||
*/
|
||||
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;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_bind_user;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
// setTitle(WordUtil.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 = WordUtil.getString(R.string.reg_get_code);
|
||||
mGetCodeAgain = WordUtil.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");
|
||||
}
|
||||
|
||||
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) {
|
||||
mTvCountryCode.setText("+" + country.code);
|
||||
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);
|
||||
} else if (i == R.id.btn_tip3) {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY2);
|
||||
} 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(WordUtil.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum))
|
||||
// {
|
||||
// mEditPhone.setError(WordUtil.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(WordUtil.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum)) {
|
||||
// mEditPhone.setError(WordUtil.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
String code = mEditCode.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(code)) {
|
||||
mEditCode.setError(WordUtil.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(WordUtil.getString(R.string.reg_input_pwd_1));
|
||||
mEditPwd1.requestFocus();
|
||||
return;
|
||||
}
|
||||
String pwd2 = mEditPwd2.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd2)) {
|
||||
mEditPwd2.setError(WordUtil.getString(R.string.reg_input_pwd_2));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (!pwd.equals(pwd2)) {
|
||||
mEditPwd2.setError(WordUtil.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) {
|
||||
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) {
|
||||
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, WordUtil.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(WordUtil.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,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(WordUtil.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,494 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
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.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.interfaces.ActivityResultCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
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.main.R;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
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 = false;
|
||||
private String isBind = "0", mobile = "";
|
||||
private boolean isName = false;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_edit_profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(WordUtil.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);
|
||||
|
||||
mImageUtil = new ProcessImageUtil(this);
|
||||
mImageUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
@Override
|
||||
public void beforeCamera() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
if (file != null) {
|
||||
ImgLoader.display(mContext, file, mAvatar);
|
||||
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"));
|
||||
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 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
} 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);
|
||||
}
|
||||
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);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void editAvatar() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void forwardName() {
|
||||
if (mUserBean == null) {
|
||||
return;
|
||||
}
|
||||
// Intent intent = new Intent(mContext, EditNameActivity.class);
|
||||
// intent.putExtra(Constants.NICK_NAME, mUserBean.getUserNiceName());
|
||||
// mImageUtil.startActivityForResult(intent, new ActivityResultCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(Intent intent) {
|
||||
// if (intent != null) {
|
||||
// String name = intent.getStringExtra(Constants.NICK_NAME);
|
||||
// mUserBean.setUserNiceName(name);
|
||||
// mName.setText(name);
|
||||
// EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
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());
|
||||
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);
|
||||
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() {
|
||||
if (mImageUtil != null) {
|
||||
mImageUtil.release();
|
||||
}
|
||||
MainHttpUtil.cancel(MainHttpConsts.UPDATE_AVATAR);
|
||||
MainHttpUtil.cancel(MainHttpConsts.UPDATE_FIELDS);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void showData(UserBean u) {
|
||||
ImgLoader.displayAvatar(mContext, u.getAvatar(), mAvatar);
|
||||
mName.setText(u.getUserNiceName());
|
||||
mSign.setText(u.getSignature());
|
||||
mBirthday.setText(u.getBirthday());
|
||||
mSex.setText(u.getSex() == 1 ? R.string.sex_male : R.string.sex_female);
|
||||
mCity.setText(u.getLocation());
|
||||
if ("1".equals(u.getIs_bind())) {
|
||||
tv_bind_phone.setText("");
|
||||
isBind = "1";
|
||||
mobile = u.getMobile();
|
||||
} else {
|
||||
tv_bind_phone.setText(getResources().getString(R.string.bind_phone_text));
|
||||
isBind = "0";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 选择城市
|
||||
*/
|
||||
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 ("1".equals(u.getIs_bind())) {
|
||||
tv_bind_phone.setText("");
|
||||
isBind = "1";
|
||||
mobile = u.getMobile();
|
||||
} else {
|
||||
tv_bind_phone.setText(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(WordUtil.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(WordUtil.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 android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
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 androidx.appcompat.app.AppCompatActivity;
|
||||
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 com.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustEvent;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.DeviceUtils;
|
||||
import com.facebook.AccessToken;
|
||||
import com.facebook.CallbackManager;
|
||||
import com.facebook.FacebookCallback;
|
||||
import com.facebook.FacebookException;
|
||||
import com.facebook.Profile;
|
||||
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.LoginData;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.dialog.LoginTipsDialog;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.logger;
|
||||
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
|
||||
|
||||
//import com.facebook.AccessToken;
|
||||
//import com.facebook.CallbackManager;
|
||||
//import com.facebook.FacebookCallback;
|
||||
//import com.facebook.FacebookException;
|
||||
//import com.facebook.FacebookSdk;
|
||||
//import com.facebook.Profile;
|
||||
//import com.facebook.login.LoginManager;
|
||||
//import com.facebook.login.LoginResult;
|
||||
|
||||
//import com.linecorp.linesdk.LoginDelegate;
|
||||
//import com.linecorp.linesdk.LoginListener;
|
||||
//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.linecorp.linesdk.widget.LoginButton;
|
||||
//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;
|
||||
|
||||
/**
|
||||
* 入口
|
||||
*/
|
||||
public class EntryActivity extends AppCompatActivity {
|
||||
|
||||
private VideoView video_view;
|
||||
private ImageView btn_phone, btn_line, btn_google, btn_twitter;
|
||||
private TextView btn_tip, btn_tip1, tv_customer;
|
||||
private TwitterLoginButton tt_login_button;
|
||||
public static Activity activity;
|
||||
private static String mLoginType = Constants.MOB_PHONE;//登录方式
|
||||
private String mPromoCode = "";//推广码
|
||||
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 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 onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
// super.onActivityResult(requestCode, resultCode, data);
|
||||
// if (requestCode != 1) {
|
||||
// Log.e("ERROR", "Unsupported Request");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// 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.");
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// // Login canceled due to other error
|
||||
// Log.e("ERROR", "Login FAILED!");
|
||||
// Log.e("ERROR", result.getErrorData().toString());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//谷歌登录回调
|
||||
|
||||
/**
|
||||
* 登录回调
|
||||
*
|
||||
* @params requestCode 对应onActivityResult的 requestCode
|
||||
* @params data 对应onActivityResult的 data
|
||||
* @params selfRequestCode 对应上面初始化请求的自定义请求码
|
||||
* @params mListener 登录结果回调
|
||||
*/
|
||||
// public static void onActivityResult(int requestCode, Intent data, int selfRequestCode) {
|
||||
// if (requestCode == selfRequestCode) {
|
||||
// Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
|
||||
// handleSignInResult( task);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// private static void handleSignInResult(@NonNull Task<GoogleSignInAccount> completedTask) {
|
||||
// try {
|
||||
// GoogleSignInAccount account = completedTask.getResult(ApiException.class);
|
||||
// String idToken = account.getIdToken();
|
||||
// Log.e("tag111", idToken+"token"+account.getPhotoUrl());
|
||||
//
|
||||
// } catch (ApiException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
public void Get_hash_key() {
|
||||
PackageInfo info;
|
||||
try {
|
||||
info = getPackageManager().getPackageInfo("com.pdlive.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);
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
btn_tip.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
WebViewActivity.forward(EntryActivity.this, HtmlConfig.LOGIN_PRIVCAY1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
btn_phone.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LoginTipsDialog loginTipsDialog = new LoginTipsDialog();
|
||||
loginTipsDialog.show(getSupportFragmentManager(), "LoginTipsDialog");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// MobSDK.submitPolicyGrantResult(true, new OperationCallback<Void>() {
|
||||
// @Override
|
||||
// public void onComplete(Void aVoid) {
|
||||
//// ToastUtil.show("onComplete: c成功");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable throwable) {
|
||||
//// ToastUtil.show("隐私协议授权结果提交:失败");
|
||||
// }
|
||||
// });
|
||||
|
||||
//gpp模式判断
|
||||
// boolean gppVer = MobSDK.isGppVer();
|
||||
// Log.i("tag", "onCreate: gppVer: " + gppVer);
|
||||
// Boolean gpAvailable = MobSDK.isGpAvailable();
|
||||
// Log.i("tag", "onCreate: gpAvailable: " + gpAvailable);
|
||||
|
||||
getPromoCode();
|
||||
getUuidDevice();
|
||||
AdjustEvent adjustEvent2 = new AdjustEvent("tyqsyf");
|
||||
Adjust.trackEvent(adjustEvent2);
|
||||
|
||||
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) {
|
||||
// final Dialog dialog = DialogUitl.loginAuthDialog(activity);
|
||||
// dialog.show();
|
||||
// mLoginUtil.execute("facebook", new MobCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(Object data) {
|
||||
// if (data != null) {
|
||||
// loginBuyThird((LoginData) data);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onCancel() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFinish() {
|
||||
// if (dialog != null) {
|
||||
// dialog.dismiss();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
LoginManager.getInstance().logInWithReadPermissions(EntryActivity.this, Arrays.asList("public_profile"));
|
||||
}
|
||||
});
|
||||
|
||||
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));
|
||||
}
|
||||
});
|
||||
// requestPermission();
|
||||
|
||||
googleLoginSet();
|
||||
twitterLoginSet();
|
||||
|
||||
btn_google.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
|
||||
startActivityForResult(signInIntent, 1002);
|
||||
}
|
||||
});
|
||||
|
||||
lt_btn_twitter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View 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);
|
||||
|
||||
// Call<User> user = TwitterCore.getInstance().getApiClient().getAccountService().verifyCredentials(false, true, false);
|
||||
// user.enqueue(new Callback<User>() {
|
||||
// @Override
|
||||
// public void success(Result<User> result) {
|
||||
// User userInfo = result.data;
|
||||
// String email = userInfo.email;
|
||||
// String description = userInfo.description;
|
||||
// String imageProfileUrl = userInfo.profileImageUrl;
|
||||
// String profileUrl = imageProfileUrl.replace("_normal", "");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void failure(TwitterException exception) {
|
||||
// Log.i("Log", "TwitterException = " + exception);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@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) {
|
||||
try {
|
||||
// App-to-app login
|
||||
Intent loginIntent = LineLoginApi.getLoginIntent(
|
||||
view.getContext(),
|
||||
"1656399535",
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void updateUI() {
|
||||
boolean enableButtons = AccessToken.getCurrentAccessToken() != null;
|
||||
Profile profile = Profile.getCurrentProfile();
|
||||
if (enableButtons && profile != null) {
|
||||
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("")) {
|
||||
JSONObject data = JSON.parseObject(appData.getData());
|
||||
mPromoCode = data.getString("admin_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));
|
||||
}
|
||||
|
||||
private static final String EMAIL = "email";
|
||||
|
||||
/**
|
||||
* 三方登录
|
||||
*/
|
||||
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);
|
||||
if(code == 0){
|
||||
//完成第三方登录
|
||||
if(mLoginType.equals("twitter")){
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("winf6e");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
mFirebaseAnalytics.logEvent("FS_log_twitter", null);
|
||||
logger.logEvent("FB_log_twitter");
|
||||
}else if(mLoginType.equals("facebook")){
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("oywoff");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
mFirebaseAnalytics.logEvent("FS_log_fb", null);
|
||||
logger.logEvent("FB_log_fb");
|
||||
}else if(mLoginType.equals("google")){
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("1cm8gl");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
mFirebaseAnalytics.logEvent("FS_log_google", null);
|
||||
logger.logEvent("FB_log_google");
|
||||
}else if(mLoginType.equals("LINE")){
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("71p74r");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
mFirebaseAnalytics.logEvent("FS_log_line", null);
|
||||
logger.logEvent("FB_log_line");
|
||||
}
|
||||
}
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("1com4k");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
mFirebaseAnalytics.logEvent("FS_createdRole", null);
|
||||
logger.logEvent("FB_createdRole");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//登录成功!
|
||||
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.getString("need_bind").equals("0")) {
|
||||
mFirstLogin = obj.getIntValue("first_login") == 1;
|
||||
mShowInvite = obj.getIntValue("isagent") == 1;
|
||||
CommonAppConfig.getInstance().setLoginInfo(uid, token, true);
|
||||
getBaseUserInfo();
|
||||
//友盟统计登录
|
||||
// MobclickAgent.onProfileSignIn(mLoginType, uid);
|
||||
} 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(mLoginType.equals("twitter")){
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("ea6lld");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
|
||||
mFirebaseAnalytics.logEvent("FS_reg_twitter", null);
|
||||
logger.logEvent("FB_reg_twitter");
|
||||
}else if(mLoginType.equals("facebook")){
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("5jbk95");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
|
||||
mFirebaseAnalytics.logEvent("FS_reg_fb", null);
|
||||
logger.logEvent("FB_reg_fb");
|
||||
}else if(mLoginType.equals("google")){
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("krap47");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
|
||||
mFirebaseAnalytics.logEvent("FS_reg_google", null);
|
||||
logger.logEvent("FB_reg_google");
|
||||
}else if(mLoginType.equals("LINE")){
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("uaacbn");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
|
||||
mFirebaseAnalytics.logEvent("FS_reg_line", null);
|
||||
logger.logEvent("FB_reg_line");
|
||||
}
|
||||
// RecommendActivity.forward(Contexts, mShowInvite);
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == true) {
|
||||
EntryActivity.this.startActivity(new Intent(EntryActivity.this, OneLoginActivity.class));
|
||||
}else{
|
||||
MainActivity.forward(EntryActivity.this, false);
|
||||
}
|
||||
} else {
|
||||
MainActivity.forward(EntryActivity.this, false);
|
||||
}
|
||||
EntryActivity.activity.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
131
main/src/main/java/com/yunbao/main/activity/FansActivity.java
Normal file
@@ -0,0 +1,131 @@
|
||||
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.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的粉丝
|
||||
*/
|
||||
|
||||
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(WordUtil.getString(R.string.fans_my_fans));
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_fans);
|
||||
} else {
|
||||
setTitle(WordUtil.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);
|
||||
}
|
||||
}
|
||||
400
main/src/main/java/com/yunbao/main/activity/FindPwdActivity.java
Normal file
@@ -0,0 +1,400 @@
|
||||
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.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.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_find_pwd;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(WordUtil.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 = WordUtil.getString(R.string.reg_get_code);
|
||||
mGetCodeAgain = WordUtil.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);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
private void showCountryCode(){
|
||||
CountryPicker.newInstance(null, new OnPick() {
|
||||
@Override
|
||||
public void onPick(Country country) {
|
||||
mTvCountryCode.setText("+"+country.code);
|
||||
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(WordUtil.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum)) {
|
||||
// mEditPhone.setError(WordUtil.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(WordUtil.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum)) {
|
||||
// mEditPhone.setError(WordUtil.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
String code = mEditCode.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(code)) {
|
||||
mEditCode.setError(WordUtil.getString(R.string.reg_input_code));
|
||||
mEditCode.requestFocus();
|
||||
return;
|
||||
}
|
||||
final String pwd = mEditPwd1.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd)) {
|
||||
mEditPwd1.setError(WordUtil.getString(R.string.reg_input_pwd_1));
|
||||
mEditPwd1.requestFocus();
|
||||
return;
|
||||
}
|
||||
String pwd2 = mEditPwd2.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd2)) {
|
||||
mEditPwd2.setError(WordUtil.getString(R.string.reg_input_pwd_2));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (!pwd.equals(pwd2)) {
|
||||
mEditPwd2.setError(WordUtil.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");
|
||||
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(WordUtil.getString(R.string.my_black));
|
||||
} else if (mToUid.equals(CommonAppConfig.getInstance().getUid())) {
|
||||
setTitle(WordUtil.getString(R.string.follow_my_follow));
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_follow);
|
||||
} else {
|
||||
setTitle(WordUtil.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
332
main/src/main/java/com/yunbao/main/activity/GoogleFragment.java
Normal file
@@ -0,0 +1,332 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
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 com.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustEvent;
|
||||
import com.android.billingclient.api.Purchase;
|
||||
import com.android.billingclient.api.SkuDetails;
|
||||
import com.facebook.appevents.AppEventsConstants;
|
||||
import com.tjbaobao.gitee.billing.GoogleBillingUtil;
|
||||
import com.tjbaobao.gitee.billing.OnGoogleBillingListener;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static android.util.Log.i;
|
||||
import static com.yunbao.common.CommonAppContext.logger;
|
||||
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class GoogleFragment extends Fragment {
|
||||
|
||||
|
||||
|
||||
private View view;
|
||||
private static String mOrderid,mProductId,MoneyUsds;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
@SuppressLint("ValidFragment")
|
||||
public GoogleFragment(String urls) {
|
||||
url = urls;
|
||||
Log.e("google","111aa");
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//通过参数中的布局填充获取对应布局
|
||||
view =inflater.inflate(R.layout.activity_recharge,container,false);
|
||||
rlWebview = (WebView) view.findViewById(R.id.rlWebview);
|
||||
Log.e("ttt",url);
|
||||
rlWebview.loadUrl(url);
|
||||
initGooglePay();
|
||||
|
||||
WebSettings webSettings = rlWebview.getSettings();
|
||||
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setTextZoom(100);
|
||||
webSettings.setUseWideViewPort(true);
|
||||
|
||||
webSettings.setJavaScriptEnabled(true); // 是否开启JS支持
|
||||
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
//
|
||||
// webSettings.setUseWideViewPort(true); // 缩放至屏幕大小
|
||||
// webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕大小
|
||||
// webSettings.setSupportZoom(true); // 是否支持缩放
|
||||
// webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放
|
||||
// webSettings.setDisplayZoomControls(false); // 是否隐藏缩放控件
|
||||
//
|
||||
// webSettings.setAllowFileAccess(true); // 是否允许访问文件
|
||||
// webSettings.setDomStorageEnabled(false); // 是否节点缓存
|
||||
// webSettings.setDatabaseEnabled(false); // 是否数据缓存
|
||||
// webSettings.setAppCacheEnabled(false); // 是否应用缓存
|
||||
//
|
||||
// webSettings.setMediaPlaybackRequiresUserGesture(false); // 是否要手势触发媒体
|
||||
// webSettings.setStandardFontFamily("sans-serif"); // 设置字体库格式
|
||||
// webSettings.setFixedFontFamily("monospace"); // 设置字体库格式
|
||||
// webSettings.setSansSerifFontFamily("sans-serif"); // 设置字体库格式
|
||||
// webSettings.setSerifFontFamily("sans-serif"); // 设置字体库格式
|
||||
// webSettings.setCursiveFontFamily("cursive"); // 设置字体库格式
|
||||
// webSettings.setFantasyFontFamily("fantasy"); // 设置字体库格式
|
||||
// webSettings.setTextZoom(100); // 设置文本缩放的百分比
|
||||
// webSettings.setMinimumFontSize(8); // 设置文本字体的最小值(1~72)
|
||||
// webSettings.setDefaultFontSize(16); // 设置文本字体默认的大小
|
||||
//
|
||||
// webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); // 按规则重新布局
|
||||
// webSettings.setLoadsImagesAutomatically(true); // 是否自动加载图片
|
||||
// webSettings.setDefaultTextEncodingName("UTF-8"); // 设置编码格式
|
||||
// webSettings.setNeedInitialFocus(true); // 是否需要获取焦点
|
||||
// webSettings.setGeolocationEnabled(false); // 设置开启定位功能
|
||||
// webSettings.setBlockNetworkLoads(false); // 是否从网络获取资源
|
||||
// rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
|
||||
// rlWebview.setWebContentsDebuggingEnabled(true);
|
||||
|
||||
|
||||
rlWebview.addJavascriptInterface(new JsInteration(),"androidObject");
|
||||
|
||||
TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(),rlWebview);
|
||||
|
||||
rlWebview.setWebViewClient(testWebViewClient);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
|
||||
String TAG = "GooglePay";
|
||||
//我们自己的订单号
|
||||
ProgressDialog progressDialog;
|
||||
|
||||
private void initGooglePay() {
|
||||
GoogleBillingUtil.isDebug(true);
|
||||
GoogleBillingUtil.setIsAutoAcknowledgePurchase(true);//设置自动确认购买
|
||||
googleBillingUtil = GoogleBillingUtil.getInstance()
|
||||
.addOnGoogleBillingListener(getActivity(), mOnMyGoogleBillingListener)
|
||||
.build(getActivity());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private OnGoogleBillingListener mOnMyGoogleBillingListener=new OnGoogleBillingListener(){
|
||||
@Override
|
||||
public void onSetupSuccess(boolean isSelf) {
|
||||
super.onSetupSuccess(isSelf);
|
||||
Log.d(TAG,"内购服务初始化完成");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuerySuccess(@NonNull String skuType, @NonNull List<SkuDetails> list, boolean isSelf) {
|
||||
|
||||
googleBillingUtil.purchaseInApp(getActivity(),mProductId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPurchaseSuccess(@NonNull Purchase purchase, boolean isSelf) {
|
||||
StringBuffer tempBuffer =new StringBuffer();
|
||||
|
||||
if(progressDialog!=null&&progressDialog.isShowing()){
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
if(purchase.getPurchaseState()==Purchase.PurchaseState.PURCHASED){
|
||||
tempBuffer.append("购买成功:");
|
||||
Log.e(TAG,purchase.getOrderId()+"ProductId"+mProductId+"OrderNumber"+mOrderid);
|
||||
|
||||
//通知自己服务器
|
||||
// if (mOrderid == null || purchase.getOrderId() == null){
|
||||
// return false;
|
||||
// }
|
||||
// googleBillingUtil.consumeAsync(GooglePayActivity.this,purchase.getPurchaseToken());
|
||||
CommonHttpUtil.notifyGoogle(purchase.getPurchaseToken(),purchase.getOrderId(),mProductId,mOrderid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if(code==0){
|
||||
try {
|
||||
// String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=1";
|
||||
// rlWebview.loadUrl(r_url);
|
||||
Bundle params = new Bundle();
|
||||
params.putString("currency", "USD");
|
||||
params.putString("money", MoneyUsds);
|
||||
logger.logEvent("FB_iap_Play", params);
|
||||
|
||||
logger.logEvent("FB_iap_users", params);
|
||||
|
||||
logger.logEvent("FB_iap_events", params);
|
||||
|
||||
Bundle fb_params = new Bundle();
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "USD");
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID,mProductId);
|
||||
|
||||
//fb官方事件记录充值
|
||||
logger.logEvent(AppEventsConstants.EVENT_NAME_PURCHASED,
|
||||
Double.parseDouble(MoneyUsds),
|
||||
fb_params);
|
||||
|
||||
//Google官方充值通知
|
||||
Bundle google_params = new Bundle();
|
||||
google_params.putString("currency", "USD");
|
||||
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");
|
||||
|
||||
|
||||
mFirebaseAnalytics.logEvent("FS_iap_Play", google_params);
|
||||
mFirebaseAnalytics.logEvent("FS_iap_users", null);
|
||||
mFirebaseAnalytics.logEvent("FS_iap_events", google_params);
|
||||
|
||||
//AD官方通知充值
|
||||
AdjustEvent adjustEvent = new AdjustEvent("z8v726");
|
||||
adjustEvent.setRevenue(Double.parseDouble(MoneyUsds),"USD");
|
||||
adjustEvent.setOrderId(mOrderid);
|
||||
Adjust.trackEvent(adjustEvent);
|
||||
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("cgssol");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
AdjustEvent adjustEvent2 = new AdjustEvent("tr8lb9");
|
||||
adjustEvent2.setRevenue(Double.parseDouble(MoneyUsds),"USD");
|
||||
adjustEvent2.setOrderId(mOrderid);
|
||||
Adjust.trackEvent(adjustEvent2);
|
||||
|
||||
|
||||
|
||||
ToastUtil.show("购买成功");
|
||||
getActivity().onBackPressed();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
// String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=0";
|
||||
// rlWebview.loadUrl(r_url);
|
||||
ToastUtil.show("购买失败,请联系客服");
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
|
||||
progressDialog.setTitle("正在處理");
|
||||
progressDialog.setMessage("系統檢測到您的卡是慢速卡,正在處理您的訂單,大概需要一分鐘,請勿離開,若因離開此頁面導致支付失敗,請聯系在線客服");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
tempBuffer.append("暂未支付:");
|
||||
}
|
||||
String details = String.format(Locale.getDefault(),"%s \n", purchase.getSku());
|
||||
tempBuffer.append(details);
|
||||
Log.d(TAG,tempBuffer.toString());
|
||||
return true ;//自动消耗(只有当isSelf为true,并且支付状态为PURCHASED时,该值才会生效)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onRecheck(@NonNull String skuType, @NonNull Purchase purchase, boolean isSelf) {
|
||||
StringBuffer tempBuffer =new StringBuffer();
|
||||
tempBuffer.append("检测到未处理的订单($skuType):${purchase.sku}()");
|
||||
Log.d(TAG,tempBuffer.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBillingServiceDisconnected() {
|
||||
super.onBillingServiceDisconnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConsumeSuccess(@NonNull String purchaseToken, boolean isSelf) {
|
||||
Log.d(TAG,"消耗商品成功:$purchaseToken");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAcknowledgePurchaseSuccess(boolean isSelf) {
|
||||
Log.d(TAG,"确认购买商品成功");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(@NonNull GoogleBillingUtil.GoogleBillingListenerTag tag, int responseCode, boolean isSelf) {
|
||||
Log.d(TAG,"操作失败:tag=${" + tag.name() + "responseCode=" + responseCode);
|
||||
// String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=0";
|
||||
// rlWebview.loadUrl(r_url);
|
||||
// ToastUtil.show("购买失败,请联系客服");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull GoogleBillingUtil.GoogleBillingListenerTag tag, boolean isSelf) {
|
||||
Log.d(TAG,"发生错误:tag="+tag.name());
|
||||
// String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=0";
|
||||
// rlWebview.loadUrl(r_url);
|
||||
// ToastUtil.show("购买失败,请联系客服");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
private GoogleBillingUtil googleBillingUtil;
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidNewGoToGooglePay(String ProductId, String OrderNumber,String MoneyUsd) {
|
||||
Log.e(TAG,"ProductId"+ProductId+"OrderNumber"+OrderNumber+"MoneyUsd"+MoneyUsd);
|
||||
mProductId = ProductId;
|
||||
mOrderid = OrderNumber;
|
||||
MoneyUsds = MoneyUsd;
|
||||
googleBillingUtil.purchaseInApp(getActivity(),mProductId);
|
||||
//下单
|
||||
Bundle params = new Bundle();
|
||||
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId);
|
||||
params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "USD");
|
||||
logger.logEvent(AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT,Double.parseDouble(MoneyUsds),
|
||||
params);
|
||||
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void androidMethodBack() {
|
||||
getActivity().onBackPressed();
|
||||
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void androidGoBack() {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void release() {
|
||||
|
||||
if (googleBillingUtil != null){
|
||||
googleBillingUtil.onDestroy(getActivity());
|
||||
//退出程序的时候可以调用(实验性)
|
||||
GoogleBillingUtil.endConnection();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.android.billingclient.api.Purchase;
|
||||
import com.android.billingclient.api.SkuDetails;
|
||||
import com.tjbaobao.gitee.billing.GoogleBillingUtil;
|
||||
import com.tjbaobao.gitee.billing.OnGoogleBillingListener;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
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.utils.HXLinePagerIndicator;
|
||||
import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
import net.lucode.hackware.magicindicator.MagicIndicator;
|
||||
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 java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static android.util.Log.i;
|
||||
|
||||
@Route(path = RouteUtil.PATH_GOOGLE)
|
||||
public class GooglePayActivity extends AbsActivity {
|
||||
|
||||
String TAG = "GooglePay";
|
||||
//我们自己的订单号
|
||||
private String mOrderid,mProductId;
|
||||
ProgressDialog progressDialog;
|
||||
|
||||
private WebView rlWebview;
|
||||
// private String [] arrPro = {"1"};
|
||||
private void initGooglePay() {
|
||||
// arrPro[0]="2";
|
||||
|
||||
GoogleBillingUtil.isDebug(true);
|
||||
// GoogleBillingUtil.setSkus(arrPro,null);
|
||||
GoogleBillingUtil.setIsAutoAcknowledgePurchase(true);//设置自动确认购买
|
||||
googleBillingUtil = GoogleBillingUtil.getInstance()
|
||||
.addOnGoogleBillingListener(GooglePayActivity.this, mOnMyGoogleBillingListener)
|
||||
.build(GooglePayActivity.this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private OnGoogleBillingListener mOnMyGoogleBillingListener=new OnGoogleBillingListener(){
|
||||
@Override
|
||||
public void onSetupSuccess(boolean isSelf) {
|
||||
super.onSetupSuccess(isSelf);
|
||||
Log.d(TAG,"内购服务初始化完成");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuerySuccess(@NonNull String skuType, @NonNull List<SkuDetails> list, boolean isSelf) {
|
||||
|
||||
googleBillingUtil.purchaseInApp(GooglePayActivity.this,mProductId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPurchaseSuccess(@NonNull Purchase purchase, boolean isSelf) {
|
||||
StringBuffer tempBuffer =new StringBuffer();
|
||||
|
||||
if(progressDialog.isShowing()){
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
if(purchase.getPurchaseState()==Purchase.PurchaseState.PURCHASED){
|
||||
tempBuffer.append("购买成功:");
|
||||
//通知自己服务器
|
||||
if (mOrderid == null || purchase.getOrderId() == null){
|
||||
return false;
|
||||
}
|
||||
// googleBillingUtil.consumeAsync(GooglePayActivity.this,purchase.getPurchaseToken());
|
||||
CommonHttpUtil.notifyGoogle(purchase.getPurchaseToken(),purchase.getOrderId(),mProductId,mOrderid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if(code==0){
|
||||
try {
|
||||
String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=1";
|
||||
rlWebview.loadUrl(r_url);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=0";
|
||||
rlWebview.loadUrl(r_url);
|
||||
ToastUtil.show("购买失败,请联系客服");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
|
||||
progressDialog.setTitle("正在處理");
|
||||
progressDialog.setMessage("系統檢測到您的卡是慢速卡,正在處理您的訂單,大概需要一分鐘,請勿離開,若因離開此頁面導致支付失敗,請聯系在線客服");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
tempBuffer.append("暂未支付:");
|
||||
}
|
||||
String details = String.format(Locale.getDefault(),"%s \n", purchase.getSku());
|
||||
tempBuffer.append(details);
|
||||
Log.d(TAG,tempBuffer.toString());
|
||||
return true ;//自动消耗(只有当isSelf为true,并且支付状态为PURCHASED时,该值才会生效)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onRecheck(@NonNull String skuType, @NonNull Purchase purchase, boolean isSelf) {
|
||||
StringBuffer tempBuffer =new StringBuffer();
|
||||
tempBuffer.append("检测到未处理的订单($skuType):${purchase.sku}()");
|
||||
Log.d(TAG,tempBuffer.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBillingServiceDisconnected() {
|
||||
super.onBillingServiceDisconnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConsumeSuccess(@NonNull String purchaseToken, boolean isSelf) {
|
||||
Log.d(TAG,"消耗商品成功:$purchaseToken");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAcknowledgePurchaseSuccess(boolean isSelf) {
|
||||
Log.d(TAG,"确认购买商品成功");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(@NonNull GoogleBillingUtil.GoogleBillingListenerTag tag, int responseCode, boolean isSelf) {
|
||||
Log.d(TAG,"操作失败:tag=${" + tag.name() + "responseCode=" + responseCode);
|
||||
String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=0";
|
||||
rlWebview.loadUrl(r_url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull GoogleBillingUtil.GoogleBillingListenerTag tag, boolean isSelf) {
|
||||
Log.d(TAG,"发生错误:tag="+tag.name());
|
||||
String r_url = CommonAppConfig.HOST +"?g=Appapi&m=Mall&a=paysuss&status=0";
|
||||
rlWebview.loadUrl(r_url);
|
||||
}
|
||||
|
||||
};
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
initGooglePay();
|
||||
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(new JsInteration(), "androidObject");
|
||||
|
||||
TestWebViewClient testWebViewClient = new TestWebViewClient(this, rlWebview);
|
||||
|
||||
rlWebview.setWebViewClient(testWebViewClient);
|
||||
|
||||
}
|
||||
|
||||
private GoogleBillingUtil googleBillingUtil;
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
@JavascriptInterface
|
||||
public void androidGoToGooglePay(String ProductId, String OrderNumber) {
|
||||
Log.e(TAG,"ProductId"+ProductId+"OrderNumber"+OrderNumber);
|
||||
mProductId = ProductId;
|
||||
mOrderid = OrderNumber;
|
||||
googleBillingUtil.purchaseInApp(GooglePayActivity.this,mProductId);
|
||||
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void androidMethodBack() {
|
||||
GooglePayActivity.this.finish();
|
||||
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void androidGoBack() {
|
||||
GooglePayActivity.this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_google_pay;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
rlWebview = (WebView) findViewById(R.id.rlWebview);
|
||||
final String[] titles = {WordUtil.getString(R.string.diamond), WordUtil.getString(R.string.coins),WordUtil.getString(R.string.golden_beans)};
|
||||
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(GooglePayActivity.this,R.style.TabLayoutTextStyle);
|
||||
colorTransitionPagerTitleView.setText(titles[index]);
|
||||
colorTransitionPagerTitleView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
});
|
||||
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);
|
||||
progressDialog=new ProgressDialog(GooglePayActivity.this);
|
||||
magicIndicator.onPageSelected(0);
|
||||
}
|
||||
|
||||
public void release() {
|
||||
|
||||
if (googleBillingUtil != null){
|
||||
googleBillingUtil.onDestroy(GooglePayActivity.this);
|
||||
//退出程序的时候可以调用(实验性)
|
||||
GoogleBillingUtil.endConnection();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
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.live.bean.LiveBean;
|
||||
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 com.yunbao.main.presenter.CheckLivePresenter;
|
||||
|
||||
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;
|
||||
private CheckLivePresenter mCheckLivePresenter;
|
||||
|
||||
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) {
|
||||
if (mCheckLivePresenter == null) {
|
||||
mCheckLivePresenter = new CheckLivePresenter(mContext);
|
||||
}
|
||||
if (CommonAppConfig.LIVE_ROOM_SCROLL) {
|
||||
mCheckLivePresenter.watchLive(liveBean, Constants.LIVE_CLASS_PREFIX + mClassId, position);
|
||||
} else {
|
||||
mCheckLivePresenter.watchLive(liveBean);
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
}
|
||||
339
main/src/main/java/com/yunbao/main/activity/LoginActivity.java
Normal file
@@ -0,0 +1,339 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustEvent;
|
||||
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.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.LoginData;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
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 static com.yunbao.common.CommonAppContext.logger;
|
||||
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
|
||||
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/17.
|
||||
*/
|
||||
|
||||
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 static 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;
|
||||
static Activity activity;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_login;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
mRoot = findViewById(R.id.root);
|
||||
Contexts = this;
|
||||
activity = this;
|
||||
//进入登录页面
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("2gar15");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
mFirebaseAnalytics.logEvent("FS_loginpage", null);
|
||||
logger.logEvent("FB_loginpage");
|
||||
|
||||
OpenInstall.getInstall(new AppInstallAdapter() {
|
||||
@Override
|
||||
public void onInstall(AppData appData) {
|
||||
//获取渠道数据
|
||||
String channelCode = appData.getChannel();
|
||||
//获取自定义数据
|
||||
String bindData = appData.getData();
|
||||
Toast.makeText(LoginActivity.this, "" + appData.toString(), Toast.LENGTH_LONG);
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
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 (configBean != null) {
|
||||
// List<MobBean> list = MobBean.getLoginTypeList(configBean.getLoginType());
|
||||
// if (list != null && list.size() > 0) {
|
||||
// mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
|
||||
// mRecyclerView.setHasFixedSize(true);
|
||||
// mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
|
||||
// LoginTypeAdapter adapter = new LoginTypeAdapter(mContext, list);
|
||||
// adapter.setOnItemClickListener(this);
|
||||
// mRecyclerView.setAdapter(adapter);
|
||||
// mLoginUtil = new MobLoginUtil();
|
||||
// otherLoginType = true;
|
||||
// }
|
||||
// }
|
||||
if (!otherLoginType) {
|
||||
findViewById(R.id.other_login_tip).setVisibility(View.INVISIBLE);
|
||||
}
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
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) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_login) {
|
||||
login();
|
||||
|
||||
} else if (i == R.id.btn_register) {
|
||||
//去手机注册
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("orgi58");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
AdjustEvent adjustEvent2 = new AdjustEvent("tyqsyf");
|
||||
Adjust.trackEvent(adjustEvent2);
|
||||
|
||||
mFirebaseAnalytics.logEvent("FS_phone_click", null);
|
||||
logger.logEvent("FB_phone_click");
|
||||
|
||||
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 void login() {
|
||||
phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(WordUtil.getString(R.string.login_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum)) {
|
||||
// mEditPhone.setError(WordUtil.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
|
||||
pwd = mEditPwd.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd)) {
|
||||
mEditPwd.setError(WordUtil.getString(R.string.login_input_pwd));
|
||||
mEditPwd.requestFocus();
|
||||
return;
|
||||
}
|
||||
mLoginType = Constants.MOB_PHONE;
|
||||
String uuid = DeviceUtils.getUniqueDeviceId();
|
||||
|
||||
MainHttpUtil.login(phoneNum, pwd, uuid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
onLoginSuccess(code, msg, info);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//登录即代表同意服务和隐私条款
|
||||
private void forwardTip() {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.LOGIN_PRIVCAY);
|
||||
}
|
||||
|
||||
//登录成功!
|
||||
private static 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);
|
||||
getBaseUserInfo();
|
||||
mFirebaseAnalytics.logEvent("FS_createdRole", null);
|
||||
logger.logEvent("FB_createdRole");
|
||||
|
||||
//友盟统计登录
|
||||
// MobclickAgent.onProfileSignIn(mLoginType, uid);
|
||||
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
private static void getBaseUserInfo() {
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
// if (mFirstLogin) {
|
||||
// RecommendActivity.forward(Contexts, mShowInvite);
|
||||
// } else {
|
||||
|
||||
//完成手机号密码登录
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("4ncwlv");
|
||||
mFirebaseAnalytics.logEvent("FS_login", null);
|
||||
logger.logEvent("FB_login");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
MainActivity.forward(Contexts, mShowInvite);
|
||||
// }
|
||||
EntryActivity.activity.finish();
|
||||
activity.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();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRegSuccessEvent(RegSuccessEvent e) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@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);
|
||||
// if (mLoginUtil != null) {
|
||||
// mLoginUtil.release();
|
||||
// }
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
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.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();
|
||||
//退出极光
|
||||
// ImMessageUtil.getInstance().logoutImClient();
|
||||
// ImPushUtil.getInstance().logout();
|
||||
//友盟统计登出
|
||||
// MobclickAgent.onProfileSignOff();
|
||||
LoginActivity.forward();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
//super.onBackPressed();
|
||||
}
|
||||
}
|
||||
1282
main/src/main/java/com/yunbao/main/activity/MainActivity.java
Normal file
@@ -0,0 +1,206 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.ViewPagerAdapter;
|
||||
import com.yunbao.common.event.FollowEvent;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.AbsMainListChildViewHolder;
|
||||
import com.yunbao.main.views.MainListContributeViewHolder;
|
||||
import com.yunbao.main.views.MainListProfitViewHolder;
|
||||
|
||||
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.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MainListActivity extends AbsActivity {
|
||||
private static final int PAGE_COUNT = 2;
|
||||
private List<FrameLayout> mViewList;
|
||||
private AbsMainListChildViewHolder[] mViewHolders;
|
||||
private MainListProfitViewHolder mProfitViewHolder;//收益榜
|
||||
private MainListContributeViewHolder mContributeViewHolder;//贡献榜
|
||||
private MagicIndicator mIndicator;
|
||||
private ViewPager mViewPager;
|
||||
|
||||
public static void forward(Context context,int p) {
|
||||
context.startActivity(new Intent(context, MainListActivity.class).putExtra("p",p));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if(mProfitViewHolder!=null && mProfitViewHolder.mAdapter!=null) {
|
||||
mProfitViewHolder.mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
if(mContributeViewHolder!=null && mContributeViewHolder.mAdapter!=null) {
|
||||
mContributeViewHolder.mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@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];
|
||||
mViewPager = (ViewPager) findViewById(R.id.viewPager);
|
||||
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) {
|
||||
loadPageData(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
});
|
||||
mIndicator = (MagicIndicator) findViewById(R.id.indicator);
|
||||
final String[] titles = new String[]{
|
||||
(WordUtil.getString(R.string.glamour_list)),
|
||||
(WordUtil.getString(R.string.magnificent_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) {
|
||||
|
||||
ClipPagerTitleView clipPagerTitleView = new ClipPagerTitleView(context);
|
||||
clipPagerTitleView.setText(titles[index]);
|
||||
clipPagerTitleView.setTextColor(Color.parseColor("#B6B6B6"));
|
||||
clipPagerTitleView.setClipColor(Color.parseColor("#F8F8F8"));
|
||||
clipPagerTitleView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mViewPager.setCurrentItem(index);
|
||||
}
|
||||
});
|
||||
|
||||
return clipPagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
float navigatorHeight = context.getResources().getDimension(R.dimen.common_navigator_height);
|
||||
float borderWidth = UIUtil.dip2px(context, 1);
|
||||
float lineHeight = navigatorHeight - 2 * borderWidth;
|
||||
indicator.setLineHeight(lineHeight);
|
||||
indicator.setRoundRadius(lineHeight / 2);
|
||||
indicator.setYOffset(borderWidth);
|
||||
//选中的背景颜色
|
||||
indicator.setColors(Color.parseColor("#FFBE41"));
|
||||
return indicator;
|
||||
}
|
||||
});
|
||||
mIndicator.setNavigator(commonNavigator);
|
||||
ViewPagerHelper.bind(mIndicator, mViewPager);
|
||||
//默认选择第几个
|
||||
mIndicator.onPageSelected(getIntent().getIntExtra("p",0));
|
||||
mViewPager.setCurrentItem(getIntent().getIntExtra("p",0));
|
||||
//加载数据
|
||||
loadData();
|
||||
EventBus.getDefault().register(MainListActivity.this);
|
||||
}
|
||||
|
||||
private void loadPageData(int position) {
|
||||
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) {
|
||||
mProfitViewHolder = new MainListProfitViewHolder(mContext, parent);
|
||||
vh = mProfitViewHolder;
|
||||
} else if (position == 1) {
|
||||
mContributeViewHolder = new MainListContributeViewHolder(mContext, parent);
|
||||
vh = mContributeViewHolder;
|
||||
}
|
||||
if (vh == null) {
|
||||
return;
|
||||
}
|
||||
mViewHolders[position] = vh;
|
||||
vh.addToParent();
|
||||
vh.subscribeActivityLifeCycle();
|
||||
}
|
||||
}
|
||||
if (vh != null) {
|
||||
vh.loadData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
public void loadData() {
|
||||
if (mViewPager != null) {
|
||||
loadPageData(mViewPager.getCurrentItem());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(MainListActivity.this);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onFollowEvent(FollowEvent e) {
|
||||
if (mViewHolders != null) {
|
||||
for (AbsMainListChildViewHolder vh : mViewHolders) {
|
||||
if (vh != null) {
|
||||
vh.onFollowEvent(e.getToUid(), e.getIsAttention());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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(WordUtil.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(WordUtil.getString(R.string.modify_pwd_old_1));
|
||||
return;
|
||||
}
|
||||
String pwdNew = mEditNew.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwdNew)) {
|
||||
mEditNew.setError(WordUtil.getString(R.string.modify_pwd_new_1));
|
||||
return;
|
||||
}
|
||||
String pwdConfirm = mEditConfirm.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwdConfirm)) {
|
||||
mEditConfirm.setError(WordUtil.getString(R.string.modify_pwd_confirm_1));
|
||||
return;
|
||||
}
|
||||
if (!pwdNew.equals(pwdConfirm)) {
|
||||
mEditConfirm.setError(WordUtil.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();
|
||||
}
|
||||
}
|
||||
326
main/src/main/java/com/yunbao/main/activity/MyCoinActivity.java
Normal file
@@ -0,0 +1,326 @@
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* 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(WordUtil.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(WordUtil.getString(R.string.wallet_coin_name), mCoinName));
|
||||
//我的金币
|
||||
TextView goldCoinNameTV = findViewById(R.id.tvMyGoldName);
|
||||
goldCoinNameTV.setText(String.format(WordUtil.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){
|
||||
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);
|
||||
}else if (i == R.id.btn_charge_explain) {
|
||||
//充值说明
|
||||
WebViewActivity.forward(mContext, HtmlConfig.CHARGE_EXPLAIN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@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(WordUtil.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(WordUtil.getString(R.string.impress_tip_3));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_MY_IMPRESS);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* 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(WordUtil.getString(R.string.profit_tip_1), mVotesName));
|
||||
mCanName.setText(String.format(WordUtil.getString(R.string.profit_tip_2), mVotesName));
|
||||
mGetName.setText(String.format(WordUtil.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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提现
|
||||
*/
|
||||
private void cash() {
|
||||
String votes = mEdit.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(votes)) {
|
||||
ToastUtil.show(String.format(WordUtil.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(WordUtil.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,150 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
||||
|
||||
import com.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustEvent;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
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 static com.yunbao.common.CommonAppContext.logger;
|
||||
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
|
||||
|
||||
@Route(path = RouteUtil.PATH_COIN)
|
||||
public class MyWalletActivity extends AbsActivity {
|
||||
|
||||
ViewPager vp_content;
|
||||
static MyWalletActivity mw;
|
||||
Fragment[] fragments = null;
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_my_wallet;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
super.main();
|
||||
mw = MyWalletActivity.this;
|
||||
setTitle(WordUtil.getString(R.string.wallet));
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("eap1ec");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
mFirebaseAnalytics.logEvent("FS_initiated_checkout", null);
|
||||
logger.logEvent("FB_initiated_checkout");
|
||||
|
||||
vp_content = (ViewPager)findViewById(R.id.vp_content);
|
||||
final String[] titles = {WordUtil.getString(R.string.diamond), WordUtil.getString(R.string.coins),WordUtil.getString(R.string.golden_beans)};
|
||||
if(getIntent().getStringExtra("tag")!=null) {
|
||||
Log.i("tss","首充");
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == false) {
|
||||
//链接版本
|
||||
fragments = new Fragment[]{new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())};
|
||||
// fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())};
|
||||
}else{
|
||||
fragments = new Fragment[]{new GoogleFragment( CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()),
|
||||
new GoogleFragment(CommonAppConfig.HOST +"/index.php?g=Appapi&m=Mall&a=googlepaygole&uid="+CommonAppConfig.getInstance().getUid()+"&token="+CommonAppConfig.getInstance().getToken()),
|
||||
new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())};
|
||||
}
|
||||
}else{
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == false) {
|
||||
Log.i("tss", "不是首充");
|
||||
//链接版本
|
||||
fragments = new Fragment[]{new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())};
|
||||
}else{
|
||||
fragments = new Fragment[]{new GoogleFragment( CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()),
|
||||
new GoogleFragment(CommonAppConfig.HOST +"/index.php?g=Appapi&m=Mall&a=googlepaygole&uid="+CommonAppConfig.getInstance().getUid()+"&token="+CommonAppConfig.getInstance().getToken()),
|
||||
new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())};
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
});
|
||||
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));
|
||||
}
|
||||
|
||||
public static void dis(){
|
||||
mw.finish();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,709 @@
|
||||
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 androidx.annotation.RequiresApi;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.JavascriptInterface;
|
||||
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 com.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustEvent;
|
||||
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.UserBean;
|
||||
import com.yunbao.common.bean.VideoListBean;
|
||||
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.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.activity.LiveReportActivity;
|
||||
import com.yunbao.live.activity.SystemMessageActivity;
|
||||
import com.yunbao.live.bean.LiveBean;
|
||||
import com.yunbao.live.bean.ReportCommunityBean;
|
||||
import com.yunbao.live.event.LiveRoomChangeEvent;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.live.views.LiveRoomViewHolder;
|
||||
import com.yunbao.main.dialog.EncourageDialog;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.video.activity.VideoPlayActivity;
|
||||
import com.yunbao.video.bean.VideoBean;
|
||||
import com.yunbao.video.utils.VideoStorge;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.logger;
|
||||
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_webview_my;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
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-------->" + 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(new JsInteration(), "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(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();
|
||||
}
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
@JavascriptInterface
|
||||
public void androidCommunityGift(String postsId) {
|
||||
Constants.nowPostsId = postsId;
|
||||
EncourageDialog fragment = new EncourageDialog();
|
||||
fragment.show(((MyWebViewActivity) mContext).getSupportFragmentManager(), "EncourageDialog");
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void reportCommunity(String info) {
|
||||
ReportCommunityBean reportCommunityBean = JSON.parseObject(info, ReportCommunityBean.class);
|
||||
LiveReportActivity.forward3(mContext, reportCommunityBean.getDynamic_id(), 1, reportCommunityBean.getCommunity_type(), reportCommunityBean.getComment_id());
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void onBack() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void modifyMydata() {
|
||||
indexInto = 1;
|
||||
RouteUtil.forwardEditProfileActivity();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void reportUser(String touid) {
|
||||
RouteUtil.forwardLiveReportActivity(touid);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidMethodLookToLive(String liveId) {
|
||||
//看直播
|
||||
gotoLive(liveId);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void AndroidFellow() {
|
||||
mFirebaseAnalytics.logEvent("FS_Follow", null);
|
||||
logger.logEvent("FB_Follow", null);
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("oess6a");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidClickSayHiBack(String uid, String name, String img) {
|
||||
Constants.firstInto = 0;
|
||||
SystemMessageActivity.forward(mContext, "-2", uid, name, img);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidClickFansList(String uid) {
|
||||
FansActivity.forward(mContext, uid);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidPlayVideo(String list) {
|
||||
list.toString();
|
||||
if (!"undefined".equals(list)) {
|
||||
JSONObject obj = JSON.parseObject(list);
|
||||
int position = obj.getIntValue("video_index");
|
||||
String videoListString = obj.getString("video_list");
|
||||
List<VideoListBean> videoList = JSON.parseArray(videoListString, VideoListBean.class);
|
||||
List<VideoBean> videoBeanList = new ArrayList<>();
|
||||
for (VideoListBean videoListBean : videoList) {
|
||||
JSONObject obj2 = JSON.parseObject(videoListBean.getContent());
|
||||
String msg = obj2.getString("msg");
|
||||
VideoBean videoBean = new VideoBean();
|
||||
videoBean.setHref(videoListBean.getVideo());
|
||||
videoBean.setCity("");
|
||||
videoBean.setCommentNum(videoListBean.getComment_num());
|
||||
videoBean.setAddtime(videoListBean.getCreate_time());
|
||||
videoBean.setDatetime("");
|
||||
videoBean.setDistance("");
|
||||
videoBean.setId(videoListBean.getId());
|
||||
videoBean.setLat("");
|
||||
videoBean.setLike(0);
|
||||
videoBean.setTitle(msg);
|
||||
if ("2".endsWith(videoListBean.getIs_attention()) || "0".endsWith(videoListBean.getIs_attention())) {
|
||||
videoBean.setAttent(2);
|
||||
} else if ("1".endsWith(videoListBean.getIs_attention())) {
|
||||
videoBean.setAttent(1);
|
||||
} else {
|
||||
videoBean.setAttent(-1);
|
||||
}
|
||||
UserBean userBean = new UserBean();
|
||||
userBean.setAvatar(videoListBean.getUser_avatar());
|
||||
userBean.setUserNiceName(videoListBean.getUser_name());
|
||||
userBean.setId(videoListBean.getUser_id());
|
||||
videoBean.setUserBean(userBean);
|
||||
|
||||
videoBean.setUid(videoListBean.getUser_id());
|
||||
videoBeanList.add(videoBean);
|
||||
}
|
||||
VideoStorge.getInstance().put(Constants.VIDEO_COMMUNITY, videoBeanList);
|
||||
VideoPlayActivity.forward(mContext, position, Constants.VIDEO_COMMUNITY, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void gotoHomePage(String indexStr) {
|
||||
if (!"".equals(indexStr) && indexStr != null) {
|
||||
int index = -1;
|
||||
if ("0".equals(indexStr)) {
|
||||
index = 0;
|
||||
} else if ("1".equals(indexStr)) {
|
||||
index = 1;
|
||||
} else if ("2".equals(indexStr)) {
|
||||
index = 2;
|
||||
} else if ("3".equals(indexStr)) {
|
||||
index = 3;
|
||||
}
|
||||
if (index != -1) {
|
||||
finish();
|
||||
Constants.isShowPage = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//打开无头部
|
||||
@JavascriptInterface
|
||||
public void openWebView(String url) {
|
||||
Constants.isTitle = false;
|
||||
RouteUtil.forwardZhuangBanActivity(url);
|
||||
}
|
||||
|
||||
//打开有头部
|
||||
@JavascriptInterface
|
||||
public void openWebViewTitle(String url) {
|
||||
Constants.isTitle = true;
|
||||
RouteUtil.forwardZhuangBanActivity(url);
|
||||
}
|
||||
|
||||
//跳转修改昵称
|
||||
@JavascriptInterface
|
||||
public void openUpdataName() {
|
||||
isUpdataUser = true;
|
||||
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());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
//跳转修改头像
|
||||
@JavascriptInterface
|
||||
public void 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();
|
||||
}
|
||||
}
|
||||
});
|
||||
// RouteUtil.forwardEditProfileActivity();
|
||||
}
|
||||
|
||||
//跳转修改签名
|
||||
@JavascriptInterface
|
||||
public void openUpdataAutograph() {
|
||||
isUpdataUser = true;
|
||||
forwardSign();
|
||||
}
|
||||
}
|
||||
|
||||
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 (mCheckLivePresenter == null) {
|
||||
mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) {
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
if (LiveRoomViewHolder.mHandler != null) {
|
||||
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
if (!"".endsWith(Constants.mStream)) {
|
||||
finish();
|
||||
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, liveTypeVal));
|
||||
} else {
|
||||
LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
mCheckLivePresenter.checkLive(liveBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
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, WordUtil.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();
|
||||
}
|
||||
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() {
|
||||
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;
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,527 @@
|
||||
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 androidx.annotation.RequiresApi;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.JavascriptInterface;
|
||||
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 com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.UserBean;
|
||||
import com.yunbao.common.bean.VideoListBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
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.LiveAudienceActivity;
|
||||
import com.yunbao.live.activity.LiveReportActivity;
|
||||
import com.yunbao.live.activity.SystemMessageActivity;
|
||||
import com.yunbao.live.bean.LiveBean;
|
||||
import com.yunbao.live.bean.ReportCommunityBean;
|
||||
import com.yunbao.live.event.LiveRoomChangeEvent;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.live.views.LiveRoomViewHolder;
|
||||
import com.yunbao.main.dialog.EncourageDialog;
|
||||
import com.yunbao.video.activity.VideoPlayActivity;
|
||||
import com.yunbao.video.bean.VideoBean;
|
||||
import com.yunbao.video.utils.VideoStorge;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Chen Haoxuan on 2022/4/19.
|
||||
*/
|
||||
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() {
|
||||
String url = getIntent().getStringExtra(Constants.URL);
|
||||
// if (!"".endsWith(Constants.myUrl)) {
|
||||
// url = 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-------->" + 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(new JsInteration(), "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();
|
||||
}
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
@JavascriptInterface
|
||||
public void androidCommunityGift(String postsId) {
|
||||
Constants.nowPostsId = postsId;
|
||||
EncourageDialog fragment = new EncourageDialog();
|
||||
fragment.show(((MyWebViewActivity2) mContext).getSupportFragmentManager(), "EncourageDialog");
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void reportCommunity(String info) {
|
||||
ReportCommunityBean reportCommunityBean = JSON.parseObject(info, ReportCommunityBean.class);
|
||||
LiveReportActivity.forward3(mContext, reportCommunityBean.getDynamic_id(), 1, reportCommunityBean.getCommunity_type(), reportCommunityBean.getComment_id());
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void onBack() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void modifyMydata() {
|
||||
indexInto = 1;
|
||||
RouteUtil.forwardEditProfileActivity();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void reportUser(String touid) {
|
||||
RouteUtil.forwardLiveReportActivity(touid);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidMethodLookToLive(String liveId) {
|
||||
//看直播
|
||||
gotoLive(liveId);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidClickSayHiBack(String uid, String name, String img) {
|
||||
Constants.firstInto = 0;
|
||||
SystemMessageActivity.forward(mContext, "-2", uid, name, img);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidClickFansList(String uid) {
|
||||
FansActivity.forward(mContext, uid);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidPlayVideo(String list) {
|
||||
list.toString();
|
||||
if (!"undefined".equals(list)) {
|
||||
JSONObject obj = JSON.parseObject(list);
|
||||
int position = obj.getIntValue("video_index");
|
||||
String videoListString = obj.getString("video_list");
|
||||
List<VideoListBean> videoList = JSON.parseArray(videoListString, VideoListBean.class);
|
||||
List<VideoBean> videoBeanList = new ArrayList<>();
|
||||
for (VideoListBean videoListBean : videoList) {
|
||||
JSONObject obj2 = JSON.parseObject(videoListBean.getContent());
|
||||
String msg = obj2.getString("msg");
|
||||
VideoBean videoBean = new VideoBean();
|
||||
videoBean.setHref(videoListBean.getVideo());
|
||||
videoBean.setCity("");
|
||||
videoBean.setCommentNum(videoListBean.getComment_num());
|
||||
videoBean.setAddtime(videoListBean.getCreate_time());
|
||||
videoBean.setDatetime("");
|
||||
videoBean.setDistance("");
|
||||
videoBean.setId(videoListBean.getId());
|
||||
videoBean.setLat("");
|
||||
videoBean.setLike(0);
|
||||
videoBean.setTitle(msg);
|
||||
if ("2".endsWith(videoListBean.getIs_attention()) || "0".endsWith(videoListBean.getIs_attention())) {
|
||||
videoBean.setAttent(2);
|
||||
} else if ("1".endsWith(videoListBean.getIs_attention())) {
|
||||
videoBean.setAttent(1);
|
||||
} else {
|
||||
videoBean.setAttent(-1);
|
||||
}
|
||||
UserBean userBean = new UserBean();
|
||||
userBean.setAvatar(videoListBean.getUser_avatar());
|
||||
userBean.setUserNiceName(videoListBean.getUser_name());
|
||||
userBean.setId(videoListBean.getUser_id());
|
||||
videoBean.setUserBean(userBean);
|
||||
|
||||
videoBean.setUid(videoListBean.getUser_id());
|
||||
videoBeanList.add(videoBean);
|
||||
}
|
||||
VideoStorge.getInstance().put(Constants.VIDEO_COMMUNITY, videoBeanList);
|
||||
VideoPlayActivity.forward(mContext, position, Constants.VIDEO_COMMUNITY, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void openWebView(String url) {
|
||||
ZhuangBanActivity.forward(mContext, url, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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 (mCheckLivePresenter == null) {
|
||||
mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) {
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
if (LiveRoomViewHolder.mHandler != null) {
|
||||
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
if (!"".endsWith(Constants.mStream)) {
|
||||
finish();
|
||||
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, liveTypeVal));
|
||||
} else {
|
||||
LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
mCheckLivePresenter.checkLive(liveBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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, WordUtil.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();
|
||||
}
|
||||
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() {
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
// 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()");
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
@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();
|
||||
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,96 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
import static android.util.Log.i;
|
||||
|
||||
//充值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打开新窗口
|
||||
//
|
||||
// webSettings.setUseWideViewPort(true); // 缩放至屏幕大小
|
||||
// webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕大小
|
||||
// webSettings.setSupportZoom(true); // 是否支持缩放
|
||||
// webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放
|
||||
// webSettings.setDisplayZoomControls(false); // 是否隐藏缩放控件
|
||||
//
|
||||
// webSettings.setAllowFileAccess(true); // 是否允许访问文件
|
||||
// webSettings.setDomStorageEnabled(false); // 是否节点缓存
|
||||
// webSettings.setDatabaseEnabled(false); // 是否数据缓存
|
||||
// webSettings.setAppCacheEnabled(false); // 是否应用缓存
|
||||
//
|
||||
// webSettings.setMediaPlaybackRequiresUserGesture(false); // 是否要手势触发媒体
|
||||
// webSettings.setStandardFontFamily("sans-serif"); // 设置字体库格式
|
||||
// webSettings.setFixedFontFamily("monospace"); // 设置字体库格式
|
||||
// webSettings.setSansSerifFontFamily("sans-serif"); // 设置字体库格式
|
||||
// webSettings.setSerifFontFamily("sans-serif"); // 设置字体库格式
|
||||
// webSettings.setCursiveFontFamily("cursive"); // 设置字体库格式
|
||||
// webSettings.setFantasyFontFamily("fantasy"); // 设置字体库格式
|
||||
// webSettings.setTextZoom(100); // 设置文本缩放的百分比
|
||||
// webSettings.setMinimumFontSize(8); // 设置文本字体的最小值(1~72)
|
||||
// webSettings.setDefaultFontSize(16); // 设置文本字体默认的大小
|
||||
//
|
||||
// webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); // 按规则重新布局
|
||||
// webSettings.setLoadsImagesAutomatically(true); // 是否自动加载图片
|
||||
// webSettings.setDefaultTextEncodingName("UTF-8"); // 设置编码格式
|
||||
// webSettings.setNeedInitialFocus(true); // 是否需要获取焦点
|
||||
// webSettings.setGeolocationEnabled(false); // 设置开启定位功能
|
||||
// webSettings.setBlockNetworkLoads(false); // 是否从网络获取资源
|
||||
// rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
|
||||
// rlWebview.setWebContentsDebuggingEnabled(true);
|
||||
|
||||
|
||||
rlWebview.addJavascriptInterface(new JsInteration(),"androidObject");
|
||||
|
||||
TestWebViewClient testWebViewClient = new TestWebViewClient(this,rlWebview);
|
||||
|
||||
rlWebview.setWebViewClient(testWebViewClient);
|
||||
|
||||
}
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
@JavascriptInterface
|
||||
public void androidMethodBack() {
|
||||
RechargeActivity.this.finish();
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void androidGoBack() {
|
||||
RechargeActivity.this.finish();
|
||||
}
|
||||
}
|
||||
@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,521 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
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.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustEvent;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.DeviceUtils;
|
||||
import com.facebook.appevents.AppEventsConstants;
|
||||
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.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
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;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.logger;
|
||||
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
|
||||
|
||||
/**
|
||||
* 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 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<>();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_register;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
// setTitle(WordUtil.getString(R.string.reg_register));
|
||||
//谷歌
|
||||
mFirebaseAnalytics.logEvent("FS_complete_2nd_loading", null);
|
||||
logger.logEvent("FB_complete_2nd_loading");
|
||||
AdjustEvent adjustEvent = new AdjustEvent("pooqmz");
|
||||
Adjust.trackEvent(adjustEvent);
|
||||
|
||||
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);
|
||||
getPromoCode();
|
||||
|
||||
mGetCode = WordUtil.getString(R.string.reg_get_code);
|
||||
mGetCodeAgain = WordUtil.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);
|
||||
//输入手机号
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("4mg5a9");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
mFirebaseAnalytics.logEvent("FS_phone_num", null);
|
||||
logger.logEvent("FB_phone_num");
|
||||
} 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();
|
||||
for (int i = 0; i < allCountries.size(); i++) {
|
||||
if (allCountries.get(i).locale.equals(ct)) {
|
||||
mTvCountryCode.setText("+" + allCountries.get(i).code);
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
mTvCountryCode.setText("+" + country.code);
|
||||
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);
|
||||
|
||||
// getPromoCode();
|
||||
//获取设备唯一标识符
|
||||
getUuidDevice();
|
||||
|
||||
} else if (i == R.id.btn_register) {
|
||||
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("wrajax");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
Bundle params = new Bundle();
|
||||
|
||||
mFirebaseAnalytics.logEvent("FS_phone_clickregister", null);
|
||||
logger.logEvent("FB_phone_clickregister");
|
||||
register();
|
||||
} else if (i == R.id.btn_tip2) {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY1);
|
||||
} else if (i == R.id.btn_tip3) {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY2);
|
||||
}
|
||||
}
|
||||
|
||||
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(WordUtil.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum))
|
||||
// {
|
||||
// mEditPhone.setError(WordUtil.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);
|
||||
}
|
||||
//获取验证码
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("rrcbdh");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
mFirebaseAnalytics.logEvent("FS_phone_getcode", null);
|
||||
logger.logEvent("FB_phone_getcode");
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 注册并登陆
|
||||
*/
|
||||
private void register() {
|
||||
final String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(WordUtil.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum)) {
|
||||
// mEditPhone.setError(WordUtil.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
String code = mEditCode.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(code)) {
|
||||
mEditCode.setError(WordUtil.getString(R.string.reg_input_code));
|
||||
mEditCode.requestFocus();
|
||||
return;
|
||||
}
|
||||
final String pwd = mEditPwd1.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd)) {
|
||||
mEditPwd1.setError(WordUtil.getString(R.string.reg_input_pwd_1));
|
||||
mEditPwd1.requestFocus();
|
||||
return;
|
||||
}
|
||||
String pwd2 = mEditPwd2.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd2)) {
|
||||
mEditPwd2.setError(WordUtil.getString(R.string.reg_input_pwd_2));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (!pwd.equals(pwd2)) {
|
||||
mEditPwd2.setError(WordUtil.getString(R.string.reg_pwd_error));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (mDialog != null) {
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
MainHttpUtil.register(edit_invitecode_2.getText().toString().trim(),phoneNum, mPromoCode, mUuidDevice, mCountryCode, pwd, pwd2, code, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
//注册成功
|
||||
AdjustEvent adjustEvent1 = new AdjustEvent("fhqx62");
|
||||
Adjust.trackEvent(adjustEvent1);
|
||||
Bundle params = new Bundle();
|
||||
|
||||
|
||||
mFirebaseAnalytics.logEvent("FS_reg_phone", null);
|
||||
logger.logEvent("FB_reg_phone");
|
||||
Bundle params1 = new Bundle();
|
||||
params1.putString(AppEventsConstants.EVENT_PARAM_REGISTRATION_METHOD, "Phone number");
|
||||
logger.logEvent(AppEventsConstants.EVENT_NAME_COMPLETED_REGISTRATION,
|
||||
params1);
|
||||
|
||||
|
||||
|
||||
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());
|
||||
mPromoCode = data.getString("admin_id") + "";
|
||||
if(!mPromoCode.equals("")) {
|
||||
yqm_view.setVisibility(View.GONE);
|
||||
}
|
||||
Log.d("OpenInstall", "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("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();
|
||||
}
|
||||
}
|
||||
482
main/src/main/java/com/yunbao/main/activity/RewardActivity.java
Normal file
@@ -0,0 +1,482 @@
|
||||
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 androidx.annotation.RequiresApi;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.JavascriptInterface;
|
||||
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 com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
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.utils.DpUtil;
|
||||
import com.yunbao.common.utils.GifCacheUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
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.MainHttpUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
@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() {
|
||||
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(new JsInteration(), "androidObject");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
|
||||
updataImg();
|
||||
}
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
@JavascriptInterface
|
||||
public void androidZBan(String svg) {
|
||||
String[] arr = svg.split("/");
|
||||
String id = arr[arr.length - 1];
|
||||
String url1;
|
||||
if (!svg.contains("http")) {
|
||||
url1 = CommonAppConfig.HOST + svg;
|
||||
} else {
|
||||
url1 = svg;
|
||||
}
|
||||
GifCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
|
||||
@Override
|
||||
public void callback(File bean) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidOpeningNoble(String svg) {
|
||||
try {
|
||||
new SVGAParser(mContext).parse(new URL(svg), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
svga.setImageDrawable(drawable);
|
||||
svga.setLoops(1);
|
||||
svga.startAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidGoBack() {
|
||||
// Log.e("Zhu", "svg" +svg);
|
||||
RewardActivity.this.finish();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidGoToRe() {
|
||||
//我们的
|
||||
// ARouter.getInstance().build(PATH_COIN).withInt("p",1).navigation();
|
||||
//谷歌的
|
||||
String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void gotoHomePage(String indexStr) {
|
||||
Log.e("tgasss","indexStr3"+indexStr);
|
||||
|
||||
if (!"".equals(indexStr) && indexStr != null) {
|
||||
int index = -1;
|
||||
if ("0".equals(indexStr)) {
|
||||
index = 0;
|
||||
} else if ("1".equals(indexStr)) {
|
||||
index = 1;
|
||||
} else if ("2".equals(indexStr)) {
|
||||
index = 2;
|
||||
} else if ("3".equals(indexStr)) {
|
||||
index = 3;
|
||||
}
|
||||
if (index != -1) {
|
||||
finish();
|
||||
Constants.isShowPage = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//打开无头部
|
||||
@JavascriptInterface
|
||||
public void openWebView(String url) {
|
||||
Constants.isTitle = false;
|
||||
RouteUtil.forwardZhuangBanActivity(url);
|
||||
}
|
||||
|
||||
//打开有头部
|
||||
@JavascriptInterface
|
||||
public void openWebViewTitle(String url) {
|
||||
Constants.isTitle = true;
|
||||
RouteUtil.forwardZhuangBanActivity(url);
|
||||
}
|
||||
|
||||
//跳转修改昵称
|
||||
@JavascriptInterface
|
||||
public void openUpdataName(String s) {
|
||||
isUpdataUser = true;
|
||||
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());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
//跳转修改头像
|
||||
@JavascriptInterface
|
||||
public void openUpdataAvater(String s) {
|
||||
isUpdataUser = true;
|
||||
RouteUtil.forwardEditProfileActivity();
|
||||
|
||||
}
|
||||
|
||||
//跳转修改签名
|
||||
@JavascriptInterface
|
||||
public void openUpdataAutograph(String s) {
|
||||
isUpdataUser = true;
|
||||
forwardSign();
|
||||
}
|
||||
}
|
||||
|
||||
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, WordUtil.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);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url) {
|
||||
forward(context, url, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
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();
|
||||
}
|
||||
// new Handler().postDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// mWebView.reload();
|
||||
// }
|
||||
// }, 100);
|
||||
if (isUpdataUser) {
|
||||
MainHttpUtil.getBaseInfo(new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
isUpdataUser = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
}
|
||||
394
main/src/main/java/com/yunbao/main/activity/SearchActivity.java
Normal file
@@ -0,0 +1,394 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
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.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.bean.SearchUserBean;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.CommonAdapter;
|
||||
import com.yunbao.main.adapter.MultiItemTypeAdapter;
|
||||
import com.yunbao.main.adapter.SearchAdapter;
|
||||
import com.yunbao.main.adapter.ViewHolder;
|
||||
import com.yunbao.main.dialog.BlankDialog;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
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.SimplePagerTitleView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
//import com.google.gson.jpush.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/25.
|
||||
*/
|
||||
|
||||
public class SearchActivity extends AbsActivity implements OnItemClickListener<SearchUserBean> {
|
||||
|
||||
private ViewPager vp_content;
|
||||
private MagicIndicator magicIndicator;
|
||||
private LinearLayout search_view, lt_search_list;
|
||||
private ImageView search_del;
|
||||
private EditText mEditText;
|
||||
private CommonRefreshView mRefreshView;
|
||||
private SearchAdapter mSearchAdapter;
|
||||
private InputMethodManager imm;
|
||||
private String mKey;
|
||||
private MyHandler mHandler;
|
||||
private RecyclerView list_record;
|
||||
private CommonAdapter adapter;
|
||||
private List<String> records;
|
||||
|
||||
SharedPreferences sharedPreferences;
|
||||
SharedPreferences.Editor editor;
|
||||
|
||||
private Fragment[] fragments = null;
|
||||
private final String[] titles = {WordUtil.getString(R.string.all), WordUtil.getString(R.string.live_anchor), WordUtil.getString(R.string.user)};
|
||||
|
||||
public static void forward(Context context) {
|
||||
context.startActivity(new Intent(context, SearchActivity.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_search;
|
||||
}
|
||||
|
||||
Gson gson;
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
search_view = (LinearLayout) findViewById(R.id.search_view);
|
||||
search_del = (ImageView) findViewById(R.id.search_del);
|
||||
mEditText = (EditText) findViewById(R.id.edit);
|
||||
list_record = (RecyclerView) findViewById(R.id.list_record);
|
||||
lt_search_list = (LinearLayout) findViewById(R.id.lt_search_list);
|
||||
magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator);
|
||||
vp_content = (ViewPager) findViewById(R.id.vp_content);
|
||||
|
||||
searchIndicator();//绑定指示器
|
||||
|
||||
sharedPreferences = getSharedPreferences("data", Context.MODE_PRIVATE);
|
||||
editor = sharedPreferences.edit();
|
||||
|
||||
gson = new Gson();
|
||||
records = new ArrayList<>();
|
||||
if (sharedPreferences.contains("data")) {
|
||||
records = gson.fromJson(sharedPreferences.getString("data", ""), new TypeToken<List<String>>() {
|
||||
}.getType());
|
||||
Collections.reverse(records);
|
||||
}
|
||||
search_view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
records.clear();
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
adapter = new CommonAdapter(SearchActivity.this, R.layout.item_search_record, records) {
|
||||
@Override
|
||||
protected void convert(ViewHolder holder, Object o, final int position) {
|
||||
holder.setText(R.id.text_id, records.get(position));
|
||||
}
|
||||
|
||||
};
|
||||
adapter.setOnItemClickListener(new MultiItemTypeAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, RecyclerView.ViewHolder holder, int position) {
|
||||
mEditText.setText(records.get(position));
|
||||
search();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, int position) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
list_record.setLayoutManager(new GridLayoutManager(this, 4));
|
||||
list_record.setAdapter(adapter);
|
||||
mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||
search();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
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) {
|
||||
MainHttpUtil.cancel(MainHttpConsts.SEARCH);
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
if (!TextUtils.isEmpty(s)) {
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessageDelayed(0, 500);
|
||||
}
|
||||
} else {
|
||||
mKey = null;
|
||||
if (mSearchAdapter != null) {
|
||||
mSearchAdapter.clearData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
});
|
||||
mRefreshView = findViewById(R.id.refreshView);
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_search);
|
||||
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<SearchUserBean>() {
|
||||
@Override
|
||||
public RefreshAdapter<SearchUserBean> getAdapter() {
|
||||
if (mSearchAdapter == null) {
|
||||
mSearchAdapter = new SearchAdapter(mContext, Constants.FOLLOW_FROM_SEARCH);
|
||||
mSearchAdapter.setOnItemClickListener(SearchActivity.this);
|
||||
}
|
||||
return mSearchAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
if (!TextUtils.isEmpty(mKey)) {
|
||||
search_view.setVisibility(View.GONE);
|
||||
if (!sharedPreferences.getString("data", "").contains(mKey)) {
|
||||
if (records.size() > 10) {
|
||||
records.remove(0);
|
||||
}
|
||||
records.add(mKey);
|
||||
editor.putString("data", gson.toJson(records));
|
||||
editor.commit();
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
MainHttpUtil.search(mKey, typeIndex, p, callback);
|
||||
lt_search_list.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
search_view.setVisibility(View.VISIBLE);
|
||||
lt_search_list.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@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() {
|
||||
|
||||
}
|
||||
});
|
||||
mHandler = new MyHandler(this);
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
//绑定指示器
|
||||
private int typeIndex = 1;
|
||||
private void searchIndicator() {
|
||||
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) {
|
||||
SimplePagerTitleView simplePagerTitleView = new SimplePagerTitleView(context);
|
||||
simplePagerTitleView.setText(titles[index]);
|
||||
simplePagerTitleView.setTextSize(16);//设置导航的文字大小
|
||||
simplePagerTitleView.setNormalColor(Color.BLACK);//正常状态下的标题颜色
|
||||
simplePagerTitleView.setSelectedColor(getResources().getColor(R.color.global));//选中的标题字体颜色
|
||||
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
vp_content.setCurrentItem(index);
|
||||
typeIndex = 1 + index;
|
||||
search();
|
||||
}
|
||||
});
|
||||
return simplePagerTitleView;
|
||||
}
|
||||
|
||||
@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));
|
||||
indicator.setColors(getResources().getColor(R.color.global));
|
||||
return indicator;
|
||||
}
|
||||
});
|
||||
magicIndicator.setNavigator(commonNavigator);
|
||||
fragments = new Fragment[]{new BlankDialog(),new BlankDialog(),new BlankDialog()};
|
||||
//每项只进入一次
|
||||
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);
|
||||
}
|
||||
|
||||
private void search() {
|
||||
String key = mEditText.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(key)) {
|
||||
ToastUtil.show(R.string.content_empty);
|
||||
return;
|
||||
}
|
||||
MainHttpUtil.cancel(MainHttpConsts.SEARCH);
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
mKey = key;
|
||||
mRefreshView.initData();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
MainHttpUtil.cancel(MainHttpConsts.SEARCH);
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mHandler.release();
|
||||
}
|
||||
mHandler = null;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onFollowEvent(FollowEvent e) {
|
||||
if (mSearchAdapter != null) {
|
||||
mSearchAdapter.updateItem(e.getToUid(), e.getIsAttention());
|
||||
ToastUtil.show(getResources().getString(R.string.following));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(SearchUserBean bean, int position) {
|
||||
//跳转到个人资料
|
||||
if (imm != null && mEditText != null) {
|
||||
imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
|
||||
RouteUtil.forwardUserHome(mContext, bean.getId(),0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class MyHandler extends Handler {
|
||||
|
||||
private SearchActivity mActivity;
|
||||
|
||||
public MyHandler(SearchActivity activity) {
|
||||
mActivity = new WeakReference<>(activity).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (mActivity != null) {
|
||||
mActivity.search();
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
mActivity = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
199
main/src/main/java/com/yunbao/main/activity/SettingActivity.java
Normal file
@@ -0,0 +1,199 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
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.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.GlideCatchUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.VersionUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
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;
|
||||
|
||||
import static com.yunbao.common.Constants.SETTING_CLEAR_CACHE;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/30.
|
||||
*/
|
||||
|
||||
public class SettingActivity extends AbsActivity implements OnItemClickListener<SettingBean> {
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private Handler mHandler;
|
||||
private SettingAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_setting;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(WordUtil.getString(R.string.setting));
|
||||
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
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(WordUtil.getString(R.string.versions));
|
||||
list.add(data1);
|
||||
|
||||
SettingBean bean = new SettingBean();
|
||||
bean.setName(WordUtil.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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@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() == 17) {//意见反馈要在url上加版本号和设备号
|
||||
href += "&version=" + android.os.Build.VERSION.RELEASE + "&model=" + android.os.Build.MODEL;
|
||||
}
|
||||
WebViewActivity.forward(mContext, href);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查更新
|
||||
*/
|
||||
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() {
|
||||
CommonAppConfig.getInstance().clearLoginInfo();
|
||||
//退出极光
|
||||
// ImMessageUtil.getInstance().logoutImClient();
|
||||
// ImPushUtil.getInstance().logout();
|
||||
//友盟统计登出
|
||||
// MobclickAgent.onProfileSignOff();
|
||||
|
||||
// SettingActivity.this.startActivity(new Intent(SettingActivity.this,EntryActivity.class));
|
||||
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(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,84 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.live2.V2TXLiveDef;
|
||||
import com.tencent.live2.V2TXLivePlayer;
|
||||
import com.tencent.live2.V2TXLivePlayerObserver;
|
||||
import com.tencent.live2.impl.V2TXLivePlayerImpl;
|
||||
import com.tencent.rtmp.ui.TXCloudVideoView;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
public class TestActivity extends AppCompatActivity {
|
||||
private TXCloudVideoView mVideoView;
|
||||
private V2TXLivePlayer mPlayer;
|
||||
String TAG = "tag";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_test);
|
||||
mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
|
||||
|
||||
|
||||
mPlayer = new V2TXLivePlayerImpl(getApplicationContext());
|
||||
mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
|
||||
mPlayer.setRenderView(mVideoView);
|
||||
mPlayer.setObserver(new V2TXLivePlayerObserver() {
|
||||
|
||||
@Override
|
||||
public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
|
||||
Log.d(TAG, "[Player] onError: player-" + player + " code-" + code + " msg-" + msg + " info-" + extraInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoPlayStatusUpdate(V2TXLivePlayer player, V2TXLiveDef.V2TXLivePlayStatus status, V2TXLiveDef.V2TXLiveStatusChangeReason reason, Bundle bundle) {
|
||||
Log.d(TAG, "[Player] onVideoPlayStatusUpdate: player-" + player + ", status-" + status + ", reason-" + reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWarning(V2TXLivePlayer v2TXLivePlayer, int i, String s, Bundle bundle) {
|
||||
Log.d(TAG, "[Player] Override: player-" + v2TXLivePlayer + ", i-" + i + ", s-" + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveDef.V2TXLiveVideoFrame v2TXLiveVideoFrame) {
|
||||
super.onRenderVideoFrame(player, v2TXLiveVideoFrame);
|
||||
Log.d(TAG, "[Player] onRenderVideoFrame: player-" + player + ", v2TXLiveVideoFrame-" + v2TXLiveVideoFrame);
|
||||
}
|
||||
});
|
||||
|
||||
int result = mPlayer.startPlay("http://sylive.shayucm.com/live/31754_1631600921.flv");
|
||||
|
||||
Log.d(TAG, "startPlay : " + result);
|
||||
// if (TextUtils.isEmpty(url)) {
|
||||
// return;
|
||||
// }
|
||||
// int playType = -1;
|
||||
// if (url.startsWith("rtmp://")) {
|
||||
// playType = TXLivePlayer.PLAY_TYPE_LIVE_RTMP;
|
||||
// } else if (url.endsWith(".flv")) {
|
||||
// playType = TXLivePlayer.PLAY_TYPE_LIVE_FLV;
|
||||
// } else if (url.endsWith(".m3u8")) {
|
||||
// playType = TXLivePlayer.PLAY_TYPE_VOD_HLS;
|
||||
// } else if (url.endsWith(".mp4")) {
|
||||
// playType = TXLivePlayer.PLAY_TYPE_VOD_MP4;
|
||||
// }
|
||||
// if (playType == -1) {
|
||||
// ToastUtil.show(R.string.live_play_error_2);
|
||||
// return;
|
||||
// }
|
||||
// if (mPlayer != null) {
|
||||
// int result = mPlayer.startPlay(url);
|
||||
// if (result == 0) {
|
||||
// mStarted = true;
|
||||
|
||||
// mUrl = url;
|
||||
// mPlayType = playType;
|
||||
// }
|
||||
// }
|
||||
// L.e(TAG, "play----url--->" + url);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,363 @@
|
||||
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, WordUtil.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();
|
||||
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() {
|
||||
mProcessResultUtil.requestPermissions(new String[]{
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
}, 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,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();
|
||||
}
|
||||
}
|
||||
118
main/src/main/java/com/yunbao/main/activity/WalletFragment.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.Fragment;
|
||||
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 com.yunbao.main.R;
|
||||
import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
import static android.util.Log.i;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class WalletFragment extends Fragment {
|
||||
|
||||
|
||||
|
||||
private View view;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
@SuppressLint("ValidFragment")
|
||||
public WalletFragment(String urls) {
|
||||
Log.e("google","222aa");
|
||||
url = urls;
|
||||
}
|
||||
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
@JavascriptInterface
|
||||
public void androidMethodBack() {
|
||||
MyWalletActivity.dis();
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void androidGoBack() {
|
||||
MyWalletActivity.dis();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//通过参数中的布局填充获取对应布局
|
||||
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打开新窗口
|
||||
//
|
||||
// webSettings.setUseWideViewPort(true); // 缩放至屏幕大小
|
||||
// webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕大小
|
||||
// webSettings.setSupportZoom(true); // 是否支持缩放
|
||||
// webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放
|
||||
// webSettings.setDisplayZoomControls(false); // 是否隐藏缩放控件
|
||||
//
|
||||
// webSettings.setAllowFileAccess(true); // 是否允许访问文件
|
||||
// webSettings.setDomStorageEnabled(false); // 是否节点缓存
|
||||
// webSettings.setDatabaseEnabled(false); // 是否数据缓存
|
||||
// webSettings.setAppCacheEnabled(false); // 是否应用缓存
|
||||
//
|
||||
// webSettings.setMediaPlaybackRequiresUserGesture(false); // 是否要手势触发媒体
|
||||
// webSettings.setStandardFontFamily("sans-serif"); // 设置字体库格式
|
||||
// webSettings.setFixedFontFamily("monospace"); // 设置字体库格式
|
||||
// webSettings.setSansSerifFontFamily("sans-serif"); // 设置字体库格式
|
||||
// webSettings.setSerifFontFamily("sans-serif"); // 设置字体库格式
|
||||
// webSettings.setCursiveFontFamily("cursive"); // 设置字体库格式
|
||||
// webSettings.setFantasyFontFamily("fantasy"); // 设置字体库格式
|
||||
// webSettings.setTextZoom(100); // 设置文本缩放的百分比
|
||||
// webSettings.setMinimumFontSize(8); // 设置文本字体的最小值(1~72)
|
||||
// webSettings.setDefaultFontSize(16); // 设置文本字体默认的大小
|
||||
//
|
||||
// webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); // 按规则重新布局
|
||||
// webSettings.setLoadsImagesAutomatically(true); // 是否自动加载图片
|
||||
// webSettings.setDefaultTextEncodingName("UTF-8"); // 设置编码格式
|
||||
// webSettings.setNeedInitialFocus(true); // 是否需要获取焦点
|
||||
// webSettings.setGeolocationEnabled(false); // 设置开启定位功能
|
||||
// webSettings.setBlockNetworkLoads(false); // 是否从网络获取资源
|
||||
// rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
|
||||
// rlWebview.setWebContentsDebuggingEnabled(true);
|
||||
|
||||
|
||||
rlWebview.addJavascriptInterface(new JsInteration(),"androidObject");
|
||||
|
||||
TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(),rlWebview);
|
||||
|
||||
rlWebview.setWebViewClient(testWebViewClient);
|
||||
|
||||
return view;
|
||||
}
|
||||
//
|
||||
// //js调用原生
|
||||
// public class JsInteration {
|
||||
// @JavascriptInterface
|
||||
// public void androidMethodBack() {
|
||||
// RechargeActivity.this.finish();
|
||||
// }
|
||||
// @JavascriptInterface
|
||||
// public void androidGoBack() {
|
||||
// RechargeActivity.this.finish();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
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 androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.JavascriptInterface;
|
||||
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 com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
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.LiveAudienceActivity;
|
||||
import com.yunbao.live.activity.WebViewActivityMedal;
|
||||
import com.yunbao.live.bean.LiveBean;
|
||||
import com.yunbao.live.dialog.LiveUserDialogFragment;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
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() {
|
||||
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(new JsInteration(),"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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
@JavascriptInterface
|
||||
public String androidMethodLookLive(String uId,String liveId,String isLiving) {
|
||||
//跳转个人主页
|
||||
RouteUtil.forwardUserHome(mContext, liveId,0);
|
||||
|
||||
return "";
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void androidMethodLookToLive(String liveId) {
|
||||
//看直播
|
||||
gotoLive(liveId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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 (mCheckLivePresenter == null) {
|
||||
mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) {
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
mCheckLivePresenter.checkLive(liveBean);
|
||||
}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, WordUtil.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();
|
||||
}
|
||||
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() {
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
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 androidx.annotation.RequiresApi;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.JavascriptInterface;
|
||||
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 com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
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.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.GifCacheUtil;
|
||||
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.main.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import static com.yunbao.common.utils.RouteUtil.PATH_COIN;
|
||||
|
||||
@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() {
|
||||
String url = getIntent().getStringExtra(Constants.URL);
|
||||
if (!"".equals(Constants.myPackageUrl)) {
|
||||
url = Constants.myPackageUrl;
|
||||
}
|
||||
v_spacing = (View) findViewById(R.id.v_spacing);
|
||||
lt_title = (LinearLayout) findViewById(R.id.lt_title);
|
||||
if (Constants.isTitle) {
|
||||
lt_title.setVisibility(View.VISIBLE);
|
||||
v_spacing.setVisibility(View.GONE);
|
||||
} else {
|
||||
lt_title.setVisibility(View.GONE);
|
||||
v_spacing.setVisibility(View.VISIBLE);
|
||||
}
|
||||
L.e("H5---5>" + 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(new JsInteration(), "androidObject");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
}
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
@JavascriptInterface
|
||||
public void onBack() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidZBan(String svg) {
|
||||
String[] arr = svg.split("/");
|
||||
String id = arr[arr.length - 1];
|
||||
String url1;
|
||||
if (!svg.contains("http")) {
|
||||
url1 = CommonAppConfig.HOST + svg;
|
||||
} else {
|
||||
url1 = svg;
|
||||
}
|
||||
GifCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
|
||||
@Override
|
||||
public void callback(File bean) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidOpeningNoble(String svg) {
|
||||
try {
|
||||
new SVGAParser(mContext).parse(new URL(svg), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
svga.setImageDrawable(drawable);
|
||||
svga.setLoops(1);
|
||||
svga.startAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidGoBack() {
|
||||
// Log.e("Zhu", "svg" +svg);
|
||||
ZhuangBanActivity.this.finish();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidGoToRe() {
|
||||
ARouter.getInstance().build(PATH_COIN).withInt("p", 1).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void gotoHomePage(String indexStr) {
|
||||
Log.e("tgasss","indexStr2"+indexStr);
|
||||
if (!"".equals(indexStr) && indexStr != null) {
|
||||
int index = -1;
|
||||
if ("0".equals(indexStr)) {
|
||||
index = 0;
|
||||
} else if ("1".equals(indexStr)) {
|
||||
index = 1;
|
||||
} else if ("2".equals(indexStr)) {
|
||||
index = 2;
|
||||
} else if ("3".equals(indexStr)) {
|
||||
index = 3;
|
||||
}
|
||||
if (index != -1) {
|
||||
finish();
|
||||
Constants.isShowPage = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void openWebView(String url) {
|
||||
Constants.isTitle = false;
|
||||
RouteUtil.forwardZhuangBanActivity(url);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void openWebViewTitle(String url) {
|
||||
Constants.isTitle = true;
|
||||
RouteUtil.forwardZhuangBanActivity(url);
|
||||
}
|
||||
}
|
||||
|
||||
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, WordUtil.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, ZhuangBanActivity.class);
|
||||
Log.i("tag", url);
|
||||
intent.putExtra(Constants.URL, url);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url) {
|
||||
forward(context, url, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 = WordUtil.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,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.live.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,369 @@
|
||||
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 androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
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 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.live.bean.LiveBean;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.bean.HomeTopBean;
|
||||
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.OnClickListener mOnClickListener;
|
||||
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(140)));
|
||||
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) {
|
||||
if (mList.get(position).getIs_week() != null && mList.get(position).getIs_week().equals("1")) {
|
||||
if (mList.get(position).getmWeekList() != null && mList.get(position).getmWeekList().size() > 0) {
|
||||
mList.get(position).setUid(mList.get(position).getmWeekList().get(weekListIndex).getAnchor_id());
|
||||
}
|
||||
}
|
||||
mOnItemClickListener.onItemClick(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
|
||||
HomeTopBean HomeTopData;
|
||||
|
||||
// class Vh extends RecyclerView.ViewHolder {
|
||||
// LinearLayout live_info_view, lt_week_list;
|
||||
// ImageView mCover, img_week_head;
|
||||
// TextView mName, name2;
|
||||
// TextView mTitle;
|
||||
// TextView mNum;
|
||||
// ImageView mType;
|
||||
// ImageView live_type;
|
||||
//
|
||||
// ImageView mLiveIco;
|
||||
// TextView mLiveState;
|
||||
// MarqueeView mRvRankingList;
|
||||
// ImageView PkAvatar;
|
||||
// ImageView Pkico;
|
||||
// ImageView dr_pk_ico;
|
||||
// View views;
|
||||
// RatioRoundImageView bgs;
|
||||
// SVGAImageView week_svga;
|
||||
//
|
||||
// public Vh(View itemView) {
|
||||
// super(itemView);
|
||||
// live_info_view = (LinearLayout) itemView.findViewById(R.id.live_info_view);
|
||||
// lt_week_list = (LinearLayout) itemView.findViewById(R.id.lt_week_list);
|
||||
// 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);
|
||||
// itemView.setOnClickListener(mOnClickListener);
|
||||
//
|
||||
// week_svga = (SVGAImageView) itemView.findViewById(R.id.week_svga);
|
||||
// img_week_head = (ImageView) itemView.findViewById(R.id.img_week_head);
|
||||
// name2 = (TextView) itemView.findViewById(R.id.name2);
|
||||
// }
|
||||
//
|
||||
// void setData(LiveBean bean, int position) {
|
||||
// Log.e("MainHomeLiveAdapter", position + " ***************" + "LiveBean:" + bean.getThumb());
|
||||
//// Log.e("MainHomeLiveAdapter", position + " ***************" + "LiveBean:" + new Gson().toJson(bean));
|
||||
// itemView.setTag(position);
|
||||
// live_info_view.setVisibility(View.VISIBLE);
|
||||
// live_type.setImageDrawable(null);
|
||||
// if (bean.getContent_pic_size_two() != null && !bean.getContent_pic_size_two().equals("") && Height <= 1920) {
|
||||
// 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);
|
||||
// lt_week_list.setVisibility(View.GONE);
|
||||
// if (bean.getIsTop() != null && bean.getIsTop().equals("1")) {
|
||||
// if (MainHomeLiveViewHolder.pp != 1) {
|
||||
// live_info_view.setVisibility(View.GONE);
|
||||
// mRvRankingList.setVisibility(View.GONE);
|
||||
// }
|
||||
// } else {
|
||||
// live_info_view.setVisibility(View.VISIBLE);
|
||||
// mRvRankingList.setVisibility(View.GONE);
|
||||
// bgs.setVisibility(View.GONE);
|
||||
// if (bean.getIs_week() != null && bean.getIs_week().equals("1")) {
|
||||
// bgs.setVisibility(View.GONE);
|
||||
// getWeekIntIndex = Constants.getWeekIntIndex;
|
||||
// getUserHotList(week_svga, live_info_view, lt_week_list, img_week_head, mTitle, name2, position, bean.getmWeekList());
|
||||
// Log.e("MainHomeLiveAdapter", position + " ***************" + "周星榜");
|
||||
// } 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(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(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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
private int weekListIndex = 0;
|
||||
public CountDownTimer countDownTimer;
|
||||
|
||||
private void setAction(ImageView imageView, int time, TextView mTitle, TextView name2, List<WeekListBean> mWeekListBean) {
|
||||
ImgLoader.display2(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);
|
||||
week_svga.startAnimation();
|
||||
Log.e("MainHomeLiveAdapter", position + " ***************" + "onComplete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
} 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,93 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.bean.LiveClassBean;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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);
|
||||
mName.setText(bean.getName());
|
||||
if(position == choice){
|
||||
mName.setBackgroundResource(R.drawable.button_ffc621);
|
||||
mName.setTextColor(Color.parseColor("#FFC621"));
|
||||
}else{
|
||||
mName.setBackgroundResource(R.drawable.button_cbd5e0);
|
||||
mName.setTextColor(Color.parseColor("#484D68"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
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 com.squareup.picasso.Picasso;
|
||||
import com.xj.marqueeview.MarqueeView;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.custom.RatioRoundImageView;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.formatBigNum;
|
||||
import com.yunbao.live.bean.LiveBean;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.utils.MainIconUtil;
|
||||
|
||||
/**
|
||||
* 关注和推荐的适配器
|
||||
*/
|
||||
public class MainHomeRemFollLiveAdapter extends RefreshAdapter<LiveBean> {
|
||||
|
||||
|
||||
private View.OnClickListener mOnClickListener;
|
||||
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;
|
||||
|
||||
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_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 mLiveIco;
|
||||
TextView mLiveState;
|
||||
MarqueeView mRvRankingList;
|
||||
ImageView PkAvatar;
|
||||
ImageView Pkico;
|
||||
ImageView dr_pk_ico;
|
||||
View views;
|
||||
RatioRoundImageView bgs;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
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);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(LiveBean bean, int position) {
|
||||
itemView.setTag(position);
|
||||
mRvRankingList.setVisibility(View.VISIBLE);
|
||||
live_info_view.setVisibility(View.VISIBLE);
|
||||
live_type.setImageDrawable(null);
|
||||
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(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(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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.video.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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
598
main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java
Normal file
@@ -0,0 +1,598 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
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 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.utils.CommonIconUtil;
|
||||
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 static final int HEAD = 0;
|
||||
private static final int NORMAL = 1;
|
||||
private String mCoinName;
|
||||
private String mFollow;
|
||||
private String mFollowing;
|
||||
private View.OnClickListener mFollowClickListener1;
|
||||
private View.OnClickListener mFollowClickListener2;
|
||||
private View.OnClickListener mItemClickListener;
|
||||
private List<ListBean> mTopList;
|
||||
private HeadVh mHeadVh;
|
||||
private int mType;
|
||||
|
||||
public MainListAdapter(Context context, int type) {
|
||||
super(context);
|
||||
mType = type;
|
||||
CommonAppConfig appConfig = CommonAppConfig.getInstance();
|
||||
mCoinName = type == TYPE_PROFIT ? appConfig.getVotesName() : appConfig.getCoinName();
|
||||
mTopList = new ArrayList<>();
|
||||
mFollow = ("+"+WordUtil.getString(R.string.follow));
|
||||
mFollowing = WordUtil.getString(R.string.following);
|
||||
mItemClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null && mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick((ListBean) tag, 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
mFollowClickListener1 = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
final ListBean bean = (ListBean) tag;
|
||||
CommonHttpUtil.setAttention(bean.getUid(), null);
|
||||
}
|
||||
}
|
||||
};
|
||||
mFollowClickListener2 = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View 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(), null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mList != null && mTopList.size() > 0) {
|
||||
return mList.size() + 1;
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
if (viewType == HEAD) {
|
||||
if (mHeadVh == null) {
|
||||
mHeadVh = new HeadVh(mInflater.inflate(R.layout.item_main_list_head, parent, false));
|
||||
}
|
||||
return mHeadVh;
|
||||
} else {
|
||||
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;
|
||||
if (vh instanceof Vh) {
|
||||
((Vh) vh).setData(mList.get(position - 1), position - 1, payload);
|
||||
} else {
|
||||
((HeadVh) vh).setData(payload);
|
||||
}
|
||||
}
|
||||
|
||||
class HeadVh extends RecyclerView.ViewHolder {
|
||||
|
||||
View mItem1;
|
||||
View mItem2;
|
||||
View mItem3;
|
||||
GifImageView liveing1;
|
||||
GifImageView liveing2;
|
||||
GifImageView liveing3;
|
||||
ImageView mAvatar1;
|
||||
ImageView mAvatar2;
|
||||
ImageView mAvatar3;
|
||||
TextView mName1;
|
||||
TextView mName2;
|
||||
TextView mName3;
|
||||
TextView mVotes1;
|
||||
TextView mVotes2;
|
||||
TextView mVotes3;
|
||||
ImageView mSex1;
|
||||
ImageView mSex2;
|
||||
ImageView mSex3;
|
||||
ImageView mLevel1;
|
||||
ImageView mLevel2;
|
||||
ImageView mLevel3;
|
||||
MyRadioButton mBtnFollow1;
|
||||
MyRadioButton mBtnFollow2;
|
||||
MyRadioButton mBtnFollow3;
|
||||
SVGAImageView svga1;
|
||||
SVGAImageView svga2;
|
||||
SVGAImageView svga3;
|
||||
|
||||
// View mDataGroup2;
|
||||
// View mDataGroup3;
|
||||
// View mNoData2;
|
||||
// View mNoData3;
|
||||
|
||||
public HeadVh(View itemView) {
|
||||
super(itemView);
|
||||
mItem1 = itemView.findViewById(R.id.item_1);
|
||||
mItem2 = itemView.findViewById(R.id.item_2);
|
||||
mItem3 = itemView.findViewById(R.id.item_3);
|
||||
liveing1 = itemView.findViewById(R.id.liveing1);
|
||||
liveing2 = itemView.findViewById(R.id.liveing2);
|
||||
liveing3 = itemView.findViewById(R.id.liveing3);
|
||||
mItem1.setOnClickListener(mItemClickListener);
|
||||
mItem2.setOnClickListener(mItemClickListener);
|
||||
mItem3.setOnClickListener(mItemClickListener);
|
||||
mAvatar1 = (ImageView) itemView.findViewById(R.id.avatar_1);
|
||||
mAvatar2 = (ImageView) itemView.findViewById(R.id.avatar_2);
|
||||
mAvatar3 = (ImageView) itemView.findViewById(R.id.avatar_3);
|
||||
mName1 = (TextView) itemView.findViewById(R.id.name_1);
|
||||
mName2 = (TextView) itemView.findViewById(R.id.name_2);
|
||||
mName3 = (TextView) itemView.findViewById(R.id.name_3);
|
||||
mVotes1 = (TextView) itemView.findViewById(R.id.votes_1);
|
||||
mVotes2 = (TextView) itemView.findViewById(R.id.votes_2);
|
||||
mVotes3 = (TextView) itemView.findViewById(R.id.votes_3);
|
||||
mSex1 = (ImageView) itemView.findViewById(R.id.sex_1);
|
||||
mSex2 = (ImageView) itemView.findViewById(R.id.sex_2);
|
||||
mSex3 = (ImageView) itemView.findViewById(R.id.sex_3);
|
||||
mLevel1 = (ImageView) itemView.findViewById(R.id.level_1);
|
||||
mLevel2 = (ImageView) itemView.findViewById(R.id.level_2);
|
||||
mLevel3 = (ImageView) itemView.findViewById(R.id.level_3);
|
||||
mBtnFollow1 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_1);
|
||||
mBtnFollow2 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_2);
|
||||
mBtnFollow3 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_3);
|
||||
mBtnFollow1.setOnClickListener(mFollowClickListener1);
|
||||
mBtnFollow2.setOnClickListener(mFollowClickListener1);
|
||||
mBtnFollow3.setOnClickListener(mFollowClickListener1);
|
||||
svga1 = (SVGAImageView)itemView.findViewById(R.id.svga1);
|
||||
svga2 = (SVGAImageView)itemView.findViewById(R.id.svga2);
|
||||
svga3 = (SVGAImageView)itemView.findViewById(R.id.svga3);
|
||||
|
||||
// mDataGroup2 = itemView.findViewById(R.id.data_group_2);
|
||||
// mDataGroup3 = itemView.findViewById(R.id.data_group_3);
|
||||
// mNoData2 = itemView.findViewById(R.id.no_data_2);
|
||||
// mNoData3 = itemView.findViewById(R.id.no_data_3);
|
||||
}
|
||||
|
||||
void setData(Object payload) {
|
||||
int topSize = mTopList.size();
|
||||
if (topSize > 0) {
|
||||
ListBean bean = mTopList.get(0);
|
||||
svga1.setVisibility(View.GONE);
|
||||
|
||||
if (bean.getDress_head()!= null) {
|
||||
if (bean.getDress_head().contains("svga")) {
|
||||
svga1.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);
|
||||
svga1.setImageDrawable(drawable);
|
||||
svga1.startAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Log.e("eee", bean.getDress_head());
|
||||
ImgLoader.display(mContext, bean.getDress_head(), svga1);
|
||||
}
|
||||
}
|
||||
mItem1.setVisibility(View.GONE);
|
||||
if (payload == null) {
|
||||
mItem1.setTag(bean);
|
||||
mItem1.setVisibility(View.VISIBLE);
|
||||
ImgLoader.display(mContext,bean.getAvatarThumb(), mAvatar1);
|
||||
mName1.setText(bean.getUserNiceName());
|
||||
mVotes1.setText(bean.getTotalCoinFormat());
|
||||
mSex1.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(), mLevel1);
|
||||
}
|
||||
}
|
||||
mBtnFollow1.setTag(bean);
|
||||
liveing1.setVisibility(View.INVISIBLE);
|
||||
if(bean.getIslive() == 1){
|
||||
liveing1.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
liveing1.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
if (bean.getAttention() == 1) {
|
||||
mBtnFollow1.doChecked(true);
|
||||
mBtnFollow1.setText(mFollowing);
|
||||
mBtnFollow1.setBackgroundResource(R.drawable.background_dbdbdb);
|
||||
mBtnFollow1.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
} else {
|
||||
mBtnFollow1.doChecked(false);
|
||||
mBtnFollow1.setText(mFollow);
|
||||
mBtnFollow1.setBackgroundResource(R.drawable.background_yellow);
|
||||
mBtnFollow1.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
}
|
||||
}
|
||||
if (topSize > 1) {
|
||||
ListBean bean = mTopList.get(1);
|
||||
svga2.setVisibility(View.GONE);
|
||||
|
||||
if (bean.getDress_head()!= null) {
|
||||
if (bean.getDress_head().contains("svga")) {
|
||||
svga2.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);
|
||||
svga2.setImageDrawable(drawable);
|
||||
svga2.startAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Log.e("eee", bean.getDress_head());
|
||||
ImgLoader.display(mContext, bean.getDress_head(), svga2);
|
||||
}
|
||||
}
|
||||
mItem2.setVisibility(View.GONE);
|
||||
if (payload == null) {
|
||||
mItem2.setVisibility(View.VISIBLE);
|
||||
mItem2.setTag(bean);
|
||||
ImgLoader.display(mContext,bean.getAvatarThumb(), mAvatar2);
|
||||
mName2.setText(bean.getUserNiceName());
|
||||
mVotes2.setText(bean.getTotalCoinFormat() + " " );
|
||||
mSex2.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(), mLevel2);
|
||||
}
|
||||
}
|
||||
mBtnFollow2.setTag(bean);
|
||||
liveing2.setVisibility(View.INVISIBLE);
|
||||
if(bean.getIslive() == 1){
|
||||
liveing2.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
liveing2.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
if (bean.getAttention() == 1) {
|
||||
mBtnFollow2.doChecked(true);
|
||||
mBtnFollow2.setText(mFollowing);
|
||||
mBtnFollow2.setBackgroundResource(R.drawable.background_dbdbdb);
|
||||
mBtnFollow2.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
} else {
|
||||
mBtnFollow2.doChecked(false);
|
||||
mBtnFollow2.setText(mFollow);
|
||||
mBtnFollow2.setBackgroundResource(R.drawable.background_yellow);
|
||||
mBtnFollow2.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
}
|
||||
// if (mNoData2.getVisibility() == View.VISIBLE) {
|
||||
// mNoData2.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
// if (mDataGroup2.getVisibility() != View.VISIBLE) {
|
||||
// mDataGroup2.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
} else {
|
||||
// if (mDataGroup2.getVisibility() == View.VISIBLE) {
|
||||
// mDataGroup2.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
// if (mNoData2.getVisibility() != View.VISIBLE) {
|
||||
// mNoData2.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
}
|
||||
if (topSize > 2) {
|
||||
ListBean bean = mTopList.get(2);
|
||||
|
||||
if (bean.getDress_head()!= null) {
|
||||
svga3.setVisibility(View.GONE);
|
||||
if (bean.getDress_head().contains("svga")) {
|
||||
svga3.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);
|
||||
svga3.setImageDrawable(drawable);
|
||||
svga3.startAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Log.e("eee", bean.getDress_head());
|
||||
ImgLoader.display(mContext, bean.getDress_head(), svga3);
|
||||
}
|
||||
}
|
||||
mItem3.setVisibility(View.GONE);
|
||||
if (payload == null) {
|
||||
mItem3.setVisibility(View.VISIBLE);
|
||||
mItem3.setTag(bean);
|
||||
ImgLoader.display(mContext,bean.getAvatarThumb(), mAvatar3);
|
||||
mName3.setText(bean.getUserNiceName());
|
||||
mVotes3.setText(bean.getTotalCoinFormat() + " " );
|
||||
mSex3.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(), mLevel3);
|
||||
}
|
||||
}
|
||||
mBtnFollow3.setTag(bean);
|
||||
liveing3.setVisibility(View.INVISIBLE);
|
||||
if(bean.getIslive() == 1){
|
||||
liveing3.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
liveing3.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
if (bean.getAttention() == 1) {
|
||||
mBtnFollow3.doChecked(true);
|
||||
mBtnFollow3.setText(mFollowing);
|
||||
mBtnFollow3.setBackgroundResource(R.drawable.background_dbdbdb);
|
||||
mBtnFollow3.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
} else {
|
||||
mBtnFollow3.doChecked(false);
|
||||
mBtnFollow3.setText(mFollow);
|
||||
mBtnFollow3.setBackgroundResource(R.drawable.background_yellow);
|
||||
mBtnFollow3.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
}
|
||||
// if (mNoData3.getVisibility() == View.VISIBLE) {
|
||||
// mNoData3.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
// if (mDataGroup3.getVisibility() != View.VISIBLE) {
|
||||
// mDataGroup3.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
} else {
|
||||
// if (mDataGroup3.getVisibility() == View.VISIBLE) {
|
||||
// mDataGroup3.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
// if (mNoData3.getVisibility() != View.VISIBLE) {
|
||||
// mNoData3.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.GONE);
|
||||
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);
|
||||
svga.startAnimation();
|
||||
}
|
||||
|
||||
@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));
|
||||
ImgLoader.display(mContext,bean.getAvatarThumb(), mAvatar);
|
||||
mName.setText(bean.getUserNiceName());
|
||||
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.setTag(position);
|
||||
if (bean.getAttention() == 1) {
|
||||
mBtnFollow.doChecked(true);
|
||||
mBtnFollow.setText(mFollowing);
|
||||
mBtnFollow.setBackgroundResource(R.drawable.background_dbdbdb);
|
||||
mBtnFollow.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
} else {
|
||||
mBtnFollow.doChecked(false);
|
||||
mBtnFollow.setText(mFollow);
|
||||
mBtnFollow.setBackgroundResource(R.drawable.background_yellow);
|
||||
mBtnFollow.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
133
main/src/main/java/com/yunbao/main/adapter/MainMeAdapter.java
Normal file
@@ -0,0 +1,133 @@
|
||||
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.bean.UserItemBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
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 View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<UserItemBean> mOnItemClickListener;
|
||||
|
||||
public MainMeAdapter(Context context, List<UserItemBean> list) {
|
||||
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) {
|
||||
UserItemBean bean = (UserItemBean) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
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.live.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()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
113
main/src/main/java/com/yunbao/main/adapter/RecommendAdapter.java
Normal file
@@ -0,0 +1,113 @@
|
||||
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.custom.MyRadioButton;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.bean.RecommendBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2017/10/23.
|
||||
*/
|
||||
|
||||
public class RecommendAdapter extends RecyclerView.Adapter<RecommendAdapter.Vh> {
|
||||
|
||||
private Context mContext;
|
||||
private List<RecommendBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
|
||||
public RecommendAdapter(Context context, List<RecommendBean> list) {
|
||||
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;
|
||||
RecommendBean bean = mList.get(position);
|
||||
bean.toggleChecked();
|
||||
notifyItemChanged(position, Constants.PAYLOAD);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_recommend, 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();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mAvatar;
|
||||
MyRadioButton mRadioButton;
|
||||
TextView mName;
|
||||
TextView mFans;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mAvatar = itemView.findViewById(R.id.avatar);
|
||||
mRadioButton = itemView.findViewById(R.id.radioButton);
|
||||
mName = itemView.findViewById(R.id.name);
|
||||
mFans = itemView.findViewById(R.id.fans);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(RecommendBean bean, int position, Object payload) {
|
||||
itemView.setTag(position);
|
||||
if (payload == null) {
|
||||
ImgLoader.displayAvatar(mContext, bean.getAvatar(), mAvatar);
|
||||
mName.setText(bean.getUserNiceName());
|
||||
mFans.setText(bean.getFans());
|
||||
}
|
||||
mRadioButton.doChecked(bean.isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
public String getCheckedUid() {
|
||||
String result = "";
|
||||
if (mList == null || mList.size() == 0) {
|
||||
return result;
|
||||
}
|
||||
for (RecommendBean bean : mList) {
|
||||
if (bean.isChecked()) {
|
||||
result += bean.getId() + ",";
|
||||
}
|
||||
}
|
||||
if (result.length() > 0) {
|
||||
result = result.substring(0, result.length() - 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
221
main/src/main/java/com/yunbao/main/adapter/SearchAdapter.java
Normal file
@@ -0,0 +1,221 @@
|
||||
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.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
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.http.HttpCallback;
|
||||
import com.yunbao.common.utils.CommonIconUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.bean.LiveBean;
|
||||
import com.yunbao.live.bean.SearchUserBean;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/29.
|
||||
*/
|
||||
|
||||
public class SearchAdapter extends RefreshAdapter<SearchUserBean> {
|
||||
|
||||
private View.OnClickListener mFollowClickListener;
|
||||
private View.OnClickListener mClickListener;
|
||||
private String mFollow;
|
||||
private String mFollowing;
|
||||
private int mFrom;
|
||||
private String mUid;
|
||||
|
||||
public SearchAdapter(Context context, int from) {
|
||||
super(context);
|
||||
mFrom = from;
|
||||
mFollow = WordUtil.getString(R.string.follow);
|
||||
mFollowing = WordUtil.getString(R.string.following);
|
||||
mFollowClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
Object tag = v.getTag();
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
SearchUserBean bean = (SearchUserBean) tag;
|
||||
CommonHttpUtil.setAttention(bean.getId(), null);
|
||||
}
|
||||
};
|
||||
mClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
Object tag = v.getTag();
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
SearchUserBean bean = (SearchUserBean) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
mUid = CommonAppConfig.getInstance().getUid();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_search, 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);
|
||||
}
|
||||
|
||||
public void updateItem(String id, int attention) {
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0, size = mList.size(); i < size; i++) {
|
||||
SearchUserBean bean = mList.get(i);
|
||||
if (bean != null && id.equals(bean.getId())) {
|
||||
bean.setAttention(attention);
|
||||
notifyItemChanged(i, Constants.PAYLOAD);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mAvatar;
|
||||
TextView mName;
|
||||
TextView mSign;
|
||||
ImageView mSex;
|
||||
ImageView mLevelAnchor;
|
||||
ImageView mLevel;
|
||||
MyRadioButton mBtnFollow;
|
||||
GifImageView btn_live;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mSign = (TextView) itemView.findViewById(R.id.sign);
|
||||
mSex = (ImageView) itemView.findViewById(R.id.sex);
|
||||
mLevelAnchor = (ImageView) itemView.findViewById(R.id.level_anchor);
|
||||
mLevel = (ImageView) itemView.findViewById(R.id.level);
|
||||
mBtnFollow = (MyRadioButton) itemView.findViewById(R.id.btn_follow);
|
||||
btn_live = (GifImageView) itemView.findViewById(R.id.btn_live);
|
||||
itemView.setOnClickListener(mClickListener);
|
||||
mBtnFollow.setOnClickListener(mFollowClickListener);
|
||||
}
|
||||
|
||||
void setData(final SearchUserBean bean, int position, Object payload) {
|
||||
itemView.setTag(bean);
|
||||
mBtnFollow.setTag(bean);
|
||||
if (payload == null) {
|
||||
ImgLoader.displayAvatar(mContext, bean.getAvatar(), mAvatar);
|
||||
mName.setText(bean.getUserNiceName());
|
||||
mSign.setText(bean.getSignature());
|
||||
mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
|
||||
btn_live.setVisibility(View.GONE);
|
||||
if (bean.getIslive() != null && bean.getIslive().equals("1")) {
|
||||
btn_live.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
btn_live.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
gotoLive(bean.getId());
|
||||
}
|
||||
});
|
||||
LevelBean anchorLevelBean = CommonAppConfig.getInstance().getAnchorLevel(bean.getLevelAnchor());
|
||||
if (anchorLevelBean != null) {
|
||||
ImgLoader.display(mContext, CommonAppConfig.getInstance().HOST + anchorLevelBean.getThumb(), mLevelAnchor);
|
||||
}
|
||||
LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel());
|
||||
if (levelBean != null) {
|
||||
ImgLoader.display(mContext, levelBean.getThumb(), mLevel);
|
||||
}
|
||||
}
|
||||
// if (mUid.equals(bean.getId())) {
|
||||
// if (mBtnFollow.getVisibility() == View.VISIBLE) {
|
||||
// mBtnFollow.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
// } else {
|
||||
// if (mBtnFollow.getVisibility() != View.VISIBLE) {
|
||||
// mBtnFollow.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
// if (bean.getAttention() == 1) {
|
||||
// mBtnFollow.doChecked(true);
|
||||
// mBtnFollow.setText(mFollowing);
|
||||
// } else {
|
||||
// mBtnFollow.doChecked(false);
|
||||
// mBtnFollow.setText(mFollow);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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 (mCheckLivePresenter == null) {
|
||||
mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) {
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
mCheckLivePresenter.checkLive(liveBean);
|
||||
} else {
|
||||
RouteUtil.forwardUserHome(mContext, live_id, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
146
main/src/main/java/com/yunbao/main/adapter/SettingAdapter.java
Normal file
@@ -0,0 +1,146 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.main.BuildConfig;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.bean.SettingBean;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/30.
|
||||
*/
|
||||
|
||||
public class SettingAdapter extends RecyclerView.Adapter {
|
||||
|
||||
private static final int NORMAL = 0;
|
||||
private static final int VERSION = 1;
|
||||
private static final int LAST = 2;
|
||||
private List<SettingBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<SettingBean> mOnItemClickListener;
|
||||
private String mVersionString;
|
||||
private String mCacheString;
|
||||
|
||||
|
||||
public SettingAdapter(Context context, List<SettingBean> list, String version, String cache) {
|
||||
mList = list;
|
||||
mVersionString = version;
|
||||
mCacheString = cache;
|
||||
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;
|
||||
SettingBean bean = mList.get(position);
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setCacheString(String cacheString) {
|
||||
mCacheString = cacheString;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<SettingBean> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
SettingBean bean = mList.get(position);
|
||||
if (bean.getId() == 19 || bean.getId() == Constants.SETTING_UPDATE_ID || bean.getId() == Constants.SETTING_CLEAR_CACHE) {
|
||||
return VERSION;
|
||||
} else if (bean.isLast()) {
|
||||
return LAST;
|
||||
} else {
|
||||
return NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == VERSION) {
|
||||
return new Vh2(mInflater.inflate(R.layout.item_setting_1, parent, false));
|
||||
} else if (viewType == LAST) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_setting_2, parent, false));
|
||||
} else {
|
||||
return new Vh(mInflater.inflate(R.layout.item_setting, parent, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
if (vh instanceof Vh) {
|
||||
((Vh) vh).setData(mList.get(position), position);
|
||||
} else {
|
||||
((Vh2) 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.name);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(SettingBean bean, int position) {
|
||||
itemView.setTag(position);
|
||||
mName.setText(bean.getName());
|
||||
}
|
||||
}
|
||||
|
||||
class Vh2 extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView mName;
|
||||
TextView mText;
|
||||
|
||||
public Vh2(View itemView) {
|
||||
super(itemView);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mText = (TextView) itemView.findViewById(R.id.text);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(SettingBean bean, int position) {
|
||||
itemView.setTag(position);
|
||||
mName.setText(bean.getName());
|
||||
if (bean.getId() == Constants.SETTING_CLEAR_CACHE) {
|
||||
mText.setText(mCacheString);
|
||||
}else if(bean.getId() == 19){
|
||||
mText.setText(BuildConfig.VERSION_NAME);
|
||||
mText.setTextColor(Color.parseColor("#969696"));
|
||||
} else {
|
||||
mText.setText(mVersionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
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.glide.ImgLoader;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.bean.MedalCarBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UserInfoCarAdapter extends RecyclerView.Adapter<UserInfoCarAdapter.Vh> {
|
||||
|
||||
private Context mContext;
|
||||
private List<MedalCarBean.DataBean.InfoBean.CarlistBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
|
||||
public UserInfoCarAdapter(Context context) {
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mList = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setList(List<MedalCarBean.DataBean.InfoBean.CarlistBean> list) {
|
||||
if (list != null && list.size() > 0) {
|
||||
mList.clear();
|
||||
mList.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_medal, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int i) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@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 {
|
||||
|
||||
ImageView ico;
|
||||
TextView name_text;
|
||||
TextView dete_text;
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
ico = itemView.findViewById(R.id.ico);
|
||||
name_text = itemView.findViewById(R.id.name_text);
|
||||
dete_text = itemView.findViewById(R.id.dete_text);
|
||||
}
|
||||
|
||||
void setData(MedalCarBean.DataBean.InfoBean.CarlistBean bean, int position, Object payload) {
|
||||
itemView.setTag(position);
|
||||
name_text.setText(bean.getDress_name());
|
||||
dete_text.setText(bean.getEnd_time());
|
||||
ImgLoader.display(mContext, bean.getDisplay_src(), ico);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
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.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.bean.MedalCarBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UserInfoMedalAdapter extends RecyclerView.Adapter<UserInfoMedalAdapter.Vh> {
|
||||
|
||||
private Context mContext;
|
||||
private List<MedalCarBean.DataBean.InfoBean.MedallistBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
|
||||
public UserInfoMedalAdapter(Context context) {
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mList = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setList(List<MedalCarBean.DataBean.InfoBean.MedallistBean> list) {
|
||||
if (list != null && list.size() > 0) {
|
||||
mList.clear();
|
||||
mList.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_medal, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int i) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@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 {
|
||||
|
||||
ImageView ico;
|
||||
TextView name_text;
|
||||
TextView dete_text;
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
ico = itemView.findViewById(R.id.ico);
|
||||
name_text = itemView.findViewById(R.id.name_text);
|
||||
dete_text = itemView.findViewById(R.id.dete_text);
|
||||
}
|
||||
|
||||
void setData(MedalCarBean.DataBean.InfoBean.MedallistBean bean, int position, Object payload) {
|
||||
itemView.setTag(position);
|
||||
name_text.setText(bean.getDress_name());
|
||||
dete_text.setText(bean.getEnd_time());
|
||||
ImgLoader.display(mContext, bean.getDisplay_src(), ico);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
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.main.R;
|
||||
import com.yunbao.video.bean.VideoBean;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/12/14.
|
||||
*/
|
||||
|
||||
public class VideoHomeAdapter extends RefreshAdapter<VideoBean> {
|
||||
|
||||
private View.OnClickListener mOnClickListener;
|
||||
|
||||
public VideoHomeAdapter(Context context) {
|
||||
super(context);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
int position = (int) tag;
|
||||
VideoBean bean = mList.get(position);
|
||||
if (bean != null && mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, position);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_video_home, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
((Vh) vh).setData(mList.get(position), position);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除视频
|
||||
*/
|
||||
public void deleteVideo(String videoId) {
|
||||
if (TextUtils.isEmpty(videoId)) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0, size = mList.size(); i < size; i++) {
|
||||
if (videoId.equals(mList.get(i).getId())) {
|
||||
notifyItemRemoved(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
ImageView mImg;
|
||||
TextView mNum;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mImg = (ImageView) itemView.findViewById(R.id.img);
|
||||
mNum = (TextView) itemView.findViewById(R.id.num);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(VideoBean bean, int position) {
|
||||
itemView.setTag(position);
|
||||
ImgLoader.display(mContext,bean.getThumb(), mImg);
|
||||
mNum.setText(bean.getViewNum());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
271
main/src/main/java/com/yunbao/main/adapter/ViewHolder.java
Normal file
@@ -0,0 +1,271 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.widget.Checkable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RatingBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder
|
||||
{
|
||||
private SparseArray<View> mViews;
|
||||
private View mConvertView;
|
||||
private Context mContext;
|
||||
|
||||
public ViewHolder(Context context, View itemView)
|
||||
{
|
||||
super(itemView);
|
||||
mContext = context;
|
||||
mConvertView = itemView;
|
||||
mViews = new SparseArray<View>();
|
||||
}
|
||||
|
||||
|
||||
public static ViewHolder createViewHolder(Context context, View itemView)
|
||||
{
|
||||
ViewHolder holder = new ViewHolder(context, itemView);
|
||||
return holder;
|
||||
}
|
||||
|
||||
public static ViewHolder createViewHolder(Context context,
|
||||
ViewGroup parent, int layoutId)
|
||||
{
|
||||
View itemView = LayoutInflater.from(context).inflate(layoutId, parent,
|
||||
false);
|
||||
ViewHolder holder = new ViewHolder(context, itemView);
|
||||
return holder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过viewId获取控件
|
||||
*
|
||||
* @param viewId
|
||||
* @return
|
||||
*/
|
||||
public <T extends View> T getView(int viewId)
|
||||
{
|
||||
View view = mViews.get(viewId);
|
||||
if (view == null)
|
||||
{
|
||||
view = mConvertView.findViewById(viewId);
|
||||
mViews.put(viewId, view);
|
||||
}
|
||||
return (T) view;
|
||||
}
|
||||
|
||||
public View getConvertView()
|
||||
{
|
||||
return mConvertView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/****以下为辅助方法*****/
|
||||
|
||||
/**
|
||||
* 设置TextView的值
|
||||
*
|
||||
* @param viewId
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
public ViewHolder setText(int viewId, String text)
|
||||
{
|
||||
TextView tv = getView(viewId);
|
||||
tv.setText(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setImageResource(int viewId, int resId)
|
||||
{
|
||||
ImageView view = getView(viewId);
|
||||
view.setImageResource(resId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setImageBitmap(int viewId, Bitmap bitmap)
|
||||
{
|
||||
ImageView view = getView(viewId);
|
||||
view.setImageBitmap(bitmap);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setImageDrawable(int viewId, Drawable drawable)
|
||||
{
|
||||
ImageView view = getView(viewId);
|
||||
view.setImageDrawable(drawable);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setBackgroundColor(int viewId, int color)
|
||||
{
|
||||
View view = getView(viewId);
|
||||
view.setBackgroundColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setBackgroundRes(int viewId, int backgroundRes)
|
||||
{
|
||||
View view = getView(viewId);
|
||||
view.setBackgroundResource(backgroundRes);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setTextColor(int viewId, int textColor)
|
||||
{
|
||||
TextView view = getView(viewId);
|
||||
view.setTextColor(textColor);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setTextColorRes(int viewId, int textColorRes)
|
||||
{
|
||||
TextView view = getView(viewId);
|
||||
view.setTextColor(mContext.getResources().getColor(textColorRes));
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public ViewHolder setAlpha(int viewId, float value)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
{
|
||||
getView(viewId).setAlpha(value);
|
||||
} else
|
||||
{
|
||||
// Pre-honeycomb hack to set Alpha value
|
||||
AlphaAnimation alpha = new AlphaAnimation(value, value);
|
||||
alpha.setDuration(0);
|
||||
alpha.setFillAfter(true);
|
||||
getView(viewId).startAnimation(alpha);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setVisible(int viewId, boolean visible)
|
||||
{
|
||||
View view = getView(viewId);
|
||||
view.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder linkify(int viewId)
|
||||
{
|
||||
TextView view = getView(viewId);
|
||||
Linkify.addLinks(view, Linkify.ALL);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setTypeface(Typeface typeface, int... viewIds)
|
||||
{
|
||||
for (int viewId : viewIds)
|
||||
{
|
||||
TextView view = getView(viewId);
|
||||
view.setTypeface(typeface);
|
||||
view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setProgress(int viewId, int progress)
|
||||
{
|
||||
ProgressBar view = getView(viewId);
|
||||
view.setProgress(progress);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setProgress(int viewId, int progress, int max)
|
||||
{
|
||||
ProgressBar view = getView(viewId);
|
||||
view.setMax(max);
|
||||
view.setProgress(progress);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setMax(int viewId, int max)
|
||||
{
|
||||
ProgressBar view = getView(viewId);
|
||||
view.setMax(max);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setRating(int viewId, float rating)
|
||||
{
|
||||
RatingBar view = getView(viewId);
|
||||
view.setRating(rating);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setRating(int viewId, float rating, int max)
|
||||
{
|
||||
RatingBar view = getView(viewId);
|
||||
view.setMax(max);
|
||||
view.setRating(rating);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setTag(int viewId, Object tag)
|
||||
{
|
||||
View view = getView(viewId);
|
||||
view.setTag(tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setTag(int viewId, int key, Object tag)
|
||||
{
|
||||
View view = getView(viewId);
|
||||
view.setTag(key, tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setChecked(int viewId, boolean checked)
|
||||
{
|
||||
Checkable view = (Checkable) getView(viewId);
|
||||
view.setChecked(checked);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关于事件的
|
||||
*/
|
||||
public ViewHolder setOnClickListener(int viewId,
|
||||
View.OnClickListener listener)
|
||||
{
|
||||
View view = getView(viewId);
|
||||
view.setOnClickListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setOnTouchListener(int viewId,
|
||||
View.OnTouchListener listener)
|
||||
{
|
||||
View view = getView(viewId);
|
||||
view.setOnTouchListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewHolder setOnLongClickListener(int viewId,
|
||||
View.OnLongClickListener listener)
|
||||
{
|
||||
View view = getView(viewId);
|
||||
view.setOnLongClickListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
27
main/src/main/java/com/yunbao/main/bean/BonusBean.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.yunbao.main.bean;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/30.
|
||||
* 签到奖励实体类
|
||||
*/
|
||||
|
||||
public class BonusBean {
|
||||
private int day;
|
||||
private String coin;
|
||||
|
||||
public int getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
public void setDay(int day) {
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
public String getCoin() {
|
||||
return coin;
|
||||
}
|
||||
|
||||
public void setCoin(String coin) {
|
||||
this.coin = coin;
|
||||
}
|
||||
}
|
||||
78
main/src/main/java/com/yunbao/main/bean/CashAccountBean.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package com.yunbao.main.bean;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/20.
|
||||
*/
|
||||
|
||||
public class CashAccountBean {
|
||||
|
||||
private String id;
|
||||
private String uid;
|
||||
private int type;
|
||||
private String bankName;
|
||||
private String userName;
|
||||
private String account;
|
||||
private boolean checked;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@JSONField(name = "account_bank")
|
||||
public String getBankName() {
|
||||
return bankName;
|
||||
}
|
||||
|
||||
@JSONField(name = "account_bank")
|
||||
public void setBankName(String bankName) {
|
||||
this.bankName = bankName;
|
||||
}
|
||||
|
||||
@JSONField(name = "name")
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
@JSONField(name = "name")
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.yunbao.main.bean;
|
||||
|
||||
/**
|
||||
* Created by CHen Haoxuan on 2022/3/25.
|
||||
* 社区送礼 实体类
|
||||
*/
|
||||
|
||||
public class EncourageGiftBean {
|
||||
private String gift_id;
|
||||
private String gift_type;
|
||||
private String gift_price;
|
||||
private String gift_img;
|
||||
private String gift_name;
|
||||
|
||||
private String user_id;
|
||||
private String user_name;
|
||||
private String user_avatar;
|
||||
private String gift_num;
|
||||
|
||||
public String getGift_num() {
|
||||
return gift_num;
|
||||
}
|
||||
|
||||
public void setGift_num(String gift_num) {
|
||||
this.gift_num = gift_num;
|
||||
}
|
||||
|
||||
public String getUser_id() {
|
||||
return user_id;
|
||||
}
|
||||
|
||||
public void setUser_id(String user_id) {
|
||||
this.user_id = user_id;
|
||||
}
|
||||
|
||||
public String getUser_name() {
|
||||
return user_name;
|
||||
}
|
||||
|
||||
public void setUser_name(String user_name) {
|
||||
this.user_name = user_name;
|
||||
}
|
||||
|
||||
public String getUser_avatar() {
|
||||
return user_avatar;
|
||||
}
|
||||
|
||||
public void setUser_avatar(String user_avatar) {
|
||||
this.user_avatar = user_avatar;
|
||||
}
|
||||
|
||||
public String getGift_id() {
|
||||
return gift_id;
|
||||
}
|
||||
|
||||
public void setGift_id(String gift_id) {
|
||||
this.gift_id = gift_id;
|
||||
}
|
||||
|
||||
public String getGift_type() {
|
||||
return gift_type;
|
||||
}
|
||||
|
||||
public void setGift_type(String gift_type) {
|
||||
this.gift_type = gift_type;
|
||||
}
|
||||
|
||||
public String getGift_price() {
|
||||
return gift_price;
|
||||
}
|
||||
|
||||
public void setGift_price(String gift_price) {
|
||||
this.gift_price = gift_price;
|
||||
}
|
||||
|
||||
public String getGift_img() {
|
||||
return gift_img;
|
||||
}
|
||||
|
||||
public void setGift_img(String gift_img) {
|
||||
this.gift_img = gift_img;
|
||||
}
|
||||
|
||||
public String getGift_name() {
|
||||
return gift_name;
|
||||
}
|
||||
|
||||
public void setGift_name(String gift_name) {
|
||||
this.gift_name = gift_name;
|
||||
}
|
||||
}
|
||||
238
main/src/main/java/com/yunbao/main/bean/HomeTopBean.java
Normal file
@@ -0,0 +1,238 @@
|
||||
package com.yunbao.main.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HomeTopBean {
|
||||
|
||||
|
||||
private List<ProfitListBean> ProfitList;
|
||||
private List<ConsumeListBean> consumeList;
|
||||
|
||||
public List<ProfitListBean> getProfitList() {
|
||||
return ProfitList;
|
||||
}
|
||||
|
||||
public void setProfitList(List<ProfitListBean> ProfitList) {
|
||||
this.ProfitList = ProfitList;
|
||||
}
|
||||
|
||||
public List<ConsumeListBean> getConsumeList() {
|
||||
return consumeList;
|
||||
}
|
||||
|
||||
public void setConsumeList(List<ConsumeListBean> consumeList) {
|
||||
this.consumeList = consumeList;
|
||||
}
|
||||
|
||||
public static class ProfitListBean {
|
||||
/**
|
||||
* avatar : http://www.pdlive.com/data/upload/20210306/604315304ef23.png
|
||||
* avatar_thumb : http://www.pdlive.com/data/upload/20210306/604315304ef23.png
|
||||
* isAttention : 1
|
||||
* islive : 0
|
||||
* level : 20
|
||||
* level_anchor : 10
|
||||
* sex : 1
|
||||
* totalcoin : 254834549
|
||||
* uid : 31736
|
||||
* user_nicename : ~~~是
|
||||
*/
|
||||
|
||||
private String avatar;
|
||||
private String avatar_thumb;
|
||||
private String isAttention;
|
||||
private String islive;
|
||||
private String level;
|
||||
private String level_anchor;
|
||||
private String sex;
|
||||
private String totalcoin;
|
||||
private String uid;
|
||||
private String user_nicename;
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getAvatar_thumb() {
|
||||
return avatar_thumb;
|
||||
}
|
||||
|
||||
public void setAvatar_thumb(String avatar_thumb) {
|
||||
this.avatar_thumb = avatar_thumb;
|
||||
}
|
||||
|
||||
public String getIsAttention() {
|
||||
return isAttention;
|
||||
}
|
||||
|
||||
public void setIsAttention(String isAttention) {
|
||||
this.isAttention = isAttention;
|
||||
}
|
||||
|
||||
public String getIslive() {
|
||||
return islive;
|
||||
}
|
||||
|
||||
public void setIslive(String islive) {
|
||||
this.islive = islive;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getLevel_anchor() {
|
||||
return level_anchor;
|
||||
}
|
||||
|
||||
public void setLevel_anchor(String level_anchor) {
|
||||
this.level_anchor = level_anchor;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getTotalcoin() {
|
||||
return totalcoin;
|
||||
}
|
||||
|
||||
public void setTotalcoin(String totalcoin) {
|
||||
this.totalcoin = totalcoin;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public String getUser_nicename() {
|
||||
return user_nicename;
|
||||
}
|
||||
|
||||
public void setUser_nicename(String user_nicename) {
|
||||
this.user_nicename = user_nicename;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConsumeListBean {
|
||||
/**
|
||||
* avatar : http://www.pdlive.com/default.jpg
|
||||
* avatar_thumb : http://www.pdlive.com/default_thumb.jpg
|
||||
* isAttention : 0
|
||||
* islive : 0
|
||||
* level : 17
|
||||
* level_anchor : 1
|
||||
* sex : 2
|
||||
* totalcoin : 254608379
|
||||
* uid : 31735
|
||||
* user_nicename : 手机用户4196
|
||||
*/
|
||||
|
||||
private String avatar;
|
||||
private String avatar_thumb;
|
||||
private String isAttention;
|
||||
private String islive;
|
||||
private String level;
|
||||
private String level_anchor;
|
||||
private String sex;
|
||||
private String totalcoin;
|
||||
private String uid;
|
||||
private String user_nicename;
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getAvatar_thumb() {
|
||||
return avatar_thumb;
|
||||
}
|
||||
|
||||
public void setAvatar_thumb(String avatar_thumb) {
|
||||
this.avatar_thumb = avatar_thumb;
|
||||
}
|
||||
|
||||
public String getIsAttention() {
|
||||
return isAttention;
|
||||
}
|
||||
|
||||
public void setIsAttention(String isAttention) {
|
||||
this.isAttention = isAttention;
|
||||
}
|
||||
|
||||
public String getIslive() {
|
||||
return islive;
|
||||
}
|
||||
|
||||
public void setIslive(String islive) {
|
||||
this.islive = islive;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getLevel_anchor() {
|
||||
return level_anchor;
|
||||
}
|
||||
|
||||
public void setLevel_anchor(String level_anchor) {
|
||||
this.level_anchor = level_anchor;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getTotalcoin() {
|
||||
return totalcoin;
|
||||
}
|
||||
|
||||
public void setTotalcoin(String totalcoin) {
|
||||
this.totalcoin = totalcoin;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public String getUser_nicename() {
|
||||
return user_nicename;
|
||||
}
|
||||
|
||||
public void setUser_nicename(String user_nicename) {
|
||||
this.user_nicename = user_nicename;
|
||||
}
|
||||
}
|
||||
}
|
||||
119
main/src/main/java/com/yunbao/main/bean/ListBean.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package com.yunbao.main.bean;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/2/2.
|
||||
* 排行榜实体类
|
||||
*/
|
||||
|
||||
public class ListBean {
|
||||
|
||||
private long totalCoin;
|
||||
private String uid;
|
||||
private String userNiceName;
|
||||
private String avatarThumb;
|
||||
private int sex;
|
||||
private int levelAnchor;
|
||||
private int level;
|
||||
private int attention;
|
||||
private int islive;
|
||||
private String dress_head;
|
||||
|
||||
@JSONField(name = "dress_head")
|
||||
public String getDress_head() {
|
||||
return dress_head;
|
||||
}
|
||||
@JSONField(name = "dress_head")
|
||||
public void setDress_head(String dress_head) {
|
||||
this.dress_head = dress_head;
|
||||
}
|
||||
|
||||
@JSONField(name = "islive")
|
||||
public int getIslive() {
|
||||
return islive;
|
||||
}
|
||||
|
||||
@JSONField(name = "islive")
|
||||
public void setIslive(int islive) {
|
||||
this.islive = islive;
|
||||
}
|
||||
|
||||
@JSONField(name = "totalcoin")
|
||||
public long getTotalCoin() {
|
||||
return totalCoin;
|
||||
}
|
||||
|
||||
@JSONField(name = "totalcoin")
|
||||
public void setTotalCoin(long totalCoin) {
|
||||
this.totalCoin = totalCoin;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
@JSONField(name = "user_nicename")
|
||||
public String getUserNiceName() {
|
||||
return userNiceName;
|
||||
}
|
||||
|
||||
@JSONField(name = "user_nicename")
|
||||
public void setUserNiceName(String userNiceName) {
|
||||
this.userNiceName = userNiceName;
|
||||
}
|
||||
|
||||
@JSONField(name = "avatar_thumb")
|
||||
public String getAvatarThumb() {
|
||||
return avatarThumb;
|
||||
}
|
||||
|
||||
@JSONField(name = "avatar_thumb")
|
||||
public void setAvatarThumb(String avatarThumb) {
|
||||
this.avatarThumb = avatarThumb;
|
||||
}
|
||||
|
||||
public int getLevelAnchor() {
|
||||
return levelAnchor;
|
||||
}
|
||||
|
||||
public void setLevelAnchor(int levelAnchor) {
|
||||
this.levelAnchor = levelAnchor;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@JSONField(name = "isAttention")
|
||||
public int getAttention() {
|
||||
return attention;
|
||||
}
|
||||
|
||||
@JSONField(name = "isAttention")
|
||||
public void setAttention(int attention) {
|
||||
this.attention = attention;
|
||||
}
|
||||
|
||||
public String getTotalCoinFormat() {
|
||||
//return StringUtil.toWan(this.totalCoin);
|
||||
return String.valueOf(this.totalCoin);
|
||||
}
|
||||
|
||||
|
||||
public int getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(int sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
}
|
||||
169
main/src/main/java/com/yunbao/main/bean/MedalCarBean.java
Normal file
@@ -0,0 +1,169 @@
|
||||
package com.yunbao.main.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MedalCarBean {
|
||||
|
||||
/**
|
||||
* ret : 200
|
||||
* data : {"code":0,"msg":"","info":{"medallist":[{"display_src":"https://qny.shayucm.com/dress/%23160.png","dress_name":"2021年6月公会赛奖励","end_time":"14天"}],"carlist":[{"display_src":"/data/upload/20210608/60bf057a55f24.png","dress_name":"这是坐骑,用的以前的","end_time":"14天"}]}}
|
||||
* msg :
|
||||
*/
|
||||
|
||||
private int ret;
|
||||
private DataBean data;
|
||||
private String msg;
|
||||
|
||||
public int getRet() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setRet(int ret) {
|
||||
this.ret = ret;
|
||||
}
|
||||
|
||||
public DataBean getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(DataBean data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static class DataBean {
|
||||
/**
|
||||
* code : 0
|
||||
* msg :
|
||||
* info : {"medallist":[{"display_src":"https://qny.shayucm.com/dress/%23160.png","dress_name":"2021年6月公会赛奖励","end_time":"14天"}],"carlist":[{"display_src":"/data/upload/20210608/60bf057a55f24.png","dress_name":"这是坐骑,用的以前的","end_time":"14天"}]}
|
||||
*/
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
private InfoBean info;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public InfoBean getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(InfoBean info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public static class InfoBean {
|
||||
private List<MedallistBean> medallist;
|
||||
private List<CarlistBean> carlist;
|
||||
|
||||
public List<MedallistBean> getMedallist() {
|
||||
return medallist;
|
||||
}
|
||||
|
||||
public void setMedallist(List<MedallistBean> medallist) {
|
||||
this.medallist = medallist;
|
||||
}
|
||||
|
||||
public List<CarlistBean> getCarlist() {
|
||||
return carlist;
|
||||
}
|
||||
|
||||
public void setCarlist(List<CarlistBean> carlist) {
|
||||
this.carlist = carlist;
|
||||
}
|
||||
|
||||
public static class MedallistBean {
|
||||
/**
|
||||
* display_src : https://qny.shayucm.com/dress/%23160.png
|
||||
* dress_name : 2021年6月公会赛奖励
|
||||
* end_time : 14天
|
||||
*/
|
||||
|
||||
private String display_src;
|
||||
private String dress_name;
|
||||
private String end_time;
|
||||
|
||||
public String getDisplay_src() {
|
||||
return display_src;
|
||||
}
|
||||
|
||||
public void setDisplay_src(String display_src) {
|
||||
this.display_src = display_src;
|
||||
}
|
||||
|
||||
public String getDress_name() {
|
||||
return dress_name;
|
||||
}
|
||||
|
||||
public void setDress_name(String dress_name) {
|
||||
this.dress_name = dress_name;
|
||||
}
|
||||
|
||||
public String getEnd_time() {
|
||||
return end_time;
|
||||
}
|
||||
|
||||
public void setEnd_time(String end_time) {
|
||||
this.end_time = end_time;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CarlistBean {
|
||||
/**
|
||||
* display_src : /data/upload/20210608/60bf057a55f24.png
|
||||
* dress_name : 这是坐骑,用的以前的
|
||||
* end_time : 14天
|
||||
*/
|
||||
|
||||
private String display_src;
|
||||
private String dress_name;
|
||||
private String end_time;
|
||||
|
||||
public String getDisplay_src() {
|
||||
return display_src;
|
||||
}
|
||||
|
||||
public void setDisplay_src(String display_src) {
|
||||
this.display_src = display_src;
|
||||
}
|
||||
|
||||
public String getDress_name() {
|
||||
return dress_name;
|
||||
}
|
||||
|
||||
public void setDress_name(String dress_name) {
|
||||
this.dress_name = dress_name;
|
||||
}
|
||||
|
||||
public String getEnd_time() {
|
||||
return end_time;
|
||||
}
|
||||
|
||||
public void setEnd_time(String end_time) {
|
||||
this.end_time = end_time;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
88
main/src/main/java/com/yunbao/main/bean/RecommendBean.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package com.yunbao.main.bean;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/11/2.
|
||||
*/
|
||||
|
||||
public class RecommendBean {
|
||||
|
||||
private String id;
|
||||
private String userNiceName;
|
||||
private String avatar;
|
||||
private String avatarThumb;
|
||||
private String fans;
|
||||
private String attention;
|
||||
private boolean checked;
|
||||
|
||||
public RecommendBean() {
|
||||
this.checked = true;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@JSONField(name = "user_nicename")
|
||||
public String getUserNiceName() {
|
||||
return userNiceName;
|
||||
}
|
||||
|
||||
@JSONField(name = "user_nicename")
|
||||
public void setUserNiceName(String userNiceName) {
|
||||
this.userNiceName = userNiceName;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
@JSONField(name = "avatar_thumb")
|
||||
public String getAvatarThumb() {
|
||||
return avatarThumb;
|
||||
}
|
||||
|
||||
@JSONField(name = "avatar_thumb")
|
||||
public void setAvatarThumb(String avatarThumb) {
|
||||
this.avatarThumb = avatarThumb;
|
||||
}
|
||||
|
||||
public String getFans() {
|
||||
return fans;
|
||||
}
|
||||
|
||||
public void setFans(String fans) {
|
||||
this.fans = fans;
|
||||
}
|
||||
|
||||
@JSONField(name = "isattention")
|
||||
public String getAttention() {
|
||||
return attention;
|
||||
}
|
||||
|
||||
@JSONField(name = "isattention")
|
||||
public void setAttention(String attention) {
|
||||
this.attention = attention;
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
public void toggleChecked() {
|
||||
this.checked = !this.checked;
|
||||
}
|
||||
}
|
||||
54
main/src/main/java/com/yunbao/main/bean/SettingBean.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.yunbao.main.bean;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/30.
|
||||
*/
|
||||
|
||||
public class SettingBean {
|
||||
private int id;
|
||||
private String name;
|
||||
private String thumb;
|
||||
private String href;
|
||||
private boolean last;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getThumb() {
|
||||
return thumb;
|
||||
}
|
||||
|
||||
public void setThumb(String thumb) {
|
||||
this.thumb = thumb;
|
||||
}
|
||||
|
||||
public String getHref() {
|
||||
return href;
|
||||
}
|
||||
|
||||
public void setHref(String href) {
|
||||
this.href = href;
|
||||
}
|
||||
|
||||
public boolean isLast() {
|
||||
return last;
|
||||
}
|
||||
|
||||
public void setLast(boolean last) {
|
||||
this.last = last;
|
||||
}
|
||||
|
||||
}
|
||||
36
main/src/main/java/com/yunbao/main/bean/UserHomeConBean.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.yunbao.main.bean;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/18.
|
||||
*/
|
||||
|
||||
public class UserHomeConBean {
|
||||
|
||||
private String uid;
|
||||
private String total;
|
||||
private String avatar;
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public String getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(String total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
}
|
||||
34
main/src/main/java/com/yunbao/main/custom/BonusItemView.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.yunbao.main.custom;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.yunbao.common.custom.RatioImageView;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/1.
|
||||
*/
|
||||
|
||||
public class BonusItemView extends RatioImageView {
|
||||
public BonusItemView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public BonusItemView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public BonusItemView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
if (checked) {
|
||||
setImageResource(R.mipmap.icon_bonus_1);
|
||||
} else {
|
||||
setImageDrawable(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
main/src/main/java/com/yunbao/main/dialog/BlankDialog.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.yunbao.main.dialog;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yunbao.main.R;
|
||||
|
||||
public class BlankDialog extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//通过参数中的布局填充获取对应布局
|
||||
View view = inflater.inflate(R.layout.fg_dialog_blank, container, false);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||