From 6ac12a526cf43827e95ad820af3fbafb77b0b4d6 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Mon, 10 Aug 2020 19:40:53 +0800 Subject: [PATCH] fix conflict --- .../v2x/adapter/SurroundingEventAdapter.java | 43 +++-- ...Data.java => SurroundingConstruction.java} | 12 +- .../fragment/SurroundingEventFragment.java | 167 +++++++++++++----- .../SurroundingItemClickListener.java | 14 ++ .../presenter/SurroundingEventPresenter.java | 2 +- ...odule_event_panel_fragment_surrounding.xml | 2 + ...module_fragment_surrounding_event_item.xml | 15 +- .../src/main/res/values/color.xml | 1 + .../src/main/res/values/strings.xml | 1 + 9 files changed, 183 insertions(+), 74 deletions(-) rename modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/entity/panel/{SurroundingConstructionData.java => SurroundingConstruction.java} (63%) create mode 100644 modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/SurroundingItemClickListener.java diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/SurroundingEventAdapter.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/SurroundingEventAdapter.java index 00634fca44..b380a66d2d 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/SurroundingEventAdapter.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/SurroundingEventAdapter.java @@ -10,9 +10,11 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import com.mogo.module.common.entity.MarkerExploreWay; +import com.bumptech.glide.Glide; import com.mogo.module.common.entity.MarkerPoiTypeEnum; import com.mogo.module.v2x.R; +import com.mogo.module.v2x.entity.panel.SurroundingConstruction; +import com.mogo.module.v2x.listener.SurroundingItemClickListener; import java.util.List; @@ -22,17 +24,20 @@ import java.util.List; * @since 2020/7/29 */ public class SurroundingEventAdapter extends RecyclerView.Adapter { - private List mPoiInfosList; + private List mPoiInfosList; private Context mContext; private ImageView mBgImageView; private ImageView mTypeImageView; private TextView mTypeTv; private TextView mTotalTv; + private SurroundingItemClickListener mClickListener; - public SurroundingEventAdapter(Context context, List poiInfosList) { + + public SurroundingEventAdapter(Context context, List poiInfosList, SurroundingItemClickListener clickListener) { mContext = context; mPoiInfosList = poiInfosList; + mClickListener = clickListener; } @Override @@ -49,9 +54,9 @@ public class SurroundingEventAdapter extends RecyclerView.Adapter construtList; + public SurroundingConstruction(String poiType) { + this.poiType = poiType; + construtList = new ArrayList<>(); + } + public String getPoiType() { return poiType; } @@ -26,7 +32,7 @@ public class SurroundingConstructionData implements Serializable { return construtList; } - public void setConstrutList(List construtList) { - this.construtList = construtList; + public void addMarkerExploreWay(MarkerExploreWay item) { + construtList.add(item); } } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/SurroundingEventFragment.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/SurroundingEventFragment.java index 1638696f8c..0efb4fbb17 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/SurroundingEventFragment.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/SurroundingEventFragment.java @@ -1,8 +1,16 @@ package com.mogo.module.v2x.fragment; +import android.graphics.Color; import android.os.Bundle; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.style.AbsoluteSizeSpan; +import android.text.style.ForegroundColorSpan; +import android.text.style.StyleSpan; import android.util.Log; import android.view.View; +import android.view.animation.AccelerateInterpolator; +import android.view.animation.LinearInterpolator; import android.widget.RelativeLayout; import android.widget.TextView; @@ -13,44 +21,54 @@ import androidx.recyclerview.widget.RecyclerView; import com.alibaba.android.arouter.launcher.ARouter; import com.mogo.commons.mvp.MvpFragment; +import com.mogo.commons.voice.AIAssist; import com.mogo.map.marker.IMogoMarker; -import com.mogo.map.marker.MogoMarkersHandler; +import com.mogo.map.marker.anim.OnMarkerAnimationListener; import com.mogo.module.common.entity.MarkerExploreWay; -import com.mogo.module.common.entity.MarkerPoiTypeEnum; +import com.mogo.module.common.entity.MarkerShowEntity; +import com.mogo.module.service.ServiceConst; import com.mogo.module.v2x.R; +import com.mogo.module.v2x.V2XServiceManager; import com.mogo.module.v2x.adapter.SurroundingEventAdapter; -import com.mogo.module.v2x.entity.panel.SurroundingConstructionData; -import com.mogo.module.v2x.entity.panel.SurroundingResponse; +import com.mogo.module.v2x.entity.panel.SurroundingConstruction; +import com.mogo.module.v2x.listener.SurroundingItemClickListener; import com.mogo.module.v2x.presenter.SurroundingEventPresenter; import com.mogo.module.v2x.view.SurroundingEventView; import com.mogo.service.IMogoServiceApis; import com.mogo.service.MogoServicePaths; -import com.mogo.service.map.IMogoMapService; +import com.mogo.utils.TipToast; +import com.mogo.utils.WorkThreadHandler; +import com.mogo.utils.logger.Logger; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import static android.view.View.OVER_SCROLL_NEVER; +import static com.mogo.module.v2x.V2XConst.MODULE_NAME; /** * 周边事件 */ -public class SurroundingEventFragment extends MvpFragment implements SurroundingEventView, View.OnClickListener { +public class SurroundingEventFragment extends MvpFragment implements SurroundingEventView, + View.OnClickListener, SurroundingItemClickListener { private static final String TAG = "SurroundingFragment"; private RecyclerView mRecyclerView; private TextView mTotalTv; private RelativeLayout mEmptyLayout; + private TextView mTopFreshTv; private TextView mShareTv; private TextView mFreshTv; private SurroundingEventAdapter mAdapter; private SurroundingEventPresenter surroundingEventPresenter; - private List poiInfosList = new ArrayList<>(); + private List poiInfosList = new ArrayList<>(); private IMogoServiceApis mApis; @Override protected int getLayoutId() { + Log.d(TAG, "getLayoutId --------> "); return R.layout.module_event_panel_fragment_surrounding; } @@ -60,8 +78,10 @@ public class SurroundingEventFragment extends MvpFragment"); } @@ -97,13 +117,12 @@ public class SurroundingEventFragment extends MvpFragment exploreWayList) { - Log.d(TAG, "showSurroudingData -------1--"); if (exploreWayList != null && exploreWayList.size() > 0) { - Log.d(TAG, "showSurroudingData -----2----"); - //对数据进行分类 - handleCategoricalData(exploreWayList); - //展示数据 mRecyclerView.setVisibility(View.VISIBLE); mEmptyLayout.setVisibility(View.GONE); poiInfosList.clear(); - poiInfosList.addAll(exploreWayList); + //对数据进行分类 + poiInfosList.addAll(handleMapToList(getPoiTypeMap(exploreWayList))); mAdapter.notifyDataSetChanged(); - //总条数 - mTotalTv.setText(exploreWayList.size() + ""); + //总条数 TODO + String originStr = String.format(getContext().getResources().getString(R.string.v2x_surrounding_top_brief), exploreWayList.size()); + SpannableString spannableString = new SpannableString(originStr); + spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#256BFF")), 7, originStr.length() - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + //设置字体大小,true表示前面的字体大小20单位为dip + spannableString.setSpan(new AbsoluteSizeSpan(40, true), 7, originStr.length() - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + spannableString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 7, originStr.length() - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + mTotalTv.setText(spannableString); } else { - Log.d(TAG, "showSurroudingData -------3---"); mRecyclerView.setVisibility(View.GONE); mEmptyLayout.setVisibility(View.VISIBLE); } } - private List mConstructionList = new ArrayList<>(); - - - //TODO - private List handleCategoricalData(List list) { - List tempExploreWayList = new ArrayList<>(); - Log.d(TAG, "handleCategoricalData -------1---"); + private Map getPoiTypeMap(List list) { + Map mPoiTypeMarkers = new HashMap<>(); + Log.d(TAG, "getPoiTypeMap list.size() = " + list.size()); for (int i = 0; i < list.size(); i++) { MarkerExploreWay exploreWay = list.get(i); - SurroundingConstructionData constructionData = new SurroundingConstructionData(); - List tempConstrutList = new ArrayList<>(); - if (exploreWay.getPoiType().equals(MarkerPoiTypeEnum.FOURS_LIVING)) { //实时路况 - tempConstrutList.add(exploreWay); - constructionData.setPoiType(MarkerPoiTypeEnum.FOURS_LIVING); - constructionData.setConstrutList(tempConstrutList); - - tempExploreWayList.add(constructionData); - } else if (exploreWay.getPoiType().equals(MarkerPoiTypeEnum.FOURS_ACCIDENT)) { - tempConstrutList.add(exploreWay); - constructionData.setPoiType(MarkerPoiTypeEnum.FOURS_ACCIDENT); - constructionData.setConstrutList(tempConstrutList); - - tempExploreWayList.add(constructionData); + if (!mPoiTypeMarkers.containsKey(exploreWay.getPoiType())) { + mPoiTypeMarkers.put(exploreWay.getPoiType(), new SurroundingConstruction(exploreWay.getPoiType())); } + SurroundingConstruction construction = mPoiTypeMarkers.get(exploreWay.getPoiType()); + construction.addMarkerExploreWay(exploreWay); } - Log.d(TAG, "handleCategoricalData tempExploreWayList.size() = " + tempExploreWayList.size()); - return tempExploreWayList; + Log.d(TAG, "getPoiTypeMap mPoiTypeMarkers.size() = " + mPoiTypeMarkers.size()); + + return mPoiTypeMarkers; } + private List handleMapToList(Map map) { + Collection valueCollection = map.values(); + List valueList = new ArrayList<>(valueCollection); + Log.d(TAG, "handleMapToList valueList.size() = " + valueList.size()); + + return valueList; + } + + + /** + * 处理marker的显示 + * + * @param v + * @param position + * @param construction + */ + @Override + public void onItemClickListener(View v, int position, SurroundingConstruction construction) { + if (construction != null) { + //卡片消失 + V2XEventPanelFragment.Companion.getInstance().hidePanel(); + //清除道路事件 + V2XServiceManager.getMarkerManager().removeMarkers(ServiceConst.CARD_TYPE_ROAD_CONDITION); + + try { + //处理 marker的显示 + List exploreWayList = construction.getConstrutList(); + Logger.d(TAG, "onItemClickListener exploreWayList.size() = " + exploreWayList.size()); + if (exploreWayList != null && exploreWayList.size() > 0) { + for (int i = 0; i < exploreWayList.size(); i++) { + MarkerExploreWay exploreWay = exploreWayList.get(i); + MarkerShowEntity markerShowEntity = new MarkerShowEntity(); + markerShowEntity.setBindObj(exploreWay); + markerShowEntity.setChecked(false); + markerShowEntity.setTextContent(exploreWay.getAddr()); + markerShowEntity.setMarkerLocation(exploreWay.getLocation()); + markerShowEntity.setMarkerType(ServiceConst.CARD_TYPE_ROAD_CONDITION); + + WorkThreadHandler.getInstance().postDelayed(() -> { + IMogoMarker mogoMarker = V2XServiceManager.getIMogoMarkerService().drawMarker(markerShowEntity); + // 点击监听,天际弹窗展示详情 + if (mogoMarker != null) { + mogoMarker.startScaleAnimation(0, 1.2f, 0, 1.2f, 300, new AccelerateInterpolator(), new OnMarkerAnimationListener() { + @Override + public void onAnimStart() { + Logger.d(TAG, " onItemClickListener onAnimStart -----> "); + } + + @Override + public void onAnimEnd() { + if (mogoMarker.isDestroyed()) { + return; + } + Logger.d(TAG, " onItemClickListener onAnimEnd ------> "); + mogoMarker.startScaleAnimation(1.2f, 1, 1.2f, 1, 100, new LinearInterpolator(), null); + } + }); + mogoMarker.setOwner(MODULE_NAME); + mogoMarker.setObject(markerShowEntity); + } + }, i * 100L); + } + } else { + Logger.e(TAG, "onItemClickListener exploreWayList == null"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } @Override public void onDestroy() { diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/SurroundingItemClickListener.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/SurroundingItemClickListener.java new file mode 100644 index 0000000000..3ebf7bccf3 --- /dev/null +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/SurroundingItemClickListener.java @@ -0,0 +1,14 @@ +package com.mogo.module.v2x.listener; + +import android.view.View; + +import com.mogo.module.v2x.entity.panel.SurroundingConstruction; + +/** + * @author lixiaopeng + * @description + * @since 2020/8/10 + */ +public interface SurroundingItemClickListener { + void onItemClickListener(View v, int position, SurroundingConstruction construction); +} diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/presenter/SurroundingEventPresenter.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/presenter/SurroundingEventPresenter.java index 9f5c393869..a5fd840a4d 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/presenter/SurroundingEventPresenter.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/presenter/SurroundingEventPresenter.java @@ -63,7 +63,7 @@ public class SurroundingEventPresenter extends Presenter { } Center center = new Center(location.getLatitude(), location.getLongitude()); String[] poiTypes = {"10002", "10003", "10006", "10007", "10008", "10010", "10011", "10013", "10015"}; - SurroundingRequest request = new SurroundingRequest(center, poiTypes, 5000, 20); + SurroundingRequest request = new SurroundingRequest(center, poiTypes, 5000, 15); eventApiService.getSurroundingEventList(Utils.getSn(), convert(GsonUtil.jsonFromObject(request))) .subscribeOn(Schedulers.io()) diff --git a/modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding.xml b/modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding.xml index 3c0ebad79b..359007e137 100644 --- a/modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding.xml +++ b/modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding.xml @@ -43,6 +43,8 @@ android:id="@+id/list_layout_container" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_marginTop="15px" + android:layout_marginBottom="30px" android:layout_below="@+id/layout_top"> + android:padding="8px" + android:background="#FF1B1B"> @@ -26,7 +23,7 @@ android:id="@+id/iv_event_type" android:layout_width="22px" android:layout_height="16px" - android:layout_marginLeft="15px" + android:layout_marginLeft="10px" android:layout_centerVertical="true" android:src="@drawable/icon_default_black_logo" /> @@ -46,11 +43,11 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" + android:layout_marginRight="22px" android:layout_centerVertical="true" android:textSize="16px" android:textColor="@color/transparent_white_30" android:text="23条" /> - diff --git a/modules/mogo-module-v2x/src/main/res/values/color.xml b/modules/mogo-module-v2x/src/main/res/values/color.xml index 80f8c743d0..d2a4ae7e34 100644 --- a/modules/mogo-module-v2x/src/main/res/values/color.xml +++ b/modules/mogo-module-v2x/src/main/res/values/color.xml @@ -5,6 +5,7 @@ #10121E #FFFFFF #4DFFFFFF + #1F2131 #1F2131 diff --git a/modules/mogo-module-v2x/src/main/res/values/strings.xml b/modules/mogo-module-v2x/src/main/res/values/strings.xml index 717fd6e301..a4dd2e5fa2 100644 --- a/modules/mogo-module-v2x/src/main/res/values/strings.xml +++ b/modules/mogo-module-v2x/src/main/res/values/strings.xml @@ -5,5 +5,6 @@ 车速 已提交 感谢已送达 + 周围5公里,共 %d 条交通信息