示例#1
0
        void OnPostFetched(CKRecord record)
        {
            // When we get a record, use it to create an Post
            Post fetchedPost = new Post(record);

            downloadingBatchStorage.Add(fetchedPost);

            fetchedPost.LoadImage(new string[] { Image.FullsizeKey }, () => {
                // Once image is loaded, tell the tableview to reload
                DispatchQueue.MainQueue.DispatchAsync(reloadHandler);
            });
        }
		public async void LoadNewPostsWithRecordID(CKRecordID recordID)
		{
			// Called when AppDelegate receives a push notification
			// The post that triggered the push may not be indexed yet, so a fetch on predicate might not see it.
			// We can still fetch by recordID though
			CKDatabase publicDB = CKContainer.DefaultContainer.PublicCloudDatabase;
			try {
				CKRecord record = await publicDB.FetchRecordAsync (recordID);
				Post postThatFiredPush = new Post(record);
				postThatFiredPush.LoadImage(null, TableView.ReloadData);
				postManager.LoadNewPosts(postThatFiredPush);
			} catch(NSErrorException ex) {
				Console.WriteLine (ex.Error);
			}
		}
示例#3
0
        public async void LoadNewPostsWithRecordID(CKRecordID recordID)
        {
            // Called when AppDelegate receives a push notification
            // The post that triggered the push may not be indexed yet, so a fetch on predicate might not see it.
            // We can still fetch by recordID though
            CKDatabase publicDB = CKContainer.DefaultContainer.PublicCloudDatabase;

            try {
                CKRecord record = await publicDB.FetchRecordAsync(recordID);

                Post postThatFiredPush = new Post(record);
                postThatFiredPush.LoadImage(null, TableView.ReloadData);
                postManager.LoadNewPosts(postThatFiredPush);
            } catch (NSErrorException ex) {
                Console.WriteLine(ex.Error);
            }
        }
示例#4
0
        void OnLoadNewPostFetchRecord(CKRecord record, List <Post> newPosts, ref Post lastRecordInOperation)
        {
            // If the record we just fetched doesn't match recordIDs to any item in our newPosts array, let's make an Post and add it
            var matchingRecord = newPosts.FindIndex(p => p.PostRecord.Id.Equals(record.Id));

            if (matchingRecord == -1)
            {
                Post fetchedPost = new Post(record);
                newPosts.Add(fetchedPost);
                fetchedPost.LoadImage(new string[] { Image.FullsizeKey }, reloadHandler);
                lastRecordInOperation = fetchedPost;
            }
            else
            {
                // If we already have this record we don't have to fetch. We'll still update lastRecordInOperation because we did see it on the server
                lastRecordInOperation = newPosts[matchingRecord];
            }
        }
示例#5
0
		void OnLoadNewPostFetchRecord(CKRecord record, List<Post> newPosts, ref Post lastRecordInOperation)
		{
			// If the record we just fetched doesn't match recordIDs to any item in our newPosts array, let's make an Post and add it
			var matchingRecord = newPosts.FindIndex (p => p.PostRecord.Id.Equals(record.Id));
			if (matchingRecord == -1) {
				Post fetchedPost = new Post (record);
				newPosts.Add (fetchedPost);
				fetchedPost.LoadImage(new string[] { Image.FullsizeKey }, reloadHandler);
				lastRecordInOperation = fetchedPost;
			} else {
				// If we already have this record we don't have to fetch. We'll still update lastRecordInOperation because we did see it on the server
				lastRecordInOperation = newPosts[matchingRecord];
			}
		}
示例#6
0
		void OnPostFetched(CKRecord record)
		{
			// When we get a record, use it to create an Post
			Post fetchedPost = new Post (record);
			downloadingBatchStorage.Add (fetchedPost);

			fetchedPost.LoadImage (new string[]{ Image.FullsizeKey }, () => {
				// Once image is loaded, tell the tableview to reload
				DispatchQueue.MainQueue.DispatchAsync (reloadHandler);
			});
		}