Skip to content

Instantly share code, notes, and snippets.

View BatriderLEL's full-sized avatar
🏠
Working from home !

BatriderLEL

🏠
Working from home !
  • Earth
View GitHub Profile
@seanfisher
seanfisher / AsyncInitializationController.cs
Last active April 10, 2023 12:42
A pattern for a Xamarin.iOS controller that permits "safe" async lifecycle methods.
using System;
using System.Threading.Tasks;
using UIKit;
namespace Seanfisher.Gists
{
public abstract class AsyncInitializationController : UIViewController
{
Task _viewDidLoadAsyncTask = Task.CompletedTask;
public virtual Task ViewDidLoadAsync()
@brendanzagaeski
brendanzagaeski / Metadata.xml
Created December 22, 2015 23:44
Some Metadata.xml fixes for binding ADTECH Mobile (http://www.adtech.com/) in Xamarin.Android
<!-- This is an example of http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding-a-java-library/troubleshooting-bindings/#Problem_Duplicate_custom_EventArgs_types
In this particular case, the conflicting definition is in
`Com.Adtech.Mobilesdk.Publisher.Vast.Player.ILinearAdPlayer`.
That interface also defines an "onError" method.
Error CS0102: The type
`Com.Adtech.Mobilesdk.Publisher.Vast.Player.ErrorEventArgs'
already contains a definition for `p0' -->
<attr path="/api/package[@name='com.adtech.mobilesdk.publisher.vast.player']/interface[@name='VideoPlayerListener']/method[@name='onError' and count(parameter)=1 and parameter[1][@type='java.lang.Exception']]" name="argsType">VideoPlayerListenerOnErrorArgs</attr>
private UIScrollView _scrollView;
private UIView _contentView;
public override void ViewDidLoad()
{
base.ViewDidLoad();
_scrollView = new UIScrollView
{
ShowsHorizontalScrollIndicator = false,
@luiseduardohd
luiseduardohd / SimulatedTransparentViewController
Created October 16, 2014 21:50
This makes uiviewcontroller appears like popup.
// This file has been autogenerated from parsing an Objective-C header file added in Xcode.
using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Collections.Generic;
using MonoTouchPlus;
using System.Drawing;
@brendanzagaeski
brendanzagaeski / Metadata.xml
Created May 20, 2014 02:33
Some Metadata.xml fixes for binding "Java WebSockets" (https://github.com/TooTallNate/Java-WebSocket/) in Xamarin.Android
<metadata>
<!-- Some Metadata.xml fixes for binding "Java WebSockets" (https://github.com/TooTallNate/Java-WebSocket/) in Xamarin.Android -->
<!-- This is a case of http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/#Problem_Duplicate_custom_EventArgs_types
Error CS0102: The type `Org.Java_websocket.WebsocketMessageEventArgs'
already contains a definition for `p0' -->
<attr path="/api/package[@name='org.java_websocket']/interface[@name='WebSocketListener']/method[@name='onWebsocketMessage' and count(parameter)=2 and parameter[1][@type='org.java_websocket.WebSocket'] and parameter[2][@type='java.nio.ByteBuffer']]" name="argsType">WebsocketMessageByteBufferEventArgs</attr>
@brendanzagaeski
brendanzagaeski / Metadata.xml
Created March 28, 2014 14:22
Metadata transforms to remove warnings in Xamarin.Android Flurry SDK binding
<metadata>
<!-- warning BG8401: Skipping Com.Flurry.Sdk.Cf.D, due to a duplicate field, method or nested type name-->
<!-- warning BG8401: Skipping Com.Flurry.Sdk.Cf.F, due to a duplicate field, method or nested type name-->
<!-- warning BG8401: Skipping Com.Flurry.Sdk.Cf.G, due to a duplicate field, method or nested type name-->
<remove-node path="/api/package[@name='com.flurry.sdk']/class[@name='cf']" />
<!-- warning BG8401: Skipping Com.Flurry.Sdk.Eh.A, due to a duplicate field, method or nested type name-->
<remove-node path="/api/package[@name='com.flurry.sdk']/class[@name='eh']" />
<!-- Warning BG8C00: For type Com.Flurry.Sdk.Bx, base interface com.flurry.sdk.cl.a does not exist. -->
@brendanzagaeski
brendanzagaeski / Metadata.xml
Last active December 7, 2021 14:22
Some Metadata.xml fixes for binding the Socialize Android SDK (http://getsocialize.com/sdk/) in Xamarin.Android
<metadata>
<!-- Some Metadata.xml fixes for binding the Socialize Android SDK (http://getsocialize.com/sdk/) in Xamarin.Android
Note that this is not a complete set of fixes. These changes only address the first round of compile errors. -->
<!-- Fixes for duplicate EventArgs, as discussed on:
http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/#Problem_Duplicate_custom_EventArgs_types
Error message: Error CS0102: The type `SomeClass` already contains a definition for `p0' (CS0102) -->
<attr path="/api/package[@name='com.socialize.auth.twitter']/interface[@name='TwitterAuthListener']/method[@name='onError' and count(parameter)=1 and parameter[1][@type='com.socialize.error.SocializeException']]" name="argsType">AuthTwitterErrorEventArgs</attr>
<attr path="/api/package[@name='com.socialize.facebook']/interface[@name='Facebook.DialogListener']/method[@name='onComplete' and count(parameter)=1 and parameter[1][@type='android.os.Bundle
@luiseduardohd
luiseduardohd / MessageBox iOs
Created February 12, 2014 16:53
simple MessageBox para Xamarin ios
public static class MessageBox
{
public static void Show(string title, string message, MessageBoxButton buttons, Action positiveCallback, Action negativeCallback)
{
UIAlertView alert = BuildAlert(title, message, buttons);
alert.Clicked += (sender, buttonArgs) =>
{
if (buttonArgs.ButtonIndex == 0)
{
@praeclarum
praeclarum / EasyLayoutExample.cs
Last active June 16, 2018 12:26
Here is an example of using my [EasyLayout](https://gist.github.com/praeclarum/6225853) library. Note the use of <= and >=, these are very difficult to write in old fashioned (frame-based) layout code. Also note the extension method GetMidY() that emulates Center.Y. You can also use GetBaseline() that works for baseline-aware views.
ContentView.ConstrainLayout (() =>
border.Frame.Top == ContentView.Frame.Top &&
border.Frame.Height == 0.5f &&
border.Frame.Left == ContentView.Frame.Left &&
border.Frame.Right == ContentView.Frame.Right &&
nameLabel.Frame.Left == ContentView.Frame.Left + hpad &&
nameLabel.Frame.Right == ContentView.Frame.GetMidX () - 5.5f &&
nameLabel.Frame.Top >= ContentView.Frame.Top + vpad &&
@dannycabrera
dannycabrera / Xamarin.iOS Image Resize
Last active January 2, 2018 21:02
Xamarin.iOS Image Resize
CGContext context = UIGraphics.GetCurrentContext ();
context.InterpolationQuality = CGInterpolationQuality.None;
context.TranslateCTM (0, newSize.Height);
context.ScaleCTM (1f, -1f);
context.DrawImage (new RectangleF (0, 0, newSize.Width, newSize.Height), source.CGImage);
var scaledImage = UIGraphics.GetImageFromCurrentImageContext();