Przeglądaj źródła

1.兼职工作的模块首页构架

liukai 2 lat temu
rodzic
commit
ec70393656
26 zmienionych plików z 704 dodań i 150 usunięć
  1. 17 18
      cpt_main/src/main/res/layout/fragment_home.xml
  2. 3 1
      cpt_parttime/src/main/AndroidManifest.xml
  3. 134 0
      cpt_parttime/src/main/java/com/hongyegroup/cpt_parttime/mvvm/PartTimeHomeViewModel.kt
  4. 4 122
      cpt_parttime/src/main/java/com/hongyegroup/cpt_parttime/mvvm/PartTimeMainViewModel.kt
  5. 2 2
      cpt_parttime/src/main/java/com/hongyegroup/cpt_parttime/router/PartTimeComponentServiceImpl.kt
  6. 316 0
      cpt_parttime/src/main/java/com/hongyegroup/cpt_parttime/ui/activity/PartTimeMainActivity.kt
  7. 2 2
      cpt_parttime/src/main/java/com/hongyegroup/cpt_parttime/ui/main/PartTimeMainFragment.kt
  8. BIN
      cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_active_blue.webp
  9. BIN
      cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_active_gray.webp
  10. BIN
      cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_job_blue.webp
  11. BIN
      cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_job_gray.webp
  12. BIN
      cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_me_blue.webp
  13. BIN
      cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_me_gray.webp
  14. BIN
      cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_train_blue.webp
  15. BIN
      cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_train_gray.webp
  16. BIN
      cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_wallet_blue.webp
  17. BIN
      cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_wallet_gray.webp
  18. 10 0
      cpt_parttime/src/main/res/drawable/selector_part_time_tab_active.xml
  19. 10 0
      cpt_parttime/src/main/res/drawable/selector_part_time_tab_job.xml
  20. 10 0
      cpt_parttime/src/main/res/drawable/selector_part_time_tab_me.xml
  21. 10 0
      cpt_parttime/src/main/res/drawable/selector_part_time_tab_train.xml
  22. 10 0
      cpt_parttime/src/main/res/drawable/selector_part_time_tab_wallet.xml
  23. 172 0
      cpt_parttime/src/main/res/layout/activity_part_time_main.xml
  24. 2 2
      cpt_parttime/src/main/res/layout/fragment_parttime_main.xml
  25. 0 1
      cs_baselib/src/main/java/com/guadou/lib_baselib/font_text_view/TypefaceUtil.java
  26. 2 2
      standalone/parttimerunalone/src/main/java/com/guadou/parttimerunalone/PartTimeMainActivity.kt

+ 17 - 18
cpt_main/src/main/res/layout/fragment_home.xml

@@ -159,7 +159,7 @@
                             android:layout_marginRight="@dimen/d_7dp"
                             android:text="¥ 0"
                             android:textColor="@color/black"
-                            android:textSize="@dimen/d_14sp"
+                            android:textSize="@dimen/d_14dsp"
                             app:layout_constraintBottom_toBottomOf="parent"
                             app:layout_constraintRight_toLeftOf="@id/iv_back_more"
                             app:layout_constraintTop_toTopOf="parent" />
@@ -199,14 +199,14 @@
                             binding:clicks="@{click.gotoParttimePage}">
 
                             <RelativeLayout
-                                android:layout_width="@dimen/d_65dp"
-                                android:layout_height="@dimen/d_65dp"
+                                android:layout_width="@dimen/d_70dp"
+                                android:layout_height="@dimen/d_70dp"
                                 android:layout_marginTop="@dimen/d_16dp">
 
                                 <ImageView
                                     android:id="@+id/iv_category_yyjobs"
-                                    android:layout_width="@dimen/d_65dp"
-                                    android:layout_height="@dimen/d_65dp"
+                                    android:layout_width="@dimen/d_70dp"
+                                    android:layout_height="@dimen/d_70dp"
                                     android:src="@drawable/home_yyjobs_categroy" />
 
                                 <!-- 未读数量 -->
@@ -229,7 +229,7 @@
                                 android:layout_marginTop="@dimen/d_3dp"
                                 android:text="兼职工作"
                                 android:textColor="@color/black"
-                                android:textSize="@dimen/d_15sp" />
+                                android:textSize="@dimen/d_14dsp" />
 
                         </LinearLayout>
 
@@ -244,14 +244,14 @@
                             binding:clicks="@{click.gotoNewsFeedTab}">
 
                             <RelativeLayout
-                                android:layout_width="@dimen/d_65dp"
-                                android:layout_height="@dimen/d_65dp"
+                                android:layout_width="@dimen/d_70dp"
+                                android:layout_height="@dimen/d_70dp"
                                 android:layout_marginTop="@dimen/d_16dp">
 
                                 <ImageView
                                     android:id="@+id/iv_category_newsfeed"
-                                    android:layout_width="@dimen/d_65dp"
-                                    android:layout_height="@dimen/d_65dp"
+                                    android:layout_width="@dimen/d_70dp"
+                                    android:layout_height="@dimen/d_70dp"
                                     android:src="@drawable/home_newsfeed_categroy" />
 
                                 <!-- NewsFeed未读提示-->
@@ -283,7 +283,6 @@
 
                             </RelativeLayout>
 
