add click surrounding

This commit is contained in:
lixiaopeng
2020-11-17 16:17:44 +08:00
parent d75ab2742b
commit 012abd52bc
470 changed files with 513 additions and 13495 deletions

View File

@@ -10,11 +10,9 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.mogo.module.common.entity.MarkerPoiTypeEnum;
import com.mogo.module.common.glide.SkinAbleBitmapTarget;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.adapter.holder.V2XSurroundingViewHolder;
import com.mogo.module.v2x.entity.panel.SurroundingConstruction;
import com.mogo.module.v2x.listener.SurroundingItemClickListener;
@@ -76,7 +74,7 @@ public class V2XSurroundingAdapter extends RecyclerView.Adapter<V2XSurroundingVi
@Override
public void onClick(View v) {
if (mClickListener != null) {
mClickListener.onItemClickListener(v, position, surroundingConstruction);
mClickListener.onItemClickListener(v, position, surroundingConstruction, getTypeName(surroundingConstruction.getPoiType()));
}
}
});

View File

@@ -0,0 +1,116 @@
package com.mogo.module.v2x.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerPoiTypeEnum;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.adapter.holder.V2XSurroundingDetailVH;
import com.mogo.module.v2x.entity.panel.SurroundingConstruction;
import com.mogo.utils.DateTimeUtils;
import java.util.List;
/**
* @author lixiaopeng
* @description 周边详情
* @since 2020/11/18
*/
public class V2XSurroundingDetailAdapter extends RecyclerView.Adapter<V2XSurroundingDetailVH> {
private List<MarkerExploreWay> markerExploreWays;
private Context mContext;
private ImageView mTypeImageView;
private TextView mTypeTv;
private TextView mAddressTv;
private TextView mTimeTv;
public V2XSurroundingDetailAdapter(Context context, List<MarkerExploreWay> list) {
mContext = context;
markerExploreWays = list;
}
@Override
public int getItemViewType(int position) {
return super.getItemViewType(position);
}
@NonNull
@Override
public V2XSurroundingDetailVH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View inflate = LayoutInflater.from(parent.getContext())
.inflate(R.layout.module_v2x_event_surrounding_detail_item, parent, false);
return new V2XSurroundingDetailVH(inflate);
}
@Override
public void onBindViewHolder(@NonNull V2XSurroundingDetailVH holder, final int position) {
final MarkerExploreWay exploreWay = markerExploreWays.get(position);
if (exploreWay == null) {
return;
}
// mTypeImageView = holder.itemView.findViewById(R.id.iv_event_type);
mTypeTv = holder.itemView.findViewById(R.id.surrounding_road_type);
mAddressTv = holder.itemView.findViewById(R.id.surrounding_road_type_address);
mTimeTv = holder.itemView.findViewById(R.id.surrounding_time);
mTypeTv.setText(getTypeName(exploreWay.getPoiType()));
mAddressTv.setText(exploreWay.getAddr());
mTimeTv.setText(DateTimeUtils.getTimeText(exploreWay.getGenerateTime(), DateTimeUtils.MM_Yue_dd_Ri_HH_mm));
// mTypeImageView.setBackgroundResource(getTypeSmallRes(surroundingConstruction.getPoiType()));
}
@Override
public int getItemCount() {
return markerExploreWays == null ? 0 : markerExploreWays.size();
}
private String getTypeName(String type) {
String typeName = "";
switch (type) {
case MarkerPoiTypeEnum.ROAD_CLOSED:
typeName = "封路";
break;
case MarkerPoiTypeEnum.FOURS_ICE:
typeName = "道路结冰";
break;
case MarkerPoiTypeEnum.FOURS_FOG:
typeName = "浓雾";
break;
case MarkerPoiTypeEnum.TRAFFIC_CHECK:
typeName = "交通检查";
break;
case MarkerPoiTypeEnum.FOURS_ACCIDENT:
typeName = "交通事故";
break;
case MarkerPoiTypeEnum.FOURS_BLOCK_UP:
typeName = "拥堵";
break;
case MarkerPoiTypeEnum.FOURS_ROAD_WORK:
typeName = "施工";
break;
case MarkerPoiTypeEnum.FOURS_PONDING:
typeName = "道路积水";
break;
case MarkerPoiTypeEnum.FOURS_LIVING:
typeName = "实时路况";
break;
default:
typeName = "实时路况";
break;
}
return typeName;
}
}

