How to access Picasa Api url in Descending Order - android

I am making an android app using picasa web album. I have implemented the code to access the images using api. but i am unable to put that images in descending order so that i can access new images at top of the grid view.
I am using url like this to access code.
https://picasaweb.google.com/data/feed/api/user/_PICASA_USER_/albumid/_ALBUM_ID_?alt=json
Please help me to get url for order(sorting)

Not so much information... But an idea will be when you read your json and create a List, use myList.add(0, picURL) instead of myList.add(picURL), that will add the URL to the first position each time, instead of adding it to the end.

Related

Need a proper example for custom expendable list view with JSON array

I searched almost every tutorials and never fiend a perfect example for a custom expendable listview, where parent node and child node data will fetch from web server using JSON array. Please help me anyone, atleast give me any proper tutorial link so that I can understand the whole process.
Download the zip from this link:
https://github.com/alessandroargentieri/AndroidToWebService
Inside there is an Android Application which asks for a JSON message from a PHP Web service which takes the data from a Database MySQL.
If you want to see the PHP page, it is at the end of MainActivity.java as a commented code.

Retrieve Images from database on the basis of json data

Currently I am developing an application which displays cricket scores from an api. The api returns json data of a list of live matches, which has a unique id of every match. By passing unique id of match in url, we get entire scorecard of match. But, this doesn't return photos of the players playing. So i want to display them in an imageview along with playername, Runs, Balls, boundaries,etc.
Something like this.. What's the best way? Firebase Or something else?
You need to use libraries like Glide for loading images from any link.
And for links of images you can maintain static array of URL's of images or you may write some dynamic code by which links of profile images will be extracted from the json id's (by requesting on some generic URL using those id's) you already have so that you need not to maintain any static array.

How to fetch data from database instead of JSON everytime

Actually, I followed this YouTube tutorial and got an idea of delivering articles from a WordPress blog using the JSON API.
Here is the GITHUB link.
The above tutorial has a good example, but it only shows data from database only when there is no internet connection available. But I want the following:
Fetch data when the app is first started.
Store the data in the database
Set the adapter and show the data in the recyclerview
When the app is loaded for the second time check if internet is available and then check for new data, download if available, and then save the data into database and show the data in the recycler view.
Now, I've developed most of the logic for it, but the tutorial has used some advanced OOPs principles of JAVA which I am unable to fully comprehend.
Can anyone please help me and tell me how I can change the given code and display the data from database even if internet is available or not?
on MainActivity, line 91
if (getNetworkAvailability()) {
getFeed();
} else {
getFeedFromDatabase();
}
Above code will check network, and if network available, getFeed() which load feed from internet will be called. Just remove that case. I mean, remove above code, just keep the line
getFeedFromDatabase();
There is nothing complex, by the way. The idea is that you define your own interface which describe how to save data and implement it for database and for communication with Rest Api (Retrofit). There may be some differences between format of stored data (one form in database and the other on a server), so you have to convert it to format of your app.
For that you create another interface (see Repository pattern), which is also implemented by you db and web stuff.
When your have implementations for both sources you can choose which one to use.

Android download remote content

I want to create Android app where I have items with images and descriptions - only for information, no interact. How can I download layout from server and show remote data? I'm newby - I can create simple apps, but this problem is not solved in Internet. I search in Google, Youtube but I can't find anything.
First you need to create a layout in your app (you cannot parse layout from server only data can be parsed), then connect your layout items to loading data from server.
You can check out an basic example to populate list view from server from here and here

How to compare feed content to cached one?

I am fetching a content of an Internet feed and storing it into a local database (caching). the feed does not have a tag which will tell me when a specific entry in it was created (no date tag). All it has is a title, content, url and image.
Now, I want to make this: if there is no new content on the feed, the app will load from the cache during the specific session. But if I see that there is a new content on the feed, then the app will load from the feed and all later loads (during one session) will go from the cache.
How can I detect in this specific case if there is a new content on the feed or not? Shall I do string comparison of the first X lines of both cache and remote feed? Or there is a better and proper way to do it?
Using your approach you will have to download the entries and compare them to the data stored in your cache. This pretty much renders the cache useless, as one of the things you want to prevent by using a caching mechanism is unnecessary downloads.
Are you sure that there are no header fields that you can use to check for changes? Good candidates are Last-Modified, If-Modified-Since and If-Not-Modified. See Wikipedia's list of header fields for more detailed information on these fields.

Categories

Resources