[feat]工程列表接口及页面调整

main
chenglifeng 8 months ago
parent 6ad88e61ce
commit d22f5257c7
  1. 3
      app/build.gradle
  2. 2
      app/src/main/java/com/project/survey/network/Api.kt
  3. 73
      app/src/main/java/com/project/survey/ui/project/ProjectListActivity.kt
  4. 60
      app/src/main/java/com/project/survey/ui/project/ProjectListFragment.kt
  5. 27
      app/src/main/java/com/project/survey/ui/project/adapter/ProjectListAdapter.kt
  6. 10
      app/src/main/res/drawable/ic_project_all_selected.xml
  7. 0
      app/src/main/res/drawable/ic_project_all_unselected.xml
  8. 0
      app/src/main/res/drawable/ic_project_recently_selected.xml
  9. 10
      app/src/main/res/drawable/ic_project_recently_unselected.xml
  10. 10
      app/src/main/res/drawable/icon_toolbar_exit.xml
  11. 11
      app/src/main/res/layout/activity_project_list.xml
  12. 90
      app/src/main/res/layout/item_project_list.xml
  13. 2
      app/src/main/res/layout/toolbar.xml
  14. 8
      app/src/main/res/menu/menu_activity_project_list.xml
  15. 1
      app/src/main/res/values/strings.xml
  16. 4
      app/src/main/res/values/styles.xml

@ -194,6 +194,7 @@ dependencies {
implementation 'net.sourceforge.jexcelapi:jxl:2.6.12'
// MMKVhttps://github.com/Tencent/MMKV
implementation 'com.tencent:mmkv:1.3.9'
// BRVAH https://github.com/CymChad/BaseRecyclerViewAdapterHelper/wiki
implementation "io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4"
}