-
                             <com.guadou.lib_baselib.font_text_view.TextViewBold
                                 android:id="@+id/tv_category_news_feed"
                                 android:layout_width="wrap_content"
@@ -291,7 +290,7 @@
                                 android:layout_marginTop="@dimen/d_3dp"
                                 android:text="朋友圈"
                                 android:textColor="@color/black"
-                                android:textSize="@dimen/d_15sp" />
+                                android:textSize="@dimen/d_14dsp" />
 
                         </LinearLayout>
 
@@ -306,14 +305,14 @@
                             binding:clicks="@{click.gotoRewardsPage}">
 
                             <RelativeLayout
-                                android:layout_width="@dimen/d_65dp"
-                                android:layout_height="@dimen/d_65dp"
+                                android:layout_width="@dimen/d_70dp"
+                                android:layout_height="@dimen/d_70dp"
                                 android:layout_marginTop="@dimen/d_16dp">
 
                                 <ImageView
                                     android:id="@+id/iv_category_rewards"
-                                    android:layout_width="@dimen/d_65dp"
-                                    android:layout_height="@dimen/d_65dp"
+                                    android:layout_width="@dimen/d_70dp"
+                                    android:layout_height="@dimen/d_70dp"
                                     android:src="@drawable/home_rewards_categroy" />
 
                                 <View
@@ -330,13 +329,13 @@
 
 
                             <com.guadou.lib_baselib.font_text_view.TextViewBold
-                                android:id="@+id/tv_category_re"
+                                android:id="@+id/tv_category_rewards"
                                 android:layout_width="wrap_content"
                                 android:layout_height="wrap_content"
                                 android:layout_marginTop="@dimen/d_3dp"
                                 android:text="积分兑换"
                                 android:textColor="@color/black"
-                                android:textSize="@dimen/d_15sp" />
+                                android:textSize="@dimen/d_14dsp" />
 
                         </LinearLayout>
 

+ 3 - 1
cpt_parttime/src/main/AndroidManifest.xml

@@ -6,7 +6,9 @@
 
         <activity android:name=".ui.activity.PartTimeJobDetailActivity" />
 
-        <activity android:name=".ui.ChooseCityActivity" />
+        <activity
+            android:name=".ui.activity.PartTimeMainActivity"
+            android:launchMode="singleTask" />
 
         <activity android:name=".ui.activity.PartJobAlbumActivity" />
 

+ 134 - 0
cpt_parttime/src/main/java/com/hongyegroup/cpt_parttime/mvvm/PartTimeHomeViewModel.kt

@@ -0,0 +1,134 @@
+package com.hongyegroup.cpt_parttime.mvvm
+
+import android.annotation.SuppressLint
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.SavedStateHandle
+import com.guadou.cs_cptservices.binding.BaseDataBindingAdapter
+import com.guadou.lib_baselib.base.vm.BaseViewModel
+import com.guadou.lib_baselib.ext.checkEmpty
+import com.hongyegroup.cpt_parttime.BR
+import com.hongyegroup.cpt_parttime.R
+import com.hongyegroup.cpt_parttime.bean.PartJobResult
+import dagger.hilt.android.lifecycle.HiltViewModel
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.async
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.withContext
+import javax.inject.Inject
+
+@SuppressLint("NotifyDataSetChanged")
+@HiltViewModel
+class PartTimeHomeViewModel @Inject constructor(
+    private val savedStateHandle: SavedStateHandle
+) : BaseViewModel() {
+
+    val mKeywordLiveData = MutableLiveData<String>()  //搜索Key值
+    var mCurPage = 1
+    var isNeedPlaceHolder = true
+    var isNeedCleanAllData = true
+
+    var mNewsJobDataes = mutableListOf<String>()
+    val mNewJobAdapter by lazy { BaseDataBindingAdapter(R.layout.item_part_time_new_job, BR.item, mNewsJobDataes) }
+
+    var mAllJobDataes = mutableListOf<PartJobResult>()
+    val mAllJobAdapter by lazy { BaseDataBindingAdapter(R.layout.item_part_time_jobs, BR.item, mAllJobDataes) }
+
+    /**
+     * 获取兼职工作列表
+     */
+
+    fun requestJobList(): LiveData<Boolean> {
+        val liveData = MutableLiveData<Boolean>()
+
+        launchOnUI {
+            //开始Loading
+            if (isNeedPlaceHolder) loadStartLoading()
+
+
+            async {
+                if (mCurPage == 1) {
+                    mNewsJobDataes.clear()
+                    for (i in 1..5) {
+                        mNewsJobDataes.add(i.toString())
+                    }
+                }
+            }
+            mNewJobAdapter.notifyDataSetChanged()
+
+            val result = withContext(Dispatchers.IO) {
+                delay(1000)
+
+                val list = mutableListOf<PartJobResult>()
+                for (i in 1..10) {
+                    if (isNeedCleanAllData) {
+                        if (i == 4) list.add(PartJobResult().apply {
+                            type = 2
+                            groupDate = "2022-03-$mCurPage 星期二"
+                        })
+                    }
+                    list.add(PartJobResult().apply {
+                        type = 1
+                        groupDate = "2022-03-$mCurPage 星期二"
+                    })
+                }
+                return@withContext list
+            }
+
+            loadSuccess()
+            handleData(result)
+            liveData.postValue(true)
+
+            //返回的数据是封装过的,检查是否成功
+//            result.checkResult({
+//                loadSuccess()
+//                //成功
+//                handleData(it?.list)
+//                liveData.postValue(true)
+//            }, {
+//                //失败
+//                if (isNeedPlaceHolder) {
+//                    loadError(it)
+//                } else {
+//                    toast(it)
+//                }
+//                liveData.postValue(false)
+//            })
+        }
+
+        return liveData
+    }
+
+    //处理数据-添加或刷新
+    private fun handleData(list: List<PartJobResult>?) {
+        if (!list.checkEmpty()) {
+            //有数据,判断是刷新还是加载更多的数据
+            if (isNeedCleanAllData) {
+                //刷新的方式
+                mAllJobDataes.clear()
+                mAllJobDataes.addAll(list!!)
+                mAllJobAdapter.notifyDataSetChanged()
+            } else {
+                //加载更多
+                mAllJobDataes.addAll(list!!)
+                mAllJobAdapter.notifyItemRangeInserted(mAllJobDataes.size - list.size, list.size)
+                mAllJobAdapter.loadMoreModule.loadMoreComplete()
+            }
+        } else {
+            //展示无数据
+            if (isNeedCleanAllData && mCurPage == 1) {
+                mAllJobDataes.clear()
+                mAllJobDataes.add(PartJobResult())  //空视图
+                mAllJobAdapter.notifyDataSetChanged()
+                mAllJobAdapter.loadMoreModule.loadMoreEnd()
+            } else {
+                //如果是加载更多,展示加载完成,没有更多数据了
+                mAllJobAdapter.loadMoreModule.loadMoreEnd()
+            }
+        }
+        isNeedPlaceHolder = false
+        isNeedCleanAllData = false
+    }
+
+
+}

