Skip to content

Commit

Permalink
Add English code annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dokieyang committed Aug 29, 2023
1 parent 86b8299 commit 7cee917
Show file tree
Hide file tree
Showing 102 changed files with 2,234 additions and 1,493 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bun
public void onActivityDestroyed(@NonNull Activity activity) {
final int taskId = activity.getTaskId();
mActivityList.remove(activity);
// 移除无用的taskId
// Remove useless `taskId`.
boolean removeFlag = true;
for (Activity tmpAct : mActivityList) {
if (null != tmpAct && !tmpAct.isDestroyed() && !tmpAct.isFinishing() && tmpAct.getTaskId() == taskId) {
Expand All @@ -121,7 +121,7 @@ public void onActivityDestroyed(@NonNull Activity activity) {
}
}
if (removeFlag) {
// valueOf装箱,根据对象移除
// Boxing of `valueOf`, remove according to the object.
mAppTaskIds.remove(Integer.valueOf(taskId));
}
}
Expand Down
12 changes: 10 additions & 2 deletions Demo/app/src/main/java/com/tencent/liteav/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void onClick(DialogInterface dialog, int which) {
private List<GroupBean> initGroupData() {
List<GroupBean> groupList = new ArrayList<>();

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

/**
* Check if there are any activities after this activity. If so, launch them.
* MainActivity must be the root activity. This method checks whether there are other activities below the current
* activity sequence of the app. If so, it means that the app's activity has been moved to another task stack due
* to other reasons and is in the background. At this time, the activity needs to be brought to the foreground.
* For example, on some models, enabling picture-in-picture mode will cause the PIP activity to move to a new
* task stack. Clicking the icon on the desktop will not return to the previous activity. At this time,
* this method needs to be used to bring it up.
*
* 检查是否有在该activity之后的activity,如果有则拉起。
* MainActivity肯定是root Activity,该方法会检查是否有其他activity位于当前activity顺序之下,如果有则代表app的activity因为其他原因
* 跑到了其他任务栈中,并且位于后台。此时则需要将该activity拉到前台。
Expand All @@ -423,7 +431,7 @@ private void checkIsHaveBackContext() {
if (demoApplication.isUsActivity(taskId)) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || taskInfo.isRunning) {
ComponentName componentName = taskInfo.topActivity;
// 拉起当前app栈顶第一个activity
// Bring up the first activity at the top of the current app stack.
Intent intent = new Intent();
intent.setComponent(componentName);
intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
Expand Down
16 changes: 11 additions & 5 deletions Demo/app/src/main/java/com/tencent/liteav/demo/TXCSDKService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@

public class TXCSDKService {
private static final String TAG = "TXCSDKService";
// Please refer to the official website guide for how to obtain the
// license: https://cloud.tencent.com/document/product/454/34750
// 如何获取License? 请参考官网指引 https://cloud.tencent.com/document/product/454/34750
private static final String licenceUrl =
"请替换成您的licenseUrl";
private static final String licenseKey = "请替换成您的licenseKey";
private static final String licenceUrl = "Please replace it with your licenseUrl";
private static final String licenseKey = "Please replace it with your licenseKey";

private static final String XMAGIC_AUTH_KEY = "Please replace it with your licenseKey";
private static final String XMAGIC_AUTH_LICENCE_URL = "Please replace it with your licenseUrl";

private TXCSDKService() {
}

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

// 短视频licence设置
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ public void onRequestPermissionsResult(int requestCode
feedView.onRequestPermissionsResult(requestCode,grantResults);
}

/**
* 加载更多数据
*/
private void loadMore() {
feedVodListLoader.loadListData(page + 1, new FeedVodListLoader.LoadDataCallBack() {
@Override
Expand All @@ -135,10 +132,8 @@ public void onError(int errorCode) {
protected void onResume() {
super.onResume();
feedView.onResume();
//添加屏幕常亮
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
if (isFullScreen) {
//隐藏虚拟按键,并且全屏
View decorView = getWindow().getDecorView();
if (decorView == null) {
return;
Expand All @@ -157,7 +152,6 @@ protected void onResume() {
protected void onPause() {
super.onPause();
feedView.onPause();
//清楚屏幕常亮
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ public class FeedPlayerManager {


/**
* 将正在播放的item添加进来
* Add the currently playing item.
*
* @param playerView
* @param position
* 将正在播放的item添加进来
*/
public void setPlayingFeedPlayerView(FeedPlayerView playerView, int position) {
if (lastPosition == position) {
Expand Down Expand Up @@ -83,9 +82,12 @@ public boolean isPlaying() {


/**
* Set full-screen mode to window mode.
*
* 将全屏模式设置为窗口模式
*
* @return true 表示消费了此次事件,
* @return true Indicates that this event has been consumed
* 表示消费了此次事件,
*/
public boolean setWindowPlayMode() {
if (feedPlayerView != null && feedPlayerView.isFullScreenPlay()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,69 +41,49 @@ public FeedView(Context context, AttributeSet attrs, int defStyleAttr) {
initViews();
}

/**
* 初始化界面元素
*/
private void initViews() {
feedListView = new FeedListView(getContext());
feedListView.setFeedListCallBack(this);
addView(feedListView);
}


/**
* 设置回调接口
*
* @param callBack
*/
public void setFeedViewCallBack(FeedViewCallBack callBack) {
feedViewCallBack = callBack;
}


/**
* 添加数据
*
* @param videoModels 数据列表
* @param isCleanData 是否清理之前的数据
*/
public void addData(List<VideoModel> videoModels, boolean isCleanData) {
feedListView.addData(videoModels, isCleanData);
}


/**
* End pull-down refresh.
*
* 结束下拉刷新
*
* @param success
* @param success Whether to mark this refresh as successful.
* 本次刷新是否置为成功
*/
public void finishRefresh(boolean success) {
feedListView.finishRefresh(success);
}

/**
* 结束上拉加载
* End pull-up load.
*
* @param success
* @param noMoreData
* 结束上拉加载
*/
public void finishLoadMore(boolean success, boolean noMoreData) {
feedListView.finishLoadMore(success, noMoreData);
}

/**
* 播放
*/
public void onResume() {
if (feedListItemView != null) {
feedListItemView.setIsPaused(false);
}
feedListView.onResume();
}

/**
* 暂停
*/
public void onPause() {
if (feedListItemView != null) {
feedListItemView.setIsPaused(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@


/**
* 详情页面recycleview 的adapter
* Adapter for the details page RecyclerView.
* 详情页面recycleView 的adapter
*/
public class FeedDetailAdapter extends RecyclerView.Adapter<FeedDetailAdapter.FeedDetailItemHolder> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.util.List;

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

/**
* Set video description information.
* 设置视频的描述信息
*
* @param videoModel
Expand All @@ -108,6 +111,7 @@ private void setVideoDescription(VideoModel videoModel) {
}

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


/**
* 添加详情页面到feedview中
*
* Add detail page to feed view.
* 添加详情页面到feedView中
*/
public void showDetailView(final VideoModel videoModel) {
feedPlayerView.post(new Runnable() {
Expand All @@ -129,7 +133,6 @@ public void run() {
playerViewHeight = feedPlayerView.getHeight() * phoneWidth / feedPlayerView.getWidth();
}
});
//设置新的callback回调
feedPlayerView.setFeedPlayerCallBack(new FeedPlayerView.FeedPlayerCallBack() {
@Override
public void onStartFullScreenPlay() {
Expand Down Expand Up @@ -159,6 +162,8 @@ public void onClickSmallReturnBtn() {


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

/**
* Clear page data.
* 对页面数据进行清除
*/
public void destroy() {
isDestroy = true;
//清理描述信息
headImg.setImageResource(0);
titleTxt.setText("");
descriptionTxt.setText("");
detailDescriptionTxt.setText("");
//清理掉列表数据
if (recyclerView != null && recyclerView.getChildCount() > 0) {
recyclerView.removeAllViews();
feedDetailAdapter.setFeedEntityList(null);
Expand All @@ -193,7 +197,8 @@ public void destroy() {
}

/**
* 当此页面从父控件移除的时候调用,
* Called when this page is removed from its parent view.
* 当此页面从父控件移除的时候调用
*/
@Override
protected void onDetachedFromWindow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public FeedListAdapter(Context context, FeedListItemView.FeedListItemViewCallBac
int videoViewWidth = (int) (context.getResources().getDisplayMetrics().widthPixels - dp2px(context, 20));
int videoViewHeight = videoViewWidth * 9 / 16;
mListItemHeight = (int) (videoViewHeight + dp2px(context, 20 + 55));
// recyclerView目前最多会创建11个,这里选择预缓存12个
mFeedViewManager = new FeedViewManager(context, mListItemHeight, 12);
}

Expand All @@ -39,10 +38,13 @@ public int getListItemHeight() {
}

/**
* Add data.
* 添加数据
*
* @param videoModels 数据列表
* @param isCleanData TRUE 表示清理之前的数据
* @param videoModels Data list.
* 数据列表
* @param isCleanData TRUE Represents data before clearing.
* TRUE 表示清理之前的数据
*/
public void addVideoData(List<VideoModel> videoModels, boolean isCleanData) {
if (isCleanData) {
Expand Down Expand Up @@ -109,7 +111,8 @@ public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
}

/**
* 此处可以对itemView进行还原处理,
* Here, itemView can be restored.
* 此处可以对itemView进行还原处理
*
* @param holder
*/
Expand Down
Loading

0 comments on commit 7cee917

Please sign in to comment.