View File

@@ -0,0 +1,19 @@
package com.mogo.module.v2x.adapter.holder;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
/**
* @author lixiaopeng
* @description
* @since 2020/11/16
*/
public class V2XSurroundingDetailVH extends RecyclerView.ViewHolder{
public V2XSurroundingDetailVH(@NonNull View itemView) {
super(itemView);
}
}

View File

@@ -1,4 +1,4 @@
package com.mogo.module.v2x.adapter;
package com.mogo.module.v2x.adapter.holder;
import android.view.View;

View File

@@ -15,12 +15,14 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.launcher.ARouter;
@@ -34,8 +36,11 @@ import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.SpacesItemDecoration;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.adapter.V2XShareEventAdapter;
import com.mogo.module.v2x.adapter.V2XSurroundingAdapter;
import com.mogo.module.v2x.adapter.V2XSurroundingDetailAdapter;
import com.mogo.module.v2x.entity.panel.SurroundingConstruction;
import com.mogo.module.v2x.listener.SurroundingItemClickListener;
import com.mogo.module.v2x.presenter.SurroundingEventPresenter;
@@ -63,6 +68,7 @@ import static android.view.View.OVER_SCROLL_NEVER;
public class V2XSurroundingFragment extends MvpFragment<SurroundingEventView, SurroundingEventPresenter> implements SurroundingEventView,
View.OnClickListener, SurroundingItemClickListener {
private static final String TAG = "SurroundingFragment";
private RelativeLayout mSurroundingLayout;
private RecyclerView mRecyclerView;
private TextView mTotalTv;
private RelativeLayout mTopLayout;
@@ -76,10 +82,17 @@ public class V2XSurroundingFragment extends MvpFragment<SurroundingEventView, Su
private IMogoServiceApis mApis;
private NetworkLoadingView mloadingImage;
private RelativeLayout mSurroundingDetailLayout;
private RecyclerView mDetailRecyclerView;
private ImageView mBackImage;
private TextView mBriefTv;
private V2XSurroundingDetailAdapter mDetailAdapter;
private List<MarkerExploreWay> markerExploreWays = new ArrayList<>();
@Override
protected int getLayoutId() {
Log.d(TAG, "getLayoutId --------> ");
return R.layout.module_event_panel_fragment_surrounding;
}
@@ -92,7 +105,7 @@ public class V2XSurroundingFragment extends MvpFragment<SurroundingEventView, Su
@Override
protected void initViews() {
Log.d(TAG, "initViews --------> ");
mSurroundingLayout = findViewById(R.id.layout_surrounding_event);
mRecyclerView = findViewById(R.id.surrounding_recycleview);
mTotalTv = findViewById(R.id.tv_brief);
mTopLayout = findViewById(R.id.layout_top);
@@ -105,6 +118,13 @@ public class V2XSurroundingFragment extends MvpFragment<SurroundingEventView, Su
mShareTv.setOnClickListener(this);
mFreshTv.setOnClickListener(this);
mSurroundingDetailLayout = findViewById(R.id.layout_surrounding_event_detail);
mDetailRecyclerView = findViewById(R.id.surrounding_detail_recycleview);
mSurroundingDetailLayout.setVisibility(View.GONE);
mBackImage = findViewById(R.id.back_image);
mBriefTv = findViewById(R.id.tv_brief_detail);
mBackImage.setOnClickListener(this);
// mRecyclerView.setHasFixedSize(true);
mRecyclerView.setOverScrollMode(OVER_SCROLL_NEVER);
GridLayoutManager layoutManage = new GridLayoutManager(getContext(), 2);
@@ -120,6 +140,15 @@ public class V2XSurroundingFragment extends MvpFragment<SurroundingEventView, Su
}
private void initDetail() {
mDetailRecyclerView.addItemDecoration(new SpacesItemDecoration((int) getResources().getDimension(R.dimen.share_item_padding)));
mDetailAdapter = new V2XSurroundingDetailAdapter(getActivity(), markerExploreWays);
mDetailRecyclerView.setAdapter(mDetailAdapter);
LinearLayoutManager linearLayoutManager =
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
mDetailRecyclerView.setLayoutManager(linearLayoutManager);
}
@NonNull
@Override
protected SurroundingEventPresenter createPresenter() {
@@ -132,8 +161,6 @@ public class V2XSurroundingFragment extends MvpFragment<SurroundingEventView, Su
surroundingEventPresenter = new SurroundingEventPresenter(getContext(), this);
mApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(getContext());
Log.d(TAG, "onViewCreated --------->");
}
@Override
@@ -147,6 +174,8 @@ public class V2XSurroundingFragment extends MvpFragment<SurroundingEventView, Su
}
} else if (id == R.id.tv_main_refresh || id == R.id.tv_top_refresh) { //刷新
initData();
} else if (id == R.id.back_image) {
showDetail(false);
}
}
@@ -278,71 +307,99 @@ public class V2XSurroundingFragment extends MvpFragment<SurroundingEventView, Su
return poiTypes;
}
private void showDetail(boolean isShow) {
if (isShow) {
mSurroundingLayout.setVisibility(View.GONE);
mSurroundingDetailLayout.setVisibility(View.VISIBLE);
} else {
mSurroundingDetailLayout.setVisibility(View.GONE);
mSurroundingLayout.setVisibility(View.VISIBLE);
}
}
/**
* 处理marker的显示
* 处理marker的显示 TODO
*
* @param v
* @param position
* @param construction
*/
@Override
public void onItemClickListener(View v, int position, SurroundingConstruction construction) {
public void onItemClickListener(View v, int position, SurroundingConstruction construction, String poiType) {
showDetail(true);
initDetail();
if (construction != null) {
//卡片消失
V2XEventPanelFragment.Companion.getInstance().hidePanel();
//清除道路事件
V2XServiceManager.getMarkerManager().removeMarkers(ServiceConst.CARD_TYPE_ROAD_CONDITION);
//处理 marker的显示
markerExploreWays.clear();
markerExploreWays.addAll(construction.getConstrutList());
mDetailAdapter.notifyDataSetChanged();
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(markerShowEntity.getMarkerType());
mogoMarker.setObject(markerShowEntity);
}
}, i * 100L);
}
//自适应显示
showBonndsRoadtion(exploreWayList);
} else {
Logger.e(TAG, "onItemClickListener exploreWayList == null");
}
} catch (Exception e) {
e.printStackTrace();
}
String brief = String.format(getContext().getResources().getString(R.string.v2x_surrounding_detail_top_brief), markerExploreWays.size());
mBriefTv.setText(brief + poiType);
Logger.d(TAG, "onItemClickListener markerExploreWays.size() = " + markerExploreWays.size());
}
}
// @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(markerShowEntity.getMarkerType());
// mogoMarker.setObject(markerShowEntity);
// }
// }, i * 100L);
// }
//
// //自适应显示
// showBonndsRoadtion(exploreWayList);
// } else {
// Logger.e(TAG, "onItemClickListener exploreWayList == null");
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
/**
* 自适应显示
*

View File

@@ -10,5 +10,5 @@ import com.mogo.module.v2x.entity.panel.SurroundingConstruction;
* @since 2020/8/10
*/
public interface SurroundingItemClickListener {
void onItemClickListener(View v, int position, SurroundingConstruction construction);
void onItemClickListener(View v, int position, SurroundingConstruction construction, String poiType);
}