From 4b2b1b4cd0b7015b468de48911dcc914022a17fb Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Fri, 17 Jan 2020 12:22:17 +0800 Subject: [PATCH] opt --- .idea/misc.xml | 2 +- .../tanlu/fragment/TanluCardViewFragment.java | 94 +++++++++++++++++-- .../module/tanlu/video/FullMediaActivity.kt | 2 +- .../tanlu/video/MediaCoverVideoPlayer.kt | 5 + .../src/main/res/values-xhdpi/dimens.xml | 2 +- 5 files changed, 93 insertions(+), 12 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 2dc54c489f..707ee6e613 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewFragment.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewFragment.java index e89b78471c..6ed33de2b5 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewFragment.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewFragment.java @@ -50,7 +50,10 @@ import com.mogo.map.search.poisearch.MogoPoiResult; import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.module.common.entity.MarkerExploreWay; +import com.mogo.module.common.entity.MarkerExploreWayItem; +import com.mogo.module.common.entity.MarkerLocation; import com.mogo.module.common.entity.MarkerShowEntity; +import com.mogo.module.common.entity.MarkerUserInfo; import com.mogo.module.service.receiver.MogoReceiver; import com.mogo.module.share.ShareControl; import com.mogo.module.tanlu.R; @@ -62,6 +65,7 @@ import com.mogo.module.tanlu.constant.TanluConstants; import com.mogo.module.tanlu.model.Center; import com.mogo.module.tanlu.model.Information; import com.mogo.module.tanlu.model.InformationAndLiveCarResult; +import com.mogo.module.tanlu.model.Items; import com.mogo.module.tanlu.model.PathLineResult; import com.mogo.module.tanlu.model.TanluModelData; import com.mogo.module.tanlu.model.VoiceSearchResult; @@ -294,7 +298,6 @@ public class TanluCardViewFragment extends MvpFragment> public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getViewLifecycleOwner().getLifecycle().addObserver(mPresenter); - Logger.d(TAG, "onActivityCreated -------> "); EventBus.getDefault().register(this); initInterface(); initModelData(); @@ -357,9 +360,10 @@ public class TanluCardViewFragment extends MvpFragment> mEmptyLayout.setVisibility(View.GONE); mRootLayout.setVisibility(View.VISIBLE); - Logger.d(TAG, "onMarkerClicked registerMogoMarkerClickListener = "); + Log.d(TAG, "onMarkerClicked registerMogoMarkerClickListener --1---- "); MarkerExploreWay exploreWay = extractFromMarker(marker); if (exploreWay == null) { + Log.e(TAG, "onMarkerClicked registerMogoMarkerClickListener --2---- "); return false; } @@ -370,6 +374,8 @@ public class TanluCardViewFragment extends MvpFragment> handleData(exploreWay); } + Log.d(TAG, "onMarkerClicked registerMogoMarkerClickListener --3----size() = " + markerExploreWayList.size()); + //更新位置currentPosition for (int i = 0; i < markerExploreWayList.size(); i++) { if (markerExploreWayList.get(i) == exploreWay) { @@ -413,7 +419,6 @@ public class TanluCardViewFragment extends MvpFragment> mogoIntentManager.registerIntentListener(TanluConstants.GO_TO_SHARE, mogoIntentListener); } - /** * 唤醒语音 */ @@ -459,7 +464,7 @@ public class TanluCardViewFragment extends MvpFragment> Logger.d(TAG, "免唤醒 onCmdSelected mogoVoiceListener cmd =" + cmd); if (cmd.equals(TanluConstants.PLAY_VIDEO)) { //播放路况 --ok //TODO - + FullMediaActivity.Companion.launch(getActivity(), mVideoUrl, mImageUrl, mTitle, mGenerateTime); } } @@ -537,7 +542,6 @@ public class TanluCardViewFragment extends MvpFragment> } } else if (id == R.id.tv_main_empty) { //上报路况 - Logger.d(TAG, "tv_main_empty click -----> "); sendShareReceiver("1"); } } @@ -661,6 +665,7 @@ public class TanluCardViewFragment extends MvpFragment> } /** + * TODO * C位事件,如何获取数据,需要有默认数据 * 如果只有一个数据,不显示上下切换按钮,没有数据显示空页面 */ @@ -673,6 +678,7 @@ public class TanluCardViewFragment extends MvpFragment> Logger.d(TAG, "tanlu卡片 onPerform 有效 ---->"); mMarkerManager = mMogoMapService.getMarkerManager(getActivity()); List markers = mMarkerManager.getMarkers(TanluConstants.MODEL_NAME); + if (markers != null && markers.size() > 0) { mEmptyLayout.setVisibility(View.GONE); mRootLayout.setVisibility(View.VISIBLE); @@ -685,6 +691,7 @@ public class TanluCardViewFragment extends MvpFragment> markerExploreWayList.add(exploreWay); } + Log.e("TAG", "tanlu卡片 onPerform 有效 markerExploreWayList.size() =" + markerExploreWayList.size()); if (markers.size() == 1) { mPreviousTv.setVisibility(View.GONE); mNextTv.setVisibility(View.GONE); @@ -702,11 +709,17 @@ public class TanluCardViewFragment extends MvpFragment> refreshVideoData(markerExploreWay); } } + + } else { mEmptyLayout.setVisibility(View.VISIBLE); mRootLayout.setVisibility(View.GONE); mEmptyTv.setText(Html.fromHtml(getContext().getString(R.string.main_empty_content))); } + + //TODO liyz + getRoadLineData(); + } /** @@ -830,7 +843,7 @@ public class TanluCardViewFragment extends MvpFragment> /** - * 上报分享信息 + * 上报分享信息 TODO */ private void uploadShareInfo(String poiType, String poiImgUrl, String nickname, String headImgUrl) { double lat = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLatitude(); @@ -976,12 +989,15 @@ public class TanluCardViewFragment extends MvpFragment> Logger.d(TAG, "getVoiceControlRoadData discription = " + discription); if (o.getResult().getInformations() != null && o.getResult().getInformations().size() > 0) { if (markerExploreWayList != null && markerExploreWayList.size() > 0) { - markerExploreWayList.clear(); // + markerExploreWayList.clear(); //刷新之前先删除之前的,然后再添加成请求的 + currentPosition = 0; } + //转换数据结构 + convertData(o.getResult().getInformations()); + //切换到探路卡片 if (!isCurrentPage) { - //切换探路卡片 iMogoCardManager.switch2(TanluConstants.MODEL_NAME); } @@ -990,13 +1006,14 @@ public class TanluCardViewFragment extends MvpFragment> List informationList = o.getResult().getInformations(); //清除探路之前的数据 mMarkerManager.removeMarkers(TanluConstants.MODEL_NAME); - mMogoStatusManager.setUserInteractionStatus(TanluConstants.MODEL_NAME, true, false); + mMogoStatusManager.setUserInteractionStatus(TanluConstants.MODEL_NAME, true, true); //打点 ArrayList optionList = new ArrayList<>(); for (int i = 0; i < informationList.size(); i++) { //根据type确定添加的图片 String trafficType = informationList.get(i).trafficInfoType; + Log.e(TAG, "trafficType =" + trafficType); if (trafficType.equals("traffic_jam")) { //拥堵 multiMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.tanlu_marker_block_up); } else if (trafficType.equals("car_checking")) { //查车 @@ -1014,6 +1031,7 @@ public class TanluCardViewFragment extends MvpFragment> .longitude(informationList.get(i).lon); optionList.add(options); + Log.e(TAG, "lat =" + informationList.get(i).lat + ">>>lon =" + informationList.get(i).lon); } Logger.d(TAG, "getVoiceControlRoadData optionList.size() = " + optionList.size()); mMarkerManager.addMarkers(TanluConstants.MODEL_NAME, optionList, true); @@ -1035,6 +1053,64 @@ public class TanluCardViewFragment extends MvpFragment> }); } + /** + * 将探路的数据结构转换成 MarkerExploreWay的列表 + */ + private void convertData(List informations) { + for (int i = 0 ; i < informations.size(); i++) { + MarkerExploreWay markerExploreWay = new MarkerExploreWay(); + markerExploreWay.setAddr(informations.get(i).addr); + markerExploreWay.setCityName(informations.get(i).cityName); + markerExploreWay.setDistance(informations.get(i).distance); + markerExploreWay.setFileType(informations.get(i).type); + markerExploreWay.setItems(convertMediaData(informations.get(i).items)); + markerExploreWay.setLocation(convertLocation(informations.get(i))); + markerExploreWay.setUserInfo(convertUserInfo(informations.get(i))); + + markerExploreWayList.add(markerExploreWay); + } + Log.e(TAG, "convertData markerExploreWayList.size() =" + markerExploreWayList.size()); + } + + /** + * 转换媒体数据 + * @param items + * @return + */ + private List convertMediaData(ArrayList items) { + List exploreWayItems = new ArrayList<>(); + MarkerExploreWayItem item = new MarkerExploreWayItem(); + if (items != null && items.size() > 0) { + item.setThumbnail(items.get(0).getThumbnail()); + item.setUrl(items.get(0).getUrl()); + + exploreWayItems.add(item); + } + + return exploreWayItems; + } + + + private MarkerLocation convertLocation(Information information) { + MarkerLocation location = new MarkerLocation(); + location.setAddress(information.addr); + location.setAngle(0); + location.setLat(information.lat); + location.setLon(information.lon); + + return location; + } + + + private MarkerUserInfo convertUserInfo(Information information) { + MarkerUserInfo userInfo = new MarkerUserInfo(); + userInfo.setUserHead(information.headImgUrl); + userInfo.setUserName(information.nickName); + + return userInfo; + } + + Random random = new Random(); private void speakSuccessVoice(List informations, String diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/FullMediaActivity.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/FullMediaActivity.kt index 1bcdab20b4..fa888063a3 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/FullMediaActivity.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/FullMediaActivity.kt @@ -49,7 +49,6 @@ class FullMediaActivity : AppCompatActivity(), View.OnClickListener { } } - private var control = HideControl() private var gsyVideoOptionBuilder = GSYVideoOptionBuilder() private var videoUrl: String? = null @@ -109,6 +108,7 @@ class FullMediaActivity : AppCompatActivity(), View.OnClickListener { } }) + video_view video_view.loadCoverImage(thumbUrl!!) //设置url,点击播放 gsyVideoOptionBuilder.setUrl(videoUrl).setCacheWithPlay(true) diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/MediaCoverVideoPlayer.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/MediaCoverVideoPlayer.kt index 048b2cec82..4a49c8a091 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/MediaCoverVideoPlayer.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/MediaCoverVideoPlayer.kt @@ -5,6 +5,7 @@ import android.util.AttributeSet import android.util.Log import android.view.View import android.widget.ImageView +import android.widget.SeekBar import com.bumptech.glide.Glide import com.mogo.module.tanlu.R import com.shuyu.gsyvideoplayer.GSYVideoManager @@ -110,6 +111,7 @@ class MediaCoverVideoPlayer : StandardGSYVideoPlayer { override fun onAutoCompletion() { super.onAutoCompletion() mProgressBar.progress = 0 + Log.d("liyz", "MediaCoverVideoPlayer onAutoCompletion ------->") } override fun showWifiDialog() { @@ -147,6 +149,9 @@ class MediaCoverVideoPlayer : StandardGSYVideoPlayer { } + override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { + super.onProgressChanged(seekBar, progress, fromUser) + } override fun onDetachedFromWindow() { super.onDetachedFromWindow() diff --git a/modules/mogo-module-tanlu/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-tanlu/src/main/res/values-xhdpi/dimens.xml index 80da6c1b1b..8f6ae1133d 100644 --- a/modules/mogo-module-tanlu/src/main/res/values-xhdpi/dimens.xml +++ b/modules/mogo-module-tanlu/src/main/res/values-xhdpi/dimens.xml @@ -1,7 +1,7 @@ - 4px + px 666px