Skip to content

Instantly share code, notes, and snippets.

View Cheesebaron's full-sized avatar
🧀
Send cheese please

Tomasz Cielecki Cheesebaron

🧀
Send cheese please
View GitHub Profile
@Cheesebaron
Cheesebaron / Main.axml
Last active March 15, 2023 19:30
Small sample showing how to use SearchView with the Support v7 ActionBar. See the tutorial here: http://youtu.be/4FvObC44bhM
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
@Cheesebaron
Cheesebaron / Chemical.cs
Last active March 15, 2023 19:30
Custom Adapter with Filter
namespace SearchViewSample
{
public class Chemical
{
public string Name { get; set; }
public int DrawableId { get; set; }
}
}
@Cheesebaron
Cheesebaron / JavaHolder.cs
Last active March 15, 2023 19:30
C# to Java object wrapper
using System;
public class JavaHolder : Java.Lang.Object
{
public readonly object Instance;
public JavaHolder(object instance)
{
Instance = instance;
}
[Activity(Label = "Pseudo MultiColumn", MainLauncher = true, Icon = "@drawable/icon")]
public class SuperAwesomeActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.main);
<cheesebaron.slidinguppanel.SlidingUpPanelLayout
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Your main content inside here -->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="App1.App1" android:versionCode="1"
android:versionName="1.0" android:installLocation="auto">
<application android:label="App1" android:icon="@drawable/Icon"></application>
<uses-permission android:name="android.permission.READ_CONTACTS" />
</manifest>
var registrationId = string.Empty;
var allRegistrations = await hubClient.GetAllRegistrationsAsync(10);
foreach (var registration in allRegistrations)
{
switch (deviceType)
{
case NotificationSubscriptionV1.DeviceTypes.Android:
{
var reg = registration as GcmRegistrationDescription;
[Activity(Label = "DialogActivity", Theme = "@style/PopupTheme")]
public class DialogActivity : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
ShowAsPopup(this, Resource.Layout.Main);
}
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.ServiceBus.Notifications;
namespace Cheesebaron.Extensions
{
public static class NotificationHubClientExtensions
{
public static async Task<NotificationOutcome> SendNotificationAsync(this NotificationHubClient client, NotificationHubClientPlatform platform,
string payload, string tagExpression)
@Cheesebaron
Cheesebaron / urlstuff.cs
Created August 12, 2014 12:30
Just a simple LINQ query to split an URL's query into a key/value dictionary. Useful in PCL's where there is not HttpUtility class.
static Dictionary<string, string> QueryToKeyValueDictionary(string url)
{
return
url.Substring(url.IndexOf('?') + 1)
.Split('&')
.Select(pair => pair.Split('='))
.ToDictionary(val => val[0], val => Uri.UnescapeDataString(val[1]));
}