Git Product home page Git Product logo

Comments (3)

YoKeyword avatar YoKeyword commented on May 24, 2024

@lylzwsy 看你的描述,你的是同级的使用场景,不是流程式的;(类知乎)你想做到这个效果的话需要这样:

我假设你还有另外2个同级模块,AFragment和BFragment,那么你的Activity层的Fragment栈内应该只有3个Fragment,Main、A、B。 这3个Fragment仅仅是容器作用,MainFragment里的内容是它的子Fragment,向里面流程式跳转的话,就是子Fragment之间的跳转;
你可以想象各个模块之间的切换是很复杂的,嵌套关系要理清。

我的README里最后有提到,目前该版本暂不能帮你恢复 同级 以及 Fragment嵌套的情况(因为很复杂~),所以如果你想在这种同级的场景下使用的话,你需要做以下2点:
1、你需要在MainActivity里自己做 内存重启 时的恢复工作(MainFragment、AFragment、BFragment的恢复)
2、你需要在MainFragment、AFragment、BFragment里自己做 内存重启 时的恢复工作(参考SupportActivity)

综上,如果你一定需要这样需求的话,就需要这么做;我的Demo可以看到是流程式的;不需要任何额外的处理,库已经帮助处理好了

最后,下个版本0.7可能会解决 Fragment嵌套、同级的恢复问题(已经找到封装思路,还在尝试封装中)

:)

from fragmentation.

YoKeyword avatar YoKeyword commented on May 24, 2024

@lylzwsy 同时还一种方案是我比较提倡的,就是少量模块Activity+多Fragment,首页还是MainActivity+3个模块Fragment,每个模块点击的话就是跳转Activity,然后该Activity是单Activity+多Fragment的结构
3个模块都是这样处理 那么你的app就是4 Activity+多Fragments, 这样处理的话代码复杂程度和Fragment之间的嵌套逻辑会降到最低,同时app质量和性能又比较高,你可以酌情考虑

当然你看下你的app是不是一定需要首页是同级的,不然的话可以参考我的demo那种结构,一样是可行且简单的
:)

from fragmentation.

lylzwsy avatar lylzwsy commented on May 24, 2024

非常感谢你。 我再继续研究研究。 同时也期待你的0.7版本!加油。

from fragmentation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.