This commit is contained in:
unknown
2020-09-10 16:12:58 +08:00
25 changed files with 150 additions and 132 deletions

View File

@@ -2,6 +2,7 @@ package com.mogo.map.impl.amap;
import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
@@ -32,6 +33,11 @@ public class AMapBaseMapView extends MogoBaseMapView {
@Override
protected IMogoMapView createMapView( Context context ) {
IMogoMapView mapView = AMapViewHandler.getMapView();
if ( mapView.getMapView().getParent() != null ) {
ViewGroup group = ( ViewGroup ) mapView.getMapView().getParent();
group.removeView( mapView.getMapView() );
}
return AMapViewHandler.getMapView();
}
}

View File

@@ -2,13 +2,12 @@ package com.mogo.map.impl.amap;
import android.content.Context;
import com.amap.api.maps.TextureMapView;
import com.amap.api.maps.MapView;
import com.amap.api.navi.AMapNaviView;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.IMogoMapView;
public
/**
* @author congtaowang
* @since 2020/9/10
@@ -21,7 +20,7 @@ class AMapViewHandler {
public static void createMapView( Context context ) {
if ( DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE ) {
sMapView = new AMapViewWrapper( new TextureMapView( context ) );
sMapView = new AMapViewWrapper( new MapView( context ) );
} else {
sMapView = new AMapNaviViewWrapper( new AMapNaviView( context ) );
}

View File

@@ -73,7 +73,7 @@ public class AMapViewWrapper implements IMogoMapView,
private static final String TAG = "AMapViewWrapper";
private final TextureMapView mMapView;
private final MapView mMapView;
private IMogoMap mIMap;
private AMapMarkerClickHandler mMarkerClickHandler;
@@ -88,7 +88,7 @@ public class AMapViewWrapper implements IMogoMapView,
.build();
private CarCursorOption mCarCursorOption = DEFAULT_OPTION;
public AMapViewWrapper( TextureMapView mapView ) {
public AMapViewWrapper( MapView mapView ) {
this.mMapView = mapView;
this.mIMap = new AMapWrapper( mMapView.getMap(), mMapView.getContext(), this );
try {

View File

@@ -272,7 +272,7 @@ public class MogoServices implements IMogoMapListener,
/**
* 当前限速
*/
private int mCurrentLimit = 0;
private int mCurrentLimit = -1;
private boolean mIsMainPageFirstResume = true;
@@ -821,7 +821,6 @@ public class MogoServices implements IMogoMapListener,
return;
}
if ( mCurrentLimit == traffic.getSpeedLimit() ) {
return;
}

View File

@@ -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<String, String> 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<ShareButtonConfigResponse>(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<FixableButton> btnList = o.getDetailMsg().getData();
if(btnList != null&&!btnList.isEmpty()) {
config = GsonUtil.jsonFromObject(o.getDetailMsg().getData());
if (o.getResult() != null) {
List<FixableButton> 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

View File

@@ -2,15 +2,31 @@ package com.mogo.module.share.bean
import com.mogo.commons.data.BaseData
import com.mogo.module.share.R
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 ShareButtonConfigResponse:BaseData(){
var detailMsg: ShareButtonConfigDetailMsg? = null
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 -> R.drawable.share_block_up
}
}
data class ShareButtonConfigDetailMsg(var data:List<FixableButton>)
class ShareButtonConfigResponse : BaseData() {
var result: ShareButtonConfigDetailMsg? = null
}
data class ShareButtonConfigDetailMsg(var data: List<FixableButton>)

View File

@@ -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) {

View File

@@ -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<TextView>(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)
}
}

View File

@@ -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<String, String>):Observable<ShareButtonConfigResponse>
}

View File

@@ -39,4 +39,9 @@
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ivTmpShow" />
</FrameLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="24px" />
<gradient
android:angle="180"
android:endColor="#5CC1FF"
android:startColor="#256BFF"/>
</shape>

View File

@@ -3,7 +3,7 @@
<item >
<shape android:shape="rectangle">
<gradient android:angle="135" android:endColor="#ff2a2b38" android:startColor="#ff3f4057" android:type="linear" android:useLevel="true" />
<corners android:radius="@dimen/dp_20" />
<corners android:radius="@dimen/dp_10" />
</shape>
</item>
</selector>

