fix conflict

This commit is contained in:
lixiaopeng
2020-08-10 19:40:53 +08:00
parent 98900b516a
commit 6ac12a526c
9 changed files with 183 additions and 74 deletions

View File

@@ -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<SurroundingEventViewHolder> {
private List<MarkerExploreWay> mPoiInfosList;
private List<SurroundingConstruction> mPoiInfosList;
private Context mContext;
private ImageView mBgImageView;
private ImageView mTypeImageView;
private TextView mTypeTv;
private TextView mTotalTv;
private SurroundingItemClickListener mClickListener;
public SurroundingEventAdapter(Context context, List<MarkerExploreWay> poiInfosList) {
public SurroundingEventAdapter(Context context, List<SurroundingConstruction> poiInfosList, SurroundingItemClickListener clickListener) {
mContext = context;
mPoiInfosList = poiInfosList;
mClickListener = clickListener;
}
@Override
@@ -49,9 +54,9 @@ public class SurroundingEventAdapter extends RecyclerView.Adapter<SurroundingEve
}
@Override
public void onBindViewHolder(@NonNull SurroundingEventViewHolder holder, int position) {
final MarkerExploreWay exploreWay = mPoiInfosList.get(position);
if (exploreWay == null) {
public void onBindViewHolder(@NonNull SurroundingEventViewHolder holder, final int position) {
final SurroundingConstruction surroundingConstruction = mPoiInfosList.get(position);
if (surroundingConstruction == null) {
return;
}
@@ -60,21 +65,25 @@ public class SurroundingEventAdapter extends RecyclerView.Adapter<SurroundingEve
mTypeTv = holder.itemView.findViewById(R.id.tv_poitype);
mTotalTv = holder.itemView.findViewById(R.id.tv_info_total);
mTypeTv.setText(getTypeName(exploreWay.getPoiType()));
// mTotalTv.setText(exploreWay.);
mTypeTv.setText(getTypeName(surroundingConstruction.getPoiType()));
if (surroundingConstruction.getConstrutList() != null) {
mTotalTv.setText(surroundingConstruction.getConstrutList().size() + "");
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mClickListener != null) {
mClickListener.onItemClickListener(v, position, surroundingConstruction);
}
}
});
//数据绑定 TODO
// RequestOptions requestOptions = new RequestOptions()
// .placeholder(R.drawable.tanlu_normal_image)
// .error(R.drawable.tanlu_normal_image)
// .fallback(R.drawable.tanlu_normal_image);
// Glide.with(mContext)
// .load(imageUrl)
// .apply(requestOptions)
// .load(R.drawable.icon_car_red)
// .into(mBgImageView);
}
@Override
@@ -120,4 +129,6 @@ public class SurroundingEventAdapter extends RecyclerView.Adapter<SurroundingEve
return typeName;
}
}

View File

