I am trying to create an endless table in Xamarin as an Instagram client. However, when I look at the bottom of the screen, it loads the same second page of images back. It loads the first page normally, then it loads the second page normally, however, when I try to load the third page, it loads the second page again. How to fix it? This is how I try to download 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;
var requestBack = new RestRequest ();
var clientBack = new RestClient (nextURL);
clientBack.ExecuteAsync (requestBack, responseBack => {
var rootObjectBack = JsonConvert.DeserializeObject<RootObject> (responseBack.Content);
table.InvokeOnMainThread (() => {
List<Datum> instagramData = rootObjectBack.data;
List<Datum> sloppy = null;
((TableSource<Datum>)table.Source).instaData.AddRange (instagramData);
table.ReloadData ();
});
});
});
Here I find 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) {
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;
}
source
share