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

侧滑成功返回上个页面后怎么监听呢 #12

Open
candrwow opened this issue Apr 19, 2017 · 11 comments
Open

侧滑成功返回上个页面后怎么监听呢 #12

candrwow opened this issue Apr 19, 2017 · 11 comments

Comments

@candrwow
Copy link

onDragStateChange这个好像只能获取state 0 1 2,但是这个并不能完全确定是否成功返回了

@candrwow
Copy link
Author

因为我需要在监听到返回成功之后需要修改上个页面的主题颜色

@YoKeyword
Copy link
Owner

可以用onHiddenChanged()

@candrwow
Copy link
Author

@YoKeyword 但是我的前后两个页面都没有用到fragment,基本上就是个recyclerview

@YoKeyword
Copy link
Owner

嗯? 没明白,没用到Fragment怎么可以侧滑返回的?
如果是Activity,可以 setResult() + onActivityResult()

@candrwow
Copy link
Author

我是在activity基类里继承了你的swipebackActivity,然后所有的activity都可以侧滑返回到上一个activity了。
我现在遇到的麻烦是,比如activity A->B->C,用户在C中变更了某些设置后,我希望侧滑返回的不是B,而是A,我现在想的是ondestroy中判断配置变了执行clearTask和start A,但是ondestroy执行时间不是立即的,所以我想监听到activity侧滑成功的那个时机,立刻执行clearTask和startA

@candrwow
Copy link
Author

另外4.4的机器转场动画是正确的,但是6.1上就失效了,全部变成了从下到上出现

@YoKeyword
Copy link
Owner

YoKeyword commented Apr 20, 2017

@candrwow

// 滑动过程监听
  getSwipeBackLayout().addSwipeListener(new SwipeBackLayout.OnSwipeListener() {
            @Override
            public void onDragScrolled(float scrollPercent) {
                // 滑动百分比
            }
   });

这个可以方法应该可以满足你的需求;

4.X上,(原生)系统默认Activity转场动画:横向
5.0+上,系统默认Activity转场动画:纵向

@candrwow
Copy link
Author

滑动百分比那个方法返回的数值貌似不能作为是否退出的判断,因为如果滑动的横向速度非常快,即时滑动百分比只有0.2依然会关闭当前activity进入之前的。

@YoKeyword
Copy link
Owner

现在手头有点事没法校验, 印象中 float scrollPercent是代表当前AC/FG已滑动的偏移量, 应该必定会到1.0f的, 1.0f就代表滑动到完全不可见状态

@candrwow
Copy link
Author

我在日志里并没有看到0和1.0f的数据,只有最后松手一瞬间的一个float值

@xh2015
Copy link

xh2015 commented Nov 10, 2017

@candrwow 最后怎么解决的,我也遇到这种--!

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

3 participants