[sweeper-cloud]合并凤坤的后置摄像头视频代码

This commit is contained in:
bxb
2023-04-24 18:13:27 +08:00
4 changed files with 113 additions and 9 deletions

View File

@@ -97,11 +97,24 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="@dimen/dp_36"
android:layout_marginTop="@dimen/dp_27">
android:layout_marginTop="@dimen/dp_27"
app:roundLayoutRadius="@dimen/dp_16"
>
<com.mogo.eagle.core.function.hmi.ui.widget.SweeperVideoView
android:id="@+id/sweeper_video_view"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_401"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:src="#999999"/>
<com.mogo.och.sweepercloud.view.WeltSmallMapView
android:id="@+id/sweeper_task_welt_small_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_width="match_parent"
android:layout_height="@dimen/dp_401"
app:layout_constraintTop_toBottomOf="@+id/sweeper_video_view"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</com.mogo.och.common.module.wigets.OCHRoundConstraintLayout>
<ImageView

View File

@@ -97,11 +97,15 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="@dimen/dp_36"
android:layout_marginTop="@dimen/dp_27">
android:layout_marginTop="@dimen/dp_27"
app:roundLayoutRadius="@dimen/dp_16"
>
<com.mogo.och.sweeper.view.WeltSmallMapView
android:id="@+id/sweeper_task_welt_small_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</com.mogo.och.common.module.wigets.OCHRoundConstraintLayout>
<ImageView

View File

@@ -40,10 +40,10 @@ ext {
arouter : "com.alibaba:arouter-api:1.0.12-mogo",
aroutercompiler : "com.alibaba:arouter-compiler:1.0.12-mogo",
// glide
glide : 'com.github.bumptech.glide:glide:4.8.0',
glideokhttp3 : 'com.github.bumptech.glide:okhttp3-integration:4.8.0',
glideanno : 'com.github.bumptech.glide:annotations:4.8.0',
glidecompiler : 'com.github.bumptech.glide:compiler:4.8.0',
glide : 'com.github.bumptech.glide:glide:4.11.0',
glideokhttp3 : 'com.github.bumptech.glide:okhttp3-integration:4.11.0',
glideanno : 'com.github.bumptech.glide:annotations:4.11.0',
glidecompiler : 'com.github.bumptech.glide:compiler:4.11.0',
androidxannotation : "androidx.annotation:annotation:1.2.0",
okhttpinterceptor : "com.squareup.okhttp3:logging-interceptor:3.12.0",
// fresco

View File

@@ -0,0 +1,87 @@
package com.mogo.eagle.core.function.hmi.ui.widget;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.mogo.eagle.core.function.api.autopilot.IMoGoSweeperFutianBackCameraVideoListener;
import com.mogo.eagle.core.function.call.autopilot.CallerSweeperFutianBackCameraVideoListenerManager;
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
/**
* 清扫车摄像头展示View
*/
public class SweeperVideoView extends AppCompatImageView implements IMoGoSweeperFutianBackCameraVideoListener {
private static final String TAG = SweeperVideoView.class.getSimpleName();
private final RequestOptions requestOptions = new RequestOptions()
.priority(Priority.HIGH)
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.dontAnimate();
public SweeperVideoView(@NonNull Context context) {
super(context);
}
public SweeperVideoView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public SweeperVideoView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
CallerSweeperFutianBackCameraVideoListenerManager.INSTANCE.addListener(TAG, this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
CallerSweeperFutianBackCameraVideoListenerManager.INSTANCE.removeListener(this);
}
private final CustomTarget<Bitmap> target = new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
//回调内容
if (!resource.isRecycled()) {
SweeperVideoView.this.setImageBitmap(resource);
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
//这个方法在target被回收时调用如果在除了imageView以外的地方引用了imageView中的bitmap在这里清除引用以避免崩溃
}
};
@Override
public void onSweeperFutianBackCameraVideo(@NonNull byte[] data) {
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
GlideApp.with(SweeperVideoView.this)
.asBitmap()
.load(data)
.placeholder(SweeperVideoView.this.getDrawable())
.apply(requestOptions)
.into(target);
}
});
}
}