I am trying to create a endless table in Xamarin as a Instagram Client. However when I scroll to the bottom of the screen it loads the same 2nd page of images back. It loads the first page normally then it loads the 2nd page normally, however when i try to load the 3rd page it loads the 2nd page again. How would i Fix this? This is how I am attempting to load it:
Account instagram = enumerable.First ();
var instagramAccessToken = instagram.Properties ["access_token"].ToString ();
var request = new RestRequest { RootElement = "data", Resource = "/users/self/feed" };
request.AddParameter ("access_token", instagramAccessToken);
var client = new RestClient ("https://api.instagram.com/v1");
client.ExecuteAsync (request, response => {
var rootObject = JsonConvert.DeserializeObject<RootObject> (response.Content);
string nextURL = rootObject.pagination.next_url;
//// Create Next Client
var requestBack = new RestRequest ();
var clientBack = new RestClient (nextURL);
// GET Next Response
clientBack.ExecuteAsync (requestBack, responseBack => {
var rootObjectBack = JsonConvert.DeserializeObject<RootObject> (responseBack.Content);
table.InvokeOnMainThread (() => {
// Create list that contains newly attained JSON
List<Datum> instagramData = rootObjectBack.data;
// Create dummy list for other values
List<Datum> sloppy = null;
((TableSource<Datum>)table.Source).instaData.AddRange (instagramData);
table.ReloadData ();
});
});
});
This is where I detect that the user is at the bottom of the TableView
public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
NetworkCheck netCheck = new NetworkCheck ();
netCheck.runCheck ();
bool log = netCheck.anyLoggedIn ();
if (tableView.ContentSize.Height - UIScreen.MainScreen.Bounds.Height <= tableView.ContentOffset.Y) {
// this is the last row in the last section
Console.WriteLine ("~~~Bottom~~~");
FLDTRequest fldt = new FLDTRequest ();
fldt.getPastInstagramFeed (tableView);
}
var cell = tableView.DequeueReusableCell(InstagramCell.Key) as InstagramCell;
if (cell == null)
{
cell = new InstagramCell();
var views = NSBundle.MainBundle.LoadNib("InstagramCell", cell, null);
cell = Runtime.GetNSObject(views.ValueAt(0)) as InstagramCell;
}
Datum h = instaData [indexPath.Row];
cell.BindData(h);
return cell;
}