Commit 7b60266b by 徐健

home

parent 370deb0b
......@@ -175,7 +175,6 @@ dependencies {
api rootProject.ext.dependencies["butterknife"]
kapt rootProject.ext.dependencies["butterknife-compiler"]
if (true) {
//开发模式
implementation fileTree(dir: 'aars', include: ['*.aar'])
......@@ -186,6 +185,9 @@ dependencies {
implementation modularPublication('com.ydl:m-consultant-api')
api project(':m-confide')
implementation project(':m-home')
// api "com.ydl:m-consultant-api:0.0.2"
// api 'com.ydl:m-consultant-module-ydl:0.0.18@aar'
......@@ -198,6 +200,7 @@ dependencies {
implementation project(':ydl-media')
implementation project(':m-muse')
......
......@@ -57,6 +57,12 @@
<data android:scheme="tencent1105070461" />
</intent-filter>
</activity>
<activity
android:name=".home.HomeActivity"
android:launchMode="singleTask"
android:noHistory="true">
</activity>
</application>
</manifest>
\ No newline at end of file
......@@ -132,6 +132,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
ARouter.getInstance().build("/course/home")
.navigation()
}
bt_to_home.setOnClickListener {
}
}
......
package com.ydl.component.home
import com.ydl.component.R
import com.ydl.ydlcommon.base.BaseActivity
class HomeActivity: BaseActivity() {
override fun layoutResId(): Int {
return R.layout.activity_home
}
override fun initDataAndEvent() {
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
android:id="@+id/home_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
\ No newline at end of file
......@@ -151,6 +151,26 @@
android:text="课程" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingBottom="20dp">
<Button
android:id="@+id/bt_to_home"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:text="首页" />
</LinearLayout>
</LinearLayout>
<com.ydl.ydlcommon.mvp.lce.view.YDLStateView
......
......@@ -19,14 +19,14 @@ buildscript {
google()
//壹点灵android maven私服 开发版
mave n{
maven{
url 'http://nexus.yidianling.com/repository/AndroidRepository/'
credentials {
username "admin"
password "fjoi#1+#@"
}
}
mave n{
maven{
url 'http://nexus.yidianling.com/repository/AndroidReleases/'
credentials {
username "admin"
......@@ -34,7 +34,7 @@ buildscript {
}
}
mave n{ url 'http://maven.aliyun.com/nexus/content/groups/public/ '}
// maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/ '}
maven {
url 'https://dl.bintray.com/zouyuhan/maven'
......@@ -65,21 +65,21 @@ buildscript {
allprojects {
repositories {
//壹点灵android maven私服 开发版
mave n{
maven{
url 'http://nexus.yidianling.com/repository/AndroidRepository/'
credentials {
username "admin"
password "fjoi#1+#@"
}
}
mave n{
maven{
url 'http://nexus.yidianling.com/repository/AndroidReleases/'
credentials {
username "admin"
password "fjoi#1+#@"
}
}
mave n{ url 'http://maven.aliyun.com/nexus/content/groups/public/ '}
// maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/ '}
// maven { url'http://developer.huawei.com/repo/' }
maven { url "https://jitpack.io" }
maven {
......
ext {
kotlin_version = "1.3.21"
dev_mode = false
dev_mode = true
ydl_app = [
appName : "心理咨询壹点灵",
......@@ -47,6 +47,7 @@ ext {
"m-consultant" : "0.0.44",
"m-fm" : "0.0.21",
"m-user" : "0.0.37",
"m-home" : "0.0.1",
"m-muse" : "0.0.19.5",
"m-tests" : "0.0.13.5",
......
......@@ -58,23 +58,25 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "com.airbnb.android:lottie:2.5.0"
implementation "com.alibaba:arouter-api:$arouter_api"
// 注意此处的依赖方式:kotlin中使用和java中使用方式有不同
kapt "com.alibaba:arouter-compiler:$arouter_compiler"
api rootProject.ext.dependencies["ydl-user-router"]
if (rootProject.ext.dev_mode){
//开发时使用
api "com.ydl:m-consultant-api:0.0.3"
api "com.ydl:m-user-api:0.0.7"
implementation project(':ydl-webview')
api project(":ydl-platform")
implementation project(':ydl-media')
implementation project(':ydl-flutter-base')
} else {
//发布时使用
api rootProject.ext.dependencies["ydl-media"]
api (rootProject.ext.dependencies["ydl-platform"]) {
transitive = true
}
implementation rootProject.ext.dependencies["ydl-flutter-base"]
}
}
modular {
//模块包名
packageName "com.yidianling.home"
// 模块发布需要的参数
publish {
modules {
xlzx {
groupId = "com.ydl"
artifactId = "m-home-module-xlzx"
// 上报的 心理咨询 业务模块 aar 包的版本号
version = rootProject.ext.ydlPublishVersion[childProject.getName()]
}
ydl{
groupId = "com.ydl"
artifactId = "m-home-module-ydl"
// 上报的 壹点灵 业务模块 aar 包的版本号
version = rootProject.ext.ydlPublishVersion[childProject.getName()]
}
}
api {
// 壹点灵/心理咨询 业务模块 API层 jar包的发布信息
groupId = "com.ydl"
artifactId = "m-home-api"
//开发时注释掉版本号,发布api时打开
//version = rootProject.ext.ydlPublishVersion[childProject.getName()+"-api"]
// API 层打包时需要引入的依赖
apiDependencies {
implementation "com.google.code.gson:gson:2.8.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.alibaba:arouter-api:1.4.1'
}
}
}
}
\ No newline at end of file
{"v":"5.5.8","fr":30,"ip":0,"op":56,"w":22,"h":22,"nm":"抱抱动效","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"爱心","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":16,"s":[0],"e":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":22,"s":[100],"e":[100]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":35,"s":[100],"e":[0]},{"t":49}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[11,11,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":16,"s":[30,30,100],"e":[119.565,119.565,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":22,"s":[119.565,119.565,100],"e":[119.565,119.565,100]},{"i":{"x":[0.833,0.833,0.833],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0,0,0]},"t":35,"s":[119.565,119.565,100],"e":[172.565,172.565,100]},{"t":49}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.174,0],[0.137,0.106],[0.999,0.903],[0.552,0.866],[0.185,0.438],[0,0.541],[-0.65,0.711],[-0.955,0],[-0.663,-0.875],[-1.069,0],[-0.668,-0.731],[0,-0.997],[0.423,-0.665],[1.331,-1.204],[0.093,-0.072]],"o":[[-0.174,0],[-0.093,-0.072],[-1.331,-1.204],[-0.25,-0.393],[-0.221,-0.523],[0,-0.997],[0.668,-0.731],[1.069,0],[0.663,-0.875],[0.955,0],[0.65,0.711],[0,1.227],[-0.552,0.866],[-0.999,0.903],[-0.138,0.106]],"v":[[0,5.75],[-0.483,5.585],[-2.421,3.952],[-5.259,0.833],[-5.935,-0.387],[-6.262,-1.969],[-5.254,-4.617],[-2.737,-5.75],[0,-4.351],[2.737,-5.75],[5.254,-4.617],[6.262,-1.969],[5.259,0.833],[2.421,3.952],[0.482,5.585]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.999295343137,0.847525383444,0.60063344918,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"抱抱 6","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0],"e":[100]},{"t":3}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[10.898,17.5,0],"ix":2},"a":{"a":0,"k":[0.023,6.5,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":8,"s":[{"i":[[0,0],[0.633,1.162],[-1.087,0.716],[0,0],[-0.416,0],[0,0],[-0.378,-0.226],[0,0],[0.633,-1.162],[1.122,0.657],[0,0],[0,0],[1.394,0],[0,0],[0,1.292],[0,0]],"o":[[-1.122,0.657],[-0.633,-1.162],[0,0],[0.353,-0.169],[0,0],[0.508,0],[0,0],[1.062,0.756],[-0.634,1.162],[0,0],[0,0],[0,1.292],[0,0],[-1.394,0],[0,0],[0,0]],"v":[[12.144,39.311],[8.953,38.391],[9.84,35.084],[13.675,32.555],[15.487,32.189],[22.794,32.189],[24.924,32.555],[28.482,35.084],[29.37,38.391],[26.178,39.311],[25.329,38.809],[25.329,42.321],[22.794,44.67],[15.487,44.67],[12.953,42.321],[12.959,38.825]],"c":true}],"e":[{"i":[[0,0],[0.633,1.162],[-0.992,0.899],[0,0],[-0.416,0],[0,0],[-0.378,-0.226],[0,0],[0.633,-1.162],[0.67,0.172],[0,0],[0,0],[1.394,0],[0,0],[0,1.292],[0,0]],"o":[[-0.358,-0.016],[-0.633,-1.162],[0,0],[0.353,-0.169],[0,0],[0.508,0],[0,0],[1.062,0.756],[-0.634,1.162],[0,0],[0,0],[0,1.292],[0,0],[-1.394,0],[0,0],[0,0]],"v":[[12.144,39.311],[10.265,37.953],[11.59,34.021],[13.675,32.555],[15.487,32.189],[22.794,32.189],[24.924,32.555],[26.795,33.709],[28.433,38.016],[26.178,39.311],[25.329,38.809],[25.329,42.321],[22.794,44.67],[15.487,44.67],[12.953,42.321],[12.959,38.825]],"c":true}]},{"i":{"x":0.667,"y":1},"o":{"x":0.167,"y":0},"t":22,"s":[{"i":[[0,0],[0.633,1.162],[-0.992,0.899],[0,0],[-0.416,0],[0,0],[-0.378,-0.226],[0,0],[0.633,-1.162],[0.67,0.172],[0,0],[0,0],[1.394,0],[0,0],[0,1.292],[0,0]],"o":[[-0.358,-0.016],[-0.633,-1.162],[0,0],[0.353,-0.169],[0,0],[0.508,0],[0,0],[1.062,0.756],[-0.634,1.162],[0,0],[0,0],[0,1.292],[0,0],[-1.394,0],[0,0],[0,0]],"v":[[12.144,39.311],[10.265,37.953],[11.59,34.021],[13.675,32.555],[15.487,32.189],[22.794,32.189],[24.924,32.555],[26.795,33.709],[28.433,38.016],[26.178,39.311],[25.329,38.809],[25.329,42.321],[22.794,44.67],[15.487,44.67],[12.953,42.321],[12.959,38.825]],"c":true}],"e":[{"i":[[0,0],[0.633,1.162],[-0.992,0.899],[0,0],[-0.416,0],[0,0],[-0.378,-0.226],[0,0],[0.633,-1.162],[0.67,0.172],[0,0],[0,0],[1.394,0],[0,0],[0,1.292],[0,0]],"o":[[-0.358,-0.016],[-0.633,-1.162],[0,0],[0.353,-0.169],[0,0],[0.508,0],[0,0],[1.062,0.756],[-0.634,1.162],[0,0],[0,0],[0,1.292],[0,0],[-1.394,0],[0,0],[0,0]],"v":[[12.144,39.311],[10.265,37.953],[11.59,34.021],[13.675,32.555],[15.487,32.189],[22.794,32.189],[24.924,32.555],[26.795,33.709],[28.433,38.016],[26.178,39.311],[25.329,38.809],[25.329,42.321],[22.794,44.67],[15.487,44.67],[12.953,42.321],[12.959,38.825]],"c":true}]},{"i":{"x":0.667,"y":1},"o":{"x":0.167,"y":0},"t":35,"s":[{"i":[[0,0],[0.633,1.162],[-0.992,0.899],[0,0],[-0.416,0],[0,0],[-0.378,-0.226],[0,0],[0.633,-1.162],[0.67,0.172],[0,0],[0,0],[1.394,0],[0,0],[0,1.292],[0,0]],"o":[[-0.358,-0.016],[-0.633,-1.162],[0,0],[0.353,-0.169],[0,0],[0.508,0],[0,0],[1.062,0.756],[-0.634,1.162],[0,0],[0,0],[0,1.292],[0,0],[-1.394,0],[0,0],[0,0]],"v":[[12.144,39.311],[10.265,37.953],[11.59,34.021],[13.675,32.555],[15.487,32.189],[22.794,32.189],[24.924,32.555],[26.795,33.709],[28.433,38.016],[26.178,39.311],[25.329,38.809],[25.329,42.321],[22.794,44.67],[15.487,44.67],[12.953,42.321],[12.959,38.825]],"c":true}],"e":[{"i":[[0,0],[0.633,1.162],[-1.087,0.716],[0,0],[-0.416,0],[0,0],[-0.378,-0.226],[0,0],[0.633,-1.162],[1.122,0.657],[0,0],[0,0],[1.394,0],[0,0],[0,1.292],[0,0]],"o":[[-1.122,0.657],[-0.633,-1.162],[0,0],[0.353,-0.169],[0,0],[0.508,0],[0,0],[1.062,0.756],[-0.634,1.162],[0,0],[0,0],[0,1.292],[0,0],[-1.394,0],[0,0],[0,0]],"v":[[12.144,39.311],[8.953,38.391],[9.84,35.084],[13.675,32.555],[15.487,32.189],[22.794,32.189],[24.924,32.555],[28.482,35.084],[29.37,38.391],[26.178,39.311],[25.329,38.809],[25.329,42.321],[22.794,44.67],[15.487,44.67],[12.953,42.321],[12.959,38.825]],"c":true}]},{"t":43}],"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[2.388,0],[0,2.352],[-2.388,0],[0,-2.352]],"o":[[-2.388,0],[0,-2.352],[2.388,0],[0,2.352]],"v":[[19.159,32.189],[14.835,27.93],[19.159,23.67],[23.482,27.93]],"c":true},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0.388235324037,0.509803921569,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-19.161,-34.17],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形 1","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"bm":0}],"markers":[{"tm":43,"cm":"1","dr":0}]}
\ No newline at end of file
{"v":"5.5.8","fr":25,"ip":0,"op":199,"w":504,"h":234,"nm":"mingxiang","ddd":0,"assets":[{"id":"image_0","w":504,"h":234,"u":"images/","p":"img_0.png","e":0},{"id":"image_1","w":504,"h":22,"u":"images/","p":"img_1.png","e":0},{"id":"image_2","w":504,"h":234,"u":"images/","p":"img_2.png","e":0}],"layers":[{"ddd":0,"ind":1,"ty":2,"nm":"feather","refId":"image_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[15.025],"e":[-10.285]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":71,"s":[-10.285],"e":[0]},{"t":127}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":0.665},"o":{"x":0.333,"y":0},"t":0,"s":[212,-43,0],"e":[263,70.637,0],"to":[0,4.714,0],"ti":[-34.871,-28.686,0]},{"i":{"x":0.63,"y":1},"o":{"x":0.333,"y":0.409},"t":71,"s":[263,70.637,0],"e":[205.062,130.812,0],"to":[27.792,22.862,0],"ti":[64.833,-1.741,0]},{"t":148}],"ix":2},"a":{"a":0,"k":[252,117,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":0,"s":[74.717,46.521,100],"e":[88.851,50.571,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":71,"s":[88.851,50.571,100],"e":[100,79.07,100]},{"t":127}],"ix":6}},"ao":0,"ip":0,"op":750,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":2,"nm":"shadow","refId":"image_1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"s":true,"x":{"a":0,"k":311.75,"ix":3},"y":{"a":0,"k":189.75,"ix":4}},"a":{"a":0,"k":[357.25,11.75,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ip":0,"op":750,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":2,"nm":"bg","refId":"image_2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[252,117,0],"ix":2},"a":{"a":0,"k":[252,117,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ip":0,"op":750,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"背景","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[252,117,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[508.762,239.879],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":0,"ix":4},"nm":"矩形路径 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"st","c":{"a":0,"k":[0.113724996529,0.631372967888,0.949020026712,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":0,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"gf","o":{"a":0,"k":100,"ix":10},"r":1,"bm":0,"g":{"p":2,"k":{"a":0,"k":[0,1,1,1,1,0,0,0],"ix":9}},"s":{"a":0,"k":[-228.375,-115.053],"ix":5},"e":{"a":0,"k":[247.004,132.97],"ix":6},"t":1,"nm":"渐变填充 1","mn":"ADBE Vector Graphic - G-Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-1.619,-1.061],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[99.976,98.959],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":750,"st":0,"bm":0}],"markers":[]}
\ No newline at end of file
package com.yidianling.consultant.constants
/**
* Created by xj on 2019/7/1.
*/
class HomeBIConstants {
companion object {
private const val YDL_USER_MAIN_PAGE: String = "ydl_user_main_page|"//壹点灵用户版首页 partId
const val YDL_USER_SEARCH_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_search_click"//搜索栏
const val YDL_USER_TELEPHONE_CUSTOMER_SERVICE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_telephone_customer_service_click"//电话客服
const val YDL_USER_BANNER_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_banner_click"//banner
const val YDL_USER_NOTICE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_notice_click"//公告
const val YDL_USER_CONSULT_CLASSIFICATION_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_consult_classification_click"//首页咨询分类
const val YDL_USER_CONSULT_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_consult_click"//四个大按钮 心理咨询点击人数
const val YDL_USER_TALK_IN_TIME_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_talk_in_time_click"//四个大按钮 即时倾诉点击人数
const val YDL_USER_PSYCHOLOGICAL_CLASSROOM_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_psychological_classroom_click"//四个大按钮 心理课堂点击人数
const val YDL_USER_PSYCHOLOGICAL_TEST_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_psychological_test_click"//四个大按钮 心理测试点击人数
const val YDL_USER_CONSULT_MORE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_consult_more_click"//咨询解惑更多
const val YDL_USER_CONSULT_TYPE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_consult_type_click"//咨询解惑分类标签
const val YDL_USER_EXPERT_INTRODUCTION_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_expert_introduction_click"//咨询师介绍模块
const val YDL_USER_PRIVATE_CHAT_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_private_chat_click"//咨询师私聊按钮
const val YDL_USER_LISTEN_MORE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_listen_more_click"//倾诉排解更多
const val YDL_USER_LISTEN_TYPE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_listen_type_click"//倾诉排解分类标签
const val YDL_USER_LISTENER_INTRODUCTION_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_listener_introduction_click "//倾诉师介绍模块
const val YDL_USER_COURSE_MORE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_course_more_click"//课程成长更多
const val YDL_USER_COURSE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_course_click"//课程标题图区域
const val YDL_USER_ASK_MORE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_ask_more_click"//解忧问答更多
const val YDL_USER_ASK_COMMENT_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_ask_comment_click"//问答评论区域
const val YDL_USER_HEART_RADIO_MORE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_heart_radio_more_click"//心灵电台更多
const val YDL_USER_RADIO_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_radio_click "//区域内四个标题
const val YDL_USER_RADIO_PLAY_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_radio_play_click"//心灵电台play按钮点击
const val YDL_USER_ARTICLE_MORE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_article_more_click"//文章阅读更多
const val YDL_USER_ARTICLE_CLICK: String = YDL_USER_MAIN_PAGE + "ydl_user_article_click"//文章标题图区域
const val YDL_USER_MAIN_PAGE_VISIT: String = YDL_USER_MAIN_PAGE + "ydl_user_main_page_visit "//首页浏览事件
}
}
\ No newline at end of file
package com.yidianling.home.adapter
import android.content.Context
import android.support.v4.view.PagerAdapter
import android.util.Log
import android.view.View
import android.view.ViewGroup
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeHeaderBean
import com.yidianling.home.ui.view.HomeCategoryContainer
import com.yidianling.home.ui.view.HomePagerBannerCategoryItemView
import java.util.*
import kotlin.collections.ArrayList
/**
* @author yuanWai
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/3/18
*/
class HomeCategoryAdapter : PagerAdapter{
private var mContext : Context? = null
private var mHomeEvent : IHomeEvent? = null
//源数据
private var mOriginList : MutableList<HomeHeaderBean.AskCategoryDataBean>? = null
//数据
private var list : MutableList<MutableList<HomeHeaderBean.AskCategoryDataBean>>? = null
init {
list = ArrayList()
}
constructor(context: Context,homeEvent : IHomeEvent?) : super(){
mContext = context
mHomeEvent = homeEvent
}
/**
* 更新数据
*/
fun updateItems(data : MutableList<HomeHeaderBean.AskCategoryDataBean>?){
if (null == data || data.isEmpty()){
return
}
Log.e("http","--------------data.size="+data!!.size)
list = this.averageAssign(data, HomeCategoryContainer.PAGE_ITEM_SIZE)
Log.e("http","--------------list.size="+list!!.size)
notifyDataSetChanged()
}
override fun isViewFromObject(view: View?, `object`: Any?): Boolean {
return view === `object`
}
override fun instantiateItem(container: ViewGroup?, position: Int): Any {
val categoryView = HomePagerBannerCategoryItemView(mContext!!,mHomeEvent!!)
categoryView.initData(list!![position])
container?.addView(categoryView)
return categoryView
}
//====================ViewPager 不刷新问题====================
override fun getItemPosition(`object`: Any?): Int {
return PagerAdapter.POSITION_NONE
}
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
container.removeView(`object` as View)
}
//====================ViewPager 不刷新问题====================
override fun getCount(): Int {
return list!!.size
}
fun <T> averageAssign(source : MutableList<T> , limit : Int) : MutableList<MutableList<T>>{
if (null == source || source.isEmpty()) {
return Collections.emptyList()
}
val result = ArrayList<MutableList<T>>()
var value : MutableList<T> = ArrayList()
// var yushu = source.size%limit
// var quotient = source.size/limit
// for (i in source.indices) {
// value.add(source[i])
// if ((i+1) % limit == 0){
// result.add(value)
// value = ArrayList()
// }else if (i == source.size - 1){
// result.add(value)
// }else if ((i+1) > source.size - yushu){
// value = ArrayList()
// }
// }
for (i in source.indices) {
if ((i + 1) % limit == 1){
//新分组
value = ArrayList()
}
value.add(source[i])
if (i == source.size -1 || ( i + 1 ) % limit == 0){
//列表最后一个或者为分组最后一个
result.add(value)
}
}
return result
}
}
\ No newline at end of file
package com.yidianling.home.adapter
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.yidianling.home.R
import com.yidianling.home.constract.YdlHomeViewHolderConstract
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.*
import com.yidianling.home.ui.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 壹点零首页适配器
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
class YdlHomeAdapter(private val mContext: Context,
private var homeEvent: IHomeEvent,
private var list: ArrayList<HomePagerDataBean>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private val mInflater: LayoutInflater = LayoutInflater.from(mContext)
/**
* 倾述item的position
*
*/
private var confidePosition = -1
/**
* 咨询条目 position
*/
private var consultPosition = -1
/**
* 倾述模块中tab上次选中的下标
*/
var confideSelectPosition = 0
/**
* 咨询模块中tab上次选中的下标
*/
var consultSelectPosition = 0
/**
* 倾诉分类 缓存
*/
var listenCategoryDate: List<HomeHeaderBean.ListenCategoryDateBean>? = null
/**
* 咨询分类 缓存
*/
var consultCategoryData: List<HomeHeaderBean.ConsultCategoryDateBean>? = null
fun updateItems(list: MutableList<HomePagerDataBean>) {
if (null == this.list || this.list!!.isEmpty()) {
this.list = ArrayList()
} else {
this.list.clear()
}
this.list.addAll(list)
//重置标记位
confidePosition = -1
consultPosition = -1
notifyDataSetChanged()
}
/**
* 更新倾诉模块数据
*/
fun updateConfideData(data: HomeConfideBean, selectPosition: Int) {
if (confidePosition == -1) {
return
}
list[confidePosition].confideBean = data
this.confideSelectPosition = selectPosition
notifyItemChanged(confidePosition)
}
/**
* 更新咨询模块数据
*/
fun updateConsultData(data: HomeConsultBean, selectPosition: Int) {
if (consultPosition == -1) {
return
}
list[consultPosition].consultBean = data
this.consultSelectPosition = selectPosition
notifyItemChanged(consultPosition)
}
/**
* 更新问答模块数据
*/
fun updateAskData(data: HomeAskBean, position: Int) {
list[position].askBean = data
// notifyItemChanged(position)
}
override fun getItemViewType(position: Int): Int {
if (position < list.size) {
return list[position].type!!
} else {
return YdlHomeViewHolderConstract.FOOTER_VIEW
}
}
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): RecyclerView.ViewHolder {
when (viewType) {
//顶部ViewPager与分类模块
YdlHomeViewHolderConstract.PAGER_BANNER_VIEW -> {
return HomePagerBannerViewHolder(HomePagerBannerView(mContext, homeEvent))
}
//咨询模块
YdlHomeViewHolderConstract.CONSULT_VIEW -> {
return HomeConsultViewHolder(HomeConsultView(mContext, homeEvent))
}
//顶部预约专家,即时倾诉,心理测试按钮模块
YdlHomeViewHolderConstract.BUTTON_BANNER_VIEW -> {
return HomeButtonBannerViewHolder(HomeButtonBannerView(mContext, homeEvent))
}
//倾诉*排解模块
YdlHomeViewHolderConstract.CONFIDE_VIEW -> {
return HomeConfideViewHolder(HomeConfideView(mContext, homeEvent))
}
//课程*成长模块
YdlHomeViewHolderConstract.COURSE_VIEW -> {
return HomeCourseViewHolder(HomeCourseView(mContext, homeEvent))
}
//解忧*问答模块
YdlHomeViewHolderConstract.ASSUAGE_GRIEF_VIEW -> {
return HomeAssuageGriefViewHolder(HomeAssuageGriefView(mContext, homeEvent))
}
//测试模块
YdlHomeViewHolderConstract.TEST_VIEW -> {
return HomeTestViewHolder(HomeTestView(mContext, homeEvent))
}
//心灵*电台模块
YdlHomeViewHolderConstract.INTELLIGENT_VIEW -> {
return HomeIntelligentViewHolder(HomeIntelligentView(mContext, homeEvent))
}
//文章*阅读模块
YdlHomeViewHolderConstract.ARTICLE_VIEW -> {
return HomeArticleViewHolder(HomeArticleView(mContext, homeEvent))
}
//壹点*冥想模块
YdlHomeViewHolderConstract.MUSE_VIEW -> {
return HomeMuseViewHolder(HomeMuseView(mContext, homeEvent))
}
//底部提示语模块
else -> {
val view = mInflater.inflate(R.layout.home_module_footer_view, parent, false)
return FooterViewViewHolder(view)
}
}
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
when (holder) {
//顶部ViewPager与分类模块
is HomePagerBannerViewHolder -> {
var headerBean = list[position].headerBean;
this.consultCategoryData = headerBean?.consultCategoryData
this.listenCategoryDate = headerBean?.listenCategoryDate
holder.pagerBannerView.initData(headerBean)
}
//顶部预约专家,即时倾诉,心理课堂,心理测试按钮模块
is HomeButtonBannerViewHolder -> {
}
//咨询模块
is HomeConsultViewHolder -> {
holder.consultView.setTitle(this.consultCategoryData, consultSelectPosition)
holder.consultView.setConsultInfoView(list[position].consultBean?.list,this.consultCategoryData?.get(consultSelectPosition))
consultPosition = position
}
//倾诉*排解模块
is HomeConfideViewHolder -> {
holder.confideViewView.setTitle(this.listenCategoryDate, confideSelectPosition)
holder.confideViewView.setConfideExpertInfoView(list[position].confideBean?.body)
confidePosition = position
}
//课程*成长模块
is HomeCourseViewHolder -> {
holder.courseViewView.initData(list[position].courseBean?.list)
}
//解忧*问答模块
is HomeAssuageGriefViewHolder -> {
holder.assuageGriefViewView.initData(position,list[position].askBean?.data)
}
//壹点*冥想模块
is HomeMuseViewHolder -> {
holder.museViewView.initData(list[position].museBean)
}
//心灵*电台模块
is HomeIntelligentViewHolder -> {
holder.intelligentViewView.initData(list[position].fmBean?.list)
}
//文章*阅读模块
is HomeArticleViewHolder -> {
holder.articleViewView.initData(list[position].articleBean?.list)
}
//测试模块
is HomeTestViewHolder -> {
holder.testView.initData(list[position].testListBean)
}
}
}
override fun getItemCount(): Int {
return list.size
}
/**
* 顶部ViewPager与分类模块 ViewHolder
*/
inner class HomePagerBannerViewHolder(val pagerBannerView: HomePagerBannerView) : RecyclerView.ViewHolder(pagerBannerView)
/**
* 顶部预约专家,即时倾诉,心理测试按钮模块 ViewHolder
*/
inner class HomeButtonBannerViewHolder(val buttonBannerView: HomeButtonBannerView) : RecyclerView.ViewHolder(buttonBannerView)
/**
* 咨询模块 ViewHolder
*/
inner class HomeConsultViewHolder(val consultView: HomeConsultView) : RecyclerView.ViewHolder(consultView)
/**
* 倾诉*排解模块 ViewHolder
*/
inner class HomeConfideViewHolder(val confideViewView: HomeConfideView) : RecyclerView.ViewHolder(confideViewView)
/**
* 课程*成长模块 ViewHolder
*/
inner class HomeCourseViewHolder(val courseViewView: HomeCourseView) : RecyclerView.ViewHolder(courseViewView)
/**
* 测试模块 ViewHolder
*/
inner class HomeTestViewHolder(val testView: HomeTestView) : RecyclerView.ViewHolder(testView)
/**
* 解忧*问答模块 ViewHolder
*/
inner class HomeAssuageGriefViewHolder(val assuageGriefViewView: HomeAssuageGriefView) : RecyclerView.ViewHolder(assuageGriefViewView)
/**
* 心灵*电台模块 ViewHolder
*/
inner class HomeIntelligentViewHolder(val intelligentViewView: HomeIntelligentView) : RecyclerView.ViewHolder(intelligentViewView)
/**
* 文章*阅读模块 ViewHolder
*/
inner class HomeMuseViewHolder(val museViewView: HomeMuseView) : RecyclerView.ViewHolder(museViewView)
/**
* 文章*阅读模块 ViewHolder
*/
inner class HomeArticleViewHolder(val articleViewView: HomeArticleView) : RecyclerView.ViewHolder(articleViewView)
/**
* 底部提示语模块 ViewHolder
*/
inner class FooterViewViewHolder(val footerView: View) : RecyclerView.ViewHolder(footerView)
}
\ No newline at end of file
package com.yidianling.home.constract
import com.ydl.ydlcommon.mvp.base.IView
import com.yidianling.home.model.bean.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 壹点灵首页约束类
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
class IHomeContract {
interface View : IView {
/**
* 首页数据回调接口
*/
fun homeDataResponse(list: MutableList<HomePagerDataBean>)
/**
* 头部数据回调
*/
fun homeHeadResponse(homeHeaderBean: HomeHeaderBean)
/**
* 首页数据请求失败接口
*/
fun homeDataFail(msg: String)
/**
* 获取倾述数据回调
*/
fun confideDataResponse(data: HomeConfideBean, selectPosition: Int)
/**
* 获取咨询数据回调
*/
fun consultDataResponse(data: HomeConsultBean, selectPosition: Int)
/**
* 问答模块数据回调
*/
fun askDataResponse(data: HomeAskBean, position: Int)
/**
* 首页问答 - 点赞
*/
fun askZan(position: Int, index: Int, id: String)
/**
* 首页问答 - 关注
*/
fun askFocus(position: Int, id: String)
/**
* 获取倾述列表数据
* @param type 倾述类型
* @param selectPosition 选中的position
*/
fun getConfideData(type: String, selectPosition: Int)
/**
* 获取咨询列表数据
*/
fun getConsultData(type: String, selectPosition: Int)
fun showHomeProgress()
fun showRefreshLayout()
fun dismissHomeProgress()
fun startAnim()
fun endAnim()
fun resetModuleTabPosition()
fun getSearchContent() : String
}
}
\ No newline at end of file
package com.yidianling.home.constract
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述:壹点零首页ViewHolder约束类
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
class YdlHomeViewHolderConstract {
companion object {
/**
* 顶部ViewPager与分类模块
*/
val PAGER_BANNER_VIEW = 10001
/**
* 顶部预约专家,即时倾诉,心理测试按钮模块
*/
val BUTTON_BANNER_VIEW = 10002
/**
* 咨询模块
*/
val CONSULT_VIEW = 10003
/**
* 课程*成长模块
*/
val COURSE_VIEW = 10004
/**
* 倾诉*排解模块
*/
val CONFIDE_VIEW = 10005
/**
* 测试模块
*/
val TEST_VIEW = 10006
/**
* 解忧*问答模块
*/
val ASSUAGE_GRIEF_VIEW = 10007
/**
* 壹点*冥想模块
*/
val MUSE_VIEW = 10008
/**
* 心灵*电台模块
*/
val INTELLIGENT_VIEW = 10009
/**
* 文章*阅读模块
*/
val ARTICLE_VIEW = 10010
/**
* 底部提示语模块
*/
val FOOTER_VIEW = 10011
}
}
\ No newline at end of file
package com.yidianling.home.dialog
import android.app.Activity
import android.app.Dialog
import android.os.Bundle
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydl_router.manager.YDLRouterManager
import com.yidianling.home.R
import kotlinx.android.synthetic.ydl.dialog_activity.*
import java.lang.ref.WeakReference
/**
* 活动弹窗
*/
class ActivityDialog : Dialog {
private var imgUrl: String? = null
private var linkUrl: String? = null
private var title: String? = null
private var mActivity: WeakReference<Activity>? = null
constructor(activit: Activity, imgUrl: String?, linkUrl: String?, title: String?) : super(
activit,
R.style.activityDialog
) {
this.imgUrl = imgUrl
this.linkUrl = linkUrl
this.title = title
this.mActivity = WeakReference<Activity>(activit)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.setBackgroundDrawableResource(android.R.color.transparent)
setContentView(R.layout.dialog_activity)
initView()
}
private fun initView() {
img_close.setOnClickListener {
this.dismiss()
}
img_activity.setOnClickListener {
//跳转
if (this.linkUrl != null && this.linkUrl!!.startsWith("http")) {
NewH5Activity.start(context, H5Params(this.linkUrl!!, null))
} else {
YDLRouterManager.router(this.linkUrl)
}
}
GlideApp.with(context).load(imgUrl).into(img_activity)
setCanceledOnTouchOutside(false)
setCancelable(false)
}
}
package com.yidianling.home.dialog
import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Window
import com.yidianling.home.R
import com.ydl.ydl_image.module.GlideApp
import kotlinx.android.synthetic.ydl.dialog_guide_activity.*
import java.util.*
/**
* 首页活动引导弹窗
*/
class ActivityGuideDialog : Dialog {
private var imgUrl: String? = null
private var title: String? = null
constructor(context: Context, imgUrl: String?, title: String?) : super(
context,
R.style.activityDialog
) {
this.imgUrl = imgUrl
this.title = title
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requestWindowFeature(Window.FEATURE_NO_TITLE)
window.setBackgroundDrawableResource(android.R.color.transparent)
setContentView(R.layout.dialog_guide_activity)
initView()
}
private fun initView() {
c_body.setOnClickListener {
dismiss()
}
tv_content.text = this.title
GlideApp.with(context).load(imgUrl).into(img_activity)
//3秒自动消失
Timer().schedule(object : TimerTask() {
override fun run() {
dismiss()
}
}, 3000)
}
}
\ No newline at end of file
package com.yidianling.home.event
import android.support.v7.widget.RecyclerView
import android.view.View
import com.yidianling.home.model.bean.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 首页点击事件接口类
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
interface IHomeEvent {
/**
* 服务电话点击事件
*/
fun serviceCallClick()
/**
* 动态编辑按钮点击
*/
fun publishTrendClick()
/**
* 咨询条目点击事件
*/
fun consultItemClick(linkUrl: String?, doctorId: String)
/**
* 咨询私聊点击事件
*/
fun consultChatClick(doctorId: String?)
/**
* 测试条目点击事件
*/
fun testItemClick(linkUrl: String?)
/**
* 测试更多点击事件
*/
fun testMoreClick()
/**
* 咨询更多点击事件
*/
fun consultMoreClick()
/**
* 搜索框点击事件
*/
fun searchTvClick(text:String)
/**
* 列表滚动事件
*/
fun onPageScroll(view_rl_top_bg: View): RecyclerView.OnScrollListener?
/**
* 跳转链接点击
* Banner & 首页分类 & 首页条目 使用
*/
fun linkTo(linkUrl: String)
/**
* banner点击跳转
*/
fun bannerClick(banner:HomeHeaderBean.FocusListBean)
/**
* 首页分类跳转
*/
fun categoryClick(category: HomeHeaderBean.AskCategoryDataBean)
/**
* 预约专家点击事件
*/
fun reservationExpertsClick()
/**
* 即可倾诉点击事件
*/
fun nowConfideClick()
/**
* 心理课堂点击事件
*/
fun psychologyClassClick()
/**
* 心理测试点击事件
*/
fun psychologyTestClick()
/**
* 倾诉更多点击事件
*/
fun confideMoreClick()
/**
* 倾述咨询师点击
* @param linkUrl 跳转地址
*/
fun confideClick(linkUrl: String?, doctorId: Int)
/**
* 私聊
*/
fun toChatForMsg(doctorId: String?)
/**
* 课程item点击事件
*/
fun courseItemClick(bean: HomeCourseBean.ListBean)
/**
* 课程更多点击事件
*/
fun courseMreClick()
/**
* 问答条目关注点击事件
* @param id : 用户uid
*/
fun askItemFocusClick(position:Int,id: String)
/**
* 问答条目点赞事件
* @param id : 动态id
*/
fun askItemZanClick(position:Int,index:Int,id: String)
/**
* 问答更多点击事件
*/
fun askMoreClick()
/**
* 问答条目点击事件
*/
fun askItemClick(bean:HomeAskBean.DataBean)
/**
* 冥想更多点击事件
*/
fun museMoreClick(dataJson: String)
/**
* 冥想item点击事件
*/
fun museClick(url: String, dataJson: String)
/**
* 电台条目点击播放事件
*/
fun fmPlayClick(bean: HomeFMBean.ListBean)
/**
* 电台条目点击进入详情
*/
fun fmItemClick(bean: HomeFMBean.ListBean)
/**
* 电台更多点击事件
*/
fun fmMoreClick()
/**
* 文章更多点击事件
*/
fun articleMoreClick()
/**
* 文章item点击事件
*/
fun articleItemClick(bean: HomeArticleBean.Bean?)
/**
* 获取倾述列表数据
* 最终调用
* @see com.yidianling.home.ui.fragment.YdlHomeFragment.getConfideData
*
* @param type 倾述类型
* @param selectPosition 选中的position
*/
fun getConfideData(type: HomeHeaderBean.ListenCategoryDateBean, selectPosition: Int)
/**
* 获取咨询列表数据
* 最终调用
* @see com.yidianling.home.ui.fragment.YdlHomeFragment.getConsultData
*
* @param type 类型
* @param selectPosition 选中的position
*/
fun getConsultData(type: HomeHeaderBean.ConsultCategoryDateBean, selectPosition: Int)
interface IRequestListener<T> {
fun onResponse(result:T)
}
}
\ No newline at end of file
package com.yidianling.home.http
import com.yidianling.home.model.bean.*
import com.yidianling.ydlcommon.bean.MuseModuleBean
import com.yidianling.ydlcommon.http.BaseAPIResponse
import com.yidianling.ydlcommon.http.BaseCommand
import com.yidianling.ydlcommon.http.BaseResponse
import com.yidianling.ydlcommon.http.YdlRetrofitUtils
import com.yidianling.ydlcommon.router.YdlCommonRouterManager
import io.reactivex.Observable
/**
* @author jiucheng
* @描述:首页接口实现类
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/8/22
*/
class HomeHttp private constructor() {
companion object {
fun getInstance(): HomeHttp {
return Holder.INSTANCE
}
fun clearHomPagerApi() {
Holder.INSTANCE.homPagerApi = null
Holder.INSTANCE.phpHomPagerApi = null
}
}
object Holder {
val INSTANCE = HomeHttp()
}
private var homPagerApi: HomePagerApi? = null
private var phpHomPagerApi: HomePagerApi? = null
private fun getPhpHomPagerApi(): HomePagerApi {
if (phpHomPagerApi == null) {
phpHomPagerApi = YdlRetrofitUtils.getRxRetrofit().create(HomePagerApi::class.java)
}
return phpHomPagerApi!!
}
private fun getHomPagerApi(): HomePagerApi {
if (homPagerApi == null) {
homPagerApi = YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(HomePagerApi::class.java)
}
return homPagerApi!!
}
//首页头部 分类&Banner 请求
fun newHomeHeaderRequest(): Observable<BaseAPIResponse<HomeHeaderBean>> {
return getHomPagerApi().getHomeHeaderData()
}
//首页倾述请求
fun getConfideData(goodType: String): Observable<BaseAPIResponse<HomeConfideBean>> {
val loginBean = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()
var userId = loginBean?.userId ?: "";
return getHomPagerApi().getConfideData(goodType, uid = userId);
}
//首页课程请求
fun getCourseData(listType: String = "10"): Observable<BaseAPIResponse<HomeCourseBean>> {
val loginBean = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()
var userId = loginBean?.userId ?: "";
return getHomPagerApi().getCourseData(listType, uid = userId);
}
//首页测试请求
fun getTestData(): Observable<BaseAPIResponse<MutableList<HomeTestItemBean>>> {
val loginBean = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()
var userId = loginBean?.userId ?: "";
return getHomPagerApi().getTestData(uid = userId)
}
//首页问答请求
fun getAskData(): Observable<BaseAPIResponse<HomeAskBean>> {
val loginBean = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()
var userId = loginBean?.userId ?: "";
var token = loginBean?.token ?: "";
return getHomPagerApi().getAskData(accessToken = token, uid = userId);
}
//首页电台请求
fun getFMData(): Observable<BaseAPIResponse<HomeFMBean>> {
return getHomPagerApi().getFMData();
}
//首页文章请求
fun getArticleData(perPageRows: String = "4"): Observable<BaseAPIResponse<HomeArticleBean>> {
return getHomPagerApi().getArticleData()
}
//首页咨询请求
fun getConsultData(goodType: String): Observable<BaseAPIResponse<HomeConsultBean>> {
val loginBean = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()
var userId = loginBean?.userId ?: ""
return getHomPagerApi().getConsultData(category = goodType, uid = userId)
}
//首页问答 - 点赞
fun askZan(id: String): Observable<BaseResponse<AskResultBean>> {
val cmd = AskRequestParamBean.ZanAction("2", id)
return getPhpHomPagerApi().askZan(formatParams(cmd))
}
//首页问答 - 关注
fun askFocus(id: String): Observable<BaseResponse<AskResultBean>> {
val cmd = AskRequestParamBean.FocusCmd(id, "1")
return getPhpHomPagerApi().askFocus(formatParams(cmd))
}
//壹点冥想
fun newMuseRequest(): Observable<BaseAPIResponse<MuseModuleBean>> {
return getHomPagerApi().getMuseData()
}
private fun formatParams(cmd: BaseCommand) =
YdlRetrofitUtils.getMaps(YdlRetrofitUtils.getPostList(cmd))
}
\ No newline at end of file
package com.yidianling.home.http
import com.yidianling.home.model.bean.*
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.ydlcommon.app.YdlCommonApp
import com.yidianling.ydlcommon.bean.MuseModuleBean
import com.yidianling.ydlcommon.data.YdlDataManager
import com.yidianling.ydlcommon.http.BaseAPIResponse
import com.yidianling.ydlcommon.http.BaseResponse
import io.reactivex.Observable
import retrofit2.http.*
/**
* @author jiucheng
* @描述:首页接口api
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/8/22
*/
interface HomePagerApi {
/**
* 首页头部数据 Banner&分类
*/
@GET("home/index")
fun getHomeHeaderData(): Observable<BaseAPIResponse<HomeHeaderBean>>
/**
* 首页咨询请求
* goodType 为空或不传 则获取默认类型数据
*/
@GET("doctor/list")
fun getConsultData(@Query("categories") category: String,
@Query("limit") limit: String = "3",
@Query("page") page: String = "1",
@Query("uid") uid: String,
@Query("searchWord") searchWord: String = "",
@Query("showType") showType: String = "0",
@Query("ffrom") ffrom: String = YdlDataManager.getRam().getChannelName(),
@Query("version") version: String = RxDeviceTool.getAppVersionName(YdlCommonApp.getApp())
): Observable<BaseAPIResponse<HomeConsultBean>>
/**
* 首页倾述请求
* goodType 为空或不传 则获取默认类型数据
*/
@GET("auth/listen/search")
fun getConfideData(@Query("goodType") goodType: String,
@Query("limit") limit: String = "3",
@Query("page") page: String = "1",
// 1: 查询第一个类型列表,较goodType比,低优先级
@Query("isDefaultType") isDefaultType: String = "1",
@Query("uid") uid: String,
@Query("ffrom") ffrom: String = YdlDataManager.getRam().getChannelName(),
@Query("version") version: String = RxDeviceTool.getAppVersionName(YdlCommonApp.getApp())
): Observable<BaseAPIResponse<HomeConfideBean>>
//首页课程请求
@GET("auth/course/getList")
fun getCourseData(@Query("listType") listType: String = "10",
@Query("limit") limit: String = "3",
@Query("uid") uid: String,
@Query("ffrom") ffrom: String = YdlDataManager.getRam().getChannelName(),
@Query("version") version: String = RxDeviceTool.getAppVersionName(YdlCommonApp.getApp())
): Observable<BaseAPIResponse<HomeCourseBean>>
//首页测试请求
@GET("test-item/home-recommend")
fun getTestData(@Query("uid") uid: String,
@Query("ffrom") ffrom: String = YdlDataManager.getRam().getChannelName(),
@Query("version") version: String = RxDeviceTool.getAppVersionName(YdlCommonApp.getApp())
): Observable<BaseAPIResponse<MutableList<HomeTestItemBean>>>
//首页问答请求
@GET("ask/list-old")
fun getAskData(@Query("perPageRows") perPageRows: String = "6",
@Query("tab") tab: String = "2",
@Query("accessToken") accessToken: String,
@Query("uid") uid: String
): Observable<BaseAPIResponse<HomeAskBean>>
//首页电台请求
@GET("fm/list/all")
fun getFMData(@Query("perPageRows") perPageRows: String = "4"): Observable<BaseAPIResponse<HomeFMBean>>
//首页文章请求
@GET("article/list/all")
fun getArticleData(@Query("perPageRows") perPageRows: String = "4"): Observable<BaseAPIResponse<HomeArticleBean>>
//首页问答 - 点赞
@FormUrlEncoded
@POST("sq-active/zan")
fun askZan(@FieldMap params: Map<String, String>): Observable<BaseResponse<AskResultBean>>
//首页问答 - 关注
@FormUrlEncoded
@POST("sq-active/focus")
fun askFocus(@FieldMap params: Map<String, String>): Observable<BaseResponse<AskResultBean>>
//壹点 - 冥想
@GET("meditation/meditation/list")
fun getMuseData(): Observable<BaseAPIResponse<MuseModuleBean>>
}
\ No newline at end of file
package com.yidianling.home.listener
import android.content.Context
import android.support.design.widget.TabLayout
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import com.yidianling.home.adapter.YdlHomeAdapter
import com.yidianling.home.constract.IHomeContract
import com.yidianling.home.constract.YdlHomeViewHolderConstract
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
/**
* @author yuanwai
* @描述:悬浮按钮监听事件
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/9/25
*/
class HomeConfideRecyleSuspendListener : RecyclerView.OnScrollListener() {
private var mContext : Context? = null
private var mCurrentPosition = 0
private var mSuspensionHeight: Int = RxImageTool.dip2px(51f)
//倾诉筛选layout
private var confideFilterView: LinearLayout? = null
//咨询筛选layout
private var consultFilterView : LinearLayout? = null
//首页界面View接口
private var mHomeView : IHomeContract.View? = null
private var adapter: YdlHomeAdapter? = null
private var mPhoneCallView : ImageView? = null
//是否执行收缩动画
private var excuteStartAnim : Boolean = true
//是否执行展开动画
private var excuteEndAnim : Boolean = true
private var dp5 : Int = 0
private var dp14 : Int = 0
private var dp15 : Int = 0
private var dp34 : Int = 0
private var cvWidth : Int = 0
private var maxCVWidth : Int = 0
private var minCVWidth : Int = 0
init {
dp5 = RxImageTool.dip2px(5f)
dp14 = RxImageTool.dip2px(14f)
dp15 = RxImageTool.dip2px(15f)
dp34 = RxImageTool.dip2px(34f)
}
fun setContext(context: Context){
mContext = context
cvWidth = RxDeviceTool.getScreenWidth(context) - RxImageTool.dip2px(73f)
minCVWidth = RxImageTool.dip2px(105f)
maxCVWidth = cvWidth
}
fun setHomeView(homeView : IHomeContract.View){
this.mHomeView = homeView
}
fun setConfideFilterView(filterView: LinearLayout) {
this.confideFilterView = filterView
}
fun setConsultFilterView(filterView: LinearLayout){
this.consultFilterView = filterView
}
fun setSectionAdapter(adapter: YdlHomeAdapter) {
this.adapter = adapter
}
fun setPhoneCallImageView(callView : ImageView){
this.mPhoneCallView = callView
}
override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
if (null != confideFilterView) {
mSuspensionHeight = confideFilterView!!.height
}
}
override fun onScrolled(recyclerView: RecyclerView?, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
if (null == adapter) {
return
}
Log.e("Tag", "-------dy=$dy")
// moveSearchView(dy)
val manager = recyclerView!!.layoutManager as LinearLayoutManager
if (mCurrentPosition != manager.findFirstVisibleItemPosition()) {
mCurrentPosition = manager.findFirstVisibleItemPosition()
}
if (adapter!!.getItemViewType(mCurrentPosition) == YdlHomeViewHolderConstract.CONFIDE_VIEW) {
val view = manager.findViewByPosition(mCurrentPosition)
if (view != null) {
if (view is ViewGroup) {
if (view.getChildAt(1) is TabLayout) {
val tabLayout = view.getChildAt(1)
val location = IntArray(2)
tabLayout.getLocationOnScreen(location)
if (location[1] - RxImageTool.dip2px(40f) <= mSuspensionHeight) {
confideFilterView!!.visibility = View.VISIBLE
} else {
confideFilterView!!.visibility = View.INVISIBLE
}
}
}
}
val nextView = manager.findViewByPosition(mCurrentPosition + 1)
if (nextView != null) {
if (nextView.top <= (mSuspensionHeight + RxImageTool.dip2px(41f))) {
confideFilterView!!.visibility = View.INVISIBLE
}
}
}else if (adapter!!.getItemViewType(mCurrentPosition) == YdlHomeViewHolderConstract.CONSULT_VIEW) {
val view = manager.findViewByPosition(mCurrentPosition)
if (view != null) {
if (view is ViewGroup) {
if (view.getChildAt(1) is TabLayout) {
val tabLayout = view.getChildAt(1)
val location = IntArray(2)
tabLayout.getLocationOnScreen(location)
if (location[1] - RxImageTool.dip2px(40f) <= mSuspensionHeight) {
consultFilterView?.visibility = View.VISIBLE
} else {
consultFilterView?.visibility = View.INVISIBLE
}
}
}
}
val nextView = manager.findViewByPosition(mCurrentPosition + 1)
if (nextView != null) {
if (nextView.top <= (mSuspensionHeight + RxImageTool.dip2px(41f))) {
consultFilterView!!.visibility = View.INVISIBLE
}
}
}else if (adapter!!.getItemViewType(mCurrentPosition) == YdlHomeViewHolderConstract.BUTTON_BANNER_VIEW){
if (excuteStartAnim){
mHomeView?.startAnim()
excuteStartAnim = false
excuteEndAnim = true
}
confideFilterView?.visibility = View.INVISIBLE
consultFilterView?.visibility = View.INVISIBLE
} else if (adapter!!.getItemViewType(mCurrentPosition) == YdlHomeViewHolderConstract.PAGER_BANNER_VIEW){
if (excuteEndAnim){
mHomeView?.endAnim()
excuteEndAnim = false
excuteStartAnim = true
}
confideFilterView?.visibility = View.INVISIBLE
consultFilterView?.visibility = View.INVISIBLE
}else {
confideFilterView?.visibility = View.INVISIBLE
consultFilterView?.visibility = View.INVISIBLE
}
}
/**
* 移动搜索View
*/
private fun moveSearchView(dy : Int){
// if (null != mCardView){
// cvWidth -= dy
// if (cvWidth < minCVWidth){
// cvWidth = minCVWidth
// mPhoneCallView?.visibility = View.GONE
// }else if (cvWidth > maxCVWidth){
// cvWidth = maxCVWidth
// mPhoneCallView?.visibility = View.VISIBLE
// }else{
// mPhoneCallView?.visibility = View.VISIBLE
// }
// val params = RelativeLayout.LayoutParams(cvWidth,dp34)
// params.setMargins(dp15,dp14,dp15,dp5)
// mCardView?.layoutParams = params
// }
}
}
\ No newline at end of file
package com.yidianling.home.model
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.RxUtils
import com.yidianling.home.http.HomeHttp
import com.yidianling.home.constract.IHomeContract
import com.yidianling.home.model.bean.*
import com.yidianling.ydlcommon.http.BaseAPIResponse
import com.yidianling.ydlcommon.bean.MuseModuleBean
import com.yidianling.ydlcommon.http.RxUtils
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述:
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
class HomeModelImpl {
companion object {
/**
* 首页咨询请求
*/
fun consultRequest(category: String): Observable<HomeConsultBean> {
return HomeHttp.getInstance().getConsultData(category).compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeConsultBean(true) }
}
/**
* 首页问答 - 点赞
*/
fun askZan(id: String): Observable<AskResultBean> {
return HomeHttp.getInstance().askZan(id).compose(RxUtils.resultData())
}
/**
* 首页问答 - 关注
*/
fun askFocus(id: String): Observable<AskResultBean> {
return HomeHttp.getInstance().askFocus(id).compose(RxUtils.resultData())
}
/**
* 首页电台请求
*/
fun fmRequest(): Observable<HomeFMBean> {
return HomeHttp.getInstance().getFMData().compose(RxUtils.resultJavaData())
.onErrorReturn { HomeFMBean(true) }
}
/**
* 首页课程请求
*/
fun courseRequest(): Observable<HomeCourseBean> {
return HomeHttp.getInstance().getCourseData().compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeCourseBean(true) }
}
/**
* 首页测试题请求
*/
fun testRequest(): Observable<BaseAPIResponse<MutableList<HomeTestItemBean>>> {
return HomeHttp.getInstance().getTestData()
}
/**
* 首页倾听请求
*/
fun confideRequest(goodType: String): Observable<HomeConfideBean> {
return HomeHttp.getInstance().getConfideData(goodType).compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeConfideBean(true) }
}
/**
* 首页问答请求
*/
fun askRequest(): Observable<HomeAskBean> {
return HomeHttp.getInstance().getAskData().compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeAskBean(true) }
}
/**
* 首页文章请求
*/
fun articleRequest(): Observable<HomeArticleBean> {
return HomeHttp.getInstance().getArticleData().compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeArticleBean(true) }
}
/**
* 首页头部 分类&Banner请求
*/
fun headerRequest(): Observable<HomeHeaderBean> {
return HomeHttp.getInstance().newHomeHeaderRequest().compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeHeaderBean(true) }
}
/**
* 首页冥想请求
*/
fun museRequest(): Observable<MuseModuleBean> {
return HomeHttp.getInstance().newMuseRequest().compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { MuseModuleBean(true) }
}
}
}
\ No newline at end of file
package com.yidianling.home.model.bean;
import com.ydl.ydlcommon.data.http.BaseCommand;
/**
* Created by haorui on 2019/2/19.
* Des:
*/
public class AskRequestParamBean {
//关注
public static class FocusCmd extends BaseCommand {
public String id;//话题id或用户uid
public String type;//业务类型:1关注用户,2关注话题
public FocusCmd(String id, String type) {
this.id = id;
this.type = type;
}
}
//点赞:动态,回帖,个人主页
public static class ZanAction extends BaseCommand {
public String type;//业务类型:1访问用户,2动态,3话题
public String id;//动态id,回复id,用户uid
public ZanAction(String type, String id) {
this.type = type;
this.id = id;
}
}
}
package com.yidianling.home.model.bean
/**
* Created by haorui on 2019/2/19.
* Des:
*/
class AskResultBean {
/**
* 点赞接口 1:点赞 2:取消赞
*/
var status: Int = 0
}
\ No newline at end of file
package com.yidianling.home.model.bean
import com.yidianling.ydlcommon.bean.HomeItemBaseBean
/**
* Created by haorui on 2019/2/14.
* Des:首页文章模块参数
*/
class HomeArticleBean : HomeItemBaseBean {
constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty)
var category: List<CategoryBean>? = null
var list: List<Bean>? = null
class CategoryBean {
var descript: String? = null
var id: Int = 0
var isShow: Int = 0
var keyword: String? = null
var name: String? = null
var parentId: Int = 0
var place: Int = 0
var title: String? = null
}
class Bean {
/**
* 收藏数
*/
var countOfFavorite: Int = 0
var createTime: String? = null
var createTimeFormat: String? = null
/**
* 文章简介
*/
var desc: String? = null
var doctorId: Int = 0
private var hUrl: String? = null
/**
* 文章id
*/
var id: Int = 0
/**
* 封面图片地址
*/
var imgUrl: String? = null
var url: String? = null
/**
* 医生名字
*/
var name: String? = null
/**
* 笔名
*/
var pseudonym: String? = null
/**
* 阅读次数
*/
var readNum: Int = 0
/**
* 120*120小头像
*/
var smallImage: String? = null
/**
* 标题
*/
var title: String? = null
fun gethUrl(): String? {
return hUrl
}
fun sethUrl(hUrl: String) {
this.hUrl = hUrl
}
}
}
package com.yidianling.home.model.bean
import com.google.gson.annotations.SerializedName
import com.yidianling.ydlcommon.bean.HomeItemBaseBean
/**
* Created by haorui on 2019/2/14.
* Des:首页问答模块参数
*/
class HomeAskBean : HomeItemBaseBean {
constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty)
var data: MutableList<DataBean>? = null
@SerializedName(value = "ext_data", alternate = ["extData"])
var ext_data: List<ExtDataBean>? = null
var bannerResps: List<BannerResp>? = null
class BannerResp {
var bannerId: Int? = 0 //bannerId ,
var bannerImageUrl: String? = null //图片地址 ,
var bannerLinkUrl: String? = null //链接地址 ,
var bannerTitle: String? = null //标题
}
class DataBean {
/**
* askId
*/
var id: Int = 0
/**
* 问答创建时间
*/
@SerializedName(value = "timeStr", alternate = ["time_str"])
var timeStr: String? = null
/**
* 浏览数量,点击数量
*/
var hits: Int = 0
/**
* 问题的标题
*/
var title: String? = null
/**
* 内容类型:1纯文本,2图片,3图文,4url链接和app内部跳转
*/
var multitextType: Int = 0
/**
* 话题id,1:心事问答
*/
var topicId: Int = 0
/**
* 回帖量
*/
var replyCounter: Int = 0
/**
* multitype=4时候添加到这个字段,json格式4:{url: '',cover:'',topicTitle:''}
*/
var extContent: String? = null
/**
* 问答发布内容
*/
var content: String? = null
/**
* 问答发布者uid,匿名为0
*/
var uid: Int = 0
/**
* 问答发布显示名称,匿名null
*/
var name: String? = null
/**
* 问答发布者性别
*/
var gender: Int = 0
/**
* 问答标签
*/
var askTag: String? = null
/**
* 总的温暖数量
*/
var zanCount: Int = 0
/**
* 问答发布者头像,匿名为null
*/
var avatar: String? = null
/**
* 安卓,问答发布者头像,匿名为null
*/
var header: String? = null
/**
* 评论数
*/
var commentsCount: Int = 0
/**
* 话题的标题
*/
var topicTitle: String? = null
/**
* 点赞id,0为未点赞
*/
var isZan: Int = 0
/**
* 访问量
*/
var visitCount: Int = 0
/**
* 来自平台
*/
var from: String? = null
var utype: Int = 0
/**
* 是否为广告
*/
@SerializedName(value = "isAd", alternate = ["is_ad"])
var isAd: Int = 0
/**
* 广告的跳转
*/
var url: String? = null
var adImg: String? = null
var focId: Int = 0
/**
* 是否关注 1关注
*/
var isFocused: Int = 0
var share: Any? = null
var isSelf: Int = 0
/**
* multitype=4,5时候添加到这个字段,json格式4:{url: '',cover:'',title:''};5待定
*/
var ext: Any? = null
/**
* 附件
*/
var smallAttach: List<*>? = null
/**
* 附件
*/
var bigAttach: List<*>? = null
/**
* 问答答案列表
*/
var comments: List<CommentsBean>? = null
class CommentsBean {
/**
* 评论用户显示姓名
*/
var name: String? = null
/**
* 评论内容
*/
var content: String? = null
/**
* 文章评论专家姓名
*/
@SerializedName(value = "toName", alternate = ["to_name"])
var toName: String? = null
/**
* 评论用户头像
*/
var userHead: String? = null
/**
* 评论发表时间
*/
var answerCreateTime: String? = null
/**
* 问答创建时间
*/
var time_str: String? = null
/**
* 文章评论内容
*/
@SerializedName(value = "toContent", alternate = ["to_content"])
var toContent: String? = null
/**
* 文章评论id
*/
var id: Int = 0
/**
* 评论用户id
*/
var uid: Int = 0
/**
* 评论问答id
*/
var askId: Int = 0
var zan: Int = 0
/**
* 文章评论用户性别
*/
var gender: Int = 0
/**
* 文章评论用户类型, 2则为专家
*/
@SerializedName(value = "userType", alternate = ["user_type"])
var userType: Int = 0
/**
* 文章评论专家id
*/
@SerializedName(value = "doctorId", alternate = ["doctor_id"])
var doctorId: Int = 0
/**
* 是否开通倾诉 0-否 1-是
*/
var isOpenListen: Int = 0
/**
* 是否空闲 0-否 1-是
*/
var isAvailable: Int = 0
/**
* 倾诉链接
*/
var listenLinkUrl: String? = null
}
}
class ExtDataBean {
var id: Int = 0
var type: Int = 0
var parentId: Int = 0
var status: Int = 0
var doctorId: Int = 0
var uid: Int = 0
var createTime: String? = null
var updateTime: Any? = null
var deleteTime: Any? = null
var deleteUser: String? = null
var isDelete: Int = 0
var hits: Int = 0
var tags: String? = null
var tags2: String? = null
var askSource: String? = null
var ffrom: String? = null
var fsid: String? = null
var browser: String? = null
var favTotalNum: Int = 0
var ip: String? = null
var title: String? = null
var showTips: Any? = null
var channel: String? = null
var platform: String? = null
var isTop: Int = 0
var zhuishuTop: Int = 0
var multitextType: Any? = null
var topicId: Int = 0
var isPublish: Any? = null
var isHot: Any? = null
var replyCounter: Int = 0
var zanCounter: Int = 0
var extContent: String? = null
var hotTime: Int = 0
var topTime: Int = 0
var anonymous: Any? = null
var checkStatus: Any? = null
var operateStatus: Any? = null
var topRule: Any? = null
var topPage: Any? = null
var isDoctorShow: Any? = null
var content: String? = null
}
}
package com.yidianling.home.model.bean
import com.yidianling.ydlcommon.bean.HomeItemBaseBean
/**
* Created by haorui on 2019/2/14.
* Des:首页倾听模块参数
*/
class HomeConfideBean : HomeItemBaseBean {
constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty)
var type: Int = 0
var diviLine: Int = 0
/**
* 头像
*/
var head: Any? = null
var body: List<BodyBean>? = null
class BodyBean {
var confidedId: Int = 0
var confidedName: String? = null
/**
* 头像
*/
var confidedIcon: String? = null
var confideHearNum: String? = null
var doctorId: Int = 0
var uid: Int = 0
var confideVoice: String? = null
var tags: String? = null
var confideContent: String? = null
var confideSex: Int = 0
var status: Int = 0
/**
* 通话状态
* 1在线 2离线 3通话中 4继续倾诉
*/
var confideLine: Int = 0
var confideAddress: String? = null
var confidePraise: String? = null
/**
* 实际费用
*/
var confideFee: String? =null
/**
* 接通率
*/
var confideConnection: String? = null
/**
* 人数
*/
var confideNum: String? = null
/**
* 跳转地址
*/
var linkUrl: String? = null
/**
* 红包金额
*/
var couponMoney: String? = null
var confidedTag: List<String>? = null
/**
* 红包展示文本
*/
var couponText : String? = null
}
}
package com.yidianling.home.model.bean
import com.google.gson.annotations.SerializedName
import com.yidianling.ydlcommon.bean.HomeItemBaseBean
/**
* Created by haorui on 2019/3/13.
* Des:
*/
class HomeConsultBean: HomeItemBaseBean {
constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty)
/**
* pageNum : 1
* pageSize : 3
* size : 3
* startRow : 1
* endRow : 3
* pages : 962
* prePage : 0
* nextPage : 2
* isFirstPage : true
* isLastPage : false
* hasPreviousPage : false
* hasNextPage : true
* navigatePages : 8
* navigatepageNums : [1,2,3,4,5,6,7,8]
* navigateFirstPage : 1
* navigateLastPage : 8
* total : 2884
* list : [{"doctorUid":97078,"doctorId":1614,"doctorName":"姜建萍","doctorHead":"https://img.ydlcdn.com/file/2018/10/20/juffcjgn6cphz7ef.jpg!s120x120","profesBack":"二级心理咨询师\r\n中学高级教师\r\n学校心理咨询师\r\n30年教育教学管理工作经历","tags":["恋爱婚姻","情绪压力","孩子教育"],"serviceFee":300,"zixunOrderNum":4841,"feedbackRate":99.7,"province":"北京","city":"北京","isOnline":1,"mUrl":"https://m.ydl.com/experts/1614","hUrl":"https://h2.yidianling.com/experts/1614","share":{"title":"姜建萍咨询工作室","cover":"https://img.ydlcdn.com/file/2018/10/20/juffcjgn6cphz7ef.jpg!s120x120","desc":"","shareUrl":"https://m.ydl.com/experts/1614","share_url":"https://m.ydl.com/experts/1614"},"isHiddenXcx":""},{"doctorUid":1204629,"doctorId":3351,"doctorName":"孙丽","doctorHead":"https://img.ydlcdn.com/file/2018/10/05/98cf1af2dc5c6f8e2c4a9ac43f58bd8d..jpg!s120x120","profesBack":"二级心理咨询师\r\n教师资格认证","tags":["恋爱婚姻","孩子教育","情绪压力"],"serviceFee":100,"zixunOrderNum":2590,"feedbackRate":100,"province":"江苏省","city":"南京","isOnline":1,"mUrl":"https://m.ydl.com/experts/3351","hUrl":"https://h2.yidianling.com/experts/3351","share":{"title":"孙丽咨询工作室","cover":"https://img.ydlcdn.com/file/2018/10/05/98cf1af2dc5c6f8e2c4a9ac43f58bd8d..jpg!s120x120","desc":"","shareUrl":"https://m.ydl.com/experts/3351","share_url":"https://m.ydl.com/experts/3351"},"isHiddenXcx":""},{"doctorUid":1177559,"doctorId":3118,"doctorName":"李艳","doctorHead":"https://img.ydlcdn.com/file/2017/02/22/5799q3ctnrm7hhi9.jpg!s120x120","profesBack":"二级心理咨询师\r\n三级心理咨询师","tags":["情绪压力","恋爱婚姻","上岗认证"],"serviceFee":150,"zixunOrderNum":4868,"feedbackRate":99.9,"province":"北京","city":"北京","isOnline":1,"mUrl":"https://m.ydl.com/experts/3118","hUrl":"https://h2.yidianling.com/experts/3118","share":{"title":"李艳咨询工作室","cover":"https://img.ydlcdn.com/file/2017/02/22/5799q3ctnrm7hhi9.jpg!s120x120","desc":"","shareUrl":"https://m.ydl.com/experts/3118","share_url":"https://m.ydl.com/experts/3118"},"isHiddenXcx":""}]
*/
var size: Int = 0
var list: MutableList<ListBean>? = null
class ListBean {
/**
* doctorUid : 97078
* doctorId : 1614
* doctorName : 姜建萍
* doctorHead : https://img.ydlcdn.com/file/2018/10/20/juffcjgn6cphz7ef.jpg!s120x120
* profesBack : 二级心理咨询师
* 中学高级教师
* 学校心理咨询师
* 30年教育教学管理工作经历
* tags : ["恋爱婚姻","情绪压力","孩子教育"]
* serviceFee : 300
* zixunOrderNum : 4841
* feedbackRate : 99.7
* province : 北京
* city : 北京
* isOnline : 1
* mUrl : https://m.ydl.com/experts/1614
* hUrl : https://h2.yidianling.com/experts/1614
* share : {"title":"姜建萍咨询工作室","cover":"https://img.ydlcdn.com/file/2018/10/20/juffcjgn6cphz7ef.jpg!s120x120","desc":"","shareUrl":"https://m.ydl.com/experts/1614","share_url":"https://m.ydl.com/experts/1614"}
* isHiddenXcx :
*/
//字段名称改了
@SerializedName("uid")
var doctorUid: Int = 0
var doctorId: String = ""
@SerializedName("name")
var doctorName: String? = null
@SerializedName("head")
var doctorHead: String? = null
var profesBack: String? = null
@SerializedName("minBookingPrice")
var serviceFee: Int = 0
var zixunOrderNum: Int = 0
var feedbackRate: Float = 0f
var province: String? = null
var city: String? = null
var isOnline: Int = 0
var mUrl: String? = null
@SerializedName("linkUrl")
var hUrl: String? = null
var share: ShareBean? = null
var isHiddenXcx: String? = null
var tags: String? = null
class ShareBean {
/**
* title : 姜建萍咨询工作室
* cover : https://img.ydlcdn.com/file/2018/10/20/juffcjgn6cphz7ef.jpg!s120x120
* desc :
* shareUrl : https://m.ydl.com/experts/1614
* share_url : https://m.ydl.com/experts/1614
*/
var title: String? = null
var cover: String? = null
var desc: String? = null
var shareUrl: String? = null
var share_url: String? = null
}
}
}
package com.yidianling.home.model.bean
import com.yidianling.ydlcommon.bean.HomeItemBaseBean
/**
* Created by haorui on 2019/2/14.
* Des:首页课程模块参数
*/
class HomeCourseBean : HomeItemBaseBean {
constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty)
var pageNum: Int = 0
var pageSize: Int = 0
var size: Int = 0
var startRow: Int = 0
var endRow: Int = 0
var pages: Int = 0
var prePage: Int = 0
var nextPage: Int = 0
var isIsFirstPage: Boolean = false
var isIsLastPage: Boolean = false
var isHasPreviousPage: Boolean = false
var isHasNextPage: Boolean = false
var navigatePages: Int = 0
var navigateFirstPage: Int = 0
var navigateLastPage: Int = 0
var total: Int = 0
var navigatepageNums: List<Int>? = null
var list: List<ListBean>? = null
class ListBean {
var shareData: ShareDataBean? = null
var id: Int = 0
/**
* 课程标题
*/
var title: String? = null
/**
* 课程图
*/
var pic: String? = null
/**
* 课程价格
*/
var applyFee: Float? = null
/**
* 课程原价
*/
var originalApplyFee: Float? = null
/**
* 课程促销价
*/
var promotionApplyFee: Float? = null
/**
* 课程报名人数
*/
var joinNum: Int = 0
/**
* 课程浏览量
*/
var readNums: Int = 0
/**
* 是否促销 1活动中 2结束or没开始 3倒计时
*/
var isPromotion: Int = 0
/**
* 是否返利 1是双返利 2是单返利 0无返利
*/
var isInvite: Int = 0
/**
* 主讲人uid
*/
var hostUid: Int = 0
/**
* 主讲人头像
*/
var hostHead: String? = null
/**
* 主讲人倾诉id
*/
var hostConfidedId: Int = 0
/**
* 主讲人专家id
*/
var hostId: Int = 0
/**
* 主讲人名称
*/
var hostName: String? = null
/**
* 主讲人是否开通私聊 0-否 1-是
*/
var isOpenChat: Int = 0
/**
* 主讲人是否开通倾诉 0-否 1-是
*/
var isOpenListen: Int = 0
/**
* 主讲人是否空闲 0-否 1-是
*/
var isAvailable: Int = 0
/**
* 主讲人是否开通咨询 0-否 1-是
*/
var isOpenConsult: Int = 0
/**
* 聊天跳转资源
*/
var chatLinkUri: String? = null
/**
* 咨询跳转资源
*/
var consultLinkUri: String? = null
/**
* 倾诉跳转资源
*/
var listenLinkUri: String? = null
/**
* 是否展示倾诉咨询聊天三个按钮 0-否 1-是
*/
var isShowHostButton: Int = 0
class ShareDataBean {
var title: String? = null
var cover: String? = null
var desc: String? = null
var shareUrl: String? = null
}
}
}
package com.yidianling.home.model.bean
import com.yidianling.ydlcommon.bean.HomeItemBaseBean
/**
* Created by haorui on 2019/2/14.
* Des:首页电台模块参数
*/
class HomeFMBean : HomeItemBaseBean {
constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty)
var endRow: Int = 0
var isHasNextPage: Boolean = false
var isHasPreviousPage: Boolean = false
var isIsFirstPage: Boolean = false
var isIsLastPage: Boolean = false
var navigateFirstPage: Int = 0
var navigateLastPage: Int = 0
var navigatePages: Int = 0
var nextPage: Int = 0
var pageNum: Int = 0
var pageSize: Int = 0
var pages: Int = 0
var prePage: Int = 0
var size: Int = 0
var startRow: Int = 0
var total: Int = 0
var list: List<ListBean>? = null
var navigatepageNums: List<Int>? = null
class ListBean {
var adminId: Int = 0
var appImg: String? = null
var author: String? = null
var categoryId: Int = 0
var createTime: String? = null
var description: String? = null
/**
* 喜欢人数
*/
var favorites: Int = 0
/**
* 电台地址
*/
var fmUrl: String? = null
/**
* 收听人数
*/
var hits: Int = 0
var id: Int = 0
/**
* 封面地址
*/
var imageUrl: String? = null
var isOriginal: String? = null
var isShow: String? = null
var name: String? = null
var orderNum: Int = 0
var period: String? = null
var shareCount: Int = 0
var updateTime: String? = null
}
}
package com.yidianling.home.model.bean
import com.yidianling.router.consultant.Keyworks
import com.yidianling.ydlcommon.bean.HomeItemBaseBean
/**
* Created by haorui on 2019/2/14.
* Des:首页头部模块数据 Banner&分类
*/
class HomeHeaderBean : HomeItemBaseBean {
constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty)
/**
* 活动弹窗数据
*/
var activityResponse: ActivityResponse? = null
/**
* 分类数据
*/
var askCategoryData: MutableList<AskCategoryDataBean>? = null
/**
* 焦点图数据
*/
var focusList: List<FocusListBean>? = null
/**
* 滚动销售数据
*/
var homeSaleData: List<HomeSaleDataBean>? = null
/**
* 搜索关键词数据
*/
var keywordData: MutableList<Keyworks>? = null
/**
* 倾诉分类
*/
var listenCategoryDate: List<ListenCategoryDateBean>? = null
/**
* 咨询分类
*/
var consultCategoryData: List<ConsultCategoryDateBean>? = null
/**
* 专家名称
*/
var doctorName : String? = null
class AskCategoryDataBean {
/**
* id
*/
var cateId: Int = 0
/**
* 名称
*/
var cateTitle: String? = null //
/**
* 跳转url
*/
var url: String? = null
/**
* 图片icon
*/
var coverUrl: String? = null
}
class FocusListBean {
/**
* 标题
*/
var title: String? = null
/**
* 跳转链接
*/
var linkUrl: String? = null
/**
* 图片
*/
var imageUrl: String? = null
/**
* iPhone X图片
*/
var imageIphonex: String? = null
/**
* 焦点图id
*/
var focId: Int = 0
/**
* 分享数据
*/
var shareData: Any? = null
}
class ConsultCategoryDateBean {
var id: Int = 0
var name: String? = null
}
class HomeSaleDataBean {
/**
* 用户昵称
*/
var nickName: String? = null
/**
* 老师名字
*/
var doctorName: String? = null
/**
* 老师id
*/
var doctorId: Int = 0
/**
* 跳转专家主页
*/
var url: String? = null
/**
* 内容开头
*/
var contentBefore: String? = null
/**
* 内容结尾
*/
var contentAfter: String? = null
/**
* 创建时间
*/
var createTime: String? = null
}
class ListenCategoryDateBean {
var id: Int = 0
var name: String? = null
}
class ActivityResponse{
var imageBanner:String? = null// 弹窗图片
var imageUrl: String?=null// 图片
var linkUrl:String?=null // 首页弹窗
var btnLinkurl:String?=null // 首页入口(左上角图标)
var title :String? = null// 标题
}
}
package com.yidianling.home.model.bean
import com.yidianling.ydlcommon.bean.MuseModuleBean
/**
* Created by haorui on 2019/2/14.
* Des:首页数据
*/
class HomePagerDataBean() {
constructor(type: Int) : this() {
this.type = type;
}
constructor(homeHeaderBean: HomeHeaderBean,
homeConsultBean: HomeConsultBean,
homeConfideBean: HomeConfideBean,
homeCourseBean: HomeCourseBean,
testListBean: MutableList<HomeTestItemBean>?,
homeAskBean: HomeAskBean,
museBean: MuseModuleBean,
homeFMBean: HomeFMBean,
homeArticleBean: HomeArticleBean):this(){
this.headerBean = homeHeaderBean
this.consultBean = homeConsultBean
this.articleBean = homeArticleBean
this.askBean = homeAskBean
this.courseBean = homeCourseBean
this.testListBean = testListBean
this.museBean = museBean
this.fmBean = homeFMBean
this.confideBean = homeConfideBean
}
/**
* 咨询模块数据
*/
var consultBean: HomeConsultBean? = null
/**
* 文章模块数据
*/
var articleBean: HomeArticleBean? = null
/**
* 问答模块数据
*/
var askBean: HomeAskBean? = null
/**
* 课程模块数据
*/
var courseBean: HomeCourseBean? = null
/**
* 测试模块数据
*/
var testListBean: MutableList<HomeTestItemBean>? = null
/**
* 冥想模块数据
*/
var museBean: MuseModuleBean? = null
/**
* 电台模块数据
*/
var fmBean: HomeFMBean? = null
/**
* 倾述模块数据
*/
var confideBean: HomeConfideBean? = null
/**
* 首页头部数据
*/
var headerBean: HomeHeaderBean? = null
/**
* 模块分类 @see [com.yidianling.home.constract.YdlHomeViewHolderConstract]
*/
var type: Int?= 0
}
package com.yidianling.home.model.bean
import com.yidianling.ydlcommon.bean.HomeItemBaseBean
/**
* Created by xj on 2019/9/29.
*/
class HomeTestBean: HomeItemBaseBean {
constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty)
/**
* 分类数据
*/
var testItemList: MutableList<HomeTestItemBean>? = null
}
\ No newline at end of file
package com.yidianling.home.model.bean;
/**
* Created by haorui on 2019/3/13.
* Des:
*/
public class HomeTestItemBean {
/**
* id : 1003
* name : 产后抑郁症状评估
* shareImage : http://img.diggme.cn/2018/03/15/f6475c6d9fc547e2d6d99d1efa43fd9d.jpg?x-oss-process=image/auto-orient,1/resize,m_lfit,w_300/quality,q_90
* testNum : 1
* hits : 133
* countOfResult : 1
*/
private int id;
private String name;
private String shareImage;
private int testNum;
private int hits;
private int countOfResult;
private String recommendLinkUrl;
public String getRecommendLinkUrl() {
return recommendLinkUrl;
}
public void setRecommendLinkUrl(String recommendLinkUrl) {
this.recommendLinkUrl = recommendLinkUrl;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getShareImage() {
return shareImage;
}
public void setShareImage(String shareImage) {
this.shareImage = shareImage;
}
public int getTestNum() {
return testNum;
}
public void setTestNum(int testNum) {
this.testNum = testNum;
}
public int getHits() {
return hits;
}
public void setHits(int hits) {
this.hits = hits;
}
public int getCountOfResult() {
return countOfResult;
}
public void setCountOfResult(int countOfResult) {
this.countOfResult = countOfResult;
}
}
package com.yidianling.home.ui.view
import android.app.Activity
import android.app.Dialog
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.text.TextUtils
import com.yidianling.home.R
import com.yidianling.ydlcommon.pay.model.CouponBean
import kotlinx.android.synthetic.main.dialog_coupon.*
/**
* @author jiucheng
* @描述:首页优惠券弹窗
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/8/6
*/
class CouponDialog : Dialog {
private var activity: Activity? = null
var status: Int = STATUS_RECEIVER
var couponBean: CouponBean? = null
var list: List<CouponBean>? = null
var listener: OnClickEnsureListener? = null
companion object {
var STATUS_RECEIVER = 0 //立即领取
var STATUS_GET = 1 //查看我的卡券
}
constructor(activity: Activity?, list: List<CouponBean>, listener: OnClickEnsureListener?) : super(activity) {
this.activity = activity
this.couponBean = list[0]
this.list = list
this.listener = listener
}
fun updateStatus(status: Int) {
this.status = status
updateUiByStatus()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.dialog_coupon)
setCanceledOnTouchOutside(false)
window.setBackgroundDrawable(ColorDrawable())
if (couponBean != null) {
if (!TextUtils.isEmpty(couponBean!!.title)) {
tv_title.text = couponBean!!.title
}
tv_duration.text = couponBean!!.validity
if (TextUtils.equals("1", couponBean!!.type)) {
tv_money.text = couponBean!!.amount
tv_unit.text = "元"
} else {
tv_money.text = (couponBean!!.discount.toFloat() * 10).toString()
tv_unit.text = "折"
}
tv_limit.text = couponBean!!.condition
}
updateUiByStatus()
tv_ensure.setOnClickListener {
if (listener != null) {
listener!!.clickEnsure(status)
}
if (status == STATUS_GET) {
dismiss()
}
}
iv_close.setOnClickListener {
dismiss()
}
}
private fun updateUiByStatus() {
var title = ""
var ensureText = ""
var iamge = 0
when (status) {
STATUS_RECEIVER -> {
if (list!!.size > 1) {
title = "获得${list!!.size}张新的优惠券"
} else {
title = "获得新优惠券"
}
ensureText = "立即领取"
iamge = R.drawable.coupon_receiver
}
STATUS_GET -> {
if (list!!.size > 1) {
title = "获得${list!!.size}张新的优惠券"
} else {
title = "恭喜您,领取成功"
}
ensureText = "查看我的卡券"
iamge = R.drawable.coupon_success
}
}
iv_title.setImageResource(iamge)
tv_status.text = title
tv_ensure.text = ensureText
}
interface OnClickEnsureListener {
fun clickEnsure(status: Int)
}
override fun show() {
if (null == activity || activity!!.isFinishing) {
return
}
super.show()
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeArticleBean
import com.ydl.ydl_image.manager.YDLImageCacheManager
import kotlinx.android.synthetic.main.home_module_article_item_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 文章*阅读模块item
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/14
*/
class HomeArticleItemView(private val mContext: Context, private var homeEvent: IHomeEvent?): LinearLayout(mContext) {
init {
initView()
}
private fun initView() {
val params = RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
View.inflate(mContext, R.layout.home_module_article_item_view, this)
}
fun updateData(bean: HomeArticleBean.Bean?) {
homeModuleArticleItemViewTitle.text = bean?.title
homeModuleArticleItemViewContent.text = bean?.desc
homeModuleArticleItemViewAuthor.text = bean?.name
homeModuleArticleItemViewGreatNum.text = bean?.countOfFavorite.toString()
homeModuleArticleItemViewLookNum.text = bean?.readNum.toString()
YDLImageCacheManager.showImage(mContext,bean?.imgUrl,homeModuleArticleItemViewImg)
setOnClickListener {
homeEvent?.articleItemClick(bean)
}
}
/**
* 最后一个item需要隐藏item的下划线
*/
fun hideBottomLine() {
homeModuleArticleItemViewBottomLine.visibility = View.GONE
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeArticleBean
import kotlinx.android.synthetic.main.home_module_article_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 文章*阅读模块
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
class HomeArticleView(private val mContext: Context, private var homeEvent: IHomeEvent?) : LinearLayout(mContext) {
private var cacheList : ArrayList<HomeArticleBean.Bean> = ArrayList()
init {
initView()
}
private fun initView() {
orientation = VERTICAL
val params = RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
View.inflate(mContext, R.layout.home_module_article_view, this)
homeModuleArticleViewHomeCommonTitleView.setTitle("文章·阅读")
homeModuleArticleViewHomeCommonTitleView.setOnClickListener {
homeEvent?.articleMoreClick()
}
}
fun initData(list: List<HomeArticleBean.Bean>?) {
//添加View
list?.let {
if (cacheList.size != list?.size) {
cacheList.clear()
cacheList.addAll(list!!)
updateHomeArticleItemViewNumber()
}
//刷新数据
for (index in 0 until childCount) {
val itemView = getChildAt(index)
if (itemView is HomeArticleItemView) {
itemView.updateData(list[index - 1])
// 最后一个隐藏底部横线
if (index == childCount - 1) {
itemView.hideBottomLine()
}
}
}
}
}
/**
* 更新itemView的数量以适应新的数据集
*/
private fun updateHomeArticleItemViewNumber() {
var childCountRecord = childCount -1 //减1是因为第一个子View是标题View
while (cacheList.size > childCountRecord) {
addView(HomeArticleItemView(mContext, homeEvent))
childCountRecord++
}
while (cacheList.size < childCountRecord && getChildAt(childCountRecord) is HomeArticleItemView) {
removeViewAt(childCountRecord)
childCountRecord--
}
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.support.v7.widget.CardView
import android.util.Log
import android.view.View
import android.widget.LinearLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.yidianling.common.tools.RxDeviceTool
import kotlinx.android.synthetic.main.home_module_assuage_grief_image_more_five_item_view.view.*
import kotlinx.android.synthetic.main.home_module_assuage_grief_image_under_four_item_view.view.*
import kotlinx.android.synthetic.main.home_module_assuage_grief_image_under_two_item_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 解忧*问答模块内部图片模块
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/15
*/
class HomeAssuageGriefImageItemView(private val mContext: Context, private val urlList: List<String>, private var homeEvent: IHomeEvent?) : CardView(mContext) {
init {
initView()
}
private fun initView() {
radius = 4f
cardElevation = 0f
var screenWidth = RxDeviceTool.getScreenWidth(mContext)
var viewWidth = (screenWidth - 2 * 30 * RxDeviceTool.getScreenDensity(mContext)).toInt()
var params: LinearLayout.LayoutParams?
//根据图片的数量,加载不同的图片布局
if (urlList.size <= 2) {
var viewHeight = viewWidth * 178 / 315
params = LinearLayout.LayoutParams(viewWidth, viewHeight)
params.bottomMargin = (20 * RxDeviceTool.getScreenDensity(mContext)).toInt()
layoutParams = params
View.inflate(mContext, R.layout.home_module_assuage_grief_image_under_two_item_view, this)
YDLImageCacheManager.showImage(mContext, urlList[0], homeModuleAssuageGriefUnderTwoItemViewImg)
} else if (urlList.size <= 4) {
var viewHeight = viewWidth * 178 / 315
params = LinearLayout.LayoutParams(viewWidth, viewHeight)
params.bottomMargin = (20 * RxDeviceTool.getScreenDensity(mContext)).toInt()
layoutParams = params
View.inflate(mContext, R.layout.home_module_assuage_grief_image_under_four_item_view, this)
YDLImageCacheManager.showImage(mContext, urlList[0], homeModuleAssuageGriefUnderFourItemViewFirstImg)
YDLImageCacheManager.showImage(mContext, urlList[1], homeModuleAssuageGriefUnderFourItemViewSecondImg)
YDLImageCacheManager.showImage(mContext, urlList[2], homeModuleAssuageGriefUnderFourItemViewThirdImg)
homeModuleAssuageGriefUnderFourthItemViewTag.text = urlList.size.toString() + "图"
} else if (urlList.size >= 5) {
var viewHeight = viewWidth * 180 / 315
params = LinearLayout.LayoutParams(viewWidth, viewHeight)
params.bottomMargin = (20 * RxDeviceTool.getScreenDensity(mContext)).toInt()
layoutParams = params
View.inflate(mContext, R.layout.home_module_assuage_grief_image_more_five_item_view, this)
YDLImageCacheManager.showImage(mContext, urlList[0], homeModuleAssuageGriefUnderFiveItemViewFirstImg)
YDLImageCacheManager.showImage(mContext, urlList[1], homeModuleAssuageGriefUnderFiveItemViewSecondImg)
YDLImageCacheManager.showImage(mContext, urlList[2], homeModuleAssuageGriefUnderFiveItemViewThirdImg)
YDLImageCacheManager.showImage(mContext, urlList[3], homeModuleAssuageGriefUnderFiveItemViewFourthImg)
YDLImageCacheManager.showImage(mContext, urlList[4], homeModuleAssuageGriefUnderFiveItemViewFiveImg)
homeModuleAssuageGriefUnderFiveItemViewTag.text = urlList.size.toString() + "图"
}
}
fun updateData() {
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeAskBean
import kotlinx.android.synthetic.main.home_module_assuage_grief_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 解忧*问答模块
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
class HomeAssuageGriefView(private val mContext: Context, private var homeEvent: IHomeEvent?) : LinearLayout(mContext) {
private var cacheList: ArrayList<HomeAskBean.DataBean> = ArrayList()
init {
initView()
}
private fun initView() {
orientation = VERTICAL
val params = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
View.inflate(mContext, R.layout.home_module_assuage_grief_view, this)
homeModuleAssuageGriefViewHomeCommonTitleView.setTitle("解忧·问答")
homeModuleAssuageGriefViewHomeCommonTitleView.setOnClickListener {
homeEvent?.askMoreClick()
}
}
fun initData(position: Int, list: List<HomeAskBean.DataBean>?) {
//添加View
list?.let {
if (null != list && cacheList.size != list?.size) {
cacheList.clear()
cacheList.addAll(list!!)
updateHomeAssuageGriefItemViewNumber()
}
//刷新数据
for (index in 0..childCount) {
val itemView = getChildAt(index)
if (itemView is HomeAssuageGriefItemView) {
if ((index - 1) < list!!.size) {
itemView.updateData(list!![index - 1], position, index - 1)
}
}
}
}
}
/**
* 更新itemView的数量以适应新的数据集
*/
private fun updateHomeAssuageGriefItemViewNumber() {
var childCountRecord = childCount - 1 //减1是因为第一个子View是标题View
while (cacheList.size > childCountRecord) {
addView(HomeAssuageGriefItemView(mContext, homeEvent))
childCountRecord++
}
while (cacheList.size < childCountRecord && getChildAt(childCountRecord) is HomeAssuageGriefItemView) {
removeViewAt(childCountRecord)
childCountRecord--
}
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.common.tools.RxDeviceTool
import kotlinx.android.synthetic.main.home_module_button_banner_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 顶部预约专家,即时倾诉,心理课堂,心理测试按钮模块
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
class HomeButtonBannerView(private val mContext: Context, private var homeEvent: IHomeEvent?) : LinearLayout(mContext) {
private var buttonParams: LinearLayout.LayoutParams? = null
init {
initView()
}
private fun initView() {
val params = RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
View.inflate(mContext, R.layout.home_module_button_banner_view, this)
initButtonView()
homeModuleButtonBannerFirst.setOnClickListener {
homeEvent?.reservationExpertsClick()
}
homeModuleButtonBannerSecond.setOnClickListener {
homeEvent?.nowConfideClick()
}
homeModuleButtonBannerThird.setOnClickListener {
homeEvent?.psychologyClassClick()
}
homeModuleButtonBannerFourth.setOnClickListener {
homeEvent?.psychologyTestClick()
}
}
/**
* 初始化四个按钮
*/
private fun initButtonView() {
if (null == buttonParams) {
var screenWidth = RxDeviceTool.getScreenWidth(mContext)
var viewWidth = ((screenWidth - 2 * 9 * RxDeviceTool.getScreenDensity(mContext)) / 4).toInt()
var viewHeight = viewWidth * 78 / 80
buttonParams = LinearLayout.LayoutParams(viewWidth, viewHeight)
homeModuleButtonBannerFirst.layoutParams = buttonParams
homeModuleButtonBannerSecond.layoutParams = buttonParams
homeModuleButtonBannerThird.layoutParams = buttonParams
homeModuleButtonBannerFourth.layoutParams = buttonParams
}
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.support.v4.view.ViewPager
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import com.yidianling.home.R
import com.yidianling.home.adapter.HomeCategoryAdapter
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeHeaderBean
import com.yidianling.common.tools.RxImageTool
import kotlinx.android.synthetic.main.home_module_category_container.view.*
/**
* created by HaoRui
* des: 首页分类Pager包装类
*/
class HomeCategoryContainer(private val mContext: Context, private var homeEvent: IHomeEvent?) : RelativeLayout(mContext), ViewPager.OnPageChangeListener {
private var mHomeCategoryAdapter: HomeCategoryAdapter? = null
private var indicatorImages: MutableList<ImageView>? = ArrayList()
private var mIndicatorSelectedResId = R.drawable.home_module_category_tip_select
private var mIndicatorUnselectedResId = R.drawable.home_module_category_tip_unselect
private var lastPosition = 0
private var count = 0
private var mIndicatorWidth: Int = RxImageTool.dip2px(9f)
private var mIndicatorHeight: Int = RxImageTool.dip2px(5f)
private var dp2 : Int = 0
companion object {
var PAGE_ITEM_SIZE:Int = 10
}
init {
initView()
dp2 = RxImageTool.dip2px(4f)
}
private fun initView() {
View.inflate(mContext, R.layout.home_module_category_container, this)
initViewPager()
}
/**
* 填充数据
*/
fun initData(bean: HomeHeaderBean?) {
mHomeCategoryAdapter?.updateItems(bean?.askCategoryData)
if (bean?.askCategoryData?.size!! > PAGE_ITEM_SIZE){
count = Math.ceil(Math.ceil(bean.askCategoryData?.size?.toFloat()?.div(PAGE_ITEM_SIZE.toFloat())?.toDouble()!!)).toInt()
createIndicator()
val params = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,RxImageTool.dip2px(153f))
vp_category.layoutParams = params
}else{
val params = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,RxImageTool.dip2px(143f))
vp_category.layoutParams = params
ll_Indicator.visibility = View.GONE
}
}
private fun initViewPager() {
if (null == mHomeCategoryAdapter) {
mHomeCategoryAdapter = HomeCategoryAdapter(context, homeEvent)
vp_category.adapter = mHomeCategoryAdapter
}
}
private fun createIndicator() {
vp_category.addOnPageChangeListener(this)
indicatorImages?.clear()
ll_Indicator.visibility = visibility
ll_Indicator.removeAllViews()
for (i in 0 until count) {
val imageView = ImageView(context)
val params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(mIndicatorWidth, mIndicatorHeight)
params.rightMargin = dp2
if (i == 0) {
imageView.setImageResource(mIndicatorSelectedResId)
} else {
imageView.setImageResource(mIndicatorUnselectedResId)
}
indicatorImages?.add(imageView)
ll_Indicator.addView(imageView, params)
}
}
override fun onPageScrollStateChanged(state: Int) {
}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
}
override fun onPageSelected(position: Int) {
indicatorImages?.get(lastPosition)?.setImageResource(mIndicatorUnselectedResId)
indicatorImages?.get(position)?.setImageResource(mIndicatorSelectedResId)
lastPosition = position
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.graphics.PointF
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.util.Log
import android.view.MotionEvent
/**
* @author yuanWai
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/3/22
*/
class HomeCategoryViewPager : ViewPager {
constructor(context: Context) : super(context){
}
constructor(context: Context,attributeSet: AttributeSet) : super(context,attributeSet){
}
/** 触摸时按下的点 */
private var downP = PointF()
/** 触摸时当前的点 */
private var curP = PointF()
/** 触摸抬起的点 */
private var upP = PointF()
private var mOnSingleTouchListener: OnSingleTouchListener? = null
override fun onInterceptTouchEvent(arg0: MotionEvent): Boolean {
// TODO Auto-generated method stub
//当拦截触摸事件到达此位置的时候,返回true,
//说明将onTouch拦截在此控件,进而执行此控件的onTouchEvent
return true
}
override fun onTouchEvent(arg0: MotionEvent): Boolean {
// TODO Auto-generated method stub
//每次进行onTouch事件都记录当前的按下的坐标
curP.x = arg0.x
curP.y = arg0.y
if (arg0.action == MotionEvent.ACTION_DOWN) {
//记录按下时候的坐标
//切记不可用 downP = curP ,这样在改变curP的时候,downP也会改变
downP.x = arg0.x
downP.y = arg0.y
//此句代码是为了通知他的父ViewPager现在进行的是本控件的操作,不要对我的操作进行干扰
// parent.requestDisallowInterceptTouchEvent(true)
}
if (arg0.action == MotionEvent.ACTION_MOVE) {
//此句代码是为了通知他的父ViewPager现在进行的是本控件的操作,不要对我的操作进行干扰
// parent.requestDisallowInterceptTouchEvent(true)
}
if (arg0.action == MotionEvent.ACTION_UP) {
upP.x = arg0.x
upP.y = arg0.y
val x = Math.abs(upP.x - downP.x)
val y = Math.abs(upP.y - downP.y)
val z = Math.sqrt(((x * x) + (y * y)).toDouble())
val jiaodu = Math.round((Math.asin(y / z) / Math.PI * 180))// 角度
if (upP.y < downP.y && jiaodu > 45) {// 上
Log.d("onTouchEvent-ACTION_UP", "角度:$jiaodu, 動作:上")
parent.requestDisallowInterceptTouchEvent(false)
} else if (upP.y > downP.y && jiaodu > 45) {// 下
Log.d("onTouchEvent-ACTION_UP", "角度:$jiaodu, 動作:下")
parent.requestDisallowInterceptTouchEvent(false)
} else if (upP.x < downP.x && jiaodu <= 45) {// 左
Log.d("onTouchEvent-ACTION_UP", "角度:$jiaodu, 動作:左")
// 原方向不是向右時,方向轉右
parent.requestDisallowInterceptTouchEvent(true)
} else if (upP.x > downP.x && jiaodu <= 45) {// 右
Log.d("onTouchEvent-ACTION_UP", "角度:$jiaodu, 動作:右")
// 原方向不是向左時,方向轉右
parent.requestDisallowInterceptTouchEvent(true)
}
//在up时判断是否按下和松手的坐标为一个点
//如果是一个点,将执行点击事件,这是我自己写的点击事件,而不是onclick
if (downP.x == curP.x && downP.y == curP.y) {
onSingleTouch()
return true
}
}
return super.onTouchEvent(arg0)
}
/**
* 单击
*/
private fun onSingleTouch() {
mOnSingleTouchListener?.onSingleTouch()
}
fun setOnSingleTouchListener(onSingleTouchListener : OnSingleTouchListener){
mOnSingleTouchListener = onSingleTouchListener
}
/**
* 创建点击事件接口
* @author wanpg
*/
interface OnSingleTouchListener {
fun onSingleTouch()
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.support.constraint.ConstraintLayout
import android.util.AttributeSet
import android.view.View
import android.widget.LinearLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import kotlinx.android.synthetic.main.home_module_common_title_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 首页通用标题
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/14
*/
class HomeCommonTitleView(private val mContext: Context, private val attributeSet: AttributeSet) : ConstraintLayout(mContext, attributeSet) {
init {
initView()
}
private fun initView() {
View.inflate(mContext, R.layout.home_module_common_title_view, this)
}
fun setTitle(title: String) {
homeModuleCommonTitleViewTitle.text = title
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Paint
import android.text.TextUtils
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeConfideBean
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.yidianling.common.tools.RxImageTool
import kotlinx.android.synthetic.main.home_module_confide_expert_info_view.view.*
/**
* @author jiucheng
* @描述:首页倾诉模块--专家个人信息view
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/2/16
*/
class HomeConfideExpertInfoView(private var mContext: Context, private var homeEvent: IHomeEvent?) : FrameLayout(mContext) {
private var dp70 = 0
init {
initView()
dp70 = RxImageTool.dip2px(70f)
}
private fun initView() {
var params = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
View.inflate(context, R.layout.home_module_confide_expert_info_view, this)
}
fun setData(bean: HomeConfideBean.BodyBean?, position: Int, isLast: Boolean) {
if (bean == null) {
visibility = View.GONE
return
}
//设置头像
setHead(bean)
//设置名称
tv_name.text = bean.confidedName
//咨询师标签
tag_view.initData(bean.confidedTag as MutableList<String>)
//设置向TA倾诉人数
setConfideNum(bean)
//设置接通率文案
setConnection(bean)
//设置向TA倾诉按钮状态
setConfideButton(bean)
//设置红包、原价
setCoupon(bean)
//最后一项显示分割线
if (isLast) {
view_line.visibility = View.GONE
} else {
view_line.visibility = View.VISIBLE
}
this.setOnClickListener {
homeEvent!!.confideClick(bean.linkUrl,bean.doctorId)
}
}
/**
* 设置头像
*/
private fun setHead(bean: HomeConfideBean.BodyBean) {
val op = SimpleImageOpConfiger()
op.errorPic = com.yidianling.ydlcommon.R.drawable.head_place_hold_pic
op.loadingPic = com.yidianling.ydlcommon.R.drawable.head_place_hold_pic
op.transform = 0
YDLImageCacheManager.showImage(mContext, bean.confidedIcon, img_head, op)
}
/**
* 设置向TA倾诉人数
*/
private fun setConfideNum(bodyBean: HomeConfideBean.BodyBean) {
if (TextUtils.isEmpty(bodyBean.confideNum)) {
tv_confideNum.visibility = View.GONE
tv_tv_confideNumContent.visibility = View.GONE
} else {
tv_confideNum.visibility = View.VISIBLE
tv_tv_confideNumContent.visibility = View.VISIBLE
tv_confideNum.text = bodyBean.confideNum
}
}
/**
* 设置接通率文案
*/
private fun setConnection(bodyBean: HomeConfideBean.BodyBean) {
if (TextUtils.isEmpty(bodyBean.confideConnection)) {
tv_Connection.visibility = View.INVISIBLE
tv_ConnectionContent.visibility = View.INVISIBLE
} else {
tv_Connection.visibility = View.VISIBLE
tv_ConnectionContent.visibility = View.VISIBLE
tv_Connection.text = bodyBean.confideConnection
}
}
/**
* 设置向TA倾诉按钮状态
*/
private fun setConfideButton(bodyBean: HomeConfideBean.BodyBean) {
when (bodyBean.confideLine) {//1在线 2离线 3通话中 4继续倾诉
1 -> {
tv_confide.setBackgroundResource(R.drawable.home_module_confide_line_1)
}
2 -> {
tv_confide.setBackgroundResource(R.drawable.home_module_confide_line_2)
}
3 -> {
tv_confide.setBackgroundResource(R.drawable.home_module_confide_line_3)
}
4 -> {
tv_confide.setBackgroundResource(R.drawable.home_module_confide_line_4)
}
}
tv_confide.setOnClickListener {
if (bodyBean.confideLine == 2) {//喊他上线 私聊
homeEvent!!.toChatForMsg(bodyBean.uid.toString())
} else {
homeEvent!!.confideClick(bodyBean.linkUrl, bodyBean.doctorId)
}
}
}
/**
* 设置红包、原价
*/
@SuppressLint("SetTextI18n")
private fun setCoupon(bodyBean: HomeConfideBean.BodyBean) {
if(!TextUtils.isEmpty(bodyBean.couponText)){
tvCoupon.text = bodyBean.couponText
tvCoupon.visibility = View.VISIBLE
}else{
tvCoupon.visibility = View.GONE
}
if (TextUtils.isEmpty(bodyBean.confideFee) || TextUtils.isEmpty(bodyBean.couponMoney) || bodyBean.couponMoney!!.toFloat() <= 0){
tvOriginalPrice.visibility = View.GONE
}else{
tvOriginalPrice.visibility = View.VISIBLE
val originalBuffer = StringBuffer()
originalBuffer.append(bodyBean.confideFee).append("元/次")
tvOriginalPrice.text = originalBuffer.toString()
//添加删除线
tvOriginalPrice.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG
}
try {
val couponMoney = bodyBean.couponMoney!!.toFloat().toInt()
val confideFee = bodyBean.confideFee!!.toFloat().toInt()
if (couponMoney >= confideFee){
tv_price.text = "¥0"
}else{
val price = confideFee - couponMoney
tv_price.text = "¥"+price.toString()
}
}catch (e:Exception){
//防止数据类型变化引起奔溃
}
}
}
package com.yidianling.home.ui.view
import android.content.Context
import android.graphics.Typeface
import android.os.Build
import android.support.design.widget.TabLayout
import android.support.v4.content.ContextCompat
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeConfideBean
import com.yidianling.home.model.bean.HomeHeaderBean
import com.yidianling.common.tools.LogUtil
import kotlinx.android.synthetic.main.home_module_confide_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 倾诉*排解模块
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
class HomeConfideView(private val mContext: Context, private var homeEvent: IHomeEvent?) : LinearLayout(mContext) {
private var mLastPosition: Int = 0
/**
* 专家信息view缓存list
*/
private var cacheInfoViewList: ArrayList<HomeConfideExpertInfoView>? = null
/**
* TabLayout.OnTabSelectedListener
*/
private var listener: ConfideExpertTabSelectedListener? = null
init {
initView()
}
private fun initView() {
val params = RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
orientation = VERTICAL
View.inflate(mContext, R.layout.home_module_confide_view, this)
homeModuleConfideViewHomeCommonTitleView.setTitle("倾诉·排解")
homeModuleConfideViewHomeCommonTitleView.setOnClickListener {
homeEvent?.confideMoreClick()
}
}
/**
* 创建tab栏
* @param lastPosition 上次选中的下标
*/
fun setTitle(list: List<HomeHeaderBean.ListenCategoryDateBean>?, lastPosition: Int) {
if (list == null || list.isEmpty()) {
visibility = View.GONE
return
}
if (listener != null) {
tab_layout.removeOnTabSelectedListener(listener!!)
}
mLastPosition = lastPosition
tab_layout.removeAllTabs()
for ((index, bean) in list.withIndex()) {
tab_layout.addTab(tab_layout.newTab().setText(bean.name), index == lastPosition)
}
listener = ConfideExpertTabSelectedListener(list, tab_layout)
tab_layout.addOnTabSelectedListener(listener!!)
var textView = ((tab_layout!!.getChildAt(0) as LinearLayout).getChildAt(lastPosition) as LinearLayout).getChildAt(1)
if (textView != null && textView is TextView) {
textView.textSize = 17f
textView.setTextColor(ContextCompat.getColor(mContext, R.color.color_242424))
textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
tab_layout.setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY ->
LogUtil.e("scrollX=$scrollX")
LogUtil.e("oldScrollX=$oldScrollX")
}
}
}
/**
* 设置数据
*/
fun setConfideExpertInfoView(list: List<HomeConfideBean.BodyBean>?) {
if (list == null || list.isEmpty()) {
ll_content.visibility = View.GONE
return
}
ll_content.visibility = View.VISIBLE
ll_content.removeAllViews()
if (cacheInfoViewList == null) {
cacheInfoViewList = ArrayList()
}
//创建HomeConfideExpertInfoView:每个tab最多显示三个专家
if (cacheInfoViewList!!.size >= list.size) {
for (index in 0 until list!!.size) {
//设置数据
cacheInfoViewList!![index].setData(list[index]!!, index, index == list!!.size - 1)
//添加到布局
ll_content.addView(cacheInfoViewList!![index])
}
} else {
for (index in 0 until list!!.size) {
if (index > 2) {
//只取前三条数据
break
}
//数据大于缓存view数量,创建view
if (index > cacheInfoViewList!!.size - 1) {
var homeConfideExpertInfoView = createExpertInfoView()
cacheInfoViewList!!.add(homeConfideExpertInfoView)
}
//设置数据
cacheInfoViewList!![index].setData(list[index]!!, index, index == list!!.size - 1)
//添加到布局
ll_content.addView(cacheInfoViewList!![index])
}
}
}
/**
* 创建专家信息view
*/
private fun createExpertInfoView(): HomeConfideExpertInfoView {
return HomeConfideExpertInfoView(mContext, homeEvent)
}
inner class ConfideExpertTabSelectedListener : TabLayout.OnTabSelectedListener {
private var list: List<HomeHeaderBean.ListenCategoryDateBean>? = null
private var tabLayout: TabLayout? = null
constructor(list: List<HomeHeaderBean.ListenCategoryDateBean>, tabLayout: TabLayout) {
this.list = list
this.tabLayout = tabLayout
}
override fun onTabReselected(tab: TabLayout.Tab?) {
}
override fun onTabUnselected(tab: TabLayout.Tab?) {
var textView = ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(1)
if (textView != null && textView is TextView) {
textView.textSize = 15f
textView.setTextColor(ContextCompat.getColor(mContext, R.color.color_333333))
}
}
override fun onTabSelected(tab: TabLayout.Tab?) {
if (mLastPosition == tab!!.position){
return
}
var textView = ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(1)
if (textView != null && textView is TextView) {
textView.textSize = 17f
textView.setTextColor(ContextCompat.getColor(mContext, R.color.color_242424))
textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
}
homeEvent!!.getConfideData(list!![tab!!.position], tab!!.position)
}
}
}
package com.yidianling.home.ui.view
import android.content.Context
import android.text.TextUtils
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeConsultBean
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.yidianling.common.tools.RxImageTool
import com.yidianling.ydlcommon.tool.StringUtils
import com.yidianling.ydlcommon.utils.URLUtils
import kotlinx.android.synthetic.main.home_module_consult_item_view.view.*
/**
* @author jiucheng
* @描述:首页咨询理解模块--专家个人信息view
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/2/16
*/
class HomeConsultItemView(private var mContext: Context, private var homeEvent: IHomeEvent?) : FrameLayout(mContext) {
private var dp70 = 0
init {
initView()
dp70 = RxImageTool.dip2px(70f)
}
private fun initView() {
val params = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
View.inflate(context, R.layout.home_module_consult_item_view, this)
}
fun setData(bean: HomeConsultBean.ListBean?, position: Int, isLast: Boolean,cateId : String?) {
if (bean == null) {
visibility = View.GONE
return
}
//设置头像
setHead(bean)
//设置名称
tv_consult_name.text = bean.doctorName
//咨询师标签
tag_view.initData(StringUtils.strToList(bean.tags))
//设置向TA倾诉人数
setConfideNum(bean)
//设置接通率文案
setConnection(bean)
//设置向TA倾诉按钮状态
setConfideButton(bean)
//设置红包、原价
setPrice(bean)
this.setOnClickListener {
val url = URLUtils.appendParmas(bean.hUrl,"cateId",cateId)
homeEvent!!.consultItemClick(url,bean.doctorId)
}
}
/**
* 设置头像
*/
private fun setHead(bean: HomeConsultBean.ListBean) {
val op = SimpleImageOpConfiger()
op.errorPic = com.yidianling.ydlcommon.R.drawable.head_place_hold_pic
op.loadingPic = com.yidianling.ydlcommon.R.drawable.head_place_hold_pic
op.transform = 0
YDLImageCacheManager.showImage(mContext, bean.doctorHead, img_consult_head, op)
}
/**
* 设置向TA倾诉人数
*/
private fun setConfideNum(bodyBean: HomeConsultBean.ListBean) {
if (TextUtils.isEmpty(bodyBean.zixunOrderNum.toString())) {
tv_consult_num.visibility = View.GONE
tv_tv_consult_num_content.visibility = View.GONE
} else {
tv_consult_num.visibility = View.VISIBLE
tv_tv_consult_num_content.visibility = View.VISIBLE
tv_consult_num.text = bodyBean.zixunOrderNum.toString()
}
}
/**
* 设置接通率文案
*/
private fun setConnection(bodyBean: HomeConsultBean.ListBean) {
if (TextUtils.isEmpty(bodyBean.feedbackRate.toString())) {
tv_feedback_rate.visibility = View.INVISIBLE
tv_feedback_rate_content.visibility = View.INVISIBLE
} else {
tv_feedback_rate.visibility = View.VISIBLE
tv_feedback_rate_content.visibility = View.VISIBLE
try {
val dd = bodyBean.feedbackRate/5.00f
val str = String.format("%.2f",dd*100f)+"%"
tv_feedback_rate.text = str
}catch (e:Exception){
e.printStackTrace()
}
}
}
/**
* 设置咨询按钮事件
*/
private fun setConfideButton(bodyBean: HomeConsultBean.ListBean) {
tv_consult_chat.setOnClickListener {
homeEvent!!.consultChatClick(bodyBean.doctorUid.toString())
}
}
private fun setPrice(bodyBean: HomeConsultBean.ListBean) {
val confideFee = bodyBean.serviceFee
val sb = StringBuffer()
tv_price.text = sb.append("¥").append(confideFee).toString()
}
}
package com.yidianling.home.ui.view
import android.content.Context
import android.graphics.Typeface
import android.os.Build
import android.support.design.widget.TabLayout
import android.support.v4.content.ContextCompat
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeConsultBean
import com.yidianling.home.model.bean.HomeHeaderBean
import com.yidianling.common.tools.LogUtil
import kotlinx.android.synthetic.main.home_module_confide_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 咨询理解模块
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
class HomeConsultView(private val mContext: Context, private var homeEvent: IHomeEvent?) : LinearLayout(mContext) {
private var mLastPosition: Int = 0
/**
* 专家信息view缓存list
*/
private var cacheInfoViewList: ArrayList<HomeConsultItemView>? = null
/**
* TabLayout.OnTabSelectedListener
*/
private var listener: ConsultTabSelectedListener? = null
/**
* 当前选中cateId
*/
var cateId = 0
init {
initView()
}
private fun initView() {
val params = RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
orientation = VERTICAL
View.inflate(mContext, R.layout.home_module_confide_view, this)
homeModuleConfideViewHomeCommonTitleView.setTitle("咨询·理解")
homeModuleConfideViewHomeCommonTitleView.setOnClickListener {
homeEvent?.consultMoreClick()
}
}
/**
* 创建tab栏
* @param lastPosition 上次选中的下标
*/
fun setTitle(list: List<HomeHeaderBean.ConsultCategoryDateBean>?, lastPosition: Int) {
if (list == null || list.isEmpty()) {
visibility = View.GONE
return
}
if (listener != null) {
tab_layout.removeOnTabSelectedListener(listener!!)
}
mLastPosition = lastPosition
tab_layout.removeAllTabs()
for ((index, bean) in list.withIndex()) {
tab_layout.addTab(tab_layout.newTab().setText(bean.name), index == lastPosition)
}
listener = ConsultTabSelectedListener(list, tab_layout)
tab_layout.addOnTabSelectedListener(listener!!)
val textView = ((tab_layout!!.getChildAt(0) as LinearLayout).getChildAt(lastPosition) as LinearLayout).getChildAt(1)
if (textView != null && textView is TextView) {
textView.textSize = 17f
textView.setTextColor(ContextCompat.getColor(mContext, R.color.color_242424))
textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
tab_layout.setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY ->
LogUtil.e("scrollX=$scrollX")
LogUtil.e("oldScrollX=$oldScrollX")
}
}
}
/**
* 设置数据
*/
fun setConsultInfoView(list: List<HomeConsultBean.ListBean>?,category : HomeHeaderBean.ConsultCategoryDateBean?) {
if (list == null || list.isEmpty()) {
ll_content.visibility = View.GONE
return
}
cateId = category?.id?:0
ll_content.visibility = View.VISIBLE
if (cacheInfoViewList == null) {
cacheInfoViewList = ArrayList()
}
//创建HomeConsultItemView:每个tab最多显示三个专家
if (cacheInfoViewList!!.size == list.size) {
for (index in 0 until list.size) {
//设置数据
val itemView = ll_content.getChildAt(index)
if (itemView is HomeConsultItemView){
itemView.setData(list[index], index, index == list.size - 1,"${category?.id}")
}
}
} else {
ll_content.removeAllViews()
cacheInfoViewList?.clear()
for (index in 0 until list!!.size) {
if (index > 2) {
//只取前三条数据
break
}
//数据大于缓存view数量,创建view
if (index > cacheInfoViewList!!.size - 1) {
val homeConsultItemView = createConsultInfoView()
cacheInfoViewList!!.add(homeConsultItemView)
}
//设置数据
cacheInfoViewList!![index].setData(list[index]!!, index, index == list!!.size - 1,"${category?.id}")
//添加到布局
ll_content.addView(cacheInfoViewList!![index])
}
}
}
/**
* 创建专家信息view
*/
private fun createConsultInfoView(): HomeConsultItemView {
return HomeConsultItemView(mContext, homeEvent)
}
inner class ConsultTabSelectedListener : TabLayout.OnTabSelectedListener {
private var list: List<HomeHeaderBean.ConsultCategoryDateBean>? = null
private var tabLayout: TabLayout? = null
constructor(list: List<HomeHeaderBean.ConsultCategoryDateBean>, tabLayout: TabLayout) {
this.list = list
this.tabLayout = tabLayout
}
override fun onTabReselected(tab: TabLayout.Tab?) {
}
override fun onTabUnselected(tab: TabLayout.Tab?) {
var textView = ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(1)
if (textView != null && textView is TextView) {
textView.textSize = 15f
textView.setTextColor(ContextCompat.getColor(mContext, R.color.color_333333))
}
}
override fun onTabSelected(tab: TabLayout.Tab?) {
if (mLastPosition == tab!!.position){
return
}
var textView = ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(1)
if (textView != null && textView is TextView) {
textView.textSize = 17f
textView.setTextColor(ContextCompat.getColor(mContext, R.color.color_242424))
textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
}
val bean = list!![tab!!.position]
homeEvent!!.getConsultData(bean, tab!!.position)
}
}
}
package com.yidianling.home.ui.view
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.RelativeLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeCourseBean
import com.ydl.ydl_image.manager.YDLImageCacheManager
import kotlinx.android.synthetic.main.home_module_course_item_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 课程成长模块item
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/14
*/
class HomeCourseItemView(private val mContext: Context, private var homeEvent: IHomeEvent?): RelativeLayout(mContext) {
init {
initView()
}
private fun initView() {
val params = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
View.inflate(mContext, R.layout.home_module_course_item_view, this)
}
/**
* 刷新数据
*/
fun updateData(bean: HomeCourseBean.ListBean?) {
YDLImageCacheManager.showImage(mContext,bean?.pic,homeModuleCourseItemViewImg)
homeModuleCourseItemViewTitle.text = bean?.title
homeModuleCourseItemViewPersonNum.text = bean?.readNums.toString()
if (bean?.applyFee == 0f) {
homeModuleCourseItemViewFreePrice.visibility = View.VISIBLE
homeModuleCourseItemViewExpensePriceHideView.visibility = View.GONE
}else {
if (bean?.isPromotion == 1) {
homeModuleCourseItemViewExpensePrice.text = "¥" + String.format("%.2f", bean?.promotionApplyFee!!)
}else {
homeModuleCourseItemViewExpensePrice.text = "¥" + String.format("%.2f", bean?.applyFee!!)
}
}
setOnClickListener {
homeEvent?.courseItemClick(bean)
}
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeCourseBean
import kotlinx.android.synthetic.main.home_module_course_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 课程*成长模块
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
class HomeCourseView(private val mContext: Context, private var homeEvent: IHomeEvent?): LinearLayout(mContext) {
private var cacheList : ArrayList<HomeCourseBean.ListBean> = ArrayList()
init {
initView()
}
private fun initView() {
orientation = VERTICAL
val params = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
View.inflate(mContext, R.layout.home_module_course_view, this)
homeModuleCourseViewHomeCommonTitleView.setTitle("课程·成长")
homeModuleCourseViewHomeCommonTitleView.setOnClickListener {
homeEvent?.courseMreClick()
}
}
fun initData(list: List<HomeCourseBean.ListBean>?) {
//添加View
if (list==null){
return
}
if (cacheList.size != list?.size){
cacheList.clear()
cacheList.addAll(list!!)
updateHomeCourseItemViewNumber()
}
//刷新数据
for (index in 0 until childCount){
val itemView = getChildAt(index)
if (itemView is HomeCourseItemView){
itemView.updateData(list[index - 1])
}
}
}
/**
* 更新itemView的数量以适应新的数据集
*/
private fun updateHomeCourseItemViewNumber() {
var childCountRecord = childCount -1 //减1是因为第一个子View是标题View
while (cacheList.size > childCountRecord) {
addView(HomeCourseItemView(mContext, homeEvent))
childCountRecord++
}
while (cacheList.size < childCountRecord && getChildAt(childCountRecord) is HomeCourseItemView) {
removeViewAt(childCountRecord)
childCountRecord--
}
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeFMBean
import com.yidianling.common.tools.RxImageTool
import kotlinx.android.synthetic.main.home_module_intelligent_item_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 心灵电台模块item
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/14
*/
class HomeIntelligentItemView(private val mContext: Context, private var homeEvent: IHomeEvent?): LinearLayout(mContext) {
private var params:LinearLayout.LayoutParams? = null
init {
initView()
}
private fun initView() {
orientation = VERTICAL
params = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
View.inflate(mContext, R.layout.home_module_intelligent_item_view, this)
}
/**
* 刷新数据
*/
fun updateData(bean: HomeFMBean.ListBean) {
homeModuleIntelligentItemViewTitle.text = bean.name
homeModuleIntelligentItemViewHits.text = bean.hits.toString()
this.setOnClickListener{ homeEvent?.fmItemClick(bean) }
iv_fm_play.setOnClickListener { homeEvent?.fmPlayClick(bean) }
}
/**
* 电台第二个item会有一个marginTop值
*/
fun setTopMargin() {
params?.topMargin = RxImageTool.dp2px(16f)
layoutParams = params
}
/**
* 电台最后一个item会有一个marginBottom值
*/
fun setBottomMargin() {
params?.bottomMargin = RxImageTool.dp2px(16f)
layoutParams = params
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.view.View
import android.widget.LinearLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeFMBean
import com.ydl.ydl_image.config.ISimpleImageOpConfig
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import kotlinx.android.synthetic.main.home_module_intelligent_top_item_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 心灵电台模块item--顶部item
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/15
*/
class HomeIntelligentTopItemView(private val mContext: Context, private var homeEvent: IHomeEvent?): LinearLayout(mContext) {
init {
initView()
}
private fun initView() {
orientation = VERTICAL
var screenWidth = RxDeviceTool.getScreenWidth(mContext)
var viewWidth = (screenWidth - 2 * 15 * RxDeviceTool.getScreenDensity(mContext)).toInt()
var viewHeight = viewWidth * 143 / 345
val params = LinearLayout.LayoutParams(viewWidth, viewHeight)
layoutParams = params
View.inflate(mContext, R.layout.home_module_intelligent_top_item_view, this)
}
/**
* 刷新数据
*/
fun updateData(bean: HomeFMBean.ListBean) {
var screenWidth = RxDeviceTool.getScreenWidth(mContext)
var viewWidth = (screenWidth - RxImageTool.dip2px(30f))
var viewHeight = viewWidth * 143 / 345
val sp = SimpleImageOpConfiger()
sp.loadingPic = R.drawable.default_img
sp.errorPic = R.drawable.default_img
sp.scaleType = ISimpleImageOpConfig.CENTER_CROP
sp.isCacheOnDisk = true
YDLImageCacheManager.showImage(mContext,bean.imageUrl,homeModuleIntelligentTopViewImage, viewWidth, viewHeight,sp)
homeModuleIntelligentTopViewTitle.text = bean.name
homeModuleIntelligentTopViewAuthor.text = bean.author
homeModuleIntelligentTopViewHits.text = bean.hits.toString()
this.setOnClickListener{ homeEvent?.fmItemClick(bean) }
iv_play_fm.setOnClickListener{homeEvent?.fmPlayClick(bean)}
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeFMBean
import kotlinx.android.synthetic.main.home_module_intelligent_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 心灵*电台模块
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/13
*/
class HomeIntelligentView(private val mContext: Context, private var homeEvent: IHomeEvent?) : LinearLayout(mContext) {
private var cacheList : ArrayList<HomeFMBean.ListBean> = ArrayList()
init {
initView()
}
private fun initView() {
orientation = VERTICAL
val params = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
View.inflate(mContext, R.layout.home_module_intelligent_view, this)
homeModuleIntelligentViewHomeCommonTitleView.setTitle("心灵·电台")
homeModuleIntelligentViewHomeCommonTitleView.setOnClickListener {
homeEvent?.fmMoreClick()
}
}
fun initData(list: List<HomeFMBean.ListBean>?) {
//添加View
list?.let {
if (cacheList.size != list?.size) {
cacheList.clear()
cacheList.addAll(list!!)
updateHomeIntelligentItemViewNumber()
}
//刷新数据
for (index in 0 until homeModuleIntelligentViewAddLayout.childCount) {
val itemView = homeModuleIntelligentViewAddLayout.getChildAt(index)
if (itemView is HomeIntelligentItemView) {
//第一个这种类型item,需要设置marginTop = 16dp,最后一个item需要设置marginBototm = 16dp
if (index == 1) {
itemView.setTopMargin()
} else if (index == homeModuleIntelligentViewAddLayout.childCount - 1) {
itemView.setBottomMargin()
}
itemView.updateData(list[index])
} else if (itemView is HomeIntelligentTopItemView) {
itemView.updateData(list[index])
}
}
}
}
/**
* 更新itemView的数量以适应新的数据集
*/
private fun updateHomeIntelligentItemViewNumber() {
var childCountRecord = homeModuleIntelligentViewAddLayout.childCount
while (cacheList.size > childCountRecord) {
if (childCountRecord == 0) {
homeModuleIntelligentViewAddLayout.addView(HomeIntelligentTopItemView(mContext, homeEvent))
}else {
homeModuleIntelligentViewAddLayout.addView(HomeIntelligentItemView(mContext, homeEvent))
}
childCountRecord++
}
while (cacheList.size < childCountRecord &&
(homeModuleIntelligentViewAddLayout.getChildAt(childCountRecord) is HomeIntelligentItemView
|| homeModuleIntelligentViewAddLayout.getChildAt(childCountRecord) is HomeIntelligentTopItemView)) {
homeModuleIntelligentViewAddLayout.removeViewAt(childCountRecord)
childCountRecord--
}
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.annotation.SuppressLint
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.google.gson.Gson
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.ydlcommon.bean.MuseModuleBean
import kotlinx.android.synthetic.main.home_module_muse_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 冥想模块
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/09/10
*/
class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEvent?) : LinearLayout(mContext) {
private var cacheList: ArrayList<HomeMuseView> = ArrayList()
init {
initView()
}
@SuppressLint("RestrictedApi")
private fun initView() {
orientation = VERTICAL
val params = RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params
View.inflate(mContext, R.layout.home_module_muse_view, this)
homeModuleMuseViewHomeCommonTitleView.setTitle("助眠·冥想")
}
fun initData(bean: MuseModuleBean?) {
if (null != bean) {
var dataJson = Gson().toJson(bean)
homeModuleMuseViewHomeCommonTitleView.setOnClickListener {
homeEvent?.museMoreClick(Gson().toJson(bean))
}
if (null != bean.muses) {
if (bean.muses?.size!! > 0) {
muse_first.setOnClickListener {
homeEvent?.museClick(bean.muses!![0].audioUrl, dataJson)
}
}
if (bean.muses?.size!! > 1) {
muse_second.setOnClickListener {
homeEvent?.museClick(bean.muses!![1].audioUrl, dataJson)
}
}
if (bean.muses?.size!! > 2) {
muse_third.setOnClickListener {
homeEvent?.museClick(bean.muses!![2].audioUrl, dataJson)
}
}
if (bean.muses?.size!! > 3) {
muse_forth.setOnClickListener {
homeEvent?.museClick(bean.muses!![3].audioUrl, dataJson)
}
}
}
if (null != bean.sleeps) {
if (bean.sleeps?.size!! > 0) {
sleeps_first.setOnClickListener {
homeEvent?.museClick(bean.sleeps!![0].audioUrl, dataJson)
}
}
if (bean.sleeps?.size!! > 1) {
sleeps_second.setOnClickListener {
homeEvent?.museClick(bean.sleeps!![1].audioUrl, dataJson)
}
}
if (bean.sleeps?.size!! > 2) {
sleeps_third.setOnClickListener {
homeEvent?.museClick(bean.sleeps!![2].audioUrl, dataJson)
}
}
if (bean.sleeps?.size!! > 3) {
sleeps_forth.setOnClickListener {
homeEvent?.museClick(bean.sleeps!![3].audioUrl, dataJson)
}
}
}
}
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.graphics.Color
import android.util.TypedValue
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import com.yidianling.home.R
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeHeaderBean
import com.ydl.ydl_image.module.GlideApp
import com.yidianling.common.tools.RxImageTool
import com.yidianling.ydlcommon.utils.ScreenUtil
import kotlinx.android.synthetic.main.home_module_pager_banner_category_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 首页顶部模块-分类模块
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/02/16
*/
class HomePagerBannerCategoryItemView(mContext: Context, homeEvent: IHomeEvent) : FrameLayout(mContext) {
/**
* 数据缓存
*/
var mDataList: ArrayList<HomeHeaderBean.AskCategoryDataBean>? = null
/**
* 分类view宽度
*/
var categoryWidth: Int = 0
/**
* 图片宽高
*/
var imageViewWidth: Int = 0
/**
* 文本宽度
*/
var textViewWidth: Int = 0
/**
* 文本高度
*/
var textViewHeight: Int = 0
/**
* 间隔
*/
var margin: Int = 0
var dp8: Int = 0
var dp10 : Int = 0
/**
* 是否添加了实时测试状态View
*/
var hasRealTestView: Boolean = false
private var realTestView: HomePagerBannerRealView? = null
/**
* 线
*/
private var lineView: View? = null
/**
* 倍数
*/
private var multiple: Int = 0
/**
* 测评首页事件处理类
*/
private var homeEvent: IHomeEvent? = null
init {
initView()
this.homeEvent = homeEvent
}
/**
* 界面初始化
*/
private fun initView() {
View.inflate(context, R.layout.home_module_pager_banner_category_view, this)
val params = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)
// params.topMargin = ScreenUtil.screenHeight * (356f / 750f).toInt()
layoutParams = params
initArgs()
}
/**
* 初始化变量
*/
private fun initArgs() {
categoryWidth = ScreenUtil.screenWidth
textViewWidth = categoryWidth / 5
imageViewWidth = RxImageTool.dip2px(38f)
margin = (categoryWidth - 5 * imageViewWidth) / 10
dp8 = RxImageTool.dip2px(8f)
dp10 = RxImageTool.dip2px(10f)
//高度=文字12dp+16dp间距
textViewHeight = RxImageTool.dip2px(28f)
}
//, homeSaleData: List<HomeHeaderBean.HomeSaleDataBean>?
fun initData(askCategoryDataBean: MutableList<HomeHeaderBean.AskCategoryDataBean>?) {
if (null == askCategoryDataBean || askCategoryDataBean.isEmpty()) {
visibility = View.GONE
return
}
visibility = View.VISIBLE
if (null == mDataList) {
mDataList = ArrayList()
}
if (getChange(askCategoryDataBean, mDataList)) {
mDataList!!.clear()
mDataList!!.addAll(askCategoryDataBean)
}
refreshView()
// setRealTextView(homeSaleData)
}
/**
* 判断数据是否变化
*/
private fun getChange(bean: MutableList<HomeHeaderBean.AskCategoryDataBean>?, cacheBean: MutableList<HomeHeaderBean.AskCategoryDataBean>?): Boolean {
if (bean?.size != cacheBean?.size) {
return true
}
for (index in 0 until bean?.size!!) {
if (!bean[index].url.equals(cacheBean!![index].url)
|| !bean[index].coverUrl.equals(cacheBean!![index].coverUrl)
|| !bean[index].cateTitle.equals(cacheBean!![index].cateTitle)
|| bean[index].cateId != cacheBean!![index].cateId) {
return true
}
}
return false
}
/**
* 刷新View
*/
private fun refreshView() {
homeModulePagerBannerFlRoot.removeAllViews()
var i = 0
for (item in mDataList!!) {
if (i > 9) {
break
}
val imageView = createIcon(i)
val textView = createText(i)
homeModulePagerBannerFlRoot.addView(imageView)
homeModulePagerBannerFlRoot.addView(textView)
imageView.setOnClickListener {
homeEvent!!.categoryClick(item)
}
textView.setOnClickListener {
homeEvent!!.categoryClick(item)
}
bindIconData(imageView, item)
bindTextData(textView, item)
i++
}
}
/**
* 创建图标
*/
private fun createIcon(i: Int): ImageView {
val imageParams = FrameLayout.LayoutParams(imageViewWidth, imageViewWidth)
val imageView = ImageView(context)
imageView.scaleType = ImageView.ScaleType.CENTER_CROP
if (i > 4) {
multiple = 2
imageParams.topMargin = imageViewWidth + dp10 + textViewHeight
imageParams.leftMargin = margin * (i - 4) + (i - 5) * (imageViewWidth + margin)
} else {
multiple = 1
imageParams.leftMargin = margin * (i + 1) + i * (imageViewWidth + margin)
}
imageView.layoutParams = imageParams
return imageView
}
/**
* 加载图片
*/
private fun bindIconData(imageView: ImageView, categoryBean: HomeHeaderBean.AskCategoryDataBean) {
GlideApp.with(context).load(categoryBean.coverUrl)
.centerCrop().into(imageView)
}
/**
* 创建文本
*/
private fun createText(index: Int): TextView {
val textParams = FrameLayout.LayoutParams(textViewWidth, textViewHeight)
val textView = TextView(context)
textView.setTextColor(Color.parseColor("#242424"))
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
textView.gravity = Gravity.CENTER_HORIZONTAL
if (index > 4) {
textParams.topMargin = 2 * (imageViewWidth + dp8) + textViewHeight
textParams.leftMargin = textViewWidth * (index - 5)
} else {
textParams.topMargin = imageViewWidth + dp8
textParams.leftMargin = textViewWidth * (index)
}
textView.layoutParams = textParams
return textView
}
/**
* 设置文本
*/
private fun bindTextData(textView: TextView, categoryBean: HomeHeaderBean.AskCategoryDataBean) {
textView.text = categoryBean.cateTitle
}
/**
* 初始化实时测评状态View
*/
private fun initRealTextView() {
if (null == realTestView) {
var realTestParam = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
realTestParam.topMargin = multiple * (imageViewWidth + dp8 + textViewHeight) + dp8 + RxImageTool.dip2px(10f)
realTestView = HomePagerBannerRealView(context, homeEvent!!)
realTestView!!.layoutParams = realTestParam
}
}
private fun initLineView() {
var lineParam = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, RxImageTool.dip2px(0.5f))
var dp15 = RxImageTool.dip2px(15f)
lineParam.leftMargin = dp15
lineParam.rightMargin = dp15
lineParam.topMargin = multiple * (imageViewWidth + dp8 + textViewHeight) + dp8
lineView = View(context)
lineView!!.setBackgroundColor(resources.getColor(R.color.home_module_category_view_test_line))
lineView!!.layoutParams = lineParam
}
/**
* 实时测评状态赋值
*/
private fun setRealTextView(list: List<HomeHeaderBean.HomeSaleDataBean>?) {
if (!hasRealTestView) {
initLineView()
homeModulePagerBannerFlRoot.addView(lineView)
initRealTextView()
homeModulePagerBannerFlRoot.addView(realTestView)
hasRealTestView = true
}
realTestView!!.initData(list)
}
fun onDestory() {
if (null == realTestView) {
return
}
realTestView!!.onDestory()
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment