Comments (9)
I did another experiment : I added a loging command to the commented line :
if (context.getSystemService("PATH_CONTEXT") == null) {
L.info("not a path context
throw Exception("not a path context
}
And I got interesting results :
- getContext() of both views are actualy NOT wrapped with a PathContext (the 2 lines appeared in logcat)
- adding an exception with the commented line must have trigger a catch block somewhere that swallows my exception and that makes the code work (bad luck, I was hoping to find where the problem was coming from that way)
from flow.
Another experiment with print debug statements.
It looks like the error comes from this part of the code :
val context = PathContext.create(oldPath, to, contextFactory)
val layout = getLayout(to)
val newView = LayoutInflater.from(context).cloneInContext(context).inflate(layout, containerView, false)
My print statements tell me that context is able to deliver a PathContext but not newView.getContext()
Which is weird as I guess that the cloneInContext part was all about using a layoutInflater set with the good PathContexted context...
Let's now grep LayoutInflater
from flow.
I looked into the chains of ContextWrapper.
newView.getContext() has :
org.lakedaemon.android.flow.MyFlowActivity@427b02c8
android.app.ContextImpl@42807fe0
context has :
flow.path.PathContext@428fc308
flow.path.Path$LocalPathWrapper@428fc2c8
org.lakedaemon.android.flow.MyFlowActivity@427b02c8
...
Also I checked LayoutInflater.from(context).cloneInContext(context)
the Context it holds is identityEquals to context
So the issue certainly comes from inflate(layout, containerView, false)
When I grepped the LayoutInflater code, it seemed to me that there might be a possibility the context could be changed (when a view uses a theme...)
from flow.
@Lakedaemon Do you use AppCompatActivity
from 22.1.+
? If so, there is a know issues with misusing context during inflation (see workaround inside): #88 (dig into mortar
issue)
from flow.
Yes I'm using AppCompatActivity (to get support for the api range 9 to 22) and I believe that I suffer from this exact issue. Thanks for the pointer.
from flow.
To fix this, just use LayoutInflater.from(context.getApplication()).cloneInContext(context).inflate(...)
from flow.
And you also need to initialize your container view group like this
PathContext pathContext = PathContext.root(this);
framePathContainerView = (MortarScreenSwitcherFrame) LayoutInflater.from(this)
.cloneInContext(pathContext)
.inflate(R.layout.activity_main, null);
setContentView(framePathContainerView);
from flow.
Thanks for the tip. It really helped.
from flow.
See also #91
from flow.
Related Issues (20)
- Documentation issues to fix for beta HOT 1
- Make sure to publish source with releases HOT 1
- No reason for setDispatcher(), setHistoryFilter() to be public HOT 1
- Getting to the flow instance from the dispatcher can be awkward HOT 2
- The purpose of MultiKey HOT 2
- Change log says "alpha2" even for "alpha3" HOT 1
- `Flow.get(context)` returns null during `Activity.onCreate` HOT 1
- State not reloaded HOT 2
- Make it clearer which end of the Flow history stack is the top HOT 2
- New way to break Flow.goBack() HOT 3
- Crash while cleaning up a transition that finished after Activity.onDestroy HOT 1
- Save view state with id = -1
- [Question] Future of Flow HOT 3
- Do not reload rest api when go back HOT 1
- ETA for 1.0? HOT 4
- help :
- Recipe for creating nested screens with Flow? HOT 1
- Is this project abandoned? HOT 4
- InternalLifecycleIntegration memory leak on P emulator HOT 1
- How to get result from previous Screen? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flow.