diff --git a/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/adapter/GeoPointMultiAdapter.kt b/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/adapter/GeoPointMultiAdapter.kt index d8b6880..be9bdaa 100644 --- a/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/adapter/GeoPointMultiAdapter.kt +++ b/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/adapter/GeoPointMultiAdapter.kt @@ -84,18 +84,8 @@ class GeoPointMultiAdapter(list: MutableList) : private fun loadBaseInfo(holder: BaseViewHolder, item: GeoPointMultiItem) { val llBaseTop = holder.itemView.findViewById(R.id.llBaseTop) - val topList = mutableListOf( - BaseItem(name = "点号", value = ""), - BaseItem(name = "点距", value = ""), - BaseItem(name = "累距", value = ""), - ) - val bottomList = mutableListOf( - BaseItem(name = "巷高", value = ""), - BaseItem(name = "顶板", value = ""), - BaseItem(name = "底板", value = ""), - BaseItem(name = "巷顶煤厚", value = ""), - ) - topList.forEach { + llBaseTop.removeAllViews() + item.baseTopList?.forEach { val itemBinding = ListItemPointBaseHorizontalBinding.inflate( LayoutInflater.from(context), llBaseTop, @@ -107,9 +97,10 @@ class GeoPointMultiAdapter(list: MutableList) : } llBaseTop.addView(itemBinding.root) } - val llBaseBottom = holder.itemView.findViewById(R.id.llBaseBottom) - bottomList.forEachIndexed { index, it -> + val llBaseBottom = holder.itemView.findViewById(R.id.llBaseBottom) + llBaseBottom.removeAllViews() + item.baseBottomList?.forEachIndexed { index, it -> val itemBinding = ListItemPointBaseVerticalBinding.inflate( LayoutInflater.from(context), llBaseBottom, @@ -119,13 +110,13 @@ class GeoPointMultiAdapter(list: MutableList) : tvItemName.text = it.name etInputValue.setText(it.value) dividerVertical.run { - if (index == bottomList.size - 1) gone() else visible() + if (index == item.baseBottomList!!.size - 1) gone() else visible() } } itemBinding.root.updateLayoutParams { width = 0 height = LinearLayout.LayoutParams.MATCH_PARENT - weight = if (index == bottomList.size - 1) 1.24F else 1.0F + weight = if (index == item.baseBottomList!!.size - 1) 1.24F else 1.0F } llBaseBottom.addView(itemBinding.root) } diff --git a/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/bean/OtherData.kt b/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/bean/OtherData.kt index 319fc5b..8ff5222 100644 --- a/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/bean/OtherData.kt +++ b/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/bean/OtherData.kt @@ -63,6 +63,8 @@ data class GeoPointMultiItem( var pointName: String = "", var pointDistance: String = "", var totalDistance: String = "", + var baseTopList: MutableList?=null, + var baseBottomList: MutableList?=null, var images: MutableList?=null ): MultiItemEntity { companion object { diff --git a/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/ui/geologging/AddGeologicalPointActivity.kt b/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/ui/geologging/AddGeologicalPointActivity.kt index eb55ae5..5fb4256 100644 --- a/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/ui/geologging/AddGeologicalPointActivity.kt +++ b/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/ui/geologging/AddGeologicalPointActivity.kt @@ -42,13 +42,6 @@ class AddGeologicalPointActivity : // mBinding.toolbarLay.rightText = "新增工作面" initFragments() - //switchFragment(0) - - supportFragmentManager.commit { - setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out) - show(fragments[0]) - setReorderingAllowed(true) - } initMagicIndicator() showFragment(0) } @@ -63,30 +56,21 @@ class AddGeologicalPointActivity : } - private val fragments = mutableListOf() + private val fragments = mutableListOf() private fun initFragments() { - titles.forEach { _ -> - fragments.add(AddGeologicalPointFragment()) - } -// supportFragmentManager.commit { -//// add(R.id.fragment_container, fragments[0], "volume").hide(fragments[0]) + titles.forEachIndexed { index, string -> + val fragment = AddGeologicalPointFragment() + fragments.add(fragment) + supportFragmentManager.commit { + add(R.id.frgContainerView, fragment, "frg_${index}").hide(fragment) // replace(R.id.frgContainerView, fragments[0], "point01") -// } + } + } } -// private fun switchFragment(position: Int) { -// supportFragmentManager.commit { -// setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out) -// fragments.forEachIndexed { index, fragment -> -// if (index == position) show(fragment) else hide(fragment) -// } -// setReorderingAllowed(true) -// } -// } - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) - fragments[0].onActivityResult(requestCode, resultCode, data) + fragments[showFrgIndex].onActivityResult(requestCode, resultCode, data) } private val titles = listOf("1#", "2#", "3#", "4#", "5#", "6#") @@ -96,12 +80,6 @@ class AddGeologicalPointActivity : override fun getCount() = titles.size override fun getTitleView(context: Context?, index: Int): IPagerTitleView { return ColorTransitionPagerTitleView(context).apply { -// setPadding( -// if (index == 0) 20.dp else 10.dp, -// 10.dp, -// if (index == titles.size - 1) 20.dp else 10.dp, -// 10.dp -// ) // setPadding(10.dp, 5.dp,10.dp, 5.dp) width = 65.dp text = titles[index] @@ -114,13 +92,6 @@ class AddGeologicalPointActivity : strokeColor = "#0C0D0E".toColorInt(), strokeWidth = 8.dp ) -// showToast(parent.javaClass.simpleName) -// updateLayoutParams { -// topMargin = 10.dp -// bottomMargin = 10.dp -// leftMargin = if (index == 0) 20.dp else 10.dp -// rightMargin = if (index == titles.size - 1) 20.dp else 10.dp -// } setOnClickListener { showFragment(index) } } } @@ -147,11 +118,20 @@ class AddGeologicalPointActivity : private lateinit var fragmentContainerHelper:FragmentContainerHelper + private var showFrgIndex = 0 private fun showFragment(position: Int) { - supportFragmentManager.beginTransaction() - .replace(R.id.frgContainerView, fragments[position]) - .commit() + showFrgIndex = position +// supportFragmentManager.beginTransaction() +// .replace(R.id.frgContainerView, fragments[position]) +// .commit() fragmentContainerHelper.handlePageSelected(position) + supportFragmentManager.commit { + setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out) + fragments.forEachIndexed { index, fragment -> + if (index == position) show(fragment) else hide(fragment) + } + setReorderingAllowed(true) + } } } \ No newline at end of file diff --git a/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/ui/geologging/AddGeologicalPointFragment.kt b/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/ui/geologging/AddGeologicalPointFragment.kt index d6311b0..64d85c1 100644 --- a/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/ui/geologging/AddGeologicalPointFragment.kt +++ b/coalMiningApp/app/src/main/java/com/zmkg/coaloperation/ui/geologging/AddGeologicalPointFragment.kt @@ -10,6 +10,7 @@ import com.zmkg.coaloperation.R import com.zmkg.coaloperation.adapter.GeoPointMultiAdapter import com.zmkg.coaloperation.base.BaseVMBFragment import com.zmkg.coaloperation.base.viewmodel.TestViewModel +import com.zmkg.coaloperation.bean.BaseItem import com.zmkg.coaloperation.bean.GeoPointImage import com.zmkg.coaloperation.bean.GeoPointMultiItem import com.zmkg.coaloperation.databinding.FragmentAddGeologicalPointBinding @@ -27,10 +28,28 @@ class AddGeologicalPointFragment : } override fun initView(root: View?, savedInstanceState: Bundle?) { + geoPointList.clear() + val topList = mutableListOf( + BaseItem(name = "点号", value = ""), + BaseItem(name = "点距", value = ""), + BaseItem(name = "累距", value = ""), + ) + val bottomList = mutableListOf( + BaseItem(name = "巷高", value = ""), + BaseItem(name = "顶板", value = ""), + BaseItem(name = "底板", value = ""), + BaseItem(name = "巷顶煤厚", value = ""), + ) val imageList = mutableListOf() imageList.add(GeoPointImage(isAddFlag = true)) geoPointList.run { - add(GeoPointMultiItem(itemType = GeoPointMultiItem.TYPE_BASE_INFO)) + add( + GeoPointMultiItem( + itemType = GeoPointMultiItem.TYPE_BASE_INFO, + baseTopList = topList, + baseBottomList = bottomList + ) + ) add(GeoPointMultiItem(itemType = GeoPointMultiItem.TYPE_LOGGING_INFO)) add(GeoPointMultiItem(itemType = GeoPointMultiItem.TYPE_CALCULATE_INFO)) add(