弹框弹出后立即播放,事故详情接口数据赋值

This commit is contained in:
liujing
2021-11-04 21:34:31 +08:00
parent 621ab281a1
commit be7dc8893c
3 changed files with 106 additions and 27 deletions

View File

@@ -1,6 +1,7 @@
package com.mogo.eagle.core.function.hmi.ui.notice;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -9,6 +10,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
import com.mogo.eagle.core.data.notice.NoticeValue;
import com.mogo.eagle.core.function.hmi.R;
@@ -21,11 +23,17 @@ import java.util.List;
* @since: 10/26/21
*/
class NoticeTrafficAdapter extends RecyclerView.Adapter {
private String TAG = "AINotice";
LayoutInflater mLayoutInflater;
private List<NoticeValue> data = new ArrayList();
public NoticeTrafficAdapter(@NonNull Context context) {
public NoticeTrafficAdapter(@NonNull Context context, List info) {
mLayoutInflater = LayoutInflater.from(context);
data = info;
}
public void setData(List<NoticeValue> data) {
this.data = data;
}
@NonNull
@@ -37,18 +45,24 @@ class NoticeTrafficAdapter extends RecyclerView.Adapter {
return holder;
}
@Override
public int getItemViewType(int position) {
return super.getItemViewType(position);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (data.size() > position) {
NoticeValue value = data.get(position);
((TrafficInfoHolder) holder).keyText.setText("测试title");
((TrafficInfoHolder) holder).valueText.setText("当前是测试数据,请查看测试来源");
((TrafficInfoHolder) holder).keyText.setText(value.getKey());
((TrafficInfoHolder) holder).valueText.setText(value.getValue());
}
}
@Override
public int getItemCount() {
return 18;
Log.d(TAG, String.valueOf(data.size()));
return 9;
}
public class TrafficInfoHolder extends RecyclerView.ViewHolder {

View File

@@ -14,6 +14,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData;
import com.mogo.eagle.core.data.notice.NoticeValue;
import com.mogo.eagle.core.function.api.notice.NoticeNetCallBack;
import com.mogo.eagle.core.function.call.notice.CallerNoticeManager;
import com.mogo.eagle.core.function.hmi.R;
@@ -24,10 +25,13 @@ import com.mogo.module.common.dialog.BaseFloatDialog;
import com.mogo.service.imageloader.MogoImageView;
import com.mogo.utils.BitmapHelper;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.mogo.utils.DateTimeUtils;
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView;
import java.util.ArrayList;
/**
* @author liujing
* @description 交警类型弹框
@@ -43,10 +47,10 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
private ImageView playImageView;
private MogoImageView thumbnailImage;
private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
private Bitmap firstBitmap;
private TextView accept;//接受
private TextView refuse;//拒绝
private NoticeTrafficAdapter adapter;
private ArrayList dataArrayList = new ArrayList();
public NoticeTrafficDialog(@NonNull Context context, NoticeTrafficStylePushData pushData) {
super(context);
@@ -67,7 +71,24 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
public void initView() {
setContentView(R.layout.notice_dialog_traffic_police);
playerShow();
playerShow();//视频播放器
recyclerVie();//下方详情信息列表
accept = findViewById(R.id.accept_traffic);
refuse = findViewById(R.id.refuse_traffic);
accept.setOnClickListener(v -> {
feedBackTraffic(1);
});
refuse.setOnClickListener(v -> {
feedBackTraffic(0);
});
//重新连接
findViewById(R.id.notice_connect).setOnClickListener(v -> {
requestTrafficInfo();
});
requestTrafficInfo();
}
private void recyclerVie() {
//网格绘制
try {
mRecyclerView = findViewById(R.id.traffic_info_recyclerView);
@@ -81,21 +102,8 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
} catch (Exception e) {
e.printStackTrace();
}
NoticeTrafficAdapter adapter = new NoticeTrafficAdapter(mContext);
adapter = new NoticeTrafficAdapter(mContext, dataArrayList);
mRecyclerView.setAdapter(adapter);
accept = findViewById(R.id.accept_traffic);
refuse = findViewById(R.id.refuse_traffic);
accept.setOnClickListener(v -> {
feedBackTraffic(1);
});
refuse.setOnClickListener(v -> {
feedBackTraffic(0);
});
//重新连接
findViewById(R.id.notice_connect).setOnClickListener(v -> {
requestTrafficInfo();
});
}
/**
@@ -115,10 +123,67 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
@Override
public void callBackWithResult(NoticeTrafficStyleInfo trafficInfo) {
Log.d(TAG, "交通事故详情::" + trafficInfo);
trafficInfo.setPoiType("交通事故");
trafficInfo.setOperaStatus("已处理");
trafficInfo.setTroubleReasonName("逆向");
infoRefresh(trafficInfo);
}
});
}
private void infoRefresh(NoticeTrafficStyleInfo info) {
if (dataArrayList.size() > 0) {
dataArrayList.clear();
}
NoticeValue laiYuan = new NoticeValue();
laiYuan.setKey("事故来源:");
laiYuan.setValue("--");
dataArrayList.add(laiYuan);
NoticeValue zeRen = new NoticeValue();
zeRen.setKey("责 任 方:");
zeRen.setValue("--");
dataArrayList.add(zeRen);
NoticeValue cTime = new NoticeValue();
cTime.setKey("事故时间:");
cTime.setValue(DateTimeUtils.getTimeText(info.getDataCreateTime(), DateTimeUtils.MM_Yue_dd_Ri_HH_mm));
dataArrayList.add(cTime);
NoticeValue p = new NoticeValue();
p.setKey("责 任 人:");
p.setValue("--");
dataArrayList.add(p);
NoticeValue hTime = new NoticeValue();
hTime.setKey("处理时间:");
hTime.setValue(DateTimeUtils.getTimeText(info.getDataHandleTime(), DateTimeUtils.MM_Yue_dd_Ri_HH_mm));
dataArrayList.add(hTime);
NoticeValue reason = new NoticeValue();
reason.setKey("事故原因:");
reason.setValue(info.getTroubleReasonName());
dataArrayList.add(reason);
NoticeValue status = new NoticeValue();
status.setKey("处理状态:");
status.setValue(info.getOperaStatus());
dataArrayList.add(status);
NoticeValue location = new NoticeValue();
location.setKey("事故地点:");
location.setValue(info.getUploadAddress());
dataArrayList.add(location);
NoticeValue style = new NoticeValue();
style.setKey("事故类型:");
style.setValue("交通事故");
dataArrayList.add(style);
adapter.setData(dataArrayList);
adapter.notifyDataSetChanged();
}
/**
* 根据推送消息渲染顶部图片/视频
* type 0图片 1视频
@@ -136,13 +201,10 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
dismiss();
});
if (mPushData.getType() == 1) {
firstBitmap = BitmapHelper.getVideoThumbnail(mPushData.getPoiImgUrl());/*获取视频第一帧图*/
complete(firstBitmap);
playImageView.setVisibility(View.VISIBLE);
startLive();
} else {
MogoApisHandler.getInstance().getApis().getImageLoaderApi().displayImage(mPushData.getPoiImgUrl(),
thumbnailImage);
thumbnailImage.setImageBitmap(firstBitmap);
thumbnailImage.setVisibility(View.VISIBLE);
playImageView.setVisibility(View.INVISIBLE);
}
@@ -303,6 +365,7 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
@Override
public void onPlayError(String url, Object... objects) {
}
@Override

View File

@@ -61,7 +61,7 @@
android:layout_height="@dimen/dp_100"
android:layout_centerInParent="true"
android:src="@drawable/notice_video_play"
android:visibility="gone"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@id/video_player"
app:layout_constraintLeft_toLeftOf="@id/video_player"
app:layout_constraintRight_toRightOf="@id/video_player"
@@ -78,6 +78,7 @@
android:visibility="gone"
android:textColor="#FFF"
android:textSize="@dimen/dp_42"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/video_player"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
@@ -92,7 +93,8 @@
android:layout_marginBottom="@dimen/dp_40"
app:layout_constraintBottom_toBottomOf="@+id/traffic_top_line"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/video_player" />
<!--分割线-->
<ImageView
android:id="@+id/traffic_top_line"