完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我看了一下代码,这个是google原来的代码就是在这样设计的,很奇怪,那个x的图标并没有做点击监控,他点击响应的是整个taskview
下面是点击时的处理代码 frameworks/base/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java @Override public void onClick(View v) { try { if (mTaskCardView.isInDismissState()) {//判断是否处于dismissstate,如处于则removeTask mTaskCardView.startDismissTaskAnimation( getRemoveAtListener(getAdapterPosition(), mTaskCardView.getTask())); } else {//否则launcherTask EventBus.getDefault().send(new LaunchTvTaskEvent(mTaskCardView, mTask, null, INVALID_STACK_ID)); } } catch (Exception e) { Log.e(TAG, v.getContext() .getString(R.string.recents_launch_error_message, mTask.title), e); } } 而如何处于DismiaaState呢看一下代码 frameworks/base/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskCardView.java @Override public boolean dispatchKeyEvent(KeyEvent event) { // Override dispatchKeyEvent() instead of onKeyDown() to prevent warning from ViewRootImpl. switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_DOWN : { if (!isInDismissState() && event.getAction() == KeyEvent.ACTION_DOWN) { setDismissState(true);//设DismissState = true return true; } break; } case KeyEvent.KEYCODE_DPAD_UP : { if (event.getAction() == KeyEvent.ACTION_DOWN) { if (isInDismissState()) { setDismissState(false); } else { ((RecentsTvActivity) getContext()).requestPipControlsFocus(); } } return true; } // Eat right and left key presses when we are in dismiss state case KeyEvent.KEYCODE_DPAD_LEFT : case KeyEvent.KEYCODE_DPAD_RIGHT : { if (isInDismissState()) { return true; } break; } } return super.dispatchKeyEvent(event); } 所以,很奇怪不知道为啥google这样设计的,但是确实是这样的。后面的话,我会做一下修改,改掉这个问题 |
|
|
|
后来又看了下,这个不是google自带的,是rk后加的,估计是为了tvbox操作的。但是没有考虑触摸操作和鼠标操作的场景
|
|
|
|
修改如下,以下是Git修改记录:
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java b/frameworks/base/pa index 236d077..8b2f31b 100644 --- a/frameworks/base/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java +++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java @@ -21,6 +21,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import com.android.systemui.R; import com.android.systemui.recents.Recents; @@ -36,6 +37,7 @@ import java.util.List; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; + public class TaskStackHorizontalViewAdapter extends RecyclerView.Adapter @@ -47,31 +49,46 @@ public class TaskStackHorizontalViewAdapter extends public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ private TaskCardView mTaskCardView; private Task mTask; + private ImageView dismissIcon; + public ViewHolder(View v) { super(v); mTaskCardView = (TaskCardView) v; + dismissIcon = (ImageView) v.findViewById(R.id.dismiss_icon); } public void init(Task task) { mTaskCardView.init(task); mTask = task; mTaskCardView.setOnClickListener(this); + dismissIcon.setOnClickListener(this); } @Override public void onClick(View v) { - try { - if (mTaskCardView.isInDismissState()) { - mTaskCardView.startDismissTaskAnimation( - getRemoveAtListener(getAdapterPosition(), mTaskCardView.getTask())); - } else { - EventBus.getDefault().send(new LaunchTvTaskEvent(mTaskCardView, mTask, - null, INVALID_STACK_ID)); - } - } catch (Exception e) { - Log.e(TAG, v.getContext() - .getString(R.string.recents_launch_error_message, mTask.title), e); - } + if(v == mTaskCardView) { // 遥控器选择X按钮,modify by ZZP + try { + if (mTaskCardView.isInDismissState()) { + mTaskCardView.startDismissTaskAnimation( + getRemoveAtListener(getAdapterPosition(), mTaskCardView.getTask())); + } else { + EventBus.getDefault().send(new LaunchTvTaskEvent(mTaskCardView, mTask, + null, INVALID_STACK_ID)); + } + } catch (Exception e) { + Log.e(TAG, v.getContext() + .getString(R.string.recents_launch_error_message, mTask.title), e); + } + } else if(v == dismissIcon){ // 鼠标点击X按钮 + try{ + mTaskCardView.startDismissTaskAnimation( + getRemoveAtListener(getAdapterPosition(), mTaskCardView.getTask())); + } catch(Exception e) { + Log.e(TAG, v.getContext() + .getString(R.string.recents_launch_error_message, mTask.title), e); + } + } + } |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
基于米尔瑞芯微RK3576核心板/开发板的人脸疲劳检测应用方案
678 浏览 0 评论
920 浏览 1 评论
814 浏览 1 评论
2030 浏览 1 评论
3275 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 22:47 , Processed in 0.608553 second(s), Total 75, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号