Permalink
Browse files

Fixes and cleanup

  • Loading branch information...
1 parent b1e9498 commit 2ed094b7e7d3c0001aff3e863756c236e0e99a2a @RobertKozak committed Dec 24, 2011
Showing with 1,304 additions and 334 deletions.
  1. +123 −0 Application/HttpDebug.cs
  2. +5 −13 Application/MonoMobileAppDelegate.cs
  3. +5 −6 Application/MonoMobileApplication.cs
  4. +5 −0 Application/ObservableObject.cs
  5. +11 −1 Application/SuspendNotificationContext.cs
  6. +443 −0 Application/UrlImageStore.cs
  7. +2 −1 Commands/ReflectiveCommand.cs
  8. +1 −2 Controllers/PhotoPickerController.cs
  9. +5 −3 Controls/CommandBarButtonItem.cs
  10. +4 −4 Controls/ProgressHud.cs
  11. +0 −1 Controls/UIKeyboardToolBar.cs
  12. +1 −1 Controls/UIPlaceholderTextField.cs
  13. +102 −21 Dialog/Cell/ComposableViewListCell.cs
  14. +91 −30 Dialog/Cell/Theme.cs
  15. +23 −2 Dialog/CellViews/Base/CellView.cs
  16. 0 Dialog/CellViews/Base/{CommandView.cs → CommandCellView.cs}
  17. +2 −3 Dialog/CellViews/Base/FocusableCellView.cs
  18. +1 −1 Dialog/CellViews/Base/ObjectCellView.cs
  19. +0 −4 Dialog/CellViews/Templates/DateAttribute.cs
  20. +15 −10 Dialog/CellViews/Templates/EntryAttribute.cs
  21. +40 −30 Dialog/DialogViewController/BaseDialogViewSource.cs
  22. +12 −1 Dialog/DialogViewController/DataContextBinder.cs
  23. +81 −50 Dialog/DialogViewController/DialogViewController.cs
  24. +37 −11 Dialog/DialogViewController/ListSource.cs
  25. +56 −40 Dialog/DialogViewController/MemberData.cs
  26. +87 −0 Dialog/DialogViewController/NavigationController.cs
  27. +1 −0 Dialog/DialogViewController/ViewSource.cs
  28. +11 −13 Dialog/ImageLoader.cs
  29. +6 −5 Dialog/RefreshTableHeaderView.cs
  30. +17 −0 Dialog/Section.cs
  31. +44 −46 Dialog/ViewParser.cs
  32. +1 −1 Extensions/TypeExtensions.cs
  33. +29 −14 Interfaces/ITappable.cs → Extensions/UIKitExtensions.cs
  34. +8 −7 Dialog/ViewNavigator.cs → Interfaces/ICommandButton.cs
  35. +8 −5 MonoMobile.Views.csproj
  36. +0 −1 Registrations.cs
  37. +1 −1 View/ObservableView.cs
  38. +15 −1 View/View.cs
  39. +11 −5 ViewModel/ViewModel.cs