View File

@@ -3,7 +3,7 @@
<item>
<shape android:shape="rectangle">
<gradient android:angle="90" android:endColor="#ff5cc1ff" android:startColor="#ff256bff" android:type="linear" android:useLevel="true" />
<corners android:bottomLeftRadius="@dimen/dp_11" android:bottomRightRadius="0dp" android:topLeftRadius="0dp" android:topRightRadius="0dp" />
<corners android:bottomLeftRadius="@dimen/dp_10" android:bottomRightRadius="0dp" android:topLeftRadius="0dp" android:topRightRadius="0dp" />
</shape>
</item>
</selector>

View File

@@ -3,8 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#88000000">
android:layout_height="match_parent">
<TextView
android:id="@+id/ivDialogBg"

View File

@@ -7,14 +7,14 @@
<Button
android:id="@+id/event_share_load_status"
android:layout_width="220px"
android:layout_width="@dimen/v2x_share_btn_width"
android:layout_height="wrap_content"
android:paddingTop="12px"
android:paddingBottom="12px"
android:layout_centerInParent="true"
android:background="@drawable/bg_v2x_event_share_type_blue"
android:background="@drawable/v2xt_dw_common_corner_bkg_light"
android:text="查看更早记录"
android:textColor="#FFFFFF"
android:textSize="18px" />
android:textSize="@dimen/dp_34" />
</RelativeLayout>

View File

@@ -23,7 +23,7 @@
android:gravity="bottom"
android:text="你还没有分享过道路事件,快去试试吧"
android:textColor="@color/v2x_FFF_333"
android:textSize="@dimen/v2x_share_btn_size" />
android:textSize="@dimen/dp_34" />
<RelativeLayout
android:layout_width="match_parent"
@@ -41,7 +41,7 @@
android:onClick="shareEventAction"
android:text="去分享"
android:textColor="#FFFFFF"
android:textSize="@dimen/v2x_share_btn_size" />
android:textSize="@dimen/dp_34" />
<View
android:id="@+id/center"
@@ -57,7 +57,7 @@
android:background="@drawable/v2xt_dw_common_corner_bkg_light"
android:text="刷新"
android:textColor="#FFFFFF"
android:textSize="@dimen/v2x_share_btn_size" />
android:textSize="@dimen/dp_34" />
</RelativeLayout>

View File

@@ -14,16 +14,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20px"
android:layout_marginTop="12px"
android:layout_marginTop="@dimen/dp_24"
android:background="@drawable/bg_v2x_event_type_read"
android:gravity="center"
android:paddingLeft="5px"
android:paddingTop="3px"
android:paddingRight="5px"
android:paddingBottom="3px"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_3"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_3"
android:text="道路类型"
android:textColor="#FFFFFF"
android:textSize="14px" />
android:textSize="@dimen/dp_28" />
<TextView
android:id="@+id/road_case_useless_num"
@@ -31,11 +31,12 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:gravity="center"
android:paddingRight="20px"
android:gravity="left"
android:paddingRight="@dimen/dp_24"
android:paddingLeft="@dimen/dp_24"
android:text="100"
android:textColor="#FFFFFF"
android:textSize="18px" />
android:textSize="@dimen/dp_34" />
<com.mogo.module.v2x.view.HeartUnLikeView
android:id="@+id/road_case_useless"
@@ -54,10 +55,11 @@
android:layout_centerInParent="true"
android:layout_toLeftOf="@id/road_case_useless"
android:gravity="center"
android:paddingRight="26px"
android:paddingRight="@dimen/dp_24"
android:paddingLeft="@dimen/dp_24"
android:text="100"
android:textColor="#FFFFFF"
android:textSize="18px" />
android:textSize="@dimen/dp_34" />
<com.mogo.module.v2x.view.HeartLikeView
android:id="@+id/road_case_uselful"
@@ -77,23 +79,23 @@
android:layout_toLeftOf="@id/road_case_uselful"
android:ellipsize="end"
android:gravity="left"
android:layout_marginTop="@dimen/dp_24"
android:lines="1"
android:paddingTop="2px"
android:text="东城区北三环附近维多欧美"
android:textColor="@color/share_event_address_color"
android:textSize="18px" />
android:textColor="@color/v2x_FFF_333"
android:textSize="@dimen/dp_34" />
<TextView
android:id="@+id/road_case_share_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/road_case_address"
android:layout_marginLeft="20px"
android:layout_marginBottom="11px"
android:layout_alignLeft="@id/road_case_style"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_24"
android:alpha="0.5"
android:gravity="left"
android:paddingTop="2px"
android:text="时间:"
android:textColor="@color/share_event_share_time_color"
android:textSize="16px" />
android:textColor="@color/v2x_FFF_666"
android:textSize="@dimen/dp_30" />
</RelativeLayout>

