private void SearchMoreKeywords(Section entries, CustomLoadMoreElement lme) { try { var images = SearchImages (); _foundImages.AddRange(images); int rowCount = 4; var newElements = new List<Images2Element>(); for (int i = 0; i < images.Count; i += rowCount) { var imagesInfos = new List<ImageInfo>(); for (int j = 0; j < rowCount; j++) { var imgInfo = new ImageInfo() { Img = (i + j < images.Count) ? images[i + j] : null, }; imagesInfos.Add(imgInfo); } newElements.Add(new Images2Element(imagesInfos, i)); } InvokeOnMainThread(()=> { lme.Animating = false; entries.Insert(entries.Count - 1, UITableViewRowAnimation.None, newElements.ToArray()); }); } catch (Exception ex) { Util.LogException("SearchMoreKeywords", ex); } }
public override void SearchButtonClicked (string text) { if (string.IsNullOrWhiteSpace(text)) return; if (Root.Count > 0) Root[0].Clear(); FinishSearch(); var lw = new LoadingView(); lw.Show("Searching for " + text); NSTimer.CreateScheduledTimer (TimeSpan.FromSeconds (0.1), delegate { SearchMirror.Text = text; SearchedText = text; LastTime = DateTime.MaxValue; var entries = new Section () { }; var images = SearchImages (); _foundImages = images; int rowCount = 4; for (int i = 0; i < images.Count; i += rowCount) { var imagesInfos = new List<ImageInfo>(); for (int j = 0; j < rowCount; j++) { var imgInfo = new ImageInfo() { Img = (i + j < images.Count) ? images[i + j] : null, }; imagesInfos.Add(imgInfo); } entries.Add(new Images2Element(imagesInfos, i)); } var more = new CustomLoadMoreElement (lme => { // Launch a thread to do some work ThreadPool.QueueUserWorkItem (delegate { SearchMoreKeywords(entries, lme); }); }); more.Height = 60; more.Image = Graphics.GetImgResource("more"); entries.Add(more); Root = new RootElement (Locale.GetText ("Search")){ entries, }; ReloadData(); lw.Hide(); }); }
private void DownloadAsync() { try { if (!hasImage) { var imgElement = new UIImageView(Graphics.GetImgResource("messagenoposts")); imgElement.Frame = new System.Drawing.RectangleF(5, 5, 310, imgElement.Bounds.Height); var viewEl = new UIViewElement(null, imgElement, true); Root[0].Add(viewEl); ReloadComplete(); return; } for (int i = 0; i < 7; i++) { Root[0].Add (new PhotosElement (this, i)); } if (ShowLoadMorePhotos) { CustomLoadMoreElement more = null; more = new CustomLoadMoreElement (delegate { var wait = new ManualResetEventSlim(false); AppDelegateIPhone.ShowRealLoading("Loading more photos", null, wait); // Launch a thread to do some work ThreadPool.QueueUserWorkItem (delegate { AddMorePhotoElements(more, wait); }); }); more.Height = 60; more.Image = Graphics.GetImgResource("more"); try { Root[0].Insert (Root[0].Count, UITableViewRowAnimation.None, more); } catch { } } } catch (Exception ex) { Util.LogException("DownloadAsync", ex); } }
private void AddMorePhotoElements(CustomLoadMoreElement more, ManualResetEventSlim wait) { try { pageNumber++; var images = _MapLocationRequest.GetDbImages(_FilterType, (pageNumber - 1) * 21, 21); if (images.Count() == 0) { pageNumber--; this.BeginInvokeOnMainThread(delegate { more.Animating = false; }); return; } Image[] resa = images.ToArray(); int count = resa.Count(); for (int i = 1; i <= 21; i++) { var imgInfo = new ImageInfo() { Index = i }; if (i <= count) { imgInfo.Img = resa[i - 1]; } _list.Add(imgInfo); previousList.Add(imgInfo.Img); } // Now make sure we invoke on the main thread the updates this.BeginInvokeOnMainThread(delegate { more.Animating = false; try { for (int i = (pageNumber - 1) * 7; i < pageNumber * 7; i++) { Root[0].Insert(Root[0].Count - 1, new PhotosElement (this, i)); } } catch (Exception ex) { Util.LogException("AddMorePhotoElements InsertElements", ex); } }); //TableView.ScrollToRow (NSIndexPath.FromRowSection (Root[0].Count - 1, 0), UITableViewScrollPosition.Middle, false); } catch (Exception ex) { Util.LogException("AddMorePhotoElements", ex); pageNumber--; // Now make sure we invoke on the main thread the updates this.BeginInvokeOnMainThread(delegate { more.Animating = false; }); } finally { wait.Set(); } }
private void DownloadTweets () { oldestTime = DateTime.MaxValue; try { photoUser = photoUser ?? AppDelegateIPhone.AIphone.UsersServ.GetUserById(_UserID); if (photoUser == null) { BeginInvokeOnMainThread(() => ReloadComplete()); return; } var tweets = GetTweets(photoUser, DateTime.MaxValue); if (tweets == null) { BeginInvokeOnMainThread(delegate { ReloadComplete (); AppDelegateIPhone.ShowMessage(View, "image stream loading failed", null); }); return; } this.BeginInvokeOnMainThread (delegate { Root[0].RemoveRange(0, Root[0].Count); NSTimer.CreateScheduledTimer (0, delegate { try { foreach (Tweet tweet in tweets) { Root[0].Add(new MemberPhotoElement(tweet, GoToUserPhotos)); } } catch (Exception ex) { Util.LogException("DownloadTweets", ex); } CustomLoadMoreElement more = null; more = new CustomLoadMoreElement (delegate { // Launch a thread to do some work ThreadPool.QueueUserWorkItem (delegate { AddOlderPhotos(more); }); }); more.Height = 60; more.Image = Graphics.GetImgResource("more"); try { Root[0].Insert (Root[0].Count, UITableViewRowAnimation.None, more); } catch { } // Notify the dialog view controller that we are done // this will hide the progress info this.BeginInvokeOnMainThread (delegate { ReloadComplete (); }); }); }); } catch (Exception ex) { Util.LogException("MembersView ReloadTimeline", ex); BeginInvokeOnMainThread(() => ReloadComplete()); } }
private void AddOlderPhotos(CustomLoadMoreElement more) { try { var tweets = GetTweets(photoUser, oldestTime); if (tweets != null && tweets.Count > 0) { var newElements = new List<MemberPhotoElement>(); foreach (Tweet tweet in tweets) { newElements.Add(new MemberPhotoElement(tweet, GoToUserPhotos)); } this.BeginInvokeOnMainThread (delegate { more.Animating = false; Root[0].Insert(Root[0].Count - 1, UITableViewRowAnimation.None, newElements.ToArray()); }); } } catch (Exception ex) { Util.LogException("AddOlderPhotos", ex); } }
void DownloadTweets () { try { sinceDate = DateTime.MaxValue; List<UIActivity> activities = GetActivities(sinceDate); if (activities == null) { this.BeginInvokeOnMainThread (delegate { ReloadComplete (); }); return; } long ticks = DateTime.UtcNow.Ticks; Util.Defaults.SetDouble (ticks, "LastUpdate"); if (activities.Count > 0) sinceDate = activities[activities.Count - 1].DbActivity.Time; this.BeginInvokeOnMainThread (delegate { AppDelegateIPhone.navigationRoots[2].TabBarItem.BadgeValue = null; Root[0].RemoveRange(0, Root[0].Count); //NSTimer.CreateScheduledTimer (0, delegate { foreach (UIActivity activity in activities) { Root[0].Add(new ActivityElement(activity, GoToMembersPhotoView, GoToPhotoDetailsView)); } CustomLoadMoreElement more = null; more = new CustomLoadMoreElement (delegate { // Launch a thread to do some work ThreadPool.QueueUserWorkItem (delegate { AddOlderActivities(); BeginInvokeOnMainThread(()=> { more.Animating = false; }); }); }); more.Height = 60; more.Image = Graphics.GetImgResource("more"); try { Root[0].Insert (Root[0].Count, UITableViewRowAnimation.None, more); } catch { } // Notify the dialog view controller that we are done // this will hide the progress info this.BeginInvokeOnMainThread (delegate { ReloadComplete (); }); }); //}); } catch (Exception ex) { this.InvokeOnMainThread(ReloadComplete); Util.LogException("ActivityView ReloadTime", ex); } }