public override void ViewDidLoad() { base.ViewDidLoad(); if (!string.IsNullOrEmpty(_name)) { Name.Text = _name; } if (!string.IsNullOrEmpty(_content)) { Text.Text = _content; } var weakThis = new WeakReference <ModifyGistFileController>(this); Text.Changed += (sender, e) => weakThis.Get()?.UpdateScrollContentSize(); UpdateScrollContentSize(); var v = NameView as TappableView; if (v != null) { v.Tapped = () => weakThis.Get().Name.BecomeFirstResponder(); } }
private Element CreateElement(ContentModel x) { var weakVm = new WeakReference <SourceTreeViewModel>(ViewModel); if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase)) { var e = new StringElement(x.Name, Octicon.FileDirectory.ToImage()); e.Clicked.Subscribe(_ => weakVm.Get()?.GoToItemCommand.ExecuteNow(x)); return(e); } if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase)) { if (x.DownloadUrl != null) { var e = new StringElement(x.Name, Octicon.FileCode.ToImage()); e.Clicked.Subscribe(_ => weakVm.Get()?.GoToItemCommand.ExecuteNow(x)); return(e); } else { var e = new StringElement(x.Name, Octicon.FileSubmodule.ToImage()); e.Clicked.Subscribe(_ => weakVm.Get()?.GoToItemCommand.ExecuteNow(x)); return(e); } } return(new StringElement(x.Name) { Image = Octicon.FileMedia.ToImage() }); }
private Element CreateElement(Octokit.RepositoryContent content) { var weakRef = new WeakReference <SourceTreeViewController>(this); if (content.Type == Octokit.ContentType.Dir) { var e = new StringElement(content.Name, Octicon.FileDirectory.ToImage()); e.Clicked.Subscribe(_ => weakRef.Get()?.GoToSourceTree(content)); return(e); } if (content.Type == Octokit.ContentType.File) { if (content.DownloadUrl != null) { var e = new StringElement(content.Name, Octicon.FileCode.ToImage()); e.Style = UITableViewCellStyle.Subtitle; e.Value = content.Size.Bytes().ToString("#.#"); e.Clicked.Subscribe(_ => weakRef.Get()?.GoToFile(content)); return(e); } else { var e = new StringElement(content.Name, Octicon.FileSubmodule.ToImage()); e.Clicked.Subscribe(_ => weakRef.Get()?.GoToSubModule(content)); return(e); } } return(new StringElement(content.Name) { Image = Octicon.FileMedia.ToImage() }); }
private Element CreateElement(ContentModel x) { var weakVm = new WeakReference <SourceTreeViewModel>(ViewModel); if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase)) { var e = new StringElement(x.Name, Octicon.FileDirectory.ToImage()); e.Clicked.Subscribe(_ => weakVm.Get()?.GoToSourceTreeCommand.Execute(x)); return(e); } if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase)) { //If there's a size, it's a file if (x.Size != null) { var e = new StringElement(x.Name, Octicon.FileCode.ToImage()); e.Clicked.Subscribe(_ => weakVm.Get()?.GoToSourceCommand.Execute(x)); return(e); } else { //If there is no size, it's most likey a submodule var e = new StringElement(x.Name, Octicon.FileSubmodule.ToImage()); e.Clicked.Subscribe(_ => weakVm.Get()?.GoToSubmoduleCommand.Execute(x)); return(e); } } return(new StringElement(x.Name) { Image = Octicon.FileMedia.ToImage() }); }
public void Add(Section section) { if (section == null) { return; } _sections.Add(section); section.Root = this; _tableView.Get()?.InsertSections(MakeIndexSet(_sections.Count - 1, 1), UITableViewRowAnimation.None); }
private static Action <object> MakeCallback(GistEditViewController ctrl, string key) { var weakCtrl = new WeakReference <GistEditViewController>(ctrl); return(new Action <object>(_ => { var model = weakCtrl.Get()?._model; if (model == null || !model.Files.ContainsKey(key)) { return; } var originalGist = weakCtrl.Get()?._originalGist; var createController = new GistFileEditViewController { Filename = key, Content = model.Files[key].Content }; createController.SaveCommand.Subscribe(__ => weakCtrl.Get()?.NavigationController.PopToViewController(weakCtrl.Get(), true)); createController.Save = (name, content) => { if (string.IsNullOrEmpty(name)) { throw new InvalidOperationException("Please enter a name for the file"); } //If different name & exists somewhere else if (!name.Equals(key)) { if (weakCtrl.Get()?.IsDuplicateName(name) == true) { throw new InvalidOperationException("A filename by that type already exists"); } } if (originalGist?.Files.ContainsKey(key) == true) { model.Files[key] = new GistFileUpdate { Content = content, NewFileName = name } } ; else { model.Files.Remove(key); model.Files[name] = new GistFileUpdate { Content = content }; } }; weakCtrl.Get()?.NavigationController.PushViewController(createController, true); })); }
public string GetSchedulingDecisionSummary() { DecayRpcScheduler scheduler = delegate_.Get(); if (scheduler == null) { return("No Active Scheduler"); } else { return(scheduler.GetSchedulingDecisionSummary()); } }
public static Task SimpleCollectionLoad <T>(this CollectionViewModel <T> viewModel, Func <BitbucketSharp.Models.V2.Collection <T> > request) { var weakVm = new WeakReference <CollectionViewModel <T> >(viewModel); return(viewModel.RequestModel(request, response => { weakVm.Get()?.CreateMore(response, m => { var weak = weakVm.Get(); if (weak != null) { weak.MoreItems = m; } }, viewModel.Items.AddRange); weakVm.Get()?.Items.Reset(response.Values); })); }
public static Task SimpleCollectionLoad <T>(this CollectionViewModel <T> viewModel, GitHubRequest <List <T> > request, bool forceDataRefresh) where T : new() { var weakVm = new WeakReference <CollectionViewModel <T> >(viewModel); return(viewModel.RequestModel(request, forceDataRefresh, response => { weakVm.Get()?.CreateMore(response, m => { var weak = weakVm.Get(); if (weak != null) { weak.MoreItems = m; } }, viewModel.Items.AddRange); weakVm.Get()?.Items.Reset(response.Data); })); }
public override void ViewDidLoad() { base.ViewDidLoad(); _segmentBarButton = new UIBarButtonItem(_viewSegment); _segmentBarButton.Width = View.Frame.Width - 10f; ToolbarItems = new [] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _segmentBarButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) }; var vm = (MyIssuesViewModel)ViewModel; var weakVm = new WeakReference <MyIssuesViewModel>(vm); vm.Bind(x => x.SelectedFilter).Subscribe(x => { var goodVm = weakVm.Get(); if (x == 2 && goodVm != null) { var filter = new CodeHub.iOS.Views.Filters.MyIssuesFilterViewController(goodVm.Issues); var nav = new UINavigationController(filter); PresentViewController(nav, true, null); } // If there is searching going on. Finish it. FinishSearch(); }); this.BindCollection(vm.Issues, CreateElement); OnActivation(d => { d(vm.Bind(x => x.SelectedFilter, true).Subscribe(x => _viewSegment.SelectedSegment = (nint)x)); d(_viewSegment.GetChangedObservable().Subscribe(x => vm.SelectedFilter = x)); }); }
private static Element CreateElement(SourceTreeViewModel.SourceModel x, WeakReference <SourceTreeViewModel> viewModel) { if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase)) { var e = new StringElement(x.Name, AtlassianIcon.Devtoolsfolderclosed.ToImage()); e.Clicked.Select(_ => x).BindCommand(viewModel.Get()?.GoToSourceCommand); return(e); } if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase)) { var e = new StringElement(x.Name, AtlassianIcon.Devtoolsfile.ToImage()); e.Clicked.Select(_ => x).BindCommand(viewModel.Get()?.GoToSourceCommand); return(e); } return(new StringElement(x.Name) { Image = AtlassianIcon.Devtoolsfilebinary.ToImage() }); }
public override bool CanEditRow(UITableView tableView, Foundation.NSIndexPath indexPath) { var view = _parent.Get(); if (view == null) { return(false); } if (view._favoriteRepoSection == null) { return(false); } if (view.Root[indexPath.Section] == view._favoriteRepoSection) { return(true); } return(false); }
private void ShowLanguages() { var vm = new WeakReference <RepositoriesTrendingViewModel>(ViewModel as RepositoriesTrendingViewModel); var view = new LanguagesViewController(); view.SelectedLanguage = vm.Get()?.SelectedLanguage; view.NavigationItem.LeftBarButtonItem = new UIBarButtonItem { Image = Images.Buttons.CancelButton }; view.NavigationItem.LeftBarButtonItem.GetClickedObservable().Subscribe(_ => DismissViewController(true, null)); view.Language.Subscribe(x => { Root.Clear(); vm.Get().With(y => y.SelectedLanguage = x); DismissViewController(true, null); }); var ctrlToPresent = new ThemedNavigationController(view); ctrlToPresent.TransitioningDelegate = new SlideDownTransition(); PresentViewController(ctrlToPresent, true, null); }
public void SetButtons(List <Button> items) { foreach (var b in _buttons.Zip(items, (x, y) => new { Button = x, Data = y })) { b.Button.Caption = b.Data.Caption; b.Button.Text = b.Data.Text; b.Button.UserInteractionEnabled = true; var weakRef = new WeakReference <Button>(b.Data); b.Button.Touch = () => weakRef.Get()?.Clicked.OnNext(Unit.Default); } }
protected IssueElement CreateElement(IssueModel x) { var weakVm = new WeakReference <IBaseIssuesViewModel>(ViewModel); var isPullRequest = x.PullRequest != null && !(string.IsNullOrEmpty(x.PullRequest.HtmlUrl)); var assigned = x.Assignee != null ? x.Assignee.Login : "******"; var kind = isPullRequest ? "Pull" : "Issue"; var commentString = x.Comments == 1 ? "1 comment" : x.Comments + " comments"; var el = new IssueElement(x.Number.ToString(), x.Title, assigned, x.State, commentString, kind, x.UpdatedAt); el.Tapped += () => weakVm.Get()?.GoToIssueCommand.Execute(x); return(el); }
public override void ViewDidLoad() { base.ViewDidLoad(); TableView.EstimatedRowHeight = 64f; TableView.RowHeight = UITableView.AutomaticDimension; var vm = (GistsViewModel)ViewModel; var weakVm = new WeakReference <GistsViewModel>(vm); BindCollection(vm.Gists, x => new GistElement(x, () => weakVm.Get()?.GoToGistCommand.Execute(x))); }
protected Element CreateElement(RepositoryModel repo) { var description = ViewModel.ShowRepositoryDescription ? Emojis.FindAndReplace(repo.Description) : string.Empty; var avatar = new GitHubAvatar(repo.Owner?.AvatarUrl); var vm = new WeakReference <RepositoriesViewModel>(ViewModel); var sse = new RepositoryElement(repo.Name, repo.Watchers, repo.Forks, description, repo.Owner.Login, avatar) { ShowOwner = ViewModel.ShowRepositoryOwner }; sse.Tapped += () => vm.Get()?.GoToRepositoryCommand.Execute(repo); return(sse); }
public override void ViewDidLoad() { base.ViewDidLoad(); var vm = (ChangesetBranchesViewModel)ViewModel; var weakVm = new WeakReference <ChangesetBranchesViewModel>(vm); BindCollection(vm.Branches, x => { var e = new StringElement(x.Name); e.Clicked.Subscribe(_ => weakVm.Get()?.GoToBranchCommand.Execute(x)); return(e); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var vm = (TeamsViewModel)ViewModel; var weakVm = new WeakReference <TeamsViewModel>(vm); this.BindCollection(vm.Teams, x => { var e = new StringElement(x.Name); e.Clicked.Subscribe(_ => weakVm.Get()?.GoToTeamCommand.Execute(x)); return(e); }); }
/// <summary>Renew or replace the delegation token for this file system.</summary> /// <remarks> /// Renew or replace the delegation token for this file system. /// It can only be called when the action is not in the queue. /// </remarks> /// <returns/> /// <exception cref="System.IO.IOException"/> /// <exception cref="System.Exception"/> private bool Renew() { T fs = weakFs.Get(); bool b = fs != null; if (b) { lock (fs) { try { long expires = token.Renew(fs.GetConf()); UpdateRenewalTime(expires - Time.Now()); } catch (IOException ie) { try { Org.Apache.Hadoop.Security.Token.Token <object>[] tokens = fs.AddDelegationTokens( null, null); if (tokens.Length == 0) { throw new IOException("addDelegationTokens returned no tokens"); } token = tokens[0]; UpdateRenewalTime(renewCycle); fs.SetDelegationToken(token); } catch (IOException) { isValid = false; throw new IOException("Can't renew or get new delegation token ", ie); } } } } return(b); }
public override void ViewDidLoad() { base.ViewDidLoad(); var vm = (BaseUserCollectionViewModel)ViewModel; var weakVm = new WeakReference <BaseUserCollectionViewModel>(vm); BindCollection(vm.Users, x => { var e = new UserElement(x.Username, string.Empty, string.Empty, new Avatar(x.Avatar)); e.Clicked.Subscribe(_ => weakVm.Get()?.GoToUserCommand.Execute(x)); return(e); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var vm = (GroupsViewModel)ViewModel; var weakVm = new WeakReference <GroupsViewModel>(vm); BindCollection(vm.Organizations, x => { var e = new StringElement(x.Name); e.Clicked.Select(_ => x).BindCommand(weakVm.Get()?.GoToGroupCommand); return(e); }); }
public static GistCreateViewController Show(UIViewController parent) { var ctrl = new GistCreateViewController(); var weakVm = new WeakReference <GistCreateViewModel>(ctrl.ViewModel); ctrl.ViewModel.SaveCommand.Subscribe(_ => parent.DismissViewController(true, null)); ctrl.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel); ctrl.NavigationItem.LeftBarButtonItem.GetClickedObservable().Subscribe(_ => { weakVm.Get()?.CancelCommand.Execute().Subscribe(); parent.DismissViewController(true, null); }); parent.PresentViewController(new ThemedNavigationController(ctrl), true, null); return(ctrl); }
public override void ViewDidLoad() { base.ViewDidLoad(); var vm = (OrganizationsViewModel)ViewModel; var weakVm = new WeakReference <OrganizationsViewModel>(vm); BindCollection(vm.Organizations, x => { var avatar = new GitHubAvatar(x.AvatarUrl); var e = new UserElement(x.Login, string.Empty, string.Empty, avatar); e.Clicked.Subscribe(_ => weakVm.Get()?.GoToOrganizationCommand.Execute(x)); return(e); }); }
public override void Run() { DecayRpcScheduler sched = schedulerRef.Get(); if (sched != null) { sched.DecayCurrentCounts(); } else { // Our scheduler was garbage collected since it is no longer in use, // so we should terminate the timer as well timer.Cancel(); timer.Purge(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override public void handleMessage(@NonNull android.os.Message msg) public override void HandleMessage(Message msg) { if (mCallback == null) { return; } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final android.os.Handler.ICallback callback = mCallback.get(); ICallback callback = (ICallback)mCallback.Get(); if (callback == null) { // Already disposed return; } callback.HandleMessage(msg); }
/// <summary>Returns a unique object o' that .equals the argument o.</summary> /// <remarks> /// Returns a unique object o' that .equals the argument o. If o /// itself is returned, this is the first request for an object /// .equals to o. /// </remarks> public virtual T Intern(T o) { lock (this) { WeakReference <T> @ref = map[o]; if (@ref == null) { @ref = Generics.NewWeakReference(o); map[o] = @ref; } // else { // log.info("Found dup for " + o); // } return(@ref.Get()); } }
public MarkReadSection(string text, NotificationsView parent, bool button) : base(new CoreGraphics.CGRect(0, 0, 320, 28f)) { var weakVm = new WeakReference <NotificationsViewModel>(parent.ViewModel as NotificationsViewModel); TextLabel.Text = text; if (button) { _button = new UIButton(UIButtonType.RoundedRect); _button.SetImage(Images.Buttons.CheckButton, UIControlState.Normal); //_button.Frame = new System.Drawing.RectangleF(320f - 42f, 1f, 26f, 26f); _button.TintColor = UIColor.FromRGB(50, 50, 50); _button.TouchUpInside += (sender, e) => weakVm.Get()?.ReadRepositoriesCommand.Execute(text); Add(_button); } }
public override void ViewDidLoad() { base.ViewDidLoad(); var weakVm = new WeakReference <PullRequestFilesViewModel>(ViewModel); var weakVc = new WeakReference <PullRequestFilesView>(this); BindCollection(ViewModel.Files, x => { var name = x.Filename.Substring(x.Filename.LastIndexOf("/", StringComparison.Ordinal) + 1); var el = new StringElement(name, x.Status, UITableViewCellStyle.Subtitle); el.Image = Octicon.FileCode.ToImage(); el.Accessory = UITableViewCellAccessory.DisclosureIndicator; el.Clicked.Subscribe(_ => weakVc.Get()?.GoToFile(x)); return(el); }); }
public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, Foundation.NSIndexPath indexPath) { if (indexPath == null) { return; } switch (editingStyle) { case UITableViewCellEditingStyle.Delete: var section = Root?[indexPath.Section]; var element = section?[indexPath.Row]; section?.Remove(element); _parent.Get()?.Delete(element); break; } }