Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
wangcongtao
2020-09-09 10:05:33 +08:00
31 changed files with 217 additions and 276 deletions

View File

@@ -84,6 +84,7 @@ targetSdkVersion : 22,
// material
material : 'com.google.android.material:material:1.1.0',
indicator : 'com.github.zhpanvip:viewpagerindicator:1.0.4',
// modules
moduletanlu : "com.mogo.module:module-tanlu:${MOGO_MODULE_TANLU_VERSION}",

View File

@@ -52,6 +52,7 @@ dependencies {
implementation rootProject.ext.dependencies.arouter
kapt rootProject.ext.dependencies.aroutercompiler
implementation rootProject.ext.dependencies.aspectj
implementation rootProject.ext.dependencies.indicator
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogoutils

View File

@@ -1,13 +1,17 @@
package com.mogo.module.guide.fragment
import androidx.recyclerview.widget.RecyclerView
import com.mogo.commons.mvp.MvpFragment
import com.mogo.commons.voice.IMogoVoiceCmdCallBack
import com.mogo.module.guide.GuideBizManager
import com.mogo.module.guide.R
import com.mogo.module.guide.util.speak
import com.mogo.utils.logger.Logger
import com.zhpan.indicator.enums.IndicatorSlideMode
import com.zhpan.indicator.enums.IndicatorStyle
import kotlinx.android.synthetic.main.module_guide_fragment.*
class GuideFragment : MvpFragment<GuideConstract.View, GuidePresenter>(), GuideConstract.View {
companion object {
@@ -28,6 +32,12 @@ class GuideFragment : MvpFragment<GuideConstract.View, GuidePresenter>(), GuideC
Logger.d(TAG, "init Views")
adapter = GuideAdapter(this)
moduleGuideViewPager.adapter = adapter
(moduleGuideViewPager.getChildAt(0) as RecyclerView).layoutManager!!.isItemPrefetchEnabled = false
moduleGuideIndicator.setSliderColor(context!!.resources.getColor(R.color.module_guide_indicator_dark),context!!.resources.getColor(R.color.module_guide_indicator_white))
.setSliderWidth(context!!.resources.getDimension(R.dimen.dp_11))
.setSlideMode(IndicatorSlideMode.NORMAL)
.setIndicatorStyle(IndicatorStyle.CIRCLE)
.setupWithViewPager(moduleGuideViewPager)
}
fun moveToNext() {

View File

@@ -29,6 +29,10 @@ class GuideStageFiveFragment : MvpFragment<IView, Presenter<IView>>, View.OnClic
override fun initViews() {
module_guide_page_left.setOnClickListener(this)
module_guide_tv_jump.setOnClickListener(this)
}
override fun onResume() {
super.onResume()
speak(context!!,context!!.resources.getString(R.string.module_guide_voice_page_five),object : IMogoVoiceCmdCallBack {
override fun onTTSEnd(ttsId: String?, tts: String?) {
containerFragment?.closeGuideFragment()

View File

@@ -30,6 +30,10 @@ class GuideStageFourFragment : MvpFragment<IView, Presenter<IView>>, View.OnClic
module_guide_page_left.setOnClickListener(this)
module_guide_page_right.setOnClickListener(this)
module_guide_tv_jump.setOnClickListener(this)
}
override fun onResume() {
super.onResume()
speak(context!!,context!!.resources.getString(R.string.module_guide_voice_page_four),object : IMogoVoiceCmdCallBack {
override fun onTTSEnd(ttsId: String?, tts: String?) {
containerFragment?.moveToNext()

View File

@@ -33,6 +33,10 @@ class GuideStageOneFragment : MvpFragment<IView, Presenter<IView>>, View.OnClick
AnalyticsUtil.track(INVOKE_TRACK_SHOW, hashMapOf("pages_num" to 1))
module_guide_page_right.setOnClickListener(this)
module_guide_tv_jump.setOnClickListener(this)
}
override fun onResume() {
super.onResume()
speak(context!!,context!!.resources.getString(R.string.module_guide_voice_page_one),object : IMogoVoiceCmdCallBack {
override fun onTTSEnd(ttsId: String?, tts: String?) {
containerFragment?.moveToNext()

View File

@@ -30,6 +30,10 @@ class GuideStageThreeFragment : MvpFragment<IView, Presenter<IView>>, View.OnCli
module_guide_page_left.setOnClickListener(this)
module_guide_page_right.setOnClickListener(this)
module_guide_tv_jump.setOnClickListener(this)
}
override fun onResume() {
super.onResume()
speak(context!!,context!!.resources.getString(R.string.module_guide_voice_page_three),object : IMogoVoiceCmdCallBack {
override fun onTTSEnd(ttsId: String?, tts: String?) {
containerFragment?.moveToNext()

View File

@@ -30,6 +30,10 @@ class GuideStageTwoFragment : MvpFragment<IView, Presenter<IView>>, View.OnClick
module_guide_page_left.setOnClickListener(this)
module_guide_page_right.setOnClickListener(this)
module_guide_tv_jump.setOnClickListener(this)
}
override fun onResume() {
super.onResume()
speak(context!!,context!!.resources.getString(R.string.module_guide_voice_page_two),object : IMogoVoiceCmdCallBack {
override fun onTTSEnd(ttsId: String?, tts: String?) {
containerFragment?.moveToNext()

View File

@@ -12,4 +12,13 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.zhpan.indicator.IndicatorView
android:id="@+id/moduleGuideIndicator"
android:layout_width="@dimen/dp_30"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_84"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="module_guide_blue_3B91FF">#3B91FF</color>
<color name="module_guide_indicator_dark">#ccffffff</color>
<color name="module_guide_indicator_white">#ffffff</color>
</resources>

View File

@@ -3,56 +3,60 @@ package com.mogo.module.share;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import android.os.Handler;
import android.os.Message;
import android.util.ArrayMap;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.commons.network.Utils;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
import com.mogo.map.listener.IMogoMapListener;
import com.mogo.map.location.IMogoLocationListener;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.navi.IMogoNaviListener;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant;
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant;
import com.mogo.module.authorize.authprovider.module.IMogoAcquireAuthorizeListener;
import com.mogo.module.authorize.authprovider.module.IMogoAuthorizeModuleManager;
import com.mogo.module.common.dialog.BaseFloatDialog;
import com.mogo.module.share.bean.FixableButton;
import com.mogo.module.share.bean.ShareButtonConfigResponse;
import com.mogo.module.share.bean.ShareConfigRequest;
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.FixableShareDialog;
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;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.intent.IMogoIntentManager;
import com.mogo.service.module.IMogoModuleLifecycle;
import com.mogo.service.share.IMogoShareManager;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.service.tanlu.IMogoTanluProvider;
import com.mogo.service.tanlu.TanluUploadParams;
import com.mogo.utils.NetworkUtils;
import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.RequestOptions;
import com.mogo.utils.network.utils.GsonUtil;
import com.mogo.utils.storage.SharedPrefsMgr;
import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;
import java.util.List;
import java.util.Map;
import io.reactivex.schedulers.Schedulers;
import static com.mogo.module.share.bean.StepAfterAuthKt.STEP_AFTER_AUTH_TYPE_SEEK_HELP;
import static com.mogo.module.share.bean.StepAfterAuthKt.STEP_AFTER_AUTH_TYPE_SHOW_DIALOG;
import static com.mogo.module.share.bean.StepAfterAuthKt.STEP_AFTER_AUTH_TYPE_UPLOAD;
import static com.mogo.module.share.constant.ShareConstants.CMD_CANCEL_SHARE;
import static com.mogo.module.share.constant.ShareConstants.CMD_ROAD_CLOSURE;
import static com.mogo.module.share.constant.ShareConstants.CMD_TRAFFIC_CHECK;
import static com.mogo.module.share.constant.ShareConstants.CMD_UPLOAD_ACCIDENT;
import static com.mogo.module.share.constant.ShareConstants.CMD_UPLOAD_BLOCK;
import static com.mogo.module.share.constant.ShareConstants.KEY_SHARE_CONFIG;
import static com.mogo.module.share.constant.ShareConstants.UNWAKE_CANCEL_SHARE;
import static com.mogo.module.share.constant.ShareConstants.UNWAKE_UPLOAD_ACCIDENT;
import static com.mogo.module.share.constant.ShareConstants.UNWAKE_UPLOAD_DENSE_FOG;
@@ -65,12 +69,7 @@ import static com.mogo.module.share.constant.ShareConstants.UNWAKE_UPLOAD_ROAD_I
import static com.mogo.module.share.constant.ShareConstants.UNWAKE_UPLOAD_SEEK_HELP;
import static com.mogo.module.share.constant.ShareConstants.UNWAKE_UPLOAD_STAGNANT_WATER;
import static com.mogo.module.share.constant.ShareConstants.UNWAKE_UPLOAD_TRAFFIC_CHECK;
import static com.mogo.module.share.constant.ShareConstants.UPLOAD_DENSE_FOG;
import static com.mogo.module.share.constant.ShareConstants.UPLOAD_REAL_TIME_TRAFFIC;
import static com.mogo.module.share.constant.ShareConstants.UPLOAD_ROAD_CONSTRUCTION;
import static com.mogo.module.share.constant.ShareConstants.UPLOAD_ROAD_ICY;
import static com.mogo.module.share.constant.ShareConstants.UPLOAD_SEEK_HELP;
import static com.mogo.module.share.constant.ShareConstants.UPLOAD_STAGNANT_WATER;
import static com.mogo.module.share.constant.ShareConstants.VOICE_CMD_GO_TO_SHARE;
import static com.mogo.module.share.constant.ShareConstants.VOICE_CMD_NO_REPLY_SHARE_DIALOG_CLOSE;
import static com.mogo.module.share.constant.ShareConstants.VOICE_CMD_PUB_ROAD_CONDITION;
@@ -94,7 +93,7 @@ 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 {
public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMogoVoiceCmdCallBack, Handler.Callback {
private static final String TAG = "ShareControl";
private Context mContext;
@@ -204,6 +203,20 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
}
});
}
ServiceApisManager.serviceApis.getStatusManagerApi().registerStatusChangedListener(TAG, StatusDescriptor.ACC_STATUS, new IMogoStatusChangedListener() {
@Override
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
if (isTrue) {
queryShareConfigRetryTime = 0;
queryShareButtonConfig();
}
}
});
// 获取分享框配置信息
queryShareConfigRetryTime = 0;
queryShareButtonConfig();
Logger.d(TAG,"init over====");
}
@@ -438,59 +451,73 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener, IMo
authorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE);
}
@Override
public Fragment createFragment(Context context, Bundle data) {
return null;
private void queryShareButtonConfig(){
if (NetworkUtils.isConnected(mContext)) {
// 有网,直接请求
MogoLocation location = ServiceApisManager.serviceApis.getMapServiceApi().getSingletonLocationClient(mContext).getLastKnowLocation();
Map<String, String> params = new ArrayMap<>();
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<ShareButtonConfigResponse>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(ShareButtonConfigResponse o) {
super.onSuccess(o);
String config = "";
if (o.getDetailMsg() != null) {
List<FixableButton> btnList = o.getDetailMsg().getData();
if(btnList != null&&!btnList.isEmpty()) {
config = GsonUtil.jsonFromObject(o.getDetailMsg().getData());
Logger.d(TAG, "获取分享框成功:" + config);
}else {
Logger.d(TAG, "获取分享框成功但是data没有内容");
}
}else{
Logger.d(TAG,"获取分享框成功但是detailMsg没有内容");
}
Logger.d(TAG, "获取分享框配置成功: " + config);
SharedPrefsMgr.getInstance(mContext).putString(KEY_SHARE_CONFIG, config);
}
@Override
public void onError(Throwable e) {
super.onError(e);
Logger.d(TAG, "获取分享框配置失败: " + e.getMessage());
retryQueryShareConfig();
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
Logger.d(TAG, "获取分享框配置失败: " + code + ", " + message);
retryQueryShareConfig();
}
});
}else{
// 重试
retryQueryShareConfig();
}
queryShareConfigRetryTime++;
}
@Override
public View createView(Context context) {
return null;
}
@NonNull
@Override
public String getModuleName() {
return "ShareControl";
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){
// 重试次数超过QUERY_SHARE_CONFIG_RETRY_TIME_THRESHOLD不再重试
return;
}
handler.sendEmptyMessageDelayed(MSG_QUERY_SHARE_CONFIG_RETRY, 3000);
}
private Handler handler = new Handler(this);
@Override
public IMogoModuleLifecycle getCardLifecycle() {
return null;
}
@Override
public IMogoMapListener getMapListener() {
return null;
}
@Override
public int getType() {
return 0;
}
@Override
public IMogoNaviListener getNaviListener() {
return null;
}
@Override
public IMogoLocationListener getLocationListener() {
return null;
}
@Override
public IMogoMarkerClickListener getMarkerClickListener() {
return null;
}
@Override
public String getAppPackage() {
return "";
}
@Override
public String getAppName() {
return "";
public boolean handleMessage(Message msg) {
if (msg.what == MSG_QUERY_SHARE_CONFIG_RETRY) {
queryShareButtonConfig();
return true;
}
return false;
}
}

View File

@@ -38,7 +38,7 @@ class ShareBtnAdapter(val context:Context): RecyclerView.Adapter<ShareBtnAdapter
private val tvContent:TextView = itemView.findViewById(R.id.tvShareContent)
fun bindData(btn: FixableButton) {
GlideApp.with(context).load(btn.iconRes).into(ivIcon)
tvContent.text = btn.content
tvContent.text = btn.title
ivIcon.setOnClickListener {
btnClickListener?.invoke(btn)
}

View File

@@ -1,9 +1,16 @@
package com.mogo.module.share.bean
import com.mogo.commons.data.BaseData
import com.mogo.module.share.R
/**
* 可配置按钮封装
* @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 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 title:String="拥堵")
class ShareButtonConfigResponse:BaseData(){
var detailMsg: ShareButtonConfigDetailMsg? = null
}
data class ShareButtonConfigDetailMsg(var data:List<FixableButton>)

View File

@@ -0,0 +1,9 @@
package com.mogo.module.share.bean
import com.mogo.utils.network.utils.GsonUtil
class ShareConfigRequest(val sn:String,val adCode:String) {
fun toJson():String{
return GsonUtil.jsonFromObject(this)
}
}

View File

@@ -81,4 +81,9 @@ public class ShareConstants {
* 这个是实时路况不是拥堵拥堵放在了extention模块里面处理
*/
public static final String VOICE_CMD_PUB_ROAD_CONDITION = "com.zhidao.pathfinder.report.roadCondition";
/**
* 分享框配置本地缓存的key
*/
public static final String KEY_SHARE_CONFIG = "SHARE_BUTTON_CONFIG";
}

View File

@@ -1,140 +0,0 @@
package com.mogo.module.share.dialog
import android.content.Context
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.commons.debug.DebugConfig
import com.mogo.module.common.dialog.BaseFloatDialog
import com.mogo.module.common.utils.CarSeries
import com.mogo.module.share.R
import com.mogo.module.share.adapter.ShareBtnAdapter
import com.mogo.module.share.bean.FixableButton
import com.mogo.module.share.manager.ISeekHelpListener
import com.mogo.module.share.manager.SeekHelpManager.removeSeekHelpListener
import com.mogo.module.share.manager.UploadHelper.upload
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
import com.mogo.service.analytics.IMogoAnalytics
import com.mogo.service.statusmanager.IMogoStatusManager
import com.mogo.service.tanlu.IMogoTanluProvider
import com.mogo.service.tanlu.TanluUploadParams
import com.mogo.utils.logger.Logger
import kotlin.random.Random
/**
* 可动态设置内容的Dialog
* 由于和左侧Adas冲突改成了windowManager方式实现这种实现方式的问题是无法监测back键的事件
* @since 2020-01-10
* @author tongchenfei
*/
class FixableShareDialog(private val mContext: Context) : BaseFloatDialog(mContext) {
private val isShown = false
private val mAnalytics: IMogoAnalytics
private val mStatusManager: IMogoStatusManager
private val mApis: IMogoServiceApis
private lateinit var btnRecycler: RecyclerView
private lateinit var btnAdapter:ShareBtnAdapter
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
lp.width = 1920
lp.height = 1080
window.attributes = lp
}
} else {
if (window != null) {
val lp = window.attributes
lp.width = 1024
lp.height = 600
window.attributes = lp
}
}
}
private fun initView() {
Logger.d(TAG, "test-------3")
setContentView(R.layout.launcher_dialog_share_with_gride)
setWrapContent()
btnRecycler = findViewById(R.id.moduleShareBtnRecyclerView)
val manager = GridLayoutManager(mContext, 5, GridLayoutManager.VERTICAL, false)
manager.isAutoMeasureEnabled = true
btnAdapter = ShareBtnAdapter(mContext)
btnRecycler.adapter = btnAdapter
btnAdapter.btnClickListener = {
Logger.d(TAG, "btn click: $it")
randomGenerateBtn()
}
randomGenerateBtn()
}
private fun randomGenerateBtn(){
val random = Random.nextInt(1, 10)
val list = ArrayList<FixableButton>()
for (i in 0 until random) {
list.add(FixableButton())
}
btnAdapter.setFixableButtonList(list)
}
private val seekListener: ISeekHelpListener = object : ISeekHelpListener {
override fun onSeekHelpSuccess() {
Logger.d(TAG, "上报求助完成,成功")
removeSeekHelpListener(this)
dismiss()
}
override fun onSeekHelpFail() {
Logger.d(TAG, "上报求助完成,失败")
removeSeekHelpListener(this)
dismiss()
}
}
/**
* 发送广播 1拥堵2交通检查3封路
*/
private fun sendShareReceiver(type: String) {
val params = TanluUploadParams(type, IMogoTanluProvider.UPLOAD_FROM_USER)
upload(mContext, params, true)
}
override fun show() {
Logger.d(TAG, "onShow====")
if (!DebugConfig.isLauncher()) {
mApis.adasControllerApi.closeADAS()
}
super.show()
}
override fun dismiss() {
Logger.d(TAG, "onDismiss=====")
if (!DebugConfig.isLauncher() && mApis.statusManagerApi.isMainPageOnResume) {
mApis.adasControllerApi.showADAS()
}
super.dismiss()
}
companion object {
private const val TAG = "FixableShareDialog"
}
init {
mApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(mContext) as IMogoServiceApis
mAnalytics = mApis.analyticsApi
mStatusManager = mApis.statusManagerApi
initView()
}
}

View File

@@ -22,6 +22,11 @@ import com.mogo.service.tanlu.TanluUploadParams
import com.mogo.utils.logger.Logger
import kotlin.random.Random
/**
* 可动态配置的分享对话框
*
* @author tongchenfei
*/
class GridFixableShareDialog(context:Context):BaseFloatDialog(context) {
private val isShown = false
private val mAnalytics: IMogoAnalytics
@@ -73,8 +78,6 @@ class GridFixableShareDialog(context:Context):BaseFloatDialog(context) {
dismiss()
}
findViewById<FrameLayout>(R.id.flShareDialogContainer).setOnClickListener { dismiss() }
gridBtnManager.showDefaultBtns()
}
private fun randomGenerateBtn(){
@@ -112,6 +115,7 @@ class GridFixableShareDialog(context:Context):BaseFloatDialog(context) {
if (!DebugConfig.isLauncher()) {
mApis.adasControllerApi.closeADAS()
}
gridBtnManager.showShareButton()
super.show()
}

View File

@@ -3,19 +3,25 @@ package com.mogo.module.share.manager
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.GridLayout
import android.widget.ImageView
import android.widget.TextView
import com.mogo.module.share.R
import com.mogo.module.share.bean.FixableButton
import com.mogo.module.share.constant.ShareConstants
import com.mogo.service.tanlu.IMogoTanluProvider
import com.mogo.utils.glide.GlideApp
import com.mogo.utils.logger.Logger
import com.mogo.utils.network.utils.GsonUtil
import com.mogo.utils.storage.SharedPrefsMgr
/**
* 用来管理生成对应的分享按钮
*/
class GridBtnManager(val context: Context, val container: GridLayout) {
class GridBtnManager(val context: Context,private val container: GridLayout) {
companion object{
const val TAG = "GridBtnManager"
}
private val inflater = LayoutInflater.from(context)
fun resetContainer() {
@@ -32,7 +38,7 @@ class GridBtnManager(val context: Context, val container: GridLayout) {
} else {
GlideApp.with(context).load(button.iconRes).centerInside().into(img)
}
content.text = button.content
content.text = button.title
view.setOnClickListener {
btnClickListener?.invoke(button)
}
@@ -40,18 +46,28 @@ class GridBtnManager(val context: Context, val container: GridLayout) {
return view
}
fun showDefaultBtns() {
fun showShareButton() {
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 = "浓雾"))
val config = SharedPrefsMgr.getInstance(context).getString(ShareConstants.KEY_SHARE_CONFIG)
Logger.d(TAG, "showDefaultBtns: $config")
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{
val btnList = GsonUtil.arrayFromJson(config, FixableButton::class.java)
btnList.forEach {btn->
generateShareButton(btn)
}
}
}
private var btnClickListener: ((fixableButton: FixableButton) -> Unit)? = null

View File

@@ -2,7 +2,9 @@ package com.mogo.module.share.net
import com.mogo.commons.data.BaseData
import com.mogo.module.share.bean.AverateSpeedResponse
import com.mogo.module.share.bean.ShareButtonConfigResponse
import io.reactivex.Observable
import io.reactivex.Single
import okhttp3.RequestBody
import retrofit2.http.*
@@ -23,4 +25,11 @@ interface ShareApiService {
@Headers("Content-type:application/json;charset=UTF-8")
@POST("/deva/car/path/no/poiStrategyCheck/v1")
fun sendAverageSpeedForBlockStrategy(@Body request:RequestBody,@Query("sn") sn:String):Observable<AverateSpeedResponse>
/**
* 获取分享框服务端配置
*/
@FormUrlEncoded
@POST("/yycp-geoIndex-preSearch-service/car/search/no/searchNearbyInformation/v1")
fun queryShareButtonConfig(@FieldMap param: Map<String, String>):Observable<ShareButtonConfigResponse>
}

View File

@@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
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_gravity="center"
android:background="@drawable/module_share_dialog_bg"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="65px"
android:paddingRight="65px"
android:paddingBottom="58px">
<TextView
android:id="@+id/btn_share_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/share_module_title_margin_top"
android:drawableLeft="@drawable/module_share_title_icon_left"
android:drawableRight="@drawable/module_share_title_icon_right"
android:drawablePadding="@dimen/dp_40"
android:text="我要分享"
android:textColor="@color/module_share_dialog_title_text_color"
android:textSize="@dimen/share_module_title_content"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/moduleShareBtnRecyclerView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="44px" />
</LinearLayout>
</FrameLayout>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -12,8 +12,8 @@
<ImageView
android:id="@+id/btnShowOrHidePanels"
android:layout_width="@dimen/v2x_panel_btn_image_width"
android:layout_height="@dimen/v2x_panel_btn_image_width"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/icon_event_panel_more" />

View File

@@ -57,7 +57,7 @@
<dimen name="module_v2x_surrounding_item_bottom_right_textsize">16px</dimen>
<dimen name="module_v2x_des_index_width">17px</dimen>
<dimen name="module_v2x_des_index_height">15.4px</dimen>
<dimen name="module_v2x_panel_width">80px</dimen>
<dimen name="module_v2x_panel_width">82px</dimen>
<dimen name="module_v2x_panel_icon_cor">16px</dimen>
<dimen name="share_empty_icon_width">117px</dimen>
<dimen name="v2x_loading_ani_width">200px</dimen>
@@ -73,7 +73,6 @@
<dimen name="share_index_bottom_padding">15px</dimen>
<dimen name="share_btn_middle_padding">29px</dimen>
<dimen name="v2x_panel_btn_translationY">-8px</dimen>
<dimen name="v2x_panel_btn_image_width">65px</dimen>
</resources>

View File

@@ -56,6 +56,5 @@
<dimen name="module_v2x_des_index_height">42px</dimen>
<dimen name="module_v2x_panel_cor">16px</dimen>
<dimen name="module_v2x_panel_width">120px</dimen>
<dimen name="v2x_panel_btn_image_width">114px</dimen>
</resources>

View File

@@ -56,7 +56,7 @@
<dimen name="module_v2x_des_index_width">31.9px</dimen>
<dimen name="module_v2x_des_index_height">26px</dimen>
<dimen name="module_v2x_panel_icon_cor">30px</dimen>
<dimen name="module_v2x_panel_width">136px</dimen>
<dimen name="module_v2x_panel_width">140px</dimen>
<dimen name="share_empty_icon_width">219px</dimen>
<dimen name="v2x_loading_ani_width">400px</dimen>
<dimen name="v2x_share_btn_width">281px</dimen>

View File

@@ -57,7 +57,7 @@
<dimen name="module_v2x_surrounding_item_bottom_right_textsize">16px</dimen>
<dimen name="module_v2x_des_index_width">16px</dimen>
<dimen name="module_v2x_des_index_height">20px</dimen>
<dimen name="module_v2x_panel_width">74px</dimen>
<dimen name="module_v2x_panel_width">82px</dimen>
<dimen name="module_v2x_panel_icon_cor">16px</dimen>
<dimen name="share_empty_icon_width">117px</dimen>
<dimen name="v2x_loading_ani_width">200px</dimen>
@@ -73,7 +73,6 @@
<dimen name="share_index_bottom_padding">15px</dimen>
<dimen name="share_btn_middle_padding">29px</dimen>
<dimen name="v2x_panel_btn_translationY">-8px</dimen>
<dimen name="v2x_panel_btn_image_width">38px</dimen>

View File

@@ -2,13 +2,14 @@ package com.mogo.service.share;
import android.content.Context;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.service.module.IMogoModuleProvider;
/**
* 分享框管理接口
* @author tongchenfei
*/
public interface IMogoShareManager extends IMogoModuleProvider {
public interface IMogoShareManager extends IProvider {
/**
* 显示分享框
*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB