Skip to content

Instantly share code, notes, and snippets.

View jheerman's full-sized avatar

John Heerman jheerman

View GitHub Profile
@jheerman
jheerman / Bank.cs
Created March 26, 2012 14:00
Demonstrate NHibernate implementation with DDD
using Castle.Core.Logging;
using System;
namespace Demo.Domain
{
public class Bank : LookupItem
{
public virtual string DivisionCode { get; set; }
public virtual string AccountType { get; set; }
public virtual string AccountNumber { get; set; }
@jheerman
jheerman / MessageAction
Created May 2, 2012 16:11
Action Mode Callback example to create a contextual menu for an Action Bar in M4A
private class MessageAction: Java.Lang.Object, ActionMode.ICallback
{
string _title;
string _subTitle;
public event EventHandler<EventArgs> DeleteActionHandler;
public event EventHandler<EventArgs> ViewActionHandler;
public event EventHandler<EventArgs> DestroyActionHandler;
public MessageAction (string title, string subTitle)
@jheerman
jheerman / CallbackFragment
Created May 2, 2012 16:14
Handle Action Mode Callback events from the Activity
ListView.ItemLongClick += delegate(object sender, AdapterView.ItemLongClickEventArgs e) {
//action context menu already displayed
if (_actionMode != null)
return;
var callback = new MessageAction(Activity.GetString(Resource.String.message_action_title),
Activity.GetString(Resource.String.message_action_subtitle));
callback.DeleteActionHandler += delegate {
DeleteMessage (_sortedItems[e.Position]);
@jheerman
jheerman / PrattleSmsReceiver
Created May 16, 2012 14:34
Example of M4A Service with Broadcast Receiver
[BroadcastReceiver]
public class PrattleSmsReceiver : BroadcastReceiver
{
Repository<SmsMessage> _messageRepo;
public override void OnReceive (Context context, Intent intent)
{
var message = new SmsMessage {
Text = intent.GetStringExtra ("messageText"),
SmsGroupId = intent.GetIntExtra ("smsGroupId", -1),
@jheerman
jheerman / gist:3788834
Created September 26, 2012 15:53
M4A sample to center child view in relative layout
var viewContainer = new RelativeLayout(this);
var layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent);
AddContentView (viewContainer, layoutParams);
var btn = new Button(this) { Text = "Centered" };
var btnParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
btnParams.AddRule (LayoutRules.CenterInParent);
viewContainer.AddView (btn, btnParams);
@jheerman
jheerman / gist:3802802
Created September 29, 2012 01:06
M4A TextView EditorAction Implementation
var editText = FindViewById<EditText>(Resource.Id.search);
editText.EditorAction += (object sender, TextView.EditorActionEventArgs e) => {
if (e.ActionId == ImeAction.Search) {
//do something here when search action button pressed
}
return;
};
@jheerman
jheerman / gist:4107842
Created November 18, 2012 22:19
Mono for Android Alert Dialog Example
var builder = new AlertDialog.Builder(this);
builder.SetTitle ("Test");
builder.SetIcon (Resource.Drawable.Icon);
builder.SetMessage ("Click a button");
builder.SetPositiveButton ("Yes", (sender, e) => {
Toast.MakeText (this, "You clicked positive button", ToastLength.Short).Show ();
});
builder.SetNegativeButton ("No", (sender, e) => {
@jheerman
jheerman / gist:4142537
Created November 25, 2012 05:49
M4A Spinner Focus
var spinMeUp = FindViewById<Spinner>(Resource.Id.spinMeUp);
var items = new string[] {"Up", "Down", "Left", "Right", "B", "A", "Select", "Start" };
var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, items);
spinMeUp.Adapter = adapter;
spinMeUp.Focusable = true;
spinMeUp.FocusableInTouchMode = true;
spinMeUp.RequestFocus (FocusSearchDirection.Up);
ffmpeg -f gif -i infile.gif outfile.mp4
@jheerman
jheerman / gist:d1dfe85f603bac7b0fba4ed26465a1ca
Created June 25, 2020 04:43
ffmpeg join multiple mp4 files
ffmpeg -f concat -i join.txt -c copy output.mp4