Skip to content

Instantly share code, notes, and snippets.

View nodoid's full-sized avatar

Paul Johnson nodoid

  • Shining Knight Software
  • Merseyside, UK
View GitHub Profile
@nodoid
nodoid / gist:b51207dab96c9e24f23ea1403e2cd8bf
Created January 9, 2021 13:01
Getting the connection string for SQLite
Android:
[assembly: Dependency(typeof(SQLConnection))]
namespace MyProject.Droid
{
public class SQLConnection : ISqliteConnectionFactory
{
readonly string Filename = "db_name.db";
public SQLiteConnection GetConnection()
@nodoid
nodoid / gist:1ac1aad465626ff1901a38d1d8c22507
Created July 1, 2020 14:31
Passing an interface in Shell
I fire up my forms app with the following
(From https://github.com/CrossGeeks/SocialMediaAuthenticationSample - the services etc are implemented on the platform)
LoadApplication(new App(new OAuth2Service()));
My app.xaml.cs looks like this
public App(IOAuth2Service oAuth2Service)
{
This file has been truncated, but you can view the full file.
Task "ApplyImplicitVersions"
Done executing task "ApplyImplicitVersions".
Done building target "ApplyImplicitVersions" in project "mvvm.csproj".
Target "CheckForImplicitPackageReferenceOverrides" skipped. Previously built successfully.
Target "ProcessFrameworkReferences" in file "/usr/local/share/dotnet/sdk/3.1.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets":
Using "CheckForDuplicateFrameworkReferences" task from assembly "/usr/local/share/dotnet/sdk/3.1.100/Sdks/Microsoft.NET.Sdk/targets/../tools/net472/Microsoft.NET.Build.Tasks.dll".
Task "CheckForDuplicateFrameworkReferences"
Done executing task "CheckForDuplicateFrameworkReferences".
@nodoid
nodoid / IterateView.cs
Created April 1, 2019 23:39
Iterate views
public class IterateView
{
readonly StringBuilder sb = new StringBuilder();
const string PADDING_STRING = " ";
string sPadding = "";
public string OutputString { get; private set; }
public int NumberOfType { get; private set; }
public List<string> GetText { get; private set; }
@nodoid
nodoid / MainActivity.cs
Created March 16, 2019 11:25
Xamarin android permissions
/* you need the xamarin permissions to use this /*
static readonly int REQUEST_WRITESETTINGS = 2, REQUEST_EXTERNAL = 4, REQUEST_WIFI = 5, REQUEST_WAKELOCK = 6, REQUEST_CONTACTS;
static string[] PERMISSIONS_SETTINGS = { Manifest.Permission.WriteSettings };
static string[] PERMISSIONS_STORAGE = { Manifest.Permission_group.Storage };
static string[] PERMISSIONS_WIFISTATE = { Manifest.Permission.AccessWifiState };
static string[] PERMISSIONS_WAKELOCK = { Manifest.Permission.WakeLock };
static string[] PERMISSIONS_CONTACTS = { Manifest.Permission.ReadContacts };
@nodoid
nodoid / gist:5abcceae070a98a7f44e966584bd5aa6
Created November 13, 2018 15:24
forms navservice for mvvmlvght
public class NavigationService : INavigationService
{
readonly Dictionary<string, Type> _pagesByKey = new Dictionary<string, Type>();
NavigationPage _navigation;
public string CurrentPageKey
{
get
{
lock (_pagesByKey)
<?php
if(isset($_GET['url']))
{
echo "in";
$url = $_GET['url'];
echo $url;
$images = glob($url."*.{jpg,jpeg,png,gif}", GLOB_BRACE);
@nodoid
nodoid / ModalView
Created October 19, 2017 13:48
Dialog box
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
style="@style/lightbox_dialog">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal">
async Task Scroller(StackLayout layout, ScrollView scroll, int position)
{
await Task.Delay(layout.Children.Count * 10).ContinueWith((y) =>
{
if (y.IsCompleted)
{
var selected = layout.Children[position];
Device.BeginInvokeOnMainThread(async () => await scroll.ScrollToAsync((StackLayout)selected, ScrollToPosition.Center, true));
}
});
yourPCLNamespace.App.ScreenSize = new Size(bounds.Width, bounds.Height);