Skip to content

Instantly share code, notes, and snippets.

@medhdj
medhdj / locking.swift
Created April 25, 2016 15:19 — forked from kristopherjohnson/locking.swift
Simple synchronization functions for Swift, wrapping the Cocoa NSLocking classes
import Foundation
/// Protocol for NSLocking objects that also provide tryLock()
public protocol TryLockable: NSLocking {
func tryLock() -> Bool
}
// These Cocoa classes have tryLock()
extension NSLock: TryLockable {}
extension NSRecursiveLock: TryLockable {}
// LXTouchGestureRecognizer.h
//
// Copyright (c) 2015 Stan Chang Khin Boon (http://lxcid.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
// furnished to do so, subject to the following conditions:
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.os.Parcel;
import android.os.Parcelable;
@medhdj
medhdj / Manager.java
Last active August 29, 2015 14:18 — forked from goodev/Manager.java
//change de.keyboardsurfer.android.widget.crouton.Manager class
// add this method below 'handleTranslucentActionBar()' method
private void handleActionBarOverlay(ViewGroup.MarginLayoutParams params, Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
final boolean flags = activity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
if (flags) {
final int actionBarContainerId = Resources.getSystem().getIdentifier("action_bar_container", "id", "android");
final View actionBarContainer = activity.findViewById(actionBarContainerId);
// The action bar is present: the app is using a Holo theme.
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.os.Parcel;
import android.os.Parcelable;
package com.example.android.customchoicelist;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
@medhdj
medhdj / CustomSpinner
Created December 29, 2014 19:59
A custom Spinner with opened and closed event, you can use it to perform some UI changes on the Spinner for example
import android.content.Context;
import android.util.AttributeSet;
import android.widget.Spinner;
public class CustomSpinner extends Spinner {
// private static final String TAG = "CustomSpinner";
private OnSpinnerEventsListener mListener;
private boolean mOpenInitiated = false;