Skip to content

Instantly share code, notes, and snippets.

View benoitjadinon's full-sized avatar

Benoit Jadinon benoitjadinon

View GitHub Profile
@rid00z
rid00z / BindablePropertyTemplate.cs
Created September 19, 2015 02:00
Visual/Xamarin Studio - Bindable Property Template for Xamarin.Forms
public static readonly BindableProperty $Name$Property =
BindableProperty.Create<$owner$, $type$>(
p => p.$Name$, default($type$));
public $type$ $Name$ {
get { return ($type$)GetValue($Name$Property); }
set { SetValue($Name$Property, value); }
}
@cesarferreira
cesarferreira / RxJava.md
Last active March 30, 2025 00:28
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
@martijn00
martijn00 / RecyclerViewActivity.cs
Last active March 18, 2024 22:13
Load more / endless scroll for Xamarin RecyclerView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var view = base.OnCreateView(inflater, container, savedInstanceState);
var recyclerView = view.FindViewById<RecyclerView>(Resource.Id.my_recycler_view);
if (recyclerView != null)
{
recyclerView.HasFixedSize = true;
var layoutManager = new LinearLayoutManager(Activity);
@keyboardr
keyboardr / HeadlessFragment.java
Last active December 31, 2021 01:05
A file template for creating a headless Fragment. The attach() methods add the fragment to the parent if it doesn't already exist and returns the attached fragment. The methods ensure that the parent implements the parent interface. If needed, parameters may be added to the attach() methods to supply fragment arguments.
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
#parse("File Header.java")
public class ${NAME} extends Fragment {
private static final String FRAG_TAG = ${NAME}.class.getCanonicalName();
@passsy
passsy / OperatorSemaphore.java
Created April 28, 2015 14:33
A Presenter when using RxAndroid which delays delivering to the View when the View isn't ready
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Konstantin Mikheev sirstripy-at-gmail-com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@aspnetde
aspnetde / .View
Last active September 28, 2021 10:11
Xamarin.iOS MemoryUtility
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.MessageUI;
using MonoTouch.UIKit;
namespace MyApp
{
public interface ICanCleanUpMyself
{
@nirinchev
nirinchev / UITableViewExtensions
Last active August 29, 2015 14:15
An extension method to dequeue a cell for use in UITableViewController.GetCell
public static T DequeueReusableCell<T> (this UITableView tableView) where T : UITableViewCell
{
var identifier = typeof(T).Name;
var cell = tableView.DequeueReusableCell (identifier);
if (cell == null)
{
// Nib with the class name MUST exist in the name bundle
var nib = UINib.FromName (identifier, NSBundle.MainBundle);
tableView.RegisterNibForCellReuse (nib, identifier);
@kpespisa
kpespisa / EpochConversion
Created February 20, 2015 16:39
Convert to and from Epoch
public static class DateTimeHelper
{
private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static DateTime UnixTimeToDateTime(string text)
{
double seconds = double.Parse(text, CultureInfo.InvariantCulture);
var time = Epoch.AddSeconds(seconds);
return time;
@kpespisa
kpespisa / SQLiteExtensions
Last active June 2, 2017 07:04
Save and Delete Extensions to SQLite-NET
public static class SQLiteExtensions
{
/// <summary>
/// Save the specified entity by calling insert or update, if the entity already exists.
/// </summary>
/// <param name="pk">The primary key of the entity</param>
/// <param name="obj">The instance of the entity</param>
/// <typeparam name="T">The entity type.</typeparam>
public static int Save<T>(this SQLiteConnection db, object pk, object obj) where T : class, new()
{
@rdavisau
rdavisau / InlineTableViewSource
Last active August 29, 2015 14:15
InlineTableViewSource
/*
Snippet Name: InlineTableViewSource
Platform: iOS
Function: A subclass of UITableViewSource that allows you to define UITableViewDataSource and UITableViewDelegate methods inline, rather than subclassing. Lets you take advantage of closures and use tableviews where you can't create subclasses, like in Xamarin Sketches (compile and reference).
Funcs/Actions are prefixed with "_", feel free to alter if this disagrees with your styling guidelines.
Usage:
var cellId = new NSString("cell");