Skip to content

Commit f429690

Browse files
committed
会议主页视频支持缩放
1 parent edf87c8 commit f429690

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

uikit/src/main/java/cn/wildfire/chat/kit/voip/ResizableFrameLayout.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
/**
1919
* 支持缩放改变子 view 大小的FrameLayout
20+
* 仅支持包含一个子 view
2021
* <p>
2122
*/
2223
public class ResizableFrameLayout extends FrameLayout implements ScaleGestureDetector.OnScaleGestureListener {
@@ -34,7 +35,7 @@ private enum Mode {
3435
private static final float MIN_ZOOM = 1.0f;
3536
private static final float MAX_ZOOM = 4.0f;
3637

37-
private boolean enableZoom = true;
38+
private boolean enableZoom = false;
3839
private boolean enableDrag = true;
3940
private Mode mode = Mode.NONE;
4041
private float scale = 1.0f;
@@ -71,18 +72,15 @@ public ResizableFrameLayout(Context context, AttributeSet attrs, int defStyle) {
7172

7273
private void init(Context context) {
7374
final ScaleGestureDetector scaleDetector = new ScaleGestureDetector(context, this);
74-
Log.d(TAG, "init");
7575
setOnTouchListener(new OnTouchListener() {
7676
@Override
7777
public boolean onTouch(View view, MotionEvent motionEvent) {
78-
Log.d(TAG, "onTouch 000");
7978
if (child() == null) {
8079
return false;
8180
}
82-
if (!enableZoom && !enableDrag) {
81+
if (!enableZoom) {
8382
return false;
8483
}
85-
Log.d(TAG, "onTouch");
8684
int y = (int) motionEvent.getY();
8785
int x = (int) motionEvent.getX();
8886
switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
@@ -145,7 +143,6 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
145143
return true;
146144
}
147145
});
148-
Log.d(TAG, "init end");
149146
}
150147

151148
// ScaleGestureDetector
@@ -223,12 +220,13 @@ private void applyScaleAndTranslation() {
223220
int newWidth = (int) (originalWidth * scale);
224221
int newHeight = (int) (originalHeight * scale);
225222

226-
// 先对原始 view 进行缩放
227-
// view.setScaleX(scale);
228-
// view.setScaleY(scale);
229-
230223
// 设置 view 大小,会触发surfaceView 重新 layout,及 video frame重新渲染
231224
if (lp.width != newWidth || lp.height != newHeight) {
225+
//
226+
// // 先对原始 view 进行缩放
227+
// view.setScaleX(scale);
228+
// view.setScaleY(scale);
229+
//
232230
lp.width = newWidth;
233231
lp.height = newHeight;
234232
view.setLayoutParams(lp);
@@ -259,9 +257,9 @@ public void setEnableZoom(boolean enable) {
259257
this.enableZoom = enable;
260258
}
261259

262-
public void setEnableDrag(boolean enable) {
263-
this.enableDrag = enable;
264-
}
260+
// public void setEnableDrag(boolean enable) {
261+
// this.enableDrag = enable;
262+
// }
265263

266264
public void reset() {
267265
View view = child();

uikit/src/main/java/cn/wildfire/chat/kit/voip/conference/ConferenceParticipantItemVideoView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
import org.webrtc.RendererCommon;
1717

1818
import cn.wildfire.chat.kit.R;
19-
import cn.wildfire.chat.kit.voip.ZoomableFrameLayout;
19+
import cn.wildfire.chat.kit.voip.ResizableFrameLayout;
2020
import cn.wildfirechat.avenginekit.AVEngineKit;
2121
import cn.wildfirechat.remote.ChatManager;
2222

2323
public class ConferenceParticipantItemVideoView extends ConferenceParticipantItemView {
24-
public ZoomableFrameLayout videoContainer;
24+
public ResizableFrameLayout videoContainer;
2525
private boolean enableVideoZoom = false;
2626

2727
private static final RendererCommon.ScalingType scalingType = RendererCommon.ScalingType.SCALE_ASPECT_FIT;

uikit/src/main/res-av/layout/av_conference_participant_grid_item_video.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
android:scaleType="fitXY"
1515
android:src="@mipmap/avatar_def" />
1616

17-
<cn.wildfire.chat.kit.voip.ZoomableFrameLayout
17+
<cn.wildfire.chat.kit.voip.ResizableFrameLayout
1818
android:id="@+id/videoContainer"
1919
android:layout_width="wrap_content"
2020
android:layout_height="wrap_content"
@@ -24,7 +24,7 @@
2424
android:visibility="gone"
2525
app:layout_gravity="center">
2626

27-
</cn.wildfire.chat.kit.voip.ZoomableFrameLayout>
27+
</cn.wildfire.chat.kit.voip.ResizableFrameLayout>
2828

2929
<LinearLayout
3030
android:layout_width="wrap_content"

0 commit comments

Comments
 (0)