View File

@@ -32,7 +32,7 @@
android:paddingTop="14px"
android:text="正在获取信息…"
android:textColor="#FFFFFF"
android:textSize="@dimen/v2x_share_btn_size"
android:textSize="@dimen/dp_34"
app:layout_constraintBottom_toBottomOf="@+id/loading_imageview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
@@ -48,7 +48,7 @@
android:background="@drawable/v2xt_dw_common_corner_bkg_light"
android:text="刷新"
android:textColor="#FFFFFF"
android:textSize="@dimen/v2x_share_btn_size"
android:textSize="@dimen/dp_34"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/loading_imageview" />

View File

@@ -63,7 +63,6 @@
<dimen name="v2x_loading_ani_width">200px</dimen>
<dimen name="v2x_share_btn_width">150px</dimen>
<dimen name="v2x_share_btn_height">48px</dimen>
<dimen name="v2x_share_btn_size">18px</dimen>
<dimen name="v2x_index_rating_top">17px</dimen>
<dimen name="share_top_text_size">16px</dimen>
<dimen name="share_des_num_size">36px</dimen>

View File

@@ -61,7 +61,6 @@
<dimen name="v2x_loading_ani_width">400px</dimen>
<dimen name="v2x_share_btn_width">281px</dimen>
<dimen name="v2x_share_btn_height">90px</dimen>
<dimen name="v2x_share_btn_size">33.75px</dimen>
<dimen name="v2x_index_rating_top">28px</dimen>
<dimen name="share_top_text_size">30px</dimen>
<dimen name="share_des_num_size">67.5px</dimen>

View File

@@ -8,8 +8,6 @@
<color name="v2x_white_refresh">#FFFFFF</color>
<color name="transparent_white_30">#B3FFFFFF</color>
<color name="surrounding_item_bottom_color">#1F2131</color>
<color name="share_event_share_time_color">#FFFFFF</color>
<color name="share_event_address_color">#FFFFFF</color>
<color name="panel_shadow_shape_color">#10121E</color>
<color name="share_event_no_more_color">#99FFFFFF</color>
<color name="v2x_FFF_999">#FFFFFF</color>

View File

@@ -63,7 +63,6 @@
<dimen name="v2x_loading_ani_width">200px</dimen>
<dimen name="v2x_share_btn_width">150px</dimen>
<dimen name="v2x_share_btn_height">48px</dimen>
<dimen name="v2x_share_btn_size">18px</dimen>
<dimen name="v2x_index_rating_top">17px</dimen>
<dimen name="share_top_text_size">16px</dimen>
<dimen name="share_des_num_size">36px</dimen>

View File

@@ -3,7 +3,7 @@
<item >
<shape android:shape="rectangle">
<gradient android:angle="135" android:endColor="#FFFFFF" android:startColor="#F5F5F5" android:type="linear" android:useLevel="true" />
<corners android:radius="@dimen/dp_20" />
<corners android:radius="@dimen/dp_10" />
</shape>
</item>
</selector>

View File

@@ -3,7 +3,7 @@
<item>
<shape android:shape="rectangle">
<gradient android:angle="90" android:endColor="#FFF" android:startColor="#FFF" android:type="linear" android:useLevel="true" />
<corners android:bottomLeftRadius="@dimen/dp_11" android:bottomRightRadius="0dp" android:topLeftRadius="0dp" android:topRightRadius="0dp" />
<corners android:bottomLeftRadius="@dimen/dp_10" android:bottomRightRadius="0dp" android:topLeftRadius="0dp" android:topRightRadius="0dp" />
</shape>
</item>
</selector>