@@ -3,6 +3,7 @@ package com.mogo.module.v2x.entity.panel;
import com.mogo.module.common.entity.MarkerExploreWay;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
@@ -10,10 +11,15 @@ import java.util.List;
* @description 构造数据
* @since 2020/8/7
*/
public class SurroundingConstructionData implements Serializable {
public class SurroundingConstruction implements Serializable {
private String poiType;
private List<MarkerExploreWay> 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<MarkerExploreWay> construtList) {
this.construtList = construtList;
public void addMarkerExploreWay(MarkerExploreWay item) {
construtList.add(item);
}
}

View File

@@ -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<SurroundingEventView, SurroundingEventPresenter> implements SurroundingEventView, View.OnClickListener {
public class SurroundingEventFragment extends MvpFragment<SurroundingEventView, SurroundingEventPresenter> 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<MarkerExploreWay> poiInfosList = new ArrayList<>();
private List<SurroundingConstruction> 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<SurroundingEventView,
mRecyclerView = findViewById(R.id.surrounding_recycleview);
mTotalTv = findViewById(R.id.tv_brief);
mEmptyLayout = findViewById(R.id.layout_empty_data_show);
mTopFreshTv = findViewById(R.id.tv_top_refresh);
mShareTv = findViewById(R.id.tv_main_share);
mFreshTv = findViewById(R.id.tv_main_refresh);
mTopFreshTv.setOnClickListener(this);
mShareTv.setOnClickListener(this);
mFreshTv.setOnClickListener(this);
@@ -70,7 +90,7 @@ public class SurroundingEventFragment extends MvpFragment<SurroundingEventView,
GridLayoutManager layoutManage = new GridLayoutManager(getContext(), 2);
mRecyclerView.setLayoutManager(layoutManage);
mAdapter = new SurroundingEventAdapter(getActivity(), poiInfosList);
mAdapter = new SurroundingEventAdapter(getActivity(), poiInfosList, this);
mRecyclerView.setAdapter(mAdapter);
initData();
@@ -89,7 +109,7 @@ public class SurroundingEventFragment extends MvpFragment<SurroundingEventView,
surroundingEventPresenter = new SurroundingEventPresenter(getContext(), this);
mApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(getContext());
Log.d(TAG, "onViewCreated ---------");
Log.d(TAG, "onViewCreated --------->");
}
@@ -97,13 +117,12 @@ public class SurroundingEventFragment extends MvpFragment<SurroundingEventView,
public void onClick(View v) {
int id = v.getId();
if (id == R.id.tv_main_share) {
//TODO 分享, 弹出框面板消失,出现分享弹框
V2XEventPanelFragment fragment = new V2XEventPanelFragment();
fragment.hidePanel();
//弹出框面板消失,出现分享弹框
V2XEventPanelFragment.Companion.getInstance().hidePanel();
if (mApis != null && mApis.getShareManager() != null) {
mApis.getShareManager().showShareDialog();
}
} else if (id == R.id.tv_main_refresh) { //刷新
} else if (id == R.id.tv_main_refresh || id == R.id.tv_top_refresh) { //刷新
initData();
}
}
@@ -120,62 +139,120 @@ public class SurroundingEventFragment extends MvpFragment<SurroundingEventView,
*/
@Override
public void showSurroudingData(List<MarkerExploreWay> 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<SurroundingConstructionData> mConstructionList = new ArrayList<>();
//TODO
private List<SurroundingConstructionData> handleCategoricalData(List<MarkerExploreWay> list) {
List<SurroundingConstructionData> tempExploreWayList = new ArrayList<>();
Log.d(TAG, "handleCategoricalData -------1---");
private Map<String, SurroundingConstruction> getPoiTypeMap(List<MarkerExploreWay> list) {
Map<String, SurroundingConstruction> 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<MarkerExploreWay> 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<SurroundingConstruction> handleMapToList(Map<String, SurroundingConstruction> map) {
Collection<? extends SurroundingConstruction> valueCollection = map.values();
List<SurroundingConstruction> 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<MarkerExploreWay> 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() {

View File

@@ -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);
}

View File

@@ -63,7 +63,7 @@ public class SurroundingEventPresenter extends Presenter<SurroundingEventView> {
}
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())

View File

@@ -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">
<androidx.recyclerview.widget.RecyclerView

View File

@@ -1,13 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="291px"
android:layout_height="173px"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingLeft="5px"
android:paddingTop="5px"
android:background="@color/white"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal">
android:padding="8px"
android:background="#FF1B1B">
<ImageView
android:id="@+id/iv_event_bg"
@@ -18,7 +15,7 @@
<RelativeLayout
android:layout_below="@+id/iv_event_bg"
android:background="#000000"
android:background="@color/surrounding_item_bottom_color"
android:layout_width="match_parent"
android:layout_height="43px">
@@ -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条" />
</RelativeLayout>
</RelativeLayout>

View File

@@ -5,6 +5,7 @@
<color name="surrounding_card_background">#10121E</color>
<color name="white">#FFFFFF</color>
<color name="transparent_white_30">#4DFFFFFF</color>
<color name="surrounding_item_bottom_color">#1F2131</color>
<color name="share_event_item_bg_color">#1F2131</color>

View File

@@ -5,5 +5,6 @@
<string name="v2x_help_speed_txt">车速</string>
<string name="v2x_report_pop_submit_txt">已提交</string>
<string name="v2x_report_pop_thank_txt">感谢已送达</string>
<string name="v2x_surrounding_top_brief">周围5公里共 %d 条交通信息</string>
</resources>