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

关于PopTo的问题 #18

Open
mallxiaodoudou opened this issue Mar 7, 2021 · 5 comments
Open

关于PopTo的问题 #18

mallxiaodoudou opened this issue Mar 7, 2021 · 5 comments
Labels
question Further information is requested

Comments

@mallxiaodoudou
Copy link

情况1:单独的Activity 启动的都是无参数的 popto可以生效
情况2:另一个Acftivity 内部Fragment都是带参数的 popto没有反应

PopTo会有使用要求吗? 写法一样 有的能生效有的不生效,难道真是参数的问题?

@mallxiaodoudou
Copy link
Author

No package ID 0f found for ID 0x0f9faf7d.
NavController: Ignoring popBackStack to destination 262123389 as it was not found on the current back stack

@vitaviva
Copy link
Owner

vitaviva commented Mar 8, 2021

情况1:单独的Activity 启动的都是无参数的 popto可以生效
情况2:另一个Acftivity 内部Fragment都是带参数的 popto没有反应

PopTo会有使用要求吗? 写法一样 有的能生效有的不生效,难道真是参数的问题?

我本地测试,可以popTo到一个带参数启动的Fragment,具体代码能不能贴一下?比如目标framgent是如何创建的?如何popTo的?

@vitaviva vitaviva added the question Further information is requested label Mar 8, 2021
@mallxiaodoudou
Copy link
Author

感觉都是常规写法,我在别的模块是可以正常返回的
ScanQRCodeActivity:
//加载根视图
val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host) as NavHostFragment
navHostFragment.loadRoot { ScanQRCodeFragment(voucherId) }
navHostFragment.handleDeepLink(intent)

   ScanQRCodeFragment:
   //跳转
   navigator.push({
         applySlideInOut()
        popSelf = true
        }) { PaymentFragnemt(result) }

    PaymentFragnemt:
    //跳转
    navigator.push({ applySlideInOut() }) {
        PaymentConfirmFragment(code,amount,promotion)
    }
    
    PaymentConfirmFragment:
     //跳转
      navigator.push({ applySlideInOut() }) {
        PaymentSuccessFragment(business)
    }

     PaymentSuccessFragment:
     //返回(不生效)
     navigator.popTo(PaymentFragment::class)

@mallxiaodoudou
Copy link
Author

image
ScanQRCodeFragment根视图 popSelf = true 的时候 到下一个页面 查看堆栈的图标点击闪退(这个问题需要修复)

我把popSelf=false之后可以正常查看堆栈,我找到大概的原因了
image
NavController: Ignoring popBackStack to destination 132157418 as it was not found on the current back stack
第二个栈是Fragment对象 而不是具体的PaymentFragnemt对象,所以 navigator.popTo(PaymentFragment::class) 找不到这个class的对象去返回到指定页面

不过这个问题我不好办,这几个页面都是跨模块的 只能通过路由提供Fragment对象加入路由,路由没办法提供具体的实例出去

@vitaviva
Copy link
Owner

vitaviva commented Mar 8, 2021

先fix 点击堆栈图标闪退的问题。

第二个栈是Fragment对象 而不是具体的PaymentFragnemt对象
为什么第二个是普通的Fragment对象?

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

No branches or pull requests

2 participants