コード例 #1
0
ファイル: Timeline.cs プロジェクト: ozgurtt/TweetStation
        void Load(int page, long since_id)
        {
            var fullUrl = BuildUrl(page, since_id);

            TwitterAccount.CurrentAccount.Download(fullUrl, false, res => {
                CancelMenu();
                if (res == null)
                {
                    BeginInvokeOnMainThread(delegate { Root = Util.MakeError(TimelineTitle); });
                    return;
                }
                Element [] tweetArray = (from tweet in GetTweetStream(res) select(Element) new TweetElement(tweet)).ToArray();

                // Now on the main thread, do the UI work
                BeginInvokeOnMainThread(delegate {
                    Section section;
                    if (since_id == 0)
                    {
                        if (page == 1)
                        {
                            // If we are the first batch of data being loaded, not load more, or refresh
                            var root = new RootElement(StreamedTitle)
                            {
                                UnevenRows = true
                            };
                            section = new Section();
                            root.Add(section);
                            Root = root;
                        }
                        else
                        {
                            section = Root [0];
                            section.Remove(loadMore);
                        }

                        int n = section.Add(tweetArray);

                        if (n == expectedCount)
                        {
                            loadMore = new LoadMoreElement(Locale.GetText("Load more"), Locale.GetText("Loading"), delegate {
                                Load(page + 1, 0);
                            }, UIFont.BoldSystemFontOfSize(14), UIColor.Black);
                            loadMore.Height = 60;
                            section.Add(loadMore);
                        }
                    }
                    else
                    {
                        section = Root [0];
                        section.Insert(0, UITableViewRowAnimation.None, tweetArray);
                    }
                    if (sinceStr != null && section.Count > 0)
                    {
                        last_id = (section [0] as TweetElement).Tweet.Id;
                    }

                    ReloadComplete();
                });
            });
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: ozgurtt/TweetStation
        void StartXauthLogin(string user, string password, NSAction callback)
        {
            LoadMoreElement status = loginDialog.Root [1][0] as LoadMoreElement;

            // Spin off a thread to start the OAuth authentication process,
            // let the GUI thread show the spinner.
            ThreadPool.QueueUserWorkItem(delegate {
                var oauth = new OAuthAuthorizer(TwitterAccount.OAuthConfig, user, password);

                if (oauth.AcquireAccessToken())
                {
                    BeginInvokeOnMainThread(delegate {
                        if (callback == null)
                        {
                            StartupAfterAuthorization(oauth);
                        }
                        else
                        {
                            SetDefaultAccount(oauth);
                            callback();
                        }
                    });
                    return;
                }

                BeginInvokeOnMainThread(delegate {
                    status.Animating = false;
                    loginAlert       = new UIAlertView(Locale.GetText("Error"),
                                                       Locale.GetText("Unable to login"),
                                                       null, null, Locale.GetText("Ok"));
                    loginAlert.Dismissed += delegate { loginAlert = null; };
                    loginAlert.Show();
                });
            });
        }
コード例 #3
0
ファイル: AddEditContactScreen.cs プロジェクト: NamXH/Graphy
        public void InstantMsgLoadMoreTapped(LoadMoreElement lme)
        {
            var labels = new List <string>()
            {
                "Skype", "Hangouts", "Facebook Messenger", "MSN", "Yahoo", "AIM", "QQ"
            };

            PopulateElements(lme, _instantMsgSection, "Skype", "IM", UIKeyboardType.ASCIICapable, "Delete This IM", labels);
        }
コード例 #4
0
ファイル: AddEditContactScreen.cs プロジェクト: NamXH/Graphy
        public void UrlLoadMoreTapped(LoadMoreElement lme)
        {
            var labels = new List <string>()
            {
                "Home Page", "Home", "Work"
            };

            PopulateElements(lme, _urlSection, "Home Page", "Url", UIKeyboardType.Url, "Delete This Url", labels);
        }
コード例 #5
0
ファイル: AddEditContactScreen.cs プロジェクト: NamXH/Graphy
        public void EmailLoadMoreTapped(LoadMoreElement lme)
        {
            var labels = new List <string>()
            {
                "Home", "Work", "Oher"
            };

            PopulateElements(lme, _emailSection, "Home", "Email Address", UIKeyboardType.EmailAddress, "Delete This Email", labels);
        }
コード例 #6
0
ファイル: AddEditContactScreen.cs プロジェクト: NamXH/Graphy
        public void PhoneLoadMoreTapped(LoadMoreElement lme)
        {
            var labels = new List <string>()
            {
                "Mobile", "Home", "Work", "Main", "Home Fax", "Work Fax", "Pager", "Other"
            };

            PopulateElements(lme, _phoneSection, "Mobile", "Phone Number", UIKeyboardType.NumberPad, "Delete This Number", labels);
        }
コード例 #7
0
ファイル: ListController.cs プロジェクト: envy4s/Gistacular
 private void LoadFinished()
 {
     if (_loadMore != null)
     {
         _loadMore.Animating = false;
         if (_nextPage < 0)
         {
             Root.Remove(_loadMore.Parent as Section);
             _loadMore.Dispose();
             _loadMore = null;
         }
     }
 }
コード例 #8
0
ファイル: AddEditContactScreen.cs プロジェクト: NamXH/Graphy
        public void PopulateElements(LoadMoreElement lme, Section section, string typeLable, string valueLabel, UIKeyboardType entryKeyboardType, string deleteLabel, IList <string> labelList)
        {
            lme.Animating = false;

            var type = new StyledStringElement(typeLable)
            {
                Accessory = UITableViewCellAccessory.DetailDisclosureButton
            };

            section.Insert(section.Count - 1, type);
            var value = new EntryElement(null, valueLabel, null);

            value.KeyboardType = entryKeyboardType;
            section.Insert(section.Count - 1, value);

            var deleteButton = new StyledStringElement(deleteLabel)
            {
                TextColor = UIColor.Red,
            };

            deleteButton.Tapped += () =>
            {
                section.Remove(type);
                section.Remove(value);
                section.Remove(deleteButton);
            };

            // Show/Hide Delete Button
            var deleteButtonOn = false;

            type.AccessoryTapped += () =>
            {
                if (!deleteButtonOn)
                {
                    deleteButtonOn = true;
                    section.Insert(type.IndexPath.Row + 2, UITableViewRowAnimation.Bottom, deleteButton);
                }
                else
                {
                    deleteButtonOn = false;
                    section.Remove(deleteButton);
                }
            };

            type.Tapped += () =>
            {
                var labelScreen = new LabelListScreen(labelList);
                var navigation  = new UINavigationController(labelScreen);
                NavigationController.PresentViewController(navigation, true, null);
            };
        }
コード例 #9
0
ファイル: Main.cs プロジェクト: ozgurtt/TweetStation
        void StartLogin(DialogViewController dvc)
        {
            dvc.Root.RemoveAt(1);
            LoadMoreElement status;

            if (dvc.Root.Count == 1)
            {
                status = new LoadMoreElement(
                    Locale.GetText("Could not authenticate with twitter"),
                    Locale.GetText("Contacting twitter"), null, UIFont.BoldSystemFontOfSize(16), UIColor.Black)
                {
                    Animating = true
                };
                dvc.Root.Add(new Section()
                {
                    status
                });
            }
            else
            {
                status = (LoadMoreElement)dvc.Root [1][0];
            }

            // Spin off a thread to start the OAuth authentication process,
            // let the GUI thread show the spinner.
            ThreadPool.QueueUserWorkItem(delegate {
                var oauth = new OAuthAuthorizer(TwitterAccount.OAuthConfig);

                try {
                    if (oauth.AcquireRequestToken())
                    {
                        BeginInvokeOnMainThread(delegate {
                            oauth.AuthorizeUser(dvc, delegate {
                                StartupAfterAuthorization(oauth);
                            });
                        });
                        return;
                    }
                } catch (Exception e) {
                    Console.WriteLine(e);
                }

                BeginInvokeOnMainThread(delegate { status.Animating = false; });
            });
        }
コード例 #10
0
ファイル: SearchTab.cs プロジェクト: ununian/TweetStation
 void StartGeoSearch(LoadMoreElement loading)
 {
     if (location == null)
     {
         loading.Animating = true;
         Util.RequestLocation(newLocation => {
             loading.Animating = false;
             if (newLocation != null)
             {
                 location = newLocation;
                 ActivateController(new SearchFromGeo(location));
             }
         });
     }
     else
     {
         ActivateController(new SearchFromGeo(location));
     }
 }
コード例 #11
0
ファイル: ListController.cs プロジェクト: envy4s/Gistacular
        protected override void OnRefresh()
        {
            var sec = new Section();

            if (Model.Count == 0)
            {
                sec.Add(new Gistacular.Elements.NoItemsElement());
            }
            else
            {
                Model.ForEach(x => sec.Add(CreateElement(x)));
            }

            Section loadSec = null;

            if (_nextPage >= 0)
            {
                _loadMore = new Gistacular.Elements.PaginateElement("Load More", "Loading...", e => this.DoWorkNoHud(LoadWork, LoadException, LoadFinished));
                loadSec   = new Section()
                {
                    _loadMore
                };
            }

            InvokeOnMainThread(delegate {
                var r = new RootElement(Title)
                {
                    UnevenRows = UnevenRows
                };
                r.Add(sec);
                if (loadSec != null)
                {
                    r.Add(loadSec);
                }
                Root = r;
            });
        }
コード例 #12
0
ファイル: Timeline.cs プロジェクト: ununian/TweetStation
        void DownloadTweets(int insertPoint, long?since, long?max_id, Element removeOnInsert)
        {
            Account.ReloadTimeline(kind, since, max_id, count => {
                CancelMenu();
                mainSection.Remove(removeOnInsert);
                if (count == -1)
                {
                    var msg = Locale.Format("Net failure on {0}", DateTime.Now);
                    Element insertElement;

                    if (mainSection.Count > 0 && (insertElement = mainSection [insertPoint] as StyledStringElement) != null)
                    {
                        insertElement.Caption = msg;
                    }
                    else
                    {
                        mainSection.Insert(insertPoint, new StyledMultilineElement(Account.lasterror ?? "Error")
                        {
                            Font = UIFont.SystemFontOfSize(14)
                        });
                    }
                    count = 1;
                }
                else
                {
                    // Remove previous error message
                    if (mainSection.Count > 0 && mainSection [0] is StyledStringElement)
                    {
                        mainSection.Remove(0);
                    }

                    // If we find an overlapping value, the timeline is continous, otherwise, we offer to load more

                    // If insertPoint == 0, this is a top load, otherwise it is a "Load more tweets" load, so we
                    // need to fetch insertPoint-1 to get the actual last tweet, instead of the message.
                    long lastId = GetTableTweetId(insertPoint == 0 ? 0 : insertPoint - 1) ?? 0;

                    continuous = false;
                    int nParsed;

                    Util.ReportTime("Before Loading tweet from DB");
                    lock (Database.Main)
                        nParsed = mainSection.Insert(insertPoint, UITableViewRowAnimation.None, UnlockedFetchTweets(count, lastId, insertPoint));
                    Util.ReportTime("Time spent loading tweets");

                    NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(0.3), delegate {
                        NavigationController.TabBarItem.BadgeValue = (nParsed > 0) ? nParsed.ToString() : null;
                    });

                    if (!continuous && nParsed > 0)
                    {
                        LoadMoreElement more = null;

                        more = new LoadMoreElement(Locale.GetText("Load more tweets"), Locale.GetText("Loading"), delegate {
                            more.Animating = true;
                            DownloadTweets(insertPoint + nParsed, null, GetTableTweetId(insertPoint + count - 1) - 1, more);
                        });
                        more.Height = 60;

                        try {
                            mainSection.Insert(insertPoint + nParsed, UITableViewRowAnimation.None, more);
                        } catch {
                            Console.WriteLine("on {0} inserting at {1}+{2} section has {3}", kind, insertPoint, count, mainSection.Count);
                        }
                    }
                    count = nParsed;
                }
                ReloadComplete();

                // Only scroll to last unread if this was not an intermediate "Load more tweets"
                if (insertPoint == 0 && count > 0)
                {
                    TableView.ScrollToRow(NSIndexPath.FromRowSection(count - 1, 0), UITableViewScrollPosition.Middle, false);
                }
            });
        }
