Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

点击事件冲突 #1

Open
0xhyperdan opened this issue Mar 21, 2017 · 7 comments
Open

点击事件冲突 #1

0xhyperdan opened this issue Mar 21, 2017 · 7 comments

Comments

@0xhyperdan
Copy link

如果列表的item有点击事件。点击整个item的时候 PhotoContents中所有的FoucsClickImageView都会触发前景的点击 整体闪一下。

@razerdp
Copy link
Owner

razerdp commented Mar 21, 2017

好的,我今晚看看

@0xhyperdan
Copy link
Author

嗯,我把列表的Item点击事件用onTouch替代了。

@razerdp
Copy link
Owner

razerdp commented Mar 22, 2017

昨晚看了一下,事实上跟photocontents无关,是FoucsClickImageView的state被改变了,也就是说点击item的时候把事件都传递了下去,然而很奇怪的是,如果我设置了imageview需要在focued时才触发前景色的变化,却发现永远无法获取焦点。。。

所以迟点我打算把imageview不用drawable,而是采取touch+colorFliter的方式。

@0xhyperdan
Copy link
Author

嗯 就是 FoucsClickImageView 我暂时把list的点击事件改成了。onTouch

@razerdp
Copy link
Owner

razerdp commented Mar 22, 2017

ya,你也可以提交一下你的解决方案哦-V- 我现在还在组件化朋友圈的项目,所以这边暂时可能不会提交。

@0xhyperdan
Copy link
Author

private long pressTime = 0;

@Override
public boolean onTouch(View v, MotionEvent event) {
  long upTime;
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      pressTime = System.currentTimeMillis();
      break;
    case MotionEvent.ACTION_UP:
      upTime = System.currentTimeMillis();
      if ((upTime - pressTime) < 200) {
        if (listener != null) {
          listener.onItemClick(mList.get(getAdapterPosition()));
        }
      }
      break;
  }
  return true;
}

}

ViewHolder(View itemView) {
  super(itemView);
  ButterKnife.bind(this, itemView);
  itemView.setOnTouchListener(this);
  mPhotos.setmOnItemClickListener(this);
}

这算是解决方案么

@razerdp
Copy link
Owner

razerdp commented Mar 22, 2017

好的,看起来你这个是从时机应用场景里入手呢,我打算是从库着手(准确说是FoucsClickImageView控件),刚刚把朋友圈项目组件化更新了一下,可以闲下来搞这边的了-V-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants