Skip to content

Instantly share code, notes, and snippets.

View softlion's full-sized avatar

ZeBen softlion

View GitHub Profile
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
* https://gist.github.com/424774
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function($) {
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.fn.textchanged = function() {
@softlion
softlion / TextViewImeActionBinding.axml
Last active January 2, 2016 07:28
TextViewImeActionBinding
<TextView
local:MvxBind="Text PasswordConfirm; ImeAction RegisterCommand"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:imeOptions="actionSend" />
@softlion
softlion / MvxRadioGroupSelectedIndexBinding.cs
Last active May 13, 2021 18:59
mvvmcross : Bind a static RadioGroup using zero based indexes
/// <summary>
/// Author: softlion (softlion@softlion.com)
/// </summary>
/// <remarks>
/// Thanks to: Stuart Lodge
/// </remarks>
public class MvxRadioGroupSelectedIndexBinding : MvxAndroidTargetBinding
{
bool stopListeningCheckChanged = false;
protected static void AddParallaxEffect(UIView back)
{
//var frame = back.Frame;
//back.Superview.RemoveConstraints(back.Superview.Constraints.Where(c => c.FirstItem == back).ToArray());
//back.Frame = frame;
var keypathx = "constraints[0].constant";
var keypathy = "constraints[1].constant";
var xMotionEffect = new UIInterpolatingMotionEffect(keypathx, UIInterpolatingMotionEffectType.TiltAlongHorizontalAxis)
@softlion
softlion / MvxNetworkActivityIndicatorTargetBinding.cs
Created April 6, 2015 09:16
MvxNetworkActivityIndicatorTargetBinding for mvvmcross iOS
public abstract class MvxTargetBinding2 : MvxBinding, IMvxTargetBinding
{
private readonly object _target;
protected MvxTargetBinding2(object target)
{
_target = target;
}
protected object Target
@softlion
softlion / MvxJsonTextSerializer.cs
Created May 22, 2015 09:12
Implementation of an IMvxTextSerializer that can be put inside a PCL and uses the latest version of Newtonsoft.Json
internal class MvxJsonTextSerializer : IMvxJsonConverter
{
private static readonly JsonSerializerSettings Settings;
public static void Register()
{
Mvx.RegisterType<IMvxJsonConverter, MvxJsonTextSerializer>();
Mvx.RegisterType<IMvxTextSerializer, MvxJsonTextSerializer>();
}
@softlion
softlion / MainPage.xaml
Created August 26, 2015 14:20
Fix for XamSvg in a button on Xamarin Android Forms
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:demo="clr-namespace:XamSvg.Demo;assembly=XamSvg.Demo"
x:Class="XamSvg.Demo.MainPage"
BackgroundColor="#E08080"
Title="XamSvg Demo">
<demo:MyButton x:Name="TestButton" Text="TestText" />
@softlion
softlion / ActivityLifecycleHelper.cs
Created January 25, 2016 09:59
ActivityLifecycleCallbacksHelper to get TopActivity from anywhere
public sealed class ActivityLifecycleHelper : IDisposable
{
private readonly ActivityLifecycleCallbacksHelper activityLifecycle = new ActivityLifecycleCallbacksHelper();
private Android.App.Application application;
public Activity TopActivity { get; private set; }
public ActivityLifecycleHelper(Android.App.Application application)
{
this.application = application;
@softlion
softlion / BaseViewModel.cs
Last active February 26, 2016 13:49
ShowViewModelAsync and InvokeOnMainThreadAsync for MvvmCross. Also adds OnBack/OnBack2 methods on viewmodels.
public class BaseViewModel : MvxViewModel, IBackViewModel
{
#region InvokeOnMainThreadAsync
protected Task InvokeOnMainThreadAsync(Action action)
{
var tcs = new TaskCompletionSource<bool>();
if (Dispatcher != null)
{
Dispatcher.RequestMainThreadAction(() =>
{