Commit 77266238 by 徐健
parents bef23df6 a22ecff5
...@@ -165,7 +165,7 @@ dependencies { ...@@ -165,7 +165,7 @@ dependencies {
kapt rootProject.ext.dependencies["butterknife-compiler"] kapt rootProject.ext.dependencies["butterknife-compiler"]
if (rootProject.ext.dev_mode) { if (true) {
//开发模式 //开发模式
api project(':m-user') api project(':m-user')
api project(':m-fm') api project(':m-fm')
...@@ -174,7 +174,7 @@ dependencies { ...@@ -174,7 +174,7 @@ dependencies {
api (project(':ydl-platform')){ api (project(':ydl-platform')){
transitive = true transitive = true
} }
// implementation project(':ydl-webview') implementation project(':ydl-webview')
implementation project(':ydl-media') implementation project(':ydl-media')
} else { } else {
//发布模式 //发布模式
......
...@@ -33,9 +33,18 @@ import kotlinx.android.synthetic.main.activity_main.* ...@@ -33,9 +33,18 @@ import kotlinx.android.synthetic.main.activity_main.*
*/ */
class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(), class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(),
DemoContract.View { DemoContract.View {
private var serviceConnection: ServiceConnection? = null private var serviceConnection: ServiceConnection? = null
protected var playService: PlayService? = null protected var playService: PlayService? = null
override fun getContentViewId(): Int {
return R.id.lce_content_view
}
override fun getStateViewId(): Int {
return R.id.lce_state_view
}
override fun setData(data: String) { override fun setData(data: String) {
tv_content.text = data tv_content.text = data
} }
...@@ -50,10 +59,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -50,10 +59,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
override fun initDataAndEvent() { override fun initDataAndEvent() {
bindService() bindService()
loadData() reLoadData()
requestPermission() requestPermission()
tv_user.setOnClickListener { tv_user.setOnClickListener {
loadData() reLoadData()
} }
tv_home.setOnClickListener { tv_home.setOnClickListener {
...@@ -111,7 +120,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -111,7 +120,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
override fun loadData() { override fun reLoadData() {
mPresenter?.loadUsers() mPresenter?.loadUsers()
} }
......
...@@ -6,6 +6,14 @@ import com.ydl.component.mvp.DemoPresenter ...@@ -6,6 +6,14 @@ import com.ydl.component.mvp.DemoPresenter
import com.ydl.ydlcommon.mvp.lce.BaseLceActivity import com.ydl.ydlcommon.mvp.lce.BaseLceActivity
class MusicPlayActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(), DemoContract.View { class MusicPlayActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(), DemoContract.View {
override fun getContentViewId(): Int {
return R.id.lce_content_view
}
override fun getStateViewId(): Int {
return R.id.lce_state_view
}
private var mPlayFragment: PlayFragment? = null private var mPlayFragment: PlayFragment? = null
override fun createPresenter(): DemoContract.Presenter { override fun createPresenter(): DemoContract.Presenter {
...@@ -17,10 +25,10 @@ class MusicPlayActivity : BaseLceActivity<DemoContract.View, DemoContract.Prese ...@@ -17,10 +25,10 @@ class MusicPlayActivity : BaseLceActivity<DemoContract.View, DemoContract.Prese
} }
override fun initDataAndEvent() { override fun initDataAndEvent() {
loadData() reLoadData()
} }
override fun loadData() { override fun reLoadData() {
mPresenter.loadFmMusic() mPresenter.loadFmMusic()
} }
......
...@@ -18,7 +18,8 @@ import io.reactivex.Observable ...@@ -18,7 +18,8 @@ import io.reactivex.Observable
class DemoModel : BaseModel(), DemoContract.Model { class DemoModel : BaseModel(), DemoContract.Model {
override fun getFmMusic(): Observable<HomeFMBean> { override fun getFmMusic(): Observable<HomeFMBean> {
return YDLHttpUtils.obtainApi(DemoService::class.java) return YDLHttpUtils.obtainApi(DemoService::class.java)
.getFMData().compose(RxUtils.resultJavaData()) .getFMData()
.compose(RxUtils.resultJavaData())
} }
......
...@@ -24,18 +24,15 @@ class DemoPresenter : BasePresenter<DemoContract.View,DemoContract.Model>(), ...@@ -24,18 +24,15 @@ class DemoPresenter : BasePresenter<DemoContract.View,DemoContract.Model>(),
} }
override fun onSuccess(homeFMBean: HomeFMBean) { override fun onSuccess(homeFMBean: HomeFMBean) {
// var jsonStirng = Gson().toJson(homeFMBean.list)
// val list = Gson().fromJson<ArrayList<Music>>(jsonStirng, object : TypeToken<ArrayList<Music>>() {}.type)
homeFMBean.list?.let { homeFMBean.list?.let {
AudioPlayer.get().addPlayList(stringToMusicPlayerList(it)) AudioPlayer.get().addPlayList(stringToMusicPlayerList(it))
mView.setData("") mView.setData("")
} }
} }
}) })
} }
override fun loadHome() = mModel!!.getHome() override fun loadHome() = mModel.getHome()
.compose(RxUtils.applySchedulers(mView)) .compose(RxUtils.applySchedulers(mView))
.subscribe(object : CommonObserver<JsonObject>() { .subscribe(object : CommonObserver<JsonObject>() {
override fun onError(errorMsg: String) { override fun onError(errorMsg: String) {
...@@ -43,11 +40,11 @@ class DemoPresenter : BasePresenter<DemoContract.View,DemoContract.Model>(), ...@@ -43,11 +40,11 @@ class DemoPresenter : BasePresenter<DemoContract.View,DemoContract.Model>(),
override fun onSuccess(users: JsonObject) { override fun onSuccess(users: JsonObject) {
var cateTitle = users.getAsJsonObject("data").getAsJsonArray("askCategoryData").get(0).asJsonObject.get("cateTitle").asString; var cateTitle = users.getAsJsonObject("data").getAsJsonArray("askCategoryData").get(0).asJsonObject.get("cateTitle").asString;
mView?.setData(cateTitle) mView.setData(cateTitle)
} }
}) })
override fun loadUsers() = mModel!!.getUser() override fun loadUsers() = mModel.getUser()
.compose(RxUtils.applySchedulers(mView))//使用 Rxlifecycle,使 Disposable 和 Activity 一起销毁 .compose(RxUtils.applySchedulers(mView))//使用 Rxlifecycle,使 Disposable 和 Activity 一起销毁
.subscribe(object : CommonObserver<JsonArray>() { .subscribe(object : CommonObserver<JsonArray>() {
override fun onError(errorMsg: String) { override fun onError(errorMsg: String) {
......
...@@ -172,7 +172,7 @@ ext { ...@@ -172,7 +172,7 @@ ext {
//Modular Api //Modular Api
"ydl-user-router" : 'com.ydl:router:1.0.0-SNAPSHOT@aar', "ydl-user-router" : 'com.ydl:router:1.0.0-SNAPSHOT@aar',
"ydl-platform" : 'com.ydl:ydl-platform:0.0.10@aar', "ydl-platform" : 'com.ydl:ydl-platform:0.0.12@aar',
"ydl-m-user-api" : 'com.ydl:m-user-api:0.0.5', "ydl-m-user-api" : 'com.ydl:m-user-api:0.0.5',
"ydl-webview" : 'com.ydl:ydl-webview:0.0.14@aar', "ydl-webview" : 'com.ydl:ydl-webview:0.0.14@aar',
"ydl-m-muse-api" : 'com.ydl:m-muse-api:0.0.1@aar', "ydl-m-muse-api" : 'com.ydl:m-muse-api:0.0.1@aar',
......
...@@ -8,14 +8,14 @@ modular { ...@@ -8,14 +8,14 @@ modular {
groupId = "com.ydl" groupId = "com.ydl"
artifactId = "m-consultant-module-xlzx" artifactId = "m-consultant-module-xlzx"
// 上报的 心理咨询 业务模块 aar 包的版本号 // 上报的 心理咨询 业务模块 aar 包的版本号
version = "0.0.11" version = "0.0.13"
} }
ydl{ ydl{
groupId = "com.ydl" groupId = "com.ydl"
artifactId = "m-consultant-module-ydl" artifactId = "m-consultant-module-ydl"
// 上报的 壹点灵 业务模块 aar 包的版本号 // 上报的 壹点灵 业务模块 aar 包的版本号
version = "0.0.11" version = "0.0.13"
} }
} }
......
...@@ -14,7 +14,7 @@ import com.ydl.ydlcommon.bean.StatusBarOptions ...@@ -14,7 +14,7 @@ import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.utils.BuryPointUtils import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.DisplayUtils import com.ydl.ydlcommon.utils.DisplayUtils
import com.ydl.ydlcommon.utils.StatusBarUtils import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.UMEventUtils
import com.ydl.ydlcommon.utils.log.LogHelper import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils import com.ydl.ydlcommon.utils.remind.HttpErrorUtils
import com.yidianling.common.tools.LogUtil import com.yidianling.common.tools.LogUtil
......
...@@ -20,7 +20,7 @@ import com.ydl.ydlcommon.router.YdlCommonOut ...@@ -20,7 +20,7 @@ import com.ydl.ydlcommon.router.YdlCommonOut
import com.ydl.ydlcommon.router.YdlCommonRouterManager import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.ydl.ydlcommon.utils.BuryPointUtils import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.SharedPreferencesEditor import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.UMEventUtils
import com.ydl.ydlcommon.view.listener.EndlessRecyclerViewScrollListener import com.ydl.ydlcommon.view.listener.EndlessRecyclerViewScrollListener
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.router.RouterManager import com.yidianling.router.RouterManager
......
...@@ -8,14 +8,14 @@ modular { ...@@ -8,14 +8,14 @@ modular {
groupId = "com.ydl" groupId = "com.ydl"
artifactId = "m-user-module-xlzx" artifactId = "m-user-module-xlzx"
// 上报的 心理咨询 业务模块 aar 包的版本号 // 上报的 心理咨询 业务模块 aar 包的版本号
version = "0.0.19" version = "0.0.21"
} }
ydl{ ydl{
groupId = "com.ydl" groupId = "com.ydl"
artifactId = "m-user-module-ydl" artifactId = "m-user-module-ydl"
// 上报的 壹点灵 业务模块 aar 包的版本号 // 上报的 壹点灵 业务模块 aar 包的版本号
version = "0.0.19" version = "0.0.21"
} }
} }
......
...@@ -8,7 +8,7 @@ import android.view.View; ...@@ -8,7 +8,7 @@ import android.view.View;
import com.ydl.ydlcommon.base.BaseMvpActivity; import com.ydl.ydlcommon.base.BaseMvpActivity;
import com.ydl.ydlcommon.data.http.EncryptUtils; import com.ydl.ydlcommon.data.http.EncryptUtils;
import com.ydl.ydlcommon.utils.ActivityManager; import com.ydl.ydlcommon.utils.ActivityManager;
import com.ydl.ydlcommon.utils.UMEventUtils;
import com.ydl.ydlcommon.utils.log.LogHelper; import com.ydl.ydlcommon.utils.log.LogHelper;
import com.ydl.ydlcommon.utils.remind.ToastHelper; import com.ydl.ydlcommon.utils.remind.ToastHelper;
import com.ydl.ydlcommon.view.DeleteEditTextView; import com.ydl.ydlcommon.view.DeleteEditTextView;
......
...@@ -11,7 +11,7 @@ import android.view.animation.AnimationUtils ...@@ -11,7 +11,7 @@ import android.view.animation.AnimationUtils
import com.ydl.ydlcommon.base.BaseMvpActivity import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.utils.ActivityManager import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.StatusBarUtils import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.UMEventUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.view.dialog.CommonDialog import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.RxKeyboardTool import com.yidianling.common.tools.RxKeyboardTool
......
...@@ -28,7 +28,7 @@ import com.umeng.socialize.bean.SHARE_MEDIA ...@@ -28,7 +28,7 @@ import com.umeng.socialize.bean.SHARE_MEDIA
import com.ydl.ydlcommon.base.BaseMvpActivity import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.utils.ActivityManager import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.StatusBarUtils import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.UMEventUtils
import com.ydl.ydlcommon.utils.YDLCacheUtils import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.actionutil.BIConstants import com.ydl.ydlcommon.utils.actionutil.BIConstants
......
...@@ -10,7 +10,7 @@ import android.view.View ...@@ -10,7 +10,7 @@ import android.view.View
import com.ydl.ydlcommon.base.BaseMvpActivity import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.utils.ActivityManager import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.StatusBarUtils import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.UMEventUtils
import com.ydl.ydlcommon.utils.YDLCacheUtils import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.actionutil.BIConstants import com.ydl.ydlcommon.utils.actionutil.BIConstants
......
...@@ -5,7 +5,7 @@ import android.text.TextUtils ...@@ -5,7 +5,7 @@ import android.text.TextUtils
import com.ydl.ydlcommon.mvp.base.BasePresenter import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.ydl.ydlcommon.router.YdlCommonOut import com.ydl.ydlcommon.router.YdlCommonOut
import com.ydl.ydlcommon.utils.StringUtils import com.ydl.ydlcommon.utils.StringUtils
import com.ydl.ydlcommon.utils.UMEventUtils
import com.ydl.ydlcommon.utils.YDLCacheUtils import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.LogHelper import com.ydl.ydlcommon.utils.log.LogHelper
......
...@@ -6,7 +6,7 @@ import android.text.TextUtils ...@@ -6,7 +6,7 @@ import android.text.TextUtils
import com.umeng.socialize.bean.SHARE_MEDIA import com.umeng.socialize.bean.SHARE_MEDIA
import com.ydl.ydlcommon.mvp.base.BasePresenter import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.ydl.ydlcommon.router.YdlCommonOut import com.ydl.ydlcommon.router.YdlCommonOut
import com.ydl.ydlcommon.utils.UMEventUtils
import com.ydl.ydlcommon.utils.YDLCacheUtils import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.LogHelper import com.ydl.ydlcommon.utils.log.LogHelper
......
...@@ -2,7 +2,7 @@ package com.yidianling.user.ui.login.presenter ...@@ -2,7 +2,7 @@ package com.yidianling.user.ui.login.presenter
import android.text.TextUtils import android.text.TextUtils
import com.ydl.ydlcommon.mvp.base.BasePresenter import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.ydl.ydlcommon.utils.UMEventUtils
import com.ydl.ydlcommon.utils.YDLCacheUtils import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.LogHelper import com.ydl.ydlcommon.utils.log.LogHelper
......
...@@ -16,7 +16,7 @@ import android.widget.RelativeLayout; ...@@ -16,7 +16,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.yidianling.user.R; import com.yidianling.user.R;
import com.ydl.ydlcommon.utils.UMEventUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
IS_PUBLISH=true IS_PUBLISH=true
VERSION_NAME=0.0.10 VERSION_NAME=0.0.12
\ No newline at end of file \ No newline at end of file
...@@ -86,6 +86,7 @@ object RxUtils { ...@@ -86,6 +86,7 @@ object RxUtils {
/** /**
* RxJava 线程协调 / RxLifecycle绑定方法 * RxJava 线程协调 / RxLifecycle绑定方法
* 自动调用 showLoading/hideLoading 方法
* @param view LceView 强转使用 * @param view LceView 强转使用
*/ */
fun <T> applySchedulers(view: ILceView): ObservableTransformer<T, T> { fun <T> applySchedulers(view: ILceView): ObservableTransformer<T, T> {
......
...@@ -2,7 +2,6 @@ package com.ydl.ydlcommon.mvp.lce ...@@ -2,7 +2,6 @@ package com.ydl.ydlcommon.mvp.lce
import android.support.annotation.CallSuper import android.support.annotation.CallSuper
import android.view.View import android.view.View
import com.ydl.ydlcommon.R
import com.ydl.ydlcommon.base.BaseMvpActivity import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.mvp.base.IPresenter import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView import com.ydl.ydlcommon.mvp.base.IView
...@@ -13,34 +12,28 @@ import com.ydl.ydlcommon.mvp.lce.view.ILceViewState ...@@ -13,34 +12,28 @@ import com.ydl.ydlcommon.mvp.lce.view.ILceViewState
* Des: LCE 架构 BaseActivity,统一处理页面加载状态 * Des: LCE 架构 BaseActivity,统一处理页面加载状态
* LCE:L:Loading加载,C:Content加载内容,E:Error加载失败 * LCE:L:Loading加载,C:Content加载内容,E:Error加载失败
* *
* 【注意:StateView需设置id为:R.id.lce_state_view】 * 【注意:StateView需继承 ILceViewState 接口】
* 【注意:ContentView需设置id为:R.id.lce_content_view】
*/ */
abstract class BaseLceActivity<V : IView, P : IPresenter<V>> : BaseMvpActivity<V, P>(), ILceView{ abstract class BaseLceActivity<V : IView, P : IPresenter<V>> : BaseMvpActivity<V, P>(), ILceView {
protected lateinit var lceStateView: ILceViewState private var lceStateView: ILceViewState? = null
protected var lceContentView: View? = null private var lceContentView: View? = null
@CallSuper @CallSuper
override fun onContentChanged() { override fun onContentChanged() {
super.onContentChanged() super.onContentChanged()
lceStateView = createStateView() lceStateView = createStateView()
lceContentView = createContentView() lceContentView = createContentView()
if (lceContentView == null) {
throw NullPointerException(
"请检查布局文件中ContentView是否设置,id需为R.id.lce_content_view"
)
}
} }
protected fun createStateView(): ILceViewState { private fun createStateView(): ILceViewState {
val stateView = findViewById<View>(R.id.lce_state_view) val stateView:View? = findViewById<View>(getStateViewId())
if (stateView is ILceViewState) {
if (stateView != null && stateView is ILceViewState) {
val viewState = stateView as ILceViewState val viewState = stateView as ILceViewState
viewState.setListener(object : ILceViewState.LogoLoadingListener { viewState.setListener(object : ILceViewState.LogoLoadingListener {
override fun onDataResetClick() { override fun onDataResetClick() {
loadData() reLoadData()
} }
override fun onBackClick() { override fun onBackClick() {
...@@ -51,33 +44,48 @@ abstract class BaseLceActivity<V : IView, P : IPresenter<V>> : BaseMvpActivity<V ...@@ -51,33 +44,48 @@ abstract class BaseLceActivity<V : IView, P : IPresenter<V>> : BaseMvpActivity<V
} }
throw NullPointerException( throw NullPointerException(
"请检查布局文件中StateView是否设置,id需为R.id.lce_state_view" "请检查布局文件中 StateView 是否设置,StateView 需继承 ILceViewState 接口 , className:${this.javaClass.simpleName}"
) )
} }
protected fun createContentView(): View { private fun createContentView(): View {
return findViewById(R.id.lce_content_view) val contentView: View? = findViewById<View>(getContentViewId())
?: throw NullPointerException(
"请检查布局文件中 ContentView 是否设置 , className:${this.javaClass.simpleName}"
)
return contentView!!
} }
/**
* 获取 ContentView 控件ID
*/
abstract fun getContentViewId(): Int
/**
* 获取 StateVie 控件 ID
*/
abstract fun getStateViewId(): Int
override fun showLoading() { override fun showLoading() {
lceStateView.showLoading() lceStateView?.showLoading()
lceContentView?.visibility = View.INVISIBLE
} }
override fun hideLoading() { override fun hideLoading() {
lceStateView.hideLoading()
}
override fun showContent() {
lceContentView?.visibility = View.VISIBLE lceContentView?.visibility = View.VISIBLE
lceStateView.hideLoading() lceStateView?.hideLoading()
} }
override fun showEmpty(msg: String) { override fun showEmpty(msg: String) {
lceStateView.showEmpty(msg) lceContentView?.visibility = View.INVISIBLE
lceStateView?.showEmpty(msg)
} }
override fun showError(msg: String) { override fun showError(msg: String) {
lceStateView.showError(msg) lceContentView?.visibility = View.INVISIBLE
lceStateView?.showError(msg)
} }
} }
......
...@@ -4,7 +4,6 @@ import android.os.Bundle ...@@ -4,7 +4,6 @@ import android.os.Bundle
import android.support.annotation.CallSuper import android.support.annotation.CallSuper
import android.support.v4.app.FragmentActivity import android.support.v4.app.FragmentActivity
import android.view.View import android.view.View
import com.ydl.ydlcommon.R
import com.ydl.ydlcommon.base.BaseMvpDialogFragment import com.ydl.ydlcommon.base.BaseMvpDialogFragment
import com.ydl.ydlcommon.mvp.base.IPresenter import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView import com.ydl.ydlcommon.mvp.base.IView
...@@ -21,30 +20,23 @@ import java.util.* ...@@ -21,30 +20,23 @@ import java.util.*
*/ */
abstract class BaseLceDialogFragment<V : IView, P : IPresenter<V>> : BaseMvpDialogFragment<V, P>(), ILceView { abstract class BaseLceDialogFragment<V : IView, P : IPresenter<V>> : BaseMvpDialogFragment<V, P>(), ILceView {
protected var lceStateView: ILceViewState? = null private var lceStateView: ILceViewState? = null
protected var lceContentView: View? = null private var lceContentView: View? = null
@CallSuper @CallSuper
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
lceStateView = createStateView(view) lceStateView = createStateView(view)
lceContentView = createContentView(view) lceContentView = createContentView(view)
if (lceContentView == null) {
throw NullPointerException(
"请检查布局文件中ContentView是否设置,id需为R.id.lce_content_view"
)
}
} }
protected fun createStateView(view: View): ILceViewState { private fun createStateView(view: View): ILceViewState {
val stateView = view.findViewById<View>(R.id.lce_state_view) val stateView:View? = view.findViewById<View>(getStateViewId())
if (stateView is ILceViewState) { if (stateView != null && stateView is ILceViewState) {
val viewState = stateView as ILceViewState val viewState = stateView as ILceViewState
viewState.setListener(object : ILceViewState.LogoLoadingListener { viewState.setListener(object : ILceViewState.LogoLoadingListener {
override fun onDataResetClick() { override fun onDataResetClick() {
loadData() reLoadData()
} }
override fun onBackClick() { override fun onBackClick() {
...@@ -55,34 +47,48 @@ abstract class BaseLceDialogFragment<V : IView, P : IPresenter<V>> : BaseMvpDial ...@@ -55,34 +47,48 @@ abstract class BaseLceDialogFragment<V : IView, P : IPresenter<V>> : BaseMvpDial
} }
throw NullPointerException( throw NullPointerException(
"请检查布局文件中StateView是否设置,id需为R.id.lce_state_view" "请检查布局文件中 StateView 是否设置,StateView 需继承 ILceViewState 接口 , className:${this.javaClass.simpleName}"
) )
} }
private fun createContentView(view: View): View {
val contentView: View? = view.findViewById<View>(getContentViewId())
?: throw NullPointerException(
"请检查布局文件中 ContentView 是否设置 , className:${this.javaClass.simpleName}"
)
protected fun createContentView(view: View): View { return contentView!!
return view.findViewById(R.id.lce_content_view)
} }
/**
* 获取 ContentView 控件ID
*/
abstract fun getContentViewId(): Int
/**
* 获取 StateVie 控件 ID
*/
abstract fun getStateViewId(): Int
override fun showLoading() { override fun showLoading() {
lceStateView!!.showLoading() lceStateView?.showLoading()
lceContentView?.visibility = View.INVISIBLE
} }
override fun hideLoading() { override fun hideLoading() {
lceStateView!!.hideLoading()
}
override fun showContent() {
lceContentView?.visibility = View.VISIBLE lceContentView?.visibility = View.VISIBLE
lceStateView!!.hideLoading() lceStateView?.hideLoading()
} }
override fun showEmpty(msg: String) { override fun showEmpty(msg: String) {
lceStateView!!.showEmpty(msg) lceContentView?.visibility = View.INVISIBLE
lceStateView?.showEmpty(msg)
} }
override fun showError(msg: String) { override fun showError(msg: String) {
lceStateView!!.showError(msg) lceContentView?.visibility = View.INVISIBLE
lceStateView?.showError(msg)
} }
override fun onDestroyView() { override fun onDestroyView() {
......
...@@ -4,7 +4,6 @@ import android.os.Bundle ...@@ -4,7 +4,6 @@ import android.os.Bundle
import android.support.annotation.CallSuper import android.support.annotation.CallSuper
import android.support.v4.app.FragmentActivity import android.support.v4.app.FragmentActivity
import android.view.View import android.view.View
import com.ydl.ydlcommon.R
import com.ydl.ydlcommon.base.BaseMvpFragment import com.ydl.ydlcommon.base.BaseMvpFragment
import com.ydl.ydlcommon.mvp.base.IPresenter import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView import com.ydl.ydlcommon.mvp.base.IView
...@@ -20,8 +19,8 @@ import java.util.* ...@@ -20,8 +19,8 @@ import java.util.*
*/ */
abstract class BaseLceFragment< V : IView, P : IPresenter<V>> : BaseMvpFragment<V, P>(), ILceView { abstract class BaseLceFragment< V : IView, P : IPresenter<V>> : BaseMvpFragment<V, P>(), ILceView {
protected var lceStateView: ILceViewState? = null private var lceStateView: ILceViewState? = null
protected var lceContentView: View? = null private var lceContentView: View? = null
@CallSuper @CallSuper
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
...@@ -37,13 +36,13 @@ abstract class BaseLceFragment< V : IView, P : IPresenter<V>> : BaseMvpFragment< ...@@ -37,13 +36,13 @@ abstract class BaseLceFragment< V : IView, P : IPresenter<V>> : BaseMvpFragment<
} }
protected fun createStateView(view: View): ILceViewState { private fun createStateView(view: View): ILceViewState {
val stateView = view.findViewById<View>(R.id.lce_state_view) val stateView:View? = view.findViewById<View>(getStateViewId())
if (stateView is ILceViewState) { if (stateView != null && stateView is ILceViewState) {
val viewState = stateView as ILceViewState val viewState = stateView as ILceViewState
viewState.setListener(object : ILceViewState.LogoLoadingListener { viewState.setListener(object : ILceViewState.LogoLoadingListener {
override fun onDataResetClick() { override fun onDataResetClick() {
loadData() reLoadData()
} }
override fun onBackClick() { override fun onBackClick() {
...@@ -54,34 +53,48 @@ abstract class BaseLceFragment< V : IView, P : IPresenter<V>> : BaseMvpFragment< ...@@ -54,34 +53,48 @@ abstract class BaseLceFragment< V : IView, P : IPresenter<V>> : BaseMvpFragment<
} }
throw NullPointerException( throw NullPointerException(
"请检查布局文件中StateView是否设置,id需为R.id.lce_state_view" "请检查布局文件中 StateView 是否设置,StateView 需继承 ILceViewState 接口 , className:${this.javaClass.simpleName}"
) )
} }
private fun createContentView(view: View): View {
val contentView: View? = view.findViewById<View>(getContentViewId())
?: throw NullPointerException(
"请检查布局文件中 ContentView 是否设置 , className:${this.javaClass.simpleName}"
)
protected fun createContentView(view: View): View { return contentView!!
return view.findViewById(R.id.lce_content_view)
} }
/**
* 获取 ContentView 控件ID
*/
abstract fun getContentViewId(): Int
/**
* 获取 StateVie 控件 ID
*/
abstract fun getStateViewId(): Int
override fun showLoading() { override fun showLoading() {
lceStateView!!.showLoading() lceStateView?.showLoading()
lceContentView?.visibility = View.INVISIBLE
} }
override fun hideLoading() { override fun hideLoading() {
lceStateView!!.hideLoading()
}
override fun showContent() {
lceContentView?.visibility = View.VISIBLE lceContentView?.visibility = View.VISIBLE
lceStateView!!.hideLoading() lceStateView?.hideLoading()
} }
override fun showEmpty(msg: String) { override fun showEmpty(msg: String) {
lceStateView!!.showEmpty(msg) lceContentView?.visibility = View.INVISIBLE
lceStateView?.showEmpty(msg)
} }
override fun showError(msg: String) { override fun showError(msg: String) {
lceStateView!!.showError(msg) lceContentView?.visibility = View.INVISIBLE
lceStateView?.showError(msg)
} }
override fun onDestroyView() { override fun onDestroyView() {
......
...@@ -16,15 +16,12 @@ interface ILceView : IView{ ...@@ -16,15 +16,12 @@ interface ILceView : IView{
fun hideLoading() fun hideLoading()
@UiThread @UiThread
fun showContent()
@UiThread
fun showError(msg: String) fun showError(msg: String)
@UiThread @UiThread
fun showEmpty(msg: String) fun showEmpty(msg: String)
@UiThread @UiThread
fun loadData() fun reLoadData()
} }
package com.ydl.ydlcommon.utils;
import android.content.Context;
import com.ydl.ydl_router.provider.YDLRouterBurryPointProvider;
/**
* Created by Wi1ls on 2016/11/11;
*/
//@Route(path = "/burry/point")
public class UMEventUtils implements YDLRouterBurryPointProvider{
@Override
public void init(Context context) {
}
@Override
public void burryPoint(String s, String s1) {
}
}
...@@ -10,7 +10,7 @@ import android.view.View ...@@ -10,7 +10,7 @@ import android.view.View
import android.widget.LinearLayout import android.widget.LinearLayout
import com.daimajia.androidanimations.library.Techniques import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo import com.daimajia.androidanimations.library.YoYo
import com.ydl.ydlcommon.utils.UMEventUtils
import kotlinx.android.synthetic.main.web_ui_private_safe_hint.view.* import kotlinx.android.synthetic.main.web_ui_private_safe_hint.view.*
......
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