Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using MonoTouch.UIKit;
namespace Async.iOS
{
public static class Layout
{
public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
{
this.HasOptionsMenu = true;
var ignored = base.OnCreateView(inflater, container, savedInstanceState);
var view = this.BindingInflate(Resource.Layout.TimerView, null);
var leftButton = view.FindViewById<Button>(Resource.Id.LeftButton);
leftButton.Text = "\U000025C0\U0000FE0E";
var rightButton = view.FindViewById<Button>(Resource.Id.RightButton);
rightButton.Text = "\U000025B6\U0000FE0E";
06-09 11:36:16.740 I/MonoDroid(21351): UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
06-09 11:36:16.740 I/MonoDroid(21351): at V.JobTrak.Apps.Droid.Views.EnterTimeView.OnCreateView (Android.Views.LayoutInflater,Android.Views.ViewGroup,Android.OS.Bundle) <IL 0x000cf, 0x00588>
06-09 11:36:16.740 I/MonoDroid(21351): at Android.Support.V4.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (intptr,intptr,intptr,intptr,intptr) <IL 0x00026, 0x0019f>
06-09 11:36:16.740 I/MonoDroid(21351): at (wrapper dynamic-method) object.d4c53d5a-8a99-43f6-bd55-88a30287aec2 (intptr,intptr,intptr,intptr,intptr) <IL 0x00023, 0x0005f>
An unhandled exception occured.
Unhandled Exception:
Java.Lang.Throwable: Loading...
@benhysell
benhysell / Crash
Created June 9, 2014 19:03
Working Loading of Fragment without Crash
From public abstract class MvxEventSourceFragmentActivity
1. OnCreate
2. StartActivityForResult
3. OnStart
4. OnResume
5. OnPause
6. OnSaveInstanceState
7. OnStop
8. OnDestroy
@benhysell
benhysell / codebehind
Created June 18, 2014 02:16
mvvmcross winphone bind item to viewmodel command
private void UIElement_OnTap(object sender, GestureEventArgs e)
{
var selectedItem = ((HomeViewModel) ViewModel).MenuItems.FirstOrDefault(x => x.Title == ((TextBlock)sender).Text);
if(null != selectedItem)
((HomeViewModel)ViewModel).SelectMenuItemCommand.Execute(selectedItem);
}
@benhysell
benhysell / Android-setup.cs
Created June 28, 2014 18:41
Building Sql Object MvvmCross
/// <summary>
/// Creates the app.
/// </summary>
/// <returns>An instance of IMvxApplication.</returns>
protected override IMvxApplication CreateApp()
{
var connectionParameters = new SQLiteConnectionString(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "database.db"), false);
var sqliteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformAndroid());
var connection = new SQLiteAsyncConnection(() => sqliteConnectionPool.GetConnection(connectionParameters));
Mvx.RegisterSingleton<SQLiteAsyncConnection>(connection);
@benhysell
benhysell / gist:e377f0e57897e474bf69
Created October 23, 2014 12:56
oxplot data point mapping
Func<object, DataPoint> dataPointMapping;
if (weightRepository.Units == WeightRepository.LBS)
dataPointMapping = item => new DataPoint (DateTimeAxis.ToDouble (((WeightEntry)item).Date), ((WeightEntry)item).WeightLbs);
else
dataPointMapping = item => new DataPoint (DateTimeAxis.ToDouble (((WeightEntry)item).Date), ((WeightEntry)item).WeightKg);
weightLinePlot.Mapping = dataPointMapping;
Root = new RootElement("Settings")
{
new Section ("") {
(Element)new RootElement ("Units", new RadioGroup (Settings.UnitsInches ? 0 : 1)) {
new Section ("Select Units for Measurements") {
new RadioElement ("Inches"),
new RadioElement ("Centimeters"),
},
}.Bind(bindings, e => e.RadioSelected, vm => vm.UnitsIndex) as Element,
@benhysell
benhysell / Repeating Timer
Last active October 7, 2016 11:53
Rx Timer Example
Action work = () =>Console.Writeln("work!");
Scheduler.Default.Schedule(
// start in so many seconds
TimeSpan.FromSeconds(60 - DateTime.Now.Second),
// then run every minute
() => Scheduler.Default.SchedulePeriodic(TimeSpan.FromMinutes(1), work));
@benhysell
benhysell / Rx Throttle
Created October 28, 2014 14:04
Rx Throttle Event
//reactive extensions for scroll view
IEventPatternSource<EventArgs> ScrollReactSource;
/// <summary>
/// Occurs when react on decelerate. Contrived method to make working with the even easier
/// </summary>
public event EventHandler<EventArgs> ReactOnDecelerate
{
add { ScrollReactSource.OnNext += value; }
remove { ScrollReactSource.OnNext -= value; }