Skip to content

Commit 5120b64

Browse files
committed
添加双目Demo入口及实现
Change-Id: I49452b234c7fcd560d4761fa8f6c914800b56837
1 parent 6d95b0e commit 5120b64

File tree

5 files changed

+236
-18
lines changed

5 files changed

+236
-18
lines changed

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/VideoDeviceFragment.kt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@ import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener
1515
import com.tencent.iot.explorer.link.demo.App
1616
import com.tencent.iot.explorer.link.demo.R
1717
import com.tencent.iot.explorer.link.demo.core.fragment.BaseFragment
18-
import com.tencent.iot.explorer.link.demo.video.playback.VideoPlaybackActivity
19-
import com.tencent.iot.explorer.link.demo.video.preview.DevUrl2Preview
2018
import com.tencent.iot.explorer.link.demo.video.nvr.VideoNvrActivity
21-
import com.tencent.iot.explorer.link.demo.video.preview.VideoMultiPreviewActivity
22-
import com.tencent.iot.explorer.link.demo.video.preview.VideoPreviewActivity
23-
import com.tencent.iot.explorer.link.demo.video.preview.VideoPreviewMJPEGActivity
24-
import com.tencent.iot.explorer.link.demo.video.preview.VideoWithoutPropertyActivity
25-
import com.tencent.iot.explorer.link.demo.video.preview.VideoPushStreamActivity
19+
import com.tencent.iot.explorer.link.demo.video.playback.VideoPlaybackActivity
20+
import com.tencent.iot.explorer.link.demo.video.preview.*
2621
import com.tencent.iot.explorer.link.demo.video.utils.ListOptionsDialog
22+
import com.tencent.iot.explorer.link.demo.video.utils.MultipleChannelChooseDialog
2723
import com.tencent.iot.explorer.link.demo.video.utils.ToastDialog
2824
import com.tencent.iot.video.link.callback.VideoCallback
2925
import com.tencent.iot.video.link.consts.VideoConst
@@ -129,20 +125,36 @@ class VideoDeviceFragment : BaseFragment(), VideoCallback, DevsAdapter.OnItemCli
129125
return
130126
}
131127

