Merge branch 'dev' of http://gitlab.zhidaoauto.com/ecos/yycp-service/Launcher into dev
This commit is contained in:
@@ -14,21 +14,24 @@ public class AppsListChangedLiveData extends MutableLiveData {
|
||||
|
||||
private Observer mObserver;
|
||||
|
||||
private AppsListChangedLiveData(){
|
||||
// private constructor
|
||||
}
|
||||
private static volatile AppsListChangedLiveData sInstance;
|
||||
|
||||
private static final class InstanceHolder{
|
||||
private static final AppsListChangedLiveData INSTANCE = new AppsListChangedLiveData();
|
||||
}
|
||||
private AppsListChangedLiveData(){}
|
||||
|
||||
public static AppsListChangedLiveData getInstance(){
|
||||
return InstanceHolder.INSTANCE;
|
||||
if( sInstance == null ){
|
||||
synchronized( AppsListChangedLiveData.class ) {
|
||||
if( sInstance == null ){
|
||||
sInstance = new AppsListChangedLiveData();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private Object readResolve(){
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,7 +40,9 @@ public class AppsListChangedLiveData extends MutableLiveData {
|
||||
mObserver = observer;
|
||||
}
|
||||
|
||||
public void release(){
|
||||
public synchronized void release(){
|
||||
removeObserver( mObserver );
|
||||
mObserver = null;
|
||||
sInstance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,6 +216,12 @@ public class AppsPresenter extends Presenter< AppsView > {
|
||||
AppsListChangedLiveData.getInstance().release();
|
||||
mView = null;
|
||||
mLauncher.destroy();
|
||||
mAnalytics = null;
|
||||
mCardManager = null;
|
||||
if ( mLauncher != null ) {
|
||||
mLauncher.destroy();
|
||||
}
|
||||
mLauncher = null;
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
|
||||
@@ -103,6 +103,7 @@ public class InternalFunctionLauncher extends BaseAppLauncher {
|
||||
public void destroy() {
|
||||
if ( getNext() != null ) {
|
||||
getNext().destroy();
|
||||
setNext( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class AppsModel {
|
||||
private Map< Integer, List< AppInfo > > mPagedApps = new HashMap<>();
|
||||
|
||||
private AppsModel( Context context ) {
|
||||
mContext = context;
|
||||
mContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
public static AppsModel getInstance( Context context ) {
|
||||
|
||||
@@ -185,7 +185,7 @@ public class MogoModulesManager implements MogoModulesHandler {
|
||||
return;
|
||||
}
|
||||
mActivity.getSupportFragmentManager().beginTransaction()
|
||||
.add( containerId, fragment, provider.getModuleName() )
|
||||
.replace( containerId, fragment, provider.getModuleName() )
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,7 +703,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
} );
|
||||
}
|
||||
|
||||
public void onSyncMarkerResponse(MarkerResponse response){
|
||||
public void onSyncMarkerResponse( MarkerResponse response ) {
|
||||
if ( ignoreDrawRequest() ) {
|
||||
return;
|
||||
}
|
||||
@@ -862,6 +862,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
// 平滑移动
|
||||
private void startSmooth( IMogoMarker iMogoMarker, MarkerOnlineCar markerOnlineCar,
|
||||
MarkerLocation markerLocation ) {
|
||||
if ( iMogoMarker == null ) {
|
||||
return;
|
||||
}
|
||||
List< MarkerCarPois > poiList = markerOnlineCar.getPois();
|
||||
if ( filterErrorPoint( poiList ) ) {
|
||||
return;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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>)
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,12 @@ import com.mogo.service.tanlu.TanluUploadParams
|
||||
import com.mogo.utils.logger.Logger
|
||||
import kotlin.random.Random
|
||||
|
||||
class GridFixableShareDialog(context:Context):BaseFloatDialog(context) {
|
||||
/**
|
||||
* 可动态配置的分享对话框
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class GridFixableShareDialog(context: Context) : BaseFloatDialog(context) {
|
||||
private val isShown = false
|
||||
private val mAnalytics: IMogoAnalytics
|
||||
private val mStatusManager: IMogoStatusManager
|
||||
@@ -30,14 +35,15 @@ 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 (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
|
||||
@@ -53,31 +59,30 @@ class GridFixableShareDialog(context:Context):BaseFloatDialog(context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
private lateinit var gridBtnManager:GridBtnManager
|
||||
|
||||
private lateinit var gridBtnManager: GridBtnManager
|
||||
private fun initView() {
|
||||
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))
|
||||
gridBtnManager.setShareClickListener {
|
||||
Logger.d(TAG, "share btn click: $it")
|
||||
if (it.poiType == IMogoTanluProvider.TYPE_SEEK_HELP) {
|
||||
// 发起故障求助
|
||||
Logger.d(TAG,"发起故障求助====")
|
||||
Logger.d(TAG, "发起故障求助====")
|
||||
seekHelp(context, seekListener, true)
|
||||
}else{
|
||||
} else {
|
||||
// 上报道路事件
|
||||
Logger.d(TAG,"上报道路事件=====")
|
||||
Logger.d(TAG, "上报道路事件=====")
|
||||
sendShareReceiver(it.poiType)
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
findViewById<FrameLayout>(R.id.flShareDialogContainer).setOnClickListener { dismiss() }
|
||||
|
||||
gridBtnManager.showDefaultBtns()
|
||||
}
|
||||
|
||||
private fun randomGenerateBtn(){
|
||||
private fun randomGenerateBtn() {
|
||||
val random = Random.nextInt(1, 10)
|
||||
gridBtnManager.resetContainer()
|
||||
for (i in 0 until random) {
|
||||
@@ -112,6 +117,7 @@ class GridFixableShareDialog(context:Context):BaseFloatDialog(context) {
|
||||
if (!DebugConfig.isLauncher()) {
|
||||
mApis.adasControllerApi.closeADAS()
|
||||
}
|
||||
gridBtnManager.showShareButton()
|
||||
super.show()
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
@@ -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>
|
||||
@@ -485,7 +485,7 @@ public class TanluSlideAdapterNew extends RecyclerView.Adapter<TanluSlideViewHol
|
||||
typeName = "实时路况";
|
||||
break;
|
||||
default:
|
||||
typeName = "道路拥堵";
|
||||
typeName = "实时路况";
|
||||
break;
|
||||
}
|
||||
return typeName;
|
||||
|
||||
@@ -80,7 +80,8 @@
|
||||
<dimen name="tanlu_module_card_height">300px</dimen>
|
||||
<dimen name="tanlu_module_card_video_width">480px</dimen>
|
||||
<dimen name="tanlu_module_card_video_height">270px</dimen>
|
||||
|
||||
<dimen name="tanlu_module_close_height">80px</dimen>
|
||||
|
||||
<dimen name="tanlu_module_card_margin_top">20px</dimen>
|
||||
<dimen name="tanlu_module_card_margin_left">15px</dimen>
|
||||
<dimen name="tanlu_module_margin_right">25px</dimen>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<dimen name="tanlu_module_card_height">350px</dimen>
|
||||
<dimen name="tanlu_module_card_video_width">480px</dimen>
|
||||
<dimen name="tanlu_module_card_video_height">320px</dimen>
|
||||
<dimen name="tanlu_module_close_height">45px</dimen>
|
||||
<dimen name="tanlu_module_close_height">80px</dimen>
|
||||
|
||||
<dimen name="tanlu_module_card_margin_top">23px</dimen>
|
||||
<dimen name="tanlu_module_card_margin_left">15px</dimen>
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.seek.V2XSeekHelpButton;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceConstants;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.module.v2x.scenario.scene.seek;
|
||||
package com.mogo.module.v2x.scenario.scene.help;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
@@ -70,12 +70,12 @@ public class V2XSeekHelpButton implements IV2XButton {
|
||||
if (tv != null) {
|
||||
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("将为您取消", null);
|
||||
tv.setVisibility(View.GONE);
|
||||
V2XServiceManager
|
||||
.getV2XRefreshModel().cancelHelpSignal(new V2XRefreshCallback<BaseData>() {
|
||||
V2XServiceManager.getV2XRefreshModel().cancelHelpSignal(new V2XRefreshCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData result) {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String msg) {
|
||||
tv.setVisibility(View.VISIBLE);
|
||||
@@ -85,6 +85,7 @@ public class V2XSeekHelpButton implements IV2XButton {
|
||||
}
|
||||
unRegisterVoice();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerVoice() {
|
||||
V2XVoiceManager.INSTANCE.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_CANCEL_HELP, cancelCb);
|
||||
Reference in New Issue
Block a user