Skip to content

Instantly share code, notes, and snippets.

// Don't do it this way
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// Do this instead
LayoutInflater inflater = LayoutInflater.from(context);
<link rel="import" href="../paper-radio-group/paper-radio-group.html">
<link rel="import" href="../paper-radio-button/paper-radio-button.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@Krylez-zz
Krylez-zz / build.gradle
Created March 18, 2014 23:31
Generating a third-party license report in Android Studio
ext {
PATH_TO_SCRIPT = '../scripts/collect_licenses.py'
PATH_TO_SOURCE_ROOT = 'src'
PATH_TO_ANOTHER_SOURCE_ROOT = '../libraries/MyLibrary/src'
}
task generateLicenseReport(type:Exec) {
def script = file(PATH_TO_SCRIPT)
def sourceRoot = file(PATH_TO_SOURCE_ROOT)
def anotherSourceRoot = file(PATH_TO_ANOTHER_SOURCE_ROOT)
@Krylez-zz
Krylez-zz / facebook.py
Created January 3, 2014 00:53
Here's a quick starting point for your Android app manifest according to Facebook's established best practices.
import re
import urllib2
from BeautifulSoup import BeautifulSoup
PERMISSIONS_URL = 'http://developer.android.com/reference/android/Manifest.permission.html'
NON_THIRD_PARTY = 'Not for use by third-party applications.'
MANIFEST_START = ("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n"
public class YTUrlActivity extends Activity {
private static final String YOUTUBE = "http://www.youtube.com/watch?v=%s";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String uriString = String.format(YOUTUBE, getIntent().getData().getLastPathSegment());
Intent intent = new Intent();
intent.setData(Uri.parse(uriString));
startActivity(intent);
finish();
<activity
android:name="MyActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
<data android:host="www.youtu.be" />
<data android:host="youtu.be" />
</intent-filter>
</activity>
repositories {
// Add the local repository
maven { url '../localrepo' }
}
dependencies {
// This is built from libraries in the 'compiled-libraries'
// Replace the old dependency with this
compile ('com.rileybrewer.mylib:mylib:1.0.+')
}
// This is the main build configuration
// It lives in: compiled-libraries/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
@Krylez-zz
Krylez-zz / directories
Created October 4, 2013 18:47
Gradle directory Structure
MyProject/
| settings.gradle
+ app/
| build.gradle
+ libraries/
+ compiled-libraries/
| settings.gradle
+ lib1/
| build.gradle
+ lib2/
@Krylez-zz
Krylez-zz / build.gradle
Last active December 24, 2015 16:48
Making gradle fast(er)
dependencies {
// Java goodies
compile ('com.google.guava:guava-jdk5:14.0.+')
// Annotations (e.g. @Nullable, @Beta)
compile ('com.google.code.findbugs:jsr305:2.0.+')
}