コード例 #13
0
ファイル: AddEditContactScreen.cs プロジェクト: NamXH/Graphy
        public AddEditContactScreen(UINavigationController nav) : base(UITableViewStyle.Grouped, null, true)
        {
            _rootContainerNavigationController = nav;

            // Navigation
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, args) =>
            {
                NavigationController.DismissViewController(true, null);
            });
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, DoneButtonClicked);
            NavigationItem.Title = "New Contact";

            Root = new RootElement("");

            // Photo
            _photoSection       = new Section();
            _photoBadge         = new BadgeElement(UIImage.FromBundle("Images/UnknownIcon.jpg"), "Add Photo");
            _photoBadge.Tapped += PhotoBadgeTapped;
            _photoSection.Add(_photoBadge);
            Root.Add(_photoSection);

            // Name
            _nameSection = new Section();
            var firstName  = new EntryElement(null, "First", null);
            var middleName = new EntryElement(null, "Middle", null);
            var lastName   = new EntryElement(null, "Last", null);
            var org        = new EntryElement(null, "Organization", null);

            _nameSection.Add(firstName);
            _nameSection.Add(middleName);
            _nameSection.Add(lastName);
            _nameSection.Add(org);
            Root.Add(_nameSection);

            // Phone numbers
            _phoneSection = new Section("Phone Numbers");
            Root.Add(_phoneSection);
            var phoneLoadMore = new LoadMoreElement("Add More Phone Numbers", "Loading...", PhoneLoadMoreTapped);

            _phoneSection.Add(phoneLoadMore);

            // Emails
            _emailSection = new Section("Emails");
            Root.Add(_emailSection);
            var emailLoadMore = new LoadMoreElement("Add More Emails", "Loading...", EmailLoadMoreTapped);

            _emailSection.Add(emailLoadMore);

            // Urls
            _urlSection = new Section("Urls");
            Root.Add(_urlSection);
            var urlLoadMore = new LoadMoreElement("Add More Urls", "Loading...", UrlLoadMoreTapped);

            _urlSection.Add(urlLoadMore);

            // IMs
            _instantMsgSection = new Section("Instant Messages");
            Root.Add(_instantMsgSection);
            var instantMsgLoadMore = new LoadMoreElement("Add More Instant Messages", "Loading...", InstantMsgLoadMoreTapped);

            _instantMsgSection.Add(instantMsgLoadMore);
        }