完成分享对话框动态添加的功能,待接入服务端

This commit is contained in:
tongchenfei
2020-09-07 17:10:13 +08:00
parent fd8803ddcd
commit ed27d34827
9 changed files with 82 additions and 21 deletions

2
.idea/misc.xml generated
View File

@@ -4,7 +4,7 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
</project>

View File

@@ -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="拥堵")
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="拥堵")

View File

@@ -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<FrameLayout>(R.id.flShareDialogContainer).setOnClickListener { dismiss() }
gridBtnManager.showDefaultBtns()
}
private fun randomGenerateBtn(){

View File

@@ -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<ImageView>(R.id.ivShareIcon)
val content = view.findViewById<TextView>(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
}

View File

@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/flShareDialogContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="@dimen/share_module_height"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:minWidth="@dimen/module_share_container_min_width"
android:background="@drawable/module_share_dialog_bg"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="65px"
android:paddingRight="65px"
android:paddingBottom="58px">
android:orientation="vertical">
<TextView
android:id="@+id/btn_share_title"
@@ -31,8 +31,12 @@
android:id="@+id/moduleShareBtnGridLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/module_share_container_padding_bottom"
android:clickable="true"
android:columnCount="5"
android:layout_marginTop="44px" />
android:paddingLeft="@dimen/module_share_container_padding_left"
android:paddingRight="@dimen/module_share_container_padding_right" />
</LinearLayout>
</FrameLayout>

View File

@@ -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">
<FrameLayout
android:layout_width="@dimen/module_share_icon_bg_width"
android:layout_height="@dimen/module_share_icon_bg_width"
android:background="@drawable/module_share_btn_bg">
<ImageView
android:id="@+id/ivShareIcon"
android:layout_width="@dimen/module_share_icon_width"
android:layout_height="@dimen/module_share_icon_width"
android:layout_gravity="center" />
</FrameLayout>
<ImageView
android:layout_width="@dimen/dp_160"
android:layout_height="@dimen/dp_160"
android:id="@+id/ivShareIcon"
android:src="@drawable/share_road_closure" />
<Space
android:layout_width="wrap_content"
android:layout_height="@dimen/share_module_tv_margin_top" />
<TextView
android:id="@+id/tvShareContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvShareContent"
android:text="上报拥堵"
android:textColor="@color/module_share_dialog_icon_text_color"
android:textSize="@dimen/share_module_item"

View File

@@ -21,6 +21,16 @@
<dimen name="share_module_bottom_size">28px</dimen>
<dimen name="share_module_btn_text_size">32px</dimen>
<dimen name="module_share_btn_margin_left">114px</dimen>
<dimen name="module_share_btn_margin_top">83px</dimen>
<dimen name="module_share_container_padding_left">6px</dimen>
<dimen name="module_share_container_padding_right">123px</dimen>
<dimen name="module_share_container_padding_bottom">110px</dimen>
<dimen name="module_share_icon_width">75px</dimen>
<dimen name="module_share_icon_bg_width">165px</dimen>
<dimen name="module_share_container_min_width">967px</dimen>
</resources>

View File

@@ -22,4 +22,14 @@
<dimen name="share_module_bottom_size">15px</dimen>
<dimen name="share_module_btn_text_size">17.5px</dimen>
<dimen name="module_share_btn_margin_left">60px</dimen>
<dimen name="module_share_btn_margin_top">44px</dimen>
<dimen name="module_share_container_padding_left">5px</dimen>
<dimen name="module_share_container_padding_right">65px</dimen>
<dimen name="module_share_container_padding_bottom">58px</dimen>
<dimen name="module_share_icon_width">40px</dimen>
<dimen name="module_share_icon_bg_width">89px</dimen>
<dimen name="module_share_container_min_width">514px</dimen>
</resources>

View File

@@ -45,6 +45,11 @@ public interface IMogoTanluProvider extends IProvider {
*/
String TYPE_ROAD_CONSTRUCTION = "10006";
/**
* 故障求助
*/
String TYPE_SEEK_HELP = "99999";
/**
* 用户手点上报
*/