[add] 网络请求添加
This commit is contained in:
@@ -2,26 +2,33 @@ package com.mogo.eagle.core.function.hmi.ui.notice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
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.function.api.notice.NoticeNetCallBack;
|
||||
import com.mogo.eagle.core.function.call.notice.CallerNoticeManager;
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
import com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.dialog.BaseFloatDialog;
|
||||
import com.mogo.service.imageloader.MogoImageView;
|
||||
import com.mogo.utils.BitmapHelper;
|
||||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
|
||||
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @description 交警类型弹框
|
||||
* @since: 10/26/21
|
||||
*/
|
||||
public class NoticeTrafficDialog extends BaseFloatDialog {
|
||||
@@ -32,15 +39,23 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
|
||||
private NoticeTrafficStylePushData mPushData;
|
||||
private ImageView close;
|
||||
private ImageView playImageView;
|
||||
private ImageView thumbnailImage;
|
||||
private MogoImageView thumbnailImage;
|
||||
private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
|
||||
private Bitmap firstBitmap;
|
||||
private TextView accept;//接受
|
||||
private TextView refuse;//拒绝
|
||||
|
||||
|
||||
public NoticeTrafficDialog(@NonNull Context context, NoticeTrafficStylePushData pushData) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mPushData = pushData;
|
||||
mPushData.setPoiImgUrl("https://vd2.bdstatic.com/mda-mk1347dzxdmcre0y/sc/cae_h264/1635819498112313003/mda-mk1347dzxdmcre0y.mp4?v_from_s=hkapp-haokan-tucheng&auth_key=1635837585-0-0-5295f6658c7711ba7b4d3ef478a7fbaa&bcevod_channel=searchbox_feed&pd=1&pt=3&abtest=");
|
||||
//图片
|
||||
String image = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201609%2F26%2F20160926081306_GM2tv.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1638511084&t=92def7498b526dcba3fceda17c43fcb8";
|
||||
String video = "https://vd2.bdstatic.com/mda-mk1347dzxdmcre0y/sc/cae_h264/1635819498112313003/mda-mk1347dzxdmcre0y.mp4?v_from_s=hkapp-haokan-tucheng&auth_key=1635837585-0-0-5295f6658c7711ba7b4d3ef478a7fbaa&bcevod_channel=searchbox_feed&pd=1&pt=3&abtest=";
|
||||
mPushData.setPoiImgUrl(image);
|
||||
mPushData.setType(0);
|
||||
mPushData.setInfoId("905456829553946624");
|
||||
initView();
|
||||
}
|
||||
|
||||
@@ -50,13 +65,7 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
|
||||
|
||||
public void initView() {
|
||||
setContentView(R.layout.notice_dialog_traffic_police);
|
||||
mVideoPlayer = findViewById(R.id.video_player);
|
||||
thumbnailImage = findViewById(R.id.thumbnail_image);
|
||||
playImageView = this.findViewById(R.id.window_video_play);
|
||||
close = findViewById(R.id.notice_traffic_dialog_close);
|
||||
close.setOnClickListener(v -> {
|
||||
dismiss();
|
||||
});
|
||||
playerShow();
|
||||
//网格绘制
|
||||
try {
|
||||
mRecyclerView = findViewById(R.id.traffic_info_recyclerView);
|
||||
@@ -73,6 +82,67 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
|
||||
NoticeTrafficAdapter adapter = new NoticeTrafficAdapter(mContext);
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i 是否接受交通事故任务
|
||||
* 0不接收 1接受
|
||||
*/
|
||||
private void feedBackTraffic(int i) {
|
||||
CallerNoticeManager.getNoticeProvider().feedBackNoticeTraffic(mPushData.getInfoId(), MoGoAiCloudClientConfig.getInstance().getSn(), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取交通事故详情
|
||||
*/
|
||||
private void requestTrafficInfo() {
|
||||
Log.d(TAG, "requestTrafficInfo");
|
||||
CallerNoticeManager.getNoticeProvider().requestAccidentInfo(mPushData.getInfoId(), MoGoAiCloudClientConfig.getInstance().getSn(), new NoticeNetCallBack() {
|
||||
@Override
|
||||
public void callBackWithResult(NoticeTrafficStyleInfo trafficInfo) {
|
||||
Log.d(TAG, "交通事故详情::" + trafficInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据推送消息渲染顶部图片/视频
|
||||
* type 0图片 1视频
|
||||
*/
|
||||
private void playerShow() {
|
||||
mVideoPlayer = findViewById(R.id.video_player);
|
||||
thumbnailImage = findViewById(R.id.thumbnail_image);
|
||||
playImageView = this.findViewById(R.id.notice_start);
|
||||
playImageView.setOnClickListener(v -> {
|
||||
startLive();
|
||||
});
|
||||
close = findViewById(R.id.notice_traffic_dialog_close);
|
||||
close.setOnClickListener(v -> {
|
||||
dismiss();
|
||||
});
|
||||
if (mPushData.getType() == 1) {
|
||||
firstBitmap = BitmapHelper.getVideoThumbnail(mPushData.getPoiImgUrl());/*获取视频第一帧图*/
|
||||
complete(firstBitmap);
|
||||
playImageView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
MogoApisHandler.getInstance().getApis().getImageLoaderApi().displayImage(mPushData.getPoiImgUrl(),
|
||||
thumbnailImage);
|
||||
thumbnailImage.setImageBitmap(firstBitmap);
|
||||
thumbnailImage.setVisibility(View.VISIBLE);
|
||||
playImageView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
mVideoPlayer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -83,7 +153,7 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
|
||||
}
|
||||
}
|
||||
});
|
||||
// startLive();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +182,7 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
|
||||
/**
|
||||
* 播放结束后
|
||||
*/
|
||||
private void complete(Bitmap firstbitmap, String path) {
|
||||
private void complete(Bitmap firstbitmap) {
|
||||
thumbnailImage.setVisibility(View.VISIBLE);
|
||||
thumbnailImage.setImageBitmap(firstbitmap);
|
||||
playImageView.setImageResource(R.drawable.notice_video_play);
|
||||
@@ -125,7 +195,6 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 视频播放
|
||||
*/
|
||||
@@ -139,118 +208,12 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
|
||||
mVideoPlayer.getStartButton().performClick();
|
||||
thumbnailImage.setVisibility(View.GONE);
|
||||
playImageView.setVisibility(View.GONE);
|
||||
startVideoCallBack(videoUrl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startVideoCallBack(String path) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bitmap firstBitmap = BitmapHelper.getVideoThumbnail(path);/*获取第一帧图*/
|
||||
mVideoPlayer.setVideoAllCallBack(new VideoAllCallBack() {
|
||||
@Override
|
||||
public void onAutoComplete(String url, Object... objects) {
|
||||
complete(firstBitmap, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickResume(String url, Object... objects) {
|
||||
thumbnailImage.setVisibility(View.GONE);
|
||||
playImageView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickStop(String url, Object... objects) {
|
||||
Log.d(TAG, "onClickStop");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartPrepared(String url, Object... objects) {
|
||||
Log.d(TAG, "onStartPrepared");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepared(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickStartIcon(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickStartError(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickStopFullscreen(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickResumeFullscreen(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickSeekbar(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickSeekbarFullscreen(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnterFullscreen(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuitFullscreen(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuitSmallWidget(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnterSmallWidget(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouchScreenSeekVolume(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouchScreenSeekPosition(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouchScreenSeekLight(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayError(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickStartThumb(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickBlank(String url, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickBlankFullscreen(String url, Object... objects) {
|
||||
Log.d(TAG, "onClickBlankFullscreen");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 426 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.9 KiB |
@@ -38,7 +38,6 @@
|
||||
android:layout_marginLeft="@dimen/dp_200"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
android:layout_marginRight="@dimen/dp_200"
|
||||
android:src="@drawable/notice_unsuccess_image"
|
||||
app:layout_constraintBottom_toTopOf="@+id/module_push_dialog_bottom_title"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
@@ -47,25 +46,40 @@
|
||||
<com.mogo.service.imageloader.MogoImageView
|
||||
android:id="@+id/thumbnail_image"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/notice_traffic_acc_image_height"
|
||||
android:layout_marginLeft="@dimen/dp_200"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
android:layout_marginRight="@dimen/dp_200"
|
||||
android:background="@drawable/notice_unsuccess_image"
|
||||
android:layout_height="0dp"
|
||||
android:background="@drawable/notice_unsuccess_traffic"
|
||||
android:scaleType="fitXY"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintBottom_toBottomOf="@id/video_player"
|
||||
app:layout_constraintEnd_toEndOf="@id/video_player"
|
||||
app:layout_constraintStart_toStartOf="@id/video_player"
|
||||
app:layout_constraintTop_toTopOf="@id/video_player" />
|
||||
<!--播放按钮-->
|
||||
<ImageView
|
||||
android:id="@+id/window_video_play"
|
||||
android:id="@+id/notice_start"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_100"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/notice_video_play"
|
||||
android:visibility="gone" />
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@id/video_player"
|
||||
app:layout_constraintLeft_toLeftOf="@id/video_player"
|
||||
app:layout_constraintRight_toRightOf="@id/video_player"
|
||||
app:layout_constraintTop_toTopOf="@id/video_player" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/notice_connect"
|
||||
android:layout_width="@dimen/dp_310"
|
||||
android:layout_height="@dimen/dp_100"
|
||||
android:layout_marginBottom="@dimen/dp_40"
|
||||
android:background="@drawable/notice_connect"
|
||||
android:gravity="center"
|
||||
android:text="连接"
|
||||
android:textColor="#FFF"
|
||||
android:textSize="@dimen/dp_42"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/video_player"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
<!--事故来源等事故详情-->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/traffic_info_recyclerView"
|
||||
@@ -77,8 +91,7 @@
|
||||
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_constraintTop_toBottomOf="@+id/back_image" />
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
<!--分割线-->
|
||||
<ImageView
|
||||
android:id="@+id/traffic_top_line"
|
||||
@@ -99,6 +112,7 @@
|
||||
|
||||
<!--接受 拒绝-->
|
||||
<TextView
|
||||
android:id="@+id/accept_traffic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
@@ -112,6 +126,7 @@
|
||||
app:layout_constraintTop_toTopOf="@+id/traffic_top_line" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/refuse_traffic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
|
||||
Reference in New Issue
Block a user