[1.0.10]首页通知轮询逻辑修改
This commit is contained in:
@@ -16,7 +16,6 @@ import com.xjjk.healthyclients.base.BaseVMBFragment
|
||||
import com.xjjk.healthyclients.bean.guidance.GuidanceListBean
|
||||
import com.xjjk.healthyclients.databinding.FragmentHomeBinding
|
||||
import com.xjjk.healthyclients.event.HomeTabChangeEvent
|
||||
import com.xjjk.healthyclients.event.RefreshEvent
|
||||
import com.xjjk.healthyclients.superfuntion.initColors
|
||||
import com.xjjk.healthyclients.superfuntion.showBanner
|
||||
import com.xjjk.healthyclients.superfuntion.startAppointmentWaitAffirmActivity
|
||||
@@ -47,6 +46,10 @@ class HomeFragment :
|
||||
var mDoctorList = arrayListOf<GuidanceListBean>()
|
||||
var mGuidanceFragmentDoctorAdapter: GuidanceFragmentDoctorAdapter? = null
|
||||
|
||||
var REQUEST_DURATION = 1000 * 120L
|
||||
|
||||
var noticeTime = REQUEST_DURATION
|
||||
|
||||
|
||||
override fun initView(root: View?, savedInstanceState: Bundle?) {
|
||||
mBinding.swipeRefresh.initColors()
|
||||
@@ -119,7 +122,8 @@ class HomeFragment :
|
||||
|
||||
}
|
||||
mBinding.apply {
|
||||
addClickViews(layoutItem4.imgLeft, layoutItem4.imgRight,
|
||||
addClickViews(
|
||||
layoutItem4.imgLeft, layoutItem4.imgRight,
|
||||
layoutItem1.homeHeadTab1, layoutItem1.homeHeadTab2, layoutItem1.homeHeadTab3,
|
||||
layoutItem1.homeHeadTab4, layoutItem3.tvDoctorMore
|
||||
)
|
||||
@@ -130,32 +134,39 @@ class HomeFragment :
|
||||
when (v?.id) {
|
||||
R.id.img_left -> {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("title","智慧体重")
|
||||
toActivity(EmptyActivity::class.java,bundle)
|
||||
bundle.putString("title", "智慧体重")
|
||||
toActivity(EmptyActivity::class.java, bundle)
|
||||
}
|
||||
|
||||
R.id.img_right -> {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("title","一人一案")
|
||||
toActivity(EmptyActivity::class.java,bundle)
|
||||
bundle.putString("title", "一人一案")
|
||||
toActivity(EmptyActivity::class.java, bundle)
|
||||
}
|
||||
|
||||
R.id.home_head_tab1 -> {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("title","健康档案")
|
||||
toActivity(EmptyActivity::class.java,bundle)
|
||||
bundle.putString("title", "健康档案")
|
||||
toActivity(EmptyActivity::class.java, bundle)
|
||||
}
|
||||
|
||||
R.id.home_head_tab2 -> {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("title","健康体检")
|
||||
toActivity(EmptyActivity::class.java,bundle)
|
||||
bundle.putString("title", "健康体检")
|
||||
toActivity(EmptyActivity::class.java, bundle)
|
||||
}
|
||||
|
||||
R.id.home_head_tab4 -> {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("title","健康银行")
|
||||
toActivity(EmptyActivity::class.java,bundle)
|
||||
bundle.putString("title", "健康银行")
|
||||
toActivity(EmptyActivity::class.java, bundle)
|
||||
|
||||
//
|
||||
// if (DataStoreManager.isLogin()) {
|
||||
// requireContext().startWebActivity(UrlConfig.getHomeBankH5Url(), myTitle = "健康银行")
|
||||
// } else {
|
||||
// startLoginActivity(requireContext())
|
||||
// }
|
||||
}
|
||||
|
||||
R.id.home_head_tab3 -> {
|
||||
@@ -187,10 +198,10 @@ class HomeFragment :
|
||||
super.onResume()
|
||||
if (DataStoreManager.isLogin()) {
|
||||
mBinding.tvHi.visibility = View.VISIBLE
|
||||
mBinding.layoutNotice.visibility = View.VISIBLE
|
||||
// mBinding.layoutNotice.visibility = View.VISIBLE
|
||||
mBinding.tvHi.text = "hi~ ${DataStoreManager.getUserInfo().realname}"
|
||||
} else {
|
||||
mBinding.layoutNotice.visibility = View.GONE
|
||||
// mBinding.layoutNotice.visibility = View.GONE
|
||||
mBinding.tvHi.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
@@ -219,13 +230,13 @@ class HomeFragment :
|
||||
homeBannerBean.showLocation.equals("4")
|
||||
}.sortedBy { homeBannerBean -> homeBannerBean.sort }
|
||||
|
||||
showBanner(mBinding.banner1,bannerList1){
|
||||
showBanner(mBinding.banner1, bannerList1) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("title","体检套餐")
|
||||
toActivity(EmptyActivity::class.java,bundle)
|
||||
bundle.putString("title", "体检套餐")
|
||||
toActivity(EmptyActivity::class.java, bundle)
|
||||
|
||||
}
|
||||
showBanner(mBinding.banner2,bannerList2){
|
||||
showBanner(mBinding.banner2, bannerList2) {
|
||||
|
||||
toActivity(HomeBannerDetailActivity::class.java)
|
||||
}
|
||||
@@ -252,20 +263,21 @@ class HomeFragment :
|
||||
mViewModel.homeNoticeRepeat.collectLatest {
|
||||
stringList.clear()
|
||||
if (it.isNullOrEmpty()) {
|
||||
stringList.add("暂无通知")
|
||||
mBinding.layoutNotice.visibility = View.GONE
|
||||
} else {
|
||||
it.forEach { noticeData ->
|
||||
stringList.add(noticeData.title)
|
||||
}
|
||||
mBinding.layoutNotice.visibility = View.VISIBLE
|
||||
}
|
||||
mBinding.homeMarqueeView.stopFlipping()
|
||||
delay(100)
|
||||
mBinding.homeMarqueeView.startWithList(stringList)
|
||||
delay(1000 * 120)
|
||||
mViewModel.getHomeNoticeListRepeat()
|
||||
// getNoticeMessage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lifecycleScope.launch {
|
||||
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||
mViewModel.mDoctorList.collectLatest { list ->
|
||||
@@ -290,24 +302,35 @@ class HomeFragment :
|
||||
|
||||
|
||||
override fun initData() {
|
||||
onRefresh()
|
||||
mViewModel.getHomeBannerList()
|
||||
if (ConstantUtils.mCheckToken) {
|
||||
mViewModel.selectDoctorRecommendHome()
|
||||
}
|
||||
if (DataStoreManager.isLogin()) {
|
||||
homeNoticeStartRepeat()
|
||||
}
|
||||
}
|
||||
|
||||
private fun homeNoticeStartRepeat() {
|
||||
lifecycleScope.launch {
|
||||
repeat(100) {
|
||||
mViewModel.getHomeNoticeListRepeat()
|
||||
delay(noticeTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onRefresh() {
|
||||
mBinding.swipeRefresh.isRefreshing = false
|
||||
mViewModel.getHomeBannerList()
|
||||
|
||||
if (ConstantUtils.mCheckToken) {
|
||||
mViewModel.selectDoctorRecommendHome()
|
||||
}
|
||||
if (DataStoreManager.isLogin()) {
|
||||
mViewModel.getHomeNoticeListRepeat()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMessageEvent(event: Any?) {
|
||||
if (event is RefreshEvent) {
|
||||
mViewModel.getHomeNoticeListRepeat()
|
||||
onRefresh()
|
||||
}
|
||||
super.onMessageEvent(event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,10 @@ object UrlConfig {
|
||||
|
||||
// 安眼修改密码
|
||||
const val ANYAN_CHANGE_PASSWORD_H5 = "https://sso.iosp.ydpt.tech/SSOManageClient/userController/changePassword"
|
||||
private const val HOME_BANK_H5 = "https://gstest.superwx.cn/healthbank/index.html"
|
||||
|
||||
|
||||
val baseUrlType: BaseUrlType = BaseUrlType.TEST
|
||||
val baseUrlType: BaseUrlType = BaseUrlType.PRODUCT
|
||||
|
||||
var isOpenIm: Boolean = true
|
||||
|
||||
@@ -98,6 +99,18 @@ object UrlConfig {
|
||||
return getH5BaseUrl(baseUrlType) + "/static/monitor/index.html?"
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机银行外链h5
|
||||
*/
|
||||
fun getHomeBankH5Url(): String{
|
||||
var httpUrl = getDefaultBaseUrl().toHttpUrl()
|
||||
|
||||
return HOME_BANK_H5+"?scheme=" + httpUrl.scheme +
|
||||
"&host=" + httpUrl.host +
|
||||
"&tokenF=" + DataStoreManager.getToken()
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取评估报告模块地址
|
||||
|
||||
@@ -90,7 +90,7 @@ class HomeViewModel : BaseViewModel() {
|
||||
showDialog = false,
|
||||
{
|
||||
handleRequest(
|
||||
HomeRepository.getHomeNoticeList(1, 10),
|
||||
HomeRepository.getHomeNoticeList(1, 20),
|
||||
successBlock = {
|
||||
homeNoticeRepeat.emit(it.result)
|
||||
})
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
android:id="@+id/rv_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="20dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
<include
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.allen.library.shape.ShapeRelativeLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/layout_notice"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginLeft="28dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textColor="@color/color_theme_or_black_33"
|
||||
|
||||
Reference in New Issue
Block a user