Commit 21ee27cc by 洪国微

merge

parents d8ac396e 69d550ff
......@@ -180,12 +180,12 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
}
// override fun onDestroy() {
// if (serviceConnection != null) {
// unbindService(serviceConnection)
// }
// super.onDestroy()
// }
override fun onDestroy() {
if (serviceConnection != null) {
unbindService(serviceConnection)
}
super.onDestroy()
}
private inner class PlayServiceConnection : ServiceConnection {
override fun onServiceConnected(name: ComponentName, service: IBinder) {
......
......@@ -9,6 +9,7 @@ import com.ydl.devicesidlib.DeviceIDHelper;
import com.ydl.media.audio.PlayService;
import com.ydl.ydlcommon.base.delegate.IAppLifecycles;
import com.ydl.ydlcommon.utils.YdlBuryPointUtil;
import com.yidianling.course.lifeCallback.CoursePlayLifecycle;
import org.jetbrains.annotations.NotNull;
......@@ -37,6 +38,8 @@ public class DemoAppLifecycles implements IAppLifecycles {
Intent intent = new Intent(application, PlayService.class);
application.startService(intent);
application.registerActivityLifecycleCallbacks(new CoursePlayLifecycle());
}
@Override
......
......@@ -27,7 +27,7 @@ public final class DemoGlobalConfig implements IConfigModule {
public void applyOptions(@NotNull Context context, @NotNull GlobalConfig.Builder builder) {
builder.setFrom( "ydl".equals(BuildConfig.FLAVOR) ?YDLConstants.FROM_YDL :YDLConstants.FROM_XLZX)
.addUrl("github", APP_DOMAIN)
.setEnv(YDLConstants.ENV_TEST)
.setEnv(YDLConstants.ENV_PROD)
.setDebug(BuildConfig.DEBUG);
}
}
......@@ -20,7 +20,9 @@ import com.ydl.media.audio.model.Music;
import com.ydl.media.audio.utils.CoverImageUtils;
import com.ydl.media.view.PlayTypeEnum;
import com.ydl.media.view.PlayerFloatHelper;
import com.ydl.ydlcommon.utils.LogUtil;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.user.LoginUtils;
import java.util.HashMap;
import java.util.Locale;
......@@ -108,6 +110,8 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
void initPlayMode() {
int mode = AudioPlayer.Companion.get().getPlayMode().value();
ivMode.setImageLevel(mode);
AudioPlayer.Companion.get().play();
showFloatView();
}
@Override
......@@ -154,11 +158,7 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
break;
case R.id.iv_play:
play();
if(!PlayerFloatHelper.Companion.isShow(getActivity())) {
PlayerFloatHelper.Companion.show(getActivity(), PlayTypeEnum.PLAY_TYPE_FM,new HashMap<>());
}else {
PlayerFloatHelper.Companion.showIfPlaying(getActivity());
}
showFloatView();
break;
case R.id.iv_next:
next();
......@@ -169,6 +169,14 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
}
}
private void showFloatView() {
if(!PlayerFloatHelper.Companion.isShow(getActivity())) {
PlayerFloatHelper.Companion.show(getActivity(), PlayTypeEnum.PLAY_TYPE_FM,new HashMap<>());
}else {
PlayerFloatHelper.Companion.showIfPlaying(getActivity());
}
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (seekBar == sbProgress) {
......@@ -291,6 +299,6 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
@Override
public void onComplete() {
LogUtil.e("onComplete");
}
}
......@@ -78,8 +78,8 @@
android:id="@+id/bt_to_other"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:text="登录" />
<Button
......@@ -87,23 +87,16 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp"
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_music"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:text="音乐" />
<Button
......@@ -111,6 +104,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:text="冥想" />
</LinearLayout>
......@@ -126,8 +120,9 @@
android:id="@+id/bt_to_fm"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:text="电台" />
<Button
......@@ -135,46 +130,26 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp"
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_tests"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:text="测评" />
<Button
android:id="@+id/bt_to_course"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="invisible" />
</LinearLayout>
android:layout_marginRight="10dp"
android:text="课程" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/bt_to_course"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:text="Jump to Course" />
</LinearLayout>
</LinearLayout>
......
ext {
kotlin_version = "1.3.21"
dev_mode = false
dev_mode = true
ydl_app = [
appName : "心理咨询壹点灵",
......@@ -28,10 +28,10 @@ ext {
version = [
androidSupportSdkVersion: "28.0.0",
retrofitSdkVersion : "2.3.0",
retrofitSdkVersion : "2.6.0",
dagger2SdkVersion : "2.23.2",
glideSdkVersion : "4.3.1",
butterknifeSdkVersion : "9.0.0",
butterknifeSdkVersion : "8.8.1",
rxlifecycleSdkVersion : "1.0",
rxlifecycle2SdkVersion : "2.2.2",
espressoSdkVersion : "3.0.1",
......@@ -41,14 +41,15 @@ ext {
ydlPublishVersion = [
// -------------- 业务模块 --------------
"m-audioim" : "0.0.12",
"m-confide" : "0.0.15",
"m-consultant" : "0.0.22",
//第三步 若干
"m-confide" : "0.0.18",
"m-consultant" : "0.0.25",
"m-course" : "0.0.14",
"m-fm" : "0.0.11",
"m-fm" : "0.0.14",
"m-muse" : "0.0.11",
"m-tests" : "0.0.4",
"m-user" : "0.0.25",
"m-tests" : "0.0.7",
"m-user" : "0.0.28",
//-------------- 业务模块 API 层 --------------
"m-audioim-api" : "0.0.1",
"m-confide-api" : "0.0.1",
......@@ -57,20 +58,27 @@ ext {
"m-fm-api" : "0.0.2",
"m-muse-api" : "0.0.1",
"m-tests-api" : "0.0.1",
"m-user-api" : "0.0.5",
"m-user-api" : "0.0.7",
//-------------- 功能组件 --------------
"ydl-media" : "0.0.9",
"ydl-net" : "0.0.1",
"ydl-pay" : "0.0.6",
"ydl-platform" : "0.0.21",
"ydl-utils" : "0.0.2",
"ydl-webview" : "0.0.20",
//第一步
"ydl-platform" : "0.0.24",
//第二步 若干
"ydl-webview" : "0.0.24",
"ydl-media" : "0.0.12",
"ydl-pay" : "0.0.9",
"m-audioim" : "0.0.15",
//以下 几乎不会动
"router" : "0.0.1",
"ydl-net" : "0.0.2",
"ydl-utils" : "0.0.2",
"ydl-flutter-base": "0.0.3",
]
ydlCompileVersion = [
// -------------- 业务模块 --------------
"m-audioim" : "0.0.12",
//第三步 若干
"m-confide" : "0.0.15",
"m-consultant" : "0.0.22",
"m-course" : "0.0.8",
......@@ -86,15 +94,22 @@ ext {
"m-fm-api" : "0.0.2",
"m-muse-api" : "0.0.1",
"m-tests-api" : "0.0.1",
"m-user-api" : "0.0.5",
"m-user-api" : "0.0.7",
//-------------- 功能组件 --------------
"ydl-media" : "0.0.9",
"ydl-net" : "0.0.1",
"ydl-pay" : "0.0.6",
"ydl-platform" : "0.0.21",
"ydl-utils" : "0.0.2",
"ydl-webview" : "0.0.20",
//第一步
"ydl-platform" : "0.0.24",
//第二步 若干
"ydl-webview" : "0.0.24",
"ydl-media" : "0.0.12",
"ydl-pay" : "0.0.9",
"m-audioim" : "0.0.15",
//以下 几乎不会动
"router" : "0.0.1",
"ydl-net" : "0.0.2",
"ydl-utils" : "0.0.2",
"ydl-flutter-base": "0.0.3",
]
dependencies = [
......@@ -115,7 +130,7 @@ ext {
"retrofit-converter-scalars" : "com.squareup.retrofit2:converter-scalars:${version["retrofitSdkVersion"]}",
"okhttp3" : "com.squareup.okhttp3:okhttp:3.12.3",
"okhttp4" : "com.squareup.okhttp3:okhttp:4.0.0",
"okhttp3-logging" : "com.squareup.okhttp3:logging-interceptor:3.8.0",
"okhttp3-logging" : "com.squareup.okhttp3:logging-interceptor:3.12.2",
"okhttp-urlconnection" : "com.squareup.okhttp:okhttp-urlconnection:2.0.0",
"glide" : "com.github.bumptech.glide:glide:${version["glideSdkVersion"]}",
"glide-compiler" : "com.github.bumptech.glide:compiler:${version["glideSdkVersion"]}",
......@@ -148,7 +163,7 @@ ext {
"rxerrorhandler" : "me.jessyan:rxerrorhandler:1.0.1",
//rx2
"rxandroid2" : "io.reactivex.rxjava2:rxandroid:2.0.1",
"rxandroid2" : "io.reactivex.rxjava2:rxandroid:2.1.1",
"rxjava2" : "io.reactivex.rxjava2:rxjava:2.2.10",
"rxlifecycle2" : "com.trello.rxlifecycle2:rxlifecycle:${version["rxlifecycle2SdkVersion"]}",
"rxlifecycle2-android" : "com.trello.rxlifecycle2:rxlifecycle-android:${version["rxlifecycle2SdkVersion"]}",
......@@ -166,7 +181,6 @@ ext {
"androideventbus" : "org.simple:androideventbus:1.0.5.1",
"otto" : "com.squareup:otto:1.3.8",
"gson" : "com.google.code.gson:gson:2.8.5",
"multidex" : "com.android.support:multidex:1.0.3",
"javax.annotation" : "javax.annotation:jsr250-api:1.0",
"arouter" : "com.alibaba:arouter-api:1.4.1",
"progressmanager" : "me.jessyan:progressmanager:1.5.0",
......@@ -226,10 +240,10 @@ ext {
"imagepicker" : "com.ydl:imagepicker:1.0.6",
"protector" : "com.ydl:protector:1.0.1-SNAPSHOT@aar",
"ydl-hnet" : "com.ydl:h-net:0.0.8",
"ydl-utils" : "com.ydl:ydl-utils:0.0.2",
"ydl-net" : "com.ydl:ydl-net:0.0.1",
"ydl-user-router" : "com.ydl:router:1.0.0-SNAPSHOT@aar",
"ydl-device" : "com.ydl:device-id:0.0.7@aar",
"ydl-net" : "com.ydl:ydl-net:${ydlCompileVersion["ydl-net"]}",
"ydl-utils" : "com.ydl:ydl-utils:${ydlCompileVersion["ydl-utils"]}",
//flutter功能组件升级===>发布ydl-flutter组件===>引用flutter相关的业务模块
"ydl-flutter" : "com.ydl:ydl-flutter:0.0.12@aar",
......
......@@ -4,7 +4,6 @@ import android.app.Activity
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import com.yidianling.router.RouterManager
import com.yidianling.router.user.UserResponse
/**
* author : Zhangwenchao
......@@ -17,8 +16,6 @@ object PhoneCallIn {
return RouterManager.getUserRouter()?.isLogin()?:false
}
fun getUserInfo(): UserResponse.UserInfo? = RouterManager.getUserRouter()?.getUserInfo()
fun rechargeIntent(activity: Activity): Intent? {
return RouterManager.getAppRouter()?.rechargeIntent(activity)
}
......
......@@ -31,12 +31,24 @@ class ConsultAssistantDialogUtils private constructor() {
* origin 展示请求来源 首页 home_index 咨询列表 doctor_list
*/
fun fitRequest(activity: Activity, origin: String) {
if (ConsultantIn.isLogin() &&
ConsultantIn.getUserImpl().getUserInfo()?.user_type == 1
/** WalleChannelReader.getChannel(BaseApp.Companion.getApp()) == "android_huawei" */
) {
shouldShowDialog(activity, origin)
when (origin) {
"home_index" -> {
if (ConsultantIn.isLogin() &&
ConsultantIn.getUserImpl().getUserInfo()?.user_type == 1
/** WalleChannelReader.getChannel(BaseApp.Companion.getApp()) == "android_huawei" */
) {
shouldShowDialog(activity, origin)
}
}
"doctor_list" -> {
if (ConsultantIn.getUserImpl().getUserInfo()?.user_type == 1
/** WalleChannelReader.getChannel(BaseApp.Companion.getApp()) == "android_huawei" */
) {
shouldShowDialog(activity, origin)
}
}
}
}
/**
......@@ -101,7 +113,7 @@ class ConsultAssistantDialogUtils private constructor() {
expertSearchPageHasShown = true
}
}
}, 10000)
}, 5000)
} else {
showDialog(activity)
}
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_40"/>
<corners android:radius="@dimen/platform_dp_40"/>
<solid android:color="#F2faff"/>
<stroke
android:width="1dp"
......
......@@ -7,8 +7,8 @@
<corners android:radius="@dimen/platform_dp_13" />
<padding
android:bottom="@dimen/platform_dp_3"
android:left="@dimen/dp_10"
android:right="@dimen/dp_10"
android:left="@dimen/platform_dp_10"
android:right="@dimen/platform_dp_10"
android:top="@dimen/platform_dp_3" />
<stroke android:color="#F0F0F0"/>
</shape>
\ No newline at end of file
......@@ -92,7 +92,7 @@
android:id="@+id/img_activity"
android:layout_width="42dp"
android:layout_height="12dp"
android:layout_marginStart="@dimen/dp_4"
android:layout_marginStart="@dimen/platform_dp_4"
android:visibility="gone"/>
<!--公益图标-->
<ImageView
......@@ -111,7 +111,7 @@
android:layout_marginLeft="@dimen/platform_dp_4"
android:scaleType="fitCenter"
tools:background="@drawable/consultant_new_enter"
android:layout_marginStart="@dimen/dp_4" />
android:layout_marginStart="@dimen/platform_dp_4" />
<!--优质图标-->
<ImageView
android:id="@+id/imgAbilityLevel"
......
......@@ -20,7 +20,7 @@
android:orientation="vertical"
android:text="@string/platform_no_search_result"
android:textColor="@color/platform_text_gray"
android:textSize="@dimen/sp_14" />
android:textSize="@dimen/platform_sp_14" />
<Button
android:id="@+id/btnSearchByCat"
......
......@@ -62,16 +62,10 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
kapt 'com.alibaba:arouter-compiler:1.2.2'
implementation 'com.jakewharton:butterknife:8.8.1'
// api 'com.dou361.ijkplayer-armv5:jjdxm-ijkplayer-armv5:1.0.0'
// api 'com.dou361.ijkplayer-arm64:jjdxm-ijkplayer-arm64:1.0.0'
// api 'com.dou361.ijkplayer-x86:jjdxm-ijkplayer-x86:1.0.0'
// api 'com.dou361.ijkplayer-x86_64:jjdxm-ijkplayer-x86_64:1.0.0'
// api('com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.6') {
// exclude group: 'com.android.support', module: 'appcompat-v7'
// }
api 'com.github.princekin-f:EasyFloat:1.1.2'
api rootProject.ext.dependencies["ydl-user-router"]
api rootProject.ext.dependencies["butterknife"]
if (rootProject.ext.dev_mode){
//开发时使用
implementation modularPublication('com.ydl:m-user-api')
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yidianling.course">
xmlns:tools="http://schemas.android.com/tools"
package="com.yidianling.course">
<uses-sdk tools:overrideLibrary="com.lzf.easyfloat"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application>
<!--课程首页-->
<activity
......@@ -42,6 +48,7 @@
android:name=".course_special_list.activity.CourseSpecialListActivity"
android:screenOrientation="portrait" />
<service android:name="com.lzf.easyfloat.service.FloatService" />
</application>
</manifest>
......@@ -68,26 +68,26 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
playView?.listener = object : HPlayStatusListener {
override fun isCanPlay(data: Music?): Boolean {
var canPlay = false
//非试听
if (courseExtra!!.isBuy) {
//已购买
canPlay = true
} else {
//未购买,判断是否是试听课程
//即未购买,也不是试听,弹窗提示
if (activity == null) return false
CommonDialog(activity)
.setMessage("\n购买课程,获取完整课程内容\n")
.setLeftOnclick("放弃") {
}
.setRightClick("购买") {
//跳转支付页
activity?.addCourseOrder()
}
.setCancelAble(false)
.show()
}
//非试听
if (courseExtra!!.isBuy) {
//已购买
canPlay = true
} else {
//未购买,判断是否是试听课程
//即未购买,也不是试听,弹窗提示
if (activity == null) return false
CommonDialog(activity)
.setMessage("\n购买课程,获取完整课程内容\n")
.setLeftOnclick("放弃") {
}
.setRightClick("购买") {
//跳转支付页
activity?.addCourseOrder()
}
.setCancelAble(false)
.show()
}
return canPlay
}
......@@ -102,7 +102,12 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
/**
* 设置显示数据
*/
override fun setData(index: Int, list: ArrayList<CourseMediaBean>, courseExtra: CourseExtraBean, from: Int) {
override fun setData(
index: Int,
list: ArrayList<CourseMediaBean>,
courseExtra: CourseExtraBean,
from: Int
) {
if (list.isEmpty()) return
playList.clear()
......@@ -110,8 +115,6 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
this.courseExtra = courseExtra
currentIndex = index
// YDLMusicHelper.course_id = courseExtra.id.toInt()
if (courseExtra.isBuy) {
playView?.setAutoNext(true)
} else {
......
......@@ -208,9 +208,12 @@ class CourseSearchActivity : BaseActivity(), CourseSearchAdapter.OnItemClick, IC
hideUnusualPage()
if (type) {
courseList.clear()
courseList.addAll(it.data.list)
courseSearchAdapterWrapper!!.notifyDataSetChanged()
} else {
courseList.addAll(it.data.list)
courseSearchAdapterWrapper!!.insertData()
}
courseList.addAll(it.data.list)
courseSearchAdapterWrapper!!.insertData()
} else {
if (!type) {
courseSearchAdapterWrapper!!.noMoreData()
......
package com.yidianling.course.courseSearch.http
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.yidianling.course.courseSearch.CourseSearchBean
import io.reactivex.Observable
......@@ -16,5 +18,6 @@ interface CourseSearchListApi{
//专家课程搜索列表
@GET("auth/course/getList")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun courseSearchList(@Query("page")page: Int, @Query("keyWord")keyWord: String): Observable<BaseAPIResponse<CourseSearchBean>>
}
\ No newline at end of file
import android.app.AlertDialog
import android.content.Intent
import android.net.Uri
import android.os.Handler
import android.text.TextUtils
import com.example.fm_plugin.base.BaseFlutterFragment
import com.lzf.easyfloat.permission.PermissionUtils
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.audio.model.Music
import com.ydl.media.view.PlayTypeEnum
......@@ -16,13 +18,14 @@ import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.course.BuildConfig
import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.CourseConstants
import com.yidianling.course.bean.ScrollStatusChangeEvent
import com.yidianling.course.courseNew.mine.MyCourseActivity
import com.yidianling.course.course_special_list.activity.CourseSpecialListActivity
import com.yidianling.course.flutterPlugin.CourseSendPlugin
import com.yidianling.course.router.CourseIn
import com.yidianling.course.widget.VideoFloatHelper
import de.greenrobot.event.EventBus
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
......@@ -66,7 +69,7 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
val loginBean = ModularServiceManager.getPlatformUserService()?.getUser()
val mMap = mutableMapOf<String, Any>()
var uid = loginBean?.userId ?: ""
mMap["isDevelopment"] = BuildConfig.DEBUG
mMap["isDevelopment"] = false
mMap["uid"] = if (TextUtils.isEmpty(uid)) "0" else uid
mMap["accessToken"] = loginBean?.token ?: ""
?: ""
......@@ -92,11 +95,21 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
return
}
when {
jumpUrl!!.contains("user/login") -> mFragment!!.startActivity(
CourseIn.loginWayIntent(
mFragment!!.activity!!
)
)
jumpUrl!!.contains("user/login") -> {
//TODO flutter 登录状态判断需要更改
val loginBean =
ModularServiceManager.getPlatformUserService()?.getUser()
if (loginBean == null || TextUtils.isEmpty(loginBean.userId) || TextUtils.equals(
loginBean.userId,
"0"
)
) {
mFragment!!.startActivity(CourseIn.loginWayIntent(mFragment!!.activity!!))
} else {
MyCourseActivity.start(mFragment!!.activity)
}
}
jumpUrl.contains("course/myCourse") -> MyCourseActivity.start(mFragment!!.activity)
jumpUrl.contains("course/specialList") -> //跳转专题列表页
mFragment!!.activity!!.startActivity(
......@@ -177,20 +190,29 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
if (demoType == 1) {
music.path = url
val hashMap = HashMap<String, String>()
hashMap["course_id"] = fileInfo["courseId"].toString()
AudioPlayer.get().singlePlay(music)
PlayerFloatHelper.show(
mFragment!!.activity,
playTypeEnum = PlayTypeEnum.PLAY_TYPE_COURSE
playTypeEnum = PlayTypeEnum.PLAY_TYPE_COURSE,
playData = hashMap
)
VideoFloatHelper.dismissFloat(mFragment!!.activity)
}
if (demoType == 2) {
//todo 视屏播放
// YDLMusicHelper.playType = 1
// YDLMusicHelper.courseVideoUlr = url
//
// PlayerFloatHelper.show(mFragment!!.activity)
VideoFloatHelper.setVideoInfo(
fileInfo["courseId"].toString(),
fileInfo["url"].toString(),
false
)
checkPermission()
if (PlayerFloatHelper.isShow(mFragment!!.activity!!)) {
PlayerFloatHelper.hide()
PlayerFloatHelper.removeView(mFragment!!.activity!!)
AudioPlayer.get().stopPlayer()
}
}
Handler().postDelayed({ CourseSendPlugin.sendMsg(true) }, 300)
......@@ -215,4 +237,28 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
}
})
}
/**
* 检测浮窗权限是否开启,若没有给与申请提示框(非必须,申请依旧是EasyFloat内部内保进行)
*/
private fun checkPermission() {
if (PermissionUtils.checkPermission(mFragment!!.activity)) {
VideoFloatHelper.showVideoFloat(mFragment!!.activity)
} else {
AlertDialog.Builder(mFragment!!.activity)
.setMessage("使用浮窗功能,需要您授权悬浮窗权限。")
.setPositiveButton("去开启") { _, _ ->
VideoFloatHelper.showVideoFloat(mFragment!!.activity)
}
.setNegativeButton("取消") { _, _ ->
ToastUtil.toastLong(
mFragment!!.activity,
"App正常工作需要内部存储使用权限,请开启"
)
}
.show()
}
}
}
\ No newline at end of file
package com.yidianling.course.lifeCallback
import android.app.Activity
import android.app.Application
import android.os.Bundle
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.view.PlayTypeEnum
import com.ydl.media.view.PlayerFloatHelper
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/11/19
*/
class CoursePlayLifecycle : Application.ActivityLifecycleCallbacks {
override fun onActivityPaused(activity: Activity?) {
}
override fun onActivityResumed(activity: Activity?) {
if (!PlayerFloatHelper.isCanClick) {
PlayerFloatHelper.hide()
PlayerFloatHelper.removeView(activity!!)
AudioPlayer.get().stopPlayer()
} else {
PlayerFloatHelper.showIfPlaying(activity!!)
PlayerFloatHelper.playingType = PlayTypeEnum.PLAY_TYPE_COURSE
}
}
override fun onActivityStarted(activity: Activity?) {
}
override fun onActivityDestroyed(activity: Activity?) {
}
override fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) {
}
override fun onActivityStopped(activity: Activity?) {
}
override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) {
}
}
\ No newline at end of file
......@@ -4,7 +4,6 @@ import android.app.Activity
import android.content.Intent
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.router.RouterManager
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.service.IUserService
/**
......@@ -18,10 +17,6 @@ object CourseIn {
return ModularServiceManager.provide(IUserService::class.java).isLogin()
}
fun getUserInfo(): UserResponse.UserInfo? {
return RouterManager.getUserRouter()?.getUserInfo()
}
fun loginWayIntent(activity: Activity): Intent? {
return ModularServiceManager.provide(IUserService::class.java).loginWayIntent(activity)
}
......
package com.yidianling.course.uitls
import android.content.Context
import android.text.TextUtils
/**
* 工具类
* Created by hgw on 2018/3/31.
*/
object VideoProgressUtil {
/**
* 保存播放进度
*/
fun saveProgress(context: Context?, url: String?, progress: Int) {
if (TextUtils.isEmpty(url)) return
val shared = context?.getSharedPreferences("COURSE_VIDEO_PROGRESS", Context.MODE_PRIVATE)
val edit = shared?.edit()
edit?.putInt(url, progress)
edit?.apply()
}
/**
* 获取进度
*/
fun getProgress(context: Context?, url: String?): Int {
if (TextUtils.isEmpty(url)) return 0
val shared = context?.getSharedPreferences("COURSE_VIDEO_PROGRESS", Context.MODE_PRIVATE)
return shared?.getInt(url, 0) ?: 0
}
}
\ No newline at end of file
package com.yidianling.course.widget
import android.annotation.SuppressLint
import android.app.Activity
import android.app.AlertDialog
import android.content.Context
import android.graphics.Paint
import android.support.constraint.ConstraintLayout
......@@ -8,6 +10,7 @@ import android.text.TextUtils
import android.util.AttributeSet
import android.view.View
import com.alibaba.android.arouter.launcher.ARouter
import com.lzf.easyfloat.permission.PermissionUtils
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.audio.model.Music
import com.ydl.media.view.PlayTypeEnum
......@@ -19,6 +22,7 @@ import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.actionutil.BIConstants
import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.CourseConstants
import com.yidianling.course.R
import com.yidianling.course.bean.Course
......@@ -228,14 +232,30 @@ class CourseItemNewView : ConstraintLayout {
PlayerFloatHelper.playingType=PlayTypeEnum.PLAY_TYPE_COURSE
music.path=course.demoFile
val hashMap = HashMap<String, String>()
hashMap["course_id"] =course.id.toString()
AudioPlayer.get().singlePlay(music)
PlayerFloatHelper.show(
mContext,
playTypeEnum = PlayTypeEnum.PLAY_TYPE_COURSE,
playData = hashMap
)
VideoFloatHelper.dismissFloat(mContext as Activity)
}
if (course.demoType == 2) {
//todo 视屏播放
// YDLMusicHelper.playType = 1
// YDLMusicHelper.courseVideoUlr = course.demoFile
//
// PlayerFloatHelper.show(mContext)
VideoFloatHelper.setVideoInfo(
course.id.toString(),
course.demoFile,
false
)
checkPermission()
if (PlayerFloatHelper.isShow(mContext)) {
PlayerFloatHelper.hide()
PlayerFloatHelper.removeView(mContext)
AudioPlayer.get().stopPlayer()
}
}
......@@ -269,4 +289,27 @@ class CourseItemNewView : ConstraintLayout {
fun hideListenerButton() {
tv_view_course.visibility = View.GONE
}
/**
* 检测浮窗权限是否开启,若没有给与申请提示框(非必须,申请依旧是EasyFloat内部内保进行)
*/
private fun checkPermission() {
if (PermissionUtils.checkPermission(mContext)) {
VideoFloatHelper.showVideoFloat(mContext as Activity)
} else {
AlertDialog.Builder(mContext)
.setMessage("使用浮窗功能,需要您授权悬浮窗权限。")
.setPositiveButton("去开启") { _, _ ->
VideoFloatHelper.showVideoFloat(mContext as Activity)
}
.setNegativeButton("取消") { _, _ ->
ToastUtil.toastLong(
mContext,
"App正常工作需要内部存储使用权限,请开启"
)
}
.show()
}
}
}
\ No newline at end of file
package com.yidianling.course.widget
import android.annotation.SuppressLint
import android.app.Activity
import android.os.Handler
import android.view.View
......@@ -36,8 +37,8 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
fun init() {
if (mContext == null) return
View.inflate(context, R.layout.course_play_music_view, this)
AudioPlayer.get().addOnPlayEventListener(this)
play_icon.setOnClickListener {
AudioPlayer.get().playPause()
......@@ -48,8 +49,6 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
}
}
AudioPlayer.get().addOnPlayEventListener(this)
pro_progress.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
if (p2) {
......@@ -114,9 +113,9 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
}
fun play(index: Int) {
updateButton()
PlayerFloatHelper.playingType=PlayTypeEnum.PLAY_TYPE_COURSE
PlayerFloatHelper.playingType = PlayTypeEnum.PLAY_TYPE_COURSE
AudioPlayer.get().play(index)
updateButton()
}
fun setImageBackground(url: String?) {
......@@ -127,14 +126,23 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
* 设置自动播放下一曲
*/
fun setAutoNext(auto: Boolean) {
if(!auto){
AudioPlayer.get().playMode=PlayModeEnum.SINGLE
if (!auto) {
AudioPlayer.get().playMode = PlayModeEnum.SINGLE
} else {
AudioPlayer.get().playMode = PlayModeEnum.LIST_LOOP
}
}
@SuppressLint("SetTextI18n")
override fun onChange(music: Music) {
if (mContext != null) {
Glide.with(mContext).asGif().load(R.drawable.course_loading5).into(img_gif)
}
play_icon.setImageResource(R.drawable.course_ico_course_play)
pro_progress.progress = 0
text_start_time.text = "00:00"
}
override fun onPlayerStart() {
......@@ -142,21 +150,18 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
}
override fun onPlayerPause() {
if (AudioPlayer.get().isPlaying){
if (AudioPlayer.get().isPlaying) {
setGifVisibity(true)
}else{
} else {
setGifVisibity(false)
}
}
override fun onPublish(percent: Int, currentPosition: Long) {
mHandler?.postDelayed({
//拖动seekbar时不进行以下操作
if (!seekBarIsDown) {
pro_progress.progress = progress
text_start_time.text = getStringTime(progress)
}
}, 0)
if (!seekBarIsDown) {
pro_progress.progress = currentPosition.toInt()
text_start_time.text = getStringTime(currentPosition.toInt())
}
}
override fun onBufferingUpdate(percent: Int) {
......@@ -170,7 +175,7 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
mHandler?.postDelayed({
pro_progress.max = duration.toInt()
text_end_time.text = getStringTime(pro_progress.max)
var index=AudioPlayer.get().getMusicList()?.indexOf(AudioPlayer.get().playMusic)?:0
var index = AudioPlayer.get().getMusicList()?.indexOf(AudioPlayer.get().playMusic) ?: 0
listener?.onPrepared(
AudioPlayer.get().playMusic, index
)
......@@ -186,11 +191,12 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
private fun showBufferLoading(show: Boolean) {
mHandler?.postDelayed({
if (show) {
if (mContext != null) {
Glide.with(mContext).asGif().load(R.drawable.course_loading5).into(img_gif)
if (!AudioPlayer.get().isPlaying) {
if (mContext != null) {
Glide.with(mContext).asGif().load(R.drawable.course_loading5).into(img_gif)
}
play_icon.setImageResource(R.drawable.course_ico_course_play)
}
play_icon.setImageResource(R.drawable.course_ico_course_play)
} else {
if (mContext != null) {
Glide.with(mContext).asGif().load(R.drawable.course_audio_play).into(img_gif)
......@@ -202,17 +208,14 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
//显示或隐藏播放动画
private fun setGifVisibity(show: Boolean) {
if (context == null) return
if (mContext == null) return
mHandler?.postDelayed({
if (show) {
if (mContext != null) {
Glide.with(mContext).asGif().load(R.drawable.course_audio_play).into(img_gif)
}
Glide.with(mContext).asGif().load(R.drawable.course_audio_play).into(img_gif)
play_icon.setImageResource(R.drawable.course_ico_course_pause)
} else {
if (mContext != null) {
Glide.with(mContext).asBitmap().load(R.drawable.course_ico_course_bg_pause).into(img_gif)
}
Glide.with(mContext).asBitmap().load(R.drawable.course_ico_course_bg_pause)
.into(img_gif)
play_icon.setImageResource(R.drawable.course_ico_course_play)
}
}, 0)
......@@ -225,7 +228,7 @@ class HPlayView : RelativeLayout, OnPlayerEventListener {
if (AudioPlayer.get().isPlaying) {
setGifVisibity(true)
}
}, 0)
}, 300)
}
......
package com.yidianling.course.widget
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.view.View
import android.widget.ImageView
import com.alibaba.android.arouter.launcher.ARouter
import com.dou361.ijkplayer.widget.PlayStateParams
import com.dou361.ijkplayer.widget.PlayerView
import com.lzf.easyfloat.EasyFloat
import com.lzf.easyfloat.enums.ShowPattern
import com.lzf.easyfloat.interfaces.OnInvokeView
import com.ydl.media.audio.utils.PlayProgressUtil
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.course.R
import com.yidianling.course.coursePlay.CoursePlayActivity
import com.yidianling.course.flutterPlugin.CourseSendPlugin
import com.yidianling.course.uitls.VideoProgressUtil
import java.util.*
/**
* @author jiucheng
* @描述:视频悬浮窗
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/11/19
*/
object VideoFloatHelper {
private const val courseTag = "course_video_play"
var courseVideoUrl = ""
var courseId = ""
var isCanClick = true
var isCurrentVideoPlaying = true
//视频播放器view
@SuppressLint("StaticFieldLeak")
private var videoView: PlayerView? = null
private var timer: Timer? = null
var defaultShowPattern = ShowPattern.CURRENT_ACTIVITY
fun setVideoInfo(
courseId: String,
courseVideoUrl: String,
isCanClick: Boolean
): VideoFloatHelper {
this.courseId = courseId
this.courseVideoUrl = courseVideoUrl
this.isCanClick = isCanClick
return this
}
fun showVideoFloat(activity: Activity) {
val x = RxDeviceTool.getScreenWidth(activity) - RxImageTool.dp2px(220f)
val y = RxDeviceTool.getScreenHeight(activity) * 3 / 4
EasyFloat.with(activity)
.setTag(courseTag)
.setShowPattern(defaultShowPattern)
.setLocation(x, y)
.setAppFloatAnimator(null)
.setFilter(CoursePlayActivity::class.java)
.setLayout(R.layout.course_float_video_view, OnInvokeView {
it.findViewById<ImageView>(R.id.iv_video_close).setOnClickListener {
dismissFloat(activity)
}
val videoFullScreen = it.findViewById<ImageView>(R.id.iv_video_full_screen)
if (isCanClick) {
videoFullScreen.visibility = View.VISIBLE
} else {
videoFullScreen.visibility = View.INVISIBLE
}
videoFullScreen.setOnClickListener {
if (isCanClick) {
startCoursePlayActivity(activity, 1, 1, courseVideoUrl, true)
}
}
val videoLayout = it.findViewById<ImageView>(R.id.app_video_box)
try {
initVideoPlayer(activity, videoLayout)
} catch (e: Exception) {
e.printStackTrace()
}
})
.show()
}
private fun initVideoPlayer(activity: Activity, view: View) {
val url = courseVideoUrl.replace("https", "http")
val hisTime = PlayProgressUtil.getProgress(activity, url)
videoView = PlayerView(activity, view)
.setScaleType(PlayStateParams.fitparent)
.hideAllUI()
.setNetWorkTypeTie(false)
.setAutoReConnect(true, 3)
.forbidTouch(true)
.setOnInfoListener { _, what, _ ->
if (what == PlayStateParams.STATE_COMPLETED) {
isCurrentVideoPlaying = false
PlayProgressUtil.saveProgress(activity, url, 0)
} else {
isCurrentVideoPlaying = true
}
true
}
.setPlaySource(url)
.startPlay()
.seekTo(hisTime)
view.setOnClickListener {
if (isCanClick) {
startCoursePlayActivity(activity, 1, 0, courseVideoUrl, true)
}
}
startTimer(url, activity)
}
private fun startTimer(url: String, activity: Activity) {
if (timer == null) {
timer = Timer()
}
timer?.schedule(object : TimerTask() {
override fun run() {
if (isCurrentVideoPlaying) {
var time = videoView?.currentPosition ?: 0
if (time < 3000) return
PlayProgressUtil.saveProgress(activity, url, time)
}
}
}, 1000, 1000)
}
private fun startCoursePlayActivity(
context: Context?,
from: Int,
fullScreen: Int,
coursePlayUrl: String,
isFromFloatView: Boolean
) {
ARouter.getInstance()
.build("/course/play")
.withInt("course_id", courseId.toInt())
.withInt("course_type", 1)
.withString("coursePlayUrl", coursePlayUrl)
.withInt("from", from)
.withBoolean("isFromFloatView", isFromFloatView)
.withInt("fullScreen", fullScreen)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.navigation()
}
fun dismissFloat(activity: Activity) {
CourseSendPlugin.sendMsg(false)
EasyFloat.dismissAppFloat(activity, courseTag)
if (videoView != null) {
videoView!!.stopPlay()
videoView = null
}
if (timer != null) {
timer!!.cancel()
}
timer = null
}
}
\ No newline at end of file
......@@ -32,7 +32,7 @@
android:layout_marginTop="9dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/dp_10"
android:layout_marginEnd="@dimen/platform_dp_10"
android:padding="5dp"
android:src="@drawable/course_confideredpacket_close"
tools:ignore="OnClick" />
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl_video_layout"
android:layout_width="200dp"
android:layout_height="124dp"
android:background="@drawable/play_float_background"
android:visibility="visible">
<include
layout="@layout/course_videoplay_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/iv_video_close"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:padding="8dp"
android:scaleType="centerCrop"
android:src="@drawable/ico_play_float_pause"
android:visibility="visible" />
<ImageView
android:id="@+id/iv_video_full_screen"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:padding="8dp"
android:scaleType="centerCrop"
android:src="@drawable/course_ico_play_float_full"
android:visibility="visible" />
</RelativeLayout>
\ No newline at end of file
......@@ -216,7 +216,7 @@
android:layout_weight="1"
android:text=""
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_10" />
android:textSize="@dimen/platform_dp_10" />
<TextView
android:id="@+id/tv_allTime"
......@@ -228,7 +228,7 @@
android:layout_weight="1"
android:text=""
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_10" />
android:textSize="@dimen/platform_dp_10" />
<SeekBar
android:id="@+id/fm_progress"
......
......@@ -16,7 +16,7 @@
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/platform_color_333333"
android:textSize="@dimen/sp_16"
android:textSize="@dimen/platform_sp_16"
android:textStyle="bold"
tools:text="你的心理足够成熟么你的心理足够成熟么"
/>
......
......@@ -15,7 +15,7 @@
android:layout_marginRight="146dp"
android:ellipsize="end"
android:maxLines="1"
android:textSize="@dimen/sp_16"
android:textSize="@dimen/platform_sp_16"
android:textStyle="bold"
android:textColor="@color/platform_color_333333"
tools:text="你的心理足够成熟么你的心理足够成熟么"/>
......
......@@ -24,7 +24,7 @@ modular {
groupId = "com.ydl"
artifactId = "m-user-api"
//开发时注释掉版本号,发布api时打开
version = rootProject.ext.ydlPublishVersion[childProject.getName()+"-api"]
//version = rootProject.ext.ydlPublishVersion[childProject.getName()+"-api"]
// API 层打包时需要引入的依赖
apiDependencies {
implementation "com.google.code.gson:gson:2.8.2"
......
......@@ -79,9 +79,6 @@
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTask"
android:screenOrientation="portrait" />
<!--<meta-data-->
<!--android:name="com.yidianling.user.base.UserGlobalConfig"-->
<!--android:value="ModuleConfig"/>-->
<activity
android:name=".wxapi.WXEntryActivity"
android:exported="true"
......
......@@ -4,7 +4,7 @@ import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.mvp.base.IModel
import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.http.request.LoginParam
import io.reactivex.Observable
......@@ -19,7 +19,7 @@ interface LoginContract {
// 开始登录
fun startLogin()
// 登录成功
fun loginSuccess(userInfo: UserResponse?)
fun loginSuccess(userInfo: UserResponseBean?)
// 登录失败
fun loginFail(msg: String)
// 登录完成
......@@ -29,7 +29,7 @@ interface LoginContract {
}
interface Model: IModel {
fun login(param: LoginParam): Observable<BaseResponse<UserResponse>>
fun login(param: LoginParam): Observable<BaseResponse<UserResponseBean>>
}
interface Presenter: IPresenter<View> {
......
......@@ -6,7 +6,7 @@ import com.ydl.ydlcommon.data.http.ThrowableConsumer;
import com.ydl.ydlcommon.utils.BuryPointUtils;
import com.ydl.ydlcommon.utils.JPushUtils;
import com.ydl.ydlcommon.utils.log.LogHelper;
import com.yidianling.router.user.UserResponse;
import com.yidianling.user.api.bean.UserResponseBean;
import com.yidianling.user.api.event.UserLoginEvent;
import com.yidianling.user.http.UserHttp;
import com.yidianling.user.http.UserHttpImpl;
......@@ -48,7 +48,7 @@ public class LoginHelper {
}
}
public static void login(UserResponse response) {
public static void login(UserResponseBean response) {
UserHelper.INSTANCE.setUserinfo(response);
EventBus.getDefault().post(new UserLoginEvent("login",response.getUid()));
......
package com.yidianling.user
import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.http.UserHttp
import com.yidianling.user.http.UserHttpImpl
import com.yidianling.user.http.request.LoginParam
......@@ -14,7 +14,7 @@ import io.reactivex.Observable
*/
class LoginModel: LoginContract.Model {
override fun login(param: LoginParam): Observable<BaseResponse<UserResponse>> {
override fun login(param: LoginParam): Observable<BaseResponse<UserResponseBean>> {
val userHttp: UserHttp = UserHttpImpl.getInstance()
return userHttp.login(param)
}
......
......@@ -7,7 +7,7 @@ import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.router.im.IMLoginInfo
import com.yidianling.router.im.IMRequestCallback
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.http.request.LoginParam
import com.yidianling.user.route.UserIn
import de.greenrobot.event.EventBus
......@@ -64,7 +64,7 @@ class LoginPresenter(view: LoginContract.View): BasePresenter<LoginContract.View
})
}
private fun setHXInfo(userInfo: UserResponse?) {
private fun setHXInfo(userInfo: UserResponseBean?) {
try {
if (userInfo != null) {
UserIn.imSetAccount(userInfo.uid.toString())
......
......@@ -2,22 +2,17 @@ package com.yidianling.user
import com.tencent.bugly.crashreport.CrashReport
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.JPushUtils
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.common.tools.LogUtil
import com.yidianling.router.im.IMLoginInfo
import com.yidianling.router.im.IMRequestCallback
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.api.event.UserLoginEvent
import com.yidianling.user.http.UserHttpImpl
import com.yidianling.user.http.request.ChannelIdParam
import com.yidianling.user.http.request.Logout
import com.yidianling.user.route.UserIn
import de.greenrobot.event.EventBus
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
/**
......@@ -28,12 +23,12 @@ import io.reactivex.functions.Consumer
object LoginUtils {
@JvmStatic
fun saveData(userInfo: UserResponse?) {
fun saveData(userInfo: UserResponseBean?) {
UserHelper.setUserinfo(userInfo)
}
@JvmStatic
fun onLogin(userInfo: UserResponse?) {
fun onLogin(userInfo: UserResponseBean?) {
//设置异常用户ID
CrashReport.setUserId(userInfo?.uid)
//登录IM聊天
......@@ -43,22 +38,22 @@ object LoginUtils {
val loginEvent = UserLoginEvent("login", userInfo?.uid!!)
EventBus.getDefault().post(loginEvent)
BuryPointUtils.bindUid(userInfo?.uid ?: "")
val channelId = JPushUtils.getRegistrationID()
UserHttpImpl.getInstance().channelId(ChannelIdParam(channelId))
.compose(RxUtils.resultData())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
if (it["upload_log"] == "1") {
LogHelper.getInstance().uploadLog(false)
}
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
// ToastHelper.show(msg)
}
})
// val channelId = JPushUtils.getRegistrationID()
// UserHttpImpl.getInstance().channelId(ChannelIdParam(channelId))
// .compose(RxUtils.resultData())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(Consumer {
// if (it["upload_log"] == "1") {
// LogHelper.getInstance().uploadLog(false)
// }
// }, object : ThrowableConsumer() {
// override fun accept(msg: String) {
// // ToastHelper.show(msg)
// }
// })
}
private fun loginIm(userInfo: UserResponse?) {
private fun loginIm(userInfo: UserResponseBean?) {
val info = IMLoginInfo(userInfo?.uid ?: "", userInfo?.hxpwd ?: "")
val callback = object : IMRequestCallback<IMLoginInfo> {
override fun onSuccess(t: IMLoginInfo?) {
......
......@@ -5,8 +5,8 @@ import com.google.gson.Gson
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.UserInfoCache
import com.ydl.ydlcommon.utils.YdlBuryPointUtil
import com.yidianling.router.user.UserResponse
import com.yidianling.router.user.UserSetting
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.api.bean.UserSettingBean
/**
* 用户信息辅助类
......@@ -24,13 +24,13 @@ object UserHelper {
private val user_setting_key_sp = "ydl_user_setting_key"
//用户信息//缓存
private var userTemp: UserResponse? = null
private var userTemp: UserResponseBean? = null
//用户设置信息缓存
private var userSetting: UserSetting? = null
private var userSetting: UserSettingBean? = null
//存储用户信息
fun setUserinfo(userInfo: UserResponse?) {
fun setUserinfo(userInfo: UserResponseBean?) {
try {
userTemp = userInfo
var str = gson.toJson(userTemp)
......@@ -46,24 +46,33 @@ object UserHelper {
}
//获取用户设置信息
fun getUserInfo(): UserResponse? {
fun getUserInfo(): UserResponseBean? {
if (userTemp != null) return userTemp!!
try {
var obj = SharedPreferencesEditor.getFileString(user_info_name_sp, user_info_key_sp)
var app: UserResponse = gson.fromJson(obj, UserResponse::class.java)
var app: UserResponseBean = gson.fromJson(obj, UserResponseBean::class.java)
userTemp = app
return userTemp!!
} catch (e: Exception) {
userTemp = UserResponse()
userTemp = UserResponseBean()
}
return userTemp
}
fun updateUserinfo(userInfo: UserResponse.UserInfo?) {
fun getUserInfoStr(): String? {
if (userTemp != null) return gson.toJson(userTemp)
try {
return SharedPreferencesEditor.getFileString(user_info_name_sp, user_info_key_sp)
} catch (e: Exception) {
return ""
}
}
fun updateUserinfo(userInfo: UserResponseBean.UserInfo?) {
getUserInfo()?.userInfo = userInfo
}
fun updateUserSetting(userseting: UserSetting?) {
fun updateUserSetting(userseting: UserSettingBean?) {
setUserSetting(userseting)
}
......@@ -96,7 +105,7 @@ object UserHelper {
/**
* 存储用户设置信息
*/
fun setUserSetting(userseting: UserSetting?) {
fun setUserSetting(userseting: UserSettingBean?) {
try {
userSetting = userseting
var str = gson.toJson(userSetting)
......@@ -109,18 +118,27 @@ object UserHelper {
/**
* 获取用户设置信息
*/
fun getUsetSetting(): UserSetting? {
fun getUsetSetting(): UserSettingBean? {
if (userSetting != null) return userSetting!!
try {
var obj = SharedPreferencesEditor.getFileString(user_setting_name_sp, user_setting_key_sp)
if (TextUtils.isEmpty(obj)) {
setUserSetting(UserSetting())
setUserSetting(UserSettingBean())
}
var app: UserSetting = gson.fromJson(obj, UserSetting::class.java)
var app: UserSettingBean = gson.fromJson(obj, UserSettingBean::class.java)
userSetting = app
return userSetting
} catch (e: Exception) {
}
return userSetting
}
fun getUserSettingStr(): String? {
if (userSetting != null) return gson.toJson(userSetting)
try {
return SharedPreferencesEditor.getFileString(user_setting_name_sp, user_setting_key_sp)
} catch (e: Exception) {
return ""
}
}
}
\ No newline at end of file
package com.yidianling.user.base
import android.app.Application
import android.content.Context
import com.umeng.commonsdk.UMConfigure
import com.umeng.socialize.UMShareAPI
import com.ydl.ydlcommon.base.delegate.IAppLifecycles
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.user.api.event.UserSetEvent
import com.yidianling.user.api.service.IUserService
import com.yidianling.user.modular_service.UserServiceImp
import de.greenrobot.event.EventBus
/**
* Created by haorui on 2019-09-02.
* Des:
*/
class UserAppLifecycles : IAppLifecycles {
override fun attachBaseContext(base: Context) {
}
override fun onCreate(application: Application) {
EventBus.getDefault().register(this)
UMConfigure.init(application, "56970affe0f55a9cda001e24", "android_yidianling", UMConfigure.DEVICE_TYPE_PHONE, null)
UMShareAPI.init(application, "56970affe0f55a9cda001e24")
}
override fun onTerminate(application: Application) {
EventBus.getDefault().unregister(this)
}
open fun onEvent(event:UserSetEvent){
if (event.userResponse!=null){
ModularServiceManager.provide(IUserService::class.java).setUserResponse(event.userResponse)
} else if (event.userInfo!=null){
ModularServiceManager.provide(IUserService::class.java).updateUserInfoSp(event.userInfo)
}else if (event.userSetting!=null){
ModularServiceManager.provide(IUserService::class.java).updateUserSetingSp(event.userSetting)
}
}
}
package com.yidianling.user.base
import android.content.Context
import com.ydl.ydlcommon.base.config.GlobalConfig
import com.ydl.ydlcommon.base.config.IConfigModule
import com.ydl.ydlcommon.base.delegate.IAppLifecycles
/**
* Created by haorui on 2019-09-01 .
* Des:
*/
class UserGlobalConfig : IConfigModule {
override fun injectAppLifecycle(context: Context, lifecycles: MutableList<IAppLifecycles>) {
lifecycles.add(UserAppLifecycles())
}
override fun applyOptions(context: Context, builder: GlobalConfig.Builder) {}
}
......@@ -3,7 +3,7 @@ package com.yidianling.user.http
import com.google.gson.Gson
import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.http.request.*
import com.yidianling.user.http.response.ChcekPhoneResponeBean
import com.yidianling.user.http.response.PhoneAuthResponseBean
......@@ -48,7 +48,7 @@ class LoginApiRequestUtil {
/**
* 一键登录
*/
fun autoLogin(param: PhoneLoginAutoParam): Observable<BaseResponse<UserResponse>> {
fun autoLogin(param: PhoneLoginAutoParam): Observable<BaseResponse<UserResponseBean>> {
var str = Gson().toJson(param)
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str)
return getUserApi().autoLogin(body)
......@@ -57,7 +57,7 @@ class LoginApiRequestUtil {
/**
* 手机号密码登录
*/
fun userLoginByPassword(param: PhoneLoginPwdParam): Observable<BaseResponse<UserResponse>> {
fun userLoginByPassword(param: PhoneLoginPwdParam): Observable<BaseResponse<UserResponseBean>> {
var str = Gson().toJson(param)
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str)
return getUserApi().loginByPassword(body)
......@@ -66,7 +66,7 @@ class LoginApiRequestUtil {
/**
* 重新设置密码
*/
fun resetPwd(param: PhoneResetPwdParam): Observable<BaseResponse<UserResponse>> {
fun resetPwd(param: PhoneResetPwdParam): Observable<BaseResponse<UserResponseBean>> {
var str = Gson().toJson(param)
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str)
return getUserApi().resetPwd(body)
......@@ -82,7 +82,7 @@ class LoginApiRequestUtil {
/**
* 验证码登录
*/
fun loginByMsgCode(param: PhoneLoginCodeParam): Observable<BaseResponse<UserResponse>> {
fun loginByMsgCode(param: PhoneLoginCodeParam): Observable<BaseResponse<UserResponseBean>> {
var str = Gson().toJson(param)
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str)
return getUserApi().loginByMsgCode(body)
......
......@@ -6,7 +6,7 @@ import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.http.response.*
import io.reactivex.Observable
import okhttp3.RequestBody
......@@ -22,7 +22,7 @@ interface UserApi {
//登录
@FormUrlEncoded
@POST("user/user")
fun login(@FieldMap params: Map<String, String>): Observable<BaseResponse<UserResponse>>
fun login(@FieldMap params: Map<String, String>): Observable<BaseResponse<UserResponseBean>>
//国家列表
@FormUrlEncoded
......@@ -42,7 +42,7 @@ interface UserApi {
//绑定手机号
@FormUrlEncoded
@POST("user/bind-phone")
fun bindPhone(@FieldMap params: Map<String, String>): Observable<BaseResponse<UserResponse>>
fun bindPhone(@FieldMap params: Map<String, String>): Observable<BaseResponse<UserResponseBean>>
//忘记密码
@FormUrlEncoded
......@@ -62,7 +62,7 @@ interface UserApi {
//第三方登录
@POST("user/user_q_w")
@Headers( YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun thirdPartyLogin(@Body body: RequestBody): Observable<BaseAPIResponse<UserResponse>>
fun thirdPartyLogin(@Body body: RequestBody): Observable<BaseAPIResponse<UserResponseBean>>
//设置用户信息
@FormUrlEncoded
......@@ -126,17 +126,17 @@ interface UserApi {
//一键登录
@POST("user/login_direct")
@Headers( YDL_DOMAIN+ YDL_DOMAIN_JAVA)
fun autoLogin(@Body body: RequestBody): Observable<BaseResponse<UserResponse>>
fun autoLogin(@Body body: RequestBody): Observable<BaseResponse<UserResponseBean>>
//手机号密码登录
@POST("user/login_pwd")
@Headers( YDL_DOMAIN+ YDL_DOMAIN_JAVA)
fun loginByPassword(@Body body: RequestBody): Observable<BaseResponse<UserResponse>>
fun loginByPassword(@Body body: RequestBody): Observable<BaseResponse<UserResponseBean>>
//重新设置密码
@POST("user/reset_pwd")
@Headers( YDL_DOMAIN+ YDL_DOMAIN_JAVA)
fun resetPwd(@Body body: RequestBody): Observable<BaseResponse<UserResponse>>
fun resetPwd(@Body body: RequestBody): Observable<BaseResponse<UserResponseBean>>
//验证重置密码的短信验证码
@GET("user/precheck_reset_sms")
......@@ -161,12 +161,12 @@ interface UserApi {
//验证码登录
@POST("user/login_sms")
@Headers( YDL_DOMAIN+ YDL_DOMAIN_JAVA)
fun loginByMsgCode(@Body body: RequestBody): Observable<BaseResponse<UserResponse>>
fun loginByMsgCode(@Body body: RequestBody): Observable<BaseResponse<UserResponseBean>>
//第三方登录获取用户信息
@POST("user/user_q_w")
@Headers( YDL_DOMAIN+ YDL_DOMAIN_JAVA)
fun thirdPartJavaLogin(@Body body: RequestBody): Observable<BaseResponse<UserResponse>>
fun thirdPartJavaLogin(@Body body: RequestBody): Observable<BaseResponse<UserResponseBean>>
//第三方登录解绑
......
......@@ -5,7 +5,7 @@ import com.google.gson.internal.LinkedTreeMap
import com.umeng.socialize.bean.SHARE_MEDIA
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.bean.CheckPhonePassBean
import com.yidianling.user.http.request.*
import com.yidianling.user.http.response.CheckPassword
......@@ -20,7 +20,7 @@ import io.reactivex.Observable
*/
interface UserHttp {
fun login(param: LoginParam): Observable<BaseResponse<UserResponse>>
fun login(param: LoginParam): Observable<BaseResponse<UserResponseBean>>
fun countryList(): Observable<BaseResponse<CountryResponse>>
......@@ -28,7 +28,7 @@ interface UserHttp {
fun code(param: CodeParam): Observable<BaseResponse<Any>>
fun bindPhone(param: BindPhoneParam): Observable<BaseResponse<UserResponse>>
fun bindPhone(param: BindPhoneParam): Observable<BaseResponse<UserResponseBean>>
fun forget(param: ForgetParam): Observable<BaseResponse<Any>>
......@@ -36,7 +36,7 @@ interface UserHttp {
fun channelId(param: ChannelIdParam): Observable<BaseResponse<LinkedTreeMap<String, String>>>
fun thirdPartLogin(param: ThirdLoginParam): Observable<BaseAPIResponse<UserResponse>>
fun thirdPartLogin(param: ThirdLoginParam): Observable<BaseAPIResponse<UserResponseBean>>
fun setUserInfo(param: UserInfoParam): Observable<BaseResponse<Any>>
......@@ -56,7 +56,7 @@ interface UserHttp {
fun privacyAgree(uid: String): Observable<BaseResponse<Any>>
fun thirdPartJavaLogin(param: ThirdLoginParam): Observable<BaseResponse<UserResponse>>
fun thirdPartJavaLogin(param: ThirdLoginParam): Observable<BaseResponse<UserResponseBean>>
// 友盟第三方登录
fun umLogin(activity: Activity, media: SHARE_MEDIA): Observable<ThirdLoginParam>
......
......@@ -12,7 +12,7 @@ import com.ydl.ydlcommon.router.YdlCommonOut
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.common.tools.RxAppTool
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.UserHelper
import com.yidianling.user.bean.CheckPhonePassBean
import com.yidianling.user.http.request.*
......@@ -56,7 +56,7 @@ class UserHttpImpl private constructor() : UserHttp {
// .create(UserApi::class.java)
// }
override fun login(param: LoginParam): Observable<BaseResponse<UserResponse>> {
override fun login(param: LoginParam): Observable<BaseResponse<UserResponseBean>> {
return RxUtils.mapObservable(param)
.flatMap { getUserApi().login(it) }
}
......@@ -77,7 +77,7 @@ class UserHttpImpl private constructor() : UserHttp {
}
override fun bindPhone(param: BindPhoneParam): Observable<BaseResponse<UserResponse>> {
override fun bindPhone(param: BindPhoneParam): Observable<BaseResponse<UserResponseBean>> {
return RxUtils.mapObservable(param)
.flatMap { getUserApi().bindPhone(it) }
}
......@@ -97,7 +97,7 @@ class UserHttpImpl private constructor() : UserHttp {
.flatMap { getUserApi().setChannelId(it) }
}
override fun thirdPartLogin(param: ThirdLoginParam): Observable<BaseAPIResponse<UserResponse>> {
override fun thirdPartLogin(param: ThirdLoginParam): Observable<BaseAPIResponse<UserResponseBean>> {
var param: String = Gson().toJson(param)
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), param)
......@@ -178,7 +178,7 @@ class UserHttpImpl private constructor() : UserHttp {
return LoginObservable(activity, media)
}
override fun thirdPartJavaLogin(param: ThirdLoginParam): Observable<BaseResponse<UserResponse>> {
override fun thirdPartJavaLogin(param: ThirdLoginParam): Observable<BaseResponse<UserResponseBean>> {
var str = Gson().toJson(param)
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str)
return getUserApi().thirdPartJavaLogin(body)
......
......@@ -7,10 +7,10 @@ import android.text.TextUtils
import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.ydlcommon.base.BaseApp
import com.yidianling.common.tools.RxAppTool
import com.yidianling.user.UserHelper
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.api.bean.UserSettingBean
import com.yidianling.user.api.service.IUserService
import com.yidianling.user.modular_service.utils.UserServiceHelper
import com.yidianling.user.route.UserIn
import com.yidianling.user.safePrivate.FingerPrintUtil
import com.yidianling.user.safePrivate.PrivacyActivity
......@@ -32,64 +32,64 @@ public class UserServiceImp : IUserService {
}
override fun getUserSetting(): UserSettingBean? {
return UserServiceHelper.getUsetSetting()
return UserHelper.getUsetSetting()
}
override fun updateUserInfoSp(userInfo: UserResponseBean.UserInfo?) {
UserServiceHelper.updateUserinfo(userInfo)
UserHelper.updateUserinfo(userInfo)
}
override fun updateUserSetingSp(userSetting: UserSettingBean?) {
UserServiceHelper.updateUserSetting(userSetting)
UserHelper.updateUserSetting(userSetting)
}
override fun setChatTeamHisShowed(showed: Boolean) {
UserServiceHelper.getUsetSetting()?.chatTeamHisShowed = showed
UserHelper.getUsetSetting()?.chatTeamHisShowed = showed
}
override fun setUserResponse(userInfo: UserResponseBean?) {
UserServiceHelper.setUserinfo(userInfo)
UserHelper.setUserinfo(userInfo)
}
override fun getUserResponse(): UserResponseBean? {
return UserServiceHelper.getUserInfo()
return UserHelper.getUserInfo()
}
override fun isLogin(): Boolean {
return UserServiceHelper.isLogin()
return UserHelper.isLogin()
}
override fun isFirstLogin(): Boolean {
return UserServiceHelper.getUserInfo()?.firstLogin==1
return UserHelper.getUserInfo()?.firstLogin==1
}
override fun setFirstLogin(first: Boolean) {
var value : Int = if (first) 1 else 2 //1是2否
UserServiceHelper.getUserInfo()?.firstLogin = value
UserHelper.getUserInfo()?.firstLogin = value
}
override fun isSafePrivacyClicked(): Boolean {
return UserServiceHelper.getUsetSetting()?.meSafePrivateIsClick?:true
return UserHelper.getUsetSetting()?.meSafePrivateIsClick?:true
}
override fun putSafePrivacyClicked(clicked: Boolean) {
UserServiceHelper.getUsetSetting()?.meSafePrivateIsClick = clicked
UserHelper.getUsetSetting()?.meSafePrivateIsClick = clicked
}
override fun getUserInfo(): UserResponseBean.UserInfo? {
return UserServiceHelper.getUserInfo()?.userInfo
return UserHelper.getUserInfo()?.userInfo
}
override fun isBindPhone(): Boolean {
return !TextUtils.isEmpty(UserServiceHelper.getUserInfo()?.userInfo?.phone)
return !TextUtils.isEmpty(UserHelper.getUserInfo()?.userInfo?.phone)
}
override fun putUnlockCheckSuccessTime(time: Long) {
UserServiceHelper.getUsetSetting()?.unLockCheckSuccessTime = time
UserHelper.getUsetSetting()?.unLockCheckSuccessTime = time
}
override fun getChatTeamHisShow(): Boolean {
return UserServiceHelper.getUsetSetting()?.chatTeamHisShowed?:true
return UserHelper.getUsetSetting()?.chatTeamHisShowed?:true
}
override fun privacyIntent(activity: Activity): Intent {
......@@ -106,7 +106,7 @@ public class UserServiceImp : IUserService {
override fun safeTipViewGone(): Boolean {
//如果是非登录状态 或者 app指纹开启 或者 手势密码不为空 或者 已提示过安全解锁 -> 隐藏 设置密码提示
return !UserServiceHelper.isLogin() || FingerPrintUtil.instance().fingerPrintIsOpen()
return !UserHelper.isLogin() || FingerPrintUtil.instance().fingerPrintIsOpen()
|| !TextUtils.isEmpty(FingerPrintUtil.instance().getHandPass())
|| FingerPrintUtil.instance().getTrendsSafeTip()
}
......@@ -120,17 +120,17 @@ public class UserServiceImp : IUserService {
}
override fun isFirstStart(): Boolean {
val lastVersionCode : Int = UserServiceHelper.getUsetSetting()?.lastVersionCode?:0
val lastVersionCode : Int = UserHelper.getUsetSetting()?.lastVersionCode?:0
val currentVersionCode : Int = RxAppTool.getAppVersionCode(BaseApp.getApp())
if (lastVersionCode < currentVersionCode) {
UserServiceHelper.getUsetSetting()?.lastVersionCode = currentVersionCode
UserHelper.getUsetSetting()?.lastVersionCode = currentVersionCode
return true
}
return false
}
override fun clearUserInfo() {
UserServiceHelper.setUserinfo(null)
UserHelper.setUserinfo(null)
UserIn.clearImData()
}
}
\ No newline at end of file
package com.yidianling.user.modular_service.utils
import android.text.TextUtils
import com.google.gson.Gson
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.UserInfoCache
import com.ydl.ydlcommon.utils.YdlBuryPointUtil
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.api.bean.UserSettingBean
/**
* 用户信息辅助类
*/
object UserServiceHelper {
val gson: Gson = Gson()
//用户信息存储
private val user_info_name_sp = "ydl_user_info"
private val user_info_key_sp = "ydl_user_info_key"
//用户设置存储
private val user_setting_name_sp = "ydl_user_setting"
private val user_setting_key_sp = "ydl_user_setting_key"
//用户信息//缓存
private var userTemp: UserResponseBean? = null
//用户设置信息缓存
private var userSettingBean: UserSettingBean? = null
//存储用户信息
fun setUserinfo(userInfo: UserResponseBean?) {
try {
userTemp = userInfo
var str = gson.toJson(userTemp)
SharedPreferencesEditor.putFileString(user_info_name_sp, user_info_key_sp, str)
UserInfoCache.getInstance().saveYDLUser("\"" + userInfo?.uid + "\"",
userInfo?.userInfo?.nick_name, userInfo?.userInfo?.head)
YdlBuryPointUtil.reLogin()
} catch (e: Exception) {
e.printStackTrace()
}
}
//获取用户设置信息
fun getUserInfo(): UserResponseBean? {
if (userTemp != null) return userTemp!!
try {
var obj = SharedPreferencesEditor.getFileString(user_info_name_sp, user_info_key_sp)
var app: UserResponseBean = gson.fromJson(obj, UserResponseBean::class.java)
userTemp = app
return userTemp!!
} catch (e: Exception) {
userTemp = UserResponseBean()
}
return userTemp
}
fun updateUserinfo(userInfo: UserResponseBean.UserInfo?) {
getUserInfo()?.userInfo = userInfo
}
fun updateUserSetting(userseting: UserSettingBean?) {
setUserSettingBean(userseting)
}
/**
* 是否登录
*/
fun isLogin(): Boolean {
try {
var user = getUserInfo()?.userInfo
if (TextUtils.isEmpty(user?.uid)) {
return false
}
var uid: Int = user?.uid?.toInt() ?: 0
if (uid > 0) {
return true
}
} catch (e: Exception) {
e.printStackTrace()
}
return false
}
/**
* 是否绑定手机
*/
fun isBindPhone(): Boolean {
return !TextUtils.isEmpty(getUserInfo()?.userInfo?.phone)
}
/**
* 存储用户设置信息
*/
fun setUserSettingBean(userseting: UserSettingBean?) {
try {
userSettingBean = userseting
var str = gson.toJson(userSettingBean)
SharedPreferencesEditor.putFileString(user_setting_name_sp, user_setting_key_sp, str)
} catch (e: Exception) {
e.printStackTrace()
}
}
/**
* 获取用户设置信息
*/
fun getUsetSetting(): UserSettingBean? {
if (userSettingBean != null) return userSettingBean!!
try {
var obj = SharedPreferencesEditor.getFileString(user_setting_name_sp, user_setting_key_sp)
if (TextUtils.isEmpty(obj)) {
setUserSettingBean(UserSettingBean())
}
var app: UserSettingBean = gson.fromJson(obj, UserSettingBean::class.java)
userSettingBean = app
return userSettingBean
} catch (e: Exception) {
}
return userSettingBean
}
}
\ No newline at end of file
......@@ -4,13 +4,15 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.text.TextUtils
import com.google.gson.Gson
import com.ydl.ydlcommon.base.BaseApp
import com.yidianling.common.tools.RxAppTool
import com.yidianling.router.user.IUserRouter
import com.yidianling.router.user.UserResponse
import com.yidianling.router.user.UserSetting
import com.yidianling.user.UserHelper
import com.yidianling.user.modular_service.utils.UserServiceHelper
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.api.bean.UserSettingBean
import com.yidianling.user.safePrivate.FingerPrintUtil
import com.yidianling.user.safePrivate.PrivacyActivity
import com.yidianling.user.ui.InputPhoneActivity
......@@ -23,16 +25,30 @@ import com.yidianling.user.ui.login.RegisterAndLoginActivity
* time : 2018/04/13
*/
class UserRouterImp : IUserRouter {
val gson: Gson = Gson()
override fun getUserSetting(): UserSetting? {
return UserHelper.getUsetSetting()
var infoStr = UserHelper.getUserSettingStr()
if (TextUtils.isEmpty(infoStr)){
return null
}
return gson.fromJson(infoStr, UserSetting::class.java)
}
override fun updateUserInfoSp(userInfo: UserResponse.UserInfo?) {
UserHelper.updateUserinfo(userInfo)
if (userInfo==null){
return
}
val info:UserResponseBean.UserInfo = gson.fromJson( gson.toJson(userInfo), UserResponseBean.UserInfo::class.java)
UserHelper.updateUserinfo(info)
}
override fun updateUserSetingSp(userSetting: UserSetting?) {
UserHelper.updateUserSetting(userSetting)
if (userSetting==null){
return
}
val info:UserSettingBean= gson.fromJson(gson.toJson(userSetting), UserSettingBean::class.java)
UserHelper.updateUserSetting(info)
}
override fun setChatTeamHisShowed(showed: Boolean) {
......@@ -40,11 +56,16 @@ class UserRouterImp : IUserRouter {
}
override fun setUserResponse(userInfo: UserResponse?) {
UserHelper.setUserinfo(userInfo)
val info:UserResponseBean = gson.fromJson(gson.toJson(userInfo), UserResponseBean::class.java)
UserHelper.setUserinfo(info)
}
override fun getUserResponse(): UserResponse? {
return UserHelper.getUserInfo()
var infoStr = UserHelper.getUserInfoStr()
if (TextUtils.isEmpty(infoStr)){
return null
}
return gson.fromJson(infoStr,UserResponse::class.java)
}
override fun isLogin(): Boolean {
......@@ -69,7 +90,7 @@ class UserRouterImp : IUserRouter {
}
override fun getUserInfo(): UserResponse.UserInfo? {
return UserHelper.getUserInfo()?.userInfo
return gson.fromJson(UserHelper.getUserInfoStr(), UserResponse::class.java)?.userInfo
}
override fun isBindPhone(): Boolean {
......
......@@ -37,7 +37,7 @@ import com.ydl.ydlcommon.view.dialog.CommonDialog;
import com.ydl.ydlcommon.view.dialog.ThreeLinesDialog;
import com.yidianling.common.tools.RxFileTool;
import com.yidianling.common.tools.RxImageTool;
import com.yidianling.router.user.UserResponse;
import com.yidianling.user.api.bean.UserResponseBean;
import com.yidianling.user.*;
import com.yidianling.user.http.UserHttp;
import com.yidianling.user.http.UserHttpImpl;
......@@ -342,7 +342,7 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(this::dismissProgressDialog)
.subscribe(o -> {
UserResponse userInfo = UserHelper.INSTANCE.getUserInfo();
UserResponseBean userInfo = UserHelper.INSTANCE.getUserInfo();
if (userInfo != null) {
userInfo.getUserInfo().setHead(head);
userInfo.getUserInfo().setGender(gender);
......
......@@ -21,7 +21,7 @@ import com.ydl.ydlcommon.view.TitleBar;
import com.yidianling.router.RouterManager;
import com.yidianling.router.im.IMLoginInfo;
import com.yidianling.router.im.IMRequestCallback;
import com.yidianling.router.user.UserResponse;
import com.yidianling.user.api.bean.UserResponseBean;
import com.yidianling.user.LoginHelper;
import com.yidianling.user.R;
import com.yidianling.user.UserConstants;
......@@ -410,7 +410,7 @@ public class GetIdentifyingCodeActivity extends BaseActivity implements View.OnC
}
//用户信息 获取登陆信息
public void setHXinfo(UserResponse userInfo) {
public void setHXinfo(UserResponseBean userInfo) {
try {
if (userInfo != null) {
......
......@@ -15,7 +15,7 @@ import com.ydl.ydlcommon.view.DeleteEditTextView;
import com.ydl.ydlcommon.view.JumpTextView;
import com.ydl.ydlcommon.view.RoundCornerButton;
import com.ydl.ydlcommon.view.TitleBar;
import com.yidianling.router.user.UserResponse;
import com.yidianling.user.api.bean.UserResponseBean;
import com.yidianling.user.LoginContract;
import com.yidianling.user.LoginPresenter;
import com.yidianling.user.R;
......@@ -140,7 +140,7 @@ public class LoginActivity extends BaseMvpActivity<LoginContract.View,LoginContr
}
@Override
public void loginSuccess(UserResponse userInfo) {
public void loginSuccess(UserResponseBean userInfo) {
finishFinger();
int size = ActivityManager.Companion.getActivitySize();
if (size == 2 || size == 1) {
......
......@@ -16,7 +16,7 @@ import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.router.im.IMLoginInfo
import com.yidianling.router.im.IMRequestCallback
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.LoginUtils
import com.yidianling.user.UserConstants
import com.yidianling.user.constants.UserBIConstants
......@@ -181,7 +181,7 @@ class SmsLoginActivity : BaseActivity() {
// 登录 IM
private fun loginIM(info: UserResponse) {
private fun loginIM(info: UserResponseBean) {
val loginInfo = IMLoginInfo(info.uid.toString(), info.hxpwd!!)
val callback = object : IMRequestCallback<IMLoginInfo> {
override fun onSuccess(loginInfo: IMLoginInfo?) {
......@@ -201,7 +201,7 @@ class SmsLoginActivity : BaseActivity() {
}
//用户信息 获取登陆信息
fun setHXInfo(userInfo: UserResponse.UserInfo?) {
fun setHXInfo(userInfo: UserResponseBean.UserInfo?) {
try {
if (userInfo != null) {
UserIn.imSetAccount(userInfo.uid.toString())
......
......@@ -34,7 +34,7 @@ import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxKeyboardTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.BuildConfig
import com.yidianling.user.R
import com.yidianling.user.UserHelper
......@@ -438,7 +438,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
/**
*三方登录成功
*/
override fun thirdLoginSuccess(userInfo: UserResponse.UserInfo) {
override fun thirdLoginSuccess(userInfo: UserResponseBean.UserInfo) {
var bindPhone = userInfo.bind_phone
if (bindPhone != 1) {
countryCode = userInfo.country_code
......
......@@ -4,7 +4,7 @@ import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.mvp.base.IModel
import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.http.request.PhoneLoginPwdParam
import com.yidianling.user.http.request.PhoneResetPwdParam
import io.reactivex.Observable
......@@ -60,11 +60,11 @@ interface IInputPassWordContract {
/**
* 手机号密码登录
*/
fun userLoginByPassword(param: PhoneLoginPwdParam): Observable<BaseResponse<UserResponse>>
fun userLoginByPassword(param: PhoneLoginPwdParam): Observable<BaseResponse<UserResponseBean>>
/**
* 重新设置密码
*/
fun resetPwd(param: PhoneResetPwdParam): Observable<BaseResponse<UserResponse>>
fun resetPwd(param: PhoneResetPwdParam): Observable<BaseResponse<UserResponseBean>>
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.mvp.base.IModel
import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.http.request.BindPhoneJavaParam
import com.yidianling.user.http.request.CheckAliAuthParam
import com.yidianling.user.http.request.PhoneLoginAutoParam
......@@ -44,7 +44,7 @@ interface ILoginContract {
/**
* 三方登录成功
*/
fun thirdLoginSuccess(userInfo: UserResponse.UserInfo)
fun thirdLoginSuccess(userInfo: UserResponseBean.UserInfo)
/**
* 弹窗
......@@ -136,7 +136,7 @@ interface ILoginContract {
/**
* 通过一键认证服务登陆
*/
fun autoLogin(bean: PhoneLoginAutoParam): Observable<BaseResponse<UserResponse>>
fun autoLogin(bean: PhoneLoginAutoParam): Observable<BaseResponse<UserResponseBean>>
/**
*
......
......@@ -4,7 +4,7 @@ import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.mvp.base.IModel
import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.http.request.BindPhoneJavaParam
import com.yidianling.user.http.request.PhoneLoginCodeParam
import io.reactivex.Observable
......@@ -93,7 +93,7 @@ interface IVerificationCodeContract {
/**
* 验证码验证码登录
*/
fun loginByMsgCode(param: PhoneLoginCodeParam): Observable<BaseResponse<UserResponse>>
fun loginByMsgCode(param: PhoneLoginCodeParam): Observable<BaseResponse<UserResponseBean>>
/**
* 重置密码的验证码
......
package com.yidianling.user.ui.login.model
import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.http.LoginApiRequestUtil
import com.yidianling.user.http.request.PhoneLoginPwdParam
import com.yidianling.user.http.request.PhoneResetPwdParam
......@@ -19,14 +19,14 @@ class InputPassWordModelImpl : IInputPassWordContract.Model {
/**
* 重新设置密码
*/
override fun resetPwd(param: PhoneResetPwdParam): Observable<BaseResponse<UserResponse>> {
override fun resetPwd(param: PhoneResetPwdParam): Observable<BaseResponse<UserResponseBean>> {
return LoginApiRequestUtil.resetPwd(param)
}
/**
* 手机号密码登录
*/
override fun userLoginByPassword(param: PhoneLoginPwdParam): Observable<BaseResponse<UserResponse>> {
override fun userLoginByPassword(param: PhoneLoginPwdParam): Observable<BaseResponse<UserResponseBean>> {
return LoginApiRequestUtil.userLoginByPassword(param)
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ package com.yidianling.user.ui.login.model
import android.app.Activity
import com.umeng.socialize.bean.SHARE_MEDIA
import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.http.LoginApiRequestUtil
import com.yidianling.user.http.request.BindPhoneJavaParam
import com.yidianling.user.http.request.CheckAliAuthParam
......@@ -34,7 +34,7 @@ class LoginModelImpl : ILoginContract.Model {
/**
* 通过一键认证服务登陆
*/
override fun autoLogin(bean: PhoneLoginAutoParam): Observable<BaseResponse<UserResponse>> {
override fun autoLogin(bean: PhoneLoginAutoParam): Observable<BaseResponse<UserResponseBean>> {
return LoginApiRequestUtil.autoLogin(bean)
}
......
package com.yidianling.user.ui.login.model
import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.http.LoginApiRequestUtil
import com.yidianling.user.http.request.BindPhoneJavaParam
import com.yidianling.user.http.request.PhoneLoginCodeParam
......@@ -42,7 +42,7 @@ class VerificationCodeModelImpl : IVerificationCodeContract.Model {
/**
* 验证码验证码登录
*/
override fun loginByMsgCode(param: PhoneLoginCodeParam): Observable<BaseResponse<UserResponse>> {
override fun loginByMsgCode(param: PhoneLoginCodeParam): Observable<BaseResponse<UserResponseBean>> {
return LoginApiRequestUtil.loginByMsgCode(param)
}
......
......@@ -10,7 +10,7 @@ import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.common.tools.ToastUtil
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.LoginUtils
import com.yidianling.user.constants.UserBIConstants
import com.yidianling.user.http.request.PhoneLoginPwdParam
......@@ -111,7 +111,7 @@ class InputPassWordPresenterImpl : BasePresenter<IInputPassWordContract.View, II
/**
* 保存登录信息
*/
private fun saveUserData(userResponse: UserResponse) {
private fun saveUserData(userResponse: UserResponseBean) {
if (!TextUtils.isEmpty(userResponse.userInfo!!.phone)) {
YDLCacheUtils.saveUserPhone(userResponse.userInfo!!.phone)
YDLCacheUtils.saveCountryPhoneCode(userResponse.userInfo!!.country_code)
......
......@@ -11,7 +11,7 @@ import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.common.tools.ToastUtil
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.LoginUtils
import com.yidianling.user.UserHelper
import com.yidianling.user.constants.UserBIConstants
......@@ -91,7 +91,7 @@ class LoginPresenterImpl(view: ILoginContract.View) : BasePresenter<ILoginContra
/**
* 保存登录信息
*/
private fun saveUserData(userResponse: UserResponse) {
private fun saveUserData(userResponse: UserResponseBean) {
if (!TextUtils.isEmpty(userResponse.userInfo!!.phone)) {
YDLCacheUtils.saveUserPhone(userResponse.userInfo!!.phone)
YDLCacheUtils.saveCountryPhoneCode(userResponse.userInfo!!.country_code)
......
......@@ -7,7 +7,7 @@ import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.common.tools.ToastUtil
import com.yidianling.router.user.UserResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.LoginUtils
import com.yidianling.user.constants.UserBIConstants
import com.yidianling.user.http.request.BindPhoneJavaParam
......@@ -161,7 +161,7 @@ class VerificationCodePresenterImpl(view: IVerificationCodeContract.View) : Base
/**
* 保存登录信息
*/
private fun saveUserData(userResponse: UserResponse) {
private fun saveUserData(userResponse: UserResponseBean) {
if (!TextUtils.isEmpty(userResponse.userInfo!!.phone)) {
YDLCacheUtils.saveUserPhone(userResponse.userInfo!!.phone)
YDLCacheUtils.saveCountryPhoneCode(userResponse.userInfo!!.country_code)
......
package com.yidianling.user.api.bean
import com.google.gson.annotations.SerializedName
import com.yidianling.user.api.event.UserSetEvent
import de.greenrobot.event.EventBus
import com.yidianling.user.api.utils.UserApiServiceUtils
/**
......@@ -18,7 +17,7 @@ class UserResponseBean {
var userInfo: UserResponseBean.UserInfo? = UserInfo()
set(value) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().setUserResponse(this)
}
inner class UserInfo {
......@@ -51,7 +50,7 @@ class UserResponseBean {
set(value) {
if (value != bind_weixin) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
@field:SerializedName("bindQq")
......@@ -60,7 +59,7 @@ class UserResponseBean {
set(value) {
if (value != bind_qq) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
@field:SerializedName("userType")
......@@ -71,14 +70,14 @@ class UserResponseBean {
set(value) {
if (value != profession) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
var marriage: Int = 0
set(value) {
if (value != marriage) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
@field:SerializedName("countryCode")
......@@ -89,7 +88,7 @@ class UserResponseBean {
set(value) {
if (!(value?.equals(home_bg) ?: false)) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
//是否同意过隐私权限 1同意过 0未同意
......@@ -97,7 +96,7 @@ class UserResponseBean {
set(value) {
if (value != privacyAgreementStatus) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
......@@ -106,7 +105,7 @@ class UserResponseBean {
set(value) {
if (!(value?.equals(description) ?: false)) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
@field:SerializedName("isSilenced")
......@@ -114,7 +113,7 @@ class UserResponseBean {
set(value) {
if (value != is_silenced) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
var hasCoupon: Int = 0
......@@ -122,7 +121,7 @@ class UserResponseBean {
set(value) {
if (value != firstLogin) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
......@@ -130,7 +129,7 @@ class UserResponseBean {
set(value) {
if (value != trendNum) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
......@@ -139,7 +138,7 @@ class UserResponseBean {
set(value) {
if (value != fansNum) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
var testRecordNum: Int = 0
......@@ -147,7 +146,7 @@ class UserResponseBean {
set(value) {
if (value != testRecordNum) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
var attentionNum: Int = 0
......@@ -155,7 +154,7 @@ class UserResponseBean {
set(value) {
if (value != attentionNum) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
var registTime: String? = null
......@@ -163,7 +162,7 @@ class UserResponseBean {
set(value) {
if (!(value?.equals(registTime) ?: false)) {
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserInfoSp(this)
}
}
......
package com.yidianling.user.api.bean
import com.yidianling.user.api.event.UserSetEvent
import de.greenrobot.event.EventBus
import com.yidianling.user.api.utils.UserApiServiceUtils
/**
......@@ -15,7 +14,7 @@ class UserSettingBean {
set(value) {
if (fingerPrintStatus!=value){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
......@@ -24,7 +23,7 @@ class UserSettingBean {
set(value) {
if (unLockCheckSuccessTime!=value){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
//指纹多次错误被禁止使用的时间戳
......@@ -32,7 +31,7 @@ class UserSettingBean {
set(value) {
if (fingerErrorTime!=value){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
//手势密码
......@@ -40,7 +39,7 @@ class UserSettingBean {
set(value) {
if (!value.equals(gesturePassword)){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
//设置群聊历史记录
......@@ -48,7 +47,7 @@ class UserSettingBean {
set(value) {
if (chatTeamHisShowed!=value){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
//获取动态页面是否提示过安全解锁
......@@ -56,7 +55,7 @@ class UserSettingBean {
set(value) {
if (trendsIsClick!=value){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
//我的页面隐私安全是否点击过
......@@ -64,7 +63,7 @@ class UserSettingBean {
set(value) {
if (meSafePrivateIsClick!=value){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
//最后一次登录的版本号
......@@ -72,7 +71,7 @@ class UserSettingBean {
set(value) {
if (lastVersionCode!=value){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
/**
......@@ -82,7 +81,7 @@ class UserSettingBean {
set(value) {
if (hasVoice!=value){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
/**
......@@ -92,7 +91,7 @@ class UserSettingBean {
set(value) {
if (hasShake!=value){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
......@@ -100,7 +99,7 @@ class UserSettingBean {
set(value) {
if (time!=value){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
/**
......@@ -110,7 +109,7 @@ class UserSettingBean {
set(value){
if (phoneStatusPermissionIsShow!=value){
field = value
EventBus.getDefault().post(UserSetEvent(this))
UserApiServiceUtils.provideUserApiService().updateUserSetingSp(this)
}
}
}
\ No newline at end of file
package com.yidianling.user.api.event
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.api.bean.UserSettingBean
/**
* Created by haorui on 2019-10-07.
* Des:
*/
class UserSetEvent {
var userResponse: UserResponseBean?=null
var userInfo: UserResponseBean.UserInfo?=null
var userSetting: UserSettingBean?=null
constructor(userResponse: UserResponseBean?) {
this.userResponse = userResponse
}
constructor(userInfo: UserResponseBean.UserInfo) {
this.userInfo = userInfo
}
constructor(userSettingBean: UserSettingBean) {
this.userSetting = userSettingBean
}
}
package com.yidianling.user.api.utils
import com.alibaba.android.arouter.exception.NoRouteFoundException
import com.alibaba.android.arouter.facade.template.IProvider
import com.alibaba.android.arouter.launcher.ARouter
import com.yidianling.user.api.service.IUserService
/**
* Created by haorui on 2019-09-21 .
* Des:查找 Arouter 服务封装类
*/
object UserApiServiceUtils {
private val routerMap: HashMap<String, IProvider> = HashMap()
fun provideUserApiService(): IUserService {
return provide(IUserService::class.java)
}
private fun <T : IProvider> provide(clz: Class<T>): T {
var provider: IProvider? = null
val simpleName = clz.simpleName;
if (routerMap[simpleName]!=null){
return routerMap[simpleName] as T
}
try {
provider = ARouter.getInstance().navigation(clz)
if (provider == null){
throw NoRouteFoundException("Please check if you are dependent on the module containing $simpleName")
}
routerMap[simpleName] = provider
} catch (e: Exception) {
System.out.print(e.message)
}
return provider as T
}
}
\ No newline at end of file
package com.yidianling.router.user
import com.yidianling.router.RouterManager
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/04/26
*/
class UserSetting {
//是否开启指纹
var fingerPrintStatus: Boolean = false
set(value) {
if (fingerPrintStatus!=value){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
//指纹或手势验证成功时间
var unLockCheckSuccessTime: Long = 0L
set(value) {
if (unLockCheckSuccessTime!=value){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
//指纹多次错误被禁止使用的时间戳
var fingerErrorTime: Long = 0
set(value) {
if (fingerErrorTime!=value){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
//手势密码
var gesturePassword: String = ""
set(value) {
if (!value.equals(gesturePassword)){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
//设置群聊历史记录
var chatTeamHisShowed: Boolean = false
set(value) {
if (chatTeamHisShowed!=value){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
//获取动态页面是否提示过安全解锁
var trendsIsClick: Boolean = false
set(value) {
if (trendsIsClick!=value){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
//我的页面隐私安全是否点击过
var meSafePrivateIsClick = false
set(value) {
if (meSafePrivateIsClick!=value){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
//最后一次登录的版本号
var lastVersionCode = 0
set(value) {
if (lastVersionCode!=value){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
/**
* 消息语音提醒
*/
var hasVoice: Boolean = true
set(value) {
if (hasVoice!=value){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
/**
* 消息震动提醒
*/
var hasShake: Boolean = true
set(value) {
if (hasShake!=value){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
var time: Long = 0L
set(value) {
if (time!=value){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
/**
* 手机识别吗是否已经提示过
*/
var phoneStatusPermissionIsShow : Boolean = false
set(value){
if (phoneStatusPermissionIsShow!=value){
field = value
RouterManager.getUserRouter()?.updateUserSetingSp(this)
}
}
}
\ No newline at end of file
......@@ -99,6 +99,10 @@ class AudioPlayer private constructor() {
* 是否自动保存播放进度
*/
var autoSaveProgress = false
/**
* 是否显示通知栏
*/
var isShowNotify = false
private object SingletonHolder {
val instance = AudioPlayer()
......@@ -255,7 +259,7 @@ class AudioPlayer private constructor() {
for (listener in listeners) {
listener.onChange(music)
}
if (playMode != PlayModeEnum.SINGLE) {
if (isShowNotify) {
NotifyManager.get().showPlay(music)
MediaSessionManager.get().updateMetaData(music)
MediaSessionManager.get().updatePlaybackState()
......@@ -313,7 +317,7 @@ class AudioPlayer private constructor() {
mediaPlayer!!.start()
state = STATE_PLAYING
handler!!.post(mPublishRunnable)
if (playMode != PlayModeEnum.SINGLE) {
if (isShowNotify) {
NotifyManager.get().showPlay(playMusic)
MediaSessionManager.get().updatePlaybackState()
}
......@@ -336,8 +340,10 @@ class AudioPlayer private constructor() {
mediaPlayer!!.pause()
state = STATE_PAUSE
handler!!.removeCallbacks(mPublishRunnable)
NotifyManager.get().showPause(playMusic)
MediaSessionManager.get().updatePlaybackState()
if(isShowNotify){
NotifyManager.get().showPause(playMusic)
MediaSessionManager.get().updatePlaybackState()
}
context!!.unregisterReceiver(noisyReceiver)
if (abandonAudioFocus) {
audioFocusManager!!.abandonAudioFocus()
......
......@@ -40,15 +40,16 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
api 'com.squareup.retrofit2:retrofit:2.6.0'
api 'com.squareup.retrofit2:converter-gson:2.6.0'
api 'com.squareup.retrofit2:adapter-rxjava2:2.6.0'
api "io.reactivex.rxjava2:rxjava:2.2.10"
api 'io.reactivex.rxjava2:rxandroid:2.1.1'
api 'com.squareup.retrofit2:converter-scalars:2.4.0'
api 'com.squareup.okhttp3:logging-interceptor:3.12.2'
api rootProject.ext.dependencies["gson"]
api rootProject.ext.dependencies["rxjava2"]
api(rootProject.ext.dependencies["rxandroid2"]) {
exclude module: 'rxjava'
}
api rootProject.ext.dependencies["retrofit"]
api rootProject.ext.dependencies["okhttp3-logging"]
api rootProject.ext.dependencies["retrofit-converter-gson"]
api rootProject.ext.dependencies["retrofit-converter-scalars"]
api rootProject.ext.dependencies["retrofit-adapter-rxjava2"]
}
......@@ -41,22 +41,6 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.4.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
//noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'de.greenrobot:eventbus:2.4.0'
api 'com.umeng.sdk:share-wechat:6.9.1'
if (rootProject.ext.dev_mode){
//开发时使用
api project(':ydl-platform')
......
......@@ -75,13 +75,22 @@ dependencies {
api rootProject.ext.dependencies["ydl-pushagent"]
api rootProject.ext.dependencies["ydl-notracepoint"]
api rootProject.ext.dependencies["ydl-hnet"]
api rootProject.ext.dependencies["imagepicker"]
api(rootProject.ext.dependencies["imagepicker"]) {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-common'
}
api rootProject.ext.dependencies["ydl-utils"]
api rootProject.ext.dependencies["ydl-js"]
api rootProject.ext.dependencies["ydl-net"]
api rootProject.ext.dependencies["ydl-js"]
api rootProject.ext.dependencies["ptr-lib-release"]
api(rootProject.ext.dependencies["ydl-device"]) {
transitive = true
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-common'
}
api(rootProject.ext.dependencies["ydl-router"]) {
transitive = true
......@@ -114,17 +123,12 @@ dependencies {
api rootProject.ext.dependencies["glide"]
api rootProject.ext.dependencies["glide-transformations"]
api rootProject.ext.dependencies["constraint-layout"]
api rootProject.ext.dependencies["ptr-lib-release"]
api rootProject.ext.dependencies["cube"]
api rootProject.ext.dependencies["support-multidex"]
api rootProject.ext.dependencies["tablayout"]
api rootProject.ext.dependencies["xrecyclerview"]
api rootProject.ext.dependencies["BaseRecyclerViewAdapterHelper"]
api rootProject.ext.dependencies["flowlayout"]
api rootProject.ext.dependencies["androidanimations"]
api rootProject.ext.dependencies["exoplayer"]
//====================Tools====================
api rootProject.ext.dependencies["robust"]
api rootProject.ext.dependencies["walle"]
......
package com.ydl.ydlcommon.base
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.View
import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView
......@@ -27,8 +26,8 @@ abstract class BaseMvpFragment<V : IView, P : IPresenter<V>> : BaseFragment(), M
abstract override fun createPresenter(): P
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mvpDelegate?.onViewCreated(view, savedInstanceState)
super.onViewCreated(view, savedInstanceState)
}
override fun onDestroyView() {
......@@ -37,8 +36,8 @@ abstract class BaseMvpFragment<V : IView, P : IPresenter<V>> : BaseFragment(), M
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mvpDelegate?.onCreate(savedInstanceState)
super.onCreate(savedInstanceState)
}
override fun onDestroy() {
......
......@@ -19,6 +19,12 @@
<dimen name="platform_title_bar_height">45dp</dimen>
<dimen name="platform_action_bar_height">48dip</dimen>
<!--Common SP -->
<dimen name="platform_sp_12">12sp</dimen>
<dimen name="platform_sp_14">14sp</dimen>
<dimen name="platform_sp_16">16sp</dimen>
<!--Common DP-->
<dimen name="platform_dp_05">0.5dp</dimen>
<dimen name="platform_dp_1">1dp</dimen>
<dimen name="platform_dp_2">2dp</dimen>
......@@ -58,6 +64,7 @@
<dimen name="platform_dp_36">36dp</dimen>
<dimen name="platform_dp_37">37dp</dimen>
<dimen name="platform_dp_38">38dp</dimen>
<dimen name="platform_dp_40">40dp</dimen>
<dimen name="platform_dp_48">48dp</dimen>
<dimen name="platform_dp_60">60dp</dimen>
<dimen name="platform_dp_64">64dp</dimen>
......
......@@ -1217,7 +1217,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
dialog.setCallBack(type -> {
if (1 == type) {
if (!WebModularServiceUtils.Companion.getUserRouter().isLogin()) {
if (!WebModularServiceUtils.Companion.getUserService().isLogin()) {
isToTrend = true;
ARouter.getInstance().build("/user/login").navigation();
} else {
......
......@@ -44,15 +44,15 @@ class SafeTipView : LinearLayout {
.duration(400)
.onEnd { visibility = View.GONE }
.playOn(this@SafeTipView)
WebModularServiceUtils.getUserRouter().setTrendsSafeTip(true)
WebModularServiceUtils.getUserService().setTrendsSafeTip(true)
}
tvTip.setOnClickListener {
WebModularServiceUtils.getUserRouter().privacyIntent(context as Activity)
WebModularServiceUtils.getUserService().privacyIntent(context as Activity)
}
}
fun updateVisibility() {
if (WebModularServiceUtils.getUserRouter().safeTipViewGone()) {
if (WebModularServiceUtils.getUserService().safeTipViewGone()) {
this.visibility = View.GONE
} else {
this.visibility = View.VISIBLE
......
......@@ -3,8 +3,6 @@ package com.ydl.webview
import android.app.Activity
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.yidianling.router.RouterManager
import com.yidianling.router.user.IUserRouter
import com.yidianling.user.api.service.IUserService
/**
......@@ -14,10 +12,6 @@ import com.yidianling.user.api.service.IUserService
class WebModularServiceUtils {
companion object {
fun getUserRouter(): IUserRouter {
return RouterManager.getUserRouter()!!
}
fun getUserService(): IUserService {
return ModularServiceManager.provide(IUserService::class.java)
}
......
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