Compare commits
137 Commits
master_融云升
...
有聊合并PD
| Author | SHA1 | Date | |
|---|---|---|---|
| 73cdf9ca43 | |||
| 37d2f0b975 | |||
| f15c609f1c | |||
| 526e05f554 | |||
| 217eb0bd41 | |||
| 08445012e8 | |||
| 74bcde8911 | |||
| 48b30868f4 | |||
| 23a2a2efb3 | |||
|
|
6d3ece2307 | ||
| be6cfd4464 | |||
| 5c311b4309 | |||
| 75c71cb437 | |||
| 19ab654342 | |||
|
|
9795d46941 | ||
|
|
f78ba226f9 | ||
| 4217da241d | |||
| c42c757001 | |||
|
|
83758f39b1 | ||
| 6e04287132 | |||
|
|
765448197e | ||
|
|
56bc86b936 | ||
| c4473f2b16 | |||
|
|
4dbcd36f56 | ||
|
|
9c2d488764 | ||
|
|
ad7ab6bcf2 | ||
|
|
038e733b80 | ||
| c978b7feac | |||
|
|
09bb0a606a | ||
|
|
ab2275d93b | ||
| 18588bed7e | |||
| c530db25d5 | |||
| 43362d3800 | |||
| d95df4b1a8 | |||
| 1dd19405bc | |||
| db8296543e | |||
| c2755cda8a | |||
|
|
b907057c3e | ||
|
|
389f33db1f | ||
|
|
ac7a491f57 | ||
| 9aa8b22d99 | |||
|
|
f36c4706e4 | ||
| 79e772ce4b | |||
| f5849a3ca2 | |||
|
|
cdc0211999 | ||
| 0d52db8edb | |||
| 479a7b8d33 | |||
|
|
eddf3a8fe2 | ||
| f7b6f75865 | |||
| ba456a007b | |||
| a8462b385a | |||
|
|
4a09f629f3 | ||
|
|
6c224d66ed | ||
| e00df4d8e5 | |||
| 76afa04643 | |||
| 9d0f8cb060 | |||
|
|
4bd1e8eccc | ||
| 430c24db05 | |||
| aa6c06927b | |||
| 56dff48462 | |||
| 71147b655d | |||
|
|
292dcaa9e4 | ||
|
|
d0ae3c49d4 | ||
| d34e30c291 | |||
| 06a2621e0f | |||
| 2e14f6979d | |||
|
|
3735616af5 | ||
| 2d456c0afd | |||
| 06f0e59c70 | |||
|
|
07f7a28d0a | ||
| ea44969bd7 | |||
| 307ec30807 | |||
|
|
3189b39b97 | ||
|
|
64fb7de187 | ||
|
|
617086cf40 | ||
|
|
f7de908057 | ||
|
|
d2ba1ed570 | ||
|
|
b90a8a69f5 | ||
|
|
758b87e426 | ||
|
|
d7e4ad9aca | ||
| be02488180 | |||
|
|
ebeb276bb1 | ||
| d3ab50e844 | |||
| 0935f76bac | |||
| 0b28dd94d1 | |||
|
|
df20d942d5 | ||
|
|
dff84a30e4 | ||
|
|
0287995bf9 | ||
|
|
bcfd1c22e6 | ||
|
|
38471cedc8 | ||
|
|
f22ad82d84 | ||
| 4ff1089549 | |||
|
|
9e68f35627 | ||
|
|
1a36077fba | ||
| d4305708f4 | |||
|
|
4f5085fc85 | ||
|
|
1f0cdd86a4 | ||
|
|
d2639ceb6a | ||
| 0ea00b2b64 | |||
| 6b992eefe4 | |||
|
|
da6782c7b0 | ||
|
|
52d565c4ee | ||
|
|
9ae47dffc2 | ||
| 6211756744 | |||
| 0c5533ffb3 | |||
| 427d10158b | |||
| abeb92ab51 | |||
| fb5fc83727 | |||
| 5ee72410b7 | |||
| 0706611df8 | |||
| 095574296f | |||
| 1424ff61e1 | |||
| 24d93f2604 | |||
| 729270c3d0 | |||
| fd377b5280 | |||
| 6d495d11fd | |||
| da6ca4fbbb | |||
| 676aba70e7 | |||
| 2bdc95b3b5 | |||
| 1950da12e6 | |||
|
|
74ec0a8713 | ||
|
|
26a4db55ed | ||
| 05d4f84844 | |||
| e4cd95951c | |||
|
|
05f598fd22 | ||
|
|
2db7cf9980 | ||
|
|
e4a5e4e814 | ||
| e7ce538d78 | |||
|
|
cd74b7140e | ||
|
|
e3fc7786a8 | ||
| 15d230e084 | |||
| d82f89f11c | |||
|
|
41b5ab93dc | ||
| 2602725320 | |||
| 2976177e92 | |||
| 93acf4c8c6 | |||
| d74d8d7e2f |
1
OneToOne/.gitignore
vendored
Normal file
1
OneToOne/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
61
OneToOne/README.md
Normal file
61
OneToOne/README.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# 项目结构
|
||||
- `app` PDLive入口
|
||||
- `baidu` 百度模块,废弃
|
||||
- `beauty` 旧美颜模块,废弃
|
||||
- `common` 公共模块
|
||||
- `FaceUnity` 美颜模块
|
||||
- `lib_country_code` 不管他
|
||||
- `live` PDLive直播模块
|
||||
- `main` PDLive主页模块
|
||||
- `OneToOne` 1v1入口*
|
||||
- `pluginsForAnchor` PDLive插件化打包模块
|
||||
- `Share` PDLive分享模块
|
||||
- `TabLayout` [滑动翻页库模块](!https://github.com/angcyo/DslTabLayout)
|
||||
- `video` PDLive 视频模块
|
||||
- `ViewPager2Delegate` [滑动翻页附属模块](!https://github.com/angcyo/DslTabLayout)
|
||||
# 运行说明
|
||||
Gradle版本:
|
||||
distributionUrl=`https://services.gradle.org/distributions/gradle-6.1.1-all.zip`
|
||||
|
||||
jdk版本:`11.0.2`
|
||||
|
||||
AndroidStudio版本:`Android Studio Giraffe | 2022.3.1 Patch 2`
|
||||
|
||||
### 若无法编译请检查`gradle.properties`的代理设置
|
||||
|
||||
# 1V1项目介绍
|
||||
## [项目文档](!https://alidocs.dingtalk.com/i/nodes/YQBnd5ExVEw1DlvwFNaZElK48yeZqMmz?utm_scene=person_space)
|
||||
## [蓝图](!https://lanhuapp.com/web/#/item/project/stage?tid=a589c634-a1c0-415a-9691-7bad6c77312c&pid=be2586b6-6583-4447-ac83-bf9669ad4854)
|
||||
|
||||
## 1v1项目结构
|
||||
|
||||
- `activity` 页面
|
||||
- - `fragments`
|
||||
- - - `message` 消息页面外层内容
|
||||
- - `message` 消息页面独立Activity
|
||||
- `adapter` 适配器
|
||||
- `bean` 数据Bean类
|
||||
- `dialog` 对话框类
|
||||
- `network` 网络请求
|
||||
- `manager` 单例模式
|
||||
- `utils` 工具类
|
||||
- `AppContext` Application
|
||||
|
||||
### 项目说明
|
||||
[即时通讯(IM)融云SDK](!https://doc.rongcloud.cn/im/Android/5.X/ui/init)
|
||||
|
||||
[实时音视频融云SDK](!https://doc.rongcloud.cn/call/Android/5.X/callkit/init)
|
||||
|
||||
Activity 跳转用Route模块,参考`RouteManager`和`MainActivity`
|
||||
|
||||
网络请求使用`OTONetManager`
|
||||
图片加载使用`ImgLoader.display(Context context, String url, ImageView imageView)`
|
||||
|
||||
### 签名文件
|
||||
签名暂时共享PDLive项目签名,用根目录下的`hdl.jks`,其余参考`build.gradle`文件
|
||||
|
||||
### APP账号密码
|
||||
运行PDLive项目,注册即可,暂时共用
|
||||
|
||||
### 混淆
|
||||
暂不混淆
|
||||
215
OneToOne/build.gradle
Normal file
215
OneToOne/build.gradle
Normal file
@@ -0,0 +1,215 @@
|
||||
apply plugin: 'com.android.application'
|
||||
//apply plugin: 'com.android.library'
|
||||
apply plugin: 'img-optimizer'
|
||||
apply plugin: 'com.alibaba.arouter'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
|
||||
android {
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
// Or, if you prefer, you can continue to check for errors in release builds,
|
||||
// but continue the build even when errors are found:
|
||||
abortOnError false
|
||||
}
|
||||
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"
|
||||
//旧美颜so
|
||||
exclude 'lib/arm64-v8a/libxeengine.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_base.so'
|
||||
exclude 'lib/arm64-v8a/libmmcrypto.so'
|
||||
exclude 'lib/arm64-v8a/libMNN.so'
|
||||
pickFirst 'lib/arm64-v8a/libc++_shared.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_base.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_beauty.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_bodylandmark.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_express.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_faceattributes.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_facefeatures.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_faceprocessor.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_facerecognition.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_handgesture.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_imagequality.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_objectdetect.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_segmentation.so'
|
||||
exclude 'lib/arm64-v8a/libmmcv_api_videoprocessor.so'
|
||||
exclude 'lib/arm64-v8a/libmmlic.so'
|
||||
exclude 'lib/arm64-v8a/libMNN_CL.so'
|
||||
exclude 'lib/arm64-v8a/libMNN_Express.so'
|
||||
exclude 'lib/armeabi-v7a/libxeengine.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_base.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcrypto.so'
|
||||
exclude 'lib/armeabi-v7a/libMNN.so'
|
||||
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_base.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_beauty.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_bodylandmark.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_express.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_faceattributes.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_facefeatures.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_faceprocessor.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_facerecognition.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_handgesture.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_imagequality.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_objectdetect.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_segmentation.so'
|
||||
exclude 'lib/armeabi-v7a/libmmcv_api_videoprocessor.so'
|
||||
exclude 'lib/armeabi-v7a/libmmlic.so'
|
||||
exclude 'lib/armeabi-v7a/libMNN_CL.so'
|
||||
exclude 'lib/armeabi-v7a/libMNN_Express.so'
|
||||
//美颜
|
||||
if (rootProject.ext.manifestPlaceholders.isPluginModel) {
|
||||
exclude 'lib/armeabi-v7a/libCNamaSDK.so'
|
||||
exclude 'lib/arm64-v8a/libCNamaSDK.so'
|
||||
exclude 'lib/armeabi-v7a/libfuai.so'
|
||||
exclude 'lib/arm64-v8a/libfuai.so'
|
||||
}
|
||||
|
||||
}
|
||||
applicationVariants.all { variant ->
|
||||
String variantName = variant.name.capitalize()
|
||||
def processManifestTask = project.tasks.getByName("process${variantName}Manifest")
|
||||
processManifestTask.doLast { pm ->
|
||||
String manifestPath = "build/intermediates/bundle_manifest/release/bundle-manifest/AndroidManifest.xml"
|
||||
def isGooglePlay = rootProject.ext.manifestPlaceholders.isGooglePlay
|
||||
if (file(manifestPath).exists() && isGooglePlay) {
|
||||
def manifestContent = file(manifestPath).getText()
|
||||
|
||||
manifestContent = manifestContent.replace('<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />', '')
|
||||
file(manifestPath).write(manifestContent)
|
||||
} else {
|
||||
print "not Exists = " + manifestPath
|
||||
}
|
||||
}
|
||||
|
||||
variant.outputs.all {
|
||||
|
||||
outputFileName = "[${new Date().format("MM-dd", TimeZone.getTimeZone("GMT+8"))}]友聊-${rootProject.ext.android.otoversionName}-${variant.buildType.name}.apk"
|
||||
|
||||
}
|
||||
}
|
||||
defaultConfig {
|
||||
//applicationId "com.shayu.onetoonenew"
|
||||
applicationId "com.pdlive.shayu"
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode rootProject.ext.android.otoversionCode
|
||||
versionName rootProject.ext.android.otoversionName
|
||||
manifestPlaceholders = rootProject.ext.manifestPlaceholders
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "arm64-v8a"
|
||||
}
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
}
|
||||
}
|
||||
}
|
||||
aaptOptions {
|
||||
cruncherEnabled = false
|
||||
useNewCruncher = false
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
keyAlias 'phonelive'
|
||||
keyPassword 'phonelive'
|
||||
storeFile file('../hdl.jks')
|
||||
storePassword 'phonelive'
|
||||
}
|
||||
debug {
|
||||
keyAlias 'phonelive'
|
||||
keyPassword 'phonelive'
|
||||
storeFile file('../hdl.jks')
|
||||
storePassword 'phonelive'
|
||||
}
|
||||
//陌陌本地配置需要
|
||||
config {//TODO BEAUTYSDK 这里需要配置keystore相关信息
|
||||
keyAlias 'phonelive'
|
||||
keyPassword 'phonelive'
|
||||
storeFile file('../hdl.jks')//keystore的存放路径
|
||||
storePassword 'phonelive'
|
||||
v2SigningEnabled true // android 5.0-8.0,必须用V2,否则会有安全问题
|
||||
v1SigningEnabled true
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
zipAlignEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
debug {
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
zipAlignEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
flatDir {
|
||||
dirs 'libs', '../libs'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation rootProject.ext.dependencies["recyclerview-androidx"]
|
||||
implementation project(path: ':lib_country_code')
|
||||
annotationProcessor rootProject.ext.dependencies["arouter-compiler"]
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
implementation platform('com.google.firebase:firebase-bom:30.5.0')
|
||||
implementation 'com.google.firebase:firebase-crashlytics'
|
||||
//common
|
||||
api project(path: ':common')
|
||||
//api project(path:':FaceUnity')//新娱美颜
|
||||
api project(path:':Share')
|
||||
api project(path:':main')
|
||||
|
||||
api project(path:':TabLayout')
|
||||
api project(path:':ViewPager2Delegate')
|
||||
api project(path:':callkit')//// 音视频通话能力 UI 组件
|
||||
//implementation 'com.github.angcyo.DslTablayout:TabLayout:3.5.5'
|
||||
//可选
|
||||
//implementation 'com.github.angcyo.DslTablayout:ViewPager2Delegate:3.5.5'
|
||||
|
||||
//ExoPlayer,腾讯的播放器不支持无缝切换
|
||||
implementation 'com.google.android.exoplayer:exoplayer:2.18.5'
|
||||
implementation 'com.google.android.exoplayer:exoplayer-core:2.18.5@aar'
|
||||
|
||||
// implementation 'cn.rongcloud.sdk:call_kit:5.5.0' // 音视频通话能力 UI 组件
|
||||
implementation 'com.github.luqiming666:SwipeRecyclerView:1.4.8'//支持侧滑删除
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
implementation 'com.blankj:utilcode:1.30.0'//獲取uuid
|
||||
implementation 'com.google.android.flexbox:flexbox:3.0.0'//自动换行框架
|
||||
|
||||
}
|
||||
0
OneToOne/consumer-rules.pro
Normal file
0
OneToOne/consumer-rules.pro
Normal file
63
OneToOne/google-services-oto.json
Normal file
63
OneToOne/google-services-oto.json
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "903482201540",
|
||||
"project_id": "onetoone-71170",
|
||||
"storage_bucket": "onetoone-71170.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:903482201540:android:132978cdf497f4d8634091",
|
||||
"android_client_info": {
|
||||
"package_name": "com.shayu.onetoonenew"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "903482201540-ddno3ro8fp0lqqoeodbhbnpqf7f8d439.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.shayu.onetoonenew",
|
||||
"certificate_hash": "b66dc8d21cfcf6c729577ddcf0c312b2a31ed872"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "903482201540-e9ua9huoejtubp7pgsbu3iq76tqkoorp.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.shayu.onetoonenew",
|
||||
"certificate_hash": "15fc5e70cf238323bf7111c8c627803985478e87"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "903482201540-k3cffuuhsed23kkiuopufhf54ano7do4.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.shayu.onetoonenew",
|
||||
"certificate_hash": "38cc19306c9facee36a9224e9a4070bc0be15c7d"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "903482201540-s2j96h6k7go0ah51ksi7es8mt7qhankh.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyCrhj-7WjwdYUHBMzz9Ntie_S474slGjVY"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "903482201540-s2j96h6k7go0ah51ksi7es8mt7qhankh.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
70
OneToOne/google-services.json
Normal file
70
OneToOne/google-services.json
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "292494634914",
|
||||
"project_id": "pdlive-1631521064967",
|
||||
"storage_bucket": "pdlive-1631521064967.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:292494634914:android:d8db197d7e7a6c3a3a4cfb",
|
||||
"android_client_info": {
|
||||
"package_name": "com.pdlive.shayu"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "903482201540-ddno3ro8fp0lqqoeodbhbnpqf7f8d439.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.pdlive.shayu",
|
||||
"certificate_hash": "38cc19306c9facee36a9224e9a4070bc0be15c7d"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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"
|
||||
}
|
||||
250
OneToOne/proguard-rules.pro
vendored
Normal file
250
OneToOne/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
# 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 groupLast number information for
|
||||
# debugging stack traces.
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the groupLast number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
-renamesourcefileattribute SourceFile
|
||||
|
||||
-keep class com.yunbao.**{
|
||||
public <methods>;
|
||||
protected <methods>;
|
||||
}
|
||||
-keep class com.shayu.**{
|
||||
public <methods>;
|
||||
protected <methods>;
|
||||
}
|
||||
-keep class * implements com.yunbao.common.bean.BaseModel {
|
||||
*;
|
||||
}
|
||||
|
||||
-keep class com.yunbao.common.bean.** {
|
||||
*;
|
||||
}
|
||||
-keep class com.shayu.onetoone.bean.** {
|
||||
*;
|
||||
}
|
||||
|
||||
-keep class com.yunbao.common.views.weight.VerticalViewPager$LayoutParams{
|
||||
*;
|
||||
}
|
||||
-keep class android.**{
|
||||
*;
|
||||
}
|
||||
|
||||
-keep class **.R$* {
|
||||
public static <fields>;
|
||||
}
|
||||
-keep class com.tencent.** { *; }
|
||||
-keep class com.adjust.sdk.**{ *; }
|
||||
-keep class com.google.android.gms.common.ConnectionResult {
|
||||
int SUCCESS;
|
||||
}
|
||||
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
|
||||
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
|
||||
}
|
||||
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
|
||||
java.lang.String getId();
|
||||
boolean isLimitAdTrackingEnabled();
|
||||
}
|
||||
-keep public class com.android.installreferrer.**{ *; }
|
||||
-keep class * implements android.os.Parcelable.**{*;}
|
||||
-keep class * implements android.os.Serializable.**{*;}
|
||||
-dontwarn javax.annotation.**
|
||||
|
||||
-dontwarn javax.inject.**
|
||||
|
||||
# OkHttp3
|
||||
|
||||
-dontwarn okhttp3.logging.**
|
||||
|
||||
-keep class okhttp3.internal.**{*;}
|
||||
|
||||
-dontwarn okio.**
|
||||
#okhttp
|
||||
-dontwarn okhttp3.**
|
||||
-keep class okhttp3.**{*;}
|
||||
|
||||
#okio
|
||||
-dontwarn okio.**
|
||||
-keep class okio.**{*;}
|
||||
|
||||
# Retrofit
|
||||
|
||||
-dontwarn retrofit2.**
|
||||
|
||||
-keep class retrofit2.** { *; }
|
||||
|
||||
-keepattributes Signature-keepattributes,Exceptions
|
||||
|
||||
# RxJava RxAndroid
|
||||
-dontwarn java.util.concurrent.Flow*
|
||||
|
||||
-dontwarn sun.misc.**
|
||||
|
||||
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
|
||||
|
||||
long producerIndex;
|
||||
|
||||
long consumerIndex;
|
||||
|
||||
}
|
||||
|
||||
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef* {
|
||||
|
||||
rx.internal.util.atomic.LinkedQueueNode* producerNode;
|
||||
|
||||
}
|
||||
|
||||
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef* {
|
||||
|
||||
rx.internal.util.atomic.LinkedQueueNode* consumerNode;
|
||||
|
||||
}
|
||||
|
||||
# Gson
|
||||
|
||||
-keep class com.google.gson.stream.** { *; }
|
||||
##---------------Begin: proguard configuration for Gson ----------
|
||||
# Gson uses generic type information stored in a class file when working with fields. Proguard
|
||||
# removes such information by default, so configure it to keep all of it.
|
||||
-keepattributes Signature
|
||||
|
||||
# For using GSON @Expose annotation
|
||||
-keepattributes *Annotation*
|
||||
|
||||
# Gson specific classes
|
||||
-dontwarn sun.misc.**
|
||||
#-keep class com.google.gson.stream.** { *; }
|
||||
|
||||
# Application classes that will be serialized/deserialized over Gson
|
||||
-keep class com.google.gson.examples.android.model.** { <fields>; }
|
||||
|
||||
# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
|
||||
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
|
||||
-keep class * extends com.google.gson.TypeAdapter
|
||||
-keep class * implements com.google.gson.TypeAdapterFactory
|
||||
-keep class * implements com.google.gson.JsonSerializer
|
||||
-keep class * implements com.google.gson.JsonDeserializer
|
||||
|
||||
# Prevent R8 from leaving Data object members always null
|
||||
-keepclassmembers,allowobfuscation class * {
|
||||
@com.google.gson.annotations.SerializedName <fields>;
|
||||
}
|
||||
|
||||
# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
|
||||
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
|
||||
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
|
||||
|
||||
##---------------End: proguard configuration for Gson ----------
|
||||
|
||||
-keepattributes EnclosingMethod
|
||||
#--------融云
|
||||
-keepattributes Exceptions,InnerClasses
|
||||
-keepattributes Signature
|
||||
-keep class io.rong.** {*;}
|
||||
-keep class cn.rongcloud.** {*;}
|
||||
-keep class * implements io.rong.imlib.model.MessageContent {*;}
|
||||
-dontwarn io.rong.push.**
|
||||
-dontnote com.xiaomi.**
|
||||
-dontnote com.google.android.gms.gcm.**
|
||||
-dontnote io.rong.**
|
||||
# 下方混淆使用了融云 IMKit 提供的 locationKit 位置插件时才需要配置,可参考高德官网的混淆方式:https://lbs.amap.com/api/android-sdk/guide/create-project/dev-attention
|
||||
-keep class com.amap.api.maps.**{*;}
|
||||
-keep class com.autonavi.**{*;}
|
||||
-keep class com.amap.api.trace.**{*;}
|
||||
-keep class com.amap.api.location.**{*;}
|
||||
-keep class com.amap.api.fence.**{*;}
|
||||
-keep class com.loc.**{*;}
|
||||
-keep class com.autonavi.aps.amapapi.model.**{*;}
|
||||
-keep class com.amap.api.services.**{*;}
|
||||
-ignorewarnings
|
||||
|
||||
#--------科大讯飞
|
||||
-keep class com.iflytek.**{*;}
|
||||
-keepattributes Signature
|
||||
#EvenBus
|
||||
-keepattributes *Annotation*
|
||||
-keepclassmembers class * {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
}
|
||||
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
|
||||
|
||||
# If using AsyncExecutord, keep required constructor of default event used.
|
||||
# Adjust the class name if a custom failure event type is used.
|
||||
-keepclassmembers class org.greenrobot.eventbus.util.ThrowableFailureEvent {
|
||||
<init>(java.lang.Throwable);
|
||||
}
|
||||
|
||||
# Accessed via reflection, avoid renaming or removal
|
||||
-keep class org.greenrobot.eventbus.android.AndroidComponentsImpl*
|
||||
|
||||
#--------ARouter
|
||||
-keep public class com.alibaba.android.arouter.routes.**{*;}
|
||||
-keep public class com.alibaba.android.arouter.facade.**{*;}
|
||||
-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
|
||||
|
||||
# If you use the byType method to obtain Service, add the following rules to protect the interface:
|
||||
-keep interface * implements com.alibaba.android.arouter.facade.template.IProvider
|
||||
|
||||
# If single-type injection is used, that is, no interface is defined to implement IProvider, the following rules need to be added to protect the implementation
|
||||
# -keep class * implements com.alibaba.android.arouter.facade.template.IProvider
|
||||
|
||||
#----retrofit2
|
||||
-keepattributes Signature, InnerClasses, EnclosingMethod
|
||||
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
|
||||
-keepattributes AnnotationDefault
|
||||
-keepclassmembers,allowshrinking,allowobfuscation interface * {
|
||||
@retrofit2.http.* <methods>;
|
||||
}
|
||||
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement*
|
||||
-dontwarn javax.annotation.**
|
||||
-dontwarn kotlin.Unit
|
||||
-dontwarn retrofit2.KotlinExtensions*
|
||||
-dontwarn retrofit2.KotlinExtensions$*
|
||||
-if interface * { @retrofit2.http.* <methods>; }
|
||||
-keep,allowobfuscation interface <1>
|
||||
-if interface * { @retrofit2.http.* <methods>; }
|
||||
-keep,allowobfuscation interface * extends <1>
|
||||
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
|
||||
-if interface * { @retrofit2.http.* public *** *(...); }
|
||||
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>
|
||||
|
||||
#-----glide
|
||||
-keep public class com.bumptech.glide.** {*;}
|
||||
-keep public class jp.co.cyberagent.** {*;}
|
||||
-dontwarn jp.co.cyberagent.android.gpuimage.**
|
||||
|
||||
-printconfiguration tmp/full-r8-config.txt
|
||||
#---美颜模块需要暴露出来的参数名
|
||||
-keep class com.yunbao.faceunity.utils.FURenderer{
|
||||
public static java.lang.String BUNDLE_AI_FACE;
|
||||
}
|
||||
-keep class com.yunbao.faceunity.utils.FaceUnityConfig{
|
||||
public static java.lang.String BUNDLE_FACE_BEAUTIFICATION;
|
||||
}
|
||||
-keep class com.faceunity.wrapper.faceunity$LoadConfig*{
|
||||
private static boolean sLoadedLibrary;
|
||||
}
|
||||
#--融云语聊--
|
||||
-keep public class cn.rongcloud.** {*;}
|
||||
-ignorewarnings
|
||||
-keep class io.rong.imkit.** {*;}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.shayu.onetoone;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.shayu.onetoone.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
311
OneToOne/src/main/AndroidManifest.xml
Normal file
311
OneToOne/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,311 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.shayu.onetoone">
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.CALL_PHONE"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.CHANGE_CONFIGURATION"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_LOGS"
|
||||
tools:ignore="ProtectedPermissions"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_CALL_LOG"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_CALL_LOG"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_SMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.SEND_SMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_SMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.RECEIVE_SMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.RECEIVE_WAP_PUSH"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.RECEIVE_MMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.SEND_MMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.MODIFY_PHONE_STATE"
|
||||
tools:ignore="ProtectedPermissions"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.PROCESS_OUTGOING_CALLS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.MODIFY_AUDIO_SETTINGS"
|
||||
tools:node="remove" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.NETWORK_PROVIDER" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.FLASHLIGHT" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_SETTINGS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!-- Android11新增 -->
|
||||
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> -->
|
||||
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<application
|
||||
android:name=".AppContext"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/app_logo"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:preserveLegacyExternalStorage="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:replace="theme,label,icon,allowBackup">
|
||||
<activity
|
||||
android:name=".activity.login.TagselectionActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.login.CompleteActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LauncherActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.login.EntryActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.message.MsgMoreGreetConfigActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.message.ChatActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.login.LoginActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.login.FindPwdActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.login.RegisterActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.WebViewActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.HomepageRankingActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.MyArnActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.DiamondExchangeActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.setting.OneMsgSettActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.ExchangeRecordActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.HomeScreenActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.HomeSearchActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.message.CallVideoActivity"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.message.CallAudioActivity"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.MatchingActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.EndCallActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.MyFriendListActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".activity.login.ChooseLabelActivity"
|
||||
android:label="选择标签"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.setting.SettingActivity"
|
||||
android:label="設定"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.user.EditProfileActivity"
|
||||
android:label="编辑资料"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.user.EditNameActivity"
|
||||
android:label="编辑名称"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.user.EditSignActivity"
|
||||
android:label="编辑签名"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.user.AuthActivity"
|
||||
android:label="实名认证"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.user.AuthBloggerActivity"
|
||||
android:label="达人认证"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.user.AuthBloggerInletActivity"
|
||||
android:label="达人认证入口"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.setting.FollowActivity"
|
||||
android:label="达人认证入口"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.setting.ModifyPwdActivity"
|
||||
android:label="修改密码"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.setting.BindUserActivity"
|
||||
android:label="绑定手机号码"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
<meta-data
|
||||
android:name="SERVER_HOST"
|
||||
android:value="${otoServerHost}" />
|
||||
<meta-data
|
||||
android:name="com.facebook.sdk.ApplicationId"
|
||||
android:value="@string/facebook_app_id" />
|
||||
<meta-data
|
||||
android:name="com.facebook.sdk.ClientToken"
|
||||
android:value="@string/facebook_client_token" />
|
||||
<meta-data
|
||||
android:name="com.facebook.sdk.AutoLogAppEventsEnabled"
|
||||
android:value="false" />
|
||||
<meta-data
|
||||
android:name="IS_GOOGLE_PLAY"
|
||||
android:value="${isGooglePlay}" />
|
||||
<meta-data
|
||||
android:name="IS_UPLOAD_ERROR_LOG"
|
||||
android:value="${isUploadLog}" />
|
||||
<meta-data
|
||||
android:name="IS_PLUGIN_MODEL"
|
||||
android:value="${isPluginModel}" />
|
||||
<meta-data
|
||||
android:name="firebase_crashlytics_collection_enabled"
|
||||
android:value="${isUploadLog}" />
|
||||
<meta-data
|
||||
android:name="com.openinstall.APP_KEY"
|
||||
android:value="smvslm" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
35
OneToOne/src/main/assets/Reward_instructions.html
Normal file
35
OneToOne/src/main/assets/Reward_instructions.html
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>本地HTML页面</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>獎勵說明</h1>
|
||||
<p>在您使用平台服務取得和提取收益(包括:互動收益、通話收益)前,您應閱讀並遵守本說明及將來公示的新增的單項說明或規則、操作時的提示以及規則。 我們在此特別提醒您認真閱讀並充分理解本說明,特別是免除或限制我們責任、限制您的權利、規定爭議解決方式的相關條款。 除非您接受本說明,否則您無權使用相關功能。 您一經使用獎勵獲取、收益兌換和提現等相關功能,即視為您已理解並接受本說明。 我們保留根據相關法律規定、主管機關要求、業務開展情況等,對獎勵的領取、兌換、提現規則進行變更、調整、中止或終止的權利,同時也會將變更、調整予以公示並自公示之日起生效。</p>
|
||||
<h1>1、如何獲得獎勵?</h1>
|
||||
|
||||
<h1>A.付費消息:</h1>
|
||||
<p>用戶在以下情況將有機會獲得付費方付費訊息星幣價值的固定比例作為獎勵:</p>
|
||||
<p>(1)系統匹配的會話,不同等級時,低等級用戶為付費方;同等級時,男用戶為付費方(目前等級由低到高分別為:未認證用戶,真人認證用戶,達人認證用戶 )。 系統匹配的會話包括:系統匹配的搭訕/訊息(如紅娘牽線)等; </p>
|
||||
<p>(2)除系統匹配的會話及平台另有規定外,首發訊息的一方為雙方會話關係中的付費方。 首發訊息包含:一鍵搭訕/搭訕/私訊,以及視訊和語音通話;</p>
|
||||
<p>(3)若一方在會話關係中已經被認定為付費方,則系統配對到同一會話關係時,該方仍為付費方; 當用戶收到其他用戶的付費訊息時,達人認證用戶會獲得該部分付費訊息星幣價值的33%作為獎勵(具體獎勵以平台顯示為準);真人認證用戶可以獲得的獎勵為22%; 未認證用戶僅可獲得11%。 我們鼓勵您進行真人認證交友。</p>
|
||||
<h1>B.禮物:</h1>
|
||||
|
||||
<p>1、當用戶收到收益禮物時,達人認證用戶將會獲得該禮物星幣價值的34%作為獎勵;真人認證用戶可以獲得的獎勵為22%;未認證用戶僅可獲得11%。 用戶背包中尚未送出的禮物不能用於提取收益。</p>
|
||||
<p>2、獎勵如何領取? 領取獎勵前,需先進行真人認證,通過認證後,綁定收款方式方可提領。</p>
|
||||
<p>3.最小提現金額? 10美元起提。</p>
|
||||
<p>4.什麼情況下會領取失敗? 用戶的帳號存在異常; 收款方式異常; 平台技術故障; 用戶被其他用戶舉報、受到平台調查或監管部門有特定要求等存在未解決爭議事項;</p>
|
||||
<p>5.領取失敗後,該筆獎勵會到哪裡? 領取失敗會導致該筆獎勵退回,如有疑問,請聯絡客服。</p>
|
||||
<p>6、其他費用 用戶對其收益應依法納稅,其平台收益相關的報稅、稅費及相關責任義務等由用戶與其合作方(公會、靈活用工平台等)約定,與平台方無關。</p>
|
||||
<p>7、其他聲明 用戶瞭解並同意,獎勵規則具體以平台顯示為準。若因平台系統突發故障、第三方軟體服務商故障、駭客攻擊等導致平台顯示及功能故障,平台將在發現後儘快修復,平台無須因此承擔賠償責任。</p>
|
||||
<p>8.無效獎勵 若經平台核查認定您全部或部分獎勵無效時,平台為履行法定義務、配合相關執法部門或履行社會責任等原因,有權自行決策將與上述無效獎勵對應的用戶側消費款項予以退還;您同意支援平台的相應決策,並配合平台要求退還您的相關獎勵或等價金額。 此時,平台有權從您帳號的收益餘額中自行扣除相應金額,若不足以扣除時,您應在平台作出通知後指定週期內按照本公司告知的方式補足。</p>
|
||||
<h1> 無效獎勵包括但不限於您基於以下情形而獲得的對應獎勵:</h1>
|
||||
<p>(1)無民事行為能力人或限制民事行為能力人的使用者打賞或進行其他消費而產生的您的獎勵收益;</p>
|
||||
<p>(2)因您透過違法、違規、違反平台規則或違反公序良俗、誠實信用原則的行為而獲取的獎勵收益;</p>
|
||||
<p>(3)因司法/行政機關要求退還/劃撥的收益(及司法/行政機關要求退還/劃撥用戶消費金額時該等消費金額中對應的您的獎勵收益); </p>
|
||||
<p>(4)使用者使用非法收入、作弊收入或非平台指定方式儲值或消費而產生的您的獎勵收益;</p>
|
||||
<p>(5)用戶依法依規撤銷其消費行為(包括但不限於支付通路退款等)時其相應消費所對應的您的獎勵收益;</p>
|
||||
<p>(6)本公司有權基於平台風控判斷、用戶投訴、行政或司法機關的要求等情形確認您的部分或全部獎勵收益無效。 在您使用平台服務取得和提取收益(包括:互動收益、通話收益)前,您應閱讀並遵守本說明及將來公示的新增的單項說明或規則、操作時的提示以及規則。 我們在此特別提醒您認真閱讀並充分理解本說明,特別是免除或限制我們責任、限制您的權利、規定爭議解決方式的相關條款。 除非您接受本說明,否則您無權使用相關功能。 您一經使用獎勵獲取、收益兌換和提現等相關功能,即視為您已理解並接受本說明。 我們保留根據相關法律規定、主管機關要求、業務開展情況等,對獎勵的領取、兌換、提現規則進行變更、調整、中止或終止的權利,同時也會將變更、調整予以公示並自公示之日起生效。</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
368
OneToOne/src/main/java/com/shayu/onetoone/AppContext.java
Normal file
368
OneToOne/src/main/java/com/shayu/onetoone/AppContext.java
Normal file
@@ -0,0 +1,368 @@
|
||||
package com.shayu.onetoone;
|
||||
|
||||
|
||||
import static com.yunbao.live.socket.SocketClient.mSocketHandler;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.Utils;
|
||||
import com.facebook.FacebookSdk;
|
||||
import com.fm.openinstall.OpenInstall;
|
||||
import com.google.firebase.FirebaseApp;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
import com.shayu.onetoone.activity.fragments.message.ChatMessageFragment;
|
||||
import com.shayu.onetoone.activity.message.ChatActivity;
|
||||
import com.shayu.onetoone.bean.MessageChatAuthContent;
|
||||
import com.shayu.onetoone.bean.MessageChatGiftContent;
|
||||
import com.shayu.onetoone.bean.MessageChatTipsContent;
|
||||
import com.shayu.onetoone.manager.CallClientManager;
|
||||
import com.shayu.onetoone.manager.CommandMessageManager;
|
||||
import com.shayu.onetoone.provider.CustomConversationProvider;
|
||||
import com.shayu.onetoone.provider.MessageChatAutoItemProvider;
|
||||
import com.shayu.onetoone.provider.MessageChatReceiveGiftItemProvider;
|
||||
import com.shayu.onetoone.provider.MessageChatTipsItemProvider;
|
||||
import com.shayu.onetoone.provider.OTOCallEndMessageItemProvider;
|
||||
import com.shayu.onetoone.utils.ChatPluginExtensionConfig;
|
||||
import com.shayu.onetoone.utils.NeverCrashUtils;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
||||
import com.tencent.imsdk.v2.V2TIMUserInfo;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.umeng.commonsdk.UMConfigure;
|
||||
import com.yunbao.common.BuildConfig;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.AnchorStartLiveBean;
|
||||
import com.yunbao.common.bean.CrashSaveBean;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.imrongcloud.InstructorSendReward;
|
||||
import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider;
|
||||
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RecommendLiveRoom;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.socket.SocketReceiveBean;
|
||||
import com.yunbao.live.socket.SocketRyClient;
|
||||
import com.yunbao.live.views.PortraitLiveManager;
|
||||
import com.yunbao.live.views.RecommendLiveRoomProvider;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.callkit.CallEndMessageItemProvider;
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.RongIM;
|
||||
import io.rong.imkit.config.RongConfigCenter;
|
||||
import io.rong.imkit.conversation.extension.RongExtension;
|
||||
import io.rong.imkit.conversation.extension.RongExtensionManager;
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
import io.rong.imkit.conversationlist.provider.PrivateConversationProvider;
|
||||
import io.rong.imkit.utils.RouteUtils;
|
||||
import io.rong.imkit.widget.adapter.ProviderManager;
|
||||
import io.rong.imlib.IMLibRTCClient;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.InitOption;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.MessageContent;
|
||||
import io.rong.message.CommandMessage;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
public class AppContext extends CommonAppContext {
|
||||
private final static List<WeakReference<Activity>> activities = new ArrayList<>();
|
||||
|
||||
public static void exit() {
|
||||
for (WeakReference<Activity> activity : activities) {
|
||||
try {
|
||||
if (activity.get() != null) {
|
||||
activity.get().finish();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
L.setDeBug(true);
|
||||
SpUtil.getInstance();
|
||||
registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks());
|
||||
|
||||
NeverCrashUtils.getInstance()
|
||||
.setDebugMode(BuildConfig.DEBUG)
|
||||
.setMainCrashHandler((t, e) -> {
|
||||
Log.e("ApplicationError", "主线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
|
||||
e.printStackTrace();
|
||||
AppManager.runDebugCode(() -> {
|
||||
//闪退后finish所有Activity并且杀死进程
|
||||
Process.killProcess(Process.myPid());
|
||||
System.exit(0);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
throw new RuntimeException(e);
|
||||
}, 100);
|
||||
});
|
||||
|
||||
})
|
||||
.setUncaughtCrashHandler((t, e) -> {
|
||||
Log.e("ApplicationError", "子线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
|
||||
e.printStackTrace();
|
||||
})
|
||||
.register(this);
|
||||
ARouter.openLog();
|
||||
ARouter.openDebug();
|
||||
ARouter.printStackTrace();
|
||||
ARouter.init(this);
|
||||
|
||||
|
||||
ProviderManager<BaseUiConversation> providerManager = RongConfigCenter.conversationListConfig().getProviderManager();
|
||||
providerManager.replaceProvider(PrivateConversationProvider.class, new CustomConversationProvider());
|
||||
|
||||
|
||||
ArrayList<Class<? extends MessageContent>> myMessages = new ArrayList<>();
|
||||
myMessages.add(MessageChatTipsContent.class);
|
||||
myMessages.add(MessageChatGiftContent.class);
|
||||
myMessages.add(MessageChatAuthContent.class);
|
||||
RongIMClient.registerMessageType(myMessages);
|
||||
|
||||
RongConfigCenter.conversationConfig().addMessageProvider(new InstructorSendRewardProvider(getApplicationContext()));
|
||||
RongConfigCenter.conversationConfig().addMessageProvider(new MessageChatTipsItemProvider(getApplicationContext()));
|
||||
RongConfigCenter.conversationConfig().addMessageProvider(new MessageChatReceiveGiftItemProvider(getApplicationContext()));
|
||||
RongConfigCenter.conversationConfig().addMessageProvider(new MessageChatAutoItemProvider(getApplicationContext()));
|
||||
|
||||
RongcloudIMManager.initRongIM(this);
|
||||
|
||||
RongIM.setConnectionStatusListener(new RongIMClient.ConnectionStatusListener() {
|
||||
@Override
|
||||
public void onChanged(ConnectionStatus status) {
|
||||
Log.i("融云", "onChanged: " + status.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
RongcloudIMManager.addRongcloudIMOnReceiveMessageListener(new RongIMClient.OnReceiveMessageWrapperListener() {
|
||||
@Override
|
||||
public boolean onReceived(Message message, int left, boolean hasPackage, boolean offline) {
|
||||
System.out.println("初始化IM消息:" + message.getContent());
|
||||
if (message.getContent() instanceof TextMessage) {
|
||||
TextMessage content = (TextMessage) message.getContent();
|
||||
} else if (message.getContent() instanceof CommandMessage) {
|
||||
CommandMessageManager.getInstance().onMessage((CommandMessage) message.getContent());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
RouteUtils.registerActivity(RouteUtils.RongActivityType.ConversationActivity, ChatActivity.class);
|
||||
IMLoginManager.get(this).setLanguage(false);
|
||||
|
||||
|
||||
RongConfigCenter.conversationConfig().replaceMessageProvider(CallEndMessageItemProvider.class, new OTOCallEndMessageItemProvider());
|
||||
RongExtensionManager.getInstance().setExtensionConfig(new ChatPluginExtensionConfig());
|
||||
|
||||
initPDLive();
|
||||
|
||||
}
|
||||
|
||||
private void initPDLive(){
|
||||
|
||||
registerFirebaseCrash();
|
||||
//初始化 邀请码库
|
||||
if (isMainProcess()) {
|
||||
OpenInstall.init(this);
|
||||
}
|
||||
//设置LOG开关,默认为false
|
||||
UMConfigure.setLogEnabled(true);
|
||||
|
||||
|
||||
//友盟正式初始化
|
||||
UMConfigure.init(getApplicationContext(), "64e40ee55488fe7b3afa2c96", "PDLive", UMConfigure.DEVICE_TYPE_PHONE,
|
||||
"64e40ee55488fe7b3afa2c96");
|
||||
|
||||
//集成umeng-crash-vx.x.x.aar,则需要关闭原有统计SDK异常捕获功能
|
||||
MobclickAgent.setCatchUncaughtExceptions(false);
|
||||
//PushSDK初始化(如使用推送SDK,必须调用此方法)
|
||||
|
||||
//统计SDK是否支持采集在子进程中打点的自定义事件,默认不支持
|
||||
UMConfigure.setProcessEvent(true);//支持多进程打点
|
||||
MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
|
||||
UMConfigure.submitPolicyGrantResult(getApplicationContext(), true);
|
||||
|
||||
registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks());
|
||||
//初始化 AndroidUtilCode
|
||||
Utils.init(this);
|
||||
|
||||
RongConfigCenter.conversationConfig().addMessageProvider(new RecommendLiveRoomProvider(getApplicationContext()));
|
||||
|
||||
RongcloudIMManager.addRongcloudIMOnReceiveMessageListener(new RongIMClient.OnReceiveMessageWrapperListener() {
|
||||
@Override
|
||||
public boolean onReceived(io.rong.imlib.model.Message message, int i, boolean b, boolean b1) {
|
||||
Log.e("wewe", message.getConversationType() + "112121");
|
||||
MessageIMManager.get(sInstance).getSystemForRongcloud(message);
|
||||
//融云直播间聊天
|
||||
android.os.Message msg = android.os.Message.obtain();
|
||||
msg.what = Constants.SOCKET_WHAT_BROADCAST;
|
||||
try {
|
||||
if (!"".equals(message.getContent()) && message.getContent() != null) {
|
||||
TextMessage content = (TextMessage) message.getContent();
|
||||
if (content.getContent().contains("_method_")) {
|
||||
msg.obj = content.getContent();
|
||||
//观众页面
|
||||
if (SocketRyClient.mSocketHandler != null
|
||||
&& (TextUtils.equals("__system__", message.getTargetId())
|
||||
|| ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
|
||||
SocketRyClient.mSocketHandler.sendMessage(msg);
|
||||
} else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
|
||||
SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class);
|
||||
JSONObject map = received.getMsg().getJSONObject(0);
|
||||
sendStartAnchorLive(map);
|
||||
}else if(content.getContent().contains("Chat_messageNotify")){
|
||||
//TODO 各种通知
|
||||
}else if(content.getContent().contains("Chat_callAudioNotify")){
|
||||
|
||||
}else if(content.getContent().contains("Chat_callVideoNotify")){
|
||||
|
||||
}
|
||||
//主播页面
|
||||
if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketRyClient.mSocketHandler != null) {
|
||||
SocketRyClient.mSocketHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
} else if (message.getConversationType() == Conversation.ConversationType.PRIVATE) {//私聊信息
|
||||
EventBus.getDefault().post(message);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void sendStartAnchorLive(JSONObject map) {
|
||||
AnchorStartLiveBean bean = new AnchorStartLiveBean(AnchorStartLiveBean.TYPE_LIVE);
|
||||
bean.setAnchorName(map.getString("anchorName"));
|
||||
bean.setRoomId(map.getString("roomid"));
|
||||
bean.setAvatar(map.getString("avatar"));
|
||||
Bus.get().post(bean);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//监听im消息
|
||||
V2TIMManager.getInstance().addSimpleMsgListener(new V2TIMSimpleMsgListener() {
|
||||
@Override
|
||||
public void onRecvGroupTextMessage(String msgID, String groupID, V2TIMGroupMemberInfo sender, String text) {
|
||||
super.onRecvGroupTextMessage(msgID, groupID, sender, text);
|
||||
Log.e("asasas", text);
|
||||
android.os.Message msg = android.os.Message.obtain();
|
||||
msg.what = Constants.SOCKET_WHAT_BROADCAST;
|
||||
msg.obj = text;
|
||||
if (mSocketHandler != null && Ingroup == 1) {
|
||||
mSocketHandler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecvC2CTextMessage(String msgID, V2TIMUserInfo sender, String text) {
|
||||
super.onRecvC2CTextMessage(msgID, sender, text);
|
||||
android.os.Message msg = android.os.Message.obtain();
|
||||
msg.what = Constants.SOCKET_WHAT_BROADCAST;
|
||||
msg.obj = text;
|
||||
if (mSocketHandler != null) {
|
||||
CommonAppContext.Ingroup = 1;
|
||||
mSocketHandler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void registerFirebaseCrash() {
|
||||
|
||||
FirebaseAnalytics.getInstance(this);
|
||||
FirebaseApp.initializeApp(this);
|
||||
}
|
||||
|
||||
|
||||
public boolean isMainProcess() {
|
||||
int pid = android.os.Process.myPid();
|
||||
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
||||
if (activityManager.getRunningAppProcesses() == null) {
|
||||
return true;
|
||||
}
|
||||
for (ActivityManager.RunningAppProcessInfo appProcess : activityManager.getRunningAppProcesses()) {
|
||||
if (appProcess.pid == pid) {
|
||||
return getApplicationInfo().packageName.equals(appProcess.processName);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static final class AdjustLifecycleCallbacks implements ActivityLifecycleCallbacks {
|
||||
@Override
|
||||
public void onActivityResumed(Activity activity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused(Activity activity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStopped(@NonNull Activity activity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(@NonNull Activity activity) {
|
||||
for (WeakReference<Activity> reference : activities) {
|
||||
if (reference.get() == activity) {
|
||||
activities.remove(reference);
|
||||
return;
|
||||
}
|
||||
}
|
||||
AppManager.getInstance().removeActivity(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
|
||||
activities.add(new WeakReference<>(activity));
|
||||
CrashSaveBean.getInstance().setActivitySize(activities);
|
||||
AppManager.getInstance().addActivity(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStarted(@NonNull Activity activity) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Activity基类
|
||||
*/
|
||||
public abstract class AbsOTOActivity extends AbsActivity {
|
||||
public Context mContext;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
private void setStatusBar() {
|
||||
|
||||
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);
|
||||
}
|
||||
/**
|
||||
* 设置布局id
|
||||
*/
|
||||
protected abstract int getLayoutId();
|
||||
|
||||
protected abstract void main(Bundle savedInstanceState);
|
||||
|
||||
protected boolean onCreate(){ return true;}
|
||||
|
||||
/**
|
||||
* 设置标题
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
TextView view = findViewById(R.id.title);
|
||||
if (view != null) {
|
||||
view.setText(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.DiamondExchangeAdapter;
|
||||
import com.shayu.onetoone.bean.ExchangeModel;
|
||||
import com.shayu.onetoone.event.DiamondExchangeEvent;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.yunbao.common.custom.ItemDecoration;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_DIAMOND_EXCHANGE)
|
||||
public class DiamondExchangeActivity extends AbsOTOActivity {
|
||||
private RecyclerView diamondExchangeList;
|
||||
private DiamondExchangeAdapter exchangeAdapter;
|
||||
private TextView title, totalConvertibility,totalConvertibilityDes;
|
||||
private String type = "yuanbao";
|
||||
|
||||
private EditText diamondExchangeInput;
|
||||
private String number;
|
||||
private int index = 0;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_diamond_exchange;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
Bus.getOn(this);
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
diamondExchangeList = findViewById(R.id.diamond_exchange_list);
|
||||
title = findViewById(R.id.title);
|
||||
diamondExchangeInput = findViewById(R.id.diamond_exchange_input);
|
||||
totalConvertibility = findViewById(R.id.total_convertibility);
|
||||
totalConvertibilityDes = findViewById(R.id.total_convertibility_des);
|
||||
diamondExchangeList.addItemDecoration(new ItemDecoration(mContext, Color.parseColor("#ffffff"), 10, 2));
|
||||
diamondExchangeList.setLayoutManager(new GridLayoutManager(mContext, 3));
|
||||
exchangeAdapter = new DiamondExchangeAdapter();
|
||||
diamondExchangeList.setAdapter(exchangeAdapter);
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.arn_toggle), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (TextUtils.equals(type, "yuanbao")) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("type", "coin");
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_DIAMOND_EXCHANGE, bundle);
|
||||
finish();
|
||||
} else {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("type", "yuanbao");
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_DIAMOND_EXCHANGE, bundle);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.exchange_record), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (TextUtils.equals(type, "yuanbao")) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("type", "coin");
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_EXCHANGE_RECORD, bundle);
|
||||
} else {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("type", "yuanbao");
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_EXCHANGE_RECORD, bundle);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.immediate_exchange), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
String exchangeNumber = "";
|
||||
if (TextUtils.isEmpty(number)) {
|
||||
exchangeNumber = diamondExchangeInput.getText().toString();
|
||||
} else {
|
||||
exchangeNumber = number;
|
||||
}
|
||||
OTONetManager.getInstance(mContext).getTransform(type, exchangeNumber, new HttpCallback<List<ExchangeModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<ExchangeModel> data) {
|
||||
if (data.size() > 0) {
|
||||
if ((data.size() - 1) > index && index > 0) {
|
||||
data.get(index).setSelect(true);
|
||||
totalConvertibility.setText(String.valueOf(data.get(0).getSum()));
|
||||
number = data.get(index).getNum();
|
||||
} else {
|
||||
if (TextUtils.isEmpty(diamondExchangeInput.getText().toString())) {
|
||||
data.get(0).setSelect(true);
|
||||
totalConvertibility.setText(String.valueOf(data.get(0).getSum()));
|
||||
number = data.get(0).getNum();
|
||||
} else {
|
||||
totalConvertibility.setText(String.valueOf(data.get(0).getSum()));
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
data.get(i).setSelect(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
ToastUtil.show(R.string.exchange_success);
|
||||
exchangeAdapter.addData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
diamondExchangeInput.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if (!TextUtils.isEmpty(diamondExchangeInput.getText().toString()) && !TextUtils.isEmpty(number)) {
|
||||
exchangeAdapter.unSelect();
|
||||
number = null;
|
||||
index = -1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.one_back), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
if (getIntent() != null && getIntent().getExtras() != null) {
|
||||
type = getIntent().getExtras().getString("type");
|
||||
if (TextUtils.equals(type, "yuanbao")) {
|
||||
title.setText(getString(R.string.my_arnings_exchange_star));
|
||||
diamondExchangeInput.setHint(R.string.diamond_exchange_input_hint);
|
||||
} else {
|
||||
title.setText(getString(R.string.my_arnings_exchange_diamond));
|
||||
diamondExchangeInput.setHint(R.string.diamond_exchange_input_hint2);
|
||||
}
|
||||
}
|
||||
OTONetManager.getInstance(mContext).getExchangeList(type, new HttpCallback<List<ExchangeModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<ExchangeModel> data) {
|
||||
if (data.size() > 0) {
|
||||
data.get(0).setSelect(true);
|
||||
totalConvertibility.setText(String.valueOf(data.get(0).getSum()));
|
||||
number = data.get(0).getNum();
|
||||
exchangeAdapter.addData(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onExchangeModel(DiamondExchangeEvent event) {
|
||||
number = event.getNum();
|
||||
index = event.getIndex();
|
||||
diamondExchangeInput.setText("");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||
import com.shayu.onetoone.bean.FollowBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.HtmlUrlUtils;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_END_CALL)
|
||||
public class EndCallActivity extends AbsOTOActivity {
|
||||
private RoundedImageView avatar;
|
||||
private TextView titleView;
|
||||
private TextView usernameView;
|
||||
private Button followButton;
|
||||
private Button callTimerButton;
|
||||
private Button cancelButton;
|
||||
private Button applyButton;
|
||||
private UserBean user;
|
||||
private String timer;
|
||||
private final String TAG="EndCallActivity";
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.dialog_end_call;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
titleView = findViewById(R.id.title);
|
||||
usernameView = findViewById(R.id.username);
|
||||
followButton = findViewById(R.id.follow);
|
||||
callTimerButton = findViewById(R.id.call_timer);
|
||||
cancelButton = findViewById(R.id.cancel);
|
||||
applyButton = findViewById(R.id.apply);
|
||||
avatar = findViewById(R.id.avatar);
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
|
||||
user = JSONObject.parseObject(extras.getString("user"), UserBean.class);
|
||||
timer = extras.getString("time");
|
||||
if (user == null || timer == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
if(StringUtil.isEmpty(timer)){
|
||||
timer=WordUtil.getNewString(R.string.call_time) + "00:00";
|
||||
}
|
||||
ImgLoader.display(mContext, user.getUser().getAvatar(), avatar);
|
||||
ImgLoader.displayBlur(mContext, user.getUser().getAvatar(), findViewById(R.id.bg), 85);
|
||||
usernameView.setText(user.getUser().getUserNicename());
|
||||
callTimerButton.setText(timer);
|
||||
if (user.getUser().isFollow()) {
|
||||
followButton.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
followButton.setOnClickListener(view -> {
|
||||
follow();
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(cancelButton, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getTargetUserInfo(user.getUser().getId(), new HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
if (data.getInfo().getName_auth() == 2) {
|
||||
RouteManager.forwardActivity(extras.getString("path"), extras);
|
||||
EndCallActivity.this.finish();
|
||||
} else {
|
||||
ToastUtil.show(R.string.end_resume_call_not_auth);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
Log.e(TAG, "onError: " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(applyButton, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteManager.forwardWebViewActivity(null, HtmlUrlUtils.getPayUrl(mContext, false, HtmlUrlUtils.URL_PAY_COIN));
|
||||
}
|
||||
});
|
||||
findViewById(R.id.close).setOnClickListener(v -> finish());
|
||||
}
|
||||
|
||||
private void follow() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.follow(user.getUser().getId() + "", new HttpCallback<FollowBean>() {
|
||||
@Override
|
||||
public void onSuccess(FollowBean data) {
|
||||
ToastUtil.show(WordUtil.getNewString(R.string.system_tip_success));
|
||||
followButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.ExchangeRecordAdapter;
|
||||
import com.shayu.onetoone.bean.ExchangeRecordModel;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_EXCHANGE_RECORD)
|
||||
public class ExchangeRecordActivity extends AbsOTOActivity {
|
||||
private ExchangeRecordAdapter recordAdapter;
|
||||
private SmartRefreshLayout mRefreshLayout;
|
||||
private SwipeRecyclerView recyclerView;
|
||||
private int page = 1;
|
||||
|
||||
private String type = "10";
|
||||
private String mType = "10";
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_exchange_record;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
if (getIntent() != null && getIntent().getExtras() != null) {
|
||||
mType = getIntent().getExtras().getString("type");
|
||||
if (TextUtils.equals(mType, "yuanbao")) {
|
||||
type = "11";
|
||||
} else {
|
||||
type = "10";
|
||||
}
|
||||
}
|
||||
initView();
|
||||
initData();
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
mRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
||||
recordAdapter = new ExchangeRecordAdapter();
|
||||
recyclerView.setAdapter(recordAdapter);
|
||||
mRefreshLayout.setNestedScrollingEnabled(false);
|
||||
mRefreshLayout.setRefreshHeader(new RongRefreshHeader(mContext));
|
||||
mRefreshLayout.setRefreshFooter(new RongRefreshHeader(mContext));
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
initData();
|
||||
}
|
||||
});
|
||||
this.mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
onConversationListLoadMore();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.one_back), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext).
|
||||
getExchangeRecord("10,11", "3", "2", page, new HttpCallback<List<ExchangeRecordModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<ExchangeRecordModel> data) {
|
||||
if (page != 1 && data.isEmpty()) {
|
||||
mRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
if (page != 1) {
|
||||
recordAdapter.addLst(data);
|
||||
} else {
|
||||
recordAdapter.setList(data);
|
||||
}
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void onConversationListLoadMore() {
|
||||
page++;
|
||||
initData();
|
||||
mRefreshLayout.finishLoadMore();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.widget.flexboxradiogroup.FlexBoxRadioGroup;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_HOME_SCREEN)
|
||||
public class HomeScreenActivity extends AbsOTOActivity {
|
||||
EditText etSearch;
|
||||
TextView tvSearch;
|
||||
LinearLayout ageLayout;
|
||||
LinearLayout sexLayout;
|
||||
LinearLayout authLayout;
|
||||
FlexBoxRadioGroup ageRadioGroup;
|
||||
FlexBoxRadioGroup sexRadioGroup;
|
||||
FlexBoxRadioGroup authRadioGroup;
|
||||
Button apply;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_screen;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
etSearch = findViewById(R.id.edit);
|
||||
tvSearch = findViewById(R.id.search);
|
||||
ageLayout = findViewById(R.id.age_layout);
|
||||
sexLayout = findViewById(R.id.sex_layout);
|
||||
authLayout = findViewById(R.id.auth_layout);
|
||||
ageRadioGroup = findViewById(R.id.age_radio_group);
|
||||
sexRadioGroup = findViewById(R.id.sex_radio_group);
|
||||
authRadioGroup = findViewById(R.id.auth_radio_group);
|
||||
apply = findViewById(R.id.apply);
|
||||
|
||||
|
||||
apply.setOnClickListener(v -> {
|
||||
String age = getRadioButtonTag(ageRadioGroup);
|
||||
String sex = getRadioButtonTag(sexRadioGroup);
|
||||
String auth = getRadioButtonTag(authRadioGroup);
|
||||
if (isRadioButtonEmpty(ageRadioGroup)) {
|
||||
age = "";
|
||||
}
|
||||
if (isRadioButtonEmpty(authRadioGroup)) {
|
||||
auth = "";
|
||||
}
|
||||
if (sex.equals("all")) {
|
||||
sex = "";
|
||||
}
|
||||
if(auth.equals("all")){
|
||||
auth="0";
|
||||
}
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("age", age);
|
||||
bundle.putString("sex", sex);
|
||||
bundle.putString("auth", auth);
|
||||
RouteManager.forwardMainActivityForScreen(bundle);
|
||||
});
|
||||
tvSearch.setOnClickListener(v -> {
|
||||
String search = etSearch.getText().toString();
|
||||
if(StringUtil.isEmpty(search)){
|
||||
ToastUtil.show(R.string.search_empty);
|
||||
return;
|
||||
}
|
||||
Bundle bundle=new Bundle();
|
||||
bundle.putString("search",search);
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_HOME_SEARCH,bundle);
|
||||
});
|
||||
findViewById(R.id.reset).setOnClickListener(v ->{
|
||||
setRadioButtonValue(ageRadioGroup,R.id.age_all);
|
||||
setRadioButtonValue(sexRadioGroup,R.id.sex_all);
|
||||
setRadioButtonValue(authRadioGroup,R.id.auth_all);
|
||||
RouteManager.forwardMainActivity();
|
||||
});
|
||||
}
|
||||
|
||||
String getRadioButtonValue(FlexBoxRadioGroup group) {
|
||||
return ((RadioButton) findViewById(group.getCheckedRadioButtonId())).getText().toString();
|
||||
}
|
||||
String getRadioButtonTag(FlexBoxRadioGroup group) {
|
||||
return ((RadioButton) findViewById(group.getCheckedRadioButtonId())).getTag().toString();
|
||||
}
|
||||
void setRadioButtonValue(FlexBoxRadioGroup group, int id) {
|
||||
group.check(id);
|
||||
}
|
||||
|
||||
boolean isRadioButtonEmpty(FlexBoxRadioGroup group) {
|
||||
RadioButton button = (RadioButton) findViewById(group.getCheckedRadioButtonId());
|
||||
if (button.getTag() == null) {
|
||||
return false;
|
||||
}
|
||||
return button.getTag().toString().equals("all");
|
||||
}
|
||||
|
||||
RadioButton getRadioButton(FlexBoxRadioGroup group) {
|
||||
return findViewById(group.getCheckedRadioButtonId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.HomeHotListAdapter;
|
||||
import com.shayu.onetoone.adapter.HomeRecommendListAdapter;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.yunbao.common.adapter.SpaceGridItemDecoration;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_HOME_SEARCH)
|
||||
public class HomeSearchActivity extends AbsOTOActivity {
|
||||
View viewEmpty;
|
||||
View refresh;
|
||||
SmartRefreshLayout swipeRefreshLayout;
|
||||
RecyclerView searchList;
|
||||
RecyclerView recommendList;
|
||||
EditText edit;
|
||||
TextView searchBtn;
|
||||
int page = 1;
|
||||
HomeRecommendListAdapter searchListAdapter;
|
||||
HomeHotListAdapter recommendListAdapter;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_oto_search;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
viewEmpty = findViewById(R.id.view_empty);
|
||||
refresh = findViewById(R.id.refresh);
|
||||
swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
||||
searchList = findViewById(R.id.searchList);
|
||||
recommendList = findViewById(R.id.recommendList);
|
||||
edit = findViewById(R.id.edit);
|
||||
searchBtn = findViewById(R.id.search);
|
||||
|
||||
searchListAdapter = new HomeRecommendListAdapter(this);
|
||||
recommendListAdapter = new HomeHotListAdapter(this);
|
||||
|
||||
swipeRefreshLayout.autoLoadMore();
|
||||
swipeRefreshLayout.setEnableRefresh(false);
|
||||
swipeRefreshLayout.setRefreshFooter(new RongRefreshHeader(this));
|
||||
swipeRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
search(edit.getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
searchList.setAdapter(searchListAdapter);
|
||||
recommendList.setAdapter(recommendListAdapter);
|
||||
recommendList.addItemDecoration(new SpaceGridItemDecoration(10));
|
||||
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(refresh, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(searchBtn, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
search(edit.getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
edit.setText(getIntent().getExtras().getString("search"));
|
||||
search(edit.getText().toString());
|
||||
refresh();
|
||||
}
|
||||
|
||||
private void search(String key) {
|
||||
if (StringUtil.isEmpty(key)) {
|
||||
ToastUtil.show(R.string.search_empty);
|
||||
return;
|
||||
}
|
||||
OTONetManager.getInstance(mContext)
|
||||
.search(key,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
page + "",
|
||||
new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
if (page == 1 && data.isEmpty()) {
|
||||
searchList.setVisibility(View.GONE);
|
||||
viewEmpty.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
viewEmpty.setVisibility(View.GONE);
|
||||
searchList.setVisibility(View.VISIBLE);
|
||||
if (page != 1 && data.isEmpty()) {
|
||||
page--;
|
||||
swipeRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
if (page == 1) {
|
||||
searchListAdapter.setList(data);
|
||||
} else {
|
||||
searchListAdapter.addLst(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
OTONetManager.getInstance(this)
|
||||
.getSearchRecommend(new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
recommendListAdapter.setList(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.angcyo.tablayout.DslTabLayout;
|
||||
import com.angcyo.tablayout.delegate2.ViewPager2Delegate;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.home.HomeRankFragment;
|
||||
import com.shayu.onetoone.listener.OnAppbarListener;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_HOME_RANK)
|
||||
public class HomepageRankingActivity extends AbsOTOActivity {
|
||||
ViewPager2 viewPager;
|
||||
DslTabLayout dslTabLayout;
|
||||
RadioButton mDay, mWeek;
|
||||
private RadioGroup radioGroup;
|
||||
private ViewPagerChangeCallback viewPagerChangeCallback;
|
||||
List<HomeRankFragment> fragments = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_main_otolist;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
mDay = findViewById(R.id.btn_day);
|
||||
mWeek = findViewById(R.id.btn_week);
|
||||
viewPager = findViewById(R.id.view_pager);
|
||||
dslTabLayout = findViewById(R.id.dslTabLayout);
|
||||
radioGroup = findViewById(R.id.radioGroup);
|
||||
|
||||
viewPagerChangeCallback = new ViewPagerChangeCallback();
|
||||
ViewPager2Delegate.Companion.install(viewPager, dslTabLayout, false);
|
||||
|
||||
fragments.add(new HomeRankFragment(HomeRankFragment.TYPE_CHARM));//魅力
|
||||
fragments.add(new HomeRankFragment(HomeRankFragment.TYPE_WEALTH)); //财富
|
||||
viewPager.setAdapter(new FragmentStateAdapter(this) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
fragments.get(position).setAppbarListener(new OnAppbarListener() {
|
||||
@Override
|
||||
public void onShow(boolean isShow) {
|
||||
if (isShow) {
|
||||
radioGroup.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
radioGroup.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
return fragments.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fragments.size();
|
||||
}
|
||||
});
|
||||
mDay.setOnClickListener(v -> {
|
||||
setRadioColor(mDay, mWeek);
|
||||
fragments.get(viewPager.getCurrentItem()).setDate(HomeRankFragment.DATE_DAY);
|
||||
});
|
||||
mWeek.setOnClickListener(v -> {
|
||||
setRadioColor(mWeek, mDay);
|
||||
fragments.get(viewPager.getCurrentItem()).setDate(HomeRankFragment.DATE_WEEK);
|
||||
});
|
||||
viewPager.registerOnPageChangeCallback(viewPagerChangeCallback);
|
||||
|
||||
findViewById(R.id.back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
viewPager.unregisterOnPageChangeCallback(viewPagerChangeCallback);
|
||||
}
|
||||
|
||||
private void setRadioColor(RadioButton select, RadioButton unSelect) {
|
||||
select.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
unSelect.setTextColor(Color.parseColor("#666666"));
|
||||
select.setBackgroundResource(R.drawable.bg_home_rank_day_select);
|
||||
unSelect.setBackgroundResource(R.drawable.bg_home_rank_day);
|
||||
}
|
||||
|
||||
private class ViewPagerChangeCallback extends ViewPager2.OnPageChangeCallback {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
super.onPageSelected(position);
|
||||
fragments.get(position).setDate(mDay.isChecked() ? HomeRankFragment.DATE_DAY : HomeRankFragment.DATE_WEEK);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,562 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.sInstance;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.login.EntryActivity;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.MainHttpConsts;
|
||||
import com.shayu.onetoone.utils.MainHttpUtil;
|
||||
import com.tencent.rtmp.ITXLivePlayListener;
|
||||
import com.tencent.rtmp.TXLiveBase;
|
||||
import com.tencent.rtmp.TXLiveConstants;
|
||||
import com.tencent.rtmp.TXLivePlayer;
|
||||
import com.tencent.rtmp.ui.TXCloudVideoView;
|
||||
import com.tencent.ugc.TXUGCBase;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.AdBean;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.custom.CircleProgress;
|
||||
import com.yunbao.common.event.DataUserInfoEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.DownloadUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LogUtil;
|
||||
import com.yunbao.common.utils.MD5Util;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 启动Activity
|
||||
*/
|
||||
public class LauncherActivity extends AbsOTOActivity implements View.OnClickListener {
|
||||
|
||||
private static final String TAG = "LauncherActivity";
|
||||
private static final int WHAT_GET_CONFIG = 0;
|
||||
private static final int WHAT_COUNT_DOWN = 1;
|
||||
protected Context mContext;
|
||||
private Handler mHandler;
|
||||
private ViewGroup mRoot;
|
||||
private ImageView mCover;
|
||||
private ViewGroup mContainer;
|
||||
private CircleProgress mCircleProgress;
|
||||
private List<AdBean> mAdList;
|
||||
private List<ImageView> mImageViewList;
|
||||
private int mMaxProgressVal;
|
||||
private int mCurProgressVal;
|
||||
private int mAdIndex;
|
||||
private int mInterval = 2000;
|
||||
private View mBtnSkipImage;
|
||||
private View mBtnSkipVideo;
|
||||
private TXCloudVideoView mTXCloudVideoView;
|
||||
private TXLivePlayer mPlayer;
|
||||
private boolean mPaused;
|
||||
private int mVideoLastProgress;
|
||||
private boolean mForward;
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_launcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
// getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
|
||||
// EventBus.getDefault().register(this);
|
||||
setStatusBar();
|
||||
setContentView(R.layout.activity_launcher);
|
||||
mContext = this;
|
||||
mRoot = findViewById(R.id.root);
|
||||
mCover = findViewById(R.id.cover);
|
||||
mCircleProgress = findViewById(R.id.progress);
|
||||
mContainer = findViewById(R.id.container);
|
||||
mBtnSkipImage = findViewById(R.id.btn_skip_img);
|
||||
mBtnSkipVideo = findViewById(R.id.btn_skip_video);
|
||||
mBtnSkipImage.setOnClickListener(this);
|
||||
mBtnSkipVideo.setOnClickListener(this);
|
||||
ImgLoader.display(mContext, R.mipmap.screen, mCover);
|
||||
mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case WHAT_GET_CONFIG:
|
||||
getConfig();
|
||||
break;
|
||||
case WHAT_COUNT_DOWN:
|
||||
updateCountDown();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
||||
LogUtil.uploadErrorLog(sInstance);
|
||||
SpUtil.getInstance().setBooleanValue("NOTIFICATION", NotificationManagerCompat.from(this).areNotificationsEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片倒计时
|
||||
*/
|
||||
private void updateCountDown() {
|
||||
mCurProgressVal += 100;
|
||||
if (mCurProgressVal > mMaxProgressVal) {
|
||||
return;
|
||||
}
|
||||
if (mCircleProgress != null) {
|
||||
mCircleProgress.setCurProgress(mCurProgressVal);
|
||||
}
|
||||
int index = mCurProgressVal / mInterval;
|
||||
if (index < mAdList.size() && mAdIndex != index) {
|
||||
View v = mImageViewList.get(mAdIndex);
|
||||
if (v != null && v.getVisibility() == View.VISIBLE) {
|
||||
v.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
mAdIndex = mCurProgressVal / mInterval;
|
||||
}
|
||||
if (mCurProgressVal < mMaxProgressVal) {
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_COUNT_DOWN, 100);
|
||||
}
|
||||
} else if (mCurProgressVal == mMaxProgressVal) {
|
||||
checkUidAndToken();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取Config信息
|
||||
*/
|
||||
private void getConfig() {
|
||||
CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() {
|
||||
@Override
|
||||
public void callback(ConfigBean bean) {
|
||||
if (bean != null) {
|
||||
L.e(TAG, "----------> getPaster360Url:" + bean.getBeautyKey() + " " + bean.getPaster360Url());
|
||||
CommonAppConfig.getInstance().setBeautySdkType(bean.getSproutType());
|
||||
//转盘开关
|
||||
CommonAppConfig.getInstance().setTurnTableEnable(bean.getTurntableEnable());
|
||||
CommonAppConfig.getInstance().setBeauty360TieZhiUrl(bean.getPaster360Url());
|
||||
CommonAppConfig.getInstance().setAnchorPkTime(bean.getPkTime());
|
||||
if (!TextUtils.isEmpty(bean.getTxVideoUgcLicenceUrl()) && !TextUtils.isEmpty(bean.getTxVideoUgcKey()))
|
||||
Log.i("tvv", bean.getTxVideoUgcLicenceUrl() + "是" + bean.getTxVideoUgcKey());
|
||||
TXLiveBase.getInstance().setLicence(LauncherActivity.this, bean.getTxVideoUgcLicenceUrl(), bean.getTxVideoUgcKey());
|
||||
TXUGCBase.getInstance().setLicence(LauncherActivity.this, bean.getTxPlayUgcLicenceUrl(), bean.getTxVideoUgcKey());
|
||||
|
||||
String adInfo = bean.getAdInfo();
|
||||
if (!TextUtils.isEmpty(adInfo)) {
|
||||
JSONObject obj = JSON.parseObject(adInfo);
|
||||
Log.i(TAG, "callback: " + adInfo);
|
||||
if (obj.getIntValue("switch") == 1) {
|
||||
List<AdBean> list = JSON.parseArray(obj.getString("list"), AdBean.class);
|
||||
if (list != null && list.size() > 0) {
|
||||
mAdList = list;
|
||||
mInterval = obj.getIntValue("time") * 1000;
|
||||
if (mContainer != null) {
|
||||
mContainer.setOnClickListener(LauncherActivity.this);
|
||||
}
|
||||
String[] uidAndToken = SpUtil.getInstance().getMultiStringValue(
|
||||
new String[]{SpUtil.UID, SpUtil.TOKEN});
|
||||
final String uid = uidAndToken[0];
|
||||
final String token = uidAndToken[1];
|
||||
if (!TextUtils.isEmpty(uid) && !TextUtils.isEmpty(token)) {
|
||||
playAD(obj.getIntValue("type") == 0);
|
||||
} else {
|
||||
releaseVideo();
|
||||
RouteManager.forwardEntryActivity();
|
||||
LauncherActivity.this.finish();
|
||||
}
|
||||
} else {
|
||||
checkUidAndToken();
|
||||
}
|
||||
} else {
|
||||
checkUidAndToken();
|
||||
}
|
||||
} else {
|
||||
checkUidAndToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查uid和token是否存在
|
||||
*/
|
||||
private void checkUidAndToken() {
|
||||
if (mForward) {
|
||||
return;
|
||||
}
|
||||
mForward = true;
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mHandler = null;
|
||||
}
|
||||
IMLoginModel model = IMLoginManager.get(this).getUserInfo();
|
||||
if (model != null) {
|
||||
IMLoginManager.get(this).upDataUserInfo();
|
||||
//融云连接服务器
|
||||
RongcloudIMManager.connectIM(this);
|
||||
forwardMainActivity();
|
||||
} else {
|
||||
//兼容老版本
|
||||
if (IMLoginManager.get(this).checkOLd()) {
|
||||
IMLoginManager.get(this).upDataUserInfo();
|
||||
} else {
|
||||
releaseVideo();
|
||||
RouteManager.forwardEntryActivity();
|
||||
this.finish();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 跳转到首页
|
||||
*/
|
||||
private void forwardMainActivity() {
|
||||
releaseVideo();
|
||||
Intent intent = new Intent(
|
||||
LauncherActivity.this, MainActivity.class);
|
||||
intent.putExtra(Constants.SHOW_INVITE, false);
|
||||
|
||||
if (getIntent().getStringExtra("liveid") != null) {
|
||||
intent.putExtra("liveid", getIntent().getStringExtra("liveid"));
|
||||
}
|
||||
if (getIntent().getStringExtra("type") != null) {
|
||||
intent.putExtra("type", getIntent().getStringExtra("type"));
|
||||
}
|
||||
|
||||
if (getIntent().getStringExtra("activityUrl") != null) {
|
||||
intent.putExtra("activityUrl", getIntent().getStringExtra("activityUrl"));
|
||||
}
|
||||
if (mImageViewList != null && mImageViewList.size() > 0) {
|
||||
Log.i(TAG, "forwardMainActivity: " + mImageViewList.size());
|
||||
AdBean bean = mAdList.get(0);
|
||||
if (bean != null && bean.getAnimation() == 1) {
|
||||
intent.putExtra("ad_url", mAdList.get(0).getUrl());
|
||||
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(LauncherActivity.this, mImageViewList.get(0), "ad_img_0").toBundle();
|
||||
LauncherActivity.this.startActivity(intent, bundle);
|
||||
} else {
|
||||
LauncherActivity.this.startActivity(intent);
|
||||
}
|
||||
} else {
|
||||
LauncherActivity.this.startActivity(intent);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mHandler = null;
|
||||
}
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_BASE_INFO);
|
||||
CommonHttpUtil.cancel(CommonHttpConsts.GET_CONFIG);
|
||||
releaseVideo();
|
||||
// if (mLauncherAdViewHolder != null) {
|
||||
// mLauncherAdViewHolder.release();
|
||||
// }
|
||||
// mLauncherAdViewHolder = null;
|
||||
super.onDestroy();
|
||||
L.e(TAG, "----------> onDestroy");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置透明状态栏
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_skip_img || i == R.id.btn_skip_video) {
|
||||
if (mBtnSkipImage != null) {
|
||||
mBtnSkipImage.setClickable(false);
|
||||
}
|
||||
if (mBtnSkipVideo != null) {
|
||||
mBtnSkipVideo.setClickable(false);
|
||||
}
|
||||
checkUidAndToken();
|
||||
} else if (i == R.id.container) {
|
||||
// clickAD();
|
||||
checkUidAndToken();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击广告
|
||||
*/
|
||||
private void clickAD() {
|
||||
if (mAdList != null && mAdList.size() > mAdIndex) {
|
||||
AdBean adBean = mAdList.get(mAdIndex);
|
||||
if (adBean != null) {
|
||||
String link = adBean.getLink();
|
||||
if (!TextUtils.isEmpty(link)) {
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
if (mContainer != null) {
|
||||
mContainer.setClickable(false);
|
||||
}
|
||||
releaseVideo();
|
||||
// if (mLauncherAdViewHolder == null) {
|
||||
// mLauncherAdViewHolder = new LauncherAdViewHolder(mContext, mRoot, link + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken());
|
||||
// mLauncherAdViewHolder.addToParent();
|
||||
// mLauncherAdViewHolder.loadData();
|
||||
// mLauncherAdViewHolder.show();
|
||||
// mLauncherAdViewHolder.setActionListener(new LauncherAdViewHolder.ActionListener() {
|
||||
// @Override
|
||||
// public void onHideClick() {
|
||||
// checkUidAndToken();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void releaseVideo() {
|
||||
if (mPlayer != null) {
|
||||
mPlayer.stopPlay(false);
|
||||
mPlayer.setPlayListener(null);
|
||||
}
|
||||
mPlayer = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 播放广告
|
||||
*/
|
||||
private void playAD(boolean isImage) {
|
||||
if (mContainer == null) {
|
||||
return;
|
||||
}
|
||||
if (isImage) {
|
||||
int imgSize = mAdList.size();
|
||||
if (imgSize > 0) {
|
||||
mImageViewList = new ArrayList<>();
|
||||
for (int i = 0; i < imgSize; i++) {
|
||||
ImageView imageView = new ImageView(mContext);
|
||||
imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
imageView.setBackgroundColor(0xffffffff);
|
||||
imageView.setTransitionName("ad_img_" + i);
|
||||
mImageViewList.add(imageView);
|
||||
ImgLoader.display(mContext, mAdList.get(i).getUrl(), imageView);
|
||||
}
|
||||
for (int i = imgSize - 1; i >= 0; i--) {
|
||||
mContainer.addView(mImageViewList.get(i));
|
||||
}
|
||||
if (mBtnSkipImage != null && mBtnSkipImage.getVisibility() != View.VISIBLE) {
|
||||
mBtnSkipImage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mMaxProgressVal = imgSize * mInterval;
|
||||
if (mCircleProgress != null) {
|
||||
mCircleProgress.setMaxProgress(mMaxProgressVal);
|
||||
}
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_COUNT_DOWN, 100);
|
||||
}
|
||||
if (mCover != null && mCover.getVisibility() == View.VISIBLE) {
|
||||
mCover.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
} else {
|
||||
checkUidAndToken();
|
||||
}
|
||||
} else {
|
||||
if (mAdList == null || mAdList.size() == 0) {
|
||||
checkUidAndToken();
|
||||
return;
|
||||
}
|
||||
String videoUrl = mAdList.get(0).getUrl();
|
||||
if (TextUtils.isEmpty(videoUrl)) {
|
||||
checkUidAndToken();
|
||||
return;
|
||||
}
|
||||
String videoFileName = MD5Util.getMD5(videoUrl);
|
||||
if (TextUtils.isEmpty(videoFileName)) {
|
||||
checkUidAndToken();
|
||||
return;
|
||||
}
|
||||
File file = new File(getCacheDir(), videoFileName);
|
||||
if (file.exists()) {
|
||||
playAdVideo(file);
|
||||
} else {
|
||||
downloadAdFile(videoUrl, videoFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
mPaused = true;
|
||||
if (mPlayer != null && mPlayer.isPlaying()) {
|
||||
mPlayer.setMute(true);
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (mPaused) {
|
||||
if (mPlayer != null && mPlayer.isPlaying()) {
|
||||
mPlayer.setMute(false);
|
||||
}
|
||||
}
|
||||
mPaused = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载视频
|
||||
*/
|
||||
private void downloadAdFile(String url, String fileName) {
|
||||
DownloadUtil downloadUtil = new DownloadUtil();
|
||||
downloadUtil.download("ad_video", getCacheDir(), fileName, url, new DownloadUtil.Callback() {
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
playAdVideo(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
checkUidAndToken();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 播放视频
|
||||
*/
|
||||
private void playAdVideo(File videoFile) {
|
||||
if (mBtnSkipVideo != null && mBtnSkipVideo.getVisibility() != View.VISIBLE) {
|
||||
mBtnSkipVideo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mTXCloudVideoView = new TXCloudVideoView(mContext);
|
||||
mTXCloudVideoView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
mTXCloudVideoView.setRenderMode(TXLiveConstants.RENDER_MODE_FULL_FILL_SCREEN);
|
||||
mContainer.addView(mTXCloudVideoView);
|
||||
mPlayer = new TXLivePlayer(mContext);
|
||||
mPlayer.setPlayerView(mTXCloudVideoView);
|
||||
mPlayer.setAutoPlay(true);
|
||||
mPlayer.setPlayListener(new ITXLivePlayListener() {
|
||||
@Override
|
||||
public void onPlayEvent(int e, Bundle bundle) {
|
||||
if (e == TXLiveConstants.PLAY_EVT_PLAY_END) {//获取到视频播放完毕的回调
|
||||
checkUidAndToken();
|
||||
L.e(TAG, "视频播放结束------>");
|
||||
} else if (e == TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION) {////获取到视频宽高回调
|
||||
float videoWidth = bundle.getInt("EVT_PARAM1", 0);
|
||||
float videoHeight = bundle.getInt("EVT_PARAM2", 0);
|
||||
if (mTXCloudVideoView != null && videoWidth > 0 && videoHeight > 0) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mTXCloudVideoView.getLayoutParams();
|
||||
int targetH = 0;
|
||||
if (videoWidth >= videoHeight) {//横屏
|
||||
params.gravity = Gravity.CENTER_VERTICAL;
|
||||
targetH = (int) (mTXCloudVideoView.getWidth() / videoWidth * videoHeight);
|
||||
} else {
|
||||
targetH = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
}
|
||||
if (targetH != params.height) {
|
||||
params.height = targetH;
|
||||
mTXCloudVideoView.requestLayout();
|
||||
}
|
||||
}
|
||||
} else if (e == TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME) {
|
||||
if (mCover != null && mCover.getVisibility() == View.VISIBLE) {
|
||||
mCover.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
} else if (e == TXLiveConstants.PLAY_ERR_NET_DISCONNECT ||
|
||||
e == TXLiveConstants.PLAY_ERR_FILE_NOT_FOUND) {
|
||||
ToastUtil.show(mContext.getString(R.string.live_play_error));
|
||||
checkUidAndToken();
|
||||
} else if (e == TXLiveConstants.PLAY_EVT_PLAY_PROGRESS) {
|
||||
int progress = bundle.getInt("EVT_PLAY_PROGRESS_MS");
|
||||
if (mVideoLastProgress == progress) {
|
||||
L.e(TAG, "视频播放结束------>");
|
||||
checkUidAndToken();
|
||||
} else {
|
||||
mVideoLastProgress = progress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetStatus(Bundle bundle) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
mPlayer.startPlay(videoFile.getAbsolutePath(), TXLivePlayer.PLAY_TYPE_LOCAL_VIDEO);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onDataUserInfoEvent(DataUserInfoEvent event) {
|
||||
if (event.isUpDataSuccess()) {
|
||||
//融云连接服务器
|
||||
RongcloudIMManager.connectIM(getApplication());
|
||||
forwardMainActivity();
|
||||
} else {
|
||||
releaseVideo();
|
||||
RouteManager.forwardEntryActivity();
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,455 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.angcyo.tablayout.DslTabLayout;
|
||||
import com.angcyo.tablayout.DslTabLayoutConfig;
|
||||
import com.angcyo.tablayout.delegate2.ViewPager2Delegate;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.shayu.onetoone.AppContext;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.activity.fragments.DynamicFragment;
|
||||
import com.shayu.onetoone.activity.fragments.FriendsFragment;
|
||||
import com.shayu.onetoone.activity.fragments.LiveFragment;
|
||||
import com.shayu.onetoone.activity.fragments.MessageFragment;
|
||||
import com.shayu.onetoone.activity.fragments.MyFragment;
|
||||
import com.shayu.onetoone.activity.fragments.message.MsgMessageFragment;
|
||||
import com.shayu.onetoone.activity.message.ChatActivity;
|
||||
import com.shayu.onetoone.bean.MatchingItemSizeBean;
|
||||
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||
import com.shayu.onetoone.dialog.FirstTipsDialog;
|
||||
import com.shayu.onetoone.event.HomeBusEvent;
|
||||
import com.shayu.onetoone.event.MessageMsgBusEvent;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.CallClientManager;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.AnchorStartLiveBean;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.event.RongIMConnectionStatusEvent;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.APKManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.VersionUtil;
|
||||
import com.yunbao.common.views.APKUpdateCustomPopup;
|
||||
import com.yunbao.common.views.APKUpdateOneToOnePopup;
|
||||
import com.yunbao.main.dialog.AnchorStartLiveNotifyDialog;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCConfig;
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import io.rong.imkit.manager.UnReadMessageManager;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.push.PushManager;
|
||||
import io.rong.push.PushType;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.jvm.functions.Function4;
|
||||
|
||||
/**
|
||||
* 主页Activity
|
||||
*/
|
||||
@Route(path = RouteManager.ACTIVITY_MAIN)
|
||||
public class MainActivity extends AbsOTOActivity {
|
||||
List<BaseFragment> fragments = new ArrayList<>();
|
||||
private ViewPager2 viewPager;
|
||||
private DslTabLayout dslTabLayout;
|
||||
private long mLastClickBackTime;//上次点击back键的时间
|
||||
private boolean isInstallApk = false;
|
||||
private static final String TAG = "MainActivity";
|
||||
private List<AnchorStartLiveBean> startListNotifyList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
Bus.getOn(this);
|
||||
fragments.add(new FriendsFragment());
|
||||
fragments.add(new LiveFragment());
|
||||
fragments.add(new DynamicFragment());
|
||||
fragments.add(new MessageFragment());
|
||||
fragments.add(new MyFragment());
|
||||
|
||||
viewPager = findViewById(R.id.viewPager);
|
||||
dslTabLayout = findViewById(R.id.dslTabLayout);
|
||||
|
||||
viewPager.setAdapter(new FragmentStateAdapter(this) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
return fragments.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fragments.size();
|
||||
}
|
||||
});
|
||||
viewPager.setUserInputEnabled(false);
|
||||
ViewPager2Delegate.Companion.install(viewPager, dslTabLayout, false);
|
||||
|
||||
dslTabLayout.configTabLayoutConfig(new Function1<DslTabLayoutConfig, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(DslTabLayoutConfig dslTabLayoutConfig) {
|
||||
dslTabLayoutConfig.setOnSelectItemView(new Function4<View, Integer, Boolean, Boolean, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(View itemView, Integer index, Boolean select, Boolean fromUse) {
|
||||
if (select) {
|
||||
viewPager.setCurrentItem(index);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
});
|
||||
RongcloudIMManager.connectIM(mContext);
|
||||
showRedPoint(-1);
|
||||
UnReadMessageManager.getInstance().addObserver(new Conversation.ConversationType[]{Conversation.ConversationType.SYSTEM, Conversation.ConversationType.PRIVATE}, new UnReadMessageManager.IUnReadMessageObserver() {
|
||||
@Override
|
||||
public void onCountChanged(int count) {
|
||||
showRedPoint(count);
|
||||
}
|
||||
});
|
||||
CallClientManager.getManager();
|
||||
checkVersion();
|
||||
initPDLive();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查版本更新
|
||||
*/
|
||||
private void checkVersion() {
|
||||
if (true)
|
||||
return;
|
||||
CommonAppConfig.getInstance().getConfig(new CommonCallback<ConfigBean>() {
|
||||
@Override
|
||||
public void callback(ConfigBean configBean) {
|
||||
if (configBean != null) {
|
||||
if (configBean.getMaintainSwitch() == 1) {//开启维护
|
||||
DialogUitl.showSimpleTipDialog(mContext, mContext.getString(R.string.main_maintain_notice), configBean.getMaintainTips());
|
||||
}
|
||||
if (!VersionUtil.isLatest(configBean.getVersion())) {
|
||||
if (!APKManager.get().getApkVerNew()) {
|
||||
|
||||
new XPopup.Builder(mContext)
|
||||
.isDestroyOnDismiss(true)
|
||||
.dismissOnBackPressed(false) // 按返回键是否关闭弹窗,默认为true
|
||||
.dismissOnTouchOutside(false) // 点击外部是否关闭弹窗,默认为true
|
||||
.asCustom(new APKUpdateOneToOnePopup(MainActivity.this, false)
|
||||
.setOnShowListener(view -> isInstallApk = true))
|
||||
.show();
|
||||
}
|
||||
} else {
|
||||
//requestBonus();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initFirstLoginTips() {
|
||||
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getMatchingNum(new HttpCallback<MatchingItemSizeBean>() {
|
||||
@Override
|
||||
public void onSuccess(MatchingItemSizeBean data) {
|
||||
boolean isHome = false;
|
||||
boolean isMan = false;
|
||||
boolean isShow = true;
|
||||
if (data.getLogin() == 0) {
|
||||
isHome = true;
|
||||
}
|
||||
if (data.getChat() == 0) {
|
||||
isMan = UserManager.getUserBean().getUser().getSex() == 1;
|
||||
}
|
||||
if (!isHome && data.getChat() != 0) {
|
||||
isShow = false;
|
||||
}
|
||||
SpUtil.setStringValue("match_data", JSONObject.toJSONString(data));
|
||||
Bus.get().post(new HomeBusEvent(HomeBusEvent.TYPE_UPDATE_MATCHING, data.getNum()));
|
||||
if (isShow) {
|
||||
new FirstTipsDialog(mContext)
|
||||
.setHome(isHome)
|
||||
.setMan(isMan)
|
||||
.setOnItemClickListener(new OnItemClickListener<FirstTipsDialog>() {
|
||||
@Override
|
||||
public void onItemClick(FirstTipsDialog dialog, int position) {
|
||||
if (position == 0) {
|
||||
SendMessageManager.matching(new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean bean) {
|
||||
super.onSuccess(token, bean);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("type", ChatActivity.CALL_CHAT_TYPE_MATCH);
|
||||
bundle.putString("data", JSONObject.toJSONString(bean));
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_MATCHING, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg, SendConsumeBean bean) {
|
||||
super.onError(status, msg, bean);
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_MATCHING);
|
||||
}
|
||||
});
|
||||
OTONetManager.getInstance(mContext).setFiled("is_login", "1", null);
|
||||
} else {
|
||||
viewPager.setCurrentItem(2);
|
||||
OTONetManager.getInstance(mContext).setFiled("is_chat", "1", null);
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.showDialog();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
checkUserInfoIsSet();
|
||||
initFirstLoginTips();
|
||||
if (isInstallApk) {
|
||||
checkVersion();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测用户是否设置个人信息
|
||||
*/
|
||||
private void checkUserInfoIsSet() {
|
||||
OTONetManager.getInstance(mContext).getBaseInfos(false, new com.yunbao.common.http.base.HttpCallback<com.shayu.onetoone.bean.UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(com.shayu.onetoone.bean.UserBean data) {
|
||||
UserManager.saveUserBean(mContext, data);
|
||||
if (data.getStatus() == 0) {
|
||||
RouteManager.forwardCompleteActivity();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showRedPoint(int count) {
|
||||
//大于0则是通过会话未读监听器获取到的数,则不用再调用获取未读数接口了
|
||||
if (count >= 0) {
|
||||
updateUnreadCount(MsgMessageFragment.systemPoint + count);
|
||||
Bus.get().post(new MessageMsgBusEvent(MessageMsgBusEvent.TYPE_UPDATE_POINT, MsgMessageFragment.systemPoint + count));
|
||||
return;
|
||||
}
|
||||
|
||||
RongIMClient.getInstance().getUnreadCount(new Conversation.ConversationType[]{Conversation.ConversationType.PRIVATE}
|
||||
, false
|
||||
, new RongIMClient.ResultCallback<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(Integer integer) {
|
||||
updateUnreadCount(MsgMessageFragment.systemPoint + integer);
|
||||
Bus.get().post(new MessageMsgBusEvent(MessageMsgBusEvent.TYPE_UPDATE_POINT, MsgMessageFragment.systemPoint + integer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateUnreadCount(int count) {
|
||||
dslTabLayout.setDrawBadge(count > 0);
|
||||
if (count > 99) {
|
||||
dslTabLayout.updateTabBadge(2, "99+");
|
||||
} else {
|
||||
dslTabLayout.updateTabBadge(2, count + "");
|
||||
}
|
||||
}
|
||||
|
||||
private void initPDLive() {
|
||||
RCRTCConfig.Builder config = RCRTCConfig.Builder.create();
|
||||
config.enableEncoderTexture(false);//新娱美颜 需要关闭这个
|
||||
RCRTCEngine.getInstance().init(this, config.build());
|
||||
|
||||
if (getIntent().getStringExtra("liveid") != null) {
|
||||
LiveHttpUtil.getLiveInfo(getIntent().getStringExtra("liveid") + "", new com.yunbao.common.http.HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ToastUtil.show("直播已结束");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("2")) {
|
||||
//跳转消息列表
|
||||
if (viewPager != null) {
|
||||
viewPager.setCurrentItem(2);
|
||||
}
|
||||
|
||||
} else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("8")) {
|
||||
WebViewActivity.forward(mContext, getIntent().getStringExtra("activityUrl"), true, false);
|
||||
}
|
||||
FirebaseMessaging.getInstance().getToken()
|
||||
.addOnCompleteListener(new OnCompleteListener<String>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<String> task) {
|
||||
if (!task.isSuccessful()) {
|
||||
Log.w(TAG, "Fetching FCM registration token failed", task.getException());
|
||||
return;
|
||||
}
|
||||
|
||||
// Get new FCM registration token
|
||||
String token = task.getResult();
|
||||
|
||||
// Log and toast
|
||||
Log.d(TAG, token);
|
||||
PushManager.getInstance()
|
||||
.onReceiveToken(MainActivity.this, PushType.GOOGLE_FCM, token);
|
||||
// Toast.makeText(MainActivity.this, token, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
CommonAppConfig.getInstance().setLaunched(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == 998) {
|
||||
checkVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
long curTime = System.currentTimeMillis();
|
||||
if (curTime - mLastClickBackTime > 2000) {
|
||||
mLastClickBackTime = curTime;
|
||||
ToastUtil.show(R.string.main_click_next_exit);
|
||||
return;
|
||||
}
|
||||
//super.onBackPressed();
|
||||
AppContext.exit();
|
||||
}
|
||||
|
||||
private void notifyLiveFlot() {
|
||||
if (startListNotifyList.iterator().hasNext()) {
|
||||
AnchorStartLiveBean bean = startListNotifyList.iterator().next();
|
||||
new AnchorStartLiveNotifyDialog(mContext, bean)
|
||||
.setOnDismissListener(dialog -> {
|
||||
startListNotifyList.remove(bean);
|
||||
if (startListNotifyList.iterator().hasNext()) {
|
||||
notifyLiveFlot();
|
||||
}
|
||||
})
|
||||
.showDialog();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void busEvent(MessageMsgBusEvent event) {
|
||||
if (event.getType() == MessageMsgBusEvent.TYPE_ALL_READ) {
|
||||
updateUnreadCount(0);
|
||||
} else if (event.getType() == MessageMsgBusEvent.TYPE_UPDATE_POINT) {
|
||||
if (event.getNum() == -1) {
|
||||
showRedPoint(-1);
|
||||
}
|
||||
} else if (event.getType() == MessageMsgBusEvent.TYPE_TO_HOME_PAGE) {
|
||||
viewPager.setCurrentItem(event.getNum());
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void busEvent(AnchorStartLiveBean event) {
|
||||
if (!IMLoginManager.get(mContext).isLiveNotifySettings()) return;
|
||||
|
||||
if (startListNotifyList.isEmpty()) {
|
||||
startListNotifyList.add(event);
|
||||
notifyLiveFlot();
|
||||
} else {
|
||||
startListNotifyList.add(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户被踢下线
|
||||
*
|
||||
* @param model
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void userSignOut(RongIMConnectionStatusEvent model) {
|
||||
IMLoginManager.get(mContext).logout(this);
|
||||
UserManager.logout();
|
||||
CommonAppConfig.getInstance().clearLoginInfo();
|
||||
RouteManager.forwardEntryActivity();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.message.ChatActivity;
|
||||
import com.shayu.onetoone.bean.MatchingInfoBean;
|
||||
import com.shayu.onetoone.bean.MatchingInfoUserBean;
|
||||
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.dialog.TipsDialog;
|
||||
import com.shayu.onetoone.event.MessageMsgBusEvent;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.shayu.onetoone.utils.ConversationUtils;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_MATCHING)
|
||||
public class MatchingActivity extends AbsOTOActivity {
|
||||
private Task task;
|
||||
private Handler handler;
|
||||
private RoundedImageView user1, user2, user3, user4, user5;
|
||||
private TextView num;
|
||||
private ImageView back;
|
||||
List<RoundedImageView> imageViewList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_matching;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
if (initView()) {
|
||||
task = new Task();
|
||||
new Timer().schedule(task, 10000, 10000);
|
||||
}
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
handler = null;
|
||||
}
|
||||
|
||||
private boolean initView() {
|
||||
user1 = findViewById(R.id.user1);
|
||||
user2 = findViewById(R.id.user2);
|
||||
user3 = findViewById(R.id.user3);
|
||||
user4 = findViewById(R.id.user4);
|
||||
user5 = findViewById(R.id.user5);
|
||||
num = findViewById(R.id.num);
|
||||
back = findViewById(R.id.back);
|
||||
imageViewList.add(user1);
|
||||
imageViewList.add(user2);
|
||||
imageViewList.add(user3);
|
||||
imageViewList.add(user4);
|
||||
imageViewList.add(user5);
|
||||
back.setOnClickListener(v -> {
|
||||
onBack();
|
||||
});
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
if (bundle != null) {
|
||||
String data = bundle.getString("data");
|
||||
bundle.putInt("type", ChatActivity.CALL_CHAT_TYPE_MATCH);
|
||||
if (data != null) {
|
||||
bean = JSONObject.parseObject(data, SendConsumeBean.class);
|
||||
if (bean != null) {
|
||||
MatchingActivity.this.bundle = bundle;
|
||||
new Handler(Looper.getMainLooper()).postDelayed(toCallRunnable, 1000);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void onBack() {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.matching_quit_title))
|
||||
.setApplyText(WordUtil.getNewString(R.string.matching_quit_cancel))
|
||||
.setCancelText(WordUtil.getNewString(R.string.matching_quit_apply))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onCancel(Dialog dialog) {
|
||||
super.onCancel(dialog);
|
||||
bean = null;
|
||||
handler.removeCallbacks(toCallRunnable);
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
MatchingActivity.this.finish();
|
||||
}
|
||||
}).showDialog();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getMatchingInfo(new HttpCallback<MatchingInfoBean>() {
|
||||
@Override
|
||||
public void onSuccess(MatchingInfoBean data) {
|
||||
List<MatchingInfoUserBean> list = data.getList();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ImgLoader.display(mContext, list.get(i).getAvatar(), imageViewList.get(i));
|
||||
}
|
||||
num.setText(data.getPeople() + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Bundle bundle;
|
||||
private Runnable toCallRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
ConversationUtils.startConversation(mContext, bean.getMateUser().getUser().getId() + "", bundle);
|
||||
MatchingActivity.this.finish();
|
||||
}
|
||||
};
|
||||
SendConsumeBean bean;
|
||||
|
||||
private void call() {
|
||||
handler.post(() -> ToastUtil.showDebug("匹配"));
|
||||
SendMessageManager.matching(new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean b) {
|
||||
super.onSuccess(token, b);
|
||||
bean = b;
|
||||
task.cancel();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("type", ChatActivity.CALL_CHAT_TYPE_MATCH);
|
||||
bundle.putString("data", JSONObject.toJSONString(bean));
|
||||
MatchingActivity.this.bundle = bundle;
|
||||
handler.postDelayed(toCallRunnable, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg, SendConsumeBean bean) {
|
||||
super.onError(status, msg, bean);
|
||||
if (bean.getCode() == 503) {
|
||||
handler.post(() -> ToastUtil.showDebug("没人,继续"));
|
||||
} else if (status == OnSendMessageListener.STATUS_NOT_PRICE) {
|
||||
task.cancel();
|
||||
handler.post(() -> {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.money_title))
|
||||
.setApplyText(WordUtil.getNewString(R.string.money_apply))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
}
|
||||
})
|
||||
.setCancelText(WordUtil.getNewString(R.string.money_cancel))
|
||||
.showDialog();
|
||||
});
|
||||
MatchingActivity.this.finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class Task extends TimerTask {
|
||||
final int MAX = 2;
|
||||
int index = MAX;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (index != 0) {
|
||||
call();
|
||||
} else {
|
||||
handler.post(() -> {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.matching_wait_title))
|
||||
.setApplyText(WordUtil.getNewString(R.string.matching_wait_apply))
|
||||
.setCancelText(WordUtil.getNewString(R.string.matching_wait_cancel))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onCancel(Dialog dialog) {
|
||||
super.onCancel(dialog);
|
||||
index = MAX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
bean = null;
|
||||
handler.removeCallbacks(toCallRunnable);
|
||||
task.cancel();
|
||||
task = null;
|
||||
MatchingActivity.this.finish();
|
||||
Bus.get().post(new MessageMsgBusEvent(MessageMsgBusEvent.TYPE_TO_HOME_PAGE, 1));
|
||||
}
|
||||
}).showDialog();
|
||||
});
|
||||
|
||||
}
|
||||
index--;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancel() {
|
||||
handler.post(() -> ToastUtil.showDebug("取消"));
|
||||
return super.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
onBack();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.MyArnAdapter;
|
||||
import com.shayu.onetoone.bean.FriendAppMoneyLogModel;
|
||||
import com.shayu.onetoone.bean.FriendAppMoneySumModel;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_MY_ARN)
|
||||
public class MyArnActivity extends AbsOTOActivity {
|
||||
private TextView todayEarnings, cumulativeIncome, withdrawalSum,withdrawalMoney;
|
||||
|
||||
private MyArnAdapter myArnAdapter;
|
||||
private SwipeRecyclerView myArnList;
|
||||
private SmartRefreshLayout mRefreshLayout;
|
||||
private int page = 1;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_my_arnings;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
todayEarnings = findViewById(R.id.today_earnings);
|
||||
cumulativeIncome = findViewById(R.id.cumulative_income);
|
||||
myArnList = findViewById(R.id.my_arn_list);
|
||||
withdrawalSum = findViewById(R.id.withdrawal_sum);
|
||||
withdrawalMoney = findViewById(R.id.withdrawal_money);
|
||||
mRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
||||
myArnList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
myArnAdapter = new MyArnAdapter();
|
||||
myArnList.setAdapter(myArnAdapter);
|
||||
mRefreshLayout.setNestedScrollingEnabled(false);
|
||||
mRefreshLayout.setRefreshHeader(new RongRefreshHeader(mContext));
|
||||
mRefreshLayout.setRefreshFooter(new RongRefreshHeader(mContext));
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
refreshMyArn();
|
||||
}
|
||||
});
|
||||
this.mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
onConversationListLoadMore();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.my_arn_back), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.diamond_star_coins), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("type", "yuanbao");
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_DIAMOND_EXCHANGE, bundle);
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.info), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteManager.forwardWebViewActivity(WordUtil.getNewString(R.string.my_arnings_reward_description),
|
||||
"file:android_asset/Reward_instructions.html"
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
OTONetManager.getInstance(mContext).getFriendAppMoneySum(new HttpCallback<FriendAppMoneySumModel>() {
|
||||
@Override
|
||||
public void onSuccess(FriendAppMoneySumModel data) {
|
||||
todayEarnings.setText(data.getToday());
|
||||
cumulativeIncome.setText(data.getSum());
|
||||
withdrawalSum.setText(data.getWithdrawalModel().getSum());
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("$ ")
|
||||
.append(data.getWithdrawalModel().getMoney());
|
||||
withdrawalMoney.setText(stringBuffer.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void refreshMyArn() {
|
||||
OTONetManager.getInstance(mContext).getFriendAppMoneyLogModel("3", "1", page, new HttpCallback<List<FriendAppMoneyLogModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<FriendAppMoneyLogModel> data) {
|
||||
if (page != 1 && data.isEmpty()) {
|
||||
mRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
if (page != 1) {
|
||||
myArnAdapter.addLst(data);
|
||||
} else {
|
||||
myArnAdapter.showData(data);
|
||||
}
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
// OTONetManager.getInstance(mContext).getFriendAppMoneySum(new HttpCallback<FriendAppMoneySumModel>() {
|
||||
// @Override
|
||||
// public void onSuccess(FriendAppMoneySumModel data) {
|
||||
// todayEarnings.setText(data.getToday());
|
||||
// cumulativeIncome.setText(data.getSum());
|
||||
// withdrawalSum.setText(data.getWithdrawalModel().getSum());
|
||||
// StringBuffer stringBuffer = new StringBuffer();
|
||||
// stringBuffer.append("$ ")
|
||||
// .append(data.getWithdrawalModel().getMoney());
|
||||
// withdrawalMoney.setText(stringBuffer.toString());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(String error) {
|
||||
// ToastUtil.show(error);
|
||||
// }
|
||||
// });
|
||||
refreshMyArn();
|
||||
}
|
||||
|
||||
private void onConversationListLoadMore() {
|
||||
page++;
|
||||
refreshMyArn();
|
||||
mRefreshLayout.finishLoadMore();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.MyFriendListAdapter;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_MY_FRIEND_LIST)
|
||||
public class MyFriendListActivity extends AbsOTOActivity {
|
||||
public static final int TYPE_FRIEND = 0;
|
||||
public static final int TYPE_FANS = 1;
|
||||
public static final int TYPE_FOLLOW = 2;
|
||||
private int type;
|
||||
private String num;
|
||||
int page = 1;
|
||||
MyFriendListAdapter adapter;
|
||||
SmartRefreshLayout mRefreshLayout;
|
||||
SwipeRecyclerView recyclerView;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_my_follow;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
Bundle extras = getIntent().getExtras();
|
||||
type = extras.getInt("type", TYPE_FRIEND);
|
||||
num = extras.getString("num", "0");
|
||||
mRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
adapter = new MyFriendListAdapter(mContext);
|
||||
recyclerView.setAdapter(adapter);
|
||||
mRefreshLayout.setNestedScrollingEnabled(false);
|
||||
mRefreshLayout.setRefreshHeader(new RongRefreshHeader(mContext));
|
||||
mRefreshLayout.setRefreshFooter(new RongRefreshHeader(mContext));
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
initData();
|
||||
}
|
||||
});
|
||||
mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
initData();
|
||||
}
|
||||
});
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
if (type == TYPE_FANS) {
|
||||
OTONetManager.getInstance(mContext).getFans(page, new MyNetData());
|
||||
} else if (type == TYPE_FOLLOW) {
|
||||
OTONetManager.getInstance(mContext).getFollows(page, new MyNetData());
|
||||
} else if (type == TYPE_FRIEND) {
|
||||
OTONetManager.getInstance(mContext).getFriends(page, new MyNetData());
|
||||
}
|
||||
}
|
||||
|
||||
private class MyNetData implements HttpCallback<List<HomeItemBean>> {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
String title = "";
|
||||
mRefreshLayout.finishRefresh();
|
||||
mRefreshLayout.finishLoadMore();
|
||||
switch (type) {
|
||||
case TYPE_FANS:
|
||||
title = WordUtil.getNewString(R.string.activity_my_friend_list_fans);
|
||||
break;
|
||||
case TYPE_FOLLOW:
|
||||
title = WordUtil.getNewString(R.string.activity_my_friend_list_follow);
|
||||
break;
|
||||
case TYPE_FRIEND:
|
||||
title = WordUtil.getNewString(R.string.activity_my_friend_list_friend);
|
||||
break;
|
||||
}
|
||||
if (data.isEmpty()) {
|
||||
setTitle(title + "(" + num + WordUtil.getNewString(R.string.activity_my_friend_list_people)+")");
|
||||
recyclerView.loadMoreFinish(true, false);
|
||||
return;
|
||||
}
|
||||
recyclerView.loadMoreFinish(false, true);
|
||||
if (page == 1) {
|
||||
adapter.setList(data);
|
||||
} else {
|
||||
adapter.addList(data);
|
||||
}
|
||||
page++;
|
||||
setTitle(title + "(" + num + WordUtil.getNewString(R.string.activity_my_friend_list_people)+")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.ConversationUtils;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.AndroidBug5497Workaround;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.share.ui.InvitePopDialog;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_WEB_VIEW)
|
||||
public class WebViewActivity extends AbsOTOActivity {
|
||||
WebView webView;
|
||||
String titleString;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_webview;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
Bus.getOn(this);
|
||||
webView = findViewById(R.id.webView);
|
||||
titleString = getIntent().getStringExtra("title");
|
||||
if (!StringUtil.isEmpty(titleString)) {
|
||||
setTitle(titleString);
|
||||
}
|
||||
if (!StringUtil.isEmpty(titleString) && titleString.equals("NoTitle")) {
|
||||
findViewById(R.id.ft_title).setVisibility(View.GONE);
|
||||
}
|
||||
initWebView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
private void initWebView() {
|
||||
WebSettings settings = webView.getSettings();
|
||||
settings.setJavaScriptEnabled(true); // 是否开启JS支持
|
||||
settings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
settings.setDomStorageEnabled(true);
|
||||
webView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(this, webView)
|
||||
.setPageClose(true)
|
||||
.setLiveZhuangBana(false), "androidObject");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
String url = getIntent().getStringExtra("url");
|
||||
if (StringUtil.isEmpty(url)) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
if (!url.contains("token") && url.startsWith("http")) {
|
||||
IMLoginModel userInfo = UserManager.getUserBean().getUser();
|
||||
url += "&uid=" + userInfo.getId() + "&token=" + userInfo.getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0");
|
||||
}
|
||||
Log.i("WebView", url);
|
||||
webView.loadUrl(url);
|
||||
AndroidBug5497Workaround.assistActivity(this);
|
||||
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
if (TextUtils.isEmpty(titleString)) {
|
||||
setTitle(view.getTitle());
|
||||
} else {
|
||||
setTitle(titleString);
|
||||
}
|
||||
int height = view.getMeasuredHeight();
|
||||
Log.e("网页高度", height + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||
super.onReceivedHttpError(view, request, errorResponse);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void event(JavascriptInterfaceEvent event) {
|
||||
if (event.getMethod().equals("androidInviteShare")) {
|
||||
new InvitePopDialog(mContext)
|
||||
.setTitle("快來認識更多有趣的朋友吧!")
|
||||
.setUrl(event.getData())
|
||||
.showDialog();
|
||||
} else if (event.getMethod().equals("androidCallChat")) {
|
||||
ConversationUtils.startConversation(mContext, event.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.shayu.onetoone.activity.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
/**
|
||||
* Fragment基类
|
||||
*/
|
||||
public abstract class BaseFragment extends Fragment {
|
||||
public Context mContext;
|
||||
private View itemView;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View itemView = createView(inflater, container, savedInstanceState);
|
||||
this.mContext = getContext();
|
||||
this.itemView = itemView;
|
||||
initView(itemView);
|
||||
return itemView;
|
||||
}
|
||||
|
||||
public <T extends View> T findViewById(@IdRes int id) {
|
||||
return itemView.findViewById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化页面
|
||||
*
|
||||
* @param itemView 布局view
|
||||
*/
|
||||
public abstract void initView(View itemView);
|
||||
|
||||
/**
|
||||
* 创建页面
|
||||
*
|
||||
* @return 布局
|
||||
*/
|
||||
public abstract View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.shayu.onetoone.activity.fragments;
|
||||
|
||||
|
||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.AndroidBug5497Workaround;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
/**
|
||||
* 动态主页面
|
||||
*/
|
||||
public class DynamicFragment extends BaseFragment {
|
||||
private WebView webView;
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
webView = itemView.findViewById(R.id.webView);
|
||||
WebSettings settings = webView.getSettings();
|
||||
settings.setJavaScriptEnabled(true); // 是否开启JS支持
|
||||
settings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
settings.setDomStorageEnabled(true);
|
||||
webView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(getActivity(), webView)
|
||||
.setPermitSetHigh(false)
|
||||
.setPageClose(true)
|
||||
.setLiveZhuangBana(false), "androidObject");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
// AndroidBug5497Workaround.assistActivity(getActivity());
|
||||
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
Log.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) {
|
||||
int height = view.getMeasuredHeight();
|
||||
Log.e("网页高度", height + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||
super.onReceivedHttpError(view, request, errorResponse);
|
||||
}
|
||||
});
|
||||
IMLoginModel userInfo = UserManager.getUserBean().getUser();
|
||||
String url = CommonAppConfig.HOST + "/h5/shequ/index.html#/h5/shequ?stack-key-1=698c5f85%20&uid="
|
||||
+ userInfo.getId() + "&token=" + userInfo.getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0");
|
||||
Log.i("Web", url);
|
||||
webView.loadUrl(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_dynamic, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.shayu.onetoone.activity.fragments;
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.angcyo.tablayout.DslTabLayout;
|
||||
import com.angcyo.tablayout.delegate2.ViewPager2Delegate;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.home.HotFragment;
|
||||
import com.shayu.onetoone.activity.fragments.home.RecommendFragment;
|
||||
import com.shayu.onetoone.activity.message.ChatActivity;
|
||||
import com.shayu.onetoone.bean.MatchingItemSizeBean;
|
||||
import com.shayu.onetoone.bean.MessageConsumeConfigBean;
|
||||
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||
import com.shayu.onetoone.dialog.TipsDialog;
|
||||
import com.shayu.onetoone.event.HomeBusEvent;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交友主页面
|
||||
*/
|
||||
public class FriendsFragment extends BaseFragment {
|
||||
List<BaseFragment> fragments = new ArrayList<>();
|
||||
ImageView matching;
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
ViewPager2 viewPager2;
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
Bus.getOn(this);
|
||||
viewPager2 = itemView.findViewById(R.id.viewPager);
|
||||
DslTabLayout tabLayout = itemView.findViewById(R.id.dslTabLayout);
|
||||
ViewPager2Delegate.Companion.install(viewPager2, tabLayout, false);
|
||||
matching = itemView.findViewById(R.id.matching);
|
||||
|
||||
fragments.add(new RecommendFragment());//消息 - 消息
|
||||
fragments.add(new HotFragment()); //消息 - 好友
|
||||
viewPager2.setAdapter(new FragmentStateAdapter(this) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
return fragments.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fragments.size();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.btn_top), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_HOME_RANK);
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.btn_filter), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_HOME_SCREEN);
|
||||
}
|
||||
});
|
||||
|
||||
Bundle screen = getActivity().getIntent().getBundleExtra("screen");
|
||||
if (screen != null) {
|
||||
viewPager2.setCurrentItem(0);
|
||||
}
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(matching, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
SendMessageManager.matching(new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean bean) {
|
||||
super.onSuccess(token, bean);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("type", ChatActivity.CALL_CHAT_TYPE_MATCH);
|
||||
bundle.putString("data", JSONObject.toJSONString(bean));
|
||||
if (configBean != null) {
|
||||
bundle.putInt("time", configBean.getMateTime());
|
||||
} else {
|
||||
bundle.putInt("time", 5);
|
||||
}
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_MATCHING, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg, SendConsumeBean bean) {
|
||||
super.onError(status, msg, bean);
|
||||
if (bean.getCode() == 503) {
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_MATCHING);
|
||||
return;
|
||||
}
|
||||
int money = 100;
|
||||
if (configBean != null) {
|
||||
money = configBean.getMatePrice();
|
||||
}
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.gift_not_money))
|
||||
.setCancelText(WordUtil.getNewString(R.string.dialog_cancel_tip))
|
||||
.setApplyText(WordUtil.getNewString(R.string.dialog_to_money_tip))
|
||||
.showDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
initMateConfig();
|
||||
}
|
||||
|
||||
private MessageConsumeConfigBean configBean;
|
||||
|
||||
private void initMateConfig() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getMessageConsumeConfig(UserManager.getUserBean().getUser().getId() + "", new HttpCallback<MessageConsumeConfigBean>() {
|
||||
@Override
|
||||
public void onSuccess(MessageConsumeConfigBean data) {
|
||||
configBean = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
String value = SpUtil.getStringValue("match_data");
|
||||
if (!StringUtil.isEmpty(value)) {
|
||||
MatchingItemSizeBean data = JSONObject.parseObject(value, MatchingItemSizeBean.class);
|
||||
if (data.getNum() > 0) {
|
||||
matching.setImageResource(R.mipmap.ic_matching_free);
|
||||
} else {
|
||||
matching.setImageResource(R.mipmap.ic_matching);
|
||||
}
|
||||
}
|
||||
Bundle screen = getActivity().getIntent().getBundleExtra("screen");
|
||||
if (screen != null) {
|
||||
((RecommendFragment)fragments.get(0)).screen(screen);
|
||||
viewPager2.setCurrentItem(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_friends, container, false);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void event(HomeBusEvent event) {
|
||||
if (event.getType() == HomeBusEvent.TYPE_UPDATE_MATCHING) {
|
||||
int num = event.getMatching();
|
||||
if (num > 0) {
|
||||
matching.setImageResource(R.mipmap.ic_matching_free);
|
||||
} else {
|
||||
matching.setImageResource(R.mipmap.ic_matching);
|
||||
}
|
||||
}
|
||||
if (event.getType() == HomeBusEvent.TYPE_SHOW_MATCHING) {
|
||||
int show = event.getMatching();
|
||||
/* if (show == 0) {
|
||||
matching.setVisibility(View.GONE);
|
||||
} else {
|
||||
matching.setVisibility(View.VISIBLE);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.shayu.onetoone.activity.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.GiftListAdapter;
|
||||
import com.shayu.onetoone.bean.GiftBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class GiftDialogFragment extends BaseFragment {
|
||||
private RecyclerView recyclerView;
|
||||
private GiftListAdapter mAdapter;
|
||||
|
||||
List<GiftBean> list;
|
||||
|
||||
public GiftDialogFragment() {
|
||||
}
|
||||
|
||||
public void setList(List<GiftBean> list) {
|
||||
this.list = list;
|
||||
mAdapter.setList(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
mAdapter = new GiftListAdapter(getContext());
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_gift, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.shayu.onetoone.activity.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yunbao.main.views.MainHomeViewHolder;
|
||||
|
||||
public class LiveFragment extends BaseFragment {
|
||||
MainHomeViewHolder viewHolder;
|
||||
public LiveFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
viewHolder.loadData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
if(viewHolder==null){
|
||||
viewHolder=new MainHomeViewHolder(getContext(),container);
|
||||
}
|
||||
return viewHolder.getContentView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
viewHolder.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
viewHolder.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
viewHolder.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
viewHolder.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
viewHolder.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.shayu.onetoone.activity.fragments;
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.angcyo.tablayout.DslTabLayout;
|
||||
import com.angcyo.tablayout.DslTabLayoutConfig;
|
||||
import com.angcyo.tablayout.delegate2.ViewPager2Delegate;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.message.MsgFriendFragment;
|
||||
import com.shayu.onetoone.activity.fragments.message.MsgMessageFragment;
|
||||
import com.shayu.onetoone.dialog.MsgMoreDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.jvm.functions.Function4;
|
||||
|
||||
/**
|
||||
* 消息主页面
|
||||
*/
|
||||
public class MessageFragment extends BaseFragment implements View.OnClickListener {
|
||||
List<BaseFragment> fragments = new ArrayList<>();
|
||||
View more;
|
||||
XPopup.Builder moreXPopup;
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_msg, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
ViewPager2 viewPager2 = itemView.findViewById(R.id.viewPager);
|
||||
DslTabLayout tabLayout = itemView.findViewById(R.id.dslTabLayout);
|
||||
more = itemView.findViewById(R.id.more);
|
||||
more.setOnClickListener(this);
|
||||
moreXPopup = new XPopup.Builder(getContext()).atView(more);
|
||||
viewPager2.setUserInputEnabled(false);
|
||||
//绑定ViewPager2到tabLayout
|
||||
ViewPager2Delegate.Companion.install(viewPager2, tabLayout, false);
|
||||
|
||||
fragments.add(new MsgMessageFragment());//消息 - 消息
|
||||
fragments.add(new MsgFriendFragment()); //消息 - 好友
|
||||
viewPager2.setAdapter(new FragmentStateAdapter(this) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
return fragments.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fragments.size();
|
||||
}
|
||||
});
|
||||
//设置点击事件
|
||||
tabLayout.configTabLayoutConfig(new Function1<DslTabLayoutConfig, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(DslTabLayoutConfig dslTabLayoutConfig) {
|
||||
dslTabLayoutConfig.setOnSelectItemView(new Function4<View, Integer, Boolean, Boolean, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(View itemView, Integer index, Boolean select, Boolean fromUse) {
|
||||
if (select) {//设置选择的Fragment
|
||||
viewPager2.setCurrentItem(index);
|
||||
more.setVisibility(index == 0 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showMoreDialog() {
|
||||
moreXPopup.asCustom(new MsgMoreDialog(mContext)).show();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.more) {
|
||||
showMoreDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,656 @@
|
||||
package com.shayu.onetoone.activity.fragments;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Outline;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ms.banner.Banner;
|
||||
import com.ms.banner.BannerConfig;
|
||||
import com.ms.banner.listener.OnBannerClickListener;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.MyFriendListActivity;
|
||||
import com.shayu.onetoone.activity.setting.SettingActivity;
|
||||
import com.shayu.onetoone.adapter.MainMeAdapter;
|
||||
import com.shayu.onetoone.bean.AuthBean;
|
||||
import com.shayu.onetoone.bean.PeopleNum;
|
||||
import com.shayu.onetoone.bean.SlideBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.bean.UserItemBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.HtmlUrlUtils;
|
||||
import com.shayu.onetoone.utils.MainHttpConsts;
|
||||
import com.shayu.onetoone.utils.MainHttpUtil;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.shayu.onetoone.view.CustomMyViewHolder;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.MyWalletActivity;
|
||||
import com.yunbao.common.bean.GoogleBean;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LevelBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.APKManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 我的主页面
|
||||
*/
|
||||
public class MyFragment extends BaseFragment implements OnItemClickListener<UserItemBean>, View.OnClickListener {
|
||||
|
||||
private ImageView mAvatar;
|
||||
private TextView mName;
|
||||
private ImageView img_setting;
|
||||
private TextView mID;
|
||||
private RecyclerView mRecyclerView;
|
||||
private MainMeAdapter mAdapter;
|
||||
private TextView signature;
|
||||
private TextView coin, gold, star_coin;//金豆,钻石,星币
|
||||
private TextView btnCopy;
|
||||
private SVGAImageView gift_svga;
|
||||
private ImageView user_noble_ico;
|
||||
private TextView user_noble_text, user_noble_time, tv_setting;
|
||||
private UserItemBean beanStetting = null, beanKefu = null;
|
||||
private boolean firstInto = true;
|
||||
private Banner banner_me;
|
||||
private LinearLayout lt_advertisement;
|
||||
private View redPoint;
|
||||
|
||||
private TextView followNum, fansNum, friendNum;
|
||||
private View followLayout, fansLayout, friendLayout;
|
||||
private ImageView sex;
|
||||
private ImageView authStatus;
|
||||
|
||||
private TextView yanLevel; //颜 等级
|
||||
private TextView wealthLevel;// 财富 等级
|
||||
private TextView idLevel;//用户 等级
|
||||
private ImageView iconLevel; //等級图标
|
||||
|
||||
UserBean userBean;
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_my, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
userBean = UserManager.getUserBean();
|
||||
|
||||
yanLevel = findViewById(R.id.yanLevel);
|
||||
wealthLevel = findViewById(R.id.wealthLevel);
|
||||
idLevel = findViewById(R.id.idLevel);
|
||||
iconLevel = findViewById(R.id.iconLevel);
|
||||
|
||||
authStatus = itemView.findViewById(R.id.authStatus);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
redPoint = itemView.findViewById(R.id.red_point);
|
||||
ViewClicksAntiShake.clicksAntiShake(mAvatar, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
//RouteUtil.forwardUserHome(mContext, CommonAppConfig.getInstance().getUid(), 2);
|
||||
RouteManager.forwardEditProfileActivity();
|
||||
}
|
||||
});
|
||||
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
gift_svga = (SVGAImageView) itemView.findViewById(R.id.gift_svga);
|
||||
ViewClicksAntiShake.clicksAntiShake(gift_svga, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
//RouteUtil.forwardUserHome(mContext, CommonAppConfig.getInstance().getUid(), 2);
|
||||
RouteManager.forwardEditProfileActivity();
|
||||
}
|
||||
});
|
||||
fansNum = itemView.findViewById(R.id.fans);
|
||||
fansLayout = itemView.findViewById(R.id.fans_layout);
|
||||
followNum = itemView.findViewById(R.id.follow);
|
||||
followLayout = itemView.findViewById(R.id.follow_layout);
|
||||
friendNum = itemView.findViewById(R.id.friend);
|
||||
friendLayout = itemView.findViewById(R.id.friend_layout);
|
||||
sex = itemView.findViewById(R.id.sex);
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(fansLayout, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("type", MyFriendListActivity.TYPE_FANS);
|
||||
bundle.putString("num", fansNum.getText().toString());
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_MY_FRIEND_LIST, bundle);
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(followLayout, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("type", MyFriendListActivity.TYPE_FOLLOW);
|
||||
bundle.putString("num", followNum.getText().toString());
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_MY_FRIEND_LIST, bundle);
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(friendLayout, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("type", MyFriendListActivity.TYPE_FRIEND);
|
||||
bundle.putString("num", friendNum.getText().toString());
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_MY_FRIEND_LIST, bundle);
|
||||
}
|
||||
});
|
||||
|
||||
user_noble_ico = (ImageView) itemView.findViewById(R.id.user_noble_ico);
|
||||
mID = (TextView) itemView.findViewById(R.id.id_val);
|
||||
signature = (TextView) itemView.findViewById(R.id.signature);
|
||||
coin = (TextView) itemView.findViewById(R.id.coin);
|
||||
star_coin = (TextView) itemView.findViewById(R.id.star_coin);
|
||||
gold = (TextView) itemView.findViewById(R.id.gold);
|
||||
btnCopy = (TextView) itemView.findViewById(R.id.btn_copy);
|
||||
user_noble_text = (TextView) itemView.findViewById(R.id.user_noble_text);
|
||||
img_setting = (ImageView) itemView.findViewById(R.id.img_setting);
|
||||
user_noble_time = (TextView) itemView.findViewById(R.id.user_noble_time);
|
||||
banner_me = (Banner) itemView.findViewById(R.id.banner_me);
|
||||
lt_advertisement = (LinearLayout) itemView.findViewById(R.id.lt_advertisement);
|
||||
tv_setting = (TextView) itemView.findViewById(R.id.tv_setting);
|
||||
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.lt_star_coin), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
onClick(itemView.findViewById(R.id.lt_star_coin));
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.btn_coin), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
onClick(itemView.findViewById(R.id.btn_coin));
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.btn_gold), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
onClick(itemView.findViewById(R.id.btn_gold));
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.rt_kefu), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
onClick(itemView.findViewById(R.id.rt_kefu));
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.rt_setting), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
onClick(itemView.findViewById(R.id.rt_setting));
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.lt_noble), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
onClick(itemView.findViewById(R.id.lt_noble));
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.lt_name), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
onClick(itemView.findViewById(R.id.lt_name));
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.signature), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
onClick(itemView.findViewById(R.id.signature));
|
||||
}
|
||||
});
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(btnCopy, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cm.setText(mID.getText() + "");
|
||||
Toast.makeText(mContext, R.string.copy_success, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
mRecyclerView = (RecyclerView) itemView.findViewById(R.id.recyclerView);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
banner_me.setOutlineProvider(new ViewOutlineProvider() {
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline) {
|
||||
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10);
|
||||
}
|
||||
});
|
||||
mAdapter = new MainMeAdapter(mContext, new ArrayList<>());
|
||||
mAdapter.setOnItemClickListener(this);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
redPoint.setVisibility(APKManager.get().getApkVerNew() ? View.GONE : View.VISIBLE);
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.complete_information), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
// mContext.startActivity(new Intent(mContext, EditProfileActivity.class));
|
||||
}
|
||||
});
|
||||
//loadData();
|
||||
//initPeopleNum();
|
||||
OTONetManager.getInstance(mContext).getMenu(new com.yunbao.common.http.base.HttpCallback<List<UserItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<UserItemBean> data) {
|
||||
initMenu(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
loadData();
|
||||
initPeopleNum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_BASE_INFO);
|
||||
}
|
||||
|
||||
public void loadData() {
|
||||
MainHttpUtil.getGoogle(mCallback1);
|
||||
MainHttpUtil.getBaseInfo(UserManager.getUserBean().getUser().getId() + "", UserManager.getUserBean().getUser().getToken(), new CommonCallback<com.yunbao.common.bean.UserBean>() {
|
||||
@Override
|
||||
public void callback(com.yunbao.common.bean.UserBean oldUser) {
|
||||
CommonAppConfig.getInstance().setUserBean(oldUser);
|
||||
OTONetManager.getInstance(mContext).getBaseInfos(true, new com.yunbao.common.http.base.HttpCallback<com.shayu.onetoone.bean.UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
showData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
OTONetManager.getInstance(mContext).getAuthInfo(new com.yunbao.common.http.base.HttpCallback<AuthBean>() {
|
||||
@Override
|
||||
public void onSuccess(AuthBean data) {
|
||||
initAuth(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
MainHttpUtil.getBalance(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
JSONObject obj = JSONObject.parseObject(info[0]);
|
||||
String golds = obj.getString("gold");
|
||||
String coins = obj.getString("coin");
|
||||
String yuanbaos = obj.getString("yuanbao");
|
||||
UserManager.saveMoney(yuanbaos);
|
||||
if (golds.length() > 8) {
|
||||
gold.setText(golds.substring(0, golds.length() - 6) + "M");
|
||||
} else if (golds.length() > 6) {
|
||||
gold.setText(golds.substring(0, golds.length() - 3) + "K");
|
||||
} else {
|
||||
gold.setText(golds);
|
||||
}
|
||||
if (coins.length() > 8) {
|
||||
coin.setText(coins.substring(0, coins.length() - 6) + "M");
|
||||
} else if (coins.length() > 6) {
|
||||
coin.setText(coins.substring(0, coins.length() - 3) + "K");
|
||||
} else {
|
||||
coin.setText(coins);
|
||||
}
|
||||
if (yuanbaos.length() > 11) {
|
||||
star_coin.setText(yuanbaos.substring(0, yuanbaos.length() - 9) + "M");
|
||||
} else if (yuanbaos.length() > 9) {
|
||||
star_coin.setText(yuanbaos.substring(0, yuanbaos.length() - 6) + "K");
|
||||
} else if (yuanbaos.length() > 6) {
|
||||
star_coin.setText(yuanbaos.substring(0, yuanbaos.length() - 3));
|
||||
} else {
|
||||
star_coin.setText(yuanbaos);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
OTONetManager.getInstance(mContext).getTargetUserInfo(Integer.parseInt(CommonAppConfig.getInstance().getUid()), new com.yunbao.common.http.base.HttpCallback<com.shayu.onetoone.bean.UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(com.shayu.onetoone.bean.UserBean data) {
|
||||
initLevel(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载等级
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void initLevel(com.shayu.onetoone.bean.UserBean data) {
|
||||
com.shayu.onetoone.bean.UserBean.UserLevel level = data.getLevel();
|
||||
yanLevel.setText("v." + level.getCharm_level());
|
||||
wealthLevel.setText(String.valueOf(level.getWealth_level()));
|
||||
idLevel.setText("Lv." + level.getLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载认证状态
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
private void initAuth(AuthBean data) {
|
||||
if (data.getName_auth() == 2) {
|
||||
authStatus.setVisibility(View.VISIBLE);
|
||||
mName.setMaxEms(4);
|
||||
} else {
|
||||
authStatus.setVisibility(View.GONE);
|
||||
mName.setMaxEms(6);
|
||||
}
|
||||
mName.invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载菜单
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
private void initMenu(List<UserItemBean> list) {
|
||||
mAdapter.setList(list);
|
||||
}
|
||||
|
||||
|
||||
//获取谷歌
|
||||
//谷歌支付是否打开 1是打开 0 关闭
|
||||
String Is_hide = "1";
|
||||
private CommonCallback<GoogleBean> mCallback1 = new CommonCallback<GoogleBean>() {
|
||||
@Override
|
||||
public void callback(GoogleBean bean) {
|
||||
if (bean != null) {
|
||||
Is_hide = bean.getIs_hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private List<SlideBean> mBannerListNew = new ArrayList<>();
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void showData(UserBean u) {
|
||||
mBannerList.clear();
|
||||
mBannerListNew.clear();
|
||||
if (u == null) {
|
||||
return;
|
||||
}
|
||||
com.yunbao.common.bean.UserBean oldUser = CommonAppConfig.getInstance().getUserBean();
|
||||
if (oldUser.getSlide() != null) {
|
||||
mBannerListNew.addAll(JSON.parseArray(oldUser.getSlide(), SlideBean.class));
|
||||
for (SlideBean bean : mBannerListNew) {
|
||||
if (bean.getSlide_status().equals("1")) {
|
||||
mBannerList.add(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (u.getUser().getSex() == 1) {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_man);
|
||||
} else {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_woman);
|
||||
}
|
||||
mID.setText("ID:" + u.getUser().getId());
|
||||
showBanner();
|
||||
if (!u.getUser().getAvatar().contains("http")) {
|
||||
ImgLoader.displayAvatar(mContext, CommonAppConfig.HOST + u.getUser().getAvatar(), mAvatar);
|
||||
} else {
|
||||
ImgLoader.displayAvatar(mContext, u.getUser().getAvatar(), mAvatar);
|
||||
}
|
||||
mName.setText(u.getUser().getUserNicename());
|
||||
if (!"0".endsWith(String.valueOf(u.getUser().getNobleId()))) {
|
||||
user_noble_text.setText(mContext.getResources().getString(R.string.now_noble) + u.getUser().getNobleName());
|
||||
user_noble_time.setText(mContext.getResources().getString(R.string.now_noble_time) + u.getUser().getNobleEndTime());
|
||||
} else {
|
||||
user_noble_text.setText(u.getUser().getNobleName());
|
||||
user_noble_time.setText(mContext.getResources().getString(R.string.open_noble_text));
|
||||
}
|
||||
String singnature = u.getUser().getSignature();
|
||||
if (TextUtils.equals(singnature, "這個人很懶,什麼也沒留下") || TextUtils.equals(singnature, "这家伙很懒,什么都没留下") || TextUtils.isEmpty(singnature)) {
|
||||
singnature = WordUtil.isNewZh() ? "這個人很懶,什麼也沒留下" : "The guy was lazy and didn't write anything.";
|
||||
}
|
||||
signature.setText(getResources().getString(R.string.user_sign) + ":" + singnature);
|
||||
CommonAppConfig appConfig = CommonAppConfig.getInstance();
|
||||
|
||||
if (u.getUser().getDress().getAvatarFrame() != null) {
|
||||
if (u.getUser().getDress().getAvatarFrame().contains("svga")) {
|
||||
try {
|
||||
new SVGAParser(mContext).parse(new URL(u.getUser().getDress().getAvatarFrame()), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
gift_svga.setImageDrawable(drawable);
|
||||
SVGAViewUtils.playEndClear(gift_svga, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
ImgLoader.display(mContext, u.getUser().getDress().getAvatarFrame(), gift_svga);
|
||||
}
|
||||
}
|
||||
|
||||
if (u.getUser().getDress().getMedal() != null) {
|
||||
Log.e("tag", u.getUser().getDress().getMedal());
|
||||
ImgLoader.display(mContext, u.getUser().getDress().getMedal(), user_noble_ico);
|
||||
} else {
|
||||
user_noble_ico.setImageResource(R.mipmap.icon_vip_gold);
|
||||
}
|
||||
|
||||
if (beanKefu != null) {
|
||||
}
|
||||
if (beanStetting != null) {
|
||||
ImgLoader.display(mContext, beanStetting.getThumb(), img_setting);
|
||||
tv_setting.setText(beanStetting.getName());
|
||||
}
|
||||
Constants.myUid = u.getUser().getGoodnum();
|
||||
Constants.myAvatar = u.getUser().getAvatar();
|
||||
// if (u.getUserInfoComplete() == 1) {
|
||||
// findViewById(R.id.complete_information_radius).setVisibility(View.INVISIBLE);
|
||||
// findViewById(R.id.complete_information).setVisibility(View.INVISIBLE);
|
||||
// } else {
|
||||
// findViewById(R.id.complete_information_radius).setVisibility(View.VISIBLE);
|
||||
// findViewById(R.id.complete_information).setVisibility(View.VISIBLE);
|
||||
// }
|
||||
// EventBus.getDefault().post(new CompleteInformationEvent().setCompleteInformation(findViewById(R.id.complete_information).getVisibility() == View.VISIBLE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(UserItemBean bean, int position) {
|
||||
if (!StringUtil.isEmpty(bean.getHref())) {
|
||||
RouteManager.forwardWebViewActivity(bean.getName(), bean.getHref());
|
||||
} else {
|
||||
switch (bean.getId()) {
|
||||
case 2:
|
||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 0));
|
||||
break;
|
||||
case 13:
|
||||
forwardSetting();
|
||||
break;
|
||||
case 14:
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_MY_ARN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
int i = v.getId();
|
||||
if (i == R.id.lt_name) {
|
||||
// mContext.startActivity(new Intent(mContext, EditProfileActivity.class));
|
||||
} else if (i == R.id.signature) {
|
||||
// mContext.startActivity(new Intent(mContext, EditProfileActivity.class));
|
||||
} else if (i == R.id.lt_star_coin) {
|
||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1));
|
||||
// RouteManager.forwardWebViewActivity(null, HtmlUrlUtils.getPayUrl(mContext, false, HtmlUrlUtils.URL_PAY_GOLD));
|
||||
// mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1)) ;
|
||||
// Bundle bundle = new Bundle();
|
||||
// bundle.putString("type", "yuanbao");
|
||||
// RouteManager.forwardActivity(RouteManager.ACTIVITY_DIAMOND_EXCHANGE, bundle);
|
||||
} else if (i == R.id.btn_coin) {
|
||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 0));
|
||||
// RouteManager.forwardWebViewActivity(null, HtmlUrlUtils.getPayUrl(mContext, false, HtmlUrlUtils.URL_PAY_COIN));
|
||||
} else if (i == R.id.btn_gold) {
|
||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 2));
|
||||
// Bundle bundle = new Bundle();
|
||||
// bundle.putString("type", "coin");
|
||||
// RouteManager.forwardActivity(RouteManager.ACTIVITY_DIAMOND_EXCHANGE, bundle);
|
||||
} else if (i == R.id.rt_kefu) {
|
||||
//WebViewActivity.forward(mContext, beanKefu.getHref(), false);
|
||||
RouteManager.forwardWebViewActivity(beanKefu.getName(), beanKefu.getHref());
|
||||
|
||||
} else if (i == R.id.rt_setting) {
|
||||
forwardSetting();
|
||||
} else if (i == R.id.lt_noble) {
|
||||
Constants.isTitle = true;
|
||||
String url = CommonAppConfig.HOST + "/h5/Noble/index.html?nickname=" + userBean.getUser().getUserNicename() + "&usernobId=" + userBean.getUser().getNobleId() + "&token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid();
|
||||
// ZhuangBanActivity.forward(mContext, url, false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置
|
||||
*/
|
||||
private void forwardSetting() {
|
||||
mContext.startActivity(new Intent(mContext, SettingActivity.class));
|
||||
}
|
||||
|
||||
public static List<SlideBean> mBannerList = new ArrayList<>();
|
||||
|
||||
private void showBanner() {
|
||||
if (mBannerList == null || mBannerList.size() <= 0 || banner_me == null) {
|
||||
lt_advertisement.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
lt_advertisement.setVisibility(View.VISIBLE);
|
||||
if (mBannerList.size() == 1) {
|
||||
banner_me.setAutoPlay(false).setPages(mBannerList, new CustomMyViewHolder()).setDelayTime(3000).setBannerStyle(BannerConfig.NOT_INDICATOR).setOnBannerClickListener(new OnBannerClickListener() {
|
||||
@Override
|
||||
public void onBannerClick(List datas, int p) {
|
||||
if (mBannerList != null) {
|
||||
if (p >= 0 && p < mBannerList.size()) {
|
||||
SlideBean bean = mBannerList.get(p);
|
||||
if (!bean.getSlide_url().equals("")) {
|
||||
Constants.isTitle = true;
|
||||
String url = bean.getSlide_url() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken();
|
||||
//WebViewActivity.forward(mContext, url, false, false);
|
||||
RouteManager.forwardWebViewActivity("", url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
banner_me.setAutoPlay(true).setPages(mBannerList, new CustomMyViewHolder()).setDelayTime(3000).setBannerStyle(BannerConfig.NOT_INDICATOR).setOnBannerClickListener(new OnBannerClickListener() {
|
||||
@Override
|
||||
public void onBannerClick(List datas, int p) {
|
||||
if (mBannerList != null) {
|
||||
if (p >= 0 && p < mBannerList.size()) {
|
||||
SlideBean bean = mBannerList.get(p);
|
||||
if (!bean.getSlide_url().equals("")) {
|
||||
Constants.isTitle = true;
|
||||
String url = bean.getSlide_url() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken();
|
||||
RouteManager.forwardWebViewActivity("", url);
|
||||
/*if(bean.getSlide_id().equals("95")){
|
||||
RouteUtil.forwardCustomerService(url);
|
||||
}else {
|
||||
ZhuangBanActivity.forward(mContext, url, false);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
void initPeopleNum() {
|
||||
OTONetManager.getInstance(mContext).getPeopleNum(new com.yunbao.common.http.base.HttpCallback<PeopleNum>() {
|
||||
@Override
|
||||
public void onSuccess(PeopleNum data) {
|
||||
fansNum.setText(data.getFans() + "");
|
||||
followNum.setText(data.getFollow() + "");
|
||||
friendNum.setText(data.getFriend() + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
package com.shayu.onetoone.activity.fragments.home;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.adapter.HomeRankListAdapter;
|
||||
import com.shayu.onetoone.bean.FollowBean;
|
||||
import com.shayu.onetoone.bean.HomeRankBean;
|
||||
import com.shayu.onetoone.listener.OnAppbarListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
|
||||
public class HomeRankFragment extends BaseFragment {
|
||||
public static final int TYPE_CHARM = 1;
|
||||
public static final int TYPE_WEALTH = 2;
|
||||
public static final int DATE_DAY = 1;
|
||||
public static final int DATE_WEEK = 2;
|
||||
private AppBarLayout rootView;
|
||||
private OnAppbarListener appbarListener;
|
||||
private SwipeRecyclerView mRecyclerView;
|
||||
HomeRankListAdapter adapter;
|
||||
SmartRefreshLayout mRefreshLayout;
|
||||
private HeadView hv;
|
||||
private int type;
|
||||
private int date;
|
||||
|
||||
public HomeRankFragment(int type) {
|
||||
super();
|
||||
this.type = type;
|
||||
this.date = DATE_DAY;
|
||||
}
|
||||
|
||||
public void setAppbarListener(OnAppbarListener appbarListener) {
|
||||
this.appbarListener = appbarListener;
|
||||
}
|
||||
|
||||
public void setDate(int date) {
|
||||
this.date = date;
|
||||
updateData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
rootView = findViewById(R.id.rootView);
|
||||
mRecyclerView = findViewById(R.id.recyclerView);
|
||||
mRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
||||
adapter = new HomeRankListAdapter(getContext(), type);
|
||||
hv = new HeadView(rootView);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
mRefreshLayout.setRefreshFooter(new RongRefreshHeader(this.getContext()));
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
updateData();
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
});
|
||||
mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
refreshLayout.finishLoadMore();
|
||||
}
|
||||
});
|
||||
rootView.addOnOffsetChangedListener((AppBarLayout.BaseOnOffsetChangedListener) (appBarLayout, verticalOffset) -> {
|
||||
if (appbarListener != null) {
|
||||
if (verticalOffset == 0) {
|
||||
appbarListener.onShow(true);
|
||||
} else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
|
||||
appbarListener.onShow(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_home_ranking, container, false);
|
||||
}
|
||||
|
||||
public void updateData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getHomeRank(type + "", date + "", new HttpCallback<List<HomeRankBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeRankBean> tmp) {
|
||||
List<HomeRankBean> data = new ArrayList<>();
|
||||
for (int i = 0; i < 1; i++) {
|
||||
data.addAll(tmp);
|
||||
}
|
||||
adapter.clear();
|
||||
hv.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
if (i < 3) {
|
||||
hv.setData(data.get(i), i);
|
||||
continue;
|
||||
}
|
||||
adapter.add(data.get(i));
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class HeadView {
|
||||
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 diamond1;
|
||||
ImageView diamond2;
|
||||
ImageView diamond3;
|
||||
Button mBtnFollow1;
|
||||
Button mBtnFollow2;
|
||||
Button mBtnFollow3;
|
||||
SVGAImageView svga1;
|
||||
SVGAImageView svga2;
|
||||
SVGAImageView svga3;
|
||||
|
||||
public HeadView(View 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);
|
||||
mAvatar1 = itemView.findViewById(R.id.avatar_1);
|
||||
mAvatar2 = itemView.findViewById(R.id.avatar_2);
|
||||
mAvatar3 = itemView.findViewById(R.id.avatar_3);
|
||||
mName1 = itemView.findViewById(R.id.name_1);
|
||||
mName2 = itemView.findViewById(R.id.name_2);
|
||||
mName3 = itemView.findViewById(R.id.name_3);
|
||||
mVotes1 = itemView.findViewById(R.id.votes_1);
|
||||
mVotes2 = itemView.findViewById(R.id.votes_2);
|
||||
mVotes3 = itemView.findViewById(R.id.votes_3);
|
||||
mSex1 = itemView.findViewById(R.id.sex_1);
|
||||
mSex2 = itemView.findViewById(R.id.sex_2);
|
||||
mSex3 = itemView.findViewById(R.id.sex_3);
|
||||
diamond1 = itemView.findViewById(R.id.diamond1);
|
||||
diamond2 = itemView.findViewById(R.id.diamond2);
|
||||
diamond3 = itemView.findViewById(R.id.diamond3);
|
||||
mBtnFollow1 = itemView.findViewById(R.id.btn_follow_1);
|
||||
mBtnFollow2 = itemView.findViewById(R.id.btn_follow_2);
|
||||
mBtnFollow3 = itemView.findViewById(R.id.btn_follow_3);
|
||||
svga1 = itemView.findViewById(R.id.svga1);
|
||||
svga2 = itemView.findViewById(R.id.svga2);
|
||||
svga3 = itemView.findViewById(R.id.svga3);
|
||||
}
|
||||
|
||||
void setData(HomeRankBean user, int position) {
|
||||
getItem(position, mItem1, mItem2, mItem3).setVisibility(View.VISIBLE);
|
||||
getItem(position, diamond1, diamond2, diamond3).setVisibility(View.VISIBLE);
|
||||
getItem(position, mName1, mName2, mName3).setText(user.getUserNicename());
|
||||
getItem(position, mVotes1, mVotes2, mVotes3).setText(user.getMoney());
|
||||
if (user.getUid().equals(UserManager.getUserBean().getUser().getId() + "")) {
|
||||
getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setVisibility(View.GONE);
|
||||
} else {
|
||||
getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (user.isFollow()) {
|
||||
getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setVisibility(View.GONE);
|
||||
}
|
||||
if (user.getSex() == 1) {
|
||||
getItem(position, mSex1, mSex2, mSex3).setImageResource(R.mipmap.ic_message_tab_man);
|
||||
} else {
|
||||
getItem(position, mSex1, mSex2, mSex3).setImageResource(R.mipmap.ic_message_tab_woman);
|
||||
}
|
||||
switch (position) {
|
||||
case 0:
|
||||
svga1.setImageResource(R.mipmap.ic_home_rank_top_1);
|
||||
break;
|
||||
case 1:
|
||||
svga2.setImageResource(R.mipmap.ic_home_rank_top_2);
|
||||
break;
|
||||
case 2:
|
||||
svga3.setImageResource(R.mipmap.ic_home_rank_top_3);
|
||||
break;
|
||||
}
|
||||
ImgLoader.display(mContext, user.getAvatar(), getItem(position, mAvatar1, mAvatar2, mAvatar3));
|
||||
getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setOnClickListener(v -> {
|
||||
UserManager.follow(mContext, user.getUid(), new OnItemClickListener<FollowBean>() {
|
||||
@Override
|
||||
public void onItemClick(FollowBean bean, int status) {
|
||||
if (status == 0) {
|
||||
getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(getItem(position, mAvatar1, mAvatar2, mAvatar3), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
UserManager.toHomePage(user.getUid());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private <T> T getItem(int position, T... views) {
|
||||
return views[position];
|
||||
}
|
||||
|
||||
private void setVisibility(int type, int position, View... views) {
|
||||
if (position == -1) {
|
||||
for (View view : views) {
|
||||
view.setVisibility(type);
|
||||
}
|
||||
} else {
|
||||
views[position].setVisibility(type);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
setVisibility(View.INVISIBLE, -1, mItem1, mItem2, mItem3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.shayu.onetoone.activity.fragments.home;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.adapter.HomeHotListAdapter;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.event.HomeBusEvent;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.adapter.SpaceGridItemDecoration;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
|
||||
public class HotFragment extends BaseFragment {
|
||||
SmartRefreshLayout mRefreshLayout;
|
||||
SwipeRecyclerView recyclerView;
|
||||
HomeHotListAdapter adapter;
|
||||
private int page = 1;
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
recyclerView = itemView.findViewById(R.id.recyclerView);
|
||||
mRefreshLayout = itemView.findViewById(R.id.swipeRefreshLayout);
|
||||
adapter = new HomeHotListAdapter(getContext());
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.addItemDecoration(new SpaceGridItemDecoration(10));
|
||||
recyclerView.setEmptyView(findViewById(R.id.view_empty));
|
||||
mRefreshLayout.setNestedScrollingEnabled(false);
|
||||
mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
mRefreshLayout.setRefreshFooter(new RongRefreshHeader(this.getContext()));
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
onConversationListRefresh(refreshLayout);
|
||||
}
|
||||
});
|
||||
this.mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
onConversationListLoadMore();
|
||||
}
|
||||
});
|
||||
page = 1;
|
||||
initData();
|
||||
}
|
||||
|
||||
private void onConversationListLoadMore() {
|
||||
page++;
|
||||
initData();
|
||||
mRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
private void onConversationListRefresh(RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
initData();
|
||||
refreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getHomeHot(page + "", new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
if (page != 1 && data.isEmpty()) {
|
||||
page--;
|
||||
mRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
if (page != 1) {
|
||||
adapter.addList(data);
|
||||
} else {
|
||||
adapter.setList(data);
|
||||
}
|
||||
if(adapter.getItemCount()==0){
|
||||
Bus.get().post(new HomeBusEvent(HomeBusEvent.TYPE_SHOW_MATCHING,0));
|
||||
}else{
|
||||
Bus.get().post(new HomeBusEvent(HomeBusEvent.TYPE_SHOW_MATCHING,1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if(adapter.getItemCount()==0){
|
||||
Bus.get().post(new HomeBusEvent(HomeBusEvent.TYPE_SHOW_MATCHING,0));
|
||||
}else{
|
||||
Bus.get().post(new HomeBusEvent(HomeBusEvent.TYPE_SHOW_MATCHING,1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_hot, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package com.shayu.onetoone.activity.fragments.home;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.activity.message.ChatActivity;
|
||||
import com.shayu.onetoone.adapter.HomeRecommendListAdapter;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||
import com.shayu.onetoone.event.HomeBusEvent;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
|
||||
public class RecommendFragment extends BaseFragment {
|
||||
SmartRefreshLayout mRefreshLayout;
|
||||
SwipeRecyclerView recyclerView;
|
||||
HomeRecommendListAdapter adapter;
|
||||
View top;
|
||||
private int page = 1;
|
||||
private boolean isScreen;
|
||||
Bundle screen;
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
recyclerView = itemView.findViewById(R.id.recyclerView);
|
||||
mRefreshLayout = itemView.findViewById(R.id.swipeRefreshLayout);
|
||||
top = itemView.findViewById(R.id.btn_top_list);
|
||||
|
||||
adapter = new HomeRecommendListAdapter(getContext());
|
||||
recyclerView.setAdapter(adapter);
|
||||
mRefreshLayout.setNestedScrollingEnabled(false);
|
||||
mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
mRefreshLayout.setRefreshFooter(new RongRefreshHeader(this.getContext()));
|
||||
recyclerView.setEmptyView(itemView.findViewById(R.id.view_empty));
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setAutoLoadMore(true);
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
onConversationListRefresh(refreshLayout);
|
||||
}
|
||||
});
|
||||
this.mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
onConversationListLoadMore();
|
||||
}
|
||||
});
|
||||
top.setOnClickListener(view -> {
|
||||
recyclerView.scrollToPosition(0);
|
||||
});
|
||||
|
||||
screen = getActivity().getIntent().getBundleExtra("screen");
|
||||
if (screen != null) {
|
||||
if (!isScreen) {
|
||||
page = 1;
|
||||
}
|
||||
isScreen = true;
|
||||
// screen(screen);
|
||||
mRefreshLayout.setEnableRefresh(false);
|
||||
} else {
|
||||
if (isScreen) {
|
||||
page = 1;
|
||||
}
|
||||
isScreen = false;
|
||||
initData();
|
||||
}
|
||||
}
|
||||
|
||||
public void screen(Bundle screen) {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.search("",
|
||||
screen.getString("age", ""),
|
||||
screen.getString("auth", ""),
|
||||
screen.getString("sex", ""),
|
||||
page + "",
|
||||
new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
if(page==1 && data.isEmpty()){
|
||||
adapter.setList(data);
|
||||
mRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
if (page != 1 && data.isEmpty()) {
|
||||
page--;
|
||||
mRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
if (page != 1) {
|
||||
adapter.addLst(data);
|
||||
} else {
|
||||
adapter.setList(data);
|
||||
}
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void onConversationListLoadMore() {
|
||||
page++;
|
||||
if (isScreen) {
|
||||
screen(screen);
|
||||
} else {
|
||||
initData();
|
||||
}
|
||||
mRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
private void onConversationListRefresh(RefreshLayout refreshLayout) {
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getHomeRecommend(page + "", new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
if (page != 1 && data.isEmpty()) {
|
||||
page--;
|
||||
mRefreshLayout.finishLoadMore();
|
||||
recyclerView.loadMoreFinish(true, false);
|
||||
return;
|
||||
}
|
||||
if (page != 1) {
|
||||
adapter.addLst(data);
|
||||
} else {
|
||||
adapter.setList(data);
|
||||
}
|
||||
if(adapter.getItemCount()==0){
|
||||
Bus.get().post(new HomeBusEvent(HomeBusEvent.TYPE_SHOW_MATCHING,0));
|
||||
}else{
|
||||
Bus.get().post(new HomeBusEvent(HomeBusEvent.TYPE_SHOW_MATCHING,1));
|
||||
}
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_recommend, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if(adapter.getItemCount()==0){
|
||||
Bus.get().post(new HomeBusEvent(HomeBusEvent.TYPE_SHOW_MATCHING,0));
|
||||
}else{
|
||||
Bus.get().post(new HomeBusEvent(HomeBusEvent.TYPE_SHOW_MATCHING,1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import io.rong.common.RLog;
|
||||
import io.rong.imkit.conversation.ConversationFragment;
|
||||
import io.rong.imkit.conversation.extension.RongExtension;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imkit.widget.FixedLinearLayoutManager;
|
||||
import io.rong.imkit.widget.adapter.BaseAdapter;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
|
||||
public abstract class AbsConversationFragment extends ConversationFragment {
|
||||
private final String TAG = AbsConversationFragment.class.getSimpleName();
|
||||
private LinearLayout mNotificationContainer;
|
||||
public Context mContext;
|
||||
View rootView;
|
||||
|
||||
public void setTitle(String title) {
|
||||
TextView view = findViewById(R.id.title);
|
||||
if (view != null) {
|
||||
view.setText(title);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
rootView = getLayoutView(inflater, container, savedInstanceState);
|
||||
mContext = getActivity();
|
||||
this.mList = (RecyclerView) rootView.findViewById(io.rong.imkit.R.id.rc_message_list);
|
||||
this.mRongExtension = (RongExtension) rootView.findViewById(io.rong.imkit.R.id.rc_extension);
|
||||
this.mRefreshLayout = (SmartRefreshLayout) rootView.findViewById(io.rong.imkit.R.id.rc_refresh);
|
||||
this.mNewMessageNum = (TextView) rootView.findViewById(io.rong.imkit.R.id.rc_new_message_number);
|
||||
this.mUnreadHistoryMessageNum = (TextView) rootView.findViewById(io.rong.imkit.R.id.rc_unread_message_count);
|
||||
this.mUnreadMentionMessageNum = (TextView) rootView.findViewById(io.rong.imkit.R.id.rc_mention_message_count);
|
||||
this.mNotificationContainer = (LinearLayout) rootView.findViewById(io.rong.imkit.R.id.rc_notification_container);
|
||||
this.mNewMessageNum.setOnClickListener(this);
|
||||
this.mUnreadHistoryMessageNum.setOnClickListener(this);
|
||||
this.mUnreadMentionMessageNum.setOnClickListener(this);
|
||||
this.mLinearLayoutManager = this.createLayoutManager();
|
||||
if (this.mList != null) {
|
||||
this.mList.setLayoutManager(this.mLinearLayoutManager);
|
||||
}
|
||||
|
||||
this.mRefreshLayout.setOnTouchListener(new View.OnTouchListener() {
|
||||
@SuppressLint({"ClickableViewAccessibility"})
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
AbsConversationFragment.this.closeExpand();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.mAdapter.setItemClickListener(new BaseAdapter.OnItemClickListener() {
|
||||
public void onItemClick(View view, ViewHolder holder, int position) {
|
||||
AbsConversationFragment.this.closeExpand();
|
||||
}
|
||||
|
||||
public boolean onItemLongClick(View view, ViewHolder holder, int position) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (this.mList != null) {
|
||||
this.mList.setAdapter(this.mAdapter);
|
||||
this.mList.addOnScrollListener(this.mScrollListener);
|
||||
this.mList.setItemAnimator((RecyclerView.ItemAnimator) null);
|
||||
final GestureDetector gd = new GestureDetector(this.getContext(), new GestureDetector.SimpleOnGestureListener() {
|
||||
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
|
||||
AbsConversationFragment.this.closeExpand();
|
||||
return super.onScroll(e1, e2, distanceX, distanceY);
|
||||
}
|
||||
});
|
||||
this.mList.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
|
||||
public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
|
||||
return gd.onTouchEvent(e);
|
||||
}
|
||||
|
||||
public void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
|
||||
}
|
||||
|
||||
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.mRefreshLayout.setNestedScrollingEnabled(false);
|
||||
this.mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
this.mRefreshLayout.setRefreshFooter(new RongRefreshHeader(this.getContext()));
|
||||
this.mRefreshLayout.setEnableRefresh(true);
|
||||
this.mRefreshLayout.setOnRefreshListener(this);
|
||||
this.mRefreshLayout.setOnLoadMoreListener(this);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mContext = getActivity();
|
||||
mRongExtension.setVisibility(View.GONE);
|
||||
main();
|
||||
View back = findViewById(R.id.btn_back);
|
||||
if (back != null) {
|
||||
back.setOnClickListener(v -> getActivity().finish());
|
||||
}
|
||||
}
|
||||
|
||||
private RecyclerView.LayoutManager createLayoutManager() {
|
||||
LinearLayoutManager linearLayoutManager = new FixedLinearLayoutManager(this.getContext());
|
||||
linearLayoutManager.setStackFromEnd(true);
|
||||
return linearLayoutManager;
|
||||
}
|
||||
|
||||
private void closeExpand() {
|
||||
if (this.mRongExtensionViewModel != null) {
|
||||
this.mRongExtensionViewModel.collapseExtensionBoard();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final RecyclerView.OnScrollListener mScrollListener = new RecyclerView.OnScrollListener() {
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
AbsConversationFragment.this.mMessageViewModel.onScrolled(recyclerView, dx, dy, AbsConversationFragment.this.mAdapter.getHeadersCount(), AbsConversationFragment.this.mAdapter.getFootersCount());
|
||||
}
|
||||
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
if (newState == 0 && AbsConversationFragment.this.onScrollStopRefreshList) {
|
||||
AbsConversationFragment.this.onScrollStopRefreshList = false;
|
||||
RLog.d(AbsConversationFragment.this.TAG, "onScrollStateChanged refresh List");
|
||||
AbsConversationFragment.this.refreshList((List) AbsConversationFragment.this.mMessageViewModel.getUiMessageLiveData().getValue());
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private void refreshList(final List<UiMessage> data) {
|
||||
if (!this.mList.isComputingLayout() && this.mList.getScrollState() == 0) {
|
||||
this.mAdapter.setDataCollection(data);
|
||||
} else {
|
||||
this.onScrollStopRefreshList = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public abstract View getLayoutView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState);
|
||||
|
||||
public abstract void main();
|
||||
|
||||
public Intent getIntent() {
|
||||
return getActivity().getIntent();
|
||||
}
|
||||
|
||||
public <T extends View> T findViewById(@IdRes int id) {
|
||||
return rootView.findViewById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,912 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputFilter;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.PermissionUtils;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.MsgChatMessageListAdapter;
|
||||
import com.shayu.onetoone.bean.FollowBean;
|
||||
import com.shayu.onetoone.bean.GiftBean;
|
||||
import com.shayu.onetoone.bean.MessageChatAuthContent;
|
||||
import com.shayu.onetoone.bean.MessageConsumeConfigBean;
|
||||
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.dialog.BottomListDialog;
|
||||
import com.shayu.onetoone.dialog.MsgChatClickDialog;
|
||||
import com.shayu.onetoone.dialog.TipsDialog;
|
||||
import com.shayu.onetoone.event.MessageMsgBusEvent;
|
||||
import com.shayu.onetoone.event.MoneyUpdateEvent;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.CallClientManager;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.shayu.onetoone.utils.MsgCheckUtils;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.shayu.onetoone.view.MsgInputPanelForAudio;
|
||||
import com.shayu.onetoone.view.MsgInputPanelForGift;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
import io.rong.calllib.RongCallClient;
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.config.RongConfigCenter;
|
||||
import io.rong.imkit.conversation.MessageListAdapter;
|
||||
import io.rong.imkit.conversation.extension.InputMode;
|
||||
import io.rong.imkit.conversation.extension.RongExtensionViewModel;
|
||||
import io.rong.imkit.conversation.extension.component.inputpanel.InputPanel;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imkit.picture.PictureSelector;
|
||||
import io.rong.imkit.picture.config.PictureMimeType;
|
||||
import io.rong.imkit.picture.entity.LocalMedia;
|
||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||
import io.rong.imlib.IRongCallback;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
import io.rong.message.ImageMessage;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
/**
|
||||
* 融云聊天UI
|
||||
*/
|
||||
public class ChatMessageFragment extends AbsConversationFragment {
|
||||
private static WeakReference<UserBean> targetUser;
|
||||
Button mSendBtn;
|
||||
View mInputPanel;
|
||||
View numLayout;
|
||||
EditText mEditText;
|
||||
ImageView img, call, video, gift, mEmojiToggleBtn;
|
||||
ProcessImageUtil cameraUtil;
|
||||
String targetId;
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
|
||||
|
||||
RoundedImageView avatar;
|
||||
TextView uname;
|
||||
TextView sign;
|
||||
TextView star;
|
||||
TextView home;
|
||||
ImageView sex;
|
||||
ImageView status;
|
||||
TextView num;
|
||||
Button follow;
|
||||
RongExtensionViewModel mExtensionViewModel;
|
||||
|
||||
|
||||
private String token;
|
||||
private static final String TAG = "聊天界面";
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
public static UserBean getTargetUser() {
|
||||
return targetUser.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
Bus.getOn(this);
|
||||
targetId = getActivity().getIntent().getStringExtra("targetId");
|
||||
num = findViewById(R.id.num);
|
||||
numLayout = findViewById(R.id.constraintLayout2);
|
||||
numLayout.setVisibility(View.INVISIBLE);
|
||||
initBtn();
|
||||
initChat();
|
||||
cameraUtil = new ProcessImageUtil(getActivity(), mContext.getPackageName() + ".fileprovider");
|
||||
|
||||
mRongExtension.setVisibility(View.VISIBLE);
|
||||
// img.setOnClickListener(v -> cameraUtil.getImageByCamera());
|
||||
initCamera();
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(mSendBtn, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (StringUtil.isEmpty(mEditText.getText().toString())) {
|
||||
return;
|
||||
}
|
||||
SendMessageManager.sendMessageForText(targetId, mEditText.getText().toString(), new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean bean) {
|
||||
super.onSuccess(token, bean);
|
||||
ChatMessageFragment.this.token = token;
|
||||
sendText();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
if (status == OnSendMessageListener.STATUS_NOT_PRICE) {
|
||||
|
||||
MsgCheckUtils.checkPrice(mContext, targetId, new OnItemClickListener<MessageConsumeConfigBean>() {
|
||||
@Override
|
||||
public void onItemClick(MessageConsumeConfigBean bean, int position) {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.not_money))
|
||||
.setContent(String.format(WordUtil.getNewString(R.string.not_money_tips), bean.getPrice()))
|
||||
.setCancelText(WordUtil.getNewString(R.string.dialog_cancel_tip))
|
||||
.setApplyText(WordUtil.getNewString(R.string.dialog_to_money_tip))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
}
|
||||
}).showDialog();
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
updateMyInfo();
|
||||
showRedPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getLayoutView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.rc_conversation_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main() {
|
||||
|
||||
}
|
||||
|
||||
private void initCamera() {
|
||||
cameraUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
@Override
|
||||
public void beforeCamera() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
sendImage(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MsgInputPanelForAudio audio;
|
||||
MsgInputPanelForGift giftPanel;
|
||||
|
||||
/**
|
||||
* 反射拿融云的view
|
||||
*/
|
||||
private void initBtn() {
|
||||
try {
|
||||
Field field = mRongExtension.getInputPanel().getClass().getDeclaredField("mInputPanel");
|
||||
field.setAccessible(true);
|
||||
mInputPanel = (View) field.get(mRongExtension.getInputPanel());
|
||||
assert mInputPanel != null;
|
||||
field = mRongExtension.getInputPanel().getClass().getDeclaredField("mExtensionViewModel");
|
||||
field.setAccessible(true);
|
||||
mExtensionViewModel = (RongExtensionViewModel) field.get(mRongExtension.getInputPanel());
|
||||
mSendBtn = mInputPanel.getRootView().findViewById(R.id.send_btn);
|
||||
img = mInputPanel.getRootView().findViewById(R.id.input_panel_image_btn);
|
||||
video = mInputPanel.getRootView().findViewById(R.id.input_panel_video_btn);
|
||||
call = mInputPanel.getRootView().findViewById(R.id.input_panel_call_btn);
|
||||
gift = mInputPanel.getRootView().findViewById(R.id.input_panel_gift_btn);
|
||||
mEditText = mInputPanel.getRootView().findViewById(R.id.edit_btn);
|
||||
mEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(300)});
|
||||
mEmojiToggleBtn = mInputPanel.findViewById(R.id.input_panel_emoji_btn);
|
||||
ImageView mVoiceToggleBtn = (ImageView) mInputPanel.getRootView().findViewById(R.id.input_panel_voice_toggle);
|
||||
assert mVoiceToggleBtn != null;
|
||||
audio = new MsgInputPanelForAudio(targetId, getActivity(), mRongExtension);
|
||||
giftPanel = new MsgInputPanelForGift(targetId, getActivity(), mRongExtension);
|
||||
giftPanel.setOnItemClickListener(new OnItemClickListener<GiftBean>() {
|
||||
@Override
|
||||
public void onItemClick(GiftBean bean, int position) {
|
||||
if (call.getTag() != null) {
|
||||
call.setTag(null);
|
||||
call.setImageResource(R.mipmap.ic_msg_call);
|
||||
video.setImageResource(R.mipmap.ic_msg_video);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.mExtensionViewModel.getInputModeLiveData().observe(getViewLifecycleOwner(), new Observer<InputMode>() {
|
||||
public void onChanged(InputMode inputMode) {
|
||||
updateViewByInputMode(inputMode);
|
||||
}
|
||||
});
|
||||
mVoiceToggleBtn.setOnClickListener(view -> {
|
||||
mExtensionViewModel.getInputModeLiveData().postValue(InputMode.NormalMode);
|
||||
giftPanel.hide();
|
||||
audio.show();
|
||||
});
|
||||
|
||||
gift.setOnClickListener(v -> {
|
||||
mExtensionViewModel.getInputModeLiveData().postValue(InputMode.NormalMode);
|
||||
audio.hide();
|
||||
giftPanel.show();
|
||||
});
|
||||
mEmojiToggleBtn.setOnClickListener(v -> {
|
||||
if (mExtensionViewModel.getInputModeLiveData().getValue() == InputMode.TextInput) {
|
||||
audio.hide();
|
||||
giftPanel.hide();
|
||||
mExtensionViewModel.getInputModeLiveData().postValue(InputMode.EmoticonMode);
|
||||
} else {
|
||||
mExtensionViewModel.getInputModeLiveData().postValue(InputMode.TextInput);
|
||||
}
|
||||
});
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(video, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (call.getTag() != null) {
|
||||
ToastUtil.show(R.string.toast_call_not_unlock);
|
||||
AppManager.runDebugCode(() -> {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle("测试模式,是否强行拨打")
|
||||
.setApplyText("确定")
|
||||
.setCancelText("取消")
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
callVideo();
|
||||
}
|
||||
}).showDialog();
|
||||
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (CallClientManager.getManager().isCalling()) {
|
||||
ToastUtil.show(R.string.now_call_tips);
|
||||
return;
|
||||
}
|
||||
callVideo();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(call, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (call.getTag() != null) {
|
||||
ToastUtil.show(R.string.toast_call_not_unlock);
|
||||
AppManager.runDebugCode(() -> {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle("测试模式,是否强行拨打")
|
||||
.setApplyText("确定")
|
||||
.setCancelText("取消")
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
callAudio();
|
||||
}
|
||||
}).showDialog();
|
||||
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (CallClientManager.getManager().isCalling() || isFloatWindows()) {
|
||||
ToastUtil.show(R.string.now_call_tips);
|
||||
return;
|
||||
}
|
||||
callAudio();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(img, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
new BottomListDialog(mContext)
|
||||
.setStrings(Arrays.asList(WordUtil.getNewString(R.string.album), WordUtil.getNewString(R.string.camera)))
|
||||
.setSelect(new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onItemClick(String bean, int position) {
|
||||
boolean isCamera = position == 1;
|
||||
|
||||
SendMessageManager.sendMessageForText(targetId, WordUtil.getNewString(R.string.photo_info), new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean bean) {
|
||||
super.onSuccess(token, bean);
|
||||
ChatMessageFragment.this.token = token;
|
||||
if (isCamera) {
|
||||
cameraUtil.getImageByCamera(false);
|
||||
} else {
|
||||
PictureSelector.create(ChatMessageFragment.this)
|
||||
.openGallery(PictureMimeType.ofImage())
|
||||
.loadImageEngine(RongConfigCenter.featureConfig().getKitImageEngine())
|
||||
.setRequestedOrientation(1)
|
||||
.videoDurationLimit(RongIMClient.getInstance().getVideoLimitTime())
|
||||
.maxSelectNum(9)
|
||||
.imageSpanCount(3)
|
||||
.isGif(true)
|
||||
.forResult(110);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
MsgCheckUtils.checkPrice(mContext, targetId, new OnItemClickListener<MessageConsumeConfigBean>() {
|
||||
@Override
|
||||
public void onItemClick(MessageConsumeConfigBean bean, int position) {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.not_money))
|
||||
.setContent(String.format(WordUtil.getNewString(R.string.not_money_tips), bean.getPrice()))
|
||||
.setCancelText(WordUtil.getNewString(R.string.dialog_cancel_tip))
|
||||
.setApplyText(WordUtil.getNewString(R.string.dialog_to_money_tip))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
}
|
||||
}).showDialog();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}).showDialog();
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateViewByInputMode(InputMode inputMode) {
|
||||
if(inputMode==InputMode.TextInput){
|
||||
audio.hide();
|
||||
giftPanel.hide();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isFloatWindows() {
|
||||
return EasyFloat.isShow("call");
|
||||
}
|
||||
|
||||
|
||||
private void sendAuthRequest() {
|
||||
MessageChatAuthContent content = MessageChatAuthContent.obtain("");
|
||||
IMCenter.getInstance().sendMessage(Message.obtain(targetId, Conversation.ConversationType.PRIVATE, content), null, null, new IRongCallback.ISendMessageCallback() {
|
||||
@Override
|
||||
public void onAttached(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void sendText() {
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
TextMessage messageContent = TextMessage.obtain(mEditText.getText().toString());
|
||||
|
||||
Message message = Message.obtain(targetId, conversationType, messageContent);
|
||||
|
||||
IMCenter.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
|
||||
|
||||
@Override
|
||||
public void onAttached(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
SendMessageManager.onCallSuccess(token, new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean bean) {
|
||||
super.onSuccess(token, bean);
|
||||
mEditText.setText("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void sendImage(File file) {
|
||||
ImageMessage imageMessage = ImageMessage.obtain(Uri.parse("file://" + file.getAbsolutePath()), true);
|
||||
Message message = Message.obtain(targetId, conversationType, imageMessage);
|
||||
message.setSenderUserId(CommonAppConfig.getInstance().getUid());
|
||||
message.setObjectName("RC:ImgMsg");
|
||||
message.setExtra("");
|
||||
message.setSentTime(new Date().getTime());
|
||||
message.setTargetId(targetId);
|
||||
IMCenter.getInstance().sendMediaMessage(message, null, null, new IRongCallback.ISendMediaMessageCallback() {
|
||||
|
||||
@Override
|
||||
public void onProgress(Message message, int progress) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
SendMessageManager.onCallSuccess(token, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
|
||||
ToastUtil.show(R.string.system_tip_failure);
|
||||
System.out.println("发送失败:" + errorCode.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void updateMyInfo() {
|
||||
OTONetManager.getInstance(getActivity())
|
||||
.getBaseInfos(false, new HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void initChat() {
|
||||
avatar = findViewById(R.id.avatar);
|
||||
uname = findViewById(R.id.user_name);
|
||||
sign = findViewById(R.id.signature);
|
||||
sex = findViewById(R.id.sex);
|
||||
status = findViewById(R.id.status);
|
||||
home = findViewById(R.id.home);
|
||||
star = findViewById(R.id.star);
|
||||
follow = findViewById(R.id.follow);
|
||||
targetId = getIntent().getStringExtra("targetId");
|
||||
updateUserInfo();
|
||||
ViewClicksAntiShake.clicksAntiShake(home, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
UserManager.toHomePage(targetId,true);
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(avatar, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
UserManager.toHomePage(targetId,true);
|
||||
}
|
||||
});
|
||||
follow.setOnClickListener(v -> {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.follow(targetId, new HttpCallback<FollowBean>() {
|
||||
@Override
|
||||
public void onSuccess(FollowBean data) {
|
||||
ToastUtil.show(WordUtil.getNewString(R.string.system_tip_success));
|
||||
follow.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void updateUserInfo() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getTargetUserInfo(Integer.parseInt(targetId), new HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
targetUser = new WeakReference<>(data);
|
||||
ImgLoader.display(mContext, data.getUser().getAvatar(), avatar);
|
||||
uname.setText(data.getUser().getUserNicename());
|
||||
sign.setText(data.getUser().getSignature());
|
||||
if(StringUtil.isEmpty(data.getInfo().getStar_name())){
|
||||
star.setVisibility(View.GONE);
|
||||
}else {
|
||||
star.setText("我是" + data.getInfo().getStar_name());
|
||||
}
|
||||
if (data.getUser().getSex() == 1) {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_man);
|
||||
} else {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_woman);
|
||||
}
|
||||
System.out.println("同性別:" + data.getUser().getSex() + "|" + UserManager.getUserBean().getUser().getSex());
|
||||
if (data.getUser().getSex() == UserManager.getUserBean().getUser().getSex()) {
|
||||
call.setVisibility(View.GONE);
|
||||
video.setVisibility(View.GONE);
|
||||
}
|
||||
switch (Integer.parseInt(data.getUser().getOnline())) {
|
||||
case 0:
|
||||
status.setImageResource(R.mipmap.ic_message_msg_status_online);
|
||||
break;
|
||||
case 2:
|
||||
status.setImageResource(R.mipmap.ic_message_msg_status_busy);
|
||||
break;
|
||||
default:
|
||||
status.setImageResource(R.mipmap.ic_message_msg_status_offline);
|
||||
}
|
||||
if (data.getUser().isFollow()) {
|
||||
follow.setVisibility(View.GONE);
|
||||
}
|
||||
if (data.getGiftNum() == 0) {
|
||||
call.setImageResource(R.mipmap.ic_msg_call_lock);
|
||||
video.setImageResource(R.mipmap.ic_msg_video_lock);
|
||||
call.setTag("true");
|
||||
}
|
||||
UserInfo info = new UserInfo(data.getUser().getId() + "", data.getUser().getUserNicename(), Uri.parse(data.getUser().getAvatar()));
|
||||
info.setExtra(JSONObject.toJSONString(data));
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onViewLongClick(int clickType, UiMessage data) {
|
||||
View position = mLinearLayoutManager.findViewByPosition(((MsgChatMessageListAdapter) mAdapter).getPosition(data.getMessageId()));
|
||||
boolean isMy = data.getMessage().getMessageDirection() == Message.MessageDirection.SEND;
|
||||
boolean isTextMessage = data.getMessage().getContent() instanceof TextMessage;
|
||||
String[] list;
|
||||
if (isTextMessage) {
|
||||
/* if (isMy) {
|
||||
list = new String[]{WordUtil.getNewString(R.string.copy), WordUtil.getNewString(R.string.delete)};
|
||||
} else {
|
||||
list = new String[]{WordUtil.getNewString(R.string.copy)};
|
||||
}*/
|
||||
list = new String[]{WordUtil.getNewString(R.string.copy), WordUtil.getNewString(R.string.delete)};
|
||||
} else {
|
||||
if (isMy) {
|
||||
list = new String[]{WordUtil.getNewString(R.string.delete)};
|
||||
} else {
|
||||
list = null;
|
||||
}
|
||||
}
|
||||
if (list == null) {
|
||||
return true;
|
||||
}
|
||||
new XPopup.Builder(getContext())
|
||||
.atView(position.findViewById(R.id.rc_content))
|
||||
.hasShadowBg(false)
|
||||
.positionByWindowCenter(true)
|
||||
.asCustom(new MsgChatClickDialog(getActivity())
|
||||
.setList(Arrays.asList(list))
|
||||
.setOnItemClickListener(new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onItemClick(String bean, int position) {
|
||||
if (bean.equals(WordUtil.getNewString(R.string.copy))) {
|
||||
copyText(data);
|
||||
} else if(bean.equals(WordUtil.getNewString(R.string.delete))){
|
||||
delete(data);
|
||||
}
|
||||
}
|
||||
}))
|
||||
.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void copyText(UiMessage uiMessage) {
|
||||
ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", uiMessage.getContentSpannable());
|
||||
cm.setPrimaryClip(clipData);
|
||||
}
|
||||
|
||||
private void delete(UiMessage uiMessage) {
|
||||
IMCenter.getInstance().deleteMessages(Conversation.ConversationType.PRIVATE, targetId, new int[]{uiMessage.getMessageId()}, new RongIMClient.ResultCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean aBoolean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MessageListAdapter onResolveAdapter() {
|
||||
return new MsgChatMessageListAdapter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 110) {
|
||||
List<LocalMedia> selectList = PictureSelector.obtainMultipleResult(data);
|
||||
if (selectList != null && selectList.size() > 0) {
|
||||
boolean sendOrigin = ((LocalMedia) selectList.get(0)).isOriginal();
|
||||
for (LocalMedia item : selectList) {
|
||||
String mimeType = item.getMimeType();
|
||||
if (mimeType.startsWith("image")) {
|
||||
Uri uri;
|
||||
//判断安卓版本小于10
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
uri = FileProvider.getUriForFile(mContext, mContext.getPackageName() + ".fileprovider", new File(item.getPath()));
|
||||
} else {
|
||||
uri = Uri.parse(item.getPath());
|
||||
}
|
||||
ImageMessage imageMessage = ImageMessage.obtain(uri, sendOrigin);
|
||||
Message message = Message.obtain(targetId, conversationType, imageMessage);
|
||||
message.setSenderUserId(CommonAppConfig.getInstance().getUid());
|
||||
message.setObjectName("RC:ImgMsg");
|
||||
message.setExtra("");
|
||||
message.setSentTime(new Date().getTime());
|
||||
message.setTargetId(targetId);
|
||||
IMCenter.getInstance().sendMediaMessage(message, null, null, new IRongCallback.ISendMediaMessageCallback() {
|
||||
|
||||
@Override
|
||||
public void onProgress(Message message, int progress) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
SendMessageManager.onCallSuccess(token, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
|
||||
ToastUtil.show(R.string.system_tip_failure);
|
||||
System.out.println("发送失败:" + errorCode.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showRedPoint() {
|
||||
RongIMClient.getInstance().getUnreadCount(new Conversation.ConversationType[]{Conversation.ConversationType.PRIVATE}
|
||||
, false
|
||||
, new RongIMClient.ResultCallback<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(Integer integer) {
|
||||
Integer tmp = integer + MsgMessageFragment.systemPoint;
|
||||
if (tmp <= 0) {
|
||||
numLayout.setVisibility(View.INVISIBLE);
|
||||
return;
|
||||
}
|
||||
numLayout.setVisibility(View.VISIBLE);
|
||||
num.setText(tmp + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
private void callVideo(){
|
||||
MsgCheckUtils.checkAuth(mContext, targetId, new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean bean) {
|
||||
super.onSuccess(token, bean);
|
||||
MsgCheckUtils.checkPrice(mContext, targetId, new OnItemClickListener<MessageConsumeConfigBean>() {
|
||||
@Override
|
||||
public void onItemClick(MessageConsumeConfigBean configBean, int position) {
|
||||
new BottomListDialog(mContext).setSelect(new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onItemClick(String bean, int position) {
|
||||
CallClientManager.getManager().checkMoney(targetId, true, new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean bean) {
|
||||
super.onSuccess(token, bean);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("model", CallClientManager.VIDEO_CALL);
|
||||
bundle.putString("targetId", targetId);
|
||||
bundle.putString("callId", targetId);
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_CALL_VIDEO, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.not_money))
|
||||
.setContent(String.format(WordUtil.getNewString(R.string.not_money_video_tips), configBean.getVideoPrice()))
|
||||
.setCancelText(WordUtil.getNewString(R.string.dialog_cancel_tip))
|
||||
.setApplyText(WordUtil.getNewString(R.string.dialog_to_money_tip))
|
||||
.showDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
}).setStrings(Collections.singletonList(String.format(WordUtil.getNewString(R.string.chat_video_tips), configBean.getVideoPrice())))
|
||||
.showDialog();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
if (status == 1) {
|
||||
sendAuthRequest();
|
||||
} else if (!StringUtil.isEmpty(msg)) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
private void callAudio(){
|
||||
MsgCheckUtils.checkAuth(mContext, targetId, new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean bean) {
|
||||
super.onSuccess(token, bean);
|
||||
MsgCheckUtils.checkPrice(mContext, targetId, new OnItemClickListener<MessageConsumeConfigBean>() {
|
||||
@Override
|
||||
public void onItemClick(MessageConsumeConfigBean configBean, int position) {
|
||||
new BottomListDialog(mContext).setSelect(new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onItemClick(String bean, int position) {
|
||||
CallClientManager.getManager().checkMoney(targetId, false, new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean bean) {
|
||||
super.onSuccess(token, bean);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("model", CallClientManager.AUDIO_CALL);
|
||||
bundle.putString("targetId", targetId);
|
||||
bundle.putString("callId", targetId);
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_CALL_AUDIO, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.not_money))
|
||||
.setContent(String.format(WordUtil.getNewString(R.string.not_money_audio_tips), configBean.getMp3Price()))
|
||||
.setCancelText(WordUtil.getNewString(R.string.dialog_cancel_tip))
|
||||
.setApplyText(WordUtil.getNewString(R.string.dialog_to_money_tip))
|
||||
.showDialog();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}).setStrings(Collections.singletonList(String.format(WordUtil.getNewString(R.string.chat_audio_tips), configBean.getMp3Price())))
|
||||
.showDialog();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
if (status == 1) {
|
||||
sendAuthRequest();
|
||||
} else if (!StringUtil.isEmpty(msg)) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Subscribe
|
||||
public void moneyEvent(MoneyUpdateEvent event) {
|
||||
if (giftPanel != null) {
|
||||
giftPanel.updateMoney(event.getMoney());
|
||||
}
|
||||
}
|
||||
@Subscribe
|
||||
public void event(MessageMsgBusEvent event) {
|
||||
if (event.getType() == MessageMsgBusEvent.TYPE_UPDATE_POINT) {
|
||||
if (event.getNum() <= 0) {
|
||||
numLayout.setVisibility(View.INVISIBLE);
|
||||
return;
|
||||
}
|
||||
if (num.getVisibility() == View.GONE) {
|
||||
numLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
num.setText(event.getNum() + "");
|
||||
}else if(event.getType()==MessageMsgBusEvent.TYPE_UPDATE_STAR){
|
||||
giftPanel.updateMoney(event.getContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.MessageInteractionConversationListAdapter;
|
||||
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
||||
import com.shayu.onetoone.bean.SystemMessageBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.view.SystemNoticeUiMessage;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import io.rong.imkit.conversation.MessageListAdapter;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imlib.model.Message;
|
||||
|
||||
/**
|
||||
* 互動消息
|
||||
*/
|
||||
public class MessageInteractiveFragment extends AbsConversationFragment {
|
||||
private OfficialNoticeBean noticeBean;
|
||||
|
||||
public MessageInteractiveFragment(String data) {
|
||||
super();
|
||||
noticeBean = JSONObject.parseObject(data, OfficialNoticeBean.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getLayoutView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_interaction, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main() {
|
||||
setTitle(noticeBean.getTitle());
|
||||
mList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
initData();
|
||||
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getSystemMessageList(noticeBean.getType(), new HttpCallback<List<SystemMessageBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<SystemMessageBean> data) {
|
||||
if(data.isEmpty()){
|
||||
mList.setVisibility(View.GONE);
|
||||
findViewById(R.id.view_empty).setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
mList.setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.view_empty).setVisibility(View.GONE);
|
||||
List<UiMessage> list = new ArrayList<>();
|
||||
for (SystemMessageBean item : data) {
|
||||
SystemNoticeUiMessage message = new SystemNoticeUiMessage(new Message());
|
||||
message.setBean(item);
|
||||
list.add(message);
|
||||
}
|
||||
mAdapter.setDataCollection(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MessageListAdapter onResolveAdapter() {
|
||||
return new MessageInteractionConversationListAdapter(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.MessageNoticeConversationListAdapter;
|
||||
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
||||
import com.shayu.onetoone.bean.SystemMessageBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.view.SystemNoticeUiMessage;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import io.rong.imkit.conversation.MessageListAdapter;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imlib.model.Message;
|
||||
|
||||
/**
|
||||
* 官方通知
|
||||
*/
|
||||
public class MessageNoticeFragment extends AbsConversationFragment {
|
||||
private OfficialNoticeBean noticeBean;
|
||||
|
||||
public MessageNoticeFragment(String data) {
|
||||
super();
|
||||
noticeBean = JSONObject.parseObject(data, OfficialNoticeBean.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getLayoutView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_notice, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main() {
|
||||
setTitle(noticeBean.getTitle());
|
||||
mList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, true));
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getSystemMessageList(noticeBean.getType(), new HttpCallback<List<SystemMessageBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<SystemMessageBean> data) {
|
||||
if(data.isEmpty()){
|
||||
mList.setVisibility(View.GONE);
|
||||
findViewById(R.id.view_empty).setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
mList.setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.view_empty).setVisibility(View.GONE);
|
||||
List<UiMessage> list = new ArrayList<>();
|
||||
for (SystemMessageBean item : data) {
|
||||
SystemNoticeUiMessage message = new SystemNoticeUiMessage(new Message());
|
||||
message.setBean(item);
|
||||
list.add(message);
|
||||
}
|
||||
mAdapter.setDataCollection(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MessageListAdapter onResolveAdapter() {
|
||||
return new MessageNoticeConversationListAdapter(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.adapter.MsgMessageRecyclerViewAdapter;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.event.MessageMsgBusEvent;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yanzhenjie.recyclerview.OnItemMenuClickListener;
|
||||
import com.yanzhenjie.recyclerview.OnItemMenuStateListener;
|
||||
import com.yanzhenjie.recyclerview.SwipeMenuBridge;
|
||||
import com.yanzhenjie.recyclerview.SwipeMenuCreator;
|
||||
import com.yanzhenjie.recyclerview.SwipeMenuItem;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.common.RLog;
|
||||
import io.rong.imkit.config.ConversationListBehaviorListener;
|
||||
import io.rong.imkit.config.RongConfigCenter;
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
import io.rong.imkit.conversationlist.model.GatheredConversation;
|
||||
import io.rong.imkit.conversationlist.model.SingleConversation;
|
||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||
import io.rong.imkit.utils.RouteUtils;
|
||||
import io.rong.imkit.widget.FixedLinearLayoutManager;
|
||||
import io.rong.imkit.widget.adapter.BaseAdapter;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
|
||||
/**
|
||||
* 消息-好友
|
||||
*/
|
||||
public class MsgFriendFragment extends BaseFragment implements BaseAdapter.OnItemClickListener {
|
||||
SwipeRecyclerView mList;
|
||||
SmartRefreshLayout mRefreshLayout;
|
||||
MsgMessageRecyclerViewAdapter mAdapter;
|
||||
List<BaseUiConversation> list;
|
||||
List<HomeItemBean> itemBeans;
|
||||
private int page = 1;
|
||||
private static final String TAG = MsgFriendFragment.class.getName();
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
Bus.getOn(this);
|
||||
mList = itemView.findViewById(R.id.recyclerView);
|
||||
mRefreshLayout = itemView.findViewById(R.id.swipeRefreshLayout);
|
||||
mAdapter = new MsgMessageRecyclerViewAdapter(mList);
|
||||
mAdapter.setItemClickListener(this);
|
||||
list = new ArrayList<>();
|
||||
mList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
//mList.setSwipeMenuCreator(initSwipeMenuCreator());
|
||||
mList.setHasFixedSize(true);
|
||||
mList.setEmptyView(itemView.findViewById(R.id.view_empty));
|
||||
mList.setAutoMarginEnabled(true);
|
||||
mList.setOnItemMenuClickListener(new OnItemMenuClickListener() {
|
||||
@Override
|
||||
public void onItemClick(SwipeMenuBridge menuBridge, int adapterPosition) {
|
||||
|
||||
}
|
||||
});
|
||||
mList.setOnItemMenuStateListener(new OnItemMenuStateListener() {
|
||||
|
||||
@Override
|
||||
public void onMenuState(RecyclerView.ViewHolder viewHolder, int menuState) {
|
||||
|
||||
}
|
||||
});
|
||||
LinearLayoutManager layoutManager = new FixedLinearLayoutManager(this.getActivity());
|
||||
mList.setLayoutManager(layoutManager);
|
||||
mList.setAdapter(this.mAdapter);
|
||||
initRefreshView();
|
||||
initData();
|
||||
|
||||
}
|
||||
|
||||
protected void initRefreshView() {
|
||||
this.mRefreshLayout.setNestedScrollingEnabled(false);
|
||||
this.mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
this.mRefreshLayout.setRefreshFooter(new RongRefreshHeader(this.getContext()));
|
||||
this.mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
initData();
|
||||
}
|
||||
});
|
||||
this.mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
initData();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_msg_friend, container, false);
|
||||
}
|
||||
|
||||
private SwipeMenuCreator initSwipeMenuCreator() {
|
||||
SwipeMenuCreator creator = (leftMenu, rightMenu, position) -> {
|
||||
SwipeMenuItem top = new SwipeMenuItem(getContext());
|
||||
SwipeMenuItem del = new SwipeMenuItem(getContext());
|
||||
top.setBackgroundColor(Color.parseColor("#D9D9D9"));
|
||||
del.setBackgroundColor(Color.parseColor("#FE5268"));
|
||||
top.setText(R.string.top);
|
||||
del.setText(R.string.delete);
|
||||
top.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
top.setWidth(DpUtil.dp2px(71));
|
||||
del.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
del.setWidth(DpUtil.dp2px(71));
|
||||
|
||||
rightMenu.addMenuItem(top);
|
||||
rightMenu.addMenuItem(del);
|
||||
|
||||
};
|
||||
return creator;
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getFriends(page, new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
if (page == 1) {
|
||||
list.clear();
|
||||
}
|
||||
itemBeans = data;
|
||||
if (data.isEmpty()) {
|
||||
Collections.sort(list,new ChatListComparator());
|
||||
mAdapter.setDataCollection(list);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
mRefreshLayout.finishRefresh();
|
||||
mRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
getNewData(data);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void getNewData(List<HomeItemBean> data) {
|
||||
if (data == null) {
|
||||
page = 1;
|
||||
initData();
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
HomeItemBean item = data.get(i);
|
||||
boolean over = i == data.size() - 1;
|
||||
RongIMClient.getInstance().getConversation(Conversation.ConversationType.PRIVATE, item.getId() + "", new RongIMClient.ResultCallback<Conversation>() {
|
||||
@Override
|
||||
public void onSuccess(Conversation conversation) {
|
||||
SingleConversation singleConversation = null;
|
||||
if (conversation == null) {
|
||||
singleConversation = setTopData(item.getUser_nicename(),
|
||||
"你们什么都没聊",
|
||||
0,
|
||||
item.getAvatar(),
|
||||
0,
|
||||
item.getId(),
|
||||
item.getSex(),
|
||||
JSONObject.toJSONString(item)
|
||||
);
|
||||
list.add(singleConversation);
|
||||
} else {
|
||||
list.add(new SingleConversation(mContext, conversation));
|
||||
}
|
||||
if (over) {
|
||||
Collections.sort(list,new ChatListComparator());
|
||||
mAdapter.setDataCollection(list);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
mRefreshLayout.finishRefresh();
|
||||
mRefreshLayout.finishLoadMore();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private class ChatListComparator implements Comparator<BaseUiConversation> {
|
||||
|
||||
@Override
|
||||
public int compare(BaseUiConversation singleConversation, BaseUiConversation t1) {
|
||||
return (int) (singleConversation.mCore.getSentTime()-t1.mCore.getSentTime());
|
||||
}
|
||||
}
|
||||
|
||||
private SingleConversation setTopData(String title, String content, long time, String avatar, int num, int id, int sex, String exp) {
|
||||
if (StringUtil.isEmpty(content)) {
|
||||
content = "";
|
||||
}
|
||||
SingleConversation conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
conversation.mCore.setSenderUserName(title);
|
||||
conversation.mCore.setConversationTitle(title);
|
||||
conversation.mCore.setSentTime(time);
|
||||
conversation.mCore.setSentStatus(Message.SentStatus.SENT);
|
||||
conversation.mConversationContent = new SpannableString(content);
|
||||
conversation.mCore.setUnreadMessageCount(num);
|
||||
conversation.mCore.setTargetId(id + "");
|
||||
conversation.mCore.setLatestMessageExtra(exp);
|
||||
conversation.mCore.setPortraitUrl(avatar);
|
||||
UserInfo info = new UserInfo(id + "", title, Uri.parse(avatar));
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("sex", sex);
|
||||
json.put("age", -1);
|
||||
info.setExtra(json.toJSONString());
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(info);
|
||||
return conversation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(View view, ViewHolder holder, int position) {
|
||||
if (position >= 0 && position < this.mAdapter.getData().size()) {
|
||||
BaseUiConversation baseUiConversation = (BaseUiConversation) this.mAdapter.getItem(position);
|
||||
ConversationListBehaviorListener listBehaviorListener = RongConfigCenter.conversationListConfig().getListener();
|
||||
if (listBehaviorListener != null && listBehaviorListener.onConversationClick(view.getContext(), view, baseUiConversation)) {
|
||||
RLog.d(TAG, "ConversationList item click event has been intercepted by App.");
|
||||
} else {
|
||||
if (baseUiConversation != null && baseUiConversation.mCore != null) {
|
||||
if (baseUiConversation instanceof GatheredConversation) {
|
||||
RouteUtils.routeToSubConversationListActivity(view.getContext(), ((GatheredConversation) baseUiConversation).mGatheredType, baseUiConversation.mCore.getConversationTitle());
|
||||
} else {
|
||||
RouteUtils.routeToConversationActivity(view.getContext(), baseUiConversation.getConversationIdentifier());
|
||||
}
|
||||
} else {
|
||||
RLog.e(TAG, "invalid conversation.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(View view, ViewHolder holder, int position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void event(MessageMsgBusEvent event) {
|
||||
if (event.getType() == MessageMsgBusEvent.TYPE_UPDATE_POINT) {
|
||||
/* page = 1;
|
||||
initData();*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,576 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.SpannableString;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.adapter.MsgMessageRecyclerViewAdapter;
|
||||
import com.shayu.onetoone.bean.MsgMessageBean;
|
||||
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
||||
import com.shayu.onetoone.bean.TargetUserInfoBean;
|
||||
import com.shayu.onetoone.event.MessageMsgBusEvent;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yanzhenjie.recyclerview.OnItemMenuClickListener;
|
||||
import com.yanzhenjie.recyclerview.OnItemMenuStateListener;
|
||||
import com.yanzhenjie.recyclerview.SwipeMenu;
|
||||
import com.yanzhenjie.recyclerview.SwipeMenuBridge;
|
||||
import com.yanzhenjie.recyclerview.SwipeMenuCreator;
|
||||
import com.yanzhenjie.recyclerview.SwipeMenuItem;
|
||||
import com.yanzhenjie.recyclerview.SwipeMenuLayout;
|
||||
import com.yanzhenjie.recyclerview.SwipeMenuView;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import io.rong.common.RLog;
|
||||
import io.rong.imkit.GlideKitImageEngine;
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.config.ConversationListBehaviorListener;
|
||||
import io.rong.imkit.config.RongConfigCenter;
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
import io.rong.imkit.conversationlist.model.GatheredConversation;
|
||||
import io.rong.imkit.conversationlist.model.SingleConversation;
|
||||
import io.rong.imkit.conversationlist.viewmodel.ConversationListViewModel;
|
||||
import io.rong.imkit.event.Event;
|
||||
import io.rong.imkit.model.NoticeContent;
|
||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||
import io.rong.imkit.utils.RouteUtils;
|
||||
import io.rong.imkit.widget.FixedLinearLayoutManager;
|
||||
import io.rong.imkit.widget.adapter.BaseAdapter;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.constant.RefreshState;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
import io.rong.imlib.IRongCoreCallback;
|
||||
import io.rong.imlib.IRongCoreEnum;
|
||||
import io.rong.imlib.RongCoreClient;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.ConversationIdentifier;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
|
||||
/**
|
||||
* 消息-消息
|
||||
* copy {@link io.rong.imkit.conversationlist.ConversationListFragment}
|
||||
*/
|
||||
public class MsgMessageFragment extends BaseFragment implements BaseAdapter.OnItemClickListener {
|
||||
public static int systemPoint = 0;
|
||||
private static final String TAG = MsgMessageFragment.class.getSimpleName();
|
||||
SwipeRecyclerView mList;
|
||||
SmartRefreshLayout mRefreshLayout;
|
||||
MsgMessageRecyclerViewAdapter mAdapter;
|
||||
List<MsgMessageBean> list;
|
||||
|
||||
protected View mNoticeContainerView;
|
||||
protected TextView mNoticeContentTv;
|
||||
protected ImageView mNoticeIconIv;
|
||||
protected ConversationListViewModel mConversationListViewModel;
|
||||
protected Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
protected boolean delayRefresh = false;
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
private class SwipeRunnable {
|
||||
private SwipeMenuBridge bridge;
|
||||
private int adapterPosition;
|
||||
|
||||
public SwipeRunnable(SwipeMenuBridge bridge, int adapterPosition) {
|
||||
this.bridge = bridge;
|
||||
this.adapterPosition = adapterPosition;
|
||||
}
|
||||
}
|
||||
|
||||
private SwipeRunnable swipeRunnable = null;
|
||||
SwipeMenuCreator creator;
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
Bus.getOn(this);
|
||||
mList = itemView.findViewById(R.id.recyclerView);
|
||||
mRefreshLayout = itemView.findViewById(R.id.swipeRefreshLayout);
|
||||
mAdapter = new MsgMessageRecyclerViewAdapter(mList);
|
||||
list = new ArrayList<>();
|
||||
mList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
creator = initSwipeMenuCreator();
|
||||
mList.setSwipeMenuCreator(creator);
|
||||
mList.setHasFixedSize(true);
|
||||
mList.setAutoMarginEnabled(true);
|
||||
mList.setOnItemMenuClickListener(new OnItemMenuClickListener() {
|
||||
@Override
|
||||
public void onItemClick(SwipeMenuBridge menuBridge, int adapterPosition) {
|
||||
swipeRunnable = new SwipeRunnable(menuBridge, adapterPosition);
|
||||
menuBridge.closeMenu();
|
||||
|
||||
}
|
||||
});
|
||||
mList.setOnItemMenuStateListener(new OnItemMenuStateListener() {
|
||||
|
||||
@Override
|
||||
public void onMenuState(RecyclerView.ViewHolder viewHolder, int menuState) {
|
||||
if (menuState == CLOSED && swipeRunnable != null) {
|
||||
mHandler.postDelayed(() -> {
|
||||
BaseUiConversation conversation = mAdapter.getData().get(swipeRunnable.adapterPosition);
|
||||
if (swipeRunnable.bridge.getPosition() == 0) {
|
||||
topItem(conversation, swipeRunnable.adapterPosition);
|
||||
} else {
|
||||
removeItem(conversation, swipeRunnable.adapterPosition);
|
||||
}
|
||||
swipeRunnable = null;
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
});
|
||||
initRongConfig();
|
||||
updateUserInfo();
|
||||
}
|
||||
|
||||
private void initRongConfig() {
|
||||
RongConfigCenter.featureConfig().setKitImageEngine(new GlideKitImageEngine() {
|
||||
@Override
|
||||
public void loadConversationListPortrait(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView, Conversation conversation) {
|
||||
super.loadConversationListPortrait(context, url, imageView, conversation);
|
||||
ImgLoader.displayAvatarForCircleCrop(context, url, imageView);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void initSystemNotice() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getMessageSystemLists(new HttpCallback<List<OfficialNoticeBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<OfficialNoticeBean> data) {
|
||||
systemPoint = 0;
|
||||
for (OfficialNoticeBean datum : data) {
|
||||
systemPoint += datum.getNum();
|
||||
if (datum.getType() == 3) {
|
||||
SpUtil.setStringValue("customerService", JSONObject.toJSONString(datum));
|
||||
continue;
|
||||
}
|
||||
mAdapter.add(setTopData(datum.getTitle(),
|
||||
datum.getContent(),
|
||||
datum.getAddtime() * 1000,
|
||||
datum.getImage(),
|
||||
datum.getNum(),
|
||||
datum.getType(),
|
||||
JSONObject.toJSONString(datum)
|
||||
), datum.getType());
|
||||
}
|
||||
onConversationListRefresh(mRefreshLayout);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
Bus.get().post(new MessageMsgBusEvent(MessageMsgBusEvent.TYPE_UPDATE_POINT, -1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private SingleConversation setTopData(String title, String content, long time, String avatar, int num, int id, String exp) {
|
||||
if (StringUtil.isEmpty(content)) {
|
||||
content = "";
|
||||
}
|
||||
SingleConversation conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
conversation.mCore.setSenderUserName(title);
|
||||
conversation.mCore.setConversationTitle(title);
|
||||
conversation.mCore.setSentTime(time);
|
||||
conversation.mCore.setSentStatus(Message.SentStatus.SENT);
|
||||
conversation.mConversationContent = new SpannableString(content);
|
||||
conversation.mCore.setUnreadMessageCount(num);
|
||||
conversation.mCore.setTargetId(id + "");
|
||||
conversation.mCore.setLatestMessageExtra(exp);
|
||||
conversation.mCore.setPortraitUrl(avatar);
|
||||
UserInfo info = new UserInfo(id + "", title, Uri.parse(avatar));
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("sex", -1);
|
||||
json.put("age", -1);
|
||||
info.setExtra(json.toJSONString());
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(info);
|
||||
return conversation;
|
||||
}
|
||||
|
||||
private void clearTopData() {
|
||||
mAdapter.clearSystemNotification();
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部标记已读
|
||||
*/
|
||||
public void allRead() {
|
||||
// clearTopData();
|
||||
OTONetManager.getInstance(mContext)
|
||||
.messageReadAll(null);
|
||||
RongCoreClient.getInstance().getUnreadConversationList(new IRongCoreCallback.ResultCallback<List<Conversation>>() {
|
||||
@Override
|
||||
public void onSuccess(List<Conversation> conversations) {
|
||||
for (Conversation conversation : conversations) {
|
||||
Log.i(TAG, "onSuccess: " + conversation.getTargetId());
|
||||
if (conversation.getConversationType() != Conversation.ConversationType.PRIVATE) {
|
||||
continue;
|
||||
}
|
||||
IMCenter.getInstance().clearMessagesUnreadStatus(conversation.getConversationType(),
|
||||
conversation.getTargetId(),
|
||||
new RongIMClient.ResultCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean aBoolean) {
|
||||
onConversationListRefresh(mRefreshLayout);
|
||||
Bus.get().post(new MessageMsgBusEvent(MessageMsgBusEvent.TYPE_ALL_READ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
System.out.println("标记失败:" + e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(IRongCoreEnum.CoreErrorCode e) {
|
||||
System.err.println(e.getMessage() + "|" + e.code);
|
||||
}
|
||||
}, Conversation.ConversationType.PRIVATE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 置顶会话
|
||||
*/
|
||||
private void topItem(BaseUiConversation conversation, int adapterPosition) {
|
||||
IMCenter.getInstance().setConversationToTop(conversation.getConversationIdentifier(), !conversation.mCore.isTop(), false, new RongIMClient.ResultCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean aBoolean) {
|
||||
Log.i(TAG, "置顶 onSuccess: " + aBoolean);
|
||||
onConversationListRefresh(mRefreshLayout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
Log.e(TAG, "置顶 onError: " + e.code + "|" + e.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会话
|
||||
*/
|
||||
private void removeItem(BaseUiConversation conversation, int adapterPosition) {
|
||||
Conversation.ConversationType conversationType = conversation.mCore.getConversationType();
|
||||
String targetId = conversation.mCore.getTargetId();
|
||||
IMCenter.getInstance().removeConversation(conversationType, targetId, new RongIMClient.ResultCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean aBoolean) {
|
||||
Log.i(TAG, "删除 onSuccess: " + aBoolean);
|
||||
onConversationListRefresh(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
Log.e(TAG, "删除 onError: " + e.code + "|" + e.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_msg_message, container, false);
|
||||
}
|
||||
|
||||
protected int mNewState = 0;
|
||||
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
if (!IMCenter.getInstance().isInitialized()) {
|
||||
RLog.e(TAG, "Please init SDK first!");
|
||||
} else {
|
||||
LinearLayoutManager layoutManager = new FixedLinearLayoutManager(this.getActivity());
|
||||
this.mList.setLayoutManager(layoutManager);
|
||||
this.mList.setAdapter(this.mAdapter);
|
||||
this.mList.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
MsgMessageFragment.this.mNewState = newState;
|
||||
if (MsgMessageFragment.this.mNewState == 0 && MsgMessageFragment.this.delayRefresh && MsgMessageFragment.this.mAdapter != null && MsgMessageFragment.this.mConversationListViewModel != null) {
|
||||
MsgMessageFragment.this.delayRefresh = false;
|
||||
MsgMessageFragment.this.mAdapter.setDataCollection((List) MsgMessageFragment.this.mConversationListViewModel.getConversationListLiveData().getValue());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
this.mAdapter.setItemClickListener(this);
|
||||
this.mNoticeContainerView = view.findViewById(R.id.rc_conversationlist_notice_container);
|
||||
this.mNoticeContentTv = (TextView) view.findViewById(R.id.rc_conversationlist_notice_tv);
|
||||
this.mNoticeIconIv = (ImageView) view.findViewById(R.id.rc_conversationlist_notice_icon_iv);
|
||||
this.initRefreshView();
|
||||
this.subscribeUi();
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
initSystemNotice();
|
||||
updateUserInfo();
|
||||
if (this.mConversationListViewModel != null) {
|
||||
mConversationListViewModel.getConversationList(false, true, 0L);
|
||||
this.mConversationListViewModel.clearAllNotification();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void initRefreshView() {
|
||||
if (this.mRefreshLayout == null) {
|
||||
RLog.d(TAG, "initRefreshView null");
|
||||
} else {
|
||||
this.mRefreshLayout.setNestedScrollingEnabled(false);
|
||||
this.mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
this.mRefreshLayout.setRefreshFooter(new RongRefreshHeader(this.getContext()));
|
||||
this.mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
initSystemNotice();
|
||||
updateUserInfo();
|
||||
MsgMessageFragment.this.onConversationListRefresh(refreshLayout);
|
||||
}
|
||||
});
|
||||
this.mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
MsgMessageFragment.this.onConversationListLoadMore();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void subscribeUi() {
|
||||
this.mConversationListViewModel = (ConversationListViewModel) (new ViewModelProvider(this)).get(ConversationListViewModel.class);
|
||||
this.mConversationListViewModel.getConversationList(false, false, 0L);
|
||||
this.mConversationListViewModel.getConversationListLiveData().observe(this.getViewLifecycleOwner(), new Observer<List<BaseUiConversation>>() {
|
||||
public void onChanged(List<BaseUiConversation> uiConversations) {
|
||||
RLog.d(TAG, "conversation list onChanged. |" + MsgMessageFragment.this.mNewState);
|
||||
if (MsgMessageFragment.this.mNewState == 1) {
|
||||
MsgMessageFragment.this.delayRefresh = true;
|
||||
}
|
||||
MsgMessageFragment.this.mAdapter.setDataCollection(uiConversations);
|
||||
|
||||
}
|
||||
});
|
||||
this.mConversationListViewModel.getNoticeContentLiveData().observe(this.getViewLifecycleOwner(), new Observer<NoticeContent>() {
|
||||
public void onChanged(NoticeContent noticeContent) {
|
||||
if (MsgMessageFragment.this.mNoticeContainerView.getVisibility() == View.GONE) {
|
||||
MsgMessageFragment.this.mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
MsgMessageFragment.this.updateNoticeContent((NoticeContent) MsgMessageFragment.this.mConversationListViewModel.getNoticeContentLiveData().getValue());
|
||||
}
|
||||
}, 4000L);
|
||||
} else {
|
||||
MsgMessageFragment.this.updateNoticeContent(noticeContent);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
this.mConversationListViewModel.getRefreshEventLiveData().observe(this.getViewLifecycleOwner(), new Observer<Event.RefreshEvent>() {
|
||||
public void onChanged(Event.RefreshEvent refreshEvent) {
|
||||
if (refreshEvent.state.equals(RefreshState.LoadFinish)) {
|
||||
if (MsgMessageFragment.this.mRefreshLayout != null) {
|
||||
MsgMessageFragment.this.mRefreshLayout.finishLoadMore();
|
||||
} else {
|
||||
RLog.d(TAG, "onChanged finishLoadMore error");
|
||||
}
|
||||
} else if (refreshEvent.state.equals(RefreshState.RefreshFinish)) {
|
||||
if (MsgMessageFragment.this.mRefreshLayout != null) {
|
||||
MsgMessageFragment.this.mRefreshLayout.finishRefresh();
|
||||
} else {
|
||||
RLog.d(TAG, "onChanged finishRefresh error");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void onConversationListRefresh(RefreshLayout refreshLayout) {
|
||||
if (this.mConversationListViewModel != null) {
|
||||
Bus.get().post(new MessageMsgBusEvent(MessageMsgBusEvent.TYPE_UPDATE_POINT, -1));
|
||||
this.mConversationListViewModel.getConversationList(false, true, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
protected void onConversationListLoadMore() {
|
||||
if (this.mConversationListViewModel != null) {
|
||||
this.mConversationListViewModel.getConversationList(true, true, 0L);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void updateNoticeContent(NoticeContent content) {
|
||||
if (content != null) {
|
||||
if (content.isShowNotice()) {
|
||||
this.mNoticeContainerView.setVisibility(View.VISIBLE);
|
||||
this.mNoticeContentTv.setText(content.getContent());
|
||||
if (content.getIconResId() != 0) {
|
||||
this.mNoticeIconIv.setImageResource(content.getIconResId());
|
||||
}
|
||||
} else {
|
||||
this.mNoticeContainerView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onItemClick(View view, ViewHolder holder, int position) {
|
||||
if (position >= 0 && position < this.mAdapter.getData().size()) {
|
||||
BaseUiConversation baseUiConversation = (BaseUiConversation) this.mAdapter.getItem(position);
|
||||
String targetId = baseUiConversation.mCore.getTargetId();
|
||||
try {
|
||||
int type = Integer.parseInt(targetId);
|
||||
if (type < 100) {
|
||||
startSystem(JSONObject.parseObject(mAdapter.getSystemItem(type).mCore.getLatestMessageExtra(), OfficialNoticeBean.class), baseUiConversation.getConversationIdentifier());
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ConversationListBehaviorListener listBehaviorListener = RongConfigCenter.conversationListConfig().getListener();
|
||||
if (listBehaviorListener != null && listBehaviorListener.onConversationClick(view.getContext(), view, baseUiConversation)) {
|
||||
RLog.d(TAG, "ConversationList item click event has been intercepted by App.");
|
||||
} else {
|
||||
if (baseUiConversation != null && baseUiConversation.mCore != null) {
|
||||
if (baseUiConversation instanceof GatheredConversation) {
|
||||
RouteUtils.routeToSubConversationListActivity(view.getContext(), ((GatheredConversation) baseUiConversation).mGatheredType, baseUiConversation.mCore.getConversationTitle());
|
||||
} else {
|
||||
RouteUtils.routeToConversationActivity(view.getContext(), baseUiConversation.getConversationIdentifier());
|
||||
}
|
||||
} else {
|
||||
RLog.e(TAG, "invalid conversation.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startSystem(OfficialNoticeBean noticeBean, ConversationIdentifier conversationIdentifier) {
|
||||
if (noticeBean.getType() != 3) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("model", noticeBean.getType());
|
||||
bundle.putString("data", JSONObject.toJSONString(noticeBean));
|
||||
RouteUtils.routeToConversationActivity(getContext(), conversationIdentifier, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(View view, ViewHolder holder, int position) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private SwipeMenuCreator initSwipeMenuCreator() {
|
||||
SwipeMenuCreator creator = (leftMenu, rightMenu, position) -> {
|
||||
SwipeMenuItem top = new SwipeMenuItem(getContext());
|
||||
SwipeMenuItem del = new SwipeMenuItem(getContext());
|
||||
top.setBackgroundColor(Color.parseColor("#D9D9D9"));
|
||||
del.setBackgroundColor(Color.parseColor("#FE5268"));
|
||||
if (mAdapter.getItem(position).mCore.isTop()) {
|
||||
top.setText(R.string.untop);
|
||||
} else {
|
||||
top.setText(R.string.top);
|
||||
}
|
||||
del.setText(R.string.delete);
|
||||
top.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
top.setWidth(DpUtil.dp2px(71));
|
||||
del.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
del.setWidth(DpUtil.dp2px(71));
|
||||
|
||||
rightMenu.addMenuItem(top);
|
||||
rightMenu.addMenuItem(del);
|
||||
};
|
||||
return creator;
|
||||
}
|
||||
|
||||
private void updateUserInfo() {
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
for (BaseUiConversation datum : mAdapter.getData()) {
|
||||
String targetId = datum.mCore.getTargetId();
|
||||
try {
|
||||
int id = Integer.parseInt(targetId);
|
||||
if (id > 100) {
|
||||
ids.add(id);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getTargetUserInfoList(ids, new HttpCallback<List<TargetUserInfoBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<TargetUserInfoBean> data) {
|
||||
for (TargetUserInfoBean item : data) {
|
||||
UserInfo info = new UserInfo(item.getId() + "", item.getUser_nicename(), Uri.parse(item.getAvatar()));
|
||||
info.setExtra(JSONObject.toJSONString(item));
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(info);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void busEvent(MessageMsgBusEvent event) {
|
||||
if (event.getType() == MessageMsgBusEvent.TYPE_ALL_READ) {
|
||||
allRead();
|
||||
}
|
||||
if (event.getType() == MessageMsgBusEvent.TYPE_UPDATE_SYSTEM) {
|
||||
initSystemNotice();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
||||
import com.shayu.onetoone.bean.SystemMessageBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.config.RongConfigCenter;
|
||||
import io.rong.imkit.conversation.ConversationFragment;
|
||||
import io.rong.imkit.conversation.MessageListAdapter;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imkit.widget.adapter.BaseAdapter;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
/**
|
||||
* 系統消息
|
||||
*/
|
||||
public class SystemMessageFragment extends AbsConversationFragment {
|
||||
View mInputPanel;
|
||||
|
||||
View titleBar;
|
||||
Button callService;
|
||||
OfficialNoticeBean noticeBean;
|
||||
|
||||
public SystemMessageFragment(String data) {
|
||||
super();
|
||||
noticeBean = JSONObject.parseObject(data, OfficialNoticeBean.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
init();
|
||||
mList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, true));
|
||||
initData();
|
||||
initSystemMessage();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
try {
|
||||
Field field = mRongExtension.getInputPanel().getClass().getDeclaredField("mInputPanel");
|
||||
field.setAccessible(true);
|
||||
mInputPanel = (View) field.get(mRongExtension.getInputPanel());
|
||||
assert mInputPanel != null;
|
||||
mInputPanel.setVisibility(View.GONE);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initSystemMessage() {
|
||||
titleBar = findViewById(R.id.include);
|
||||
callService = findViewById(R.id.call_service);
|
||||
titleBar.setVisibility(View.VISIBLE);
|
||||
setTitle(noticeBean.getTitle());
|
||||
callService.setOnClickListener(v -> {
|
||||
String value = SpUtil.getStringValue("customerService");
|
||||
if (!StringUtil.isEmpty(value)) {
|
||||
OfficialNoticeBean service = JSONObject.parseObject(value, OfficialNoticeBean.class);
|
||||
RouteManager.forwardWebViewActivity(service.getTitle(), service.getLink());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(getContext())
|
||||
.getSystemMessageList(SystemMessageBean.TYPE_SYSTEM, new HttpCallback<List<SystemMessageBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<SystemMessageBean> data) {
|
||||
if(data.isEmpty()){
|
||||
mList.setVisibility(View.GONE);
|
||||
findViewById(R.id.view_empty).setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
mList.setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.view_empty).setVisibility(View.GONE);
|
||||
for (SystemMessageBean item : data) {
|
||||
sendMessage(item);
|
||||
}
|
||||
mAdapter.notifyDataSetChanged();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
|
||||
private void sendMessage(SystemMessageBean item) {
|
||||
TextMessage content = TextMessage.obtain(item.getContent());
|
||||
UiMessage message = new UiMessage(Message.obtain("4", Conversation.ConversationType.PRIVATE, content));
|
||||
UserInfo userInfo = new UserInfo(item.getId() + "", item.getTitle(), mipmapToUri(R.mipmap.icon_vip_gold));
|
||||
message.setUserInfo(userInfo);
|
||||
message.setMessageDirection(Message.MessageDirection.RECEIVE);
|
||||
message.setState(0);
|
||||
message.setTargetId("4");
|
||||
mAdapter.add(message);
|
||||
}
|
||||
|
||||
private Uri mipmapToUri(int resId) {
|
||||
Resources r = getResources();
|
||||
return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
|
||||
+ r.getResourcePackageName(resId) + "/"
|
||||
+ r.getResourceTypeName(resId) + "/"
|
||||
+ r.getResourceEntryName(resId) + "/"
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getLayoutView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.view_conversation_system_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onViewLongClick(int clickType, UiMessage data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main() {
|
||||
String data = getIntent().getStringExtra("data");
|
||||
if (!StringUtil.isEmpty(data)) {
|
||||
noticeBean = JSONObject.parseObject(data, OfficialNoticeBean.class);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
package com.shayu.onetoone.activity.login;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||
import com.shayu.onetoone.adapter.LabelTagAdapter;
|
||||
import com.shayu.onetoone.adapter.LableChooseAdapter;
|
||||
import com.shayu.onetoone.bean.LabelBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.xuexiang.xui.widget.flowlayout.FlowTagLayout;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||
|
||||
|
||||
/**
|
||||
* 设置标签
|
||||
*/
|
||||
@Route(path = RouteManager.ACTIVITY_CHOOSE_LABEL)
|
||||
public class ChooseLabelActivity extends AbsOTOActivity {
|
||||
|
||||
FlowTagLayout myFlowTag; //我的标签
|
||||
|
||||
RecyclerView recyclerView; //系统分类标签
|
||||
|
||||
TextView next; //跳过
|
||||
|
||||
LableChooseAdapter lableChooseAdapter;
|
||||
|
||||
List<LabelBean.Children> myLabelList = new ArrayList<>();
|
||||
|
||||
LabelTagAdapter myAdapter;
|
||||
|
||||
Button submit; //提交
|
||||
|
||||
boolean isUserHome;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_choose_label;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
initView();
|
||||
initDate();
|
||||
}
|
||||
|
||||
private void initDate() {
|
||||
|
||||
isUserHome = getIntent().getBooleanExtra("isUserHome", false);
|
||||
|
||||
OTONetManager.getInstance(mContext).getSysLabel(new HttpCallback<List<LabelBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<LabelBean> data) {
|
||||
lableChooseAdapter.setList(data);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
if (isUserHome) {
|
||||
next.setVisibility(View.GONE);
|
||||
getUserLabel();
|
||||
}else{
|
||||
findViewById(R.id.btn_back).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void getUserLabel() {
|
||||
|
||||
OTONetManager.getInstance(mContext).getBaseInfos(true, new com.yunbao.common.http.base.HttpCallback<com.shayu.onetoone.bean.UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(com.shayu.onetoone.bean.UserBean data) {
|
||||
String[] strs = data.getInfo().getCn_label().split(",");
|
||||
List<String> tempStrlist = Arrays.asList(strs);
|
||||
|
||||
String[] ids = data.getInfo().getLabel_id().split(",");
|
||||
List<String> tempIdlist = Arrays.asList(ids);
|
||||
|
||||
for (int i = 0; i < tempStrlist.size(); i++) {
|
||||
myLabelList.add(new LabelBean.Children(Integer.parseInt(tempIdlist.get(i)), tempStrlist.get(i)));
|
||||
}
|
||||
myAdapter.setData(myLabelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void initView() {
|
||||
submit = findViewById(R.id.submit);
|
||||
myFlowTag = findViewById(R.id.myFlowTag);
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
next = findViewById(R.id.next);
|
||||
|
||||
myLabelList = new ArrayList<>();
|
||||
|
||||
myAdapter = new LabelTagAdapter(mContext, new LabelTagAdapter.OnSureOnClickListener() {
|
||||
@Override
|
||||
public void sure(LabelBean.Children labelBean) {
|
||||
|
||||
}
|
||||
});
|
||||
myFlowTag.setAdapter(myAdapter);
|
||||
myFlowTag.setTagCheckedMode(FlowTagLayout.FLOW_TAG_CHECKED_NONE);
|
||||
myAdapter.setData(myLabelList);
|
||||
|
||||
recyclerView.setHasFixedSize(true);
|
||||
LinearLayoutManager layoutManager1 = new LinearLayoutManager(ChooseLabelActivity.this);
|
||||
layoutManager1.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
recyclerView.setLayoutManager(layoutManager1);
|
||||
|
||||
lableChooseAdapter = new LableChooseAdapter(ChooseLabelActivity.this, new LableChooseAdapter.onItemLabelClicklistener() {
|
||||
@Override
|
||||
public void onChoose(LabelBean.Children children) {
|
||||
addLabel(children);
|
||||
}
|
||||
});
|
||||
recyclerView.setAdapter(lableChooseAdapter);
|
||||
|
||||
next.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RouteManager.forwardMainActivity();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setLabel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标签
|
||||
*/
|
||||
private void setLabel() {
|
||||
StringBuffer labels = new StringBuffer();
|
||||
StringBuffer labelNames = new StringBuffer();
|
||||
for (int i = 0; i < myLabelList.size(); i++) {
|
||||
if (i == 0) {
|
||||
labels.append(myLabelList.get(i).getId());
|
||||
labelNames.append(myLabelList.get(i).getCn_title());
|
||||
} else {
|
||||
labels.append("," + myLabelList.get(i).getId());
|
||||
labelNames.append("," + myLabelList.get(i).getCn_title());
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(labels)) {
|
||||
ToastUtil.show("請設置標籤");
|
||||
return;
|
||||
}
|
||||
OTONetManager.getInstance(mContext).setLabels(labels.toString(), new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
Toast.makeText(mContext, data.getMsg(), Toast.LENGTH_SHORT).show();
|
||||
if (data.getCode() == 0) {
|
||||
if (isUserHome) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("label", labelNames.toString());
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
} else {
|
||||
RouteManager.forwardMainActivity();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理标签 +-
|
||||
*
|
||||
* @param children
|
||||
*/
|
||||
private void addLabel(LabelBean.Children children) {
|
||||
if (children.isSelect()) {
|
||||
boolean isAdd = true;
|
||||
for (int i = 0; i < myLabelList.size(); i++) {
|
||||
if (myLabelList.get(i).getId() == children.getId()) {
|
||||
isAdd = false;
|
||||
}
|
||||
}
|
||||
if (isAdd) {
|
||||
myLabelList.add(children);
|
||||
myAdapter.setData(myLabelList);
|
||||
}
|
||||
} else {
|
||||
int index = -1;
|
||||
for (int i = 0; i < myLabelList.size(); i++) {
|
||||
if (myLabelList.get(i).getId() == children.getId()) {
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
if (index != -1) {
|
||||
myLabelList.remove(index);
|
||||
myAdapter.setData(myLabelList);
|
||||
}
|
||||
}
|
||||
if (myLabelList.size() > 0) {
|
||||
findViewById(R.id.notitle).setVisibility(View.GONE);
|
||||
} else {
|
||||
findViewById(R.id.notitle).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
package com.shayu.onetoone.activity.login;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.bigkoo.pickerview.builder.TimePickerBuilder;
|
||||
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
|
||||
import com.bigkoo.pickerview.view.TimePickerView;
|
||||
import com.blankj.utilcode.util.StringUtils;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||
import com.shayu.onetoone.bean.AvatarBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.view.UserAvatarPopup;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
/**
|
||||
* 完善个人资料
|
||||
*/
|
||||
@Route(path = RouteManager.ACTIVITY_COMPLETE)
|
||||
public class CompleteActivity extends AbsOTOActivity {
|
||||
|
||||
private RelativeLayout editHead; //头像点击事件
|
||||
private ImageView userAvatar; //头像
|
||||
private TextView txtChoose;
|
||||
private EditText userNickName; //昵称
|
||||
private TextView userSex1; //性别
|
||||
private TextView userSex2; //性别
|
||||
private TextView userBirthday; //年龄
|
||||
private Button btnRegister; //提交资料
|
||||
|
||||
private int sex = -1; //1 男 2女
|
||||
|
||||
ProcessImageUtil cameraUtil;
|
||||
|
||||
private File mAvatarFile;
|
||||
|
||||
int year;
|
||||
int month;
|
||||
int day;
|
||||
|
||||
private String avatarUrl;
|
||||
Dialog dialog;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_complete;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
year = calendar.get(Calendar.YEAR) - 18;
|
||||
month = calendar.get(Calendar.MONTH);
|
||||
day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
initView();
|
||||
initCamera();
|
||||
dialog = DialogUitl.loadingDialog(mContext, WordUtil.getNewString(R.string.upload_in_progress));
|
||||
}
|
||||
|
||||
private void initCamera() {
|
||||
cameraUtil = new ProcessImageUtil(this, getPackageName()+".fileprovider");
|
||||
cameraUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
@Override
|
||||
public void beforeCamera() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
L.e("cameraUtil.setImageResultCallback:");
|
||||
if (file != null) {
|
||||
mAvatarFile = file;
|
||||
dialog.show();
|
||||
OTONetManager.getInstance(CompleteActivity.this).updateFile(mAvatarFile, new HttpCallback<AvatarBean>() {
|
||||
@Override
|
||||
public void onSuccess(AvatarBean data) {
|
||||
ImgLoader.display(mContext, file, userAvatar);
|
||||
//txtChoose.setVisibility(View.GONE);
|
||||
avatarUrl = data.getAvatar();
|
||||
dialog.hide();
|
||||
ToastUtil.show(R.string.upload_success);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
dialog.hide();
|
||||
ToastUtil.show(R.string.upload_failed);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
dialog.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void initView() {
|
||||
editHead = findViewById(R.id.editHead);
|
||||
userAvatar = findViewById(R.id.userAvatar);
|
||||
txtChoose = findViewById(R.id.text_choose);
|
||||
userNickName = findViewById(R.id.userNickName);
|
||||
userSex1 = findViewById(R.id.user_sex_1);
|
||||
userSex2 = findViewById(R.id.user_sex_2);
|
||||
userBirthday = findViewById(R.id.userBirthday);
|
||||
btnRegister = findViewById(R.id.btn_register);
|
||||
avatarUrl = CommonAppConfig.getInstance().getUserBean().getAvatar();
|
||||
if (!StringUtils.isEmpty(avatarUrl)) {
|
||||
ImgLoader.display(CompleteActivity.this, avatarUrl, userAvatar);
|
||||
}
|
||||
if (!StringUtils.isEmpty(CommonAppConfig.getInstance().getUserBean().getUserNiceName())) {
|
||||
userNickName.setText(CommonAppConfig.getInstance().getUserBean().getUserNiceName());
|
||||
}
|
||||
editHead.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
chooseImage();
|
||||
}
|
||||
});
|
||||
|
||||
userBirthday.setText(String.format(Locale.getDefault(), "%d %s %d %s %d %s",
|
||||
year,
|
||||
WordUtil.getNewString(R.string.year),
|
||||
month + 1,
|
||||
WordUtil.getNewString(R.string.month),
|
||||
day,
|
||||
WordUtil.getNewString(R.string.day)
|
||||
));
|
||||
|
||||
userSex1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
changeSex(2);
|
||||
}
|
||||
});
|
||||
userSex2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
changeSex(1);
|
||||
}
|
||||
});
|
||||
userBirthday.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//时间选择器
|
||||
Calendar selectedDate = Calendar.getInstance();
|
||||
selectedDate.set(year, month, day);
|
||||
Calendar startCalendar = Calendar.getInstance();
|
||||
Calendar endCalendar = Calendar.getInstance();
|
||||
startCalendar.set(1990, 1, 1);
|
||||
endCalendar.setTime(new Date());
|
||||
TimePickerView pvTime = new TimePickerBuilder(CompleteActivity.this, new OnTimeSelectListener() {
|
||||
@Override
|
||||
public void onTimeSelect(Date date, View v) {
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
|
||||
year = calendar.get(Calendar.YEAR);
|
||||
month = calendar.get(Calendar.MONTH);
|
||||
day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
userBirthday.setText(String.format(Locale.getDefault(), "%d %s %d %s %d %s",
|
||||
year,
|
||||
WordUtil.getNewString(R.string.year),
|
||||
month + 1,
|
||||
WordUtil.getNewString(R.string.month),
|
||||
day,
|
||||
WordUtil.getNewString(R.string.day)
|
||||
));
|
||||
}
|
||||
}).setRangDate(startCalendar, endCalendar).setCancelText(WordUtil.getNewString(R.string.birthday))
|
||||
.setSubmitColor(getResources().getColor(R.color.blue01))
|
||||
.setSubmitText(WordUtil.getNewString(R.string.complete))
|
||||
.setContentTextSize(20)
|
||||
.setDate(selectedDate)
|
||||
.build();
|
||||
pvTime.show();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(btnRegister, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (StringUtils.isEmpty(userNickName.getText().toString())) {
|
||||
Toast.makeText(mContext, WordUtil.getNewString(R.string.nickname_hint), Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (sex == -1) {
|
||||
Toast.makeText(mContext, WordUtil.getNewString(R.string.gender_hint), Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
OTONetManager.getInstance(mContext).setInfo(avatarUrl, userNickName.getText().toString(), sex, year + "-" + (month + 1) + "-" + day, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
Toast.makeText(mContext, data.getMsg(), Toast.LENGTH_SHORT).show();
|
||||
if (data.getCode() == 0) {
|
||||
RouteManager.forwardChooseLabelActivity(false);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择图片
|
||||
*/
|
||||
private void chooseImage() {
|
||||
UserAvatarPopup userAvatarPopup = new UserAvatarPopup(this, userAvatar1 -> {
|
||||
avatarUrl = userAvatar1;
|
||||
ImgLoader.display(CompleteActivity.this, avatarUrl, userAvatar);
|
||||
//txtChoose.setVisibility(View.GONE);
|
||||
}, isCamera -> {
|
||||
if (isCamera) {
|
||||
cameraUtil.getImageByCamera();
|
||||
} else {
|
||||
cameraUtil.getImageByAlumb();
|
||||
}
|
||||
});
|
||||
new XPopup.Builder(mContext).asCustom(userAvatarPopup).show();
|
||||
|
||||
}
|
||||
|
||||
private void changeSex(int i) {
|
||||
sex = i;
|
||||
if (sex == 2) {
|
||||
userSex1.setTextColor(getResources().getColor(R.color.white));
|
||||
userSex2.setTextColor(getResources().getColor(R.color.text_gray));
|
||||
userSex1.setBackgroundResource(R.mipmap.icon_user_sex_02);
|
||||
userSex2.setBackgroundResource(R.mipmap.icon_user_sex_00);
|
||||
} else {
|
||||
userSex1.setTextColor(getResources().getColor(R.color.text_gray));
|
||||
userSex2.setTextColor(getResources().getColor(R.color.white));
|
||||
userSex1.setBackgroundResource(R.mipmap.icon_user_sex_00);
|
||||
userSex2.setBackgroundResource(R.mipmap.icon_user_sex_01);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,696 @@
|
||||
package com.shayu.onetoone.activity.login;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.home_zdy_img_cn;
|
||||
import static com.yunbao.common.CommonAppContext.home_zdy_img_us;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
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.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.Settings;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.DeviceUtils;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.facebook.AccessToken;
|
||||
import com.facebook.CallbackManager;
|
||||
import com.facebook.FacebookCallback;
|
||||
import com.facebook.FacebookException;
|
||||
import com.facebook.Profile;
|
||||
import com.facebook.ProfileTracker;
|
||||
import com.facebook.login.LoginManager;
|
||||
import com.facebook.login.LoginResult;
|
||||
import com.fm.openinstall.OpenInstall;
|
||||
import com.fm.openinstall.listener.AppInstallAdapter;
|
||||
import com.fm.openinstall.model.AppData;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignIn;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
|
||||
import com.google.android.gms.common.api.ApiException;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.linecorp.linesdk.Scope;
|
||||
import com.linecorp.linesdk.auth.LineAuthenticationParams;
|
||||
import com.linecorp.linesdk.auth.LineLoginApi;
|
||||
import com.linecorp.linesdk.auth.LineLoginResult;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||
import com.shayu.onetoone.bean.JoinAnchorBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.twitter.sdk.android.core.Callback;
|
||||
import com.twitter.sdk.android.core.DefaultLogger;
|
||||
import com.twitter.sdk.android.core.Result;
|
||||
import com.twitter.sdk.android.core.Twitter;
|
||||
import com.twitter.sdk.android.core.TwitterAuthConfig;
|
||||
import com.twitter.sdk.android.core.TwitterAuthToken;
|
||||
import com.twitter.sdk.android.core.TwitterConfig;
|
||||
import com.twitter.sdk.android.core.TwitterException;
|
||||
import com.twitter.sdk.android.core.TwitterSession;
|
||||
import com.twitter.sdk.android.core.identity.TwitterLoginButton;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.FaceBookUpModel;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.LoginData;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.main.MainNetManager;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
|
||||
/**
|
||||
* 入口
|
||||
*/
|
||||
@Route(path = RouteManager.ACTIVITY_ENTRY)
|
||||
public class EntryActivity extends AbsOTOActivity {
|
||||
|
||||
private ImageView btn_phone, btn_line;
|
||||
private TextView btn_tip, btn_tip1, tv_customer;
|
||||
private TwitterLoginButton tt_login_button;
|
||||
private LinearLayout btn_google;
|
||||
private static String mLoginType = Constants.MOB_PHONE;//登录方式
|
||||
public String mPromoCode = "", UserID = "";//推广码
|
||||
|
||||
private String mUuidDevice = "";//手机唯一标识符
|
||||
private static boolean mFirstLogin;//是否是第一次登录
|
||||
private static boolean mShowInvite;//显示邀请码弹窗
|
||||
private GoogleSignInClient mGoogleSignInClient;
|
||||
private LinearLayout lt_btn_twitter, lt_btn_facebook, lt_customer;
|
||||
private String kefuUrl = "";
|
||||
private boolean mBtnClick = false;
|
||||
private Dialog loginLoadingDialog;
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void close(String str) {
|
||||
if ("close_login".equals(str)) {
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置透明状态栏
|
||||
*/
|
||||
private void setStatusBar() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Window window = getWindow();
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_entry;
|
||||
}
|
||||
|
||||
|
||||
public void Get_hash_key() {
|
||||
PackageInfo info;
|
||||
try {
|
||||
info = getPackageManager().getPackageInfo(getPackageName(), 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 main(Bundle savedInstanceState) {
|
||||
if (getIntent().getBooleanExtra("forwardEntry", false)) {
|
||||
IMLoginManager.get(this).logout(this);
|
||||
ToastUtil.show(R.string.login_invalid);
|
||||
}
|
||||
Get_hash_key();
|
||||
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);
|
||||
|
||||
btn_google = findViewById(R.id.btn_google);
|
||||
tt_login_button = findViewById(R.id.tt_login_button);
|
||||
|
||||
tv_customer = findViewById(R.id.tv_customer);
|
||||
btn_phone = findViewById(R.id.btn_phone);
|
||||
btn_phone.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ToLogin();
|
||||
}
|
||||
});
|
||||
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, false);
|
||||
}
|
||||
});
|
||||
|
||||
btn_tip.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
WebViewActivity.forward(EntryActivity.this, HtmlConfig.LOGIN_PRIVCAY1, false);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
getPromoCode();
|
||||
getUuidDevice();
|
||||
|
||||
|
||||
lt_btn_facebook.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (isBtnClick()) {
|
||||
return;
|
||||
}
|
||||
timerOutBtn(view);
|
||||
MainNetManager.get(EntryActivity.this)
|
||||
.FaceBookUp(new HttpCallback<FaceBookUpModel>() {
|
||||
@Override
|
||||
public void onSuccess(FaceBookUpModel data) {
|
||||
if (data.getType().equals("0")) {
|
||||
LoginManager.getInstance().logInWithReadPermissions(EntryActivity.this, Arrays.asList("public_profile"));
|
||||
} else {
|
||||
WebViewActivity.forward(EntryActivity.this, data.getLink() + "?", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(R.string.net_error);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
|
||||
@Override
|
||||
public void onSuccess(LoginResult loginResult) {
|
||||
updateUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(FacebookException error) {
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
});
|
||||
|
||||
googleLoginSet();
|
||||
twitterLoginSet();
|
||||
|
||||
btn_google.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isBtnClick()) {
|
||||
return;
|
||||
}
|
||||
timerOutBtn(v);
|
||||
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
|
||||
startActivityForResult(signInIntent, 1002);
|
||||
}
|
||||
});
|
||||
|
||||
lt_btn_twitter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isBtnClick()) {
|
||||
return;
|
||||
}
|
||||
timerOutBtn(v);
|
||||
tt_login_button.performClick();
|
||||
}
|
||||
});
|
||||
|
||||
tt_login_button.setCallback(new Callback<TwitterSession>() {
|
||||
@Override
|
||||
public void success(Result<TwitterSession> result) {
|
||||
// Do something with result, which provides a TwitterSession for making API calls
|
||||
//result里面包含了用户的信息,我们可以从中取出token,tokenSecret
|
||||
//(如果我们有自己的后台服务器,发送这两个到我们自己的后台,后台再去验证)
|
||||
TwitterAuthToken authToken = result.data.getAuthToken();
|
||||
String token = authToken.token;
|
||||
String appId = "24315541";
|
||||
String tokenSecret = authToken.secret;
|
||||
|
||||
final String userName = result.data.getUserName();
|
||||
|
||||
LoginData data = new LoginData();
|
||||
data.setAvatar("");
|
||||
data.setNickName(userName);
|
||||
data.setOpenID(token);
|
||||
data.setType("twitter");
|
||||
|
||||
loginBuyThird(data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failure(TwitterException exception) {
|
||||
Log.i("Log", "TwitterException = " + exception);
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
});
|
||||
findViewById(R.id.btn_line).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (isBtnClick()) {
|
||||
return;
|
||||
}
|
||||
timerOutBtn(view);
|
||||
try {
|
||||
// App-to-app login
|
||||
Intent loginIntent = LineLoginApi.getLoginIntent(
|
||||
view.getContext(),
|
||||
"2001228692",
|
||||
new LineAuthenticationParams.Builder()
|
||||
.scopes(Arrays.asList(Scope.PROFILE))
|
||||
// .nonce("<a randomly-generated string>") // nonce can be used to improve security
|
||||
.build());
|
||||
startActivityForResult(loginIntent, 1001);
|
||||
} catch (Exception e) {
|
||||
Log.e("ERROR", e.toString());
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
getUrl();
|
||||
|
||||
lt_customer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!"".equals(kefuUrl)) {
|
||||
Constants.LoginKefu = true;
|
||||
WebViewActivity.forward(EntryActivity.this, kefuUrl, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getUrl() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getCustomerService(new HttpCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
kefuUrl = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void twitterLoginSet() {
|
||||
TwitterConfig config = new TwitterConfig.Builder(this)
|
||||
.logger(new DefaultLogger(Log.DEBUG))
|
||||
.twitterAuthConfig(new TwitterAuthConfig(getResources().getString(R.string.twitter_key), getResources().getString(R.string.twitter_secret)))
|
||||
.debug(true)
|
||||
.build();
|
||||
Twitter.initialize(config);
|
||||
}
|
||||
|
||||
private void googleLoginSet() {
|
||||
//TODO Google登录
|
||||
//配置登录以请求用户的ID,电子邮件地址和基本配置文件.ID和基本配置文件包含在DEFAULT_SIGN_IN中.
|
||||
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
|
||||
.requestEmail()
|
||||
// .requestIdToken("AIzaSyDVnuGnQzjI_vDrxh20Hv_S1OMUD7Vp3zU")
|
||||
.build();
|
||||
//使用gso指定的选项构建一个GoogleSignInClient.
|
||||
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
|
||||
|
||||
}
|
||||
|
||||
private void requestPermission() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {//30
|
||||
// 先判断有没有权限
|
||||
if (!Environment.isExternalStorageManager()) {
|
||||
//跳转到设置界面引导用户打开
|
||||
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
|
||||
intent.setData(Uri.parse("package:" + getPackageName()));
|
||||
startActivityForResult(intent, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CallbackManager callbackManager = CallbackManager.Factory.create();
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
Log.i("ttts1", requestCode + "a " + resultCode);
|
||||
|
||||
if (requestCode == 1001) {//line登录
|
||||
LineLoginResult result = LineLoginApi.getLoginResultFromIntent(data);
|
||||
Log.i("ttts", result.getResponseCode() + "");
|
||||
switch (result.getResponseCode()) {
|
||||
case SUCCESS:
|
||||
// Login successful
|
||||
String accessToken = result.getLineCredential().getAccessToken().getTokenString();
|
||||
LoginData re_data = new LoginData();
|
||||
re_data.setOpenID(result.getLineProfile().getUserId());
|
||||
if (result.getLineProfile().getPictureUrl() != null) {
|
||||
re_data.setAvatar("" + result.getLineProfile().getPictureUrl().toString());
|
||||
}
|
||||
re_data.setNickName(result.getLineProfile().getDisplayName());
|
||||
re_data.setType("line");
|
||||
loginBuyThird(re_data);
|
||||
break;
|
||||
case CANCEL:
|
||||
// Login canceled by user
|
||||
Log.e("ERROR", "LINE Login Canceled by user.");
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
break;
|
||||
default:
|
||||
// Login canceled due to other error
|
||||
Log.e("ERROR", "Login FAILED!");
|
||||
Log.e("ERROR", result.getErrorData().toString());
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
} else if (requestCode == 1000) {//判断权限
|
||||
if (Environment.isExternalStorageManager()) {
|
||||
//自己的操作
|
||||
} else {
|
||||
|
||||
}
|
||||
} else if (requestCode == 1002) {//google登录
|
||||
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
|
||||
handleSignInResult(task);
|
||||
} else {
|
||||
tt_login_button.onActivityResult(requestCode, resultCode, data);//twitter登录回调
|
||||
callbackManager.onActivityResult(requestCode, resultCode, data);//facebook登录回调
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
}
|
||||
|
||||
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
|
||||
try {
|
||||
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
|
||||
//account里可以直接获取到ID,name,和头像
|
||||
String idToken = account.getIdToken();
|
||||
account.getFamilyName();
|
||||
account.getGivenName();
|
||||
|
||||
LoginData data = new LoginData();
|
||||
data.setAvatar("");
|
||||
data.setNickName(account.getDisplayName());
|
||||
data.setOpenID(account.getId());
|
||||
data.setType("google");
|
||||
|
||||
loginBuyThird(data);
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
Log.i("Log", "ApiException = " + e);
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
boolean enableButtons = AccessToken.getCurrentAccessToken() != null;
|
||||
Profile profile = Profile.getCurrentProfile();
|
||||
if (profile == null) {
|
||||
ProfileTracker tracker = new ProfileTracker() {
|
||||
|
||||
@Override
|
||||
protected void onCurrentProfileChanged(@Nullable Profile pf, @Nullable Profile profile1) {
|
||||
if (!enableButtons) {
|
||||
stopTracking();
|
||||
return;
|
||||
}
|
||||
if (pf != null) {
|
||||
loginFaceBookUpdateUI(pf);
|
||||
} else if (profile1 != null) {
|
||||
loginFaceBookUpdateUI(profile1);
|
||||
} else {
|
||||
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
|
||||
}
|
||||
stopTracking();
|
||||
}
|
||||
};
|
||||
tracker.startTracking();
|
||||
} else {
|
||||
if (enableButtons) {
|
||||
loginFaceBookUpdateUI(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loginFaceBookUpdateUI(Profile profile) {
|
||||
LoginData data = new LoginData();
|
||||
data.setAvatar(profile.getProfilePictureUri(150, 150).toString());
|
||||
data.setNickName(profile.getName());
|
||||
data.setOpenID(AccessToken.getCurrentAccessToken().getUserId());
|
||||
data.setType("facebook");
|
||||
loginBuyThird(data);
|
||||
}
|
||||
|
||||
//从网页获取推广码
|
||||
private void getPromoCode() {
|
||||
OpenInstall.getInstall(new AppInstallAdapter() {
|
||||
@Override
|
||||
public void onInstall(AppData appData) {
|
||||
//获取渠道数据
|
||||
String channelCode = appData.getChannel();
|
||||
Log.d("OpenInstall", "appData.getData()= " + appData.getData());
|
||||
//获取自定义数据
|
||||
if (appData.getData() != null && !appData.getData().equals("")) {
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == true) {
|
||||
|
||||
} else {
|
||||
JSONObject data = JSON.parseObject(appData.getData());
|
||||
mPromoCode = data.getString("admin_id") + "";
|
||||
UserID = data.getString("user_id") + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void getUuidDevice() {
|
||||
mUuidDevice = DeviceUtils.getUniqueDeviceId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
public void ToLogin() {
|
||||
RouteManager.forwardLoginActivity();
|
||||
finish();
|
||||
}
|
||||
|
||||
private static final String EMAIL = "email";
|
||||
|
||||
/**
|
||||
* 三方登录
|
||||
*/
|
||||
private void loginBuyThird(LoginData data) {
|
||||
mLoginType = data.getType();
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == true) {
|
||||
mPromoCode = "";
|
||||
}
|
||||
OTONetManager.getInstance(mContext)
|
||||
.userLoginByThird(UserID, data.getOpenID(), mPromoCode, mUuidDevice, data.getNickName(), data.getAvatar(), data.getType(),
|
||||
new HttpCallback<IMLoginModel>() {
|
||||
@Override
|
||||
public void onSuccess(IMLoginModel data) {
|
||||
onLoginSuccess(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
//登录成功!
|
||||
private void onLoginSuccess(IMLoginModel data) {
|
||||
String uid = data.getId() + "";
|
||||
String token = data.getToken();
|
||||
if (data.getNeedBind() == 0) {
|
||||
mFirstLogin = data.getFirstLogin() == 1;
|
||||
mShowInvite = data.getIsagent() == 1;
|
||||
CommonAppConfig.getInstance().setLoginInfo(uid, token, true);
|
||||
//设置登录信息
|
||||
IMLoginManager.get(mContext).setupLoginUser(data);
|
||||
//融云连接服务器
|
||||
RongcloudIMManager.connectIM(mContext);
|
||||
getBaseUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
private void getBaseUserInfo() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getBaseInfos(true,new HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
UserManager.saveUserBean(mContext,data);
|
||||
if (mFirstLogin) {
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY) {
|
||||
RouteManager.forwardMainActivity();
|
||||
} else {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getRandJoinAnchor(new HttpCallback<JoinAnchorBean>() {
|
||||
@Override
|
||||
public void onSuccess(JoinAnchorBean data) {
|
||||
IMLoginManager.get(EntryActivity.this).setNewUserGif(true);
|
||||
IMLoginManager.get(EntryActivity.this).setisNewUserOne(true);
|
||||
// MainActivity.forward(EntryActivity.this, false);
|
||||
if (!StringUtil.isEmpty(data.getHome_zdy_img_us())) {
|
||||
home_zdy_img_us = data.getHome_zdy_img_us();
|
||||
home_zdy_img_cn = data.getHome_zdy_img_cn();
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.getHome_zdy_pop())) {
|
||||
NoviceInstructorManager.get(mContext).setHomeZdyPop(data.getHome_zdy_pop());
|
||||
}
|
||||
RouteManager.forwardMainActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
RouteManager.forwardMainActivity();
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void timerOutBtn(View btn) {
|
||||
if (mBtnClick) {
|
||||
return;
|
||||
}
|
||||
loginLoadingDialog = DialogUitl.loadingDialog(EntryActivity.this, getString(R.string.login_wait));
|
||||
loginLoadingDialog.show();
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
mBtnClick = false;
|
||||
if (loginLoadingDialog != null) {
|
||||
loginLoadingDialog.dismiss();
|
||||
loginLoadingDialog = null;
|
||||
}
|
||||
}
|
||||
}, 3000);
|
||||
mBtnClick = true;
|
||||
}
|
||||
|
||||
private boolean isBtnClick() {
|
||||
if (mBtnClick) {
|
||||
ToastUtil.show("請稍後再試");
|
||||
}
|
||||
return mBtnClick;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (loginLoadingDialog != null) {
|
||||
if (loginLoadingDialog.isShowing()) {
|
||||
loginLoadingDialog.dismiss();
|
||||
}
|
||||
loginLoadingDialog = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,426 @@
|
||||
package com.shayu.onetoone.activity.login;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.DeviceUtils;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.sahooz.library.Country;
|
||||
import com.sahooz.library.CountryPicker;
|
||||
import com.sahooz.library.OnPick;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.MainHttpUtil;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/25.
|
||||
*/
|
||||
|
||||
public class FindPwdActivity extends AbsActivity {
|
||||
|
||||
private EditText mEditPhone;
|
||||
private EditText mEditCode;
|
||||
private EditText mEditPwd1;
|
||||
private EditText mEditPwd2;
|
||||
private TextView mBtnCode;
|
||||
private View mBtnRegister;
|
||||
private Handler mHandler;
|
||||
private static final int TOTAL = 60;
|
||||
private int mCount = TOTAL;
|
||||
private String mGetCode;
|
||||
private String mGetCodeAgain;
|
||||
private Dialog mDialog;
|
||||
private int mPhoneMinLength=5;//输入手机号的最小位数
|
||||
private int mCountryCode = 852;//国家代码
|
||||
private ImageView mIvCountryCode;
|
||||
private TextView mTvCountryCode;
|
||||
private WebView webview;
|
||||
private WebSettings webSettings;
|
||||
private ArrayList<Country> allCountries = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_find_pwd;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.find_pwd_forget));
|
||||
mEditPhone = (EditText) findViewById(R.id.edit_phone);
|
||||
mEditCode = (EditText) findViewById(R.id.edit_code);
|
||||
mIvCountryCode =findViewById(R.id.ivCountryCode);
|
||||
mTvCountryCode=findViewById(R.id.tvCountryCode);
|
||||
webview = (WebView)findViewById(R.id.webview);
|
||||
initView();
|
||||
mEditPwd1 = (EditText) findViewById(R.id.edit_pwd_1);
|
||||
mEditPwd2 = (EditText) findViewById(R.id.edit_pwd_2);
|
||||
mBtnCode = (TextView) findViewById(R.id.btn_code);
|
||||
mBtnRegister = findViewById(R.id.btn_register);
|
||||
mGetCode =mContext.getString(R.string.reg_get_code);
|
||||
mGetCodeAgain =mContext.getString(R.string.reg_get_code_again);
|
||||
mTvCountryCodeClick();
|
||||
mEditPhone.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (!TextUtils.isEmpty(s) && s.length() >= mPhoneMinLength) {
|
||||
mBtnCode.setEnabled(true);
|
||||
} else {
|
||||
mBtnCode.setEnabled(false);
|
||||
}
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
TextWatcher textWatcher = new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
};
|
||||
mEditCode.addTextChangedListener(textWatcher);
|
||||
mEditPwd1.addTextChangedListener(textWatcher);
|
||||
mEditPwd2.addTextChangedListener(textWatcher);
|
||||
mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
mCount--;
|
||||
if (mCount > 0) {
|
||||
mBtnCode.setText(mGetCodeAgain + "(" + mCount + "s)");
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessageDelayed(0, 1000);
|
||||
}
|
||||
} else {
|
||||
mBtnCode.setText(mGetCode);
|
||||
mCount = TOTAL;
|
||||
if (mBtnCode != null) {
|
||||
mBtnCode.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mDialog = DialogUitl.loadingDialog(mContext);
|
||||
// EventBus.getDefault().register(this);
|
||||
|
||||
|
||||
allCountries.clear();
|
||||
allCountries.addAll(Country.getAll(mContext, null));
|
||||
|
||||
String ct = IMLoginManager.get(mContext).getString("sys_user_area");
|
||||
ct = TextUtils.equals("中国", ct) ? "中国香港" : ct;
|
||||
for (int i = 0; i < allCountries.size(); i++) {
|
||||
if (allCountries.get(i).chs.equals(ct)) {
|
||||
String countryName = allCountries.get(i).name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) : countryName;
|
||||
mTvCountryCode.setText("+" + allCountries.get(i).code + " " + countryName);
|
||||
mCountryCode = allCountries.get(i).code;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void mTvCountryCodeClick() {
|
||||
mIvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
mTvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public class JsBridge {
|
||||
@JavascriptInterface
|
||||
public void getData(final String Randstr, final String Ticket) {
|
||||
|
||||
((FindPwdActivity) mContext).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i("tvss",Randstr);
|
||||
webview.setVisibility(View.GONE);
|
||||
//获取验证码
|
||||
getCode(Randstr,Ticket);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
webview = (WebView) findViewById(R.id.webview);
|
||||
webSettings = webview.getSettings();
|
||||
webSettings.setUseWideViewPort(true);
|
||||
webSettings.setLoadWithOverviewMode(true);
|
||||
// 禁用缓存
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||
webview.setWebViewClient(new WebViewClient(){
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
view.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
// 开启js支持
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webview.addJavascriptInterface(new JsBridge(), "jsBridge");
|
||||
// 也可以加载本地html(webView.loadUrl("file:///android_asset/xxx.html"))
|
||||
webview.loadUrl(CommonAppConfig.HOST +"/h5/live/TCaptcha.html");
|
||||
}
|
||||
|
||||
private void showCountryCode(){
|
||||
CountryPicker.newInstance(null, new OnPick() {
|
||||
@Override
|
||||
public void onPick(Country country) {
|
||||
String countryName = country.name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) + "..." : countryName;
|
||||
mTvCountryCode.setText(" +" + country.code + " " + countryName);
|
||||
mCountryCode=country.code;
|
||||
}
|
||||
}).show(getSupportFragmentManager(), "country");
|
||||
}
|
||||
|
||||
private void changeEnable() {
|
||||
String phone = mEditPhone.getText().toString();
|
||||
String code = mEditCode.getText().toString();
|
||||
String pwd1 = mEditPwd1.getText().toString();
|
||||
String pwd2 = mEditPwd2.getText().toString();
|
||||
mBtnRegister.setEnabled(!TextUtils.isEmpty(phone) && !TextUtils.isEmpty(code) && !TextUtils.isEmpty(pwd1) && !TextUtils.isEmpty(pwd2));
|
||||
}
|
||||
|
||||
public void registerClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_code) {
|
||||
webview.setVisibility(View.VISIBLE);
|
||||
} else if (i == R.id.btn_register) {
|
||||
register();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证码
|
||||
*/
|
||||
private void getCode(String Randstr,String Ticket) {
|
||||
String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum)) {
|
||||
// mEditPhone.setError(mContext.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
mEditCode.requestFocus();
|
||||
MainHttpUtil.getRegisterCode(Randstr,Ticket,phoneNum,mCountryCode, mGetCodeCallback);
|
||||
}
|
||||
|
||||
private HttpCallback mGetCodeCallback = new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
mBtnCode.setEnabled(false);
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessage(0);
|
||||
}
|
||||
if (!TextUtils.isEmpty(msg) && msg.contains("123456")) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 注册并登陆
|
||||
*/
|
||||
private void register() {
|
||||
final String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum)) {
|
||||
// mEditPhone.setError(mContext.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
String code = mEditCode.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(code)) {
|
||||
mEditCode.setError(mContext.getString(R.string.reg_input_code));
|
||||
mEditCode.requestFocus();
|
||||
return;
|
||||
}
|
||||
final String pwd = mEditPwd1.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd)) {
|
||||
mEditPwd1.setError(mContext.getString(R.string.reg_input_pwd_1));
|
||||
mEditPwd1.requestFocus();
|
||||
return;
|
||||
}
|
||||
String pwd2 = mEditPwd2.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_input_pwd_2));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (!pwd.equals(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_pwd_error));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (mDialog != null) {
|
||||
mDialog.show();
|
||||
}
|
||||
MainHttpUtil.findPwd(phoneNum, pwd, pwd2, code, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
login(phoneNum, pwd);
|
||||
} else {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
if (!TextUtils.isEmpty(msg)) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void login(String phoneNum, String pwd) {
|
||||
String uuid= DeviceUtils.getUniqueDeviceId();
|
||||
MainHttpUtil.login(phoneNum, pwd,uuid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
String uid = obj.getString("id");
|
||||
String token = obj.getString("token");
|
||||
IMLoginModel model = GsonUtils.fromJson(info[0], IMLoginModel.class);
|
||||
IMLoginManager.get(mContext).setupLoginUser(model);
|
||||
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) {
|
||||
RouteManager.forwardMainActivity();
|
||||
finish();
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,356 @@
|
||||
package com.shayu.onetoone.activity.login;
|
||||
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
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.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
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.ConfigBean;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.UserAreaBean;
|
||||
import com.yunbao.common.fragment.LoadingDialog;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/17.
|
||||
*/
|
||||
@Route(path = RouteManager.ACTIVITY_LOGIN)
|
||||
public class LoginActivity extends AbsOTOActivity {
|
||||
|
||||
private View mRoot;
|
||||
// private ImageView mBg;
|
||||
private ObjectAnimator mAnimator;
|
||||
private EditText mEditPhone;
|
||||
private EditText mEditPwd;
|
||||
private View mBtnLogin;
|
||||
private RecyclerView mRecyclerView;
|
||||
// private MobLoginUtil mLoginUtil;
|
||||
private boolean mFirstLogin;//是否是第一次登录
|
||||
private static boolean mShowInvite;//显示邀请码弹窗
|
||||
private static String mLoginType = Constants.MOB_PHONE;//登录方式
|
||||
private String mPromoCode = "";//推广码
|
||||
private String mUuidDevice = "";//手机唯一标识符
|
||||
static String phoneNum;
|
||||
static String pwd;
|
||||
private static Context Contexts;
|
||||
Activity activity;
|
||||
TextView btn_forget_pwd;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_login;
|
||||
}
|
||||
|
||||
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onRegSuccessEvent(RegSuccessEvent e) {
|
||||
// if (!isFinishing()) {
|
||||
// finish();
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
EventBus.getDefault().register(this);
|
||||
initUserArea();
|
||||
mRoot = findViewById(R.id.root);
|
||||
Contexts = this;
|
||||
activity = this;
|
||||
OpenInstall.getInstall(new AppInstallAdapter() {
|
||||
@Override
|
||||
public void onInstall(AppData appData) {
|
||||
//获取渠道数据
|
||||
String channelCode = appData.getChannel();
|
||||
//获取自定义数据
|
||||
String bindData = appData.getData();
|
||||
Log.d("OpenInstall", "getInstall : installData = " + appData.toString());
|
||||
}
|
||||
});
|
||||
|
||||
mEditPhone = (EditText) findViewById(R.id.edit_phone);
|
||||
mEditPwd = (EditText) findViewById(R.id.edit_pwd);
|
||||
mBtnLogin = findViewById(R.id.btn_login);
|
||||
btn_forget_pwd = findViewById(R.id.btn_forget_pwd);
|
||||
btn_forget_pwd.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
forgetPwd();
|
||||
}
|
||||
});
|
||||
TextView btn_register = findViewById(R.id.btn_register);
|
||||
btn_register.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
register();
|
||||
}
|
||||
});
|
||||
|
||||
// findViewById(R.id.btn_back).setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// //finish();
|
||||
// RouteUtil.forwardEntry2();
|
||||
// }
|
||||
// });
|
||||
|
||||
TextWatcher textWatcher = new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
String phone = mEditPhone.getText().toString();
|
||||
String pwd = mEditPwd.getText().toString();
|
||||
// mBtnLogin.setEnabled(!TextUtils.isEmpty(phone) && !TextUtils.isEmpty(pwd));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
};
|
||||
mEditPhone.addTextChangedListener(textWatcher);
|
||||
mEditPwd.addTextChangedListener(textWatcher);
|
||||
boolean otherLoginType = false;
|
||||
ConfigBean configBean = CommonAppConfig.getInstance().getConfig();
|
||||
// if (!otherLoginType) {
|
||||
// findViewById(R.id.other_login_tip).setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
|
||||
getUuidDevice();
|
||||
getPromoCode();
|
||||
}
|
||||
|
||||
|
||||
public void loginClick(View v) {
|
||||
ViewClicksAntiShake.clicksAntiShake(v, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_login) {
|
||||
login();
|
||||
|
||||
} else if (i == R.id.btn_register) {
|
||||
register();
|
||||
} else if (i == R.id.btn_forget_pwd) {
|
||||
forgetPwd();
|
||||
|
||||
} else if (i == R.id.btn_tip) {
|
||||
forwardTip();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//注册
|
||||
private void register() {
|
||||
startActivity(new Intent(mContext, RegisterActivity.class));
|
||||
//RouteManager.forwardCompleteActivity();
|
||||
}
|
||||
|
||||
//忘记密码
|
||||
private void forgetPwd() {
|
||||
startActivity(new Intent(mContext, FindPwdActivity.class));
|
||||
}
|
||||
|
||||
private LoadingDialog loadingDialog;
|
||||
|
||||
//手机号密码登录
|
||||
private void login() {
|
||||
phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.login_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
pwd = mEditPwd.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd)) {
|
||||
mEditPwd.setError(mContext.getString(R.string.login_input_pwd));
|
||||
mEditPwd.requestFocus();
|
||||
return;
|
||||
}
|
||||
mLoginType = Constants.MOB_PHONE;
|
||||
String uuid = DeviceUtils.getUniqueDeviceId();
|
||||
loadingDialog = new LoadingDialog();
|
||||
loadingDialog.show(getSupportFragmentManager(), "LoadingDialog");
|
||||
loadingDialog.setShowText(getString(R.string.login_ing));
|
||||
OTONetManager.getInstance(mContext).login(phoneNum, pwd, uuid, new com.yunbao.common.http.base.HttpCallback<IMLoginModel>() {
|
||||
@Override
|
||||
public void onSuccess(IMLoginModel data) {
|
||||
onLoginSuccess(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
loadingDialog.dismiss();
|
||||
}
|
||||
});
|
||||
hideKeyboard(mEditPwd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 强隐键盘
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
private void hideKeyboard(View view) {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
//登录即代表同意服务和隐私条款
|
||||
private void forwardTip() {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.LOGIN_PRIVCAY, false);
|
||||
}
|
||||
|
||||
|
||||
//登录成功!
|
||||
private void onLoginSuccess(IMLoginModel data) {
|
||||
String uid = data.getId() + "";
|
||||
String token = data.getToken();
|
||||
mFirstLogin = data.getFirstLogin() == 1;
|
||||
mShowInvite = data.getIsagent() == 1;
|
||||
CommonAppConfig.getInstance().setLoginInfo(uid, token, true);
|
||||
//设置登录信息
|
||||
IMLoginManager.get(activity).setupLoginUser(data);
|
||||
getBaseUserInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
private void getBaseUserInfo() {
|
||||
OTONetManager.getInstance(mContext).getBaseInfos(true, new com.yunbao.common.http.base.HttpCallback<com.shayu.onetoone.bean.UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(com.shayu.onetoone.bean.UserBean data) {
|
||||
RongcloudIMManager.connectIM(mContext);
|
||||
if (mFirstLogin) {
|
||||
IMLoginManager.get(mContext).setNewUserGif(true);
|
||||
IMLoginManager.get(mContext).setisNewUserOne(true);
|
||||
}
|
||||
loadingDialog.dismiss();
|
||||
RouteManager.forwardMainActivity();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void close(String str) {
|
||||
if ("close_login".equals(str)) {
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * 三方登录
|
||||
// */
|
||||
// private void loginBuyThird(LoginData data) {
|
||||
// mLoginType = data.getType();
|
||||
// MainHttpUtil.loginByThird(data.getOpenID(), mPromoCode, mUuidDevice, data.getNickName(), data.getAvatar(), data.getType(), new HttpCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(int code, String msg, String[] info) {
|
||||
// onLoginSuccess(code, msg, info);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
//从网页获取推广码
|
||||
private void getPromoCode() {
|
||||
OpenInstall.getInstall(new AppInstallAdapter() {
|
||||
@Override
|
||||
public void onInstall(AppData appData) {
|
||||
//获取渠道数据
|
||||
String channelCode = appData.getChannel();
|
||||
//获取自定义数据
|
||||
if (appData.getData() != null) {
|
||||
mPromoCode = appData.getData();
|
||||
}
|
||||
Log.d("OpenInstall", "appData.getData()= " + appData.getData());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getUuidDevice() {
|
||||
mUuidDevice = DeviceUtils.getUniqueDeviceId();
|
||||
}
|
||||
|
||||
private void initUserArea() {
|
||||
LiveNetManager.get(mContext).getUserArea(new com.yunbao.common.http.base.HttpCallback<UserAreaBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserAreaBean data) {
|
||||
IMLoginManager.get(mContext).put("sys_user_area", data.getArea());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mAnimator != null) {
|
||||
mAnimator.cancel();
|
||||
}
|
||||
mAnimator = null;
|
||||
EventBus.getDefault().unregister(this);
|
||||
// MainHttpUtil.cancel(MainHttpConsts.LOGIN);
|
||||
// CommonHttpUtil.cancel(CommonHttpConsts.GET_QQ_LOGIN_UNION_ID);
|
||||
// MainHttpUtil.cancel(MainHttpConsts.LOGIN_BY_THIRD);
|
||||
// MainHttpUtil.cancel(MainHttpConsts.GET_BASE_INFO);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
RouteManager.forwardEntryActivity();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,572 @@
|
||||
package com.shayu.onetoone.activity.login;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.home_zdy_img_cn;
|
||||
import static com.yunbao.common.CommonAppContext.home_zdy_img_us;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.DeviceUtils;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.blankj.utilcode.util.StringUtils;
|
||||
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.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.MainActivity;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.MainHttpUtil;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/25.
|
||||
*/
|
||||
|
||||
public class RegisterActivity extends AbsActivity {
|
||||
|
||||
private EditText mEditPhone;
|
||||
private EditText mEditCode;
|
||||
private EditText mEditPwd1;
|
||||
private EditText mEditPwd2;
|
||||
private EditText edit_invitecode_2;
|
||||
private TextView mBtnCode;
|
||||
private View mBtnRegister;
|
||||
private Handler mHandler;
|
||||
private static final int TOTAL = 60;
|
||||
private int mCount = TOTAL;
|
||||
private String mGetCode;
|
||||
private String mGetCodeAgain;
|
||||
private Dialog mDialog;
|
||||
private boolean mFirstLogin;//是否是第一次登录
|
||||
private boolean mShowInvite;
|
||||
private String mPromoCode = "";//推广码
|
||||
private String UserID = "";//用户推广码
|
||||
private String mUuidDevice = "";//手机唯一标识符
|
||||
private int mPhoneMinLength = 5;//输入手机号的最小位数
|
||||
private TextView mTvCountryCode;
|
||||
private int mCountryCode = 852;//国家代码
|
||||
private ImageView mIvCountryCode;
|
||||
private WebView webview;
|
||||
private WebSettings webSettings;
|
||||
private LinearLayout yqm_view;
|
||||
private ArrayList<Country> allCountries = new ArrayList<>();
|
||||
private RegisterActivity activity;
|
||||
//网络请求的回执
|
||||
private Handler netHandler = new Handler();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_register;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
activity = this;
|
||||
mEditPhone = (EditText) findViewById(R.id.edit_phone);
|
||||
webview = (WebView) findViewById(R.id.webview);
|
||||
initView();
|
||||
mTvCountryCode = findViewById(R.id.tvCountryCode);
|
||||
mIvCountryCode = findViewById(R.id.ivCountryCode);
|
||||
mEditCode = (EditText) findViewById(R.id.edit_code);
|
||||
mEditPwd1 = (EditText) findViewById(R.id.edit_pwd_1);
|
||||
mEditPwd2 = (EditText) findViewById(R.id.edit_pwd_2);
|
||||
mBtnCode = (TextView) findViewById(R.id.btn_code);
|
||||
mBtnRegister = findViewById(R.id.btn_register);
|
||||
edit_invitecode_2 = (EditText) findViewById(R.id.edit_invitecode_2);
|
||||
yqm_view = (LinearLayout) findViewById(R.id.yqm_view);
|
||||
//获取设备唯一标识符
|
||||
getUuidDevice();
|
||||
getPromoCode();
|
||||
|
||||
mGetCode = mContext.getString(R.string.reg_get_code);
|
||||
mGetCodeAgain = mContext.getString(R.string.reg_get_code_again);
|
||||
mTvCountryCodeClick();
|
||||
mEditPhone.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (!TextUtils.isEmpty(s) && s.length() >= mPhoneMinLength) {
|
||||
mBtnCode.setEnabled(true);
|
||||
} else {
|
||||
mBtnCode.setEnabled(false);
|
||||
}
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
TextWatcher textWatcher = new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
};
|
||||
mEditCode.addTextChangedListener(textWatcher);
|
||||
mEditPwd1.addTextChangedListener(textWatcher);
|
||||
mEditPwd2.addTextChangedListener(textWatcher);
|
||||
mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
mCount--;
|
||||
if (mCount > 0) {
|
||||
mBtnCode.setText(mGetCodeAgain + "(" + mCount + "s)");
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessageDelayed(0, 1000);
|
||||
}
|
||||
} else {
|
||||
mBtnCode.setText(mGetCode);
|
||||
mCount = TOTAL;
|
||||
if (mBtnCode != null) {
|
||||
mBtnCode.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mDialog = DialogUitl.loadingDialog(mContext, getString(R.string.reg_register_ing));
|
||||
// EventBus.getDefault().register(this);
|
||||
|
||||
allCountries.clear();
|
||||
allCountries.addAll(Country.getAll(mContext, null));
|
||||
|
||||
//String ct = Locale.getDefault().getCountry();
|
||||
String ct = IMLoginManager.get(mContext).getString("sys_user_area");
|
||||
ct = TextUtils.equals("中国", ct) ? "中国香港" : ct;
|
||||
for (int i = 0; i < allCountries.size(); i++) {
|
||||
if (allCountries.get(i).chs.equals(ct)) {
|
||||
String countryName = allCountries.get(i).name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) : countryName;
|
||||
mTvCountryCode.setText("+" + allCountries.get(i).code + " " + countryName);
|
||||
mCountryCode = allCountries.get(i).code;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class JsBridge {
|
||||
@JavascriptInterface
|
||||
public void getData(final String Randstr, final String Ticket) {
|
||||
|
||||
((RegisterActivity) mContext).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i("tvss", Randstr);
|
||||
webview.setVisibility(View.GONE);
|
||||
//获取验证码
|
||||
getMessageCode(Randstr, Ticket);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
webview = (WebView) findViewById(R.id.webview);
|
||||
webSettings = webview.getSettings();
|
||||
webSettings.setUseWideViewPort(true);
|
||||
webSettings.setLoadWithOverviewMode(true);
|
||||
// 禁用缓存
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||
webview.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
view.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
// 开启js支持
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webview.addJavascriptInterface(new JsBridge(), "jsBridge");
|
||||
// 也可以加载本地html(webView.loadUrl("file:///android_asset/xxx.html"))
|
||||
webview.loadUrl(CommonAppConfig.HOST + "/h5/live/TCaptcha.html");
|
||||
}
|
||||
|
||||
|
||||
private void mTvCountryCodeClick() {
|
||||
mIvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
mTvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void changeEnable() {
|
||||
}
|
||||
|
||||
private void showCountryCode() {
|
||||
CountryPicker.newInstance(null, new OnPick() {
|
||||
@Override
|
||||
public void onPick(Country country) {
|
||||
String countryName = country.name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) + "..." : countryName;
|
||||
mTvCountryCode.setText(" +" + country.code + " " + countryName);
|
||||
mCountryCode = country.code;
|
||||
}
|
||||
}).show(getSupportFragmentManager(), "country");
|
||||
}
|
||||
|
||||
public void registerClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_code) {
|
||||
webview.setVisibility(View.VISIBLE);
|
||||
|
||||
} else if (i == R.id.btn_register) {
|
||||
register();
|
||||
} else if (i == R.id.btn_tip2) {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY1, false);
|
||||
} else if (i == R.id.btn_tip3) {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY2, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void getUuidDevice() {
|
||||
String uuid = DeviceUtils.getUniqueDeviceId();
|
||||
if (uuid != null) {
|
||||
mUuidDevice = uuid;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短信验证码
|
||||
*/
|
||||
private void getMessageCode(String Randstr, String Ticket) {
|
||||
String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
mEditCode.requestFocus();
|
||||
MainHttpUtil.getRegisterCode(Randstr, Ticket, phoneNum, mCountryCode, mGetCodeCallback);
|
||||
}
|
||||
|
||||
private HttpCallback mGetCodeCallback = new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
mBtnCode.setEnabled(false);
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessage(0);
|
||||
}
|
||||
if (!TextUtils.isEmpty(msg) && msg.contains("123456")) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 注册并登陆
|
||||
*/
|
||||
private void register() {
|
||||
final String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
String code = mEditCode.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(code)) {
|
||||
mEditCode.setError(mContext.getString(R.string.reg_input_code));
|
||||
mEditCode.requestFocus();
|
||||
return;
|
||||
}
|
||||
final String pwd = mEditPwd1.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd)) {
|
||||
mEditPwd1.setError(mContext.getString(R.string.reg_input_pwd_1));
|
||||
mEditPwd1.requestFocus();
|
||||
return;
|
||||
}
|
||||
String pwd2 = mEditPwd2.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_input_pwd_2));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (!pwd.equals(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_pwd_error));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (mDialog != null) {
|
||||
mDialog.show();
|
||||
}
|
||||
String ti = "";
|
||||
if (edit_invitecode_2.getText().toString().trim().equals("此設備已註冊")) {
|
||||
ti = "";
|
||||
} else {
|
||||
ti = edit_invitecode_2.getText().toString().trim();
|
||||
}
|
||||
MainHttpUtil.register(UserID, ti, phoneNum, mPromoCode, mUuidDevice, mCountryCode, pwd, pwd2, code, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
//注册成功
|
||||
login(phoneNum, pwd, mUuidDevice);
|
||||
OpenInstall.reportRegister();
|
||||
} else {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//从网页获取推广码
|
||||
private void getPromoCode() {
|
||||
|
||||
OpenInstall.getInstall(new AppInstallAdapter() {
|
||||
@Override
|
||||
public void onInstall(AppData appData) {
|
||||
//获取渠道数据
|
||||
String channelCode = appData.getChannel();
|
||||
//获取自定义数据
|
||||
if (appData.getData() != null && !appData.getData().equals("")) {
|
||||
JSONObject data = JSON.parseObject(appData.getData());
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == true) {
|
||||
yqm_view.setVisibility(View.VISIBLE);
|
||||
MainHttpUtil.getDeviceLoginType(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 201) {
|
||||
edit_invitecode_2.setText("此設備已註冊");
|
||||
edit_invitecode_2.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
yqm_view.setVisibility(View.GONE);
|
||||
//推广的码
|
||||
mPromoCode = data.getString("admin_id") + "";
|
||||
//用户的码
|
||||
UserID = data.getString("user_id") + "";
|
||||
}
|
||||
Log.d("OpenInstall", UserID + "appData.getData()1111= " + mPromoCode);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void login(String phoneNum, String pwd, String uuid) {
|
||||
MainHttpUtil.login(phoneNum, pwd, uuid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
String uid = obj.getString("id");
|
||||
String token = obj.getString("token");
|
||||
mFirstLogin = obj.getIntValue("first_login") == 1;
|
||||
mShowInvite = obj.getIntValue("isagent") == 1;
|
||||
CommonAppConfig.getInstance().setLoginInfo(uid, token, true);
|
||||
//设置登录信息
|
||||
IMLoginModel model = GsonUtils.fromJson(info[0], IMLoginModel.class);
|
||||
IMLoginManager.get(activity).setupLoginUser(model);
|
||||
//融云连接服务器
|
||||
RongcloudIMManager.connectIM(activity);
|
||||
getBaseUserInfo();
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
private void getBaseUserInfo() {
|
||||
OTONetManager.getInstance(mContext).getBaseInfos(true, new com.yunbao.common.http.base.HttpCallback<com.shayu.onetoone.bean.UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(com.shayu.onetoone.bean.UserBean data) {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
if (data != null) {
|
||||
netHandler.post(getRandJoinAnchor);
|
||||
// EventBus.getDefault().post(new RegSuccessEvent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户自动签到
|
||||
*/
|
||||
private Runnable getRandJoinAnchor = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IMLoginModel userInfo = IMLoginManager.get(activity).getUserInfo();
|
||||
HttpClient.getInstance().post("Home.getRandJoinAnchor", "Home.getRandJoinAnchor").params("uid", userInfo.getId()).params("token", userInfo.getToken()).execute(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (info[0] != null) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
IMLoginManager.get(activity).setisNewUserOne(true);
|
||||
IMLoginManager.get(activity).setNewUserGif(true);
|
||||
if (obj.containsKey("home_zdy_img_us")) {
|
||||
home_zdy_img_us = obj.getString("home_zdy_img_us");
|
||||
home_zdy_img_cn = obj.getString("home_zdy_img_cn");
|
||||
}
|
||||
gotoLive(obj.getString("anchor_id"));
|
||||
if (obj.containsKey("home_zdy_pop")) {
|
||||
NoviceInstructorManager.get(mContext).setHomeZdyPop(obj.getString("home_zdy_pop"));
|
||||
}
|
||||
jumpMain(false);
|
||||
} else {
|
||||
jumpMain(false);
|
||||
}
|
||||
// EventBus.getDefault().post(new RegSuccessEvent());
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private void jumpMain(boolean showInvite) {
|
||||
RouteManager.forwardCompleteActivity();
|
||||
}
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
NoviceInstructorManager.get(mContext).setFrist(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
// MainActivity.forward(RegisterActivity.this, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onRegSuccessEvent(RegSuccessEvent e) {
|
||||
// finish();
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
// MainHttpUtil.cancel(MainHttpConsts.GET_REGISTER_CODE);
|
||||
// MainHttpUtil.cancel(MainHttpConsts.REGISTER);
|
||||
// MainHttpUtil.cancel(MainHttpConsts.LOGIN);
|
||||
// MainHttpUtil.cancel(MainHttpConsts.GET_BASE_INFO);
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mHandler = null;
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.shayu.onetoone.activity.login;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
|
||||
public class TagselectionActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_tagselection);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,520 @@
|
||||
package com.shayu.onetoone.activity.message;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import io.rong.callkit.util.CallRingingUtil;
|
||||
import io.rong.callkit.util.RingingMode;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
import com.lzf.easyfloat.enums.ShowPattern;
|
||||
import com.lzf.easyfloat.interfaces.OnFloatCallbacks;
|
||||
import com.lzf.easyfloat.interfaces.OnPermissionResult;
|
||||
import com.lzf.easyfloat.permission.PermissionUtils;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||
import com.shayu.onetoone.bean.FollowBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.dialog.GiftDialog;
|
||||
import com.shayu.onetoone.dialog.TipsDialog;
|
||||
import com.shayu.onetoone.dialog.TipsTextDialog;
|
||||
import com.shayu.onetoone.listener.OnCallStatusListener;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.manager.CallClientManager;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.ConversationUtils;
|
||||
import com.shayu.onetoone.utils.HtmlUrlUtils;
|
||||
import com.yunbao.common.activity.MyWalletActivity;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_CALL_AUDIO)
|
||||
public class CallAudioActivity extends AbsOTOActivity implements View.OnClickListener {
|
||||
private static final String TAG = "语音通话";
|
||||
private ImageView vague;
|
||||
private ImageView close;
|
||||
private ImageView avatar;
|
||||
private ImageView follow;
|
||||
private TextView userName;
|
||||
private TextView userInfo;
|
||||
private ImageView gift;
|
||||
private ImageView money;
|
||||
private ImageView callStop;
|
||||
private ImageView callMsg;
|
||||
private TextView callTime;
|
||||
private TextView tips;
|
||||
|
||||
private String targetId;
|
||||
private String callId;
|
||||
private String model;
|
||||
|
||||
|
||||
private OnCallStatusListener onCallStatusListener;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_call_audio;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
if (bundle == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
targetId = bundle.getString("targetId");
|
||||
callId = bundle.getString("callId");
|
||||
model = bundle.getString("model");
|
||||
initView();
|
||||
onCallStatusListener = new CallStatusListener();
|
||||
CallClientManager.getManager().addOnVoIPCallListener(CallAudioActivity.class, onCallStatusListener);
|
||||
initTargetData();
|
||||
if (model.equals(CallClientManager.VIDEO_FLOAT)) {
|
||||
EasyFloat.dismiss("call");
|
||||
callMsg.setTag(true);
|
||||
callMsg.setImageResource(R.mipmap.ic_call_audio_msg);
|
||||
gift.setVisibility(View.VISIBLE);
|
||||
money.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (!com.blankj.utilcode.util.PermissionUtils.isGranted(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO)) {
|
||||
com.blankj.utilcode.util.PermissionUtils.permission(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO).callback(new com.blankj.utilcode.util.PermissionUtils.SimpleCallback() {
|
||||
@Override
|
||||
public void onGranted() {
|
||||
if (model.equals(CallClientManager.AUDIO_CALL)) {
|
||||
CallClientManager.getManager().callAudio(targetId);
|
||||
callMsg.setTag(true);
|
||||
callMsg.setImageResource(R.mipmap.ic_call_audio_msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDenied() {
|
||||
finish();
|
||||
}
|
||||
}).request();
|
||||
return;
|
||||
}
|
||||
if (model.equals(CallClientManager.AUDIO_CALL)) {
|
||||
CallClientManager.getManager().callAudio(targetId);
|
||||
callMsg.setTag(true);
|
||||
callMsg.setImageResource(R.mipmap.ic_call_audio_msg);
|
||||
CallRingingUtil.getInstance().startRinging(this, RingingMode.Outgoing);
|
||||
}else if(model.equals(CallClientManager.AUDIO_RECEIVED_CALL)){
|
||||
CallRingingUtil.getInstance().startRinging(this, RingingMode.Incoming);
|
||||
close.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if(!CallClientManager.getManager().isCalling()) {
|
||||
EasyFloat.dismiss("call");
|
||||
}
|
||||
CallRingingUtil.getInstance().stopRinging();
|
||||
CallClientManager.getManager().removeOnVoIPCallListener(CallAudioActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
// 获取全局变量
|
||||
vague = findViewById(R.id.vague);
|
||||
close = findViewById(R.id.close);
|
||||
avatar = findViewById(R.id.avatar);
|
||||
follow = findViewById(R.id.follow);
|
||||
userName = findViewById(R.id.user_name);
|
||||
userInfo = findViewById(R.id.user_info);
|
||||
gift = findViewById(R.id.gift);
|
||||
money = findViewById(R.id.money);
|
||||
callStop = findViewById(R.id.call_stop);
|
||||
callMsg = findViewById(R.id.call_msg);
|
||||
callTime = findViewById(R.id.call_time);
|
||||
tips = findViewById(R.id.tips);
|
||||
|
||||
callMsg.setImageResource(io.rong.callkit.R.drawable.rc_voip_audio_answer_selector_new);
|
||||
|
||||
// 注册点击事件
|
||||
vague.setOnClickListener(this);
|
||||
close.setOnClickListener(this);
|
||||
avatar.setOnClickListener(this);
|
||||
follow.setOnClickListener(this);
|
||||
userName.setOnClickListener(this);
|
||||
userInfo.setOnClickListener(this);
|
||||
gift.setOnClickListener(this);
|
||||
money.setOnClickListener(this);
|
||||
callStop.setOnClickListener(this);
|
||||
callMsg.setOnClickListener(this);
|
||||
callTime.setOnClickListener(this);
|
||||
|
||||
gift.setVisibility(View.INVISIBLE);
|
||||
money.setVisibility(View.INVISIBLE);
|
||||
|
||||
}
|
||||
|
||||
UserBean userData;
|
||||
|
||||
private void initTargetData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getTargetUserInfo(Integer.parseInt(targetId), new HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
userData = data;
|
||||
userName.setText(data.getUser().getUserNicename());
|
||||
userInfo.setText(data.getUser().getSignature());
|
||||
ImgLoader.display(mContext, data.getUser().getAvatar(), avatar);
|
||||
ImgLoader.displayBlur(mContext, data.getUser().getAvatar(), vague, 85);
|
||||
if (data.getUser().isFollow()) {
|
||||
follow.setVisibility(View.GONE);
|
||||
} else {
|
||||
follow.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void accept() {
|
||||
close.setVisibility(View.VISIBLE);
|
||||
CallClientManager.getManager().acceptCall(targetId);
|
||||
}
|
||||
|
||||
private void stop() {
|
||||
CallClientManager.getManager().endCall();
|
||||
}
|
||||
|
||||
private void showGift() {
|
||||
new GiftDialog(mContext)
|
||||
.setTargetId(targetId)
|
||||
.showDialog();
|
||||
}
|
||||
|
||||
private void follow() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.follow(targetId, new HttpCallback<FollowBean>() {
|
||||
@Override
|
||||
public void onSuccess(FollowBean data) {
|
||||
ToastUtil.show(WordUtil.getNewString(R.string.system_tip_success));
|
||||
follow.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (model.equals(CallClientManager.AUDIO_FLOAT)) {
|
||||
EasyFloat.getFloatView("call").setOnClickListener(null);
|
||||
//((ViewGroup) EasyFloat.getFloatView("call").getParent()).removeAllViews();
|
||||
EasyFloat.dismiss("call");
|
||||
String sessionId = CallClientManager.getManager().getSessionId();
|
||||
if (!CallClientManager.getManager().isCalling()) {
|
||||
model = CallClientManager.AUDIO_CALL;
|
||||
gift.setVisibility(View.INVISIBLE);
|
||||
money.setVisibility(View.INVISIBLE);
|
||||
callMsg.setImageResource(R.mipmap.ic_call_audio_msg);
|
||||
return;
|
||||
}
|
||||
if (sessionId.equals(targetId)) {
|
||||
gift.setVisibility(View.INVISIBLE);
|
||||
money.setVisibility(View.INVISIBLE);
|
||||
model = CallClientManager.AUDIO_RECEIVED_CALL;
|
||||
} else {
|
||||
gift.setVisibility(View.VISIBLE);
|
||||
money.setVisibility(View.VISIBLE);
|
||||
model = CallClientManager.AUDIO_CALL;
|
||||
}
|
||||
callMsg.setImageResource(R.mipmap.ic_call_audio_msg);
|
||||
callMsg.setTag(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void showWindow(boolean toChatView, boolean toPay) {
|
||||
if(!CallClientManager.getManager().isCalling()){
|
||||
return;
|
||||
}
|
||||
if (!PermissionUtils.checkPermission(this)) {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.permission_hint))
|
||||
.setApplyText(WordUtil.getNewString(R.string.permission_setting))
|
||||
.setCancelText(WordUtil.getNewString(R.string.permission_cancel))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
PermissionUtils.requestPermission(CallAudioActivity.this, new OnPermissionResult() {
|
||||
@Override
|
||||
public void permissionResult(boolean b) {
|
||||
if (b) {
|
||||
showWindow(toChatView, toPay);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
.showDialog();
|
||||
return;
|
||||
}
|
||||
ImageView icon = new ImageView(mContext);
|
||||
icon.setTag(getIntent().getExtras());
|
||||
icon.setImageResource(io.rong.callkit.R.drawable.rc_voip_audio_answer_selector_new);
|
||||
icon.setLayoutParams(new ViewGroup.LayoutParams(DpUtil.dp2px(40), DpUtil.dp2px(40)));
|
||||
EasyFloat.with(this)
|
||||
.setLayout(icon)
|
||||
.setShowPattern(ShowPattern.ALL_TIME)
|
||||
.setTag("call")
|
||||
.setDragEnable(true)
|
||||
.setBorder()
|
||||
.registerCallbacks(new OnFloatCallbacks() {
|
||||
OnCallStatusListener windowListener;
|
||||
|
||||
@Override
|
||||
public void createdResult(boolean b, @Nullable String s, @Nullable View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(@NonNull View view) {
|
||||
ViewClicksAntiShake.clicksAntiShake(view, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
Bundle bundle = (Bundle) view.getTag();
|
||||
bundle.putString("model", CallClientManager.AUDIO_FLOAT);
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_CALL_AUDIO, bundle);
|
||||
}
|
||||
});
|
||||
windowListener = new WindowCallStatusListener();
|
||||
CallClientManager.getManager().addOnVoIPCallListener(EasyFloat.class, windowListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide(@NonNull View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
CallClientManager.getManager().removeOnVoIPCallListener(EasyFloat.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void touchEvent(@NonNull View view, @NonNull MotionEvent motionEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drag(@NonNull View view, @NonNull MotionEvent motionEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragEnd(@NonNull View view) {
|
||||
|
||||
}
|
||||
}).show();
|
||||
finish();
|
||||
if (toPay) {
|
||||
Log.e(TAG, "调起支付界面");
|
||||
// RouteManager.forwardWebViewActivity(null, HtmlUrlUtils.getPayUrl(mContext,false,HtmlUrlUtils.URL_PAY_COIN));
|
||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1));
|
||||
}
|
||||
if (toChatView) {
|
||||
ConversationUtils.startConversation(mContext, targetId);
|
||||
}
|
||||
}
|
||||
|
||||
private class CallStatusListener extends OnCallStatusListener {
|
||||
String sessionId;
|
||||
|
||||
@Override
|
||||
public void onCallWait(SurfaceView surfaceView) {
|
||||
tips.setVisibility(View.VISIBLE);
|
||||
tips.setText(R.string.call_tips1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallStart(String userId, SurfaceView surfaceView) {
|
||||
CallRingingUtil.getInstance().stopRinging();
|
||||
if (model.equals(CallClientManager.AUDIO_RECEIVED_CALL)) {
|
||||
gift.setVisibility(View.INVISIBLE);
|
||||
money.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
gift.setVisibility(View.VISIBLE);
|
||||
money.setVisibility(View.VISIBLE);
|
||||
}
|
||||
tips.setText(R.string.call_tips2);
|
||||
tips.postDelayed(() -> {
|
||||
tips.setVisibility(View.GONE);
|
||||
}, 1000);
|
||||
sessionId = CallClientManager.getManager().getSessionId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallEnd() {
|
||||
if (sessionId != null && !sessionId.equals(targetId)) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("model", CallClientManager.AUDIO_CALL);
|
||||
bundle.putString("targetId", targetId);
|
||||
bundle.putString("callId", targetId);
|
||||
bundle.putString("user", JSONObject.toJSONString(userData));
|
||||
bundle.putString("time", callTime.getText().toString());
|
||||
bundle.putString("path", RouteManager.ACTIVITY_CALL_AUDIO);
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_END_CALL, bundle);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartFirstFrame() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTime(String time) {
|
||||
super.onTime(time);
|
||||
callTime.setText(WordUtil.getNewString(R.string.call_time) + "" + time);
|
||||
}
|
||||
|
||||
|
||||
private BasePopupView tipsView = null;
|
||||
private TipsTextDialog tipsDialog;
|
||||
|
||||
@Override
|
||||
public void onTimeWarning(long msg) {
|
||||
super.onTimeWarning(msg);
|
||||
Log.i(TAG, "通话时间:" + msg);
|
||||
if (tipsView == null) {
|
||||
createShow(msg);
|
||||
} else {
|
||||
if (msg <= 0) {
|
||||
Log.i(TAG, "时间不够,挂断");
|
||||
CallClientManager.getManager().endCall();
|
||||
return;
|
||||
}
|
||||
tipsDialog.updateTips(String.format(WordUtil.getNewString(R.string.call_tips), msg));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void createShow(long msg) {
|
||||
if (model.equals(CallClientManager.AUDIO_RECEIVED_CALL) || model.equals(CallClientManager.VIDEO_RECEIVED_CALL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg <= 0) {
|
||||
Log.i(TAG, "时间不够,挂断");
|
||||
CallClientManager.getManager().endCall();
|
||||
return;
|
||||
}
|
||||
tipsDialog = new TipsTextDialog(mContext)
|
||||
.setTips(String.format(WordUtil.getNewString(R.string.call_tips), msg))
|
||||
.setOnItemClickListener(new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onItemClick(String bean, int position) {
|
||||
|
||||
}
|
||||
});
|
||||
tipsView = new XPopup.Builder(mContext)
|
||||
.atView(money)
|
||||
.hasShadowBg(false)
|
||||
.isDestroyOnDismiss(true)
|
||||
.isTouchThrough(true)
|
||||
.isClickThrough(true)
|
||||
.dismissOnBackPressed(false)
|
||||
.dismissOnTouchOutside(false)
|
||||
.asCustom(tipsDialog)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
private static class WindowCallStatusListener extends OnCallStatusListener {
|
||||
@Override
|
||||
public void onCallWait(SurfaceView surfaceView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallStart(String userId, SurfaceView surfaceView) {
|
||||
CallRingingUtil.getInstance().stopRinging();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallEnd() {
|
||||
EasyFloat.dismiss("call");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartFirstFrame() {
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (!EasyFloat.isShow("call")) {
|
||||
showWindow(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.call_msg) {
|
||||
if (v.getTag() == null) {
|
||||
accept();
|
||||
v.setTag(true);
|
||||
callMsg.setImageResource(R.mipmap.ic_call_audio_msg);
|
||||
} else {
|
||||
showWindow(true, false);
|
||||
}
|
||||
} else if (id == R.id.call_stop) {
|
||||
stop();
|
||||
} else if (id == R.id.gift) {
|
||||
showGift();
|
||||
} else if (id == R.id.close) {
|
||||
showWindow(false, false);
|
||||
} else if (id == R.id.follow) {
|
||||
follow();
|
||||
} else if (id == R.id.money) {
|
||||
showWindow(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,728 @@
|
||||
package com.shayu.onetoone.activity.message;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
import com.lzf.easyfloat.enums.ShowPattern;
|
||||
import com.lzf.easyfloat.interfaces.OnFloatCallbacks;
|
||||
import com.lzf.easyfloat.interfaces.OnPermissionResult;
|
||||
import com.lzf.easyfloat.permission.PermissionUtils;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||
import com.shayu.onetoone.bean.FollowBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.dialog.GiftDialog;
|
||||
import com.shayu.onetoone.dialog.TipsDialog;
|
||||
import com.shayu.onetoone.dialog.TipsTextDialog;
|
||||
import com.shayu.onetoone.listener.OnCallStatusListener;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.manager.CallClientManager;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.ConversationUtils;
|
||||
import com.shayu.onetoone.utils.HtmlUrlUtils;
|
||||
import com.yunbao.common.activity.MyWalletActivity;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.rong.callkit.util.CallRingingUtil;
|
||||
import io.rong.callkit.util.RingingMode;
|
||||
import io.rong.calllib.RongCallClient;
|
||||
import io.rong.calllib.StartIncomingPreviewCallback;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_CALL_VIDEO)
|
||||
public class CallVideoActivity extends AbsOTOActivity {
|
||||
private static final String TAG = "视频通话";
|
||||
|
||||
private ViewGroup myView;
|
||||
private ViewGroup targetView;
|
||||
private ViewGroup callLayout;
|
||||
private View callWaitLayout;
|
||||
private ViewGroup rootView;
|
||||
private View buttonView;
|
||||
private ImageView callStop;
|
||||
private ImageView gift;
|
||||
private ImageView message;
|
||||
private ImageView cameraCloseSwitch;
|
||||
private ImageView cameraSwitch;
|
||||
private ImageView micSwitch;
|
||||
private ImageView money;
|
||||
private RoundedImageView avatar;
|
||||
private ImageView close;
|
||||
private ImageView follow;
|
||||
private TextView followText;
|
||||
private TextView callTime;
|
||||
private TextView tips;
|
||||
private ImageView closeWait;
|
||||
|
||||
private OnCallStatusListener onCallStatusListener;
|
||||
|
||||
private String targetId;
|
||||
private String sessionId;
|
||||
private String callId;
|
||||
private String model;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_call_video;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onCreate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
initView();
|
||||
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
if (bundle == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
targetId = bundle.getString("targetId");
|
||||
callId = bundle.getString("callId");
|
||||
model = bundle.getString("model");
|
||||
|
||||
onCallStatusListener = new CallStatusListener();
|
||||
CallClientManager.getManager().addOnVoIPCallListener(CallVideoActivity.class, onCallStatusListener);
|
||||
|
||||
if (!model.equals(CallClientManager.VIDEO_FLOAT)) {
|
||||
RongCallClient.getInstance()
|
||||
.startIncomingPreview(
|
||||
new StartIncomingPreviewCallback() {
|
||||
@Override
|
||||
public void onDone(boolean isFront, SurfaceView localVideo) {
|
||||
myView.removeAllViews();
|
||||
myView.addView(localVideo);
|
||||
callLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int errorCode) {
|
||||
}
|
||||
});
|
||||
}
|
||||
initButton(buttonView);
|
||||
if (!com.blankj.utilcode.util.PermissionUtils.isGranted(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO)) {
|
||||
com.blankj.utilcode.util.PermissionUtils.permission(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO).callback(new com.blankj.utilcode.util.PermissionUtils.SimpleCallback() {
|
||||
@Override
|
||||
public void onGranted() {
|
||||
if (!StringUtil.isEmpty(targetId)) {
|
||||
CallClientManager.getManager().callVideo(targetId);
|
||||
initWaitView();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDenied() {
|
||||
finish();
|
||||
}
|
||||
}).request();
|
||||
return;
|
||||
}
|
||||
if (!StringUtil.isEmpty(targetId)) {
|
||||
CallClientManager.getManager().callVideo(targetId);
|
||||
initWaitView();
|
||||
}
|
||||
if (model.equals(CallClientManager.VIDEO_RECEIVED_CALL)) {
|
||||
CallRingingUtil.getInstance().startRinging(this, RingingMode.Incoming);
|
||||
close.setVisibility(View.GONE);
|
||||
} else if (model.equals(CallClientManager.VIDEO_CALL)) {
|
||||
CallRingingUtil.getInstance().startRinging(this, RingingMode.Outgoing);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (model.equals(CallClientManager.VIDEO_FLOAT)) {
|
||||
callLayout.setVisibility(View.GONE);
|
||||
EasyFloat.getFloatView("call").setOnClickListener(null);
|
||||
//((ViewGroup) EasyFloat.getFloatView("call").getParent()).removeAllViews();
|
||||
EasyFloat.dismiss("call");
|
||||
myView.removeAllViews();
|
||||
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(() -> {
|
||||
SurfaceView localVideo = CallClientManager.getManager().getLocalVideo();
|
||||
SurfaceView surfaceView = CallClientManager.getManager().getRemoteVideo();
|
||||
if (localVideo.getParent() != null) {
|
||||
((ViewGroup) localVideo.getParent()).removeAllViews();
|
||||
}
|
||||
if (surfaceView != null) {
|
||||
surfaceView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
|
||||
}
|
||||
localVideo.setLayoutParams(new ViewGroup.LayoutParams(DpUtil.dp2px(114), DpUtil.dp2px(164)));
|
||||
initView();
|
||||
initButton(buttonView);
|
||||
if (surfaceView == null) {
|
||||
localVideo.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
|
||||
localVideo.setZOrderOnTop(false);
|
||||
localVideo.setZOrderMediaOverlay(false);
|
||||
myView.addView(localVideo);
|
||||
initWaitView();
|
||||
myView.addView(callWaitLayout);
|
||||
} else {
|
||||
if (surfaceView.getParent() != null) {
|
||||
((ViewGroup) surfaceView.getParent()).removeAllViews();
|
||||
}
|
||||
myView.addView(surfaceView);
|
||||
myView.addView(buttonView);
|
||||
localVideo.setZOrderOnTop(true);
|
||||
localVideo.setZOrderMediaOverlay(true);
|
||||
localVideo.setOnClickListener(new VideoViewClick());
|
||||
targetView.addView(localVideo);
|
||||
closeWait.setVisibility(View.GONE);
|
||||
}
|
||||
initTargetData();
|
||||
sessionId = CallClientManager.getManager().getSessionId();
|
||||
if (sessionId.equals(targetId)) {
|
||||
gift.setVisibility(View.INVISIBLE);
|
||||
money.setVisibility(View.INVISIBLE);
|
||||
model = CallClientManager.VIDEO_RECEIVED_CALL;
|
||||
} else {
|
||||
model = CallClientManager.VIDEO_CALL;
|
||||
}
|
||||
}, 300);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
rootView = findViewById(R.id.rootView);
|
||||
myView = findViewById(R.id.my_view);
|
||||
callLayout = findViewById(R.id.rc_voip_two_btn);
|
||||
buttonView = LayoutInflater.from(mContext).inflate(R.layout.view_call_video_item, rootView, false);
|
||||
callWaitLayout = LayoutInflater.from(mContext).inflate(R.layout.view_call_video_wait, rootView, false);
|
||||
targetView = buttonView.findViewById(R.id.target_view);
|
||||
tips = findViewById(R.id.tips);
|
||||
closeWait = findViewById(R.id.close1);
|
||||
targetView.setBackgroundColor(Color.YELLOW);
|
||||
targetView.setOnClickListener(new VideoViewClick());
|
||||
}
|
||||
|
||||
private boolean isSwitchView = false;
|
||||
|
||||
private class VideoViewClick implements View.OnClickListener {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
/* myView.removeAllViews();
|
||||
targetView.removeAllViews();*/
|
||||
ViewGroup parent1 = (ViewGroup) CallClientManager.getManager().getLocalVideo().getParent();
|
||||
ViewGroup parent2 = (ViewGroup) CallClientManager.getManager().getRemoteVideo().getParent();
|
||||
if (parent1 != null) {
|
||||
parent1.removeAllViews();
|
||||
}
|
||||
if (parent2 != null) {
|
||||
parent2.removeAllViews();
|
||||
}
|
||||
if (isSwitchView) {
|
||||
targetView.addView(CallClientManager.getManager().getLocalVideo());
|
||||
CallClientManager.getManager().getLocalVideo().setZOrderOnTop(true);
|
||||
CallClientManager.getManager().getLocalVideo().setZOrderMediaOverlay(true);
|
||||
CallClientManager.getManager().getRemoteVideo().setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
|
||||
myView.addView(CallClientManager.getManager().getRemoteVideo());
|
||||
CallClientManager.getManager().getRemoteVideo().setZOrderOnTop(false);
|
||||
CallClientManager.getManager().getRemoteVideo().setZOrderMediaOverlay(false);
|
||||
myView.addView(buttonView);
|
||||
isSwitchView = false;
|
||||
CallClientManager.getManager().getLocalVideo().setOnClickListener(new VideoViewClick());
|
||||
CallClientManager.getManager().getRemoteVideo().setOnClickListener(null);
|
||||
} else {
|
||||
ImageView imageView = new ImageView(mContext);
|
||||
imageView.setImageResource(R.mipmap.bg_message_msg_title_heartbeat);
|
||||
CallClientManager.getManager().getLocalVideo().setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
|
||||
myView.addView(CallClientManager.getManager().getLocalVideo());
|
||||
CallClientManager.getManager().getLocalVideo().setZOrderOnTop(false);
|
||||
CallClientManager.getManager().getLocalVideo().setZOrderMediaOverlay(false);
|
||||
myView.addView(buttonView);
|
||||
targetView.addView(imageView);
|
||||
targetView.addView(CallClientManager.getManager().getRemoteVideo());
|
||||
CallClientManager.getManager().getRemoteVideo().setZOrderOnTop(true);
|
||||
CallClientManager.getManager().getRemoteVideo().setZOrderMediaOverlay(true);
|
||||
isSwitchView = true;
|
||||
CallClientManager.getManager().getRemoteVideo().setOnClickListener(new VideoViewClick());
|
||||
CallClientManager.getManager().getLocalVideo().setOnClickListener(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initWaitView() {
|
||||
callLayout.setVisibility(View.GONE);
|
||||
callStop = callWaitLayout.findViewById(R.id.call_stop);
|
||||
cameraCloseSwitch = callWaitLayout.findViewById(R.id.camera_close_switch);
|
||||
cameraSwitch = callWaitLayout.findViewById(R.id.camera_switch);
|
||||
micSwitch = callWaitLayout.findViewById(R.id.mic_switch);
|
||||
close = callWaitLayout.findViewById(R.id.close);
|
||||
callStop.setOnClickListener(onClickListener);
|
||||
cameraCloseSwitch.setOnClickListener(onClickListener);
|
||||
cameraSwitch.setOnClickListener(onClickListener);
|
||||
micSwitch.setOnClickListener(onClickListener);
|
||||
close.setOnClickListener(onClickListener);
|
||||
}
|
||||
|
||||
private void initButton(View itemView) {
|
||||
callStop = itemView.findViewById(R.id.call_stop);
|
||||
gift = itemView.findViewById(R.id.gift);
|
||||
message = itemView.findViewById(R.id.message);
|
||||
cameraCloseSwitch = itemView.findViewById(R.id.camera_close_switch);
|
||||
cameraSwitch = itemView.findViewById(R.id.camera_switch);
|
||||
micSwitch = itemView.findViewById(R.id.mic_switch);
|
||||
money = itemView.findViewById(R.id.money);
|
||||
avatar = itemView.findViewById(R.id.avatar);
|
||||
close = itemView.findViewById(R.id.close);
|
||||
follow = itemView.findViewById(R.id.follow);
|
||||
followText = itemView.findViewById(R.id.follow_text);
|
||||
callTime = itemView.findViewById(R.id.call_time);
|
||||
// 为所有View设置点击事件监听器
|
||||
setClickListeners();
|
||||
|
||||
if (model.equals(CallClientManager.VIDEO_RECEIVED_CALL)) {
|
||||
gift.setVisibility(View.INVISIBLE);
|
||||
money.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setClickListeners() {
|
||||
// 为所有ImageView设置点击事件监听器
|
||||
callStop.setOnClickListener(onClickListener);
|
||||
gift.setOnClickListener(onClickListener);
|
||||
message.setOnClickListener(onClickListener);
|
||||
cameraCloseSwitch.setOnClickListener(onClickListener);
|
||||
cameraSwitch.setOnClickListener(onClickListener);
|
||||
micSwitch.setOnClickListener(onClickListener);
|
||||
money.setOnClickListener(onClickListener);
|
||||
|
||||
// 为其他View设置点击事件监听器
|
||||
avatar.setOnClickListener(onClickListener);
|
||||
close.setOnClickListener(onClickListener);
|
||||
closeWait.setOnClickListener(onClickListener);
|
||||
follow.setOnClickListener(onClickListener);
|
||||
findViewById(R.id.rc_voip_call_answer_btn).setOnClickListener(onClickListener);
|
||||
findViewById(R.id.rc_voip_call_hang_up).setOnClickListener(onClickListener);
|
||||
}
|
||||
|
||||
private void accept() {
|
||||
callLayout.setVisibility(View.GONE);
|
||||
close.setVisibility(View.VISIBLE);
|
||||
CallClientManager.getManager().acceptCall(callId);
|
||||
}
|
||||
|
||||
private void closeCamera() {
|
||||
RongCallClient.getInstance().setEnableLocalVideo(!RongCallClient.getInstance().isLocalVideoEnabled());
|
||||
cameraCloseSwitch.setImageResource(RongCallClient.getInstance().isLocalVideoEnabled() ? R.mipmap.ic_call_video_select : R.mipmap.ic_call_video);
|
||||
if (RongCallClient.getInstance().isLocalVideoEnabled()) {
|
||||
targetView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
targetView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void switchCamera() {
|
||||
RongCallClient.getInstance().switchCamera();
|
||||
}
|
||||
|
||||
private void switchAudio() {
|
||||
boolean enabled = RongCallClient.getInstance().isLocalAudioEnabled();
|
||||
RongCallClient.getInstance().setEnableLocalAudio(!enabled);
|
||||
micSwitch.setImageResource(!enabled ? R.mipmap.ic_call_audio_select : R.mipmap.ic_call_audio);
|
||||
}
|
||||
|
||||
private void showWindow(boolean toChatView, boolean toPay) {
|
||||
if(!CallClientManager.getManager().isCalling()){
|
||||
return;
|
||||
}
|
||||
if (!PermissionUtils.checkPermission(this)) {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.permission_hint))
|
||||
.setApplyText(WordUtil.getNewString(R.string.permission_setting))
|
||||
.setCancelText(WordUtil.getNewString(R.string.permission_cancel))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
PermissionUtils.requestPermission(CallVideoActivity.this, new OnPermissionResult() {
|
||||
@Override
|
||||
public void permissionResult(boolean b) {
|
||||
if (b) {
|
||||
showWindow(toChatView, toPay);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
.showDialog();
|
||||
return;
|
||||
}
|
||||
myView.removeAllViews();
|
||||
targetView.removeAllViews();
|
||||
finish();
|
||||
SurfaceView floatWindows;
|
||||
if (CallClientManager.getManager().getRemoteVideo() == null) {
|
||||
/* floatWindows=new ImageView(mContext);
|
||||
((ImageView)floatWindows).setImageResource(io.rong.callkit.R.drawable.rc_voip_vedio_answer_selector_new);*/
|
||||
CallClientManager.getManager().getLocalVideo().setLayoutParams(new ViewGroup.LayoutParams(DpUtil.dp2px(114), DpUtil.dp2px(164)));
|
||||
floatWindows = CallClientManager.getManager().getLocalVideo();
|
||||
} else {
|
||||
CallClientManager.getManager().getRemoteVideo().setLayoutParams(new ViewGroup.LayoutParams(DpUtil.dp2px(114), DpUtil.dp2px(164)));
|
||||
floatWindows = CallClientManager.getManager().getRemoteVideo();
|
||||
}
|
||||
floatWindows.setTag(getIntent().getExtras());
|
||||
EasyFloat.with(this)
|
||||
.setLayout(floatWindows)
|
||||
.setShowPattern(ShowPattern.ALL_TIME)
|
||||
.setTag("call")
|
||||
.setDragEnable(true)
|
||||
.setBorder()
|
||||
.registerCallbacks(new OnFloatCallbacks() {
|
||||
OnCallStatusListener windowListener;
|
||||
|
||||
@Override
|
||||
public void createdResult(boolean b, @Nullable String s, @Nullable View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(@NonNull View view) {
|
||||
ViewClicksAntiShake.clicksAntiShake(view, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
Bundle bundle = (Bundle) view.getTag();
|
||||
bundle.putString("model", CallClientManager.VIDEO_FLOAT);
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_CALL_VIDEO, bundle);
|
||||
}
|
||||
});
|
||||
windowListener = new WindowCallStatusListener(view);
|
||||
CallClientManager.getManager().addOnVoIPCallListener(EasyFloat.class, windowListener);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide(@NonNull View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
CallClientManager.getManager().removeOnVoIPCallListener(EasyFloat.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void touchEvent(@NonNull View view, @NonNull MotionEvent motionEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drag(@NonNull View view, @NonNull MotionEvent motionEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragEnd(@NonNull View view) {
|
||||
|
||||
}
|
||||
}).show();
|
||||
if (toPay) {
|
||||
// RouteManager.forwardWebViewActivity(null, HtmlUrlUtils.getPayUrl(mContext, false, HtmlUrlUtils.URL_PAY_COIN));
|
||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1));
|
||||
}
|
||||
if (toChatView) {
|
||||
ConversationUtils.startConversation(mContext, targetId);
|
||||
}
|
||||
}
|
||||
|
||||
UserBean userData;
|
||||
|
||||
private void initTargetData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getTargetUserInfo(Integer.parseInt(targetId), new HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
ImgLoader.display(mContext, data.getUser().getAvatar(), avatar);
|
||||
userData = data;
|
||||
if (data.getUser().isFollow()) {
|
||||
follow.setVisibility(View.GONE);
|
||||
} else {
|
||||
follow.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void follow() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.follow(targetId, new HttpCallback<FollowBean>() {
|
||||
@Override
|
||||
public void onSuccess(FollowBean data) {
|
||||
ToastUtil.show(WordUtil.getNewString(R.string.system_tip_success));
|
||||
follow.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private final View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// 在这里编写点击事件的处理逻辑
|
||||
int id = v.getId();
|
||||
if (id == R.id.rc_voip_call_answer_btn) {
|
||||
accept();
|
||||
} else if (id == R.id.call_stop || id == R.id.rc_voip_call_hang_up) {
|
||||
CallRingingUtil.getInstance().stopRinging();
|
||||
CallClientManager.getManager().endCall();
|
||||
} else if (id == R.id.gift) {
|
||||
new GiftDialog(mContext)
|
||||
.setTargetId(targetId)
|
||||
.showDialog();
|
||||
} else if (id == R.id.camera_close_switch) {
|
||||
closeCamera();
|
||||
} else if (id == R.id.camera_switch) {
|
||||
switchCamera();
|
||||
} else if (id == R.id.mic_switch) {
|
||||
switchAudio();
|
||||
} else if (id == R.id.close || id == R.id.close1) {
|
||||
showWindow(false, false);
|
||||
} else if (id == R.id.message) {
|
||||
showWindow(true, false);
|
||||
} else if (id == R.id.follow) {
|
||||
follow();
|
||||
} else if (id == R.id.money) {
|
||||
showWindow(false, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private class CallStatusListener extends OnCallStatusListener {
|
||||
@Override
|
||||
public void onCallWait(SurfaceView surfaceView) {
|
||||
myView.removeAllViews();
|
||||
myView.addView(CallClientManager.getManager().getLocalVideo());
|
||||
if (model.equals(CallClientManager.VIDEO_CALL)) {
|
||||
myView.addView(callWaitLayout);
|
||||
}
|
||||
tips.setVisibility(View.VISIBLE);
|
||||
tips.setText(R.string.call_tips1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallStart(String userId, SurfaceView surfaceView) {
|
||||
CallRingingUtil.getInstance().stopRinging();
|
||||
closeWait.setVisibility(View.GONE);
|
||||
initView();
|
||||
initButton(buttonView);
|
||||
initTargetData();
|
||||
surfaceView.setZOrderOnTop(false);
|
||||
surfaceView.setZOrderMediaOverlay(false);
|
||||
surfaceView.invalidate();
|
||||
surfaceView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
|
||||
surfaceView.setOnClickListener(v -> {
|
||||
surfaceView.setZOrderOnTop(false);
|
||||
surfaceView.setZOrderMediaOverlay(false);
|
||||
surfaceView.invalidate();
|
||||
});
|
||||
if (surfaceView.getParent() != null) {
|
||||
((ViewGroup) surfaceView.getParent()).removeAllViews();
|
||||
}
|
||||
if (CallClientManager.getManager().getLocalVideo().getParent() != null) {
|
||||
((ViewGroup) CallClientManager.getManager().getLocalVideo().getParent()).removeAllViews();
|
||||
}
|
||||
myView.addView(surfaceView);
|
||||
targetView.removeAllViews();
|
||||
targetView.addView(CallClientManager.getManager().getLocalVideo());
|
||||
CallClientManager.getManager().getLocalVideo().setOnClickListener(new VideoViewClick());
|
||||
myView.addView(buttonView);
|
||||
tips.setText(R.string.call_tips2);
|
||||
tips.postDelayed(() -> {
|
||||
tips.setVisibility(View.GONE);
|
||||
}, 1000);
|
||||
sessionId = CallClientManager.getManager().getSessionId();
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
public void onCallEnd() {
|
||||
if (sessionId != null && !sessionId.equals(targetId)) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("model", CallClientManager.VIDEO_CALL);
|
||||
bundle.putString("targetId", targetId);
|
||||
bundle.putString("callId", callId);
|
||||
bundle.putString("user", JSONObject.toJSONString(userData));
|
||||
bundle.putString("time", callTime.getText().toString());
|
||||
bundle.putString("path", RouteManager.ACTIVITY_CALL_VIDEO);
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_END_CALL, bundle);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartFirstFrame() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTime(String time) {
|
||||
super.onTime(time);
|
||||
if (callTime != null) {
|
||||
callTime.setText(WordUtil.getNewString(R.string.call_time) + "" + time);
|
||||
}
|
||||
}
|
||||
|
||||
private BasePopupView tipsView = null;
|
||||
private TipsTextDialog tipsDialog;
|
||||
|
||||
@Override
|
||||
public void onTimeWarning(long msg) {
|
||||
super.onTimeWarning(msg);
|
||||
Log.i(TAG, "通话时间:" + msg);
|
||||
if (tipsView == null) {
|
||||
createShow(msg);
|
||||
} else {
|
||||
if (msg <= 0) {
|
||||
Log.i(TAG, "时间不够,挂断");
|
||||
CallClientManager.getManager().endCall();
|
||||
return;
|
||||
}
|
||||
tipsDialog.updateTips(String.format(WordUtil.getNewString(R.string.call_tips), msg));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void createShow(long msg) {
|
||||
if (model.equals(CallClientManager.VIDEO_RECEIVED_CALL)) {
|
||||
return;
|
||||
}
|
||||
if (msg <= 0) {
|
||||
Log.i(TAG, "时间不够,挂断");
|
||||
CallClientManager.getManager().endCall();
|
||||
return;
|
||||
}
|
||||
tipsDialog = new TipsTextDialog(mContext)
|
||||
.setTips(String.format(WordUtil.getNewString(R.string.call_tips), msg))
|
||||
.setOnItemClickListener(new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onItemClick(String bean, int position) {
|
||||
|
||||
}
|
||||
});
|
||||
tipsView = new XPopup.Builder(mContext)
|
||||
.atView(money)
|
||||
.hasShadowBg(false)
|
||||
.isTouchThrough(true)
|
||||
.isDestroyOnDismiss(true)
|
||||
.isClickThrough(true)
|
||||
.dismissOnBackPressed(false)
|
||||
.dismissOnTouchOutside(false)
|
||||
.asCustom(tipsDialog)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
private static class WindowCallStatusListener extends OnCallStatusListener {
|
||||
View rootView;
|
||||
|
||||
public WindowCallStatusListener(View view) {
|
||||
this.rootView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallWait(SurfaceView surfaceView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallStart(String userId, SurfaceView surfaceView) {
|
||||
CallRingingUtil.getInstance().stopRinging();
|
||||
Object tag = rootView.getTag();
|
||||
ViewGroup parent = (ViewGroup) rootView.getParent();
|
||||
parent.removeView(rootView);
|
||||
if (surfaceView.getParent() != null) {
|
||||
((ViewGroup) surfaceView.getParent()).removeAllViews();
|
||||
}
|
||||
surfaceView.setLayoutParams(new ViewGroup.LayoutParams(DpUtil.dp2px(114), DpUtil.dp2px(164)));
|
||||
surfaceView.setTag(tag);
|
||||
surfaceView.setOnClickListener(v -> {
|
||||
Bundle bundle = (Bundle) v.getTag();
|
||||
bundle.putString("model", CallClientManager.VIDEO_FLOAT);
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_CALL_VIDEO, bundle);
|
||||
});
|
||||
parent.addView(surfaceView);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallEnd() {
|
||||
EasyFloat.dismiss("call");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartFirstFrame() {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if(!CallClientManager.getManager().isCalling()) {
|
||||
EasyFloat.dismiss("call");
|
||||
}
|
||||
CallClientManager.getManager().removeOnVoIPCallListener(CallVideoActivity.class);
|
||||
CallRingingUtil.getInstance().stopRinging();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (!EasyFloat.isShow("call")) {
|
||||
showWindow(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.shayu.onetoone.activity.message;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||
import com.shayu.onetoone.activity.fragments.message.ChatMessageFragment;
|
||||
import com.shayu.onetoone.activity.fragments.message.MessageInteractiveFragment;
|
||||
import com.shayu.onetoone.activity.fragments.message.MessageNoticeFragment;
|
||||
import com.shayu.onetoone.activity.fragments.message.SystemMessageFragment;
|
||||
import com.shayu.onetoone.bean.MessageChatTipsContent;
|
||||
import com.shayu.onetoone.bean.OfficialNoticeBean;
|
||||
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||
import com.shayu.onetoone.bean.SystemMessageBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.dialog.TipsDialog;
|
||||
import com.shayu.onetoone.event.MessageMsgBusEvent;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.conversation.ConversationFragment;
|
||||
import io.rong.imlib.IRongCallback;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
/**
|
||||
* 聊天界面
|
||||
*/
|
||||
@Route(path = RouteManager.ACTIVITY_MSG_CHAT)
|
||||
public class ChatActivity extends AbsOTOActivity {
|
||||
public final static int CALL_CHAT_TYPE_CHAT_UP = 0;//搭讪
|
||||
public final static int CALL_CHAT_TYPE_GIFT = 1;//打开【首次匹配弹窗】
|
||||
public final static int CALL_CHAT_TYPE_MATCH = 2;//匹配
|
||||
String targetId;
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_msg_chat;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onCreate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
int type = getIntent().getIntExtra("model", 0);
|
||||
ConversationFragment conversationFragment;
|
||||
if (type == 4) {
|
||||
conversationFragment = new SystemMessageFragment(getIntent().getStringExtra("data"));
|
||||
} else if (type == 1) {
|
||||
conversationFragment = new MessageNoticeFragment(getIntent().getStringExtra("data"));
|
||||
} else if (type == 2) {
|
||||
conversationFragment = new MessageInteractiveFragment(getIntent().getStringExtra("data"));
|
||||
} else {
|
||||
conversationFragment = new ChatMessageFragment();
|
||||
targetId = getIntent().getStringExtra("targetId");
|
||||
}
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.container, conversationFragment);
|
||||
transaction.commit();
|
||||
initChatUpData();
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
if (bundle != null) {
|
||||
int bundleInt = bundle.getInt("type", -1);
|
||||
String data = bundle.getString("data");
|
||||
SendConsumeBean bean = JSONObject.parseObject(data, SendConsumeBean.class);
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
if (bundleInt == CALL_CHAT_TYPE_GIFT || bundleInt == CALL_CHAT_TYPE_MATCH) {
|
||||
System.out.println("匹配數據:" + data);
|
||||
if (bean.getProp().getId() == 0) {
|
||||
return;
|
||||
}
|
||||
ImageView imageView = new ImageView(this);
|
||||
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.dialog_normal_title))
|
||||
.setContent(WordUtil.getNewString(R.string.dialog_normal_content) + bean.getProp().getCnTitle() + "*" + bean.getProp().getNum())
|
||||
.setContentView(imageView)
|
||||
.setApplyText(WordUtil.getNewString(R.string.dialog_call_prop_apply))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onCreateView(View itemView) {
|
||||
super.onCreateView(itemView);
|
||||
ImgLoader.display(ChatActivity.this, bean.getProp().getIcon(), (ImageView) itemView);
|
||||
}
|
||||
}).showDialog();
|
||||
} else if (bundleInt == CALL_CHAT_TYPE_CHAT_UP) {
|
||||
String token = bundle.getString("token", "");
|
||||
if (!StringUtil.isEmpty(bean.getAccostMsg())) {
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
TextMessage messageContent = TextMessage.obtain(bean.getAccostMsg());
|
||||
Message message = Message.obtain(targetId, conversationType, messageContent);
|
||||
IMCenter.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
|
||||
@Override
|
||||
public void onAttached(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
SendMessageManager.onCallSuccess(token, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initChatUpData() {//反正进来就获取又没有提示信息,有的话就发送,没有就不管,抛异常=发过了
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getChatTips(targetId, new HttpCallback<JSONObject>() {
|
||||
@Override
|
||||
public void onSuccess(JSONObject data) {
|
||||
try {
|
||||
String tips1 = data.getJSONObject("data").getJSONObject("info").getJSONObject("0").getString("cn");
|
||||
String tips2 = data.getJSONObject("data").getJSONObject("info").getJSONObject("1").getString("cn");
|
||||
String tips3 = data.getJSONObject("data").getJSONObject("info").getJSONObject("2").getString("cn");
|
||||
if (!StringUtil.isEmpty(tips1)) {
|
||||
MessageChatTipsContent.sendMessage(Conversation.ConversationType.PRIVATE, targetId, MessageChatTipsContent.obtain(tips1), null);
|
||||
}
|
||||
if (!StringUtil.isEmpty(tips2)) {
|
||||
MessageChatTipsContent.sendMessage(Conversation.ConversationType.PRIVATE, targetId, MessageChatTipsContent.obtain(tips2), null);
|
||||
}
|
||||
if (!StringUtil.isEmpty(tips3)) {
|
||||
MessageChatTipsContent.sendMessage(Conversation.ConversationType.PRIVATE, targetId, MessageChatTipsContent.obtain(tips3), null);
|
||||
}
|
||||
OTONetManager.getInstance(mContext)
|
||||
.updateChatTips(targetId, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//调用过了,不管
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package com.shayu.onetoone.activity.message;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||
import com.shayu.onetoone.adapter.MsgGreetConfigAdapter;
|
||||
import com.shayu.onetoone.bean.AvatarBean;
|
||||
import com.shayu.onetoone.bean.GreetBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 打招呼设置界面
|
||||
*/
|
||||
@Route(path = RouteManager.ACTIVITY_MSG_MORE_CONFIG_ACTIVITY)
|
||||
public class MsgMoreGreetConfigActivity extends AbsOTOActivity {
|
||||
List<GreetBean> deleteList = new ArrayList<>();
|
||||
RecyclerView recyclerView;
|
||||
MsgGreetConfigAdapter adapter;
|
||||
SwitchCompat msgSwitch;
|
||||
View add;
|
||||
View editLayout;
|
||||
Button cancel, apply;
|
||||
|
||||
ProcessImageUtil imageUtil;
|
||||
Dialog uploadImgDialog;
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_msg_config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
setTitle(WordUtil.getNewString(R.string.title_greet_config));
|
||||
uploadImgDialog=DialogUitl.loadingDialog(mContext);
|
||||
imageUtil = new ProcessImageUtil(this);
|
||||
recyclerView = findViewById(R.id.msg_recyclerView);
|
||||
msgSwitch = findViewById(R.id.msg_switch);
|
||||
add = findViewById(R.id.add_msg);
|
||||
cancel = findViewById(R.id.btn_cancel);
|
||||
apply = findViewById(R.id.btn_apply);
|
||||
editLayout = findViewById(R.id.edit_layout);
|
||||
|
||||
adapter = new MsgGreetConfigAdapter(this);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||
recyclerView.setAdapter(adapter);
|
||||
adapter.setDeleteListener((bean, position) -> {
|
||||
if (position >= 10) {
|
||||
add.setVisibility(View.GONE);
|
||||
} else {
|
||||
add.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (!StringUtil.isEmpty(bean.getId())) {
|
||||
deleteList.add(bean);
|
||||
}
|
||||
});
|
||||
add.setOnClickListener(v -> {
|
||||
adapter.addItem(new GreetBean());
|
||||
if (adapter.getItemCount() >= 10) {
|
||||
add.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
msgSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
editLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
OTONetManager.getInstance(mContext)
|
||||
.setGreetConfigGreet(isChecked, null);
|
||||
});
|
||||
apply.setOnClickListener(v -> {
|
||||
adapter.notifyDataSetChanged();
|
||||
new Handler(Looper.getMainLooper()).postDelayed(this::save, 100);
|
||||
});
|
||||
cancel.setOnClickListener(v -> clearGreet());
|
||||
recyclerView.setOnClickListener(v -> adapter.notifyDataSetChanged());
|
||||
findViewById(R.id.upload_img).setOnClickListener(v -> {
|
||||
imageUtil.getImageByAlumb(false);
|
||||
});
|
||||
initData();
|
||||
imageUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
@Override
|
||||
public void beforeCamera() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
uploadImgDialog.show();
|
||||
System.out.println("file = " + file.getAbsolutePath());
|
||||
System.out.println("file.exists() = " + file.exists());
|
||||
OTONetManager.getInstance(mContext)
|
||||
.updateFile(file, new HttpCallback<AvatarBean>() {
|
||||
@Override
|
||||
public void onSuccess(AvatarBean data) {
|
||||
System.out.println("头像地址:" + data.getAvatar());
|
||||
OTONetManager.getInstance(mContext)
|
||||
.addMessageMoreGreetConfig(data.getAvatar(), "2", new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel upload) {
|
||||
if (upload.getCode() == 0) {
|
||||
ImgLoader.display(mContext, data.getAvatar(), (ImageView) findViewById(R.id.imageView5));
|
||||
}
|
||||
uploadImgDialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
uploadImgDialog.dismiss();
|
||||
ToastUtil.showDebug(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
uploadImgDialog.dismiss();
|
||||
ToastUtil.showDebug(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void clearGreet() {
|
||||
adapter.clear();
|
||||
((ImageView)findViewById(R.id.imageView5)).setImageResource(R.mipmap.ic_msg_more_config_add_image);
|
||||
OTONetManager.getInstance(mContext)
|
||||
.cleanMoreGreetConfig(new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
ToastUtil.show(data.getMsg());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
// ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void save() {
|
||||
if (!msgSwitch.isChecked()) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
for (GreetBean bean : adapter.getNotEmptyList()) {
|
||||
if (StringUtil.isEmpty(bean.getId())) {
|
||||
addGreet(bean);
|
||||
} else if (bean.isEdit()) {
|
||||
editGreet(bean);
|
||||
}
|
||||
}
|
||||
for (GreetBean bean : deleteList) {
|
||||
OTONetManager.getInstance(mContext).removeMoreGreetConfig(bean.getId(), null);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
private void addGreet(GreetBean bean) {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.addMessageMoreGreetConfig(bean.getContent(), bean.getType() + "", null);
|
||||
}
|
||||
|
||||
private void editGreet(GreetBean bean) {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.setMoreGreetConfig(bean.getId(), bean.getContent(), bean.getType() + "", null);
|
||||
}
|
||||
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getMessageMoreGreetConfig(new HttpCallback<List<GreetBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<GreetBean> data) {
|
||||
List<GreetBean> list = new ArrayList<>();
|
||||
for (GreetBean item : data) {
|
||||
if (item.getType() == 0) {
|
||||
list.add(item);
|
||||
} else if (item.getType() == 2) {
|
||||
ImgLoader.display(mContext, item.getContent(), (ImageView) findViewById(R.id.imageView5));
|
||||
}
|
||||
}
|
||||
adapter.setList(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getGreetConfigStatus(new HttpCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean data) {
|
||||
msgSwitch.setChecked(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,476 @@
|
||||
package com.shayu.onetoone.activity.setting;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.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.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.BindPhoneEvent;
|
||||
import com.shayu.onetoone.utils.MainHttpConsts;
|
||||
import com.shayu.onetoone.utils.MainHttpUtil;
|
||||
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.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 綁定手機號
|
||||
*/
|
||||
public class BindUserActivity extends AbsActivity {
|
||||
|
||||
private LinearLayout lt_first_bind;
|
||||
private EditText mEditPhone;
|
||||
private EditText mEditCode;
|
||||
private EditText mEditPwd1;
|
||||
private EditText mEditPwd2;
|
||||
private TextView mBtnCode;
|
||||
private View mBtnRegister;
|
||||
private Handler mHandler;
|
||||
private static final int TOTAL = 60;
|
||||
private int mCount = TOTAL;
|
||||
private String mGetCode;
|
||||
private String mGetCodeAgain;
|
||||
private Dialog mDialog;
|
||||
private boolean mFirstLogin;//是否是第一次登录
|
||||
private boolean mShowInvite;
|
||||
private String mPromoCode = "";//推广码
|
||||
private String mUuidDevice = "";//手机唯一标识符
|
||||
private int mPhoneMinLength = 5;//输入手机号的最小位数
|
||||
private TextView mTvCountryCode;
|
||||
private int mCountryCode = 852;//国家代码
|
||||
private ImageView mIvCountryCode;
|
||||
private LinearLayout lt_now_bind, lt_give, lt_password, lt_password2;
|
||||
private TextView tv_now_phone, tv_title;
|
||||
private Button btn_goto_updata;
|
||||
private String isBind = "0", mobile = "";
|
||||
private WebView webview;
|
||||
private WebSettings webSettings;
|
||||
private ArrayList<Country> allCountries = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_bind_user;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
// setTitle(mContext.getString(R.string.reg_register));
|
||||
getPromoCode();
|
||||
webview = (WebView) findViewById(R.id.webview);
|
||||
lt_first_bind = (LinearLayout) findViewById(R.id.lt_first_bind);
|
||||
lt_password = findViewById(R.id.lt_password);
|
||||
lt_password2 = findViewById(R.id.lt_password2);
|
||||
mEditPhone = (EditText) findViewById(R.id.edit_phone);
|
||||
mTvCountryCode = findViewById(R.id.tvCountryCode);
|
||||
mIvCountryCode = findViewById(R.id.ivCountryCode);
|
||||
mEditCode = (EditText) findViewById(R.id.edit_code);
|
||||
mEditPwd1 = (EditText) findViewById(R.id.edit_pwd_1);
|
||||
mEditPwd2 = (EditText) findViewById(R.id.edit_pwd_2);
|
||||
mBtnCode = (TextView) findViewById(R.id.btn_code);
|
||||
mBtnRegister = findViewById(R.id.btn_register);
|
||||
|
||||
lt_now_bind = findViewById(R.id.lt_now_bind);
|
||||
lt_give = findViewById(R.id.lt_give);
|
||||
tv_now_phone = findViewById(R.id.tv_now_phone);
|
||||
btn_goto_updata = findViewById(R.id.btn_goto_updata);
|
||||
tv_title = findViewById(R.id.tv_title);
|
||||
|
||||
mGetCode = mContext.getString(R.string.reg_get_code);
|
||||
mGetCodeAgain = mContext.getString(R.string.reg_get_code_again);
|
||||
mTvCountryCodeClick();
|
||||
mEditPhone.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (!TextUtils.isEmpty(s) && s.length() >= mPhoneMinLength) {
|
||||
mBtnCode.setEnabled(true);
|
||||
} else {
|
||||
mBtnCode.setEnabled(false);
|
||||
}
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
TextWatcher textWatcher = new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
changeEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
};
|
||||
mEditCode.addTextChangedListener(textWatcher);
|
||||
mEditPwd1.addTextChangedListener(textWatcher);
|
||||
mEditPwd2.addTextChangedListener(textWatcher);
|
||||
mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
mCount--;
|
||||
if (mCount > 0) {
|
||||
mBtnCode.setText(mGetCodeAgain + "(" + mCount + "s)");
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessageDelayed(0, 1000);
|
||||
}
|
||||
} else {
|
||||
mBtnCode.setText(mGetCode);
|
||||
mCount = TOTAL;
|
||||
if (mBtnCode != null) {
|
||||
mBtnCode.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mDialog = DialogUitl.loadingDialog(mContext, getString(R.string.reg_register_ing));
|
||||
//EventBus.getDefault().register(this);
|
||||
|
||||
isBind = getIntent().getStringExtra("isBind");
|
||||
mobile = getIntent().getStringExtra("mobile");
|
||||
if ("1".equals(isBind)) {
|
||||
lt_now_bind.setVisibility(View.VISIBLE);
|
||||
lt_first_bind.setVisibility(View.GONE);
|
||||
tv_now_phone.setText(mobile);
|
||||
} else {
|
||||
lt_now_bind.setVisibility(View.GONE);
|
||||
lt_first_bind.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
webSettings = webview.getSettings();
|
||||
webSettings.setUseWideViewPort(true);
|
||||
webSettings.setLoadWithOverviewMode(true);
|
||||
// 禁用缓存
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||
webview.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
view.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
// 开启js支持
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webview.addJavascriptInterface(new JsBridge(), "jsBridge");
|
||||
// 也可以加载本地html(webView.loadUrl("file:///android_asset/xxx.html"))
|
||||
webview.loadUrl(CommonAppConfig.HOST + "/h5/live/TCaptcha.html");
|
||||
|
||||
allCountries.clear();
|
||||
allCountries.addAll(Country.getAll(mContext, null));
|
||||
|
||||
String ct = IMLoginManager.get(mContext).getString("sys_user_area");
|
||||
ct = TextUtils.equals("中国", ct) ? "中国香港" : ct;
|
||||
for (int i = 0; i < allCountries.size(); i++) {
|
||||
if (allCountries.get(i).chs.equals(ct)) {
|
||||
String countryName = allCountries.get(i).name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) : countryName;
|
||||
mTvCountryCode.setText("+" + allCountries.get(i).code + " " + countryName);
|
||||
mCountryCode = allCountries.get(i).code;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEditProfileEvent(BindPhoneEvent event) {
|
||||
}
|
||||
|
||||
private void mTvCountryCodeClick() {
|
||||
mIvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
mTvCountryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCountryCode();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void changeEnable() {
|
||||
String phone = mEditPhone.getText().toString();
|
||||
String code = mEditCode.getText().toString();
|
||||
String pwd1 = mEditPwd1.getText().toString();
|
||||
String pwd2 = mEditPwd2.getText().toString();
|
||||
// mBtnRegister.setEnabled(!TextUtils.isEmpty(phone) && !TextUtils.isEmpty(code) && !TextUtils.isEmpty(pwd1) && !TextUtils.isEmpty(pwd2));
|
||||
}
|
||||
|
||||
private void showCountryCode() {
|
||||
CountryPicker.newInstance(null, new OnPick() {
|
||||
@Override
|
||||
public void onPick(Country country) {
|
||||
String countryName = country.name;
|
||||
countryName = countryName.length() > 4 ? countryName.substring(0, 4) + "..." : countryName;
|
||||
mTvCountryCode.setText(" +" + country.code + " " + countryName);
|
||||
mCountryCode = country.code;
|
||||
}
|
||||
}).show(getSupportFragmentManager(), "country");
|
||||
}
|
||||
|
||||
|
||||
public void registerClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_code) {
|
||||
//获取验证码
|
||||
// getMessageCode();
|
||||
//获取邀请码
|
||||
// getPromoCode();
|
||||
webview.setVisibility(View.VISIBLE);
|
||||
//获取设备唯一标识符
|
||||
getUuidDevice();
|
||||
|
||||
} else if (i == R.id.btn_register) {
|
||||
register();
|
||||
} else if (i == R.id.btn_tip2) {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY1, false);
|
||||
} else if (i == R.id.btn_tip3) {
|
||||
WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY2, false);
|
||||
} else if (i == R.id.btn_goto_updata) {
|
||||
lt_now_bind.setVisibility(View.GONE);
|
||||
lt_first_bind.setVisibility(View.VISIBLE);
|
||||
lt_give.setVisibility(View.GONE);
|
||||
lt_password.setVisibility(View.GONE);
|
||||
lt_password2.setVisibility(View.GONE);
|
||||
tv_title.setText(getResources().getString(R.string.bind_phone_updata_title));
|
||||
}
|
||||
}
|
||||
|
||||
private void getUuidDevice() {
|
||||
String uuid = DeviceUtils.getUniqueDeviceId();
|
||||
if (uuid != null) {
|
||||
mUuidDevice = uuid;
|
||||
}
|
||||
}
|
||||
|
||||
public class JsBridge {
|
||||
@JavascriptInterface
|
||||
public void getData(final String Randstr, final String Ticket) {
|
||||
((BindUserActivity) mContext).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i("tvss", Randstr);
|
||||
webview.setVisibility(View.GONE);
|
||||
//获取验证码
|
||||
getMessageCode(Randstr, Ticket);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短信验证码
|
||||
*/
|
||||
private void getMessageCode(String Randstr, String Ticket) {
|
||||
String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum))
|
||||
// {
|
||||
// mEditPhone.setError(mContext.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
mEditCode.requestFocus();
|
||||
MainHttpUtil.getRegisterCode(Randstr, Ticket, phoneNum, mCountryCode, mGetCodeCallback);
|
||||
}
|
||||
|
||||
private HttpCallback mGetCodeCallback = new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
mBtnCode.setEnabled(false);
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessage(0);
|
||||
}
|
||||
if (!TextUtils.isEmpty(msg) && msg.contains("123456")) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 注册并登陆
|
||||
*/
|
||||
private void register() {
|
||||
final String phoneNum = mEditPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNum)) {
|
||||
mEditPhone.setError(mContext.getString(R.string.reg_input_phone));
|
||||
mEditPhone.requestFocus();
|
||||
return;
|
||||
}
|
||||
//屏蔽,原因:国外手机号无法校验合法性
|
||||
// if (!ValidatePhoneUtil.validateMobileNumber(phoneNum)) {
|
||||
// mEditPhone.setError(mContext.getString(R.string.login_phone_error));
|
||||
// mEditPhone.requestFocus();
|
||||
// return;
|
||||
// }
|
||||
String code = mEditCode.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(code)) {
|
||||
mEditCode.setError(mContext.getString(R.string.reg_input_code));
|
||||
mEditCode.requestFocus();
|
||||
return;
|
||||
}
|
||||
if ("0".equals(isBind)) {
|
||||
final String pwd = mEditPwd1.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd)) {
|
||||
mEditPwd1.setError(mContext.getString(R.string.reg_input_pwd_1));
|
||||
mEditPwd1.requestFocus();
|
||||
return;
|
||||
}
|
||||
String pwd2 = mEditPwd2.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_input_pwd_2));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (!pwd.equals(pwd2)) {
|
||||
mEditPwd2.setError(mContext.getString(R.string.reg_pwd_error));
|
||||
mEditPwd2.requestFocus();
|
||||
return;
|
||||
}
|
||||
// if (mDialog != null) {
|
||||
// mDialog.show();
|
||||
// }
|
||||
MainHttpUtil.bindPhone(phoneNum, mCountryCode, getIntent().getStringExtra("uid"), getIntent().getStringExtra("token"), pwd, pwd2, code, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
ToastUtil.show(msg);
|
||||
if (code == 0) {
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra("phoneNum", phoneNum);
|
||||
setResult(RESULT_OK, intent);
|
||||
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) {
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra("phoneNum", phoneNum);
|
||||
setResult(RESULT_OK, intent);
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@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,151 @@
|
||||
package com.shayu.onetoone.activity.setting;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.SearchAdapter;
|
||||
import com.shayu.onetoone.bean.SearchUserBean;
|
||||
import com.shayu.onetoone.utils.MainHttpConsts;
|
||||
import com.shayu.onetoone.utils.MainHttpUtil;
|
||||
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.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.event.FollowEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 我的关注 TA的关注
|
||||
*/
|
||||
|
||||
public class FollowActivity extends AbsActivity implements OnItemClickListener<SearchUserBean> {
|
||||
|
||||
public static void forward(Context context, String toUid, int isBlack) {
|
||||
Intent intent = new Intent(context, FollowActivity.class);
|
||||
intent.putExtra(Constants.TO_UID, toUid);
|
||||
intent.putExtra(Constants.isBlack, isBlack);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
private CommonRefreshView mRefreshView;
|
||||
private SearchAdapter mAdapter;
|
||||
private String mToUid;
|
||||
private int isBlack;
|
||||
private int intoIndex = 0;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_follow;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
mToUid = getIntent().getStringExtra(Constants.TO_UID);
|
||||
isBlack = getIntent().getIntExtra(Constants.isBlack, 0);
|
||||
if (TextUtils.isEmpty(mToUid)) {
|
||||
return;
|
||||
}
|
||||
mRefreshView = findViewById(R.id.refreshView);
|
||||
if (isBlack == 1) {
|
||||
setTitle(mContext.getString(R.string.my_black));
|
||||
} else if (mToUid.equals(CommonAppConfig.getInstance().getUid())) {
|
||||
setTitle(mContext.getString(R.string.follow_my_follow));
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_follow);
|
||||
} else {
|
||||
setTitle(mContext.getString(R.string.follow_ta_follow));
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_follow_2);
|
||||
}
|
||||
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<SearchUserBean>() {
|
||||
@Override
|
||||
public RefreshAdapter<SearchUserBean> getAdapter() {
|
||||
if (mAdapter == null) {
|
||||
mAdapter = new SearchAdapter(mContext, Constants.FOLLOW_FROM_FOLLOW);
|
||||
mAdapter.setOnItemClickListener(FollowActivity.this);
|
||||
}
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
if (isBlack == 1) {
|
||||
MainHttpUtil.getBlackList(p, callback);
|
||||
} else {
|
||||
MainHttpUtil.getFollowList(mToUid, p, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchUserBean> processData(String[] info) {
|
||||
return JSON.parseArray(Arrays.toString(info), SearchUserBean.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshSuccess(List<SearchUserBean> list, int listCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreSuccess(List<SearchUserBean> loadItemList, int loadItemCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
EventBus.getDefault().register(this);
|
||||
mRefreshView.initData();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onFollowEvent(FollowEvent e) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.updateItem(e.getToUid(), e.getIsAttention());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_FOLLOW_LIST);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(SearchUserBean bean, int position) {
|
||||
RouteUtil.forwardUserHome(mContext, bean.getId(), 0);
|
||||
intoIndex = 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (intoIndex == 1) {
|
||||
intoIndex = 0;
|
||||
mRefreshView.initData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.shayu.onetoone.activity.setting;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.user.AuthActivity;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
|
||||
public class ModifyPwdActivity extends AbsActivity implements View.OnClickListener {
|
||||
|
||||
private EditText mEditOld;
|
||||
private EditText mEditNew;
|
||||
private EditText mEditConfirm;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_modify_pwd;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.modify_pwd));
|
||||
mEditOld = (EditText) findViewById(R.id.edit_old);
|
||||
mEditNew = (EditText) findViewById(R.id.edit_new);
|
||||
mEditConfirm = (EditText) findViewById(R.id.edit_confirm);
|
||||
findViewById(R.id.btn_confirm).setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
modify();
|
||||
}
|
||||
|
||||
private void modify() {
|
||||
String pwdOld = mEditOld.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwdOld)) {
|
||||
mEditOld.setError(mContext.getString(R.string.modify_pwd_old_1));
|
||||
return;
|
||||
}
|
||||
String pwdNew = mEditNew.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwdNew)) {
|
||||
mEditNew.setError(mContext.getString(R.string.modify_pwd_new_1));
|
||||
return;
|
||||
}
|
||||
String pwdConfirm = mEditConfirm.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(pwdConfirm)) {
|
||||
mEditConfirm.setError(mContext.getString(R.string.modify_pwd_confirm_1));
|
||||
return;
|
||||
}
|
||||
if (!pwdNew.equals(pwdConfirm)) {
|
||||
mEditConfirm.setError(mContext.getString(R.string.reg_pwd_error));
|
||||
return;
|
||||
}
|
||||
|
||||
OTONetManager.getInstance(ModifyPwdActivity.this).updatePass(pwdOld, pwdNew, pwdConfirm, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
if (data.getCode() == 0) {
|
||||
ToastUtil.show(data.getMsg());
|
||||
finish();
|
||||
} else {
|
||||
ToastUtil.show(data.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
package com.shayu.onetoone.activity.setting;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||
import com.yunbao.common.adapter.MsgFollowAdapter;
|
||||
import com.yunbao.common.bean.MsgSwitchDetailModel;
|
||||
import com.yunbao.common.http.ResponseData;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.main.MainNetManager;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
public class OneMsgSettActivity extends AbsOTOActivity {
|
||||
ImageView dt_switch, hdd_switch, lt_switch, xt_switch, kb_switch, privateChatMessageSwitch;
|
||||
public static final String SWITCH_PRIVATE_CHAT_MSG = "private_chat_message_switch";
|
||||
|
||||
RecyclerView follow_list;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_msg_sett;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
setTitle(getString(R.string.alerts));
|
||||
follow_list = (RecyclerView) findViewById(R.id.follow_list);
|
||||
dt_switch = (ImageView) findViewById(R.id.dt_switch);
|
||||
hdd_switch = (ImageView) findViewById(R.id.hdd_switch);
|
||||
lt_switch = (ImageView) findViewById(R.id.lt_switch);
|
||||
xt_switch = (ImageView) findViewById(R.id.xt_switch);
|
||||
kb_switch = (ImageView) findViewById(R.id.kb_switch);
|
||||
privateChatMessageSwitch = findViewById(R.id.private_chat_switch);
|
||||
getData();
|
||||
dt_switch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//打开的
|
||||
if (dt_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
if (setMsgMasterSwitch("2", "1")) {
|
||||
dt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
;
|
||||
} else {
|
||||
if (setMsgMasterSwitch("1", "1")) {
|
||||
dt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
hdd_switch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//打开的
|
||||
if (hdd_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
if (setMsgMasterSwitch("2", "2")) {
|
||||
hdd_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
;
|
||||
} else {
|
||||
if (setMsgMasterSwitch("1", "2")) {
|
||||
hdd_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
lt_switch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//打开的
|
||||
if (lt_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
if (setMsgMasterSwitch("2", "3")) {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
;
|
||||
} else {
|
||||
if (setMsgMasterSwitch("1", "3")) {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
xt_switch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//打开的
|
||||
if (xt_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
if (setMsgMasterSwitch("2", "4")) {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
;
|
||||
} else {
|
||||
if (setMsgMasterSwitch("1", "4")) {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
follow_list.setVisibility(View.GONE);
|
||||
kb_switch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int is = 1;
|
||||
//打开的
|
||||
if (kb_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
is = 2;
|
||||
} else {
|
||||
is = 1;
|
||||
}
|
||||
MainNetManager.get(OneMsgSettActivity.this).setBeginShowMsgSwitch(is + "", "1", "", new HttpCallback<ResponseData>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseData data) {
|
||||
|
||||
Log.e("ds", data.getCode() + "");
|
||||
if (data.getCode() == 200) {
|
||||
Log.e("ds", kb_switch.getDrawable().getCurrent().getConstantState() + "");
|
||||
if (kb_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
kb_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
follow_list.setVisibility(View.GONE);
|
||||
} else {
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
Log.e("ds", kb_switch.getDrawable().getCurrent().getConstantState() + "11" + error);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
/* privateChatMessageSwitch.setOnClickListener(view -> {
|
||||
if (privateChatMessageSwitch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())){
|
||||
if(setMsgMasterSwitch("2","5")){
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
}else{
|
||||
if(setMsgMasterSwitch("1","5")){
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
}
|
||||
});*/
|
||||
privateChatMessageSwitch.setOnClickListener(view -> {
|
||||
if (privateChatMessageSwitch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())) {
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_off);
|
||||
SpUtil.getInstance().setBooleanValue(SWITCH_PRIVATE_CHAT_MSG, false);
|
||||
} else {
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_on);
|
||||
SpUtil.getInstance().setBooleanValue(SWITCH_PRIVATE_CHAT_MSG, true);
|
||||
}
|
||||
});
|
||||
|
||||
follow_list.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
follow_list.setHasFixedSize(true);
|
||||
follow_list.setNestedScrollingEnabled(true);
|
||||
}
|
||||
|
||||
public void getData() {
|
||||
MainNetManager.get(this)
|
||||
.getMsgSwitchDetail(new HttpCallback<MsgSwitchDetailModel>() {
|
||||
@Override
|
||||
public void onSuccess(MsgSwitchDetailModel data) {
|
||||
|
||||
if (data.getDynamic_msg_switch().equals("2")) {
|
||||
dt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
dt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
if (data.getInteraction_show_msg_switch().equals("2")) {
|
||||
hdd_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
hdd_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
if (data.getChat_msg_switch().equals("2")) {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
if (data.getChat_msg_switch().equals("2")) {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
lt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
if (data.getSystem_msg_switch().equals("2")) {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
if (data.getSystem_msg_switch().equals("2")) {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_off);
|
||||
} else {
|
||||
xt_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.getFollowList().size(); i++) {
|
||||
if (!data.getFollowList().get(i).getStatus().equals("2")) {
|
||||
kb_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
follow_list.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (SpUtil.getInstance().getBooleanValue(SWITCH_PRIVATE_CHAT_MSG)) {
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_on);
|
||||
} else {
|
||||
privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_off);
|
||||
}
|
||||
|
||||
MsgFollowAdapter topAdapter = new MsgFollowAdapter(OneMsgSettActivity.this, data.getFollowList());
|
||||
follow_list.setAdapter(topAdapter);
|
||||
follow_list.setVisibility(View.VISIBLE);
|
||||
kb_switch.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(R.string.net_error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean ret = false;
|
||||
|
||||
public boolean setMsgMasterSwitch(String status, String type) {
|
||||
ret = false;
|
||||
MainNetManager.get(this).setMsgMasterSwitch(status, type, new HttpCallback<ResponseData>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseData data) {
|
||||
|
||||
if (data.getCode() == 200) {
|
||||
ret = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.shayu.onetoone.activity.setting;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.login.EntryActivity;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.HtmlUrlUtils;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.GlideCatchUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.VersionUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
|
||||
/**
|
||||
* 设置
|
||||
*/
|
||||
@Route(path = RouteManager.PATH_SETTING)
|
||||
public class SettingActivity extends AbsActivity {
|
||||
|
||||
private Handler mHandler;
|
||||
|
||||
private TextView versionCode;
|
||||
private TextView cacheSize;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_setting;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.set_up));
|
||||
IMLoginModel model = UserManager.getUserBean().getUser();
|
||||
|
||||
versionCode = findViewById(R.id.versionCode);
|
||||
cacheSize = findViewById(R.id.cacheSize);
|
||||
|
||||
//编辑资料
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.personSet), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteUtil.forwardEditProfileActivity();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.change_the_password), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
forwardModifyPwd();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.blacklist), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
FollowActivity.forward(mContext, CommonAppConfig.getInstance().getUserBean().getId(), 1);
|
||||
}
|
||||
});
|
||||
// 达人认证
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.toBlogger), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
//forwardModifyPwd();
|
||||
RouteManager.forwardAuthBloggerInletActivity();
|
||||
}
|
||||
});
|
||||
//清除緩存
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.clearCaChe), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
clearCache();
|
||||
}
|
||||
});
|
||||
//检查版本更新
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.checkVersion), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
checkVersion();
|
||||
}
|
||||
});
|
||||
//退出登录
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.logout), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
logout();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.layout_alerts), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
startActivity(new Intent(SettingActivity.this, OneMsgSettActivity.class));
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.qa), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteManager.forwardWebViewActivity(null, HtmlUrlUtils.getQAUrl());
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.user_agreement), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteManager.forwardWebViewActivity(null,HtmlUrlUtils.getUserAgreement());
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.server_agreement), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteManager.forwardWebViewActivity(null,HtmlUrlUtils.getServerAgreement());
|
||||
}
|
||||
});
|
||||
intiData();
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void intiData() {
|
||||
versionCode.setText(VersionUtil.getVersion()+"("+VersionUtil.getVersionCode()+")");
|
||||
cacheSize.setText(GlideCatchUtil.getInstance().getCacheSize());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查更新
|
||||
*/
|
||||
private void checkVersion() {
|
||||
CommonAppConfig.getInstance().getConfig(new CommonCallback<ConfigBean>() {
|
||||
@Override
|
||||
public void callback(ConfigBean configBean) {
|
||||
if (configBean != null) {
|
||||
if (VersionUtil.isLatest(configBean.getVersion())) {
|
||||
ToastUtil.show(R.string.version_latest);
|
||||
} else {
|
||||
VersionUtil.showDialog(mContext, configBean, configBean.getDownloadApkUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
private void logout() {
|
||||
IMLoginManager.get(this).logout(this);
|
||||
UserManager.logout();
|
||||
CommonAppConfig.getInstance().clearLoginInfo();
|
||||
RCRTCEngine.getInstance().unInit();
|
||||
RongIMClient.getInstance().logout();
|
||||
Intent intent = new Intent(SettingActivity.this, EntryActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
Constants.firstInto = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
private void forwardModifyPwd() {
|
||||
startActivity(new Intent(mContext, ModifyPwdActivity.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
*/
|
||||
private String getCacheSize() {
|
||||
return GlideCatchUtil.getInstance().getCacheSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
*/
|
||||
private void clearCache() {
|
||||
final 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) {
|
||||
cacheSize.setText(GlideCatchUtil.getInstance().getCacheSize());
|
||||
dialog.dismiss();
|
||||
}
|
||||
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,268 @@
|
||||
package com.shayu.onetoone.activity.user;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.AuthBean;
|
||||
import com.shayu.onetoone.bean.AvatarBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.view.UserAuthPopup;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 我的 编辑资料
|
||||
*/
|
||||
@Route(path = RouteManager.ACTIVITY_AUTH)
|
||||
public class AuthActivity extends AbsActivity {
|
||||
|
||||
private ImageView image1;
|
||||
private ImageView image2;
|
||||
|
||||
private ImageView image11;
|
||||
private ImageView image22;
|
||||
|
||||
private TextView submit;
|
||||
private ProcessImageUtil cameraUtil;
|
||||
|
||||
private File file1;
|
||||
private File file2;
|
||||
|
||||
private String imgUrl1;
|
||||
private String imgUrl2;
|
||||
|
||||
Dialog dialog;
|
||||
AuthBean authBean;
|
||||
|
||||
private TextView remake;
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_auth;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle("真人认证");
|
||||
image1 = findViewById(R.id.image1);
|
||||
image11 = findViewById(R.id.image11);
|
||||
image2 = findViewById(R.id.image2);
|
||||
image22 = findViewById(R.id.image22);
|
||||
submit = findViewById(R.id.submit);
|
||||
remake = findViewById(R.id.remake);
|
||||
|
||||
image1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
isFront = true;
|
||||
setImage();
|
||||
}
|
||||
});
|
||||
image11.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
isFront = true;
|
||||
setImage();
|
||||
}
|
||||
});
|
||||
image2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
isFront = false;
|
||||
setImage();
|
||||
}
|
||||
});
|
||||
image22.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
isFront = false;
|
||||
setImage();
|
||||
}
|
||||
});
|
||||
submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
submit();
|
||||
}
|
||||
});
|
||||
initCamera();
|
||||
dialog = DialogUitl.loadingDialog(mContext, WordUtil.getNewString(R.string.upload_in_progress));
|
||||
getAuthInfo();
|
||||
}
|
||||
|
||||
private void getAuthInfo() {
|
||||
OTONetManager.getInstance(AuthActivity.this).getAuthInfo(new HttpCallback<AuthBean>() {
|
||||
@Override
|
||||
public void onSuccess(AuthBean data) {
|
||||
authBean = data;
|
||||
if (data.getName_auth() == 2) {//已通过
|
||||
ImgLoader.display(mContext, data.getAuth_front(), image1);
|
||||
ImgLoader.display(mContext, data.getAuth_back(), image2);
|
||||
image11.setVisibility(View.GONE);
|
||||
image22.setVisibility(View.GONE);
|
||||
submit.setEnabled(false);
|
||||
image1.setEnabled(false);
|
||||
image2.setEnabled(false);
|
||||
} else if (data.getName_auth() == 3) {//已提交
|
||||
ImgLoader.display(mContext, data.getAuth_front(), image1);
|
||||
ImgLoader.display(mContext, data.getAuth_back(), image2);
|
||||
image11.setVisibility(View.GONE);
|
||||
image22.setVisibility(View.GONE);
|
||||
submit.setText(WordUtil.getNewString(R.string.title_audit_config));
|
||||
submit.setEnabled(false);
|
||||
image1.setEnabled(false);
|
||||
image2.setEnabled(false);
|
||||
} else if(data.getName_auth() == 4){
|
||||
ImgLoader.display(mContext, data.getAuth_front(), image1);
|
||||
ImgLoader.display(mContext, data.getAuth_back(), image2);
|
||||
image11.setVisibility(View.GONE);
|
||||
image22.setVisibility(View.GONE);
|
||||
submit.setText(WordUtil.getNewString(R.string.resubmit));
|
||||
submit.setEnabled(true);
|
||||
}else{
|
||||
ImgLoader.display(mContext, data.getAuth_front(), image1);
|
||||
ImgLoader.display(mContext, data.getAuth_back(), image2);
|
||||
submit.setText(WordUtil.getNewString(R.string.layout_auth_tips5));
|
||||
remake.setText(data.getAuth_remark());
|
||||
submit.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCamera() {
|
||||
cameraUtil = new ProcessImageUtil(this, getPackageName()+".fileprovider");
|
||||
cameraUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
@Override
|
||||
public void beforeCamera() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
L.e("cameraUtil.setImageResultCallback:");
|
||||
if (!dialog.isShowing()) {
|
||||
dialog.show();
|
||||
}
|
||||
if (file != null) {
|
||||
OTONetManager.getInstance(mContext).updateFile(file, new HttpCallback<AvatarBean>() {
|
||||
@Override
|
||||
public void onSuccess(AvatarBean data) {
|
||||
if (data != null) {
|
||||
ToastUtil.show(WordUtil.getNewString(R.string.upload_success));
|
||||
if (isFront) {
|
||||
imgUrl1 = data.getAvatar();
|
||||
file1 = file;
|
||||
ImgLoader.display(mContext, file1, image1);
|
||||
image11.setVisibility(View.GONE);
|
||||
findViewById(R.id.image11).setVisibility(View.GONE);
|
||||
} else {
|
||||
imgUrl2 = data.getAvatar();
|
||||
file2 = file;
|
||||
ImgLoader.display(mContext, file2, image2);
|
||||
image22.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
if (file1 != null && file2 != null) {
|
||||
submit.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_2));
|
||||
}
|
||||
dialog.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
dialog.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean isFront = true;
|
||||
|
||||
private void submit() {
|
||||
OTONetManager.getInstance(AuthActivity.this).setAuthInfo(imgUrl1, imgUrl2, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
if (data.getCode() == 0) {
|
||||
ToastUtil.show(R.string.title_audit_config2);
|
||||
submit.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_1));
|
||||
submit.setText(R.string.title_audit_config);
|
||||
imgUrl1 = null;
|
||||
imgUrl2 = null;
|
||||
} else {
|
||||
ToastUtil.show(data.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setImage() {
|
||||
UserAuthPopup userAuthPopup = new UserAuthPopup(AuthActivity.this, new UserAuthPopup.onIsCameraClickListener() {
|
||||
@Override
|
||||
public void onIsCamera(boolean isCamera) {
|
||||
if (isCamera) {
|
||||
cameraUtil.getImageByCamera();
|
||||
} else {
|
||||
cameraUtil.getImageByAlumb();
|
||||
}
|
||||
}
|
||||
});
|
||||
new XPopup.Builder(mContext).asCustom(userAuthPopup).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (cameraUtil != null) {
|
||||
cameraUtil.release();
|
||||
}
|
||||
//MainHttpUtil.cancel(MainHttpConsts.UPDATE_AVATAR);
|
||||
//MainHttpUtil.cancel(MainHttpConsts.UPDATE_FIELDS);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (Constants.isShowPage != -1) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
package com.shayu.onetoone.activity.user;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.blankj.utilcode.util.StringUtils;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.AvatarBean;
|
||||
import com.shayu.onetoone.bean.ImageBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.view.UserAuthPopup;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.custom.ItemDecoration;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.CompleteInformationPopup;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 達人認證
|
||||
*/
|
||||
@Route(path = RouteManager.ACTIVITY_AUTH_BLOGGER)
|
||||
public class AuthBloggerActivity extends AbsActivity {
|
||||
private ImageView personImg;
|
||||
private TextView submit;
|
||||
private ProcessImageUtil cameraUtil;
|
||||
Dialog dialog;
|
||||
|
||||
private RecyclerView mRecyclerViewImage;
|
||||
|
||||
ActiveAdapter adapter;
|
||||
|
||||
List<ImageBean> imageBeanList = new ArrayList<>();
|
||||
|
||||
private int selectIndex;
|
||||
|
||||
private String personImgUrl;
|
||||
|
||||
private LinearLayout sexLayoutMan;
|
||||
|
||||
private LinearLayout sexLayoutWoman;
|
||||
|
||||
private ImageView sexImgMan;
|
||||
private ImageView sexImgWoman;
|
||||
|
||||
private int sex = 1;
|
||||
|
||||
private EditText editUserName;
|
||||
private EditText editUserMobile;
|
||||
private EditText editCardId;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_auth_blogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(WordUtil.getNewString(R.string.upload_enter_title));
|
||||
sexLayoutMan = findViewById(R.id.sex_man);
|
||||
sexLayoutWoman = findViewById(R.id.sex_woman);
|
||||
sexImgMan = findViewById(R.id.sex_img_man);
|
||||
sexImgWoman = findViewById(R.id.sex_img_woman);
|
||||
|
||||
editUserName = findViewById(R.id.name);
|
||||
editUserMobile = findViewById(R.id.mobile);
|
||||
editCardId = findViewById(R.id.cardId);
|
||||
|
||||
personImg = findViewById(R.id.personImg);
|
||||
submit = findViewById(R.id.submit);
|
||||
submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
submit();
|
||||
}
|
||||
});
|
||||
initCamera();
|
||||
dialog = DialogUitl.loadingDialog(mContext, WordUtil.getNewString(R.string.upload_in_progress));
|
||||
|
||||
mRecyclerViewImage = findViewById(R.id.recyclerView_image);
|
||||
mRecyclerViewImage.setLayoutManager(new GridLayoutManager(mContext, 3, GridLayoutManager.VERTICAL, false));
|
||||
ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 15, 15);
|
||||
decoration.setOnlySetItemOffsetsButNoDraw(true);
|
||||
mRecyclerViewImage.addItemDecoration(decoration);
|
||||
|
||||
imageBeanList = new ArrayList<>();
|
||||
for (int i = 0; i < 9; i++) {
|
||||
imageBeanList.add(new ImageBean(i));
|
||||
}
|
||||
|
||||
adapter = new ActiveAdapter(AuthBloggerActivity.this);
|
||||
mRecyclerViewImage.setAdapter(adapter);
|
||||
adapter.setList(imageBeanList);
|
||||
|
||||
personImg.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectIndex = -1;
|
||||
setImage();
|
||||
}
|
||||
});
|
||||
|
||||
sexLayoutMan.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sex = 1;
|
||||
sexImgMan.setImageDrawable(getResources().getDrawable(R.mipmap.sex_radio_2));
|
||||
sexImgWoman.setImageDrawable(getResources().getDrawable(R.mipmap.sex_radio_1));
|
||||
}
|
||||
});
|
||||
sexLayoutWoman.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sex = 2;
|
||||
sexImgMan.setImageDrawable(getResources().getDrawable(R.mipmap.sex_radio_1));
|
||||
sexImgWoman.setImageDrawable(getResources().getDrawable(R.mipmap.sex_radio_2));
|
||||
}
|
||||
});
|
||||
|
||||
editCardId.addTextChangedListener(textWatcher);
|
||||
editUserName.addTextChangedListener(textWatcher);
|
||||
editUserMobile.addTextChangedListener(textWatcher);
|
||||
}
|
||||
|
||||
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) {
|
||||
checkSubmit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private void initCamera() {
|
||||
cameraUtil = new ProcessImageUtil(this, getPackageName()+".fileprovider");
|
||||
cameraUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
@Override
|
||||
public void beforeCamera() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
L.e("cameraUtil.setImageResultCallback:");
|
||||
if (!dialog.isShowing()) {
|
||||
dialog.show();
|
||||
}
|
||||
if (file != null) {
|
||||
OTONetManager.getInstance(mContext).updateFile(file, new HttpCallback<AvatarBean>() {
|
||||
@Override
|
||||
public void onSuccess(AvatarBean data) {
|
||||
if (selectIndex == -1) {
|
||||
personImgUrl = data.getAvatar();
|
||||
ImgLoader.display(mContext, personImgUrl, personImg);
|
||||
findViewById(R.id.image11).setVisibility(View.GONE);
|
||||
checkSubmit();
|
||||
} else {
|
||||
imageBeanList.get(selectIndex).setFile(file);
|
||||
imageBeanList.get(selectIndex).setUrl(data.getAvatar());
|
||||
adapter.notifyItemChanged(selectIndex);
|
||||
}
|
||||
dialog.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
dialog.hide();
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
public void checkSubmit() {
|
||||
if (CheckInput()) {
|
||||
submit.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_2));
|
||||
submit.setEnabled(true);
|
||||
} else {
|
||||
submit.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_1));
|
||||
submit.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean CheckInput() {
|
||||
if (StringUtils.isEmpty(editUserName.getText().toString())) {
|
||||
return false;
|
||||
}
|
||||
if (StringUtils.isEmpty(editUserMobile.getText().toString())) {
|
||||
return false;
|
||||
}
|
||||
if (StringUtils.isEmpty(editCardId.getText().toString())) {
|
||||
return false;
|
||||
}
|
||||
if (StringUtils.isEmpty(personImgUrl)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void submit() {
|
||||
StringBuffer imgs = new StringBuffer();
|
||||
for (int i = 0; i < imageBeanList.size(); i++) {
|
||||
if (!StringUtils.isEmpty(imageBeanList.get(i).getUrl())) {
|
||||
if (imgs.length() == 0) {
|
||||
imgs.append(imageBeanList.get(i).getUrl());
|
||||
} else {
|
||||
imgs.append("," + imageBeanList.get(i).getUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OTONetManager.getInstance(AuthBloggerActivity.this).authSage(editUserName.getText().toString(), editUserMobile.getText().toString(), editCardId.getText().toString(), personImgUrl, imgs.toString(), sex, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
if (data.getCode() == 0) {
|
||||
ToastUtil.show(WordUtil.getNewString(R.string.title_audit_config2));
|
||||
submit.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_1));
|
||||
submit.setText(WordUtil.getNewString(R.string.title_audit_config));
|
||||
} else {
|
||||
ToastUtil.show(data.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setImage() {
|
||||
UserAuthPopup userAuthPopup = new UserAuthPopup(AuthBloggerActivity.this, new UserAuthPopup.onIsCameraClickListener() {
|
||||
@Override
|
||||
public void onIsCamera(boolean isCamera) {
|
||||
if (isCamera) {
|
||||
cameraUtil.getImageByCamera();
|
||||
} else {
|
||||
cameraUtil.getImageByAlumb();
|
||||
}
|
||||
}
|
||||
});
|
||||
new XPopup.Builder(mContext).asCustom(userAuthPopup).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (cameraUtil != null) {
|
||||
cameraUtil.release();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private UserBean userModel;
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (Constants.isShowPage != -1) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public void onBackPressed() {
|
||||
if (userModel.getUserInfoComplete() == 1) {
|
||||
finish();
|
||||
} else {
|
||||
new XPopup.Builder(mContext).asCustom(new CompleteInformationPopup(mContext, true, new CompleteInformationPopup.CompleteInformationCallBack() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSure() {
|
||||
finish();
|
||||
}
|
||||
})).show();
|
||||
}
|
||||
}*/
|
||||
|
||||
public class ActiveAdapter extends RefreshAdapter<ImageBean> {
|
||||
|
||||
public ActiveAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_auth_img, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
((Vh) vh).setData(mList.get(position));
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView img1;
|
||||
ImageView img11;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
img1 = itemView.findViewById(R.id.image1);
|
||||
img11 = itemView.findViewById(R.id.image11);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
ImageBean imageBean = (ImageBean) itemView.getTag();
|
||||
selectIndex = imageBean.getIndex();
|
||||
setImage();
|
||||
});
|
||||
}
|
||||
|
||||
void setData(ImageBean bean) {
|
||||
itemView.setTag(bean);
|
||||
if (bean.getFile() == null) {
|
||||
img11.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
img11.setVisibility(View.INVISIBLE);
|
||||
img1.setVisibility(View.VISIBLE);
|
||||
ImgLoader.display(mContext, bean.getFile(), img1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.shayu.onetoone.activity.user;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.AuthBean;
|
||||
import com.shayu.onetoone.bean.AuthBloggerBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
/**
|
||||
* 達人認證入口
|
||||
*/
|
||||
@Route(path = RouteManager.ACTIVITY_AUTH_BLOGGER_INLET)
|
||||
public class AuthBloggerInletActivity extends AbsActivity {
|
||||
|
||||
private LinearLayout personLayout;
|
||||
private LinearLayout sageLayout;
|
||||
private ImageView personImg;
|
||||
private ImageView sageImg;
|
||||
|
||||
private TextView perStatus;
|
||||
private TextView sageStatus;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_auth_blogger_inlet;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(WordUtil.getNewString(R.string.user_authentication));
|
||||
personLayout = findViewById(R.id.personLayout);
|
||||
sageLayout = findViewById(R.id.sageLayout);
|
||||
|
||||
personImg = findViewById(R.id.personStatus);
|
||||
sageImg = findViewById(R.id.sageStatus);
|
||||
|
||||
perStatus = findViewById(R.id.personBt);
|
||||
sageStatus = findViewById(R.id.sageBt);
|
||||
|
||||
dialog = DialogUitl.loadingDialog(mContext, WordUtil.getNewString(R.string.query));
|
||||
|
||||
}
|
||||
|
||||
AuthBean authBean;
|
||||
|
||||
AuthBloggerBean authBloggerBean;
|
||||
|
||||
Dialog dialog;
|
||||
|
||||
private void getAuthInfo() {
|
||||
dialog.show();
|
||||
OTONetManager.getInstance(AuthBloggerInletActivity.this).getAuthInfo(new HttpCallback<AuthBean>() {
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
@Override
|
||||
public void onSuccess(AuthBean data) {
|
||||
authBean = data;
|
||||
if (data.getName_auth() == 2) {//已通过
|
||||
personLayout.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_4));
|
||||
personImg.setImageDrawable(getResources().getDrawable(R.mipmap.icon_suc));
|
||||
perStatus.setText(R.string.complete);
|
||||
perStatus.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_3));
|
||||
} else if (data.getName_auth() == 3) {//已提交
|
||||
personLayout.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_1));
|
||||
personImg.setImageDrawable(getResources().getDrawable(R.mipmap.icon_fail));
|
||||
perStatus.setText(R.string.title_audit_config);
|
||||
perStatus.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_3));
|
||||
} else if (data.getName_auth() == 4) {
|
||||
personLayout.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_1));
|
||||
personImg.setImageDrawable(getResources().getDrawable(R.mipmap.icon_fail));
|
||||
perStatus.setText(R.string.title_audit_config3);
|
||||
perStatus.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_5));
|
||||
findViewById(R.id.personBt).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RouteManager.forwardAuthActivity();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
personLayout.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_1));
|
||||
personImg.setImageDrawable(getResources().getDrawable(R.mipmap.icon_fail));
|
||||
perStatus.setText(R.string.to_upload);
|
||||
perStatus.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_5));
|
||||
findViewById(R.id.personBt).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RouteManager.forwardAuthActivity();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
OTONetManager.getInstance(AuthBloggerInletActivity.this).getAuthBloggerInfo(new HttpCallback<AuthBloggerBean>() {
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
@Override
|
||||
public void onSuccess(AuthBloggerBean data) {
|
||||
authBloggerBean = data;
|
||||
if (data.getStatus() == 2) {//已通过
|
||||
sageLayout.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_4));
|
||||
sageImg.setImageDrawable(getResources().getDrawable(R.mipmap.icon_suc));
|
||||
sageStatus.setText(R.string.complete2);
|
||||
sageStatus.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_3));
|
||||
} else if (data.getStatus() == 3) {//已提交
|
||||
sageLayout.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_1));
|
||||
sageImg.setImageDrawable(getResources().getDrawable(R.mipmap.icon_fail));
|
||||
sageStatus.setText(R.string.title_audit_config);
|
||||
sageStatus.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_3));
|
||||
} else if (data.getStatus() == 4) {
|
||||
sageLayout.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_1));
|
||||
sageImg.setImageDrawable(getResources().getDrawable(R.mipmap.icon_fail));
|
||||
sageStatus.setText(R.string.title_audit_config3);
|
||||
sageStatus.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_5));
|
||||
findViewById(R.id.sageBt).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RouteManager.forwardAuthBloggerActivity();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sageLayout.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_1));
|
||||
sageImg.setImageDrawable(getResources().getDrawable(R.mipmap.icon_fail));
|
||||
sageStatus.setText(R.string.to_upload);
|
||||
sageStatus.setBackground(getResources().getDrawable(R.drawable.bg_auth_submit_5));
|
||||
findViewById(R.id.sageBt).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RouteManager.forwardAuthBloggerActivity();
|
||||
}
|
||||
});
|
||||
}
|
||||
dialog.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
dialog.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
dialog.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
getAuthInfo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.shayu.onetoone.activity.user;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.utils.MainHttpConsts;
|
||||
import com.shayu.onetoone.utils.MainHttpUtil;
|
||||
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.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/29.
|
||||
* 设置昵称
|
||||
*/
|
||||
|
||||
public class EditNameActivity extends AbsActivity {
|
||||
|
||||
private EditText mEditText;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_edit_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.edit_profile_update_nickname));
|
||||
mEditText = (EditText) findViewById(R.id.edit);
|
||||
mEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(8)});
|
||||
findViewById(R.id.btSave).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.btSave).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
editName();
|
||||
}
|
||||
});
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
public void editName() {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
final String content = mEditText.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
ToastUtil.show(R.string.edit_profile_name_empty);
|
||||
return;
|
||||
}
|
||||
|
||||
OTONetManager.getInstance(EditNameActivity.this).setFiled("user_nicename", content, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
if (data.getCode() == 0) {
|
||||
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 (data.getCode() == 2001) {
|
||||
//余额不足,跳转支付页面
|
||||
RouteUtil.forwardMyCoin(mContext);
|
||||
ToastUtil.show(data.getMsg());
|
||||
} else {
|
||||
ToastUtil.show(data.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.UPDATE_FIELDS);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,594 @@
|
||||
package com.shayu.onetoone.activity.user;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
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 android.widget.Toast;
|
||||
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.bigkoo.pickerview.builder.TimePickerBuilder;
|
||||
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
|
||||
import com.bigkoo.pickerview.view.TimePickerView;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.sahooz.library.Country;
|
||||
import com.sahooz.library.CountryPicker;
|
||||
import com.sahooz.library.OnPick;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.login.ChooseLabelActivity;
|
||||
import com.shayu.onetoone.activity.setting.BindUserActivity;
|
||||
import com.shayu.onetoone.bean.AuthBean;
|
||||
import com.shayu.onetoone.bean.AvatarBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.shayu.onetoone.view.UserAvatarPopup;
|
||||
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.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.event.UpdateFieldEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.ActivityResultCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 我的 编辑资料
|
||||
*/
|
||||
@Route(path = RouteManager.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 TextView auth_status;
|
||||
|
||||
private TextView tag;
|
||||
private ProcessImageUtil cameraUtil;
|
||||
private String mProvinceVal;
|
||||
private String mCityVal;
|
||||
private String mZoneVal;
|
||||
private boolean isInto = true;
|
||||
private String isBind = "0", mobile = "";
|
||||
private boolean isName = false;
|
||||
|
||||
private String avatarUrl;
|
||||
|
||||
int userSex;
|
||||
|
||||
AuthBean authBean;
|
||||
|
||||
UserBean userInfo;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_edit_profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.edit_profile));
|
||||
auth_status = findViewById(R.id.auth_status);
|
||||
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);
|
||||
tag = findViewById(R.id.tag);
|
||||
findViewById(R.id.btn_person).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RouteManager.forwardAuthActivity();
|
||||
}
|
||||
});
|
||||
userInfo = UserManager.getUserBean();
|
||||
OTONetManager.getInstance(mContext).getBaseInfos(true, new com.yunbao.common.http.base.HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
showData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
initCamera();
|
||||
}
|
||||
|
||||
private void initCamera() {
|
||||
cameraUtil = new ProcessImageUtil(this, getPackageName() + ".fileprovider");
|
||||
cameraUtil.setImageResultCallback(new ImageResultCallback() {
|
||||
@Override
|
||||
public void beforeCamera() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
L.e("cameraUtil.setImageResultCallback:");
|
||||
if (file != null) {
|
||||
ImgLoader.display(mContext, file, mAvatar);
|
||||
|
||||
OTONetManager.getInstance(EditProfileActivity.this).updateFile(file, new com.yunbao.common.http.base.HttpCallback<AvatarBean>() {
|
||||
@Override
|
||||
public void onSuccess(AvatarBean data) {
|
||||
ImgLoader.display(mContext, file, mAvatar);
|
||||
//txtChoose.setVisibility(View.GONE);
|
||||
avatarUrl = data.getAvatar();
|
||||
ToastUtil.show(R.string.upload_success);
|
||||
|
||||
OTONetManager.getInstance(EditProfileActivity.this).setFiled("avatar", avatarUrl, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
if (data.getCode() == 0) {
|
||||
Toast.makeText(mContext, data.getMsg(), Toast.LENGTH_SHORT).show();
|
||||
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
|
||||
v2TIMUserFullInfo.setFaceUrl(avatarUrl);
|
||||
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(R.string.upload_failed);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
editName();
|
||||
} else {
|
||||
showTaskDialog();
|
||||
}
|
||||
} else if (i == R.id.btn_like) {
|
||||
if (isInto) {
|
||||
editLabel();
|
||||
} else {
|
||||
showTaskDialog();
|
||||
}
|
||||
} else if (i == R.id.btn_sign) {
|
||||
if (isInto) {
|
||||
forwardSign();
|
||||
} else {
|
||||
showTaskDialog();
|
||||
}
|
||||
} else if (i == R.id.btn_birthday) {
|
||||
editBirthday();
|
||||
|
||||
} else if (i == R.id.btn_sex) {
|
||||
// forwardSex();
|
||||
/*new XPopup.Builder(mContext).asCustom(new UpdateSexPopup(mContext, userModel.getSex(), new UpdateSexPopup.UpdateSexCallBack() {
|
||||
@Override
|
||||
public void onSex(int sex) {
|
||||
userSex = sex;
|
||||
|
||||
OTONetManager.getInstance(EditProfileActivity.this).setFiled("sex", String.valueOf(sex), new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
if (data.getCode() == 0) {
|
||||
ToastUtil.show(data.getMsg());
|
||||
userModel.setSex(sex);
|
||||
showData(userModel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
})).show();*/
|
||||
} else if (i == R.id.btn_city) {
|
||||
CountryPicker.newInstance(null, new OnPick() {
|
||||
@Override
|
||||
public void onPick(final Country country) {
|
||||
OTONetManager.getInstance(EditProfileActivity.this).setFiled("area", country.name, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
if (data.getCode() == 0) {
|
||||
ToastUtil.show(data.getMsg());
|
||||
if (userInfo != null) {
|
||||
userInfo.getUser().setLocation(country.name);
|
||||
}
|
||||
if (userInfo != null) {
|
||||
userInfo.getUser().setArea(country.name);
|
||||
}
|
||||
mCity.setText(country.name);
|
||||
//showData(userInfo);
|
||||
EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}).show(getSupportFragmentManager(), "country");
|
||||
} else if (i == R.id.rt_bind_phone) {
|
||||
Intent intent = new Intent(mContext, BindUserActivity.class).putExtra("uid", CommonAppConfig.getInstance().getUid()).putExtra("token", CommonAppConfig.getInstance().getToken()).putExtra("isBind", isBind).putExtra("mobile", mobile);
|
||||
|
||||
cameraUtil.startActivityForResult(intent, new ActivityResultCallback() {
|
||||
@Override
|
||||
public void onSuccess(Intent intent) {
|
||||
if (intent != null) {
|
||||
String phoneNum = String.valueOf(intent.getStringExtra("phoneNum"));
|
||||
userInfo.getUser().setMobile(phoneNum);
|
||||
tv_bind_phone.setText(phoneNum);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (i == R.id.auth) {
|
||||
RouteManager.forwardAuthActivity();
|
||||
}
|
||||
}
|
||||
|
||||
private void editLabel() {
|
||||
Intent intent = new Intent(mContext, ChooseLabelActivity.class);
|
||||
intent.putExtra("isUserHome", true);
|
||||
cameraUtil.startActivityForResult(intent, new ActivityResultCallback() {
|
||||
@Override
|
||||
public void onSuccess(Intent intent) {
|
||||
if (intent != null) {
|
||||
String label = intent.getStringExtra("label");
|
||||
userInfo.getInfo().setCn_label(label);
|
||||
tag.setText(label);
|
||||
EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void editName() {
|
||||
Intent intent = new Intent(mContext, EditNameActivity.class);
|
||||
intent.putExtra(Constants.NICK_NAME, userInfo.getUser().getUserNicename());
|
||||
cameraUtil.startActivityForResult(intent, new ActivityResultCallback() {
|
||||
@Override
|
||||
public void onSuccess(Intent intent) {
|
||||
if (intent != null) {
|
||||
String nickName = intent.getStringExtra(Constants.NICK_NAME);
|
||||
userInfo.getUser().setSignature(nickName);
|
||||
mName.setText(nickName);
|
||||
EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showTaskDialog() {
|
||||
final Dialog dialog = new Dialog(EditProfileActivity.this, R.style.dialog);
|
||||
dialog.setContentView(R.layout.dialog_task);
|
||||
dialog.setCancelable(true);
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
|
||||
dialog.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.findViewById(R.id.tv_into).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=task&a=index&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&tabIndex=1";
|
||||
WebViewActivity.forward(mContext, url, false);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void editAvatar() {
|
||||
UserAvatarPopup userAvatarPopup = new UserAvatarPopup(this, userAvatar1 -> {
|
||||
avatarUrl = userAvatar1;
|
||||
ImgLoader.display(EditProfileActivity.this, avatarUrl, mAvatar);
|
||||
|
||||
OTONetManager.getInstance(EditProfileActivity.this).setFiled("avatar", avatarUrl, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
Toast.makeText(mContext, data.getMsg(), Toast.LENGTH_SHORT).show();
|
||||
if (data.getCode() == 0) {
|
||||
V2TIMUserFullInfo v2TIMUserFullInfo = new V2TIMUserFullInfo();
|
||||
v2TIMUserFullInfo.setFaceUrl(avatarUrl);
|
||||
V2TIMManager.getInstance().setSelfInfo(v2TIMUserFullInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
//txtChoose.setVisibility(View.GONE);
|
||||
}, isCamera -> {
|
||||
if (isCamera) {
|
||||
cameraUtil.getImageByCamera();
|
||||
} else {
|
||||
cameraUtil.getImageByAlumb();
|
||||
}
|
||||
});
|
||||
new XPopup.Builder(mContext).asCustom(userAvatarPopup).show();
|
||||
}
|
||||
|
||||
private void forwardSign() {
|
||||
if (userInfo == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(mContext, EditSignActivity.class);
|
||||
intent.putExtra(Constants.SIGN, userInfo.getUser().getSignature());
|
||||
cameraUtil.startActivityForResult(intent, new ActivityResultCallback() {
|
||||
@Override
|
||||
public void onSuccess(Intent intent) {
|
||||
if (intent != null) {
|
||||
String sign = intent.getStringExtra(Constants.SIGN);
|
||||
userInfo.getUser().setSignature(sign);
|
||||
mSign.setText(sign);
|
||||
EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
int year;
|
||||
int month;
|
||||
int day;
|
||||
|
||||
|
||||
private void editBirthday() {
|
||||
if (userInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String[] times = userInfo.getUser().getBirthday().split("-");
|
||||
year = Integer.parseInt(times[0]);
|
||||
month = Integer.parseInt(times[1]) - 1;
|
||||
day = Integer.parseInt(times[2]);
|
||||
|
||||
//时间选择器
|
||||
Calendar selectedDate = Calendar.getInstance();
|
||||
selectedDate.set(year, month, day);
|
||||
|
||||
Calendar startCalendar = Calendar.getInstance();
|
||||
Calendar endCalendar = Calendar.getInstance();
|
||||
startCalendar.set(1990, 1, 1);
|
||||
endCalendar.setTime(new Date());
|
||||
|
||||
TimePickerView pvTime = new TimePickerBuilder(EditProfileActivity.this, new OnTimeSelectListener() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onTimeSelect(Date date, View v) {
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
|
||||
year = calendar.get(Calendar.YEAR);
|
||||
month = calendar.get(Calendar.MONTH);
|
||||
day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
String strbir = year + "-" + (month + 1) + "-" + day;
|
||||
|
||||
mBirthday.setText(strbir);
|
||||
OTONetManager.getInstance(EditProfileActivity.this).setFiled("birthday", strbir, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
if (data.getCode() == 0) {
|
||||
userInfo.getUser().setBirthday(strbir);
|
||||
mBirthday.setText(strbir);
|
||||
|
||||
if (userInfo != null) {
|
||||
userInfo.getUser().setBirthday(strbir);
|
||||
}
|
||||
|
||||
//showData(userInfo);
|
||||
EventBus.getDefault().post(new UpdateFieldEvent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}).setRangDate(startCalendar, endCalendar).isAlphaGradient(true).setCancelText(WordUtil.getNewString(R.string.birthday)).setSubmitColor(getResources().getColor(R.color.blue01)).setSubmitText(WordUtil.getNewString(R.string.complete)).setContentTextSize(20).setDate(selectedDate).build();
|
||||
pvTime.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (cameraUtil != null) {
|
||||
cameraUtil.release();
|
||||
}
|
||||
//MainHttpUtil.cancel(MainHttpConsts.UPDATE_FIELDS);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void showData(UserBean userInfo) {
|
||||
int index = 0;
|
||||
String birthday = userInfo.getUser().getBirthday();
|
||||
String location = userInfo.getUser().getLocation();
|
||||
String bindPhone = userInfo.getUser().getMobile();
|
||||
String sex = "";
|
||||
if (userInfo.getUser().getSex() == 1) {
|
||||
sex = mContext.getString(R.string.sex_male);
|
||||
} else if (userInfo.getUser().getSex() == 2) {
|
||||
sex = mContext.getString(R.string.sex_female);
|
||||
}
|
||||
if (!TextUtils.isEmpty(bindPhone)) {
|
||||
index = index + 1;
|
||||
}
|
||||
if (!TextUtils.isEmpty(location)) {
|
||||
index = index + 1;
|
||||
}
|
||||
if (!TextUtils.isEmpty(birthday)) {
|
||||
index = index + 1;
|
||||
}
|
||||
if (!TextUtils.isEmpty(sex)) {
|
||||
index = index + 1;
|
||||
}
|
||||
if (!userInfo.getUser().getAvatar().contains("http")) {
|
||||
ImgLoader.displayAvatar(mContext, CommonAppConfig.HOST + userInfo.getUser().getAvatar(), mAvatar);
|
||||
} else {
|
||||
ImgLoader.displayAvatar(mContext, userInfo.getUser().getAvatar(), mAvatar);
|
||||
}
|
||||
mName.setText(userInfo.getUser().getUserNicename());
|
||||
mSign.setText(userInfo.getUser().getSignature());
|
||||
mBirthday.setText(userInfo.getUser().getBirthday());
|
||||
if (userInfo.getUser().getSex() == 0) {
|
||||
mSex.setText("");
|
||||
} else if (userInfo.getUser().getSex() == 1) {
|
||||
mSex.setText(R.string.sex_male);
|
||||
} else if (userInfo.getUser().getSex() == 2) {
|
||||
mSex.setText(R.string.sex_female);
|
||||
}
|
||||
tag.setText(userInfo.getInfo().getCn_label());
|
||||
mCity.setText(userInfo.getInfo().getArea());
|
||||
if (!StringUtil.isEmpty(userInfo.getUser().getMobile())) {
|
||||
mobile = userInfo.getUser().getMobile();
|
||||
tv_bind_phone.setText(mobile);
|
||||
isBind = "1";
|
||||
} else {
|
||||
tv_bind_phone.setHint(getResources().getString(R.string.bind_phone_text));
|
||||
isBind = "0";
|
||||
}
|
||||
OTONetManager.getInstance(EditProfileActivity.this).getAuthInfo(new com.yunbao.common.http.base.HttpCallback<AuthBean>() {
|
||||
@Override
|
||||
public void onSuccess(AuthBean data) {
|
||||
authBean = data;
|
||||
if (data.getName_auth() == 2) {//已通过
|
||||
auth_status.setText(R.string.title_audit_config5);
|
||||
auth_status.setTextColor(getResources().getColor(R.color.green_81c160));
|
||||
auth_status.setVisibility(View.INVISIBLE);
|
||||
findViewById(R.id.img_auth_status).setVisibility(View.VISIBLE);
|
||||
} else if (data.getName_auth() == 3) {//已提交
|
||||
auth_status.setText(R.string.title_audit_config4);
|
||||
auth_status.setTextColor(getResources().getColor(R.color.gray1));
|
||||
} else if (data.getName_auth() == 4) {
|
||||
auth_status.setText(R.string.title_audit_config6);
|
||||
auth_status.setTextColor(getResources().getColor(R.color.red));
|
||||
} else {
|
||||
auth_status.setText(R.string.title_audit_config7);
|
||||
auth_status.setTextColor(getResources().getColor(R.color.black2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (Constants.isShowPage != -1) {
|
||||
finish();
|
||||
}
|
||||
if (userInfo.getUser().getLoginType().equals("phone")) {
|
||||
mobile = userInfo.getUser().getMobile();
|
||||
tv_bind_phone.setText(mobile);
|
||||
isBind = "1";
|
||||
} else {
|
||||
tv_bind_phone.setHint(getResources().getString(R.string.bind_phone_text));
|
||||
isBind = "0";
|
||||
}
|
||||
|
||||
// getTaskType();
|
||||
/*if (isName) {
|
||||
isName = false;
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getBaseInfos(false, new com.yunbao.common.http.base.HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
if (data != null) {
|
||||
CommonAppConfig.getInstance().setLoginInfo(CommonAppConfig.getInstance().getUid(), CommonAppConfig.getInstance().getToken(), false);
|
||||
mName.setText(userInfo.getUserNicename());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.shayu.onetoone.activity.user;
|
||||
|
||||
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.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.utils.MainHttpConsts;
|
||||
import com.shayu.onetoone.utils.MainHttpUtil;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/29.
|
||||
* 设置签名
|
||||
*/
|
||||
|
||||
public class EditSignActivity extends AbsActivity {
|
||||
|
||||
private EditText mEditText;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_edit_sign;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.edit_profile_update_sign));
|
||||
mEditText = (EditText) findViewById(R.id.edit);
|
||||
mEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(20)});
|
||||
findViewById(R.id.btSave).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.btSave).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ediSign();
|
||||
}
|
||||
});
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
public void ediSign() {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
final String content = mEditText.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
ToastUtil.show(R.string.edit_profile_sign_empty);
|
||||
return;
|
||||
}
|
||||
|
||||
OTONetManager.getInstance(EditSignActivity.this).setFiled("signature", content, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
if (data.getCode() == 0) {
|
||||
ToastUtil.show(data.getMsg());
|
||||
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(data.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.UPDATE_FIELDS);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BottomListDialogAdapter extends RecyclerView.Adapter<BottomListDialogAdapter.ViewHolder> {
|
||||
private List<String> list;
|
||||
private Context mContext;
|
||||
private OnItemClickListener<String> onItemClickListener;
|
||||
|
||||
public BottomListDialogAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setList(List<String> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public void setContext(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<String> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_dialog_bottom, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
holder.setData(list.get(position),position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView textView;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
textView = itemView.findViewById(R.id.item);
|
||||
}
|
||||
|
||||
public void setData(String data, int position) {
|
||||
textView.setText(data);
|
||||
itemView.setOnClickListener(v -> {
|
||||
onItemClickListener.onItemClick(data, position);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.ExchangeModel;
|
||||
import com.shayu.onetoone.view.DiamondExchangeViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DiamondExchangeAdapter extends RecyclerView.Adapter {
|
||||
private List<ExchangeModel> exchangeModels = new ArrayList<>();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View bodyView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_diamond_exchange_item_holder, parent, false);
|
||||
return new DiamondExchangeViewHolder(bodyView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
DiamondExchangeViewHolder exchangeViewHolder = (DiamondExchangeViewHolder) holder;
|
||||
exchangeViewHolder.showData(exchangeModels.get(position), position);
|
||||
exchangeViewHolder.setListener(new DiamondExchangeViewHolder.DiamondExchangeClickListener() {
|
||||
@Override
|
||||
public void onDiamondExchangeClickListener(ExchangeModel model, int position) {
|
||||
for (int i = 0; i < exchangeModels.size(); i++) {
|
||||
exchangeModels.get(i).setSelect(i == position);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return exchangeModels.size();
|
||||
}
|
||||
|
||||
public void addData(List<ExchangeModel> mExchangeModels) {
|
||||
exchangeModels.clear();
|
||||
exchangeModels.addAll(mExchangeModels);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void unSelect() {
|
||||
for (int i = 0; i < exchangeModels.size(); i++) {
|
||||
exchangeModels.get(i).setSelect(false);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.ExchangeRecordModel;
|
||||
import com.shayu.onetoone.view.ExchangeRecordViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExchangeRecordAdapter extends RecyclerView.Adapter<ExchangeRecordViewHolder> {
|
||||
private List<ExchangeRecordModel> exchangeRecordModels = new ArrayList<>();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ExchangeRecordViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View bodyView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_exchange_record_item_holder, parent, false);
|
||||
return new ExchangeRecordViewHolder(bodyView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ExchangeRecordViewHolder holder, int position) {
|
||||
holder.setData(exchangeRecordModels.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return exchangeRecordModels.size();
|
||||
}
|
||||
|
||||
public void setList(List<ExchangeRecordModel> mExchangeRecordModels) {
|
||||
this.exchangeRecordModels = mExchangeRecordModels;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addLst(List<ExchangeRecordModel> mExchangeRecordModels) {
|
||||
this.exchangeRecordModels.addAll(mExchangeRecordModels);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.GiftBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GiftListAdapter extends RecyclerView.Adapter<GiftListAdapter.ViewHolder> {
|
||||
private Context mContext;
|
||||
private List<GiftBean> list;
|
||||
private int selectPosition = 0;
|
||||
|
||||
public GiftListAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setList(List<GiftBean> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_gift, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
holder.setData(list.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public GiftBean getItem() {
|
||||
return list.get(selectPosition);
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView giftIcon;
|
||||
private TextView giftName;
|
||||
private TextView money;
|
||||
private View select;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
giftIcon = itemView.findViewById(R.id.gift_icon);
|
||||
giftName = itemView.findViewById(R.id.gift_name);
|
||||
money = itemView.findViewById(R.id.money);
|
||||
select = itemView.findViewById(R.id.bg_select);
|
||||
itemView.setOnClickListener(v -> {
|
||||
selectPosition = getAbsoluteAdapterPosition();
|
||||
notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
private void setData(GiftBean giftBean, int position) {
|
||||
giftName.setText(giftBean.getGiftname());
|
||||
money.setText(giftBean.getNeedcoin() + "");
|
||||
ImgLoader.display(itemView.getContext(), giftBean.getGifticon(), giftIcon);
|
||||
select.setVisibility(View.GONE);
|
||||
|
||||
if (position == selectPosition) {
|
||||
select.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
select.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.message.ChatActivity;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||
import com.shayu.onetoone.dialog.TipsDialog;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.shayu.onetoone.utils.ConversationUtils;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HomeHotListAdapter extends RecyclerView.Adapter<HomeHotListAdapter.ViewHolder> {
|
||||
private Context mContext;
|
||||
private List<HomeItemBean> list;
|
||||
|
||||
public HomeHotListAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
list = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
public void setList(List<HomeItemBean> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_home_hot, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
holder.setData(list.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void addList(List<HomeItemBean> data) {
|
||||
list.addAll(data);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private RoundedImageView avatar;
|
||||
private ImageView status;
|
||||
private ImageView chat;
|
||||
private TextView userName;
|
||||
private ImageView sex;
|
||||
private TextView age;
|
||||
private ImageView levelIcon;
|
||||
private ImageView cover;
|
||||
private TextView level;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
level = itemView.findViewById(R.id.level);
|
||||
levelIcon = itemView.findViewById(R.id.ic_level);
|
||||
age = itemView.findViewById(R.id.age);
|
||||
sex = itemView.findViewById(R.id.sex);
|
||||
chat = itemView.findViewById(R.id.btn_chat);
|
||||
userName = itemView.findViewById(R.id.user_name);
|
||||
avatar = itemView.findViewById(R.id.avatar);
|
||||
status = itemView.findViewById(R.id.status);
|
||||
cover = itemView.findViewById(R.id.cover);
|
||||
}
|
||||
|
||||
private void setData(HomeItemBean bean, int position) {
|
||||
userName.setText(bean.getUser_nicename());
|
||||
age.setText(bean.getAge() + "");
|
||||
level.setText("Lv." + bean.getLevel());
|
||||
if (bean.getSex() == 1) {
|
||||
sex.setImageResource(R.mipmap.ic_home_hot_man);
|
||||
} else {
|
||||
sex.setImageResource(R.mipmap.ic_home_hot_woman);
|
||||
}
|
||||
if (bean.getIs_accost() == 1) {
|
||||
chat.setImageResource(R.mipmap.ic_home_hot_chat_up);
|
||||
} else {
|
||||
chat.setImageResource(R.mipmap.ic_home_hot_chat);
|
||||
}
|
||||
cover.setVisibility(View.GONE);
|
||||
status.setImageResource(R.mipmap.ic_home_hot_status_online);
|
||||
if (bean.getOnline() == 1) {
|
||||
cover.setVisibility(View.VISIBLE);
|
||||
status.setImageResource(R.mipmap.ic_home_hot_status_offine);
|
||||
} else if (bean.getOnline() == 2) {
|
||||
status.setImageResource(R.mipmap.ic_home_hot_status_busy);
|
||||
}
|
||||
ImgLoader.display(mContext, bean.getAvatar(), avatar);
|
||||
ViewClicksAntiShake.clicksAntiShake(avatar, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
UserManager.toHomePage(bean.getId());
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(chat, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (bean.getIs_accost() == 0) {
|
||||
ConversationUtils.startConversation(mContext, bean.getId() + "");
|
||||
return;
|
||||
}
|
||||
SendMessageManager.chatUp(bean.getId() + "", new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean sb) {
|
||||
super.onSuccess(token, sb);
|
||||
System.out.println("搭讪回调:" + JSONObject.toJSONString(sb));
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("token", token);
|
||||
bundle.putInt("type", ChatActivity.CALL_CHAT_TYPE_CHAT_UP);
|
||||
bundle.putString("data", JSONObject.toJSONString(sb));
|
||||
ConversationUtils.startConversation(mContext, bean.getId() + "", bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg, SendConsumeBean bean) {
|
||||
super.onError(status, msg, bean);
|
||||
if (status == OnSendMessageListener.STATUS_NOT_PRICE) {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.money_title))
|
||||
.setApplyText(WordUtil.getNewString(R.string.money_apply))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
}
|
||||
})
|
||||
.setCancelText(WordUtil.getNewString(R.string.money_cancel))
|
||||
.showDialog();
|
||||
} else {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(msg)
|
||||
.showDialog();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.home.HomeRankFragment;
|
||||
import com.shayu.onetoone.bean.FollowBean;
|
||||
import com.shayu.onetoone.bean.HomeRankBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HomeRankListAdapter extends RecyclerView.Adapter<HomeRankListAdapter.ViewHolder> {
|
||||
private Context mContext;
|
||||
private List<HomeRankBean> list;
|
||||
private int type;
|
||||
|
||||
public HomeRankListAdapter(Context mContext, int type) {
|
||||
this.mContext = mContext;
|
||||
this.type = type;
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_home_rank, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
holder.setData(list.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void setList(List<HomeRankBean> data) {
|
||||
this.list = data;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void add(HomeRankBean homeRankBean) {
|
||||
this.list.add(homeRankBean);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
list.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView rank;
|
||||
private RoundedImageView avatar;
|
||||
private ImageView sex;
|
||||
private TextView user_name;
|
||||
private TextView level;
|
||||
private ImageView ic_level;
|
||||
private TextView money;
|
||||
private Button follow;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
rank = itemView.findViewById(R.id.rank);
|
||||
avatar = itemView.findViewById(R.id.avatar);
|
||||
sex = itemView.findViewById(R.id.sex);
|
||||
user_name = itemView.findViewById(R.id.user_name);
|
||||
level = itemView.findViewById(R.id.level);
|
||||
ic_level = itemView.findViewById(R.id.ic_level);
|
||||
money = itemView.findViewById(R.id.money);
|
||||
follow = itemView.findViewById(R.id.follow);
|
||||
}
|
||||
|
||||
private void setData(HomeRankBean bean, int position) {
|
||||
rank.setText(position + 4 + "");
|
||||
user_name.setText(bean.getUserNicename());
|
||||
money.setText(bean.getMoney());
|
||||
|
||||
if (bean.getSex() == 1) {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_man);
|
||||
} else {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_woman);
|
||||
}
|
||||
if (bean.isFollow()) {
|
||||
follow.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
follow.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (type == HomeRankFragment.TYPE_CHARM) {
|
||||
level.setText("Lv." + bean.getCharmLevel());
|
||||
} else {
|
||||
level.setText("Lv." + bean.getWealthLevel());
|
||||
}
|
||||
ImgLoader.display(mContext, bean.getAvatar(), avatar);
|
||||
if(bean.getUid().equals(UserManager.getUserBean().getUser().getId()+"")){
|
||||
follow.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
follow.setText(R.string.layout_home_ranking_tips1);
|
||||
follow.setTag(bean.getUid());
|
||||
ViewClicksAntiShake.clicksAntiShake(avatar, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
UserManager.toHomePage(bean.getUid());
|
||||
}
|
||||
});
|
||||
follow.setOnClickListener(v -> {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.follow(v.getTag().toString(), new HttpCallback<FollowBean>() {
|
||||
@Override
|
||||
public void onSuccess(FollowBean data) {
|
||||
ToastUtil.show(WordUtil.getNewString(R.string.system_tip_success));
|
||||
v.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.message.ChatActivity;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.bean.SendConsumeBean;
|
||||
import com.shayu.onetoone.dialog.TipsDialog;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.shayu.onetoone.utils.ConversationUtils;
|
||||
import com.shayu.onetoone.utils.UserManager;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HomeRecommendListAdapter extends RecyclerView.Adapter<HomeRecommendListAdapter.ViewHolder> {
|
||||
private Context mContext;
|
||||
private List<HomeItemBean> list;
|
||||
|
||||
public HomeRecommendListAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_home_recommend, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
holder.setData(list.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void setList(List<HomeItemBean> data) {
|
||||
this.list = data;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addLst(List<HomeItemBean> data) {
|
||||
this.list.addAll(data);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private RoundedImageView avatar;
|
||||
private ImageView chat;
|
||||
private TextView userName;
|
||||
private ImageView sex;
|
||||
private ImageView auth;
|
||||
private TextView star;
|
||||
private TextView sign;
|
||||
private TextView level;
|
||||
private LinearLayout tagLayout;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
star = itemView.findViewById(R.id.star_up);
|
||||
sex = itemView.findViewById(R.id.sex);
|
||||
chat = itemView.findViewById(R.id.btn_chat_up);
|
||||
userName = itemView.findViewById(R.id.user_name);
|
||||
avatar = itemView.findViewById(R.id.avatar);
|
||||
tagLayout = itemView.findViewById(R.id.user_tag_layout);
|
||||
sign = itemView.findViewById(R.id.user_sign);
|
||||
auth = itemView.findViewById(R.id.auth);
|
||||
level = itemView.findViewById(R.id.level);
|
||||
}
|
||||
|
||||
private void setData(HomeItemBean itemBean, int position) {
|
||||
star.setText(itemBean.getAge() + "·" + itemBean.getStar_name());
|
||||
sign.setText(itemBean.getSignature());
|
||||
userName.setText(itemBean.getUser_nicename());
|
||||
level.setText("Lv."+itemBean.getLevel());
|
||||
tagLayout.removeAllViews();
|
||||
tagLayout.addView(star);
|
||||
if (WordUtil.isNewZh()) {
|
||||
addTag(itemBean.getCn_label());
|
||||
} else {
|
||||
addTag(itemBean.getEn_label());
|
||||
}
|
||||
if (itemBean.getSex() == 1) {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_man);
|
||||
} else {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_woman);
|
||||
}
|
||||
if (itemBean.getName_auth() == 2) {
|
||||
auth.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
auth.setVisibility(View.GONE);
|
||||
}
|
||||
if (itemBean.getIs_accost() == 1) {
|
||||
chat.setImageResource(R.mipmap.ic_home_recommend_chat_up);
|
||||
} else {
|
||||
chat.setImageResource(R.mipmap.ic_home_recommend_chat);
|
||||
}
|
||||
ImgLoader.display(mContext, itemBean.getAvatar(), avatar);
|
||||
ViewClicksAntiShake.clicksAntiShake(avatar, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
UserManager.toHomePage(itemBean.getId());
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(chat, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (itemBean.getIs_accost() == 0) {
|
||||
ConversationUtils.startConversation(mContext, itemBean.getId() + "");
|
||||
return;
|
||||
}
|
||||
SendMessageManager.chatUp(itemBean.getId() + "", new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token, SendConsumeBean bean) {
|
||||
super.onSuccess(token, bean);
|
||||
System.out.println("搭讪回调:" + JSONObject.toJSONString(bean));
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("token", token);
|
||||
bundle.putInt("type", ChatActivity.CALL_CHAT_TYPE_CHAT_UP);
|
||||
bundle.putString("data", JSONObject.toJSONString(bean));
|
||||
ConversationUtils.startConversation(mContext, itemBean.getId() + "", bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg, SendConsumeBean bean) {
|
||||
super.onError(status, msg, bean);
|
||||
if (status == OnSendMessageListener.STATUS_NOT_PRICE) {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(WordUtil.getNewString(R.string.money_title))
|
||||
.setApplyText(WordUtil.getNewString(R.string.money_apply))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
}
|
||||
})
|
||||
.showDialog();
|
||||
} else {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle(msg)
|
||||
.showDialog();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addTag(List<String> tags) {
|
||||
for (String tag : tags) {
|
||||
if (StringUtil.isEmpty(tag)) {
|
||||
continue;
|
||||
}
|
||||
TextView tagView = (TextView) LayoutInflater.from(mContext).inflate(R.layout.item_home_recommend_tag, (ViewGroup) itemView.getRootView(), false);
|
||||
tagView.setText(tag);
|
||||
tagLayout.addView(tagView);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.LabelBean;
|
||||
import com.xuexiang.xui.widget.flowlayout.BaseTagAdapter;
|
||||
|
||||
public class LabelChooseTagAdapter extends BaseTagAdapter<LabelBean.Children, TextView> {
|
||||
|
||||
OnSureOnClickListener onSureOnClickListener;
|
||||
|
||||
Context mContext;
|
||||
|
||||
public LabelChooseTagAdapter(Context context, OnSureOnClickListener onSureOnClickListener) {
|
||||
super(context);
|
||||
this.onSureOnClickListener = onSureOnClickListener;
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
public LabelChooseTagAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextView newViewHolder(View convertView) {
|
||||
return (TextView) convertView.findViewById(R.id.tv_tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.adapter_item_tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(TextView textView, LabelBean.Children item, int position) {
|
||||
textView.setText(item.getCn_title());
|
||||
if (item.isSelect()) {
|
||||
textView.setBackground(getDrawable(R.drawable.bg_rect_round_tag_btn1));
|
||||
textView.setTextColor(mContext.getResources().getColor(R.color.white));
|
||||
} else {
|
||||
textView.setBackground(getDrawable(R.drawable.bg_rect_round_tag_btn));
|
||||
textView.setTextColor(mContext.getResources().getColor(R.color.black2));
|
||||
}
|
||||
textView.setOnClickListener(v -> {
|
||||
item.setSelect(!item.isSelect());
|
||||
onSureOnClickListener.sure(item);
|
||||
notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
public interface OnSureOnClickListener {
|
||||
void sure(LabelBean.Children labelBean);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.LabelBean;
|
||||
import com.xuexiang.xui.widget.flowlayout.BaseTagAdapter;
|
||||
|
||||
public class LabelTagAdapter extends BaseTagAdapter<LabelBean.Children, TextView> {
|
||||
|
||||
OnSureOnClickListener onSureOnClickListener;
|
||||
|
||||
Context mContext;
|
||||
|
||||
public LabelTagAdapter(Context context, OnSureOnClickListener onSureOnClickListener) {
|
||||
super(context);
|
||||
this.onSureOnClickListener = onSureOnClickListener;
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
public LabelTagAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextView newViewHolder(View convertView) {
|
||||
return (TextView) convertView.findViewById(R.id.tv_tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.adapter_item_tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(TextView textView, LabelBean.Children item, int position) {
|
||||
textView.setText(item.getCn_title());
|
||||
textView.setBackground(getDrawable(R.drawable.bg_rect_round_tag_btn));
|
||||
textView.setTextColor(mContext.getResources().getColor(R.color.black2));
|
||||
}
|
||||
|
||||
public interface OnSureOnClickListener {
|
||||
void sure(LabelBean.Children labelBean);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.LabelBean;
|
||||
import com.xuexiang.xui.widget.flowlayout.FlowTagLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LableChooseAdapter extends RecyclerView.Adapter<LableChooseAdapter.ViewHolder> {
|
||||
private Context mContext;
|
||||
private List<LabelBean> list;
|
||||
private int selectPosition = 0;
|
||||
|
||||
public onItemLabelClicklistener onItemLabelClicklistener;
|
||||
|
||||
public LableChooseAdapter(Context mContext, onItemLabelClicklistener onItemLabelClicklistener) {
|
||||
this.mContext = mContext;
|
||||
list = new ArrayList<>();
|
||||
this.onItemLabelClicklistener = onItemLabelClicklistener;
|
||||
}
|
||||
|
||||
public void setList(List<LabelBean> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.adapter_choose_label, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
holder.setData(list.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public LabelBean getItem() {
|
||||
return list.get(selectPosition);
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private FlowTagLayout flowTagLayout;
|
||||
private TextView title;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
flowTagLayout = itemView.findViewById(R.id.myFlowTag);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
}
|
||||
|
||||
private void setData(LabelBean labelBean, int position) {
|
||||
LabelChooseTagAdapter tagAdapter1 = new LabelChooseTagAdapter(mContext, new LabelChooseTagAdapter.OnSureOnClickListener() {
|
||||
@Override
|
||||
public void sure(LabelBean.Children labelBean) {
|
||||
if (onItemLabelClicklistener != null) {
|
||||
onItemLabelClicklistener.onChoose(labelBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
flowTagLayout.setAdapter(tagAdapter1);
|
||||
flowTagLayout.setTagCheckedMode(FlowTagLayout.FLOW_TAG_CHECKED_NONE);
|
||||
tagAdapter1.setData(labelBean.getChildren());
|
||||
title.setText(labelBean.getCn_title());
|
||||
title.setTag(labelBean);
|
||||
}
|
||||
}
|
||||
|
||||
public interface onItemLabelClicklistener {
|
||||
void onChoose(LabelBean.Children children);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shayu.onetoone.bean.UserItemBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/28.
|
||||
*/
|
||||
|
||||
public class MainMeAdapter extends RecyclerView.Adapter<MainMeAdapter.Vh> {
|
||||
|
||||
private static final int NORMAL = 0;
|
||||
private static final int GROUP_LAST = 1;
|
||||
private static final int ALL_LAST = 2;
|
||||
|
||||
private Context mContext;
|
||||
private List<UserItemBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private OnItemClickListener<UserItemBean> mOnItemClickListener;
|
||||
|
||||
public MainMeAdapter(Context context, List<UserItemBean> list) {
|
||||
mContext = context;
|
||||
mList = list;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<UserItemBean> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
UserItemBean bean = mList.get(position);
|
||||
/*if (bean.isGroupLast()) {
|
||||
return GROUP_LAST;
|
||||
} else if (bean.isAllLast()) {
|
||||
return ALL_LAST;
|
||||
} else {
|
||||
return NORMAL;
|
||||
}*/
|
||||
return NORMAL;
|
||||
}
|
||||
|
||||
|
||||
public void setList(List<UserItemBean> list) {
|
||||
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 = com.shayu.onetoone.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(com.shayu.onetoone.R.id.thumb);
|
||||
mName = (TextView) itemView.findViewById(com.shayu.onetoone.R.id.name);
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView, () -> {
|
||||
Object tag = itemView.getTag();
|
||||
if (tag != null) {
|
||||
UserItemBean bean = (UserItemBean) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void setData(UserItemBean bean) {
|
||||
itemView.setTag(bean);
|
||||
ImgLoader.display(mContext, bean.getThumb(), mThumb);
|
||||
mName.setText(bean.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.SystemMessageBean;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.view.SystemNoticeUiMessage;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import io.rong.imkit.conversation.MessageListAdapter;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imkit.widget.adapter.IViewProviderListener;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
|
||||
public class MessageInteractionConversationListAdapter extends MessageListAdapter {
|
||||
|
||||
public MessageInteractionConversationListAdapter(IViewProviderListener<UiMessage> listener) {
|
||||
super(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return ViewHolder.createViewHolder(parent.getContext(), parent, R.layout.item_interaction_msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataCollection(List<UiMessage> data) {
|
||||
super.setDataCollection(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
SystemMessageBean bean = ((SystemNoticeUiMessage) getData().get(position)).getBean();
|
||||
holder.setText(R.id.content, bean.getContent());
|
||||
holder.setText(R.id.text, bean.getUser_nicename());
|
||||
holder.setText(R.id.time, new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()).format(new Date(bean.getAddtime() * 1000)));
|
||||
ImgLoader.display(holder.getContext(), bean.getAvatar(), holder.getView(R.id.ico));
|
||||
//ImgLoader.display(holder.getContext(), bean.getAvatar(), holder.getView(R.id.img_item_interaction));//右侧头像
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.SystemMessageBean;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.view.SystemNoticeUiMessage;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import io.rong.imkit.conversation.MessageListAdapter;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imkit.widget.adapter.IViewProviderListener;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
|
||||
public class MessageNoticeConversationListAdapter extends MessageListAdapter {
|
||||
|
||||
public MessageNoticeConversationListAdapter(IViewProviderListener<UiMessage> listener) {
|
||||
super(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return ViewHolder.createViewHolder(parent.getContext(), parent, R.layout.item_sys_msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataCollection(List<UiMessage> data) {
|
||||
super.setDataCollection(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
SystemMessageBean bean = ((SystemNoticeUiMessage) getData().get(position)).getBean();
|
||||
holder.setText(R.id.content, bean.getContent());
|
||||
holder.setText(R.id.text, bean.getTitle());
|
||||
holder.setText(R.id.time, new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()).format(new Date(bean.getAddtime() * 1000)));
|
||||
|
||||
if (StringUtil.isEmpty(bean.getBanner())) {
|
||||
holder.setVisible(R.id.cv_img_content, false);
|
||||
} else {
|
||||
holder.setVisible(R.id.cv_img_content, true);
|
||||
ImgLoader.display(holder.getContext(), bean.getBanner(), holder.getView(R.id.img_content));
|
||||
}
|
||||
holder.setOnClickListener(R.id.bg, new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
RouteManager.forwardWebViewActivity(bean.getTitle(), bean.getLink());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
|
||||
import io.rong.imkit.conversation.MessageListAdapter;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imkit.widget.adapter.IViewProviderListener;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
import io.rong.imlib.model.Message;
|
||||
|
||||
public class MsgChatMessageListAdapter extends MessageListAdapter {
|
||||
public MsgChatMessageListAdapter(IViewProviderListener<UiMessage> listener) {
|
||||
super(listener);
|
||||
}
|
||||
//onCreateMessageContentViewH
|
||||
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return super.onCreateViewHolder(parent, viewType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
super.onBindViewHolder(holder, position);
|
||||
if(getData().get(position).getMessageDirection()== Message.MessageDirection.SEND) {
|
||||
holder.setTextColor(R.id.rc_text, Color.WHITE);
|
||||
}else{
|
||||
holder.setTextColor(R.id.rc_text, Color.parseColor("#555555"));
|
||||
}
|
||||
}
|
||||
|
||||
public int getPosition(int messageId) {
|
||||
for (int i = 0; i < getData().size(); i++) {
|
||||
if (getData().get(i).getMessageId() == messageId){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.GreetBean;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 打招呼设置适配器
|
||||
*/
|
||||
public class MsgGreetConfigAdapter extends RecyclerView.Adapter<MsgGreetConfigAdapter.ViewHolder> {
|
||||
List<GreetBean> mList;
|
||||
Context mContext;
|
||||
OnItemClickListener<GreetBean> deleteListener;
|
||||
Handler handler;
|
||||
public static final String TAG="打招呼列表";
|
||||
|
||||
public MsgGreetConfigAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
this.mList = new ArrayList<>();
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
|
||||
public void setList(List<GreetBean> mList) {
|
||||
if (mList.isEmpty()) {
|
||||
GreetBean bean = new GreetBean();
|
||||
mList.add(bean);
|
||||
}
|
||||
this.mList = mList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setDeleteListener(OnItemClickListener<GreetBean> deleteListener) {
|
||||
this.deleteListener = deleteListener;
|
||||
}
|
||||
|
||||
public List<GreetBean> getNotEmptyList() {
|
||||
List<GreetBean> tmp = new ArrayList<>();
|
||||
for (GreetBean bean : mList) {
|
||||
if (!StringUtil.isEmpty(bean.getContent())) {
|
||||
tmp.add(bean);
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public List<GreetBean> getmList() {
|
||||
return mList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_msg_greet_config, viewGroup, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
|
||||
viewHolder.setData(mList.get(i), i);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
public void addItem(GreetBean GreetBean) {
|
||||
mList.add(GreetBean);
|
||||
notifyItemChanged(getItemCount() - 1);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
mList.clear();
|
||||
notifyDataSetChanged();
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
mList.add(new GreetBean());
|
||||
notifyDataSetChanged();
|
||||
}, 300);
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private EditText editText;
|
||||
private View edit;
|
||||
private View del;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
editText = itemView.findViewById(R.id.editTextText);
|
||||
edit = itemView.findViewById(R.id.edit);
|
||||
del = itemView.findViewById(R.id.del);
|
||||
editText.setEnabled(false);
|
||||
itemView.setOnClickListener(v -> notifyDataSetChanged());
|
||||
}
|
||||
|
||||
public void setData(GreetBean bean, int position) {
|
||||
editText.clearFocus();
|
||||
del.setOnClickListener(v -> {
|
||||
notifyDataSetChanged();
|
||||
handler.postDelayed(() -> {
|
||||
editText.setEnabled(false);
|
||||
mList.remove(position);
|
||||
if (deleteListener != null) {
|
||||
deleteListener.onItemClick(bean, mList.size());
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}, 50);
|
||||
|
||||
|
||||
});
|
||||
Log.i(TAG, position+"|"+bean.getContent()+"||"+mList.size());
|
||||
edit.setOnClickListener(v -> {
|
||||
mList.get(position).setEdit(true);
|
||||
editText.setEnabled(true);
|
||||
editText.requestFocus();
|
||||
});
|
||||
if (bean.getContent() == null) {
|
||||
editText.setEnabled(true);
|
||||
editText.setText("");
|
||||
editText.requestFocus();
|
||||
} else {
|
||||
editText.setText(bean.getContent());
|
||||
editText.setEnabled(false);
|
||||
}
|
||||
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(50)});
|
||||
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (!hasFocus && editText.getText().toString().length() > 0 && mList.size() > position) {
|
||||
mList.get(position).setContent(editText.getText().toString());
|
||||
editText.setEnabled(false);
|
||||
Log.d(TAG, "设置文本:"+position+" → "+editText.getText().toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.text.SpannableString;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.MessageChatAuthContent;
|
||||
import com.shayu.onetoone.bean.MessageChatGiftContent;
|
||||
import com.shayu.onetoone.bean.MessageChatTipsContent;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.rong.imkit.conversationlist.ConversationListAdapter;
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
import io.rong.imkit.conversationlist.model.SingleConversation;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
|
||||
/**
|
||||
* 聊天列表适配器
|
||||
*/
|
||||
public class MsgMessageRecyclerViewAdapter extends ConversationListAdapter {
|
||||
List<BaseUiConversation> conversationList = null;
|
||||
Map<Integer, SingleConversation> map = new HashMap<>();
|
||||
|
||||
SwipeRecyclerView mList;
|
||||
|
||||
public MsgMessageRecyclerViewAdapter(SwipeRecyclerView mList) {
|
||||
this.mList = mList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
BaseUiConversation conversation = getData().get(position);
|
||||
String targetId = conversation.mCore.getTargetId();
|
||||
try {
|
||||
int type = Integer.parseInt(targetId);
|
||||
mList.setSwipeItemMenuEnabled(position, type > 100);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
super.onBindViewHolder(holder, position);
|
||||
if(conversation.mCore.getUnreadMessageCount()>99){
|
||||
holder.setText(R.id.rc_conversation_unread_count,"99+");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataCollection(List<BaseUiConversation> data) {
|
||||
conversationList = new ArrayList<>(data);
|
||||
List<BaseUiConversation> top = new ArrayList<>();
|
||||
List<BaseUiConversation> data2 = new ArrayList<>();
|
||||
for (BaseUiConversation datum : data) {
|
||||
System.out.println("接收到的Tid=" + datum.mCore.getTargetId());
|
||||
try {
|
||||
int parseInt = Integer.parseInt(datum.mCore.getTargetId());
|
||||
if (parseInt < 100) {
|
||||
continue;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
if (datum.mCore.getConversationType() == Conversation.ConversationType.PRIVATE || datum.mCore.getConversationType() == Conversation.ConversationType.SYSTEM) {
|
||||
if (datum.mCore.getLatestMessage() instanceof MessageChatGiftContent) {
|
||||
datum.mConversationContent = new SpannableString(WordUtil.getNewString(R.string.gift));
|
||||
} else if (datum.mCore.getLatestMessage() instanceof MessageChatAuthContent) {
|
||||
datum.mConversationContent = new SpannableString(WordUtil.getNewString(R.string.authentication));
|
||||
}else if(datum.mCore.getLatestMessage() instanceof MessageChatTipsContent){
|
||||
datum.mConversationContent = new SpannableString(WordUtil.getNewString(R.string.system_tips));
|
||||
}
|
||||
if (datum.mCore.isTop()) {
|
||||
top.add(datum);
|
||||
} else {
|
||||
data2.add(datum);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<BaseUiConversation> list = new ArrayList<>(top);
|
||||
data2.addAll(map.values());
|
||||
Collections.sort(data2, new ListComparator());
|
||||
list.addAll(data2);
|
||||
|
||||
super.setDataCollection(list);
|
||||
}
|
||||
|
||||
|
||||
public void add(SingleConversation item, int position) {
|
||||
map.put(position, item);
|
||||
}
|
||||
|
||||
public void clearSystemNotification() {
|
||||
for (BaseUiConversation conversation : map.values()) {
|
||||
conversation.mCore.setUnreadMessageCount(0);
|
||||
}
|
||||
}
|
||||
|
||||
public SingleConversation getSystemItem(int position) {
|
||||
return map.get(position);
|
||||
}
|
||||
|
||||
public BaseUiConversation getItem(int position) {
|
||||
return mDataList.get(position);
|
||||
}
|
||||
|
||||
private class ListComparator implements Comparator<BaseUiConversation> {
|
||||
|
||||
@Override
|
||||
public int compare(BaseUiConversation baseUiConversation, BaseUiConversation t1) {
|
||||
return (int) (t1.mCore.getSentTime() - baseUiConversation.mCore.getSentTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.FriendAppMoneyLogModel;
|
||||
import com.shayu.onetoone.view.MyArnViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MyArnAdapter extends RecyclerView.Adapter {
|
||||
private List<FriendAppMoneyLogModel> friendAppMoneyLogModels = new ArrayList<>();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View bodyView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_my_arn_item_holder, parent, false);
|
||||
return new MyArnViewHolder(bodyView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
MyArnViewHolder arnViewHolder = (MyArnViewHolder) holder;
|
||||
arnViewHolder.setData(friendAppMoneyLogModels.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return friendAppMoneyLogModels.size();
|
||||
}
|
||||
|
||||
public void showData(List<FriendAppMoneyLogModel> mFriendAppMoneyLogModels) {
|
||||
friendAppMoneyLogModels.clear();
|
||||
friendAppMoneyLogModels.addAll(mFriendAppMoneyLogModels);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addLst(List<FriendAppMoneyLogModel> mFriendAppMoneyLogModels) {
|
||||
this.friendAppMoneyLogModels.addAll(mFriendAppMoneyLogModels);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.FollowBean;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MyFriendListAdapter extends RecyclerView.Adapter<MyFriendListAdapter.ViewHolder> {
|
||||
List<HomeItemBean> list;
|
||||
Context context;
|
||||
|
||||
public MyFriendListAdapter(Context context) {
|
||||
this.context = context;
|
||||
list=new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setList(List<HomeItemBean> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_my_follow, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
holder.setDate(list.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void addList(List<HomeItemBean> data) {
|
||||
this.list.addAll(data);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private RoundedImageView avatar;
|
||||
private ImageView sex;
|
||||
private TextView uname;
|
||||
private TextView starUp;
|
||||
private Button submit;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
avatar = itemView.findViewById(R.id.avatar);
|
||||
sex = itemView.findViewById(R.id.sex);
|
||||
uname = itemView.findViewById(R.id.uname);
|
||||
starUp = itemView.findViewById(R.id.star_up);
|
||||
submit = itemView.findViewById(R.id.submit);
|
||||
}
|
||||
|
||||
void setDate(HomeItemBean bean, int position) {
|
||||
ImgLoader.display(context, bean.getAvatar(), avatar);
|
||||
uname.setText(bean.getUser_nicename());
|
||||
starUp.setText(bean.getAge() + "·" + bean.getStar_name());
|
||||
if (bean.getSex() == 1) {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_man);
|
||||
} else {
|
||||
sex.setImageResource(R.mipmap.ic_message_tab_woman);
|
||||
}
|
||||
//isAttention 0 未关注 1被关注 2已关注 3互相关注
|
||||
submit.setEnabled(true);
|
||||
switch (bean.getIsAttention()) {
|
||||
case 1:
|
||||
submit.setText(R.string.activity_my_friend_list_item_1);
|
||||
break;
|
||||
case 2:
|
||||
submit.setText(R.string.activity_my_friend_list_item_2);
|
||||
submit.setEnabled(false);
|
||||
break;
|
||||
case 3:
|
||||
submit.setText(R.string.activity_my_friend_list_item_3);
|
||||
submit.setEnabled(false);
|
||||
break;
|
||||
default:
|
||||
submit.setText(R.string.activity_my_friend_list_item_0);
|
||||
}
|
||||
submit.setOnClickListener(v -> follow(bean.getId() + "", submit));
|
||||
|
||||
}
|
||||
|
||||
private void follow(String targetId, Button follow) {
|
||||
OTONetManager.getInstance(context)
|
||||
.follow(targetId, new HttpCallback<FollowBean>() {
|
||||
@Override
|
||||
public void onSuccess(FollowBean data) {
|
||||
ToastUtil.show(WordUtil.getNewString(R.string.system_tip_success));
|
||||
follow.setEnabled(false);
|
||||
follow.setText(R.string.activity_my_friend_list_item_3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.SearchUserBean;
|
||||
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.bean.LiveBean;
|
||||
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.http.LiveHttpUtil;
|
||||
import com.yunbao.common.utils.CommonIconUtil;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
|
||||
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 =mContext.getString(R.string.follow);
|
||||
mFollowing =mContext.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 void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
RouteUtil.forwardUserHome(mContext, live_id, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.yunbao.common.bean.UserAvatarSelectBean;
|
||||
import com.yunbao.common.custom.RatioRoundImageView;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UserAvatarSelectAdapter extends RecyclerView.Adapter<UserAvatarSelectAdapter.AvatarSelectViewHolder> {
|
||||
private Context mContext;
|
||||
private List<UserAvatarSelectBean> list = new ArrayList<>();
|
||||
private OnItemClickListener<UserAvatarSelectBean> onClickListener;
|
||||
private int selectId = -1;
|
||||
private int defId = -1;
|
||||
private UserAvatarSelectBean selectInfo;
|
||||
|
||||
public void setList(List<UserAvatarSelectBean> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public int getSelect() {
|
||||
if (selectId == -1 && getItemCount() > 0) {
|
||||
return list.get(0).getId();
|
||||
}
|
||||
return selectId;
|
||||
}
|
||||
|
||||
public void setOnClickListener(OnItemClickListener<UserAvatarSelectBean> onClickListener) {
|
||||
this.onClickListener = onClickListener;
|
||||
}
|
||||
|
||||
public int getDefId() {
|
||||
return defId;
|
||||
}
|
||||
|
||||
public UserAvatarSelectAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public AvatarSelectViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new AvatarSelectViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_user_avatar_select, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull AvatarSelectViewHolder holder, int position) {
|
||||
holder.setData(list.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void setDef(int id) {
|
||||
this.defId = id;
|
||||
}
|
||||
|
||||
public class AvatarSelectViewHolder extends RecyclerView.ViewHolder {
|
||||
private View hide;
|
||||
private View show;
|
||||
private RatioRoundImageView avatar;
|
||||
|
||||
public AvatarSelectViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
hide = itemView.findViewById(R.id.hideCover);
|
||||
show = itemView.findViewById(R.id.showCover);
|
||||
avatar = itemView.findViewById(R.id.avatar);
|
||||
itemView.setOnClickListener(v -> {
|
||||
selectInfo = (UserAvatarSelectBean) v.getTag();
|
||||
selectId = selectInfo.getId();
|
||||
notifyDataSetChanged();
|
||||
onClickListener.onItemClick(selectInfo, defId);
|
||||
});
|
||||
}
|
||||
|
||||
public void setData(UserAvatarSelectBean bean, int position) {
|
||||
ImgLoader.display(itemView.getContext(), bean.getPath(), avatar);
|
||||
if (selectId == -1 && bean.getChecked() == 1) {
|
||||
selectId = bean.getId();
|
||||
defId = bean.getId();
|
||||
selectInfo = bean;
|
||||
}
|
||||
hide.setVisibility(View.GONE);
|
||||
/*if (select == bean.getId()) {
|
||||
show.setVisibility(View.VISIBLE);
|
||||
hide.setVisibility(View.GONE);
|
||||
} else {
|
||||
show.setVisibility(View.INVISIBLE);
|
||||
hide.setVisibility(View.VISIBLE);
|
||||
}*/
|
||||
itemView.setTag(bean);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
56
OneToOne/src/main/java/com/shayu/onetoone/bean/AuthBean.java
Normal file
56
OneToOne/src/main/java/com/shayu/onetoone/bean/AuthBean.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class AuthBean extends BaseModel {
|
||||
private int name_auth; //审核状态 1未提交 2通过 3已提交 4驳回
|
||||
private String auth_front; //身份证正面
|
||||
private String auth_back; //身份证反面
|
||||
private String auth_remark; //审核备注
|
||||
|
||||
public AuthBean(int name_auth, String auth_front, String auth_back, String auth_remark) {
|
||||
this.name_auth = name_auth;
|
||||
this.auth_front = auth_front;
|
||||
this.auth_back = auth_back;
|
||||
this.auth_remark = auth_remark;
|
||||
}
|
||||
|
||||
public int getName_auth() {
|
||||
return name_auth;
|
||||
}
|
||||
|
||||
public void setName_auth(int name_auth) {
|
||||
this.name_auth = name_auth;
|
||||
}
|
||||
|
||||
public String getAuth_front() {
|
||||
return auth_front;
|
||||
}
|
||||
|
||||
public void setAuth_front(String auth_front) {
|
||||
this.auth_front = auth_front;
|
||||
}
|
||||
|
||||
public String getAuth_back() {
|
||||
return auth_back;
|
||||
}
|
||||
|
||||
public void setAuth_back(String auth_back) {
|
||||
this.auth_back = auth_back;
|
||||
}
|
||||
|
||||
public String getAuth_remark() {
|
||||
return auth_remark;
|
||||
}
|
||||
|
||||
public void setAuth_remark(String auth_remark) {
|
||||
this.auth_remark = auth_remark;
|
||||
}
|
||||
|
||||
public AuthBean() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class AuthBloggerBean extends BaseModel {
|
||||
private String mobile;
|
||||
private String card_img;
|
||||
private String remark;
|
||||
private String name;
|
||||
private String card_no;
|
||||
private int sex;
|
||||
private int status; //审核状态 1未提交 2通过 3已提交 4驳回
|
||||
|
||||
public AuthBloggerBean() {
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getCard_img() {
|
||||
return card_img;
|
||||
}
|
||||
|
||||
public void setCard_img(String card_img) {
|
||||
this.card_img = card_img;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCard_no() {
|
||||
return card_no;
|
||||
}
|
||||
|
||||
public void setCard_no(String card_no) {
|
||||
this.card_no = card_no;
|
||||
}
|
||||
|
||||
public int getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(int sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class AvatarBean extends BaseModel {
|
||||
private String avatar;
|
||||
private String avatarThumb;
|
||||
|
||||
public AvatarBean() {
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getAvatarThumb() {
|
||||
return avatarThumb;
|
||||
}
|
||||
|
||||
public void setAvatarThumb(String avatarThumb) {
|
||||
this.avatarThumb = avatarThumb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
public class BindPhoneEvent {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CustomBean extends BaseModel {
|
||||
|
||||
public int code;
|
||||
public String msg;
|
||||
public List<String> info;
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setInfo(List<String> info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public List<String> getInfo() {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class ExchangeModel extends BaseModel {
|
||||
|
||||
@SerializedName("top")
|
||||
private String top;
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
@SerializedName("title")
|
||||
private String title;
|
||||
@SerializedName("num")
|
||||
private String num;
|
||||
@SerializedName("sum")
|
||||
private String sum;
|
||||
|
||||
private boolean select = false;
|
||||
|
||||
public boolean isSelect() {
|
||||
return select;
|
||||
}
|
||||
|
||||
public ExchangeModel setSelect(boolean select) {
|
||||
this.select = select;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSum() {
|
||||
return sum;
|
||||
}
|
||||
|
||||
public void setSum(String sum) {
|
||||
this.sum = sum;
|
||||
}
|
||||
|
||||
public String getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public ExchangeModel setTop(String top) {
|
||||
this.top = top;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ExchangeModel setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public ExchangeModel setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public ExchangeModel setNum(String num) {
|
||||
this.num = num;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class ExchangeRecordModel extends BaseModel {
|
||||
|
||||
@SerializedName("id")
|
||||
private int id;
|
||||
@SerializedName("uid")
|
||||
private int uid;
|
||||
@SerializedName("income")
|
||||
private int income;
|
||||
@SerializedName("before_money")
|
||||
private String beforeMoney;
|
||||
@SerializedName("money")
|
||||
private String money;
|
||||
@SerializedName("after_money")
|
||||
private String afterMoney;
|
||||
@SerializedName("memo")
|
||||
private String memo;
|
||||
@SerializedName("type")
|
||||
private String type;
|
||||
@SerializedName("currency_type")
|
||||
private String currencyType;
|
||||
@SerializedName("service_id")
|
||||
private String serviceId;
|
||||
@SerializedName("create_time")
|
||||
private long createTime;
|
||||
@SerializedName("tuid")
|
||||
private int tuid;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setId(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setUid(int uid) {
|
||||
this.uid = uid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getIncome() {
|
||||
return income;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setIncome(int income) {
|
||||
this.income = income;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBeforeMoney() {
|
||||
return beforeMoney;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setBeforeMoney(String beforeMoney) {
|
||||
this.beforeMoney = beforeMoney;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setMoney(String money) {
|
||||
this.money = money;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAfterMoney() {
|
||||
return afterMoney;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setAfterMoney(String afterMoney) {
|
||||
this.afterMoney = afterMoney;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMemo() {
|
||||
return memo;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setMemo(String memo) {
|
||||
this.memo = memo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCurrencyType() {
|
||||
return currencyType;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setCurrencyType(String currencyType) {
|
||||
this.currencyType = currencyType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getServiceId() {
|
||||
return serviceId;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setServiceId(String serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTuid() {
|
||||
return tuid;
|
||||
}
|
||||
|
||||
public ExchangeRecordModel setTuid(int tuid) {
|
||||
this.tuid = tuid;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class FollowBean extends BaseModel {
|
||||
private String isattent;
|
||||
private int fans_status;
|
||||
|
||||
public FollowBean() {
|
||||
}
|
||||
|
||||
public String getIsattent() {
|
||||
return isattent;
|
||||
}
|
||||
|
||||
public void setIsattent(String isattent) {
|
||||
this.isattent = isattent;
|
||||
}
|
||||
|
||||
public int getFans_status() {
|
||||
return fans_status;
|
||||
}
|
||||
|
||||
public void setFans_status(int fans_status) {
|
||||
this.fans_status = fans_status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class FriendAppMoneyLogModel extends BaseModel {
|
||||
|
||||
@SerializedName("id")
|
||||
private String id;
|
||||
@SerializedName("uid")
|
||||
private String uid;
|
||||
@SerializedName("income")
|
||||
private String income;
|
||||
@SerializedName("before_money")
|
||||
private String beforeMoney;
|
||||
@SerializedName("money")
|
||||
private String money;
|
||||
@SerializedName("after_money")
|
||||
private String afterMoney;
|
||||
@SerializedName("memo")
|
||||
private String memo;
|
||||
@SerializedName("type")
|
||||
private String type;
|
||||
@SerializedName("currency_type")
|
||||
private String currencyType;
|
||||
@SerializedName("service_id")
|
||||
private String serviceId;
|
||||
@SerializedName("create_time")
|
||||
private String createTime;
|
||||
@SerializedName("tuid")
|
||||
private String tuid;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setUid(String uid) {
|
||||
this.uid = uid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getIncome() {
|
||||
return income;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setIncome(String income) {
|
||||
this.income = income;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBeforeMoney() {
|
||||
return beforeMoney;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setBeforeMoney(String beforeMoney) {
|
||||
this.beforeMoney = beforeMoney;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setMoney(String money) {
|
||||
this.money = money;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAfterMoney() {
|
||||
return afterMoney;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setAfterMoney(String afterMoney) {
|
||||
this.afterMoney = afterMoney;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMemo() {
|
||||
return memo;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setMemo(String memo) {
|
||||
this.memo = memo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCurrencyType() {
|
||||
return currencyType;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setCurrencyType(String currencyType) {
|
||||
this.currencyType = currencyType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getServiceId() {
|
||||
return serviceId;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setServiceId(String serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTuid() {
|
||||
return tuid;
|
||||
}
|
||||
|
||||
public FriendAppMoneyLogModel setTuid(String tuid) {
|
||||
this.tuid = tuid;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class FriendAppMoneySumModel extends BaseModel {
|
||||
|
||||
@SerializedName("today")
|
||||
private String today;
|
||||
@SerializedName("sum")
|
||||
private String sum;
|
||||
@SerializedName("withdrawal")
|
||||
private WithdrawalModel withdrawalModel;
|
||||
|
||||
public WithdrawalModel getWithdrawalModel() {
|
||||
return withdrawalModel;
|
||||
}
|
||||
|
||||
public FriendAppMoneySumModel setWithdrawalModel(WithdrawalModel withdrawalModel) {
|
||||
this.withdrawalModel = withdrawalModel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getToday() {
|
||||
return today;
|
||||
}
|
||||
|
||||
public FriendAppMoneySumModel setToday(String today) {
|
||||
this.today = today;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSum() {
|
||||
return sum;
|
||||
}
|
||||
|
||||
public FriendAppMoneySumModel setSum(String sum) {
|
||||
this.sum = sum;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
279
OneToOne/src/main/java/com/shayu/onetoone/bean/GiftBean.java
Normal file
279
OneToOne/src/main/java/com/shayu/onetoone/bean/GiftBean.java
Normal file
@@ -0,0 +1,279 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class GiftBean extends BaseModel {
|
||||
private int id;
|
||||
private int mark;
|
||||
private int sendtype;
|
||||
private int type;
|
||||
private int sid;
|
||||
private String giftname;
|
||||
private int needcoin;
|
||||
private String gifticon_mini;
|
||||
private String gifticon;
|
||||
private String corner_mark;
|
||||
private int orderno;
|
||||
private long addtime;
|
||||
private int swftype;
|
||||
private String swf;
|
||||
private String swftime;
|
||||
private String gift_description;
|
||||
private String operate_image;
|
||||
private String operate_url;
|
||||
private int status;
|
||||
private int gift_uid;
|
||||
private int wishtype;
|
||||
private int sort;
|
||||
private int fans_level;
|
||||
private String gift_start_time;
|
||||
private String gift_end_time;
|
||||
private int naming_status;
|
||||
private int naming_coin;
|
||||
private int naming_liveuid;
|
||||
private int naming_uid;
|
||||
private int gift_type;
|
||||
|
||||
public GiftBean() {
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getMark() {
|
||||
return mark;
|
||||
}
|
||||
|
||||
public void setMark(int mark) {
|
||||
this.mark = mark;
|
||||
}
|
||||
|
||||
public int getSendtype() {
|
||||
return sendtype;
|
||||
}
|
||||
|
||||
public void setSendtype(int sendtype) {
|
||||
this.sendtype = sendtype;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public void setSid(int sid) {
|
||||
this.sid = sid;
|
||||
}
|
||||
|
||||
public String getGiftname() {
|
||||
return giftname;
|
||||
}
|
||||
|
||||
public void setGiftname(String giftname) {
|
||||
this.giftname = giftname;
|
||||
}
|
||||
|
||||
public int getNeedcoin() {
|
||||
return needcoin;
|
||||
}
|
||||
|
||||
public void setNeedcoin(int needcoin) {
|
||||
this.needcoin = needcoin;
|
||||
}
|
||||
|
||||
public String getGifticon_mini() {
|
||||
return gifticon_mini;
|
||||
}
|
||||
|
||||
public void setGifticon_mini(String gifticon_mini) {
|
||||
this.gifticon_mini = gifticon_mini;
|
||||
}
|
||||
|
||||
public String getGifticon() {
|
||||
return gifticon;
|
||||
}
|
||||
|
||||
public void setGifticon(String gifticon) {
|
||||
this.gifticon = gifticon;
|
||||
}
|
||||
|
||||
public String getCorner_mark() {
|
||||
return corner_mark;
|
||||
}
|
||||
|
||||
public void setCorner_mark(String corner_mark) {
|
||||
this.corner_mark = corner_mark;
|
||||
}
|
||||
|
||||
public int getOrderno() {
|
||||
return orderno;
|
||||
}
|
||||
|
||||
public void setOrderno(int orderno) {
|
||||
this.orderno = orderno;
|
||||
}
|
||||
|
||||
public long getAddtime() {
|
||||
return addtime;
|
||||
}
|
||||
|
||||
public void setAddtime(long addtime) {
|
||||
this.addtime = addtime;
|
||||
}
|
||||
|
||||
public int getSwftype() {
|
||||
return swftype;
|
||||
}
|
||||
|
||||
public void setSwftype(int swftype) {
|
||||
this.swftype = swftype;
|
||||
}
|
||||
|
||||
public String getSwf() {
|
||||
return swf;
|
||||
}
|
||||
|
||||
public void setSwf(String swf) {
|
||||
this.swf = swf;
|
||||
}
|
||||
|
||||
public String getSwftime() {
|
||||
return swftime;
|
||||
}
|
||||
|
||||
public void setSwftime(String swftime) {
|
||||
this.swftime = swftime;
|
||||
}
|
||||
|
||||
public String getGift_description() {
|
||||
return gift_description;
|
||||
}
|
||||
|
||||
public void setGift_description(String gift_description) {
|
||||
this.gift_description = gift_description;
|
||||
}
|
||||
|
||||
public String getOperate_image() {
|
||||
return operate_image;
|
||||
}
|
||||
|
||||
public void setOperate_image(String operate_image) {
|
||||
this.operate_image = operate_image;
|
||||
}
|
||||
|
||||
public String getOperate_url() {
|
||||
return operate_url;
|
||||
}
|
||||
|
||||
public void setOperate_url(String operate_url) {
|
||||
this.operate_url = operate_url;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getGift_uid() {
|
||||
return gift_uid;
|
||||
}
|
||||
|
||||
public void setGift_uid(int gift_uid) {
|
||||
this.gift_uid = gift_uid;
|
||||
}
|
||||
|
||||
public int getWishtype() {
|
||||
return wishtype;
|
||||
}
|
||||
|
||||
public void setWishtype(int wishtype) {
|
||||
this.wishtype = wishtype;
|
||||
}
|
||||
|
||||
public int getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(int sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public int getFans_level() {
|
||||
return fans_level;
|
||||
}
|
||||
|
||||
public void setFans_level(int fans_level) {
|
||||
this.fans_level = fans_level;
|
||||
}
|
||||
|
||||
public String getGift_start_time() {
|
||||
return gift_start_time;
|
||||
}
|
||||
|
||||
public void setGift_start_time(String gift_start_time) {
|
||||
this.gift_start_time = gift_start_time;
|
||||
}
|
||||
|
||||
public String getGift_end_time() {
|
||||
return gift_end_time;
|
||||
}
|
||||
|
||||
public void setGift_end_time(String gift_end_time) {
|
||||
this.gift_end_time = gift_end_time;
|
||||
}
|
||||
|
||||
public int getNaming_status() {
|
||||
return naming_status;
|
||||
}
|
||||
|
||||
public void setNaming_status(int naming_status) {
|
||||
this.naming_status = naming_status;
|
||||
}
|
||||
|
||||
public int getNaming_coin() {
|
||||
return naming_coin;
|
||||
}
|
||||
|
||||
public void setNaming_coin(int naming_coin) {
|
||||
this.naming_coin = naming_coin;
|
||||
}
|
||||
|
||||
public int getNaming_liveuid() {
|
||||
return naming_liveuid;
|
||||
}
|
||||
|
||||
public void setNaming_liveuid(int naming_liveuid) {
|
||||
this.naming_liveuid = naming_liveuid;
|
||||
}
|
||||
|
||||
public int getNaming_uid() {
|
||||
return naming_uid;
|
||||
}
|
||||
|
||||
public void setNaming_uid(int naming_uid) {
|
||||
this.naming_uid = naming_uid;
|
||||
}
|
||||
|
||||
public int getGift_type() {
|
||||
return gift_type;
|
||||
}
|
||||
|
||||
public void setGift_type(int gift_type) {
|
||||
this.gift_type = gift_type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class GreetBean extends BaseModel {
|
||||
private String id;
|
||||
private int uid;
|
||||
private String content;
|
||||
private int type;
|
||||
private long createTime;
|
||||
private long updateTime;
|
||||
private int status;
|
||||
private boolean isEdit;
|
||||
|
||||
public GreetBean() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public long getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(long updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public boolean isEdit() {
|
||||
return isEdit;
|
||||
}
|
||||
|
||||
public void setEdit(boolean edit) {
|
||||
isEdit = edit;
|
||||
}
|
||||
}
|
||||
330
OneToOne/src/main/java/com/shayu/onetoone/bean/HomeItemBean.java
Normal file
330
OneToOne/src/main/java/com/shayu/onetoone/bean/HomeItemBean.java
Normal file
@@ -0,0 +1,330 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HomeItemBean extends BaseModel {
|
||||
private int id;
|
||||
private String label_id;
|
||||
private List<String> cn_label;
|
||||
private List<String> en_label;
|
||||
private int first_mate;
|
||||
private long create_time;
|
||||
private long update_time;
|
||||
private int sex;
|
||||
private int b_y;
|
||||
private int b_ym;
|
||||
private int b_ymd;
|
||||
private int name_auth;//1未认证 2已认证 3审核中 4被拒绝
|
||||
private long name_auth_time;
|
||||
private String auth_front;
|
||||
private String auth_back;
|
||||
private String auth_remark;
|
||||
private int sage_auth;//1未认证 2已认证 3审核中 4被拒绝
|
||||
private long sage_auth_time;
|
||||
private int is_hot;
|
||||
private String vodie_price;
|
||||
private String price;
|
||||
private int star;
|
||||
private String area;
|
||||
private int is_hello;
|
||||
private int online;
|
||||
private String user_nicename;
|
||||
private String avatar;
|
||||
private String avatar_thumb;
|
||||
private String birthday;
|
||||
private String signature;
|
||||
private String star_name;
|
||||
private int age;
|
||||
private int level;
|
||||
private int is_accost;
|
||||
private int isAttention;//isAttention 0 未关注 1被关注 2已关注 3互相关注
|
||||
|
||||
public HomeItemBean() {
|
||||
}
|
||||
|
||||
public int getIsAttention() {
|
||||
return isAttention;
|
||||
}
|
||||
|
||||
public void setIsAttention(int isAttention) {
|
||||
this.isAttention = isAttention;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel_id() {
|
||||
return label_id;
|
||||
}
|
||||
|
||||
public void setLabel_id(String label_id) {
|
||||
this.label_id = label_id;
|
||||
}
|
||||
|
||||
public List<String> getCn_label() {
|
||||
return cn_label;
|
||||
}
|
||||
|
||||
public void setCn_label(List<String> cn_label) {
|
||||
this.cn_label = cn_label;
|
||||
}
|
||||
|
||||
public List<String> getEn_label() {
|
||||
return en_label;
|
||||
}
|
||||
|
||||
public void setEn_label(List<String> en_label) {
|
||||
this.en_label = en_label;
|
||||
}
|
||||
|
||||
public int getFirst_mate() {
|
||||
return first_mate;
|
||||
}
|
||||
|
||||
public void setFirst_mate(int first_mate) {
|
||||
this.first_mate = first_mate;
|
||||
}
|
||||
|
||||
public long getCreate_time() {
|
||||
return create_time;
|
||||
}
|
||||
|
||||
public void setCreate_time(long create_time) {
|
||||
this.create_time = create_time;
|
||||
}
|
||||
|
||||
public long getUpdate_time() {
|
||||
return update_time;
|
||||
}
|
||||
|
||||
public void setUpdate_time(long update_time) {
|
||||
this.update_time = update_time;
|
||||
}
|
||||
|
||||
public int getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(int sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public int getB_y() {
|
||||
return b_y;
|
||||
}
|
||||
|
||||
public void setB_y(int b_y) {
|
||||
this.b_y = b_y;
|
||||
}
|
||||
|
||||
public int getB_ym() {
|
||||
return b_ym;
|
||||
}
|
||||
|
||||
public void setB_ym(int b_ym) {
|
||||
this.b_ym = b_ym;
|
||||
}
|
||||
|
||||
public int getB_ymd() {
|
||||
return b_ymd;
|
||||
}
|
||||
|
||||
public void setB_ymd(int b_ymd) {
|
||||
this.b_ymd = b_ymd;
|
||||
}
|
||||
|
||||
public int getName_auth() {
|
||||
return name_auth;
|
||||
}
|
||||
|
||||
public void setName_auth(int name_auth) {
|
||||
this.name_auth = name_auth;
|
||||
}
|
||||
|
||||
public long getName_auth_time() {
|
||||
return name_auth_time;
|
||||
}
|
||||
|
||||
public void setName_auth_time(long name_auth_time) {
|
||||
this.name_auth_time = name_auth_time;
|
||||
}
|
||||
|
||||
public String getAuth_front() {
|
||||
return auth_front;
|
||||
}
|
||||
|
||||
public void setAuth_front(String auth_front) {
|
||||
this.auth_front = auth_front;
|
||||
}
|
||||
|
||||
public String getAuth_back() {
|
||||
return auth_back;
|
||||
}
|
||||
|
||||
public void setAuth_back(String auth_back) {
|
||||
this.auth_back = auth_back;
|
||||
}
|
||||
|
||||
public String getAuth_remark() {
|
||||
return auth_remark;
|
||||
}
|
||||
|
||||
public void setAuth_remark(String auth_remark) {
|
||||
this.auth_remark = auth_remark;
|
||||
}
|
||||
|
||||
public int getSage_auth() {
|
||||
return sage_auth;
|
||||
}
|
||||
|
||||
public void setSage_auth(int sage_auth) {
|
||||
this.sage_auth = sage_auth;
|
||||
}
|
||||
|
||||
public long getSage_auth_time() {
|
||||
return sage_auth_time;
|
||||
}
|
||||
|
||||
public void setSage_auth_time(long sage_auth_time) {
|
||||
this.sage_auth_time = sage_auth_time;
|
||||
}
|
||||
|
||||
public int getIs_hot() {
|
||||
return is_hot;
|
||||
}
|
||||
|
||||
public void setIs_hot(int is_hot) {
|
||||
this.is_hot = is_hot;
|
||||
}
|
||||
|
||||
public String getVodie_price() {
|
||||
return vodie_price;
|
||||
}
|
||||
|
||||
public void setVodie_price(String vodie_price) {
|
||||
this.vodie_price = vodie_price;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public int getStar() {
|
||||
return star;
|
||||
}
|
||||
|
||||
public void setStar(int star) {
|
||||
this.star = star;
|
||||
}
|
||||
|
||||
public String getArea() {
|
||||
return area;
|
||||
}
|
||||
|
||||
public void setArea(String area) {
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
public int getIs_hello() {
|
||||
return is_hello;
|
||||
}
|
||||
|
||||
public void setIs_hello(int is_hello) {
|
||||
this.is_hello = is_hello;
|
||||
}
|
||||
|
||||
public int getOnline() {
|
||||
return online;
|
||||
}
|
||||
|
||||
public void setOnline(int online) {
|
||||
this.online = online;
|
||||
}
|
||||
|
||||
public String getUser_nicename() {
|
||||
return user_nicename;
|
||||
}
|
||||
|
||||
public void setUser_nicename(String user_nicename) {
|
||||
this.user_nicename = user_nicename;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
if (!avatar.startsWith("http")) {
|
||||
avatar = CommonAppConfig.HOST+"/" + avatar;
|
||||
}
|
||||
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 getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(String birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(String signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public String getStar_name() {
|
||||
return star_name;
|
||||
}
|
||||
|
||||
public void setStar_name(String star_name) {
|
||||
this.star_name = star_name;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getIs_accost() {
|
||||
return is_accost;
|
||||
}
|
||||
|
||||
public void setIs_accost(int is_accost) {
|
||||
this.is_accost = is_accost;
|
||||
}
|
||||
}
|
||||
219
OneToOne/src/main/java/com/shayu/onetoone/bean/HomeRankBean.java
Normal file
219
OneToOne/src/main/java/com/shayu/onetoone/bean/HomeRankBean.java
Normal file
@@ -0,0 +1,219 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class HomeRankBean extends BaseModel {
|
||||
private String id;
|
||||
private String uid;
|
||||
private String money;
|
||||
private int type;
|
||||
private int ymd;
|
||||
private int yw;
|
||||
private int ym;
|
||||
private long updateTime;
|
||||
private long createTime;
|
||||
private int isAttention;//0 未关注 1被关注 2已关注 3互相关注
|
||||
private int islive;
|
||||
private String avatar;
|
||||
private String avatarThumb;
|
||||
@SerializedName("user_nicename")
|
||||
private String userNicename;
|
||||
private int sex;
|
||||
private int level;
|
||||
@SerializedName("charm_level")
|
||||
private int charmLevel;
|
||||
@SerializedName("wealth_level")
|
||||
private int wealthLevel;
|
||||
private String icon;
|
||||
private String charmIcon;
|
||||
private String wealthIcon;
|
||||
private String iconsss;
|
||||
|
||||
public HomeRankBean() {
|
||||
}
|
||||
|
||||
public String getIconsss() {
|
||||
return iconsss;
|
||||
}
|
||||
|
||||
public void setIconsss(String iconsss) {
|
||||
this.iconsss = iconsss;
|
||||
}
|
||||
|
||||
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 String getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public void setMoney(String money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getYmd() {
|
||||
return ymd;
|
||||
}
|
||||
|
||||
public void setYmd(int ymd) {
|
||||
this.ymd = ymd;
|
||||
}
|
||||
|
||||
public int getYw() {
|
||||
return yw;
|
||||
}
|
||||
|
||||
public void setYw(int yw) {
|
||||
this.yw = yw;
|
||||
}
|
||||
|
||||
public int getYm() {
|
||||
return ym;
|
||||
}
|
||||
|
||||
public void setYm(int ym) {
|
||||
this.ym = ym;
|
||||
}
|
||||
|
||||
public long getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(long updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public int getIsAttention() {
|
||||
return isAttention;
|
||||
}
|
||||
|
||||
public void setIsAttention(int isAttention) {
|
||||
this.isAttention = isAttention;
|
||||
}
|
||||
|
||||
public int getIslive() {
|
||||
return islive;
|
||||
}
|
||||
|
||||
public void setIslive(int islive) {
|
||||
this.islive = islive;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
if (!avatar.startsWith("http")) {
|
||||
avatar = CommonAppConfig.HOST+"/" + avatar;
|
||||
}
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getAvatarThumb() {
|
||||
return avatarThumb;
|
||||
}
|
||||
|
||||
public void setAvatarThumb(String avatarThumb) {
|
||||
this.avatarThumb = avatarThumb;
|
||||
}
|
||||
|
||||
public String getUserNicename() {
|
||||
return userNicename;
|
||||
}
|
||||
|
||||
public void setUserNicename(String userNicename) {
|
||||
this.userNicename = userNicename;
|
||||
}
|
||||
|
||||
public int getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(int sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getCharmLevel() {
|
||||
return charmLevel;
|
||||
}
|
||||
|
||||
public void setCharmLevel(int charmLevel) {
|
||||
this.charmLevel = charmLevel;
|
||||
}
|
||||
|
||||
public int getWealthLevel() {
|
||||
return wealthLevel;
|
||||
}
|
||||
|
||||
public void setWealthLevel(int wealthLevel) {
|
||||
this.wealthLevel = wealthLevel;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getCharmIcon() {
|
||||
return charmIcon;
|
||||
}
|
||||
|
||||
public void setCharmIcon(String charmIcon) {
|
||||
this.charmIcon = charmIcon;
|
||||
}
|
||||
|
||||
public String getWealthIcon() {
|
||||
return wealthIcon;
|
||||
}
|
||||
|
||||
public void setWealthIcon(String wealthIcon) {
|
||||
this.wealthIcon = wealthIcon;
|
||||
}
|
||||
|
||||
public boolean isFollow() {
|
||||
return isAttention == 2 || isAttention == 3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ImageBean {
|
||||
private String path;
|
||||
private File file;
|
||||
private String url;
|
||||
|
||||
private int index;
|
||||
|
||||
public ImageBean() {
|
||||
}
|
||||
|
||||
public ImageBean(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public ImageBean(String path, File file, String url) {
|
||||
this.path = path;
|
||||
this.file = file;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class JoinAnchorBean extends BaseModel {
|
||||
private String anchor_id;
|
||||
private String anchor_stream;
|
||||
private String home_zdy_img_us;
|
||||
private String home_zdy_img_cn;
|
||||
private String home_zdy_pop;
|
||||
|
||||
public JoinAnchorBean() {
|
||||
}
|
||||
|
||||
public String getAnchor_id() {
|
||||
return anchor_id;
|
||||
}
|
||||
|
||||
public void setAnchor_id(String anchor_id) {
|
||||
this.anchor_id = anchor_id;
|
||||
}
|
||||
|
||||
public String getAnchor_stream() {
|
||||
return anchor_stream;
|
||||
}
|
||||
|
||||
public void setAnchor_stream(String anchor_stream) {
|
||||
this.anchor_stream = anchor_stream;
|
||||
}
|
||||
|
||||
public String getHome_zdy_img_us() {
|
||||
return home_zdy_img_us;
|
||||
}
|
||||
|
||||
public void setHome_zdy_img_us(String home_zdy_img_us) {
|
||||
this.home_zdy_img_us = home_zdy_img_us;
|
||||
}
|
||||
|
||||
public String getHome_zdy_img_cn() {
|
||||
return home_zdy_img_cn;
|
||||
}
|
||||
|
||||
public void setHome_zdy_img_cn(String home_zdy_img_cn) {
|
||||
this.home_zdy_img_cn = home_zdy_img_cn;
|
||||
}
|
||||
|
||||
public String getHome_zdy_pop() {
|
||||
return home_zdy_pop;
|
||||
}
|
||||
|
||||
public void setHome_zdy_pop(String home_zdy_pop) {
|
||||
this.home_zdy_pop = home_zdy_pop;
|
||||
}
|
||||
}
|
||||
130
OneToOne/src/main/java/com/shayu/onetoone/bean/LabelBean.java
Normal file
130
OneToOne/src/main/java/com/shayu/onetoone/bean/LabelBean.java
Normal file
@@ -0,0 +1,130 @@
|
||||
package com.shayu.onetoone.bean;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LabelBean extends BaseModel {
|
||||
private int id;
|
||||
private int pid;
|
||||
private String cn_title;
|
||||
private String en_title;
|
||||
private List<Children> children;
|
||||
|
||||
public static class Children {
|
||||
private int id;
|
||||
private int pid;
|
||||
private String cn_title;
|
||||
private String en_title;
|
||||
private List<Children> children;
|
||||
|
||||
private boolean isSelect;
|
||||
|
||||
public boolean isSelect() {
|
||||
return isSelect;
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
|
||||
public Children() {
|
||||
|
||||
}
|
||||
|
||||
public Children(int id, String cn_title) {
|
||||
this.id = id;
|
||||
this.cn_title = cn_title;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getCn_title() {
|
||||
return cn_title;
|
||||
}
|
||||
|
||||
public void setCn_title(String cn_title) {
|
||||
this.cn_title = cn_title;
|
||||
}
|
||||
|
||||
public String getEn_title() {
|
||||
return en_title;
|
||||
}
|
||||
|
||||
public void setEn_title(String en_title) {
|
||||
this.en_title = en_title;
|
||||
}
|
||||
|
||||
public List<Children> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<Children> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getCn_title() {
|
||||
return cn_title;
|
||||
}
|
||||
|
||||
public void setCn_title(String cn_title) {
|
||||
this.cn_title = cn_title;
|
||||
}
|
||||
|
||||
public String getEn_title() {
|
||||
return en_title;
|
||||
}
|
||||
|
||||
public void setEn_title(String en_title) {
|
||||
this.en_title = en_title;
|
||||
}
|
||||
|
||||
public List<Children> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getStringChildren() {
|
||||
List<String> stringList = new ArrayList<>();
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
stringList.add(children.get(i).getCn_title());
|
||||
}
|
||||
return stringList;
|
||||
}
|
||||
|
||||
public void setChildren(List<Children> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user