Questions about retrieving/refreshing data using Volley (and SimpleXML) on Android - android

All the data my Android app displays is taken from a XML file. I'm using Volley to retrieve the data and SimpleXML to map the XML data to objects using a Volley custom Request: SimpleXmlRequest.
Every time I refresh the content, it reads the whole XML file and creates every single object again and I have the feeling that this is not the best way to do it, cause this file can be quite large. So I have a few questions about that:
Is there a way to "subscribe" to the XML file to retrieve only the
new items added on it, avoiding to read the whole file every time? I know Volley can cache but doesn't help so much here.
Would it be possible to make a SimpleXmlArrayRequest using
SimpleXML framework? Would it help? Cause I really don't want to
parse the file by myself...
If not, would it worth to switch from XML to Json so I could use
JsonArrayRequest or would I have to read the whole file and refresh
every single item anyway? I've never used it before.
Many items from the source file are displayed as a list using
RecyclerView but, again, when I refresh, I have to remove the items
it had before and add them all again as I'm getting all the items at
once and consequently can't use
RecyclerView.notifyDataSetChanged().
I've been reading a lot, even until finding out the RxJava and RxAndroid which seems perfect but it looks like too hard to integrate Volley and SimpleXML on it... so I hope you can help me :)
Thanks!

I always work with Json apart from being very light, with libraries like GSON its fun to work with.
To get only new new data, my practice is to include two fields in the database tables, 1 for isDeleted (boolean) and 1 for lastModified (long epoc time).
The isDeleted field applies only if the data is accessed by multiple users.

Related

Adding item at the top of a list in Parse (local datastore enabled)

I have followed the tutorial "http://www.michaelevans.org/blog/2013/08/14/tutorial-building-an-android-to-do-list-app-using-parse/.
What I can't seem to figure out is to place a new item at the top of the list and not at the bottom like in the tutorial.
I've been trying to solve it with sorting, but since it did not work I am now solving this issue by loading the list items from Parse - which gives me the correct order of the objects. This results in to many unnecessary requests to Parse.
I have enabled Local Datastore and I read somewhere that the above issue is due to Local Datastore.
Very grateful for help with this!!
br
Susanna

Populate Android App with JSON data

I want to build an android app for a restaurant. I want it to display the menu in several activities using listviews. One for drinks, one for meals, one for deserts, etc. The menu comes from a json file which is being parsed in a splashscreen on app start.
Now i'm wondering what's the best way to populate the listviews and activities after parsing the json:
Populating the listviews from the splashscreen activity?
Storing the menu data in files and access them on the depending activity's oncreate()…?
Parsing a separate json file for each activity?
What is the best way in terms of performance, simplicity and effectiveness?
That would imply you have all you Acticities with their ListViews up & running when the splashscreen is starting. Probably not what you want.
You already said the JSON is stored in a file. You can parse that JSON in your splashscreen Activity, keep a global reference to it and let you Activities pick the part they need from that global class / JSONObject.
Tradeoff: Parse the complete JSON once and let all Activities retrieve the parts they need from it (this is basically 2.) at the 'risk' of parts of it never being used or split the JSON into several parts that are being loaded/parsed on demand by every Activity seperately, but having the overhead of doing file transactions in every Activity.
Either way, if the menu you're storing isn't immensely huge, the difference in performance will be minimal.
I'd go 2., load the whole file at startup, store the data globally and let every Activity make use of it.

XML or JSON Data to View mapper in Android

I have some sort of simple mobile shopping section inside my app. I get XML or JSON from server and want to put name/description/price/currency/etc to corresponding views. I really don't want to parse all XML myself and prefer to use some syntax like ["products.product.price" -> R.id.priceTextView] to map xml/json data to Android views.
I googled a little bit but failed to find a good way to do this. Do anybody know some lib or maybe Android class doing that?

How to present parsed JSON in readable format to users?

So I have JSON, I parsed in and it's sitting there. From my code below it looks like I have put everything into an ArrayList but then what? I mean for example I need the "title" of each JSON object to be an onClick on the first page, is that possible?
Essentially my onPostExceute() is empty/not doing much. Eventually I need to separate each object into it's own page via the onlicks I'm mentioning, but I think I can do that by separating the JSONObjects...? guess I'll come to that when I can.
If I want to separate things should I even be using an ArrayList? It's just what I used for a server test I ran with different code.
Would really appreciate some help. Basically stuck at the last hurdle is how I perceive it. Maybe I'm wrong though. The logs see that the JSON is showing up as one big chunk.
Edit: Removed my code, this is more of a theory question. ListView being the best thing to go with.
yes you can make spearate arraylist for them..and can store them in diferent listviews...on google click you can open new listview showing id and link for google ..and same you can do for microsoft and your other trem.And using onItemClick is a gud option,you can easily get the index of item clicked//

Trying to pull API into LinearLayout Android APP

I am a beginner of Android apps and am using Eclipse. I have found some larger samples of pulling APIs but I cannot find a simple one to get started with. I simply want to pull from an XML file on the web (by using an API KEY) and throw it in a LinearLayout (Vertical). I can then go from there, anyone know of any? Below is a sample of my XML:
<xmldata>
<Products>
<ProductCode>ITI-GR12</ProductCode>
<ProductName>Granada 9-3/4" Narrow Rim Platter</ProductName>
<ProductPrice>64.4000</ProductPrice>
</Products>
</xmldata>
I am assuming you are looking for mechanisms which help you to parse XML and extract data from it...Voila here is a link to get you started with different ways of doing it...
http://www.ibm.com/developerworks/opensource/library/x-android/
Good luck!
your question is not easy as you will have quite a lot of programming to achieve what you want.
Here are the steps :
read your data using sax
fill a data structure of your own (build a
class, data members will be filled by
previous parsing)
build an activity, use a layout you define to
show all UI fields you think you need
to display your data
fill the content of each view using the data
structure you filled on step 2.
If you are a beginner, I suggest you first understand steps 3 and 4, having fun with UIs, then try to understand how you could download your file, parse it and fill some data class to provide content for the views.
Regards,
Stéphane

Categories

Resources