Skip to content

Commit 7cee917

Browse files
author
dokieyang
committed
Add English code annotations.
1 parent 86b8299 commit 7cee917

File tree

102 files changed

+2234
-1493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2234
-1493
lines changed

Demo/app/src/main/java/com/tencent/liteav/demo/DemoApplication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bun
112112
public void onActivityDestroyed(@NonNull Activity activity) {
113113
final int taskId = activity.getTaskId();
114114
mActivityList.remove(activity);
115-
// 移除无用的taskId
115+
// Remove useless `taskId`.
116116
boolean removeFlag = true;
117117
for (Activity tmpAct : mActivityList) {
118118
if (null != tmpAct && !tmpAct.isDestroyed() && !tmpAct.isFinishing() && tmpAct.getTaskId() == taskId) {
@@ -121,7 +121,7 @@ public void onActivityDestroyed(@NonNull Activity activity) {
121121
}
122122
}
123123
if (removeFlag) {
124-
// valueOf装箱,根据对象移除
124+
// Boxing of `valueOf`, remove according to the object.
125125
mAppTaskIds.remove(Integer.valueOf(taskId));
126126
}
127127
}

Demo/app/src/main/java/com/tencent/liteav/demo/MainActivity.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void onClick(DialogInterface dialog, int which) {
144144
private List<GroupBean> initGroupData() {
145145
List<GroupBean> groupList = new ArrayList<>();
146146

147-
// 初始化播放器
147+
// Initialize the player.
148148
List<ChildBean> playerChildList = new ArrayList<>();
149149
playerChildList.add(new ChildBean(getString(R.string.app_item_super_player), R.drawable.play, 3, SuperPlayerActivity.class));
150150
playerChildList.add(new ChildBean(getString(R.string.app_vod_player), R.drawable.play,
@@ -402,6 +402,14 @@ private File zip(List<String> files, String zipFileName) {
402402
}
403403

404404
/**
405+
* Check if there are any activities after this activity. If so, launch them.
406+
* MainActivity must be the root activity. This method checks whether there are other activities below the current
407+
* activity sequence of the app. If so, it means that the app's activity has been moved to another task stack due
408+
* to other reasons and is in the background. At this time, the activity needs to be brought to the foreground.
409+
* For example, on some models, enabling picture-in-picture mode will cause the PIP activity to move to a new
410+
* task stack. Clicking the icon on the desktop will not return to the previous activity. At this time,
411+
* this method needs to be used to bring it up.
412+
*
405413
* 检查是否有在该activity之后的activity,如果有则拉起。
406414
* MainActivity肯定是root Activity,该方法会检查是否有其他activity位于当前activity顺序之下,如果有则代表app的activity因为其他原因
407415
* 跑到了其他任务栈中,并且位于后台。此时则需要将该activity拉到前台。
@@ -423,7 +431,7 @@ private void checkIsHaveBackContext() {
423431
if (demoApplication.isUsActivity(taskId)) {
424432
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || taskInfo.isRunning) {
425433
ComponentName componentName = taskInfo.topActivity;
426-
// 拉起当前app栈顶第一个activity
434+
// Bring up the first activity at the top of the current app stack.
427435
Intent intent = new Intent();
428436
intent.setComponent(componentName);
429437
intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);

Demo/app/src/main/java/com/tencent/liteav/demo/TXCSDKService.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,23 @@
88

99
public class TXCSDKService {
1010
private static final String TAG = "TXCSDKService";
11+
// Please refer to the official website guide for how to obtain the
12+
// license: https://cloud.tencent.com/document/product/454/34750
1113
// 如何获取License? 请参考官网指引 https://cloud.tencent.com/document/product/454/34750
12-
private static final String licenceUrl =
13-
"请替换成您的licenseUrl";
14-
private static final String licenseKey = "请替换成您的licenseKey";
14+
private static final String licenceUrl = "Please replace it with your licenseUrl";
15+
private static final String licenseKey = "Please replace it with your licenseKey";
16+
17+
private static final String XMAGIC_AUTH_KEY = "Please replace it with your licenseKey";
18+
private static final String XMAGIC_AUTH_LICENCE_URL = "Please replace it with your licenseUrl";
1519

1620
private TXCSDKService() {
1721
}
1822

1923
/**
24+
* Initialize Tencent Cloud related SDKs.
25+
* During the SDK initialization process, sensitive information such as the mobile phone model may be read,
26+
* which needs to be obtained after the user agrees to the privacy policy.
27+
*
2028
* 初始化腾讯云相关sdk。
2129
* SDK 初始化过程中可能会读取手机型号等敏感信息,需要在用户同意隐私政策后,才能获取。
2230
*
@@ -33,7 +41,5 @@ public void onUpdateNetworkTime(int errCode, String errMsg) {
3341
}
3442
});
3543
TXLiveBase.updateNetworkTime();
36-
37-
// 短视频licence设置
3844
}
3945
}

Demo/feedvideo/src/main/java/com/tencent/liteav/demo/player/demo/FeedActivity.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ public void onRequestPermissionsResult(int requestCode
106106
feedView.onRequestPermissionsResult(requestCode,grantResults);
107107
}
108108

109-
/**
110-
* 加载更多数据
111-
*/
112109
private void loadMore() {
113110
feedVodListLoader.loadListData(page + 1, new FeedVodListLoader.LoadDataCallBack() {
114111
@Override
@@ -135,10 +132,8 @@ public void onError(int errorCode) {
135132
protected void onResume() {
136133
super.onResume();
137134
feedView.onResume();
138-
//添加屏幕常亮
139135
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
140136
if (isFullScreen) {
141-
//隐藏虚拟按键,并且全屏
142137
View decorView = getWindow().getDecorView();
143138
if (decorView == null) {
144139
return;
@@ -157,7 +152,6 @@ protected void onResume() {
157152
protected void onPause() {
158153
super.onPause();
159154
feedView.onPause();
160-
//清楚屏幕常亮
161155
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
162156
}
163157

Demo/feedvideo/src/main/java/com/tencent/liteav/demo/player/demo/feed/FeedPlayerManager.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ public class FeedPlayerManager {
1212

1313

1414
/**
15-
* 将正在播放的item添加进来
15+
* Add the currently playing item.
1616
*
17-
* @param playerView
18-
* @param position
17+
* 将正在播放的item添加进来
1918
*/
2019
public void setPlayingFeedPlayerView(FeedPlayerView playerView, int position) {
2120
if (lastPosition == position) {
@@ -83,9 +82,12 @@ public boolean isPlaying() {
8382

8483

8584
/**
85+
* Set full-screen mode to window mode.
86+
*
8687
* 将全屏模式设置为窗口模式
8788
*
88-
* @return true 表示消费了此次事件,
89+
* @return true Indicates that this event has been consumed
90+
* 表示消费了此次事件,
8991
*/
9092
public boolean setWindowPlayMode() {
9193
if (feedPlayerView != null && feedPlayerView.isFullScreenPlay()) {

Demo/feedvideo/src/main/java/com/tencent/liteav/demo/player/demo/feed/FeedView.java

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,69 +41,49 @@ public FeedView(Context context, AttributeSet attrs, int defStyleAttr) {
4141
initViews();
4242
}
4343

44-
/**
45-
* 初始化界面元素
46-
*/
4744
private void initViews() {
4845
feedListView = new FeedListView(getContext());
4946
feedListView.setFeedListCallBack(this);
5047
addView(feedListView);
5148
}
5249

53-
54-
/**
55-
* 设置回调接口
56-
*
57-
* @param callBack
58-
*/
5950
public void setFeedViewCallBack(FeedViewCallBack callBack) {
6051
feedViewCallBack = callBack;
6152
}
6253

63-
64-
/**
65-
* 添加数据
66-
*
67-
* @param videoModels 数据列表
68-
* @param isCleanData 是否清理之前的数据
69-
*/
7054
public void addData(List<VideoModel> videoModels, boolean isCleanData) {
7155
feedListView.addData(videoModels, isCleanData);
7256
}
7357

7458

7559
/**
60+
* End pull-down refresh.
61+
*
7662
* 结束下拉刷新
7763
*
78-
* @param success
64+
* @param success Whether to mark this refresh as successful.
65+
* 本次刷新是否置为成功
7966
*/
8067
public void finishRefresh(boolean success) {
8168
feedListView.finishRefresh(success);
8269
}
8370

8471
/**
85-
* 结束上拉加载
72+
* End pull-up load.
8673
*
87-
* @param success
88-
* @param noMoreData
74+
* 结束上拉加载
8975
*/
9076
public void finishLoadMore(boolean success, boolean noMoreData) {
9177
feedListView.finishLoadMore(success, noMoreData);
9278
}
9379

94-
/**
95-
* 播放
96-
*/
9780
public void onResume() {
9881
if (feedListItemView != null) {
9982
feedListItemView.setIsPaused(false);
10083
}
10184
feedListView.onResume();
10285
}
10386

104-
/**
105-
* 暂停
106-
*/
10787
public void onPause() {
10888
if (feedListItemView != null) {
10989
feedListItemView.setIsPaused(true);

Demo/feedvideo/src/main/java/com/tencent/liteav/demo/player/demo/feed/feeddetailview/FeedDetailAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919

2020
/**
21-
* 详情页面recycleview 的adapter
21+
* Adapter for the details page RecyclerView.
22+
* 详情页面recycleView 的adapter
2223
*/
2324
public class FeedDetailAdapter extends RecyclerView.Adapter<FeedDetailAdapter.FeedDetailItemHolder> {
2425

Demo/feedvideo/src/main/java/com/tencent/liteav/demo/player/demo/feed/feeddetailview/FeedDetailView.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import java.util.List;
3030

3131
/**
32+
* Details page of the feed stream.
33+
*
3234
* feed流详情页面
3335
*/
3436
public class FeedDetailView extends FrameLayout implements FeedDetailListClickListener {
@@ -39,11 +41,11 @@ public class FeedDetailView extends FrameLayout implements FeedDetailListClickLi
3941
private TextView titleTxt = null;
4042
private TextView descriptionTxt = null;
4143
private TextView detailDescriptionTxt = null;
42-
private boolean isChangeVideo = false; //用于在详情页面是否播放了底部列表的视频,TRUE表示播放了
44+
private boolean isChangeVideo = false;
4345
private FeedPlayerView feedPlayerView = null;
44-
private int playerViewHeight = 0; //PlayerView 的在窗口模式时的高度
45-
private FeedPlayerView.FeedPlayerCallBack feedPlayerCallBack = null; //用于存放之前给FeedPlayerView设置的callBack对象
46-
private RelativeLayout detailLayout = null; //详情页面用于展示视频介绍和视频列表的布局
46+
private int playerViewHeight = 0;
47+
private FeedPlayerView.FeedPlayerCallBack feedPlayerCallBack = null;
48+
private RelativeLayout detailLayout = null;
4749
private boolean isDestroy = false;
4850
private RelativeLayout titleLayout = null;
4951
private Button backButton = null;
@@ -93,6 +95,7 @@ public void onClick(View v) {
9395
}
9496

9597
/**
98+
* Set video description information.
9699
* 设置视频的描述信息
97100
*
98101
* @param videoModel
@@ -108,6 +111,7 @@ private void setVideoDescription(VideoModel videoModel) {
108111
}
109112

110113
/**
114+
* Set data for the bottom list.
111115
* 设置底部列表的数据
112116
*
113117
* @param videoModels
@@ -118,8 +122,8 @@ public void addDetailListData(List<VideoModel> videoModels) {
118122

119123

120124
/**
121-
* 添加详情页面到feedview中
122-
*
125+
* Add detail page to feed view.
126+
* 添加详情页面到feedView中
123127
*/
124128
public void showDetailView(final VideoModel videoModel) {
125129
feedPlayerView.post(new Runnable() {
@@ -129,7 +133,6 @@ public void run() {
129133
playerViewHeight = feedPlayerView.getHeight() * phoneWidth / feedPlayerView.getWidth();
130134
}
131135
});
132-
//设置新的callback回调
133136
feedPlayerView.setFeedPlayerCallBack(new FeedPlayerView.FeedPlayerCallBack() {
134137
@Override
135138
public void onStartFullScreenPlay() {
@@ -159,6 +162,8 @@ public void onClickSmallReturnBtn() {
159162

160163

161164
/**
165+
* When the bottom video list on the detail page is clicked, this event is triggered,
166+
* and video playback can be performed here.
162167
* 当点击详情页面底部视频列表时触发此事件,此时可在此处进行视频播放
163168
*
164169
* @param entity
@@ -175,16 +180,15 @@ public void onItemClickListener(VideoModel entity, int position) {
175180
}
176181

177182
/**
183+
* Clear page data.
178184
* 对页面数据进行清除
179185
*/
180186
public void destroy() {
181187
isDestroy = true;
182-
//清理描述信息
183188
headImg.setImageResource(0);
184189
titleTxt.setText("");
185190
descriptionTxt.setText("");
186191
detailDescriptionTxt.setText("");
187-
//清理掉列表数据
188192
if (recyclerView != null && recyclerView.getChildCount() > 0) {
189193
recyclerView.removeAllViews();
190194
feedDetailAdapter.setFeedEntityList(null);
@@ -193,7 +197,8 @@ public void destroy() {
193197
}
194198

195199
/**
196-
* 当此页面从父控件移除的时候调用,
200+
* Called when this page is removed from its parent view.
201+
* 当此页面从父控件移除的时候调用
197202
*/
198203
@Override
199204
protected void onDetachedFromWindow() {

Demo/feedvideo/src/main/java/com/tencent/liteav/demo/player/demo/feed/feedlistview/FeedListAdapter.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public FeedListAdapter(Context context, FeedListItemView.FeedListItemViewCallBac
3030
int videoViewWidth = (int) (context.getResources().getDisplayMetrics().widthPixels - dp2px(context, 20));
3131
int videoViewHeight = videoViewWidth * 9 / 16;
3232
mListItemHeight = (int) (videoViewHeight + dp2px(context, 20 + 55));
33-
// recyclerView目前最多会创建11个,这里选择预缓存12个
3433
mFeedViewManager = new FeedViewManager(context, mListItemHeight, 12);
3534
}
3635

@@ -39,10 +38,13 @@ public int getListItemHeight() {
3938
}
4039

4140
/**
41+
* Add data.
4242
* 添加数据
4343
*
44-
* @param videoModels 数据列表
45-
* @param isCleanData TRUE 表示清理之前的数据
44+
* @param videoModels Data list.
45+
* 数据列表
46+
* @param isCleanData TRUE Represents data before clearing.
47+
* TRUE 表示清理之前的数据
4648
*/
4749
public void addVideoData(List<VideoModel> videoModels, boolean isCleanData) {
4850
if (isCleanData) {
@@ -109,7 +111,8 @@ public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
109111
}
110112

111113
/**
112-
* 此处可以对itemView进行还原处理,
114+
* Here, itemView can be restored.
115+
* 此处可以对itemView进行还原处理
113116
*
114117
* @param holder
115118
*/

0 commit comments

Comments
 (0)