Skip to content

Commit

Permalink
修复向左向右播放
Browse files Browse the repository at this point in the history
添加节目单功能,按菜单键即可呼出
  • Loading branch information
Zcodeoooo committed Jan 13, 2024
1 parent 3be2e3d commit 21945d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.List;

public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.ChannelViewHolder> {
private int selectedItem = -1; // 用于跟踪选中的项
private int selectedItem = 0; // 用于跟踪选中的项

private List<EpgInfo> channelList;
private OnItemClickListener onItemClickListener;
Expand Down Expand Up @@ -48,11 +48,12 @@ public void onBindViewHolder(ChannelViewHolder holder, int position) {
holder.channelNameTextView.setBackgroundResource(R.drawable.channel_background_selected);
holder.channelNameTextView.setTextColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.text_color));
}
recyclerView.requestFocus(); // 将焦点设置到 RecyclerView

EpgInfo channel = channelList.get(position);
holder.bind(channel);
Log.d("ChannelAdapterxx", "Bound channel: " + channel.getName());
holder.channelNameTextView.setOnKeyListener((v, keyCode, event) -> {
notifyDataSetChanged();
int action = event.getAction();
if (event.getAction() == KeyEvent.ACTION_DOWN){
switch (keyCode) {
Expand Down Expand Up @@ -82,6 +83,7 @@ public void onBindViewHolder(ChannelViewHolder holder, int position) {
+ "document.querySelector('#" + epgInfo.getId() + "')" + ".click();"+"}"+"xx()"
, null);
return true;

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ function sleep(ms) {
}
async function playback(offset){
document.querySelector('#play_or_plause_player').click();
await sleep(500);
const targetElement = document.querySelector("#timeshift_pointer_player")
const xy = document.querySelector("#timeshift_pointer_player").getClientRects()[0]
console.log(xy)
Expand All @@ -484,7 +486,10 @@ async function playback(offset){


Log.d("recyclerView.hasFocus()",recyclerView.hasFocus()+"xxx");
Log.d("recyclerView.hasFocus()",webView.hasFocus()+"xxx");

if (!recyclerView.hasFocus()&&event.getAction() == KeyEvent.ACTION_DOWN) {
channelAdapter.notifyDataSetChanged();
Log.d("ACTION_DOWN","ACTION进入了");
if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP || event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN || event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT || event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT || event.getKeyCode() == KeyEvent.KEYCODE_ENTER || event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER || event.getKeyCode() == KeyEvent.KEYCODE_MENU) {
if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP) {
Expand Down Expand Up @@ -514,7 +519,6 @@ async function playback(offset){
""",null);
} else if (event.getKeyCode() == KeyEvent.KEYCODE_MENU) {
recyclerView.setVisibility(View.VISIBLE);
recyclerView.requestFocus(); // 将焦点设置到 RecyclerView
return false; // 返回 true 表示事件已处理,不传递给 WebView
}
return true; // 返回 true 表示事件已处理,不传递给 WebView
Expand Down

0 comments on commit 21945d2

Please sign in to comment.