132-
var options = arrayListOf(getString(R.string.preview), getString(R.string.playback), getString(R.string.preview_mjpeg), getString(R.string.video_without_property), getString(R.string.video_push_stream))
128+
var options = arrayListOf(getString(R.string.preview), getString(R.string.playback), getString(R.string.preview_mjpeg), getString(R.string.video_without_property), getString(R.string.video_push_stream), getString(R.string.multiple_channel_choose))
133129
var dlg =
134130
ListOptionsDialog(
135131
context,
136132
options
137133
)
138134
dlg.show()
139-
dlg.setOnDismisListener {
135+
dlg.setOnDismisListener { it ->
140136
when(it) {
141137
0 -> { VideoPreviewActivity.startPreviewActivity(context, dev) }
142138
1 -> { VideoPlaybackActivity.startPlaybackActivity(context, dev) }
143139
2 -> { VideoPreviewMJPEGActivity.startPreviewActivity(context, dev) }
144140
3 -> { VideoWithoutPropertyActivity.startPreviewActivity(context, dev) }
145141
4 -> { VideoPushStreamActivity.startPreviewActivity(context, dev) }
142+
5 -> {
143+
val multipleChannelChooseDialog = MultipleChannelChooseDialog(context)
144+
multipleChannelChooseDialog.show()
145+
multipleChannelChooseDialog.setOnDismisListener { selectChannels ->
146+
var allUrl = ArrayList<DevUrl2Preview>()
147+
for (i in 0 until selectChannels.size) {
148+
var device = DevUrl2Preview()
149+
device.devName = dev.DeviceName
150+
device.Status = 1
151+
device.channel = selectChannels[i]
152+
allUrl.add(device)
153+
}
154+
155+
VideoMultiPreviewActivity.startMultiPreviewActivity(context, allUrl)
156+
}
157+
}
146158
}
147159
}
148160
}

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoMultiPreviewActivity.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,23 @@ class VideoMultiPreviewActivity : VideoBaseActivity(), XP2PCallback, CoroutineSc
214214
var holders = getHolderById(id)
215215
for (i in 0 until holders.size) {
216216
Thread(Runnable {
217-
App.data.accessInfo?.let {
218-
var command = Command.getNvrIpcStatus(holders.get(i).channel, 0)
219-
var repStatus = XP2P.postCommandRequestSync("${it.productId}/${holders.get(i).devName}",
220-
command.toByteArray(), command.toByteArray().size.toLong(), 2 * 1000 * 1000)
221-
JSONArray.parseArray(repStatus, DevStatus::class.java)?.let {
222-
if (it.size == 1 && it.get(0).status == 0) {
223-
countDownLatchs.get("${id}/${holders.get(i).channel}")?.let {
224-
it.countDown()
217+
Timer().schedule(object : TimerTask() {
218+
override fun run() {
219+
App.data.accessInfo?.let {
220+
var command = Command.getNvrIpcStatus(holders.get(i).channel, 0)
221+
var repStatus = XP2P.postCommandRequestSync("${it.productId}/${holders.get(i).devName}",
222+
command.toByteArray(), command.toByteArray().size.toLong(), 2 * 1000 * 1000)
223+
JSONArray.parseArray(repStatus, DevStatus::class.java)?.let {
224+
if (it.size == 1 && it.get(0).status == 0) {
225+
countDownLatchs.get("${id}/${holders.get(i).channel}")?.let {
226+
it.countDown()
227+
}
228+
}
225229
}
226230
}
227231
}
228-
}
232+
233+
}, 500)
229234
}).start()
230235
}
231236
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.tencent.iot.explorer.link.demo.video.utils;
2+
3+
import android.content.Context;
4+
import android.util.Log;
5+
import android.view.View;
6+
import android.widget.CheckBox;
7+
import android.widget.Toast;
8+
9+
import com.tencent.iot.explorer.link.demo.R;
10+
11+
import java.util.ArrayList;
12+
13+
public class MultipleChannelChooseDialog extends IosCenterStyleDialog implements View.OnClickListener {
14+
15+
private CheckBox mCbChannel1;
16+
private CheckBox mCbChannel2;
17+
private CheckBox mCbChannel3;
18+
private CheckBox mCbChannel4;
19+
20+
public MultipleChannelChooseDialog(Context context) {
21+
super(context, R.layout.popup_multiple_channel_layout);
22+
}
23+
24+
@Override
25+
public void initView() {
26+
super.initView();
27+
28+
mCbChannel1 = view.findViewById(R.id.cb_channel1);
29+
mCbChannel2 = view.findViewById(R.id.cb_channel2);
30+
mCbChannel3 = view.findViewById(R.id.cb_channel3);
31+
mCbChannel4 = view.findViewById(R.id.cb_channel4);
32+
33+
view.findViewById(R.id.tv_multiple_cancel).setOnClickListener(this);
34+
view.findViewById(R.id.tv_multiple_confirm).setOnClickListener(this);
35+
}
36+
37+
@Override
38+
public void onClick(View view) {
39+
switch (view.getId()) {
40+
case R.id.tv_multiple_cancel:
41+
dismiss();
42+
break;
43+
case R.id.tv_multiple_confirm:
44+
Log.d("MultipleChannelChoose", "checkbox selected: channel0: " + mCbChannel1.isChecked()
45+
+ ", channel1: " + mCbChannel2.isChecked() + ", channel2: " + mCbChannel3.isChecked() + ", channel3: " + mCbChannel4.isChecked());
46+
ArrayList<Integer> selectChannels = new ArrayList<>();
47+
if (mCbChannel1.isChecked()) selectChannels.add(1);
48+
if (mCbChannel2.isChecked()) selectChannels.add(2);
49+
if (mCbChannel3.isChecked()) selectChannels.add(3);
50+
if (mCbChannel4.isChecked()) selectChannels.add(4);
51+
if (selectChannels.size() != 0) {
52+
if (onDismisListener != null) {
53+
onDismisListener.onDismissed(selectChannels);
54+
}
55+
dismiss();
56+
} else {
57+
Toast.makeText(getContext(), "请选择要观看的channels", Toast.LENGTH_SHORT).show();
58+
}
59+
break;
60+
}
61+
}
62+
63+
private OnDismisListener onDismisListener;
64+
65+
public interface OnDismisListener {
66+
void onDismissed(ArrayList<Integer> selectChannels);
67+
}
68+
69+
public void setOnDismisListener(OnDismisListener onDismisListener) {
70+
this.onDismisListener = onDismisListener;
71+
}
72+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:id="@+id/multiply_channel_layout"
6+
android:background="#AA333333"
7+
xmlns:app="http://schemas.android.com/apk/res-auto">
8+
9+
<RelativeLayout
10+
android:id="@+id/tip_layout"
11+
android:layout_width="0dp"
12+
android:layout_height="wrap_content"
13+
android:paddingTop="20dp"
14+
android:layout_marginEnd="28dp"
15+
android:layout_marginStart="28dp"
16+
android:background="@color/white"
17+
app:layout_constraintBottom_toBottomOf="parent"
18+
app:layout_constraintEnd_toEndOf="parent"
19+
app:layout_constraintStart_toStartOf="parent"
20+
app:layout_constraintTop_toTopOf="parent"
21+
>
22+
23+
<TextView
24+
android:id="@+id/tip_title"
25+
android:textSize="@dimen/ts_16"
26+
android:textColor="@color/black_15161A"
27+
android:layout_width="wrap_content"
28+
android:layout_marginStart="24dp"
29+
android:layout_height="wrap_content"
30+
android:text="@string/channel_choose"/>
31+
32+
<RelativeLayout
33+
android:id="@+id/rl_content"
34+
android:layout_width="match_parent"
35+
android:layout_height="212dp"
36+
android:layout_below="@id/tip_title"
37+
android:layout_centerHorizontal="true"
38+
android:layout_marginStart="24dp"
39+
android:layout_marginTop="20dp"
40+
android:layout_marginEnd="24dp"
41+
android:layout_marginBottom="20dp">
42+
43+
<CheckBox
44+
android:id="@+id/cb_channel1"
45+
android:layout_width="120dp"
46+
android:layout_height="wrap_content"
47+
android:lineSpacingMultiplier="1.0"
48+
android:textSize="@dimen/ts_14"
49+
android:text="channel 1"/>
50+
51+
<CheckBox
52+
android:id="@+id/cb_channel2"
53+
android:layout_width="120dp"
54+
android:layout_height="wrap_content"
55+
android:layout_toRightOf="@id/cb_channel1"
56+
android:lineSpacingMultiplier="1.0"
57+
android:textSize="@dimen/ts_14"
58+
android:text="channel 2"/>
59+
60+
<CheckBox
61+
android:id="@+id/cb_channel3"
62+
android:layout_width="120dp"
63+
android:layout_height="wrap_content"
64+
android:layout_below="@id/cb_channel1"
65+
android:lineSpacingMultiplier="1.0"
66+
android:textSize="@dimen/ts_14"
67+
android:text="channel 3"/>
68+
69+
<CheckBox
70+
android:id="@+id/cb_channel4"
71+
android:layout_width="120dp"
72+
android:layout_height="wrap_content"
73+
android:layout_below="@id/cb_channel1"
74+
android:layout_toRightOf="@id/cb_channel3"
75+
android:lineSpacingMultiplier="1.0"
76+
android:textSize="@dimen/ts_14"
77+
android:text="channel 4"/>
78+
79+
</RelativeLayout>
80+
81+
<View
82+
android:id="@+id/divid_line"
83+
android:layout_width="match_parent"
84+
android:layout_below="@id/rl_content"
85+
android:layout_centerHorizontal="true"
86+
android:layout_marginTop="20dp"
87+
android:layout_height="1dp"/>
88+
89+
<View
90+
android:id="@+id/divid_line_v"
91+
android:layout_below="@id/divid_line"
92+
android:layout_width="1dp"
93+
android:layout_height="48dp"
94+
android:layout_centerHorizontal="true"
95+
/>
96+
97+
<TextView
98+
android:id="@+id/tv_multiple_confirm"
99+
android:layout_below="@id/divid_line"
100+
android:layout_toRightOf="@id/divid_line_v"
101+
android:layout_width="match_parent"
102+
android:background="@drawable/background_blue_btn"
103+
android:textSize="@dimen/ts_16"
104+
android:text="@string/confirm"
105+
android:textColor="@color/white"
106+
android:gravity="center"
107+
android:layout_alignTop="@id/divid_line_v"
108+
android:layout_alignBottom="@id/divid_line_v"
109+
android:layout_height="wrap_content"/>
110+
111+
<TextView
112+
android:id="@+id/tv_multiple_cancel"
113+
android:layout_below="@id/divid_line"
114+
android:layout_toLeftOf="@id/divid_line_v"
115+
android:layout_width="match_parent"
116+
android:textSize="@dimen/ts_16"
117+
android:text="@string/cancel"
118+
android:gravity="center"
119+
android:layout_alignTop="@id/divid_line_v"
120+
android:layout_alignBottom="@id/divid_line_v"
121+
android:layout_height="wrap_content"/>
122+
123+
</RelativeLayout>
124+
125+
</androidx.constraintlayout.widget.ConstraintLayout>

sdkdemo/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,8 @@
194194
<string name="download_fail">下载失败</string>
195195
<string name="downloading">下载中</string>
196196

197+
<!-- 多通道选择 -->
198+
<string name="multiple_channel_choose">多通道选择</string>
199+
<string name="channel_choose">通道选择: </string>
200+
197201
</resources>

0 commit comments

Comments
 (0)