Avocarrot / json2view

Update native Android UI on the fly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow using the layout XML directly instead of converting to JSON?

curioustechizen opened this issue Β· comments

One more advantage I can think of this is you already have an inflater provided by the Android system that understands XML.

πŸ‘

I just stumbled upon this repo and have nothing invested, but I am a bit confused why json is being used at all, why isn't this just pure xml?

Only idle curiosity, I honestly don't know.

We started developing in JSON format because we needed it for our team purposes at Avocarrot. Having said that, we are open to seeing this working for XML too.

Yeah, why not use the same XML document? That would mean even less work πŸ˜‰

We needed JSON for other purposes too so are stuck with it I guess:)

@giorgosera If that's the case, thank you for sharing this out in the open πŸ‘

One of the main reasons why XML cannot be used "directly" is because LayoutInflater does not support this :-

For performance reasons, view inflation relies heavily on pre-processing of XML files that is done at build time. 
Therefore, it is not currently possible to use LayoutInflater with an XmlPullParser over a plain XML file at runtime; 
it only works with an XmlPullParser returned from a compiled resource (R.something file.)

On the other hand, if you want to parse through the XML and create the view manually like what is being created, you can :) As much as i'd LOVE for android to accept XML directly, it doesn't, so it doesn't matter if it is JSON or XML, there is an intermediate step which is compulsory.

@gaara87, I understand that LayoutInflater requires pre-compiled layout resources. However having the library to accept XML would make developers' lives easier.

maybe you can try react-native

πŸ‘

Actually, it is not matter to use json or xml (there are the same). If the view description data (which is created with xml or json) is independent of special framework then it is possible to cover others too.

For example, it is possible to support IOS (see #24)