View
@@ -0,0 +1,123 @@
+using System;
+using System.Net;
+using System.Threading;
+using System.IO;
+using System.Linq;
+using MonoTouch.Foundation;
+
+namespace MonoMobile.Views
+{
+ public class HttpDebug: NSObject
+ {
+ static HttpListener listener;
+ static Thread handlerThread;
+
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing && listener != null)
+ {
+ listener.Close();
+ }
+
+ base.Dispose(disposing);
+ }
+
+ ~HttpDebug()
+ {
+ Dispose(false);
+ }
+
+ static public void Start()
+ {
+ handlerThread = new Thread(HttpServer);
+ handlerThread.Start();
+ }
+
+ static void HttpServer()
+ {
+ listener = new HttpListener();
+ listener.Prefixes.Add("http://*:5000/");
+ listener.Start();
+ while (true)
+ {
+ var context = listener.GetContext();
+ var request = context.Request;
+ var response = context.Response;
+
+ var tw = new StreamWriter(response.OutputStream);
+
+ var path = request.Url.AbsolutePath;
+ if (path.StartsWith("/type/"))
+ {
+ ShowInstancesOf(tw, path.Substring(6));
+ }
+ else
+ {
+ Summary(tw);
+ }
+
+ tw.Flush();
+ response.OutputStream.Close();
+ }
+ }
+
+ static void Header(TextWriter c, string title, string script = null)
+ {
+ c.WriteLine(
+ "<html><head><title>{0}</title>\n" +
+ "<head>\n" +
+ " <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js'></script>", title);
+ if (script != null)
+ {
+ c.WriteLine("<script>$(document).ready(function () {{ {0} }});</script>", script);
+ }
+ c.WriteLine("</head><body>");
+ }
+
+ static void Summary(TextWriter c)
+ {
+ Header(c, "Summary", "$(\"a.type\").click (function (e) { $(this).append ('<div></div>'); $(this).children ().load ('/type/'); console.log ($(this).contents ()); e.preventDefault ();});");
+ //Header (c, "Summary", "alert ('loaded');");
+ var weakList = MonoTouch.ObjCRuntime.Runtime.GetSurfacedObjects();
+ c.WriteLine("<div id='foo'></div>");
+ c.WriteLine("<p>Total surfaced objects: {0}", weakList.Count);
+ var groups = from weak in weakList
+ let nso = weak.Target
+ where nso != null
+ let typeName = nso.GetType().FullName
+ orderby typeName
+ group nso by typeName into g
+ let gCount = g.ToList().Count
+ orderby gCount descending
+ select new { Type = g.Key, Instances = g };
+ var list = groups.ToList();
+ c.WriteLine("<p>Have {0} different types surfaced", list.Count);
+ c.WriteLine("<ul>");
+ foreach (var type in list)
+ {
+ c.WriteLine("<li>{1} <a href='' class='type'>{0}</a>", type.Type, type.Instances.ToList().Count);
+ }
+ c.WriteLine("</ul>");
+ c.WriteLine("</body></html>");
+ }
+
+ static void ShowInstancesOf(TextWriter c, string type)
+ {
+ var weakList = MonoTouch.ObjCRuntime.Runtime.GetSurfacedObjects();
+ var res = from weak in weakList
+ let nso = weak.Target
+ where nso != null
+ let typeName = nso.GetType().FullName
+ where typeName == type
+ select nso;
+
+ c.WriteLine("<ul>");
+ foreach (NSObject nso in res)
+ {
+ c.WriteLine("<li>0x{0:x}</li>", nso.Handle);
+ }
+ c.WriteLine("</ul>");
+ }
+
+ }
+}
@@ -31,20 +31,19 @@ namespace MonoMobile.Views
{
using System;
using System.Collections.Generic;
- using System.ComponentModel;
using System.Linq;
- using System.Threading;
using MonoTouch.Foundation;
- using MonoTouch.UIKit;
+ using MonoTouch.UIKit;
[Register("MonoMobileAppDelegate")]
public class MonoMobileAppDelegate : UIApplicationDelegate
{
// This method is invoked when the application has loaded its UI and its ready to run
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
- MonoMobileApplication.NavigationController = new UINavigationController();
-
+ HttpDebug.Start ();
+
+ MonoMobileApplication.NavigationController = new NavigationController();
MonoMobileApplication.Window = new UIWindow(UIScreen.MainScreen.Bounds);
MonoMobileApplication.Window.AddSubview(MonoMobileApplication.NavigationController.View);
@@ -70,9 +69,6 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)
private static void Startup()
{
- var sw = new System.Diagnostics.Stopwatch();
- sw.Start();
-
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach(var assembly in assemblies)
{
@@ -90,10 +86,6 @@ private static void Startup()
}
}
}
-
- sw.Stop();
-
- Console.WriteLine("Initialized in :" + sw.Elapsed.Milliseconds);
MonoMobileApplication.Views = new List<object>();
foreach (var viewType in MonoMobileApplication.ViewTypes)
@@ -113,7 +105,7 @@ private static void Startup()
foreach(var view in MonoMobileApplication.Views)
{
- MonoMobileApplication.DialogViewControllers.Add(new DialogViewController(MonoMobileApplication.Title, view, new Theme(), true) { Autorotate = true } );
+ MonoMobileApplication.DialogViewControllers.Add(new DialogViewController(MonoMobileApplication.Title, view, Theme.CreateTheme(), true) { Autorotate = true } );
}
MonoMobileApplication.NavigationController.ViewControllers = MonoMobileApplication.DialogViewControllers.ToArray();
@@ -150,14 +150,15 @@ public static void PresentModelView(object view, UIModalTransitionStyle transist
var dvc = CreateDialogViewController(view, true, false);
dvc.ModalTransitionStyle = transistionStyle;
- var navController = new UINavigationController() { ViewControllers = new UIViewController[] { dvc } };
+ var navController = new NavigationController() { ViewControllers = new UIViewController[] { dvc } };
NavigationController.PresentModalViewController(navController, true);
}
public static void DismissModalView(bool animated)
{
NavigationController.DismissModalViewControllerAnimated(animated);
+ NavigationController.VisibleViewController.Dispose();
}
public static void Run(string title, Type mainViewType, string[] args)
@@ -188,9 +189,8 @@ private static DialogViewController CreateDialogViewController(object view, bool
if (CurrentDialogViewController != null)
{
theme = CurrentDialogViewController.Theme;
- if (theme == null)
- theme = new Theme();
- theme.TableViewStyle = UITableViewStyle.Grouped;
+ theme = Theme.CreateTheme(theme);
+ theme.TableViewStyle = UITableViewStyle.Grouped;
}
string title = null;
@@ -203,8 +203,7 @@ private static DialogViewController CreateDialogViewController(object view, bool
if (string.IsNullOrEmpty(title))
title = MonoMobileApplication.Title;
- var dvc = new DialogViewController(title, view, theme, pushing) { Autorotate = true };
- dvc.IsModal = isModal;
+ var dvc = new DialogViewController(title, view, theme, pushing) { Autorotate = true, IsModal = isModal };
return dvc;
}
@@ -47,6 +47,11 @@ public class ObservableObject : NSObject, IObservableObject
public IDictionary<string, object> PropertyMap { get { return _PropertyMap; } set { _PropertyMap = value; } }
+ public void UnsubscribeAllNotifications()
+ {
+ PropertyChanged = null;
+ }
+
public void NotifyPropertyChanged(string propertyName)
{
if (!_SuspendNotifications)
@@ -31,7 +31,6 @@ namespace MonoMobile.Views
{
using System;
using System.Collections.Generic;
- using System.ComponentModel;
public class SuspendNotificationContext : IDisposable
{
@@ -54,7 +53,18 @@ public SuspendNotificationContext(IEnumerable<IObservableObject> observableObjec
}
}
+ ~SuspendNotificationContext()
+ {
+ Dispose(false);
+ }
+
public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ public void Dispose(bool disposing)
{
foreach (var observableObject in _ObservableObjects)
{
Oops, something went wrong.

0 comments on commit 2ed094b

Please sign in to comment.