+ 4 - 122
cpt_parttime/src/main/java/com/hongyegroup/cpt_parttime/mvvm/PartTimeMainViewModel.kt

@@ -1,134 +1,16 @@
 package com.hongyegroup.cpt_parttime.mvvm
 
-import android.annotation.SuppressLint
-import androidx.lifecycle.LiveData
-import androidx.lifecycle.MutableLiveData
 import androidx.lifecycle.SavedStateHandle
-import com.guadou.cs_cptservices.binding.BaseDataBindingAdapter
 import com.guadou.lib_baselib.base.vm.BaseViewModel
-import com.guadou.lib_baselib.ext.checkEmpty
-import com.hongyegroup.cpt_parttime.BR
-import com.hongyegroup.cpt_parttime.R
-import com.hongyegroup.cpt_parttime.bean.PartJobResult
 import dagger.hilt.android.lifecycle.HiltViewModel
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.async
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.withContext
 import javax.inject.Inject
 
-@SuppressLint("NotifyDataSetChanged")
+/**
+ * 兼职首页父布局
+ */
 @HiltViewModel
-class PartTimeMainViewModel @Inject constructor(
+class PartTimeMainViewModel  @Inject constructor(
     private val savedStateHandle: SavedStateHandle
 ) : BaseViewModel() {
 
-    val mKeywordLiveData = MutableLiveData<String>()  //搜索Key值
-    var mCurPage = 1
-    var isNeedPlaceHolder = true
-    var isNeedCleanAllData = true
-
-    var mNewsJobDataes = mutableListOf<String>()
-    val mNewJobAdapter by lazy { BaseDataBindingAdapter(R.layout.item_part_time_new_job, BR.item, mNewsJobDataes) }
-
-    var mAllJobDataes = mutableListOf<PartJobResult>()
-    val mAllJobAdapter by lazy { BaseDataBindingAdapter(R.layout.item_part_time_jobs, BR.item, mAllJobDataes) }
-
-    /**
-     * 获取兼职工作列表
-     */
-
-    fun requestJobList(): LiveData<Boolean> {
-        val liveData = MutableLiveData<Boolean>()
-
-        launchOnUI {
-            //开始Loading
-            if (isNeedPlaceHolder) loadStartLoading()
-
-
-            async {
-                if (mCurPage == 1) {
-                    mNewsJobDataes.clear()
-                    for (i in 1..5) {
-                        mNewsJobDataes.add(i.toString())
-                    }
-                }
-            }
-            mNewJobAdapter.notifyDataSetChanged()
-
-            val result = withContext(Dispatchers.IO) {
-                delay(1000)
-
-                val list = mutableListOf<PartJobResult>()
-                for (i in 1..10) {
-                    if (isNeedCleanAllData) {
-                        if (i == 4) list.add(PartJobResult().apply {
-                            type = 2
-                            groupDate = "2022-03-$mCurPage 星期二"
-                        })
-                    }
-                    list.add(PartJobResult().apply {
-                        type = 1
-                        groupDate = "2022-03-$mCurPage 星期二"
-                    })
-                }
-                return@withContext list
-            }
-
-            loadSuccess()
-            handleData(result)
-            liveData.postValue(true)
-
-            //返回的数据是封装过的,检查是否成功
-//            result.checkResult({
-//                loadSuccess()
-//                //成功
-//                handleData(it?.list)
-//                liveData.postValue(true)
-//            }, {
-//                //失败
-//                if (isNeedPlaceHolder) {
-//                    loadError(it)
-//                } else {
-//                    toast(it)
-//                }
-//                liveData.postValue(false)
-//            })
-        }
-
-        return liveData
-    }
-
-    //处理数据-添加或刷新
-    private fun handleData(list: List<PartJobResult>?) {
-        if (!list.checkEmpty()) {
-            //有数据,判断是刷新还是加载更多的数据
-            if (isNeedCleanAllData) {
-                //刷新的方式
-                mAllJobDataes.clear()
-                mAllJobDataes.addAll(list!!)
-                mAllJobAdapter.notifyDataSetChanged()
-            } else {
-                //加载更多
-                mAllJobDataes.addAll(list!!)
-                mAllJobAdapter.notifyItemRangeInserted(mAllJobDataes.size - list.size, list.size)
-                mAllJobAdapter.loadMoreModule.loadMoreComplete()
-            }
-        } else {
-            //展示无数据
-            if (isNeedCleanAllData && mCurPage == 1) {
-                mAllJobDataes.clear()
-                mAllJobDataes.add(PartJobResult())  //空视图
-                mAllJobAdapter.notifyDataSetChanged()
-                mAllJobAdapter.loadMoreModule.loadMoreEnd()
-            } else {
-                //如果是加载更多,展示加载完成,没有更多数据了
-                mAllJobAdapter.loadMoreModule.loadMoreEnd()
-            }
-        }
-        isNeedPlaceHolder = false
-        isNeedCleanAllData = false
-    }
-
-
 }

+ 2 - 2
cpt_parttime/src/main/java/com/hongyegroup/cpt_parttime/router/PartTimeComponentServiceImpl.kt

@@ -8,7 +8,7 @@ import com.guadou.cs_router.parttime.IParttimeComponentServer
 import com.guadou.lib_baselib.utils.log.YYLogUtils
 import com.hongyegroup.cpt_parttime.ui.main.JobActivesFragment
 import com.hongyegroup.cpt_parttime.ui.PartJobProfileFragment
-import com.hongyegroup.cpt_parttime.ui.main.PartTimeMainFragment
+import com.hongyegroup.cpt_parttime.ui.main.PartTimeHomeFragment
 
 @Route(path = ARouterPath.PATH_SERVICE_PARTTIME, name = "PartTime模块路由服务")
 class PartTimeComponentServiceImpl : IParttimeComponentServer {
@@ -18,7 +18,7 @@ class PartTimeComponentServiceImpl : IParttimeComponentServer {
     }
 
     override fun obtainPartTimeMainFragment(): Fragment {
-        return PartTimeMainFragment()
+        return PartTimeHomeFragment()
     }
 
     override fun obtainPartTimeActivesFragment(): Fragment {

+ 316 - 0
cpt_parttime/src/main/java/com/hongyegroup/cpt_parttime/ui/activity/PartTimeMainActivity.kt

@@ -0,0 +1,316 @@
+package com.hongyegroup.cpt_parttime.ui.activity
+
+import android.os.Bundle
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.FragmentManager
+import androidx.fragment.app.FragmentTransaction
+import com.alibaba.android.arouter.facade.annotation.Route
+import com.guadou.cs_cptservices.base.activity.YYBaseVDBActivity
+import com.guadou.cs_cptservices.interfaces.IFragmentRefresh
+import com.guadou.cs_router.ARouterPath
+import com.guadou.cs_router.YYRouterService
+import com.guadou.lib_baselib.bean.DataBindingConfig
+import com.guadou.lib_baselib.ext.commContext
+import com.guadou.lib_baselib.ext.gotoActivity
+import com.guadou.lib_baselib.utils.NetWorkUtil
+import com.guadou.lib_baselib.utils.StatusBarUtils
+import com.hongyegroup.cpt_parttime.R
+import com.hongyegroup.cpt_parttime.BR
+import com.hongyegroup.cpt_parttime.databinding.ActivityPartTimeMainBinding
+import com.hongyegroup.cpt_parttime.mvvm.PartTimeMainViewModel
+import dagger.hilt.android.AndroidEntryPoint
+
+/**
+ * 兼职首页Tab + Fragment
+ */
+@AndroidEntryPoint
+class PartTimeMainActivity : YYBaseVDBActivity<PartTimeMainViewModel, ActivityPartTimeMainBinding>() {
+
+    //首页的5个TabFragment
+    private var mHomeFragment: Fragment? = null
+    private var mEWalletFragment: Fragment? = null
+    private var mNewsFeedFragment: Fragment? = null
+    private var mProfileFragment: Fragment? = null
+    private var mCurPosition = 0  //当前Fragment选中的索引
+    private var mClickPage = 0  //当前Fragment选中的索引
+
+    companion object {
+        fun startInstance() {
+            commContext().gotoActivity<PartTimeMainActivity>()
+        }
+    }
+
+    override fun getDataBindingConfig(): DataBindingConfig {
+        return DataBindingConfig(R.layout.activity_part_time_main, BR.viewModel, mViewModel)
+            .addBindingParams(BR.click, ClickProxy())
+    }
+
+    override fun init(savedInstanceState: Bundle?) {
+        //沉浸式状态栏
+        StatusBarUtils.immersive(this)
+
+        if (savedInstanceState == null) {
+            initFragment()
+            //第一次初始化首页默认显示第一个fragment
+            switchFragment(mCurPosition)
+        } else {
+            // Activity因为内存不足的时候,这里进行Fragment恢复
+            restoreFragmentInstance(savedInstanceState)
+            // 因为内存原因Activity退到后天被kill,再打开的时候,会重新走onCreate
+            // 这时候恢复的Fragment默认恢复第一个
+            // 实际中这里可以根据需求进行修改
+            switchFragment(mCurPosition)
+        }
+    }
+
+    override fun startObserve() {
+
+    }
+
+    override fun needRegistNetworkChangeObserver(): Boolean = true
+
+    override fun onNetworkConnectionChanged(isConnected: Boolean, networkType: NetWorkUtil.NetworkType?) {
+        if (isConnected) {
+            when (mCurPosition) {
+                0 -> {
+                    mHomeFragment?.let {
+                        if (it is IFragmentRefresh) (it as IFragmentRefresh).scrollTopRefresh()
+                    }
+                }
+                1 -> {
+                    mEWalletFragment?.let {
+                        if (it is IFragmentRefresh) (it as IFragmentRefresh).scrollTopRefresh()
+                    }
+                }
+                2 -> {
+                    mNewsFeedFragment?.let {
+                        if (it is IFragmentRefresh) (it as IFragmentRefresh).scrollTopRefresh()
+                    }
+                }
+                3 -> {
+                    mProfileFragment?.let {
+                        if (it is IFragmentRefresh) (it as IFragmentRefresh).scrollTopRefresh()
+                    }
+                }
+            }
+        }
+    }
+
+    // ============================  Fragment begin ↓  =============================
+
+    //切换索引
+    fun switchFragment(index: Int) {
+        val targetFragment: Fragment?
+        val targetTag = index.toString()
+
+        when (index) {
+            0 -> {
+                targetFragment = mHomeFragment
+            }
+            1 -> {
+                targetFragment = mEWalletFragment
+            }
+            2 -> {
+                targetFragment = mNewsFeedFragment
+            }
+            3 -> {
+                targetFragment = mProfileFragment
+            }
+            else -> {
+                targetFragment = null
+            }
+        }
+
+        if (null == targetFragment) {
+            return
+        }
+
+        val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
+        // 先隐藏掉所有的Fragment
+        hideFragment(transaction)
+
+        // 在 show 操作
+        if (!targetFragment.isAdded) {
+            transaction.add(R.id.main_fragment_container, targetFragment, targetTag)
+            transaction.show(targetFragment)
+            transaction.commit()
+        } else {
+            transaction.show(targetFragment).commit()
+        }
+
+        mCurPosition = index
+
+        setBottomSelected(index)
+        setupStatusBarColor()
+    }
+
+    //设置或重置状态栏颜色
+    private fun setupStatusBarColor() {
+        //只有Profile页面变白色
+        when (mCurPosition) {
+            1, 3 -> setStatusBarWhiteText()
+            else -> setStatusBarBlackText()
+        }
+    }
+
+    // 隐藏 fragment
+    private fun hideFragment(transaction: FragmentTransaction) {
+        mHomeFragment?.let {
+            transaction.hide(it)
+        }
+        mEWalletFragment?.let {
+            transaction.hide(it)
+        }
+        mNewsFeedFragment?.let {
+            transaction.hide(it)
+        }
+        mProfileFragment?.let {
+            transaction.hide(it)
+        }
+    }
+
+    //底部Tab的选中效果
+    private fun setBottomSelected(position: Int) {
+
+        //传递进来的Position设置为选中:
+        when (position) {
+            0 -> {
+                mBinding.groupTabHome.isSelected = true
+                mBinding.groupTabWallet.isSelected = false
+                mBinding.groupTabNewsfeed.isSelected = false
+                mBinding.groupTabMe.isSelected = false
+            }
+            1 -> {
+                mBinding.groupTabHome.isSelected = false
+                mBinding.groupTabWallet.isSelected = true
+                mBinding.groupTabNewsfeed.isSelected = false
+                mBinding.groupTabMe.isSelected = false
+            }
+            2 -> {
+                mBinding.groupTabHome.isSelected = false
+                mBinding.groupTabWallet.isSelected = false
+                mBinding.groupTabNewsfeed.isSelected = true
+                mBinding.groupTabMe.isSelected = false
+            }
+            3 -> {
+                mBinding.groupTabHome.isSelected = false
+                mBinding.groupTabWallet.isSelected = false
+                mBinding.groupTabNewsfeed.isSelected = false
+                mBinding.groupTabMe.isSelected = true
+            }
+        }
+    }
+
+    /**
+     * 初始化Fragment
+     */
+    private fun initFragment() {
+        // 正常情况下初始化
+        mHomeFragment = HomeFragment()
+        mEWalletFragment = YYRouterService.eWalletComponentServer?.obtainEWalletMainFragment()
+        mNewsFeedFragment = YYRouterService.newsfeedComponentServer?.obtainNewsFeedMainFragment()
+        mProfileFragment = YYRouterService.parttimeComponentServer?.obtainPartTimeProfileFragment()
+    }
+
+    // activity的销毁标识
+    private var isHomeActDestroy = false
+    private val EXTRA_SAVE_INDEX = "SaveIndex"
+    private val EXTRA_IS_HOME_ACT_DESTROY = "isHomeActDestroy"
+
+    //恢复Fragment
+    private fun restoreFragmentInstance(savedInstanceState: Bundle?) {
+        if (savedInstanceState != null) {
+            mCurPosition = savedInstanceState.getInt(EXTRA_SAVE_INDEX, 0)
+            isHomeActDestroy = savedInstanceState.getBoolean(EXTRA_IS_HOME_ACT_DESTROY, false)
+
+            val manager: FragmentManager = supportFragmentManager
+            val f0 = manager.findFragmentByTag("0")
+            val f1 = manager.findFragmentByTag("1")
+            val f2 = manager.findFragmentByTag("2")
+            val f3 = manager.findFragmentByTag("3")
+
+            // 复用
+            mHomeFragment = f0 ?: HomeFragment()
+            mEWalletFragment = f1 ?: YYRouterService.eWalletComponentServer?.obtainEWalletMainFragment()
+            mNewsFeedFragment = f2 ?: YYRouterService.newsfeedComponentServer?.obtainNewsFeedMainFragment()
+            mProfileFragment = f3 ?: YYRouterService.parttimeComponentServer?.obtainPartTimeProfileFragment()
+        }
+    }
+
+    override fun onSaveInstanceState(outState: Bundle) {
+        hideFragment(supportFragmentManager.beginTransaction())
+        outState.putInt(EXTRA_SAVE_INDEX, mCurPosition)
+        outState.putBoolean(EXTRA_IS_HOME_ACT_DESTROY, true)
+        super.onSaveInstanceState(outState)
+    }
+
+    // ============================  Fragment end ↑  =============================
+
+    /**
+     * DataBinding事件处理
+     */
+    inner class ClickProxy {
+
+        fun switchHome() {
+            mClickPage = 0
+            if (mClickPage == mCurPosition) {
+                //重复点击
+                mHomeFragment?.let {
+                    if (it is IFragmentRefresh) (it as IFragmentRefresh).scrollTopRefresh()
+                }
+            } else {
+                switchFragment(0)
+            }
+        }
+
+        fun switchActive() {
+            mClickPage = 1
+            if (mClickPage == mCurPosition) {
+                //重复点击
+                mEWalletFragment?.let {
+                    if (it is IFragmentRefresh) (it as IFragmentRefresh).scrollTopRefresh()
+                }
+            } else {
+                switchFragment(1)
+            }
+        }
+
+        fun switchEWallet() {
+            mClickPage = 2
+            if (mClickPage == mCurPosition) {
+                //重复点击
+                mNewsFeedFragment?.let {
+                    if (it is IFragmentRefresh) (it as IFragmentRefresh).scrollTopRefresh()
+                }
+            } else {
+                switchFragment(2)
+            }
+        }
+
+        fun switchTrain() {
+            mClickPage = 2
+            if (mClickPage == mCurPosition) {
+                //重复点击
+                mNewsFeedFragment?.let {
+                    if (it is IFragmentRefresh) (it as IFragmentRefresh).scrollTopRefresh()
+                }
+            } else {
+                switchFragment(2)
+            }
+        }
+
+        //切换Me页面Tab
+        fun switchMe() {
+            mClickPage = 3
+            if (mClickPage == mCurPosition) {
+                //重复点击
+                mProfileFragment?.let {
+                    if (it is IFragmentRefresh) (it as IFragmentRefresh).scrollTopRefresh()
+                }
+            } else {
+                switchFragment(3)
+            }
+        }
+
+    }
+}

+ 2 - 2
cpt_parttime/src/main/java/com/hongyegroup/cpt_parttime/ui/main/PartTimeMainFragment.kt

@@ -20,7 +20,7 @@ import com.guadou.lib_baselib.view.gloading.GloadingPlaceHolderlAdapter
 import com.hongyegroup.cpt_parttime.BR
 import com.hongyegroup.cpt_parttime.R
 import com.hongyegroup.cpt_parttime.databinding.FragmentParttimeMainBinding
-import com.hongyegroup.cpt_parttime.mvvm.PartTimeMainViewModel
+import com.hongyegroup.cpt_parttime.mvvm.PartTimeHomeViewModel
 import com.hongyegroup.cpt_parttime.ui.activity.PartTimeJobDetailActivity
 import com.scwang.smart.refresh.layout.api.RefreshLayout
 import com.scwang.smart.refresh.layout.listener.OnRefreshListener
@@ -29,7 +29,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
 /**
  * 兼职模块的首页Frgment
  */
-class PartTimeMainFragment : YYBaseVDBLoadingFragment<PartTimeMainViewModel, FragmentParttimeMainBinding>(), IFragmentRefresh, OnRefreshListener,
+class PartTimeHomeFragment : YYBaseVDBLoadingFragment<PartTimeHomeViewModel, FragmentParttimeMainBinding>(), IFragmentRefresh, OnRefreshListener,
     OnLoadMoreListener {
 
     private var mTopDecoration: PowerfulStickyDecoration? = null

BIN
cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_active_blue.webp


BIN
cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_active_gray.webp


BIN
cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_job_blue.webp


BIN
cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_job_gray.webp


BIN
cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_me_blue.webp


BIN
cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_me_gray.webp


BIN
cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_train_blue.webp


BIN
cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_train_gray.webp


BIN
cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_wallet_blue.webp


BIN
cpt_parttime/src/main/res/drawable-xxhdpi/part_time_tab_wallet_gray.webp


+ 10 - 0
cpt_parttime/src/main/res/drawable/selector_part_time_tab_active.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:drawable="@drawable/part_time_tab_active_blue" android:state_pressed="true" />
+    <item android:drawable="@drawable/part_time_tab_active_blue" android:state_selected="true" />
+    <item android:drawable="@drawable/part_time_tab_active_blue" android:state_active="true" />
+    <item android:drawable="@drawable/part_time_tab_active_gray" android:state_selected="false" />
+    <item android:drawable="@drawable/part_time_tab_active_gray" android:state_active="false" />
+    <item android:drawable="@drawable/part_time_tab_active_gray" android:state_pressed="false" />
+</selector>

+ 10 - 0
cpt_parttime/src/main/res/drawable/selector_part_time_tab_job.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:drawable="@drawable/part_time_tab_job_blue" android:state_pressed="true" />
+    <item android:drawable="@drawable/part_time_tab_job_blue" android:state_selected="true" />
+    <item android:drawable="@drawable/part_time_tab_job_blue" android:state_active="true" />
+    <item android:drawable="@drawable/part_time_tab_job_gray" android:state_selected="false" />
+    <item android:drawable="@drawable/part_time_tab_job_gray" android:state_active="false" />
+    <item android:drawable="@drawable/part_time_tab_job_gray" android:state_pressed="false" />
+</selector>

+ 10 - 0
cpt_parttime/src/main/res/drawable/selector_part_time_tab_me.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:drawable="@drawable/part_time_tab_me_blue" android:state_pressed="true" />
+    <item android:drawable="@drawable/part_time_tab_me_blue" android:state_selected="true" />
+    <item android:drawable="@drawable/part_time_tab_me_blue" android:state_active="true" />
+    <item android:drawable="@drawable/part_time_tab_me_gray" android:state_selected="false" />
+    <item android:drawable="@drawable/part_time_tab_me_gray" android:state_active="false" />
+    <item android:drawable="@drawable/part_time_tab_me_gray" android:state_pressed="false" />
+</selector>

+ 10 - 0
cpt_parttime/src/main/res/drawable/selector_part_time_tab_train.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:drawable="@drawable/part_time_tab_train_blue" android:state_pressed="true" />
+    <item android:drawable="@drawable/part_time_tab_train_blue" android:state_selected="true" />
+    <item android:drawable="@drawable/part_time_tab_train_blue" android:state_active="true" />
+    <item android:drawable="@drawable/part_time_tab_train_gray" android:state_selected="false" />
+    <item android:drawable="@drawable/part_time_tab_train_gray" android:state_active="false" />
+    <item android:drawable="@drawable/part_time_tab_train_gray" android:state_pressed="false" />
+</selector>

+ 10 - 0
cpt_parttime/src/main/res/drawable/selector_part_time_tab_wallet.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:drawable="@drawable/part_time_tab_wallet_blue" android:state_pressed="true" />
+    <item android:drawable="@drawable/part_time_tab_wallet_blue" android:state_selected="true" />
+    <item android:drawable="@drawable/part_time_tab_wallet_blue" android:state_active="true" />
+    <item android:drawable="@drawable/part_time_tab_wallet_gray" android:state_selected="false" />
+    <item android:drawable="@drawable/part_time_tab_wallet_gray" android:state_active="false" />
+    <item android:drawable="@drawable/part_time_tab_wallet_gray" android:state_pressed="false" />
+</selector>

+ 172 - 0
cpt_parttime/src/main/res/layout/activity_part_time_main.xml

@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:binding="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:ignore="RtlHardcoded">
+
+    <data>
+
+        <variable
+            name="viewModel"
+            type="com.hongyegroup.cpt_parttime.mvvm.PartTimeMainViewModel" />
+
+        <variable
+            name="click"
+            type="com.hongyegroup.cpt_parttime.ui.activity.PartTimeMainActivity.ClickProxy" />
+
+    </data>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@color/white"
+        android:orientation="vertical">
+
+        <FrameLayout
+            android:id="@+id/main_fragment_container"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1" />
+
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/d_0.7dp"
+            android:layout_gravity="bottom"
+            android:background="@color/divider_color" />
+
+        <!-- 底部的Tab -->
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:background="@color/white"
+            android:gravity="center_vertical"
+            android:orientation="horizontal"
+            android:paddingTop="@dimen/d_3dp"
+            android:paddingBottom="@dimen/d_3dp">
+
+            <!--首页-->
+            <LinearLayout
+                style="@style/SelectableItemBackgroundLess"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:gravity="center"
+                android:onClick="@{() -> click.switchHome()}"
+                android:orientation="vertical">
+
+                <ImageView
+                    android:layout_width="@dimen/d_30dp"
+                    android:layout_height="@dimen/d_30dp"
+                    android:src="@drawable/selector_part_time_tab_job" />
+
+                <com.guadou.lib_baselib.font_text_view.TextViewMedium
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="兼职"
+                    android:textColor="@color/selector_tab_main_text"
+                    android:textSize="@dimen/d_12sp" />
+
+            </LinearLayout>
+
+            <!-- 工作状态 -->
+            <LinearLayout
+                style="@style/SelectableItemBackgroundLess"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:gravity="center"
+                android:onClick="@{() -> click.switchActive()}"
+                android:orientation="vertical">
+
+                <ImageView
+                    android:layout_width="@dimen/d_30dp"
+                    android:layout_height="@dimen/d_30dp"
+                    android:src="@drawable/selector_part_time_tab_active" />
+
+                <com.guadou.lib_baselib.font_text_view.TextViewMedium
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="工作状态"
+                    android:textColor="@color/selector_tab_main_text"
+                    android:textSize="@dimen/d_12sp" />
+
+            </LinearLayout>
+
+            <!--钱包-->
+            <LinearLayout
+                style="@style/SelectableItemBackgroundLess"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:gravity="center"
+                android:onClick="@{() -> click.switchEWallet()}"
+                android:orientation="vertical">
+
+                <ImageView
+                    android:layout_width="@dimen/d_30dp"
+                    android:layout_height="@dimen/d_30dp"
+                    android:src="@drawable/selector_part_time_tab_wallet" />
+
+                <com.guadou.lib_baselib.font_text_view.TextViewMedium
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="钱包"
+                    android:textColor="@color/selector_tab_main_text"
+                    android:textSize="@dimen/d_12sp" />
+
+            </LinearLayout>
+
+            <!-- 培训 -->
+            <LinearLayout
+                style="@style/SelectableItemBackgroundLess"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:gravity="center"
+                android:onClick="@{() -> click.switchTrain()}"
+                android:orientation="vertical">
+
+                <ImageView
+                    android:layout_width="@dimen/d_30dp"
+                    android:layout_height="@dimen/d_30dp"
+                    android:src="@drawable/selector_part_time_tab_train" />
+
+                <com.guadou.lib_baselib.font_text_view.TextViewMedium
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="培训"
+                    android:textColor="@color/selector_tab_main_text"
+                    android:textSize="@dimen/d_12sp" />
+
+            </LinearLayout>
+
+            <!-- 我的  -->
+            <LinearLayout
+                style="@style/SelectableItemBackgroundLess"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:gravity="center"
+                android:onClick="@{() -> click.switchMe()}"
+                android:orientation="vertical">
+
+                <ImageView
+                    android:layout_width="@dimen/d_30dp"
+                    android:layout_height="@dimen/d_30dp"
+                    android:src="@drawable/selector_part_time_tab_me" />
+
+                <com.guadou.lib_baselib.font_text_view.TextViewMedium
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="我的"
+                    android:textColor="@color/selector_tab_main_text"
+                    android:textSize="@dimen/d_12sp" />
+
+            </LinearLayout>
+
+        </LinearLayout>
+
+    </LinearLayout>
+
+</layout>

+ 2 - 2
cpt_parttime/src/main/res/layout/fragment_parttime_main.xml

@@ -9,11 +9,11 @@
 
         <variable
             name="viewModel"
-            type="com.hongyegroup.cpt_parttime.mvvm.PartTimeMainViewModel" />
+            type="com.hongyegroup.cpt_parttime.mvvm.PartTimeHomeViewModel" />
 
         <variable
             name="click"
-            type="com.hongyegroup.cpt_parttime.ui.main.PartTimeMainFragment.ClickProxy" />
+            type="com.hongyegroup.cpt_parttime.ui.main.PartTimeHomeFragment.ClickProxy" />
 
         <import type="android.text.TextUtils" />
 

+ 0 - 1
cs_baselib/src/main/java/com/guadou/lib_baselib/font_text_view/TypefaceUtil.java

@@ -20,5 +20,4 @@ public class TypefaceUtil {
         return Typeface.create("sans-serif-light", Typeface.BOLD);
     }
 
-
 }

+ 2 - 2
standalone/parttimerunalone/src/main/java/com/guadou/parttimerunalone/PartTimeMainActivity.kt

@@ -7,7 +7,7 @@ import com.guadou.lib_baselib.base.activity.BaseVMActivity
 import com.guadou.lib_baselib.base.vm.EmptyViewModel
 import com.guadou.lib_baselib.utils.CommUtils
 import com.guadou.lib_baselib.utils.StatusBarUtils
-import com.hongyegroup.cpt_parttime.ui.main.PartTimeMainFragment
+import com.hongyegroup.cpt_parttime.ui.main.PartTimeHomeFragment
 
 /**
  * 独立运行模块的兼职Fragment的页面载体
@@ -15,7 +15,7 @@ import com.hongyegroup.cpt_parttime.ui.main.PartTimeMainFragment
 class PartTimeMainActivity : BaseVMActivity<EmptyViewModel>() {
 
     private lateinit var mGroupTabPartTime: View
-    private val mPartTimeFragment by lazy { PartTimeMainFragment() }
+    private val mPartTimeFragment by lazy { PartTimeHomeFragment() }
 
     companion object {
         fun startInstance() {