From fb4f9548cddef551aace0c9ccd9b1db3945090ad Mon Sep 17 00:00:00 2001 From: tongchenfei Date: Thu, 10 Sep 2020 14:12:01 +0800 Subject: [PATCH] =?UTF-8?q?opt=EF=BC=9A=E5=88=86=E4=BA=AB=E6=A1=86?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mogo/module/share/ShareControl.java | 105 ++++++++++-------- .../mogo/module/share/bean/FixableButton.kt | 21 +++- .../share/dialog/GridFixableShareDialog.kt | 10 +- .../module/share/manager/GridBtnManager.kt | 35 +++--- .../mogo/module/share/net/ShareApiService.kt | 2 +- .../layout/dialog_share_with_gridlayout.xml | 5 + 6 files changed, 103 insertions(+), 75 deletions(-) diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/ShareControl.java b/modules/mogo-module-share/src/main/java/com/mogo/module/share/ShareControl.java index 9e6a666721..7f0c7b741d 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/ShareControl.java +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/ShareControl.java @@ -27,6 +27,7 @@ import com.mogo.module.share.bean.StepAfterAuth; import com.mogo.module.share.constant.HttpConstant; import com.mogo.module.share.constant.ShareConstants; import com.mogo.module.share.dialog.GridFixableShareDialog; +import com.mogo.module.share.dialog.LaucherShareDialog; import com.mogo.module.share.manager.ServiceApisManager; import com.mogo.module.share.manager.UploadHelper; import com.mogo.module.share.net.ShareApiService; @@ -93,7 +94,8 @@ import static com.mogo.service.tanlu.IMogoTanluProvider.TYPE_TRAFFIC_CHECK; * @since 2020-01-10 */ @Route(path = MogoServicePaths.PATH_SHARE) -public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMogoVoiceCmdCallBack, Handler.Callback { +public class ShareControl implements IMogoShareManager, IMogoIntentListener, + IMogoVoiceCmdCallBack, Handler.Callback { private static final String TAG = "ShareControl"; private Context mContext; @@ -116,7 +118,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo @Override public void dismissShareDialog() { if (mShareDialog != null) { - Logger.d(TAG,"dismissShareDialog"); + Logger.d(TAG, "dismissShareDialog"); mShareDialog.dismiss(); } } @@ -128,8 +130,12 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo private void realShowDialog() { if (mShareDialog == null) { - Logger.d(TAG,"realShowDialog context : " + mContext); - mShareDialog = new GridFixableShareDialog(mContext); + Logger.d(TAG, "realShowDialog context : " + mContext); + if(DebugConfig.isLauncher()){ + mShareDialog = new LaucherShareDialog(mContext); + }else { + mShareDialog = new GridFixableShareDialog(mContext); + } mShareDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { @@ -140,11 +146,11 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo mShareDialog.show(); } - private StepAfterAuth stepAfterAuth = new StepAfterAuth(-1, "",false); + private StepAfterAuth stepAfterAuth = new StepAfterAuth(-1, "", false); @Override public void init(Context context) { - Logger.d(TAG,"start init===="); + Logger.d(TAG, "start init===="); mContext = context; ServiceApisManager.INSTANCE.init(context); authorizeModuleManager = @@ -158,8 +164,10 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo break; case STEP_AFTER_AUTH_TYPE_UPLOAD: TanluUploadParams params = - new TanluUploadParams(stepAfterAuth.getUploadType(), IMogoTanluProvider.UPLOAD_FROM_VOICE); - UploadHelper.INSTANCE.upload(mContext, params,stepAfterAuth.getForcePlayVoice()); + new TanluUploadParams(stepAfterAuth.getUploadType(), + IMogoTanluProvider.UPLOAD_FROM_VOICE); + UploadHelper.INSTANCE.upload(mContext, params, + stepAfterAuth.getForcePlayVoice()); dismissShareDialog(); break; case STEP_AFTER_AUTH_TYPE_SEEK_HELP: @@ -193,7 +201,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo AIAssist.getInstance(mContext).registerUnWakeupCommand(UNWAKE_UPLOAD_REAL_TIME_TRAFFIC, UPLOAD_REAL_TIME_TRAFFIC, ShareControl.this); - if(!DebugConfig.isLauncher()) { + if (!DebugConfig.isLauncher()) { ServiceApisManager.serviceApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.MAIN_PAGE_RESUME, new IMogoStatusChangedListener() { @Override public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) { @@ -204,7 +212,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo }); } - if(!DebugConfig.isLauncher()) { + if (!DebugConfig.isLauncher()) { ServiceApisManager.serviceApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.ACC_STATUS, new IMogoStatusChangedListener() { @Override public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) { @@ -219,7 +227,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo queryShareConfigRetryTime = 0; queryShareButtonConfig(); } - Logger.d(TAG,"init over===="); + Logger.d(TAG, "init over===="); } @Override @@ -231,42 +239,42 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo break; case UNWAKE_UPLOAD_ROAD_BLOCK: if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_BLOCK,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_BLOCK, false); } else { uploadFromVoice(TYPE_BLOCK); } break; case UNWAKE_UPLOAD_TRAFFIC_CHECK: if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_TRAFFIC_CHECK,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_TRAFFIC_CHECK, false); } else { uploadFromVoice(TYPE_TRAFFIC_CHECK); } break; case UNWAKE_UPLOAD_ROAD_CLOSURE: if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_CLOSURE,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_CLOSURE, false); } else { uploadFromVoice(TYPE_CLOSURE); } break; case UNWAKE_UPLOAD_ACCIDENT: if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ACCIDENT,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ACCIDENT, false); } else { uploadFromVoice(TYPE_ACCIDENT); } break; case UNWAKE_UPLOAD_REAL_TIME_TRAFFIC: if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_REAL_TIME_TRAFFIC,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_REAL_TIME_TRAFFIC, false); } else { uploadFromVoice(TYPE_REAL_TIME_TRAFFIC); } break; case UNWAKE_UPLOAD_SEEK_HELP: if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_SEEK_HELP, TYPE_BLOCK,false); + goAuth(STEP_AFTER_AUTH_TYPE_SEEK_HELP, TYPE_BLOCK, false); } else { seekHelp(); } @@ -274,28 +282,28 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo break; case UNWAKE_UPLOAD_STAGNANT_WATER: if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_STAGNANT_WATER,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_STAGNANT_WATER, false); } else { uploadFromVoice(TYPE_STAGNANT_WATER); } break; case UNWAKE_UPLOAD_ROAD_ICY: if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_ICY,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_ICY, false); } else { uploadFromVoice(TYPE_ROAD_ICY); } break; case UNWAKE_UPLOAD_DENSE_FOG: if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_DENSE_FOG,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_DENSE_FOG, false); } else { uploadFromVoice(TYPE_DENSE_FOG); } break; case UNWAKE_UPLOAD_ROAD_CONSTRUCTION: if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_CONSTRUCTION,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_CONSTRUCTION, false); } else { uploadFromVoice(TYPE_ROAD_CONSTRUCTION); } @@ -304,6 +312,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo break; } } + @Override public void onIntentReceived(String intentStr, Intent intent) { // 此处只接受处理语音相关广播 @@ -312,7 +321,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo switch (intentStr) { case VOICE_CMD_PUB_TROUBLE_HELP: if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_SEEK_HELP, TYPE_DENSE_FOG,false); + goAuth(STEP_AFTER_AUTH_TYPE_SEEK_HELP, TYPE_DENSE_FOG, false); } else { // 开启服务,准备上报求助 seekHelp(); @@ -326,7 +335,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo switch (ob) { case "积水": if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_STAGNANT_WATER,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_STAGNANT_WATER, false); } else { uploadFromVoice(TYPE_STAGNANT_WATER); dismissShareDialog(); @@ -334,7 +343,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo break; case "积冰": if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_ICY,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_ICY, false); } else { uploadFromVoice(TYPE_ROAD_ICY); dismissShareDialog(); @@ -342,7 +351,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo break; case "雾": if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_DENSE_FOG,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_DENSE_FOG, false); } else { uploadFromVoice(TYPE_DENSE_FOG); dismissShareDialog(); @@ -350,7 +359,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo break; case "交通事故": if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ACCIDENT,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ACCIDENT, false); } else { uploadFromVoice(TYPE_ACCIDENT); dismissShareDialog(); @@ -358,7 +367,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo break; case "施工": if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_CONSTRUCTION,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_ROAD_CONSTRUCTION, false); } else { uploadFromVoice(TYPE_ROAD_CONSTRUCTION); dismissShareDialog(); @@ -366,7 +375,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo break; case "封路": if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_CLOSURE,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_CLOSURE, false); } else { uploadFromVoice(TYPE_CLOSURE); dismissShareDialog(); @@ -374,7 +383,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo break; case "交通检查": if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_TRAFFIC_CHECK,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_TRAFFIC_CHECK, false); } else { uploadFromVoice(TYPE_TRAFFIC_CHECK); dismissShareDialog(); @@ -391,7 +400,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo switch (obCondition) { case "路况": if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_REAL_TIME_TRAFFIC,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_REAL_TIME_TRAFFIC, false); } else { Logger.d(TAG, "分享框准备触发上报实时路况"); uploadFromVoice(TYPE_REAL_TIME_TRAFFIC); @@ -400,7 +409,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo break; case "拥堵": if (needAuth()) { - goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_BLOCK,false); + goAuth(STEP_AFTER_AUTH_TYPE_UPLOAD, TYPE_BLOCK, false); } else { Logger.d(TAG, "分享框准备触发上报拥堵"); uploadFromVoice(TYPE_BLOCK); @@ -432,7 +441,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo private void uploadFromVoice(String eventType) { TanluUploadParams params = new TanluUploadParams(eventType, IMogoTanluProvider.UPLOAD_FROM_VOICE); - UploadHelper.INSTANCE.upload(mContext, params,false); + UploadHelper.INSTANCE.upload(mContext, params, false); } private void seekHelp() { @@ -446,19 +455,21 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo return authorizeModuleManager.needAuthorize(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE); } - private void goAuth(int type, String uploadType,boolean forcePlayVoice) { + private void goAuth(int type, String uploadType, boolean forcePlayVoice) { stepAfterAuth.setType(type); stepAfterAuth.setUploadType(uploadType); stepAfterAuth.setForcePlayVoice(forcePlayVoice); authorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE); } - private void queryShareButtonConfig(){ + private void queryShareButtonConfig() { if (NetworkUtils.isConnected(mContext)) { // 有网,直接请求 - MogoLocation location = ServiceApisManager.serviceApis.getMapServiceApi().getSingletonLocationClient(mContext).getLastKnowLocation(); + MogoLocation location = + ServiceApisManager.serviceApis.getMapServiceApi().getSingletonLocationClient(mContext).getLastKnowLocation(); Map params = new ArrayMap<>(); - ShareConfigRequest request = new ShareConfigRequest(Utils.getSn(), location.getAdCode()); + ShareConfigRequest request = new ShareConfigRequest(Utils.getSn(), + location.getAdCode()); params.put("data", request.toJson()); ServiceApisManager.serviceApis.getNetworkApi().create(ShareApiService.class, HttpConstant.Companion.getNetHost()).queryShareButtonConfig(params).subscribeOn(Schedulers.io()).observeOn(Schedulers.io()).subscribe(new SubscribeImpl(RequestOptions.create(mContext)) { @@ -466,16 +477,16 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo public void onSuccess(ShareButtonConfigResponse o) { super.onSuccess(o); String config = ""; - if (o.getDetailMsg() != null) { - List btnList = o.getDetailMsg().getData(); - if(btnList != null&&!btnList.isEmpty()) { - config = GsonUtil.jsonFromObject(o.getDetailMsg().getData()); + if (o.getResult() != null) { + List btnList = o.getResult().getData(); + if (btnList != null && !btnList.isEmpty()) { + config = GsonUtil.jsonFromObject(btnList); Logger.d(TAG, "获取分享框成功:" + config); - }else { + } else { Logger.d(TAG, "获取分享框成功,但是data没有内容"); } - }else{ - Logger.d(TAG,"获取分享框成功,但是detailMsg没有内容"); + } else { + Logger.d(TAG, "获取分享框成功,但是detailMsg没有内容"); } Logger.d(TAG, "获取分享框配置成功: " + config); SharedPrefsMgr.getInstance(mContext).putString(KEY_SHARE_CONFIG, config); @@ -495,7 +506,7 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo retryQueryShareConfig(); } }); - }else{ + } else { // 重试 retryQueryShareConfig(); } @@ -505,13 +516,15 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo private static final int MSG_QUERY_SHARE_CONFIG_RETRY = 1001; private int queryShareConfigRetryTime = 0; private static final int QUERY_SHARE_CONFIG_RETRY_TIME_THRESHOLD = 10; - private void retryQueryShareConfig(){ - if(queryShareConfigRetryTime > QUERY_SHARE_CONFIG_RETRY_TIME_THRESHOLD){ + + private void retryQueryShareConfig() { + if (queryShareConfigRetryTime > QUERY_SHARE_CONFIG_RETRY_TIME_THRESHOLD) { // 重试次数超过QUERY_SHARE_CONFIG_RETRY_TIME_THRESHOLD,不再重试 return; } handler.sendEmptyMessageDelayed(MSG_QUERY_SHARE_CONFIG_RETRY, 3000); } + private Handler handler = new Handler(this); @Override 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 1b6a2dac93..396b0ba2bb 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 @@ -2,15 +2,32 @@ package com.mogo.module.share.bean import com.mogo.commons.data.BaseData import com.mogo.module.share.R +import com.mogo.service.tanlu.IMogoTanluProvider +import com.mogo.service.tanlu.IMogoTanluProvider.* /** * 可配置按钮封装 * @author tongchenfei */ -data class FixableButton(val id:Int = 0,val poiType:String = "10007",val iconUrl:String = "", val iconRes:Int = R.drawable.share_block_up, val title:String="拥堵") +class FixableButton(val id:Int = 0,val poiType:String = "10007",val iconUrl:String = "", val title:String="拥堵"){ + val iconRes:Int + get() = when(poiType){ + TYPE_SEEK_HELP-> R.drawable.share_seek_help + TYPE_DENSE_FOG -> R.drawable.share_dense_fog + TYPE_ROAD_ICY-> R.drawable.share_road_icy + TYPE_STAGNANT_WATER->R.drawable.share_stagnant_water + TYPE_REAL_TIME_TRAFFIC->R.drawable.share_real_time_traffic + TYPE_ROAD_CONSTRUCTION->R.drawable.share_road_construction + TYPE_ACCIDENT->R.drawable.share_accident + TYPE_CLOSURE->R.drawable.share_road_closure + TYPE_TRAFFIC_CHECK->R.drawable.share_traffic_check + TYPE_BLOCK->R.drawable.share_block_up + else -> 0 + } +} class ShareButtonConfigResponse:BaseData(){ - var detailMsg: ShareButtonConfigDetailMsg? = null + var result: ShareButtonConfigDetailMsg? = null } data class ShareButtonConfigDetailMsg(var data:List) \ 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 59f98f4559..8b8eaa14ee 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 @@ -35,14 +35,6 @@ class GridFixableShareDialog(context: Context) : BaseFloatDialog(context) { private fun setWrapContent() { val window = window -// if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_BYD) { -// if (window != null) { -// val lp = window.attributes -// lp.width = 1024 -// lp.height = 600 -// window.attributes = lp -// } -// } else if (CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X) { if (window != null) { val lp = window.attributes @@ -65,7 +57,7 @@ class GridFixableShareDialog(context: Context) : BaseFloatDialog(context) { Logger.d(TAG, "test-------3") setContentView(R.layout.dialog_share_with_gridlayout) setWrapContent() - gridBtnManager = GridBtnManager(context, findViewById(R.id.moduleShareBtnGridLayout)) + gridBtnManager = GridBtnManager(context, findViewById(R.id.moduleShareBtnGridLayout),findViewById(R.id.ivTmpShow)) gridBtnManager.setShareClickListener { Logger.d(TAG, "share btn click: $it") if (it.poiType == IMogoTanluProvider.TYPE_SEEK_HELP) { 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 f3c21f45b0..0ff0380ca3 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 @@ -18,10 +18,11 @@ import com.mogo.utils.storage.SharedPrefsMgr /** * 用来管理生成对应的分享按钮 */ -class GridBtnManager(val context: Context,private val container: GridLayout) { - companion object{ +class GridBtnManager(val context: Context, private val container: GridLayout, private val tmpImg: ImageView) { + companion object { const val TAG = "GridBtnManager" } + private val inflater = LayoutInflater.from(context) fun resetContainer() { @@ -34,9 +35,9 @@ class GridBtnManager(val context: Context,private val container: GridLayout) { val content = view.findViewById(R.id.tvShareContent) // 优先加载url图片,然后加载资源图片 if (button.iconUrl.isNotEmpty()) { - GlideApp.with(context).load(button.iconUrl).centerInside().into(img) + GlideApp.with(context).load(button.iconUrl).placeholder(button.iconRes).error(button.iconRes).into(img) } else { - GlideApp.with(context).load(button.iconRes).centerInside().into(img) + GlideApp.with(context).load(button.iconRes).placeholder(button.iconRes).error(button.iconRes).into(img) } content.text = button.title view.setOnClickListener { @@ -50,21 +51,21 @@ class GridBtnManager(val context: Context,private val container: GridLayout) { resetContainer() val config = SharedPrefsMgr.getInstance(context).getString(ShareConstants.KEY_SHARE_CONFIG) Logger.d(TAG, "showDefaultBtns: $config") - if(config.isEmpty()) { + if (config.isEmpty()) { // 默认的全部十个按钮 - generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_BLOCK, iconRes = R.drawable.share_block_up, title = "拥堵")) - generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_TRAFFIC_CHECK, iconRes = R.drawable.share_traffic_check, title = "交通检查")) - generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_CLOSURE, iconRes = R.drawable.share_road_closure, title = "封路")) - generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ACCIDENT, iconRes = R.drawable.share_accident, title = "事故")) - generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ROAD_CONSTRUCTION, iconRes = R.drawable.share_road_construction, title = "道路施工")) - generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_REAL_TIME_TRAFFIC, iconRes = R.drawable.share_real_time_traffic, title = "实时路况")) - generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_SEEK_HELP, iconRes = R.drawable.share_seek_help, title = "故障求助")) - generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_STAGNANT_WATER, iconRes = R.drawable.share_stagnant_water, title = "道路积水")) - generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ROAD_ICY, iconRes = R.drawable.share_road_icy, title = "道路结冰")) - generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_DENSE_FOG, iconRes = R.drawable.share_dense_fog, title = "浓雾")) - }else{ + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_BLOCK, title = "拥堵")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_TRAFFIC_CHECK, title = "交通检查")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_CLOSURE, title = "封路")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ACCIDENT, title = "事故")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ROAD_CONSTRUCTION, title = "道路施工")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_REAL_TIME_TRAFFIC, title = "实时路况")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_SEEK_HELP, title = "故障求助")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_STAGNANT_WATER, title = "道路积水")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_ROAD_ICY, title = "道路结冰")) + generateShareButton(FixableButton(poiType = IMogoTanluProvider.TYPE_DENSE_FOG, title = "浓雾")) + } else { val btnList = GsonUtil.arrayFromJson(config, FixableButton::class.java) - btnList.forEach {btn-> + btnList.forEach { btn -> generateShareButton(btn) } } diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt index 0919a94738..fb427784f0 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt @@ -30,6 +30,6 @@ interface ShareApiService { * 获取分享框服务端配置 */ @FormUrlEncoded - @POST("/yycp-geoIndex-preSearch-service/car/search/no/searchNearbyInformation/v1") + @POST("/deva/car/poiType/no/poiTypeList") fun queryShareButtonConfig(@FieldMap param: Map):Observable } \ No newline at end of file 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 b428cc73eb..8ca5255de6 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 @@ -39,4 +39,9 @@ + + \ No newline at end of file