@ -16,7 +16,7 @@ interface Api {
): HttpResult<String>
/**
* 获取用户在工作的所以项目的信息
* 获取用户可访问的所有项目的信息
*/
@GET("/je/project/getAllProjectIDByAccount")
suspend fun getAllProjectIDByAccount(

@ -1,51 +1,76 @@
package com.project.survey.ui.project
import android.view.Menu
import android.view.MenuItem
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.bingce.ui.TabEntity
import com.flyco.tablayout.listener.CustomTabEntity
import com.gyf.immersionbar.ImmersionBar
import com.project.survey.R
import com.project.survey.ui.base.BaseBindingActivity
import com.project.survey.databinding.ActivityProjectListBinding
import com.project.survey.util.ActivityNavUtil
class ProjectListActivity : BaseBindingActivity<ActivityProjectListBinding>() {
override fun getBinding(): ActivityProjectListBinding {
return ActivityProjectListBinding.inflate(layoutInflater)
companion object {
fun start() {
ActivityNavUtil.startActivity<ProjectListActivity> { }
}
}
override fun getBinding(): ActivityProjectListBinding =
ActivityProjectListBinding.inflate(layoutInflater)
override fun initView() {
ImmersionBar.with(this)
.statusBarDarkFont(true)
.titleBarMarginTop(mBinding.ilToolBar.toolbar)
.init()
setSupportActionBar(mBinding.ilToolBar.toolbar)
mBinding.ilToolBar.toolbar.setBackgroundColor(0)
mBinding.ilToolBar.toolbar.setTitle("项目列表")
mBinding.ilToolBar.toolbar.setTitleTextColor(ContextCompat.getColor(this, R.color.text_color_main))
initTabLayout()
}
override fun initData() {
}
private fun initTabLayout() {
val mTabEntities = ArrayList<CustomTabEntity>()
mTabEntities.add(
TabEntity(
"最近打开",
R.drawable.ic_project_recently,
R.drawable.ic_project_recently
)
)
mTabEntities.add(
TabEntity(
"全部",
R.drawable.ic_project_all,
R.drawable.ic_project_all
mBinding.tabLayout.setTabData(
arrayListOf(
TabEntity(
"最近打开",
R.drawable.ic_project_recently_selected,
R.drawable.ic_project_recently_unselected
),
TabEntity(
"全部",
R.drawable.ic_project_all_selected,
R.drawable.ic_project_all_unselected
)
),
this,
R.id.container,
arrayListOf(
ProjectListFragment.newInstance(ProjectListFragment.TYPE_RECENTLY),
ProjectListFragment.newInstance(ProjectListFragment.TYPE_ALL)
)
)
val fragmentList = ArrayList<Fragment>()
fragmentList.add(ProjectListFragment.newInstance(ProjectListFragment.TYPE_RECENTLY))
fragmentList.add(ProjectListFragment.newInstance(ProjectListFragment.TYPE_ALL))
mBinding.tabLayout.setTabData(mTabEntities, this, R.id.container, fragmentList)
}
override fun initData() {
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_activity_project_list, menu)
return super.onCreateOptionsMenu(menu)
}
companion object {
fun start(){
ActivityNavUtil.startActivity<ProjectListActivity> { }
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.menu_activity_project_list_exit) {
finish()
}
return super.onOptionsItemSelected(item)
}
}

@ -4,63 +4,55 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import com.project.survey.adapter.ProjectListAdapter
import androidx.fragment.app.viewModels
import com.project.survey.constants.SPConstants
import com.project.survey.databinding.FragmentProjectListBinding
import com.project.survey.ui.base.BaseFragmentBinding
import com.project.survey.model.ProjectBean
import com.project.survey.logic.viewmodel.ProjectViewModel
import com.project.survey.ui.base.BaseBindingFragment
import com.project.survey.ui.project.adapter.ProjectListAdapter
import com.project.survey.util.SPUtils
import com.project.survey.util.param.Param
import com.project.survey.widget.decoration.HorDividerDecoration
class ProjectListFragment : BaseFragmentBinding<FragmentProjectListBinding>() {
private val adapter by lazy { ProjectListAdapter(requireContext()) }
class ProjectListFragment : BaseBindingFragment<FragmentProjectListBinding>() {
companion object {
const val TYPE_RECENTLY = "1"
const val TYPE_ALL = "2"
const val KEY_TYPE = "KEY_TYPE"
fun newInstance(type: String): Fragment {
val fragment = ProjectListFragment()
fragment.arguments = bundleOf(
KEY_TYPE to type
)
return fragment
return ProjectListFragment().apply {
arguments = bundleOf("type" to type)
}
}
}
override fun getViewBinding(
override fun getBinding(
inflater: LayoutInflater,
container: ViewGroup?
): FragmentProjectListBinding {
return FragmentProjectListBinding.inflate(inflater, container, false)
}
): FragmentProjectListBinding = FragmentProjectListBinding.inflate(inflater, container, false)
private val viewModel: ProjectViewModel by viewModels()
private val adapter by lazy { ProjectListAdapter() }
@Param
private lateinit var type: String
override fun initView() {
initAdapter()
binding.recyclerView.addItemDecoration(HorDividerDecoration(mContext))
binding.recyclerView.setAdapter(adapter)
}
override fun initData() {
val type = getArgumentString(KEY_TYPE)
val num = if (type == TYPE_RECENTLY) {
3
} else {
6
viewModel.projectResponse.observe(this) {
adapter.submitList(it)
}
val dataList = mutableListOf<ProjectBean>()
for (i in 0 until num) {
dataList.add(ProjectBean("",""))
}
adapter.refreshData(dataList)
viewModel.getAllProjectIDByAccount(SPUtils.getString(SPConstants.ACCOUNT) ?: "")
}
private fun initAdapter() {
mBinding.recyclerView.addItemDecoration(HorDividerDecoration(requireContext()))
adapter.setOnItemClickListener {
override fun initListener() {
}
mBinding.recyclerView.setAdapter(adapter)
}
}

@ -0,0 +1,27 @@
package com.project.survey.ui.project.adapter
import android.content.Context
import android.view.ViewGroup
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.project.survey.R
import com.project.survey.model.ProjectBean
class ProjectListAdapter : BaseQuickAdapter<ProjectBean, QuickViewHolder>() {
override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: ProjectBean?) {
item?.let { bean ->
holder.setText(R.id.tvProjectName, bean.XMXX_INDUSTRYTYPE)
.setText(R.id.tvProjectNum, bean.XMXX_PILENO)
.setText(R.id.tvProjectArea, "上海市长宁区")
}
}
override fun onCreateViewHolder(
context: Context,
parent: ViewGroup,
viewType: Int
): QuickViewHolder {
return QuickViewHolder(R.layout.item_project_list, parent)
}
}

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16.5dp"
android:height="16.5dp"
android:viewportWidth="16.5"
android:viewportHeight="16.5">
<path
android:pathData="M0,0L7.333,0L7.333,9.167L0,9.167L0,0ZM9.167,0L16.5,0L16.5,5.5L9.167,5.5L9.167,0ZM5.5,7.333L5.5,1.833L1.833,1.833L1.833,7.333L5.5,7.333ZM14.667,3.667L14.667,1.833L11,1.833L11,3.667L14.667,3.667ZM9.167,7.333L16.5,7.333L16.5,16.5L9.167,16.5L9.167,7.333ZM14.667,14.667L14.667,9.167L11,9.167L11,14.667L14.667,14.667ZM0,11L7.333,11L7.333,16.5L0,16.5L0,11ZM5.5,14.667L5.5,12.833L1.833,12.833L1.833,14.667L5.5,14.667Z"
android:fillColor="#396BD0"
android:fillType="evenOdd"/>
</vector>

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18.333dp"
android:height="18.333dp"
android:viewportWidth="18.333"
android:viewportHeight="18.333">
<path
android:pathData="M9.167,0C4.125,0 0,4.125 0,9.167C0,14.208 4.125,18.333 9.167,18.333C14.208,18.333 18.333,14.208 18.333,9.167C18.333,4.125 14.208,0 9.167,0ZM1.833,9.167C1.833,13.209 5.124,16.5 9.167,16.5C13.209,16.5 16.5,13.209 16.5,9.167C16.5,5.124 13.209,1.833 9.167,1.833C5.124,1.833 1.833,5.124 1.833,9.167ZM9.625,4.583L8.25,4.583L8.25,10.083L13.017,13.017L13.75,11.825L9.625,9.35L9.625,4.583Z"
android:fillColor="#5B5A5E"
android:fillType="evenOdd"/>
</vector>

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M8,3.333L2.667,3.333L2.667,12.667L8,12.667L8,14L2.667,14C1.933,14 1.333,13.4 1.333,12.667L1.333,3.333C1.333,2.6 1.933,2 2.667,2L8,2L8,3.333ZM10.393,5.607L11.333,4.667L14.667,8L11.333,11.333L10.393,10.387L12.113,8.667L5.333,8.667L5.333,7.333L12.113,7.333L10.393,5.607Z"
android:fillColor="#396BD0"
android:fillType="evenOdd"/>
</vector>

@ -21,16 +21,15 @@
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="54dp"
android:background="#ffffff"
android:background="@color/bg_color_main_tab"
tl:tl_iconHeight="23dp"
tl:tl_iconWidth="23dp"
tl:tl_indicator_color="#3498db"
tl:tl_indicator_height="0dp"
tl:tl_textSelectColor="#3498db"
tl:tl_textUnselectColor="#666666"
tl:tl_textSelectColor="@color/text_color_tab_selected"
tl:tl_textUnselectColor="@color/text_color_tab_unselected"
tl:tl_textsize="12sp"
tl:tl_underline_color="#cfcfcf"
tl:tl_underline_color="@color/bg_color_main_underline_color"
tl:tl_underline_gravity="TOP"
tl:tl_underline_height="1dp" />
tl:tl_underline_height="0.5dp" />
</LinearLayout>

@ -1,57 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingVertical="@dimen/sw_18dp">
android:paddingVertical="18dp">
<ImageView
android:id="@+id/ivIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_project_list" />
android:src="@drawable/ic_project_list"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="match_parent"
<TextView
android:id="@+id/tvProjectName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/sw_14dp"
android:orientation="vertical">
<TextView
android:id="@+id/tvProjectName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_color_1"
android:textSize="@dimen/sw_15sp"
android:textStyle="bold"
android:text="xx工程" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/sw_3dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tvProjectNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_color_2"
android:textSize="@dimen/sw_11sp"
android:text="XMBH2021-00001" />
<TextView
android:id="@+id/tvProjectArea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_color_2"
android:textSize="@dimen/sw_11sp"
android:text="上海市长宁区" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
android:layout_marginStart="14dp"
android:textColor="@color/text_color_20"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintStart_toEndOf="@id/ivIcon"
app:layout_constraintTop_toTopOf="parent"
tools:text="xx工程" />
<TextView
android:id="@+id/tvProjectNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginTop="3dp"
android:textColor="@color/text_color_727778"
android:textSize="12sp"
app:layout_constraintStart_toEndOf="@id/ivIcon"
app:layout_constraintTop_toBottomOf="@id/tvProjectName"
tools:text="XMBH2021-00001" />
<TextView
android:id="@+id/tvProjectArea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_color_727778"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@id/tvProjectNum"
app:layout_constraintStart_toEndOf="@id/tvProjectNum"
app:layout_constraintTop_toTopOf="@id/tvProjectNum"
tools:text="上海市长宁区" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="?actionBarSize"
android:background="?colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

@ -0,0 +1,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_activity_project_list_exit"
android:icon="@drawable/icon_toolbar_exit"
app:showAsAction="withText|always"
android:title="@string/exit"/>
</menu>

@ -343,5 +343,6 @@
<string name="tab_home_page">首页</string>
<string name="tab_instrument">仪器</string>
<string name="tab_mine">我的</string>
<string name="exit">退出</string>
</resources>

@ -119,4 +119,8 @@
<attr name="behavior_fitToContents" format="boolean" />
</declare-styleable>
<style name="ToolbarTextAppearance" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textSize">15sp</item>
</style>
</resources>

Loading…
Cancel
Save