From ed27d3482784e0345223b3aaa24f52af3ea80d7d Mon Sep 17 00:00:00 2001 From: tongchenfei Date: Mon, 7 Sep 2020 17:10:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=88=86=E4=BA=AB=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E6=A1=86=E5=8A=A8=E6=80=81=E6=B7=BB=E5=8A=A0=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=BE=85=E6=8E=A5=E5=85=A5=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- .../mogo/module/share/bean/FixableButton.kt | 2 +- .../share/dialog/GridFixableShareDialog.kt | 5 +++- .../module/share/manager/GridBtnManager.kt | 30 +++++++++++++++---- .../layout/dialog_share_with_gridlayout.xml | 16 ++++++---- .../src/main/res/layout/item_share_btn.xml | 23 +++++++++----- .../src/main/res/values-xhdpi/dimens.xml | 10 +++++++ .../src/main/res/values/dimens.xml | 10 +++++++ .../service/tanlu/IMogoTanluProvider.java | 5 ++++ 9 files changed, 82 insertions(+), 21 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 21e99e2dc0..cd77a1f062 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/FixableButton.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/FixableButton.kt index b22ee55ad4..e52d73c420 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/FixableButton.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/bean/FixableButton.kt @@ -6,4 +6,4 @@ import com.mogo.module.share.R * 可配置按钮封装 * @author tongchenfei */ -data class FixableButton(val id:Int = 0,val iconUrl:String = "", val iconRes:Int = R.drawable.share_block_up, val content:String="拥堵") \ No newline at end of file +data class FixableButton(val id:Int = 0,val poiType:String = "10007",val iconUrl:String = "", val iconRes:Int = R.drawable.share_block_up, val content:String="拥堵") \ No newline at end of file diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/GridFixableShareDialog.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/GridFixableShareDialog.kt index 5fc8567b5d..f2b146fded 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/GridFixableShareDialog.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/dialog/GridFixableShareDialog.kt @@ -1,6 +1,7 @@ package com.mogo.module.share.dialog import android.content.Context +import android.widget.FrameLayout import android.widget.GridLayout import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -65,7 +66,9 @@ class GridFixableShareDialog(context:Context):BaseFloatDialog(context) { Logger.d(TAG, "share btn click: $it") randomGenerateBtn() } - randomGenerateBtn() + findViewById(R.id.flShareDialogContainer).setOnClickListener { dismiss() } + + gridBtnManager.showDefaultBtns() } private fun randomGenerateBtn(){ diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/GridBtnManager.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/GridBtnManager.kt index cbebfd609d..65dd00d2da 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/GridBtnManager.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/GridBtnManager.kt @@ -9,23 +9,29 @@ import android.widget.ImageView import android.widget.TextView import com.mogo.module.share.R import com.mogo.module.share.bean.FixableButton +import com.mogo.service.tanlu.IMogoTanluProvider import com.mogo.utils.glide.GlideApp /** * 用来管理生成对应的分享按钮 */ -class GridBtnManager(val context:Context,val container:GridLayout) { +class GridBtnManager(val context: Context, val container: GridLayout) { private val inflater = LayoutInflater.from(context) - fun resetContainer(){ + fun resetContainer() { container.removeAllViews() } fun generateShareButton(button: FixableButton): View { - val view = inflater.inflate(R.layout.item_share_btn, container,false ) + val view = inflater.inflate(R.layout.item_share_btn, container, false) val img = view.findViewById(R.id.ivShareIcon) val content = view.findViewById(R.id.tvShareContent) - GlideApp.with(context).load(button.iconRes).into(img) + // 优先加载url图片,然后加载资源图片 + if (button.iconUrl.isNotEmpty()) { + GlideApp.with(context).load(button.iconUrl).centerInside().into(img) + } else { + GlideApp.with(context).load(button.iconRes).centerInside().into(img) + } content.text = button.content view.setOnClickListener { btnClickListener?.invoke(button) @@ -34,7 +40,21 @@ class GridBtnManager(val context:Context,val container:GridLayout) { return view } - private var btnClickListener:((fixableButton:FixableButton)->Unit)? =null + fun showDefaultBtns() { + resetContainer() + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_BLOCK, iconRes = R.drawable.share_block_up, content = "拥堵")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_TRAFFIC_CHECK, iconRes = R.drawable.share_traffic_check, content = "交通检查")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_CLOSURE, iconRes = R.drawable.share_road_closure, content = "封路")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ACCIDENT, iconRes = R.drawable.share_accident, content = "事故")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ROAD_CONSTRUCTION, iconRes = R.drawable.share_road_construction, content = "道路施工")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_REAL_TIME_TRAFFIC, iconRes = R.drawable.share_real_time_traffic, content = "实时路况")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_SEEK_HELP, iconRes = R.drawable.share_seek_help, content = "故障求助")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_STAGNANT_WATER, iconRes = R.drawable.share_stagnant_water, content = "道路积水")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ROAD_ICY, iconRes = R.drawable.share_road_icy, content = "道路结冰")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_DENSE_FOG, iconRes = R.drawable.share_dense_fog, content = "浓雾")) + } + + private var btnClickListener: ((fixableButton: FixableButton) -> Unit)? = null fun setShareClickListener(listener: ((fixableButton: FixableButton) -> Unit)) { btnClickListener = listener } diff --git a/modules/mogo-module-share/src/main/res/layout/dialog_share_with_gridlayout.xml b/modules/mogo-module-share/src/main/res/layout/dialog_share_with_gridlayout.xml index 061b149f08..b428cc73eb 100644 --- a/modules/mogo-module-share/src/main/res/layout/dialog_share_with_gridlayout.xml +++ b/modules/mogo-module-share/src/main/res/layout/dialog_share_with_gridlayout.xml @@ -1,18 +1,18 @@ + android:orientation="vertical"> + android:paddingLeft="@dimen/module_share_container_padding_left" + android:paddingRight="@dimen/module_share_container_padding_right" /> + \ No newline at end of file diff --git a/modules/mogo-module-share/src/main/res/layout/item_share_btn.xml b/modules/mogo-module-share/src/main/res/layout/item_share_btn.xml index d17fe7fc18..8ae0f36968 100644 --- a/modules/mogo-module-share/src/main/res/layout/item_share_btn.xml +++ b/modules/mogo-module-share/src/main/res/layout/item_share_btn.xml @@ -3,22 +3,31 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" - android:orientation="vertical"> + android:orientation="vertical" + android:paddingLeft="@dimen/module_share_btn_margin_left" + android:paddingTop="@dimen/module_share_btn_margin_top"> + + + + + - 28px 32px + 114px + 83px + 6px + 123px + 110px + + 75px + 165px + 967px + diff --git a/modules/mogo-module-share/src/main/res/values/dimens.xml b/modules/mogo-module-share/src/main/res/values/dimens.xml index de5262bd89..044d40bc47 100644 --- a/modules/mogo-module-share/src/main/res/values/dimens.xml +++ b/modules/mogo-module-share/src/main/res/values/dimens.xml @@ -22,4 +22,14 @@ 15px 17.5px + 60px + 44px + 5px + 65px + 58px + + 40px + 89px + 514px + \ No newline at end of file diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/IMogoTanluProvider.java b/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/IMogoTanluProvider.java index 2ea236564c..20c64855e3 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/IMogoTanluProvider.java +++ b/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/IMogoTanluProvider.java @@ -45,6 +45,11 @@ public interface IMogoTanluProvider extends IProvider { */ String TYPE_ROAD_CONSTRUCTION = "10006"; + /** + * 故障求助 + */ + String TYPE_SEEK_HELP = "99999"; + /** * 用户手点上报 */