Skip to content

Instantly share code, notes, and snippets.

@granoeste
granoeste / build.gradle
Created November 5, 2014 01:07
Android Studio build.gradle Template of dependencies
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'android-power-assert'
group = 'net.granoeste'
version = '1.0.0'
def AAVersion = '3.0.1'
android {
@granoeste
granoeste / pom.xml
Created May 1, 2014 08:59
[Android][Maven][AndroidAnnotations] androidManifestFile options in pom.xml
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
<!-- does not work. -->
<!--
<compilerArguments>
<AandroidManifestFile>${project.basedir}/src/main/AndroidManifest.xml</AandroidManifestFile>
@granoeste
granoeste / webkitmediasource-is-type-supported.html
Last active December 26, 2021 10:54
[JavaScript][HTML5][MediaSource] MediaSource.isTypeSupported
<!DOCTYPE html>
<html>
<head>
<script>
window.MediaSource = window.MediaSource || window.WebKitMediaSource;
function testTypes(types) {
for (var i = 0; i < types.length; ++i)
console.log("MediaSource.isTypeSupported(" + types[i] + ") : " + MediaSource.isTypeSupported(types[i]));
}
@granoeste
granoeste / Setup maven-android.md
Last active September 14, 2021 19:22
[Android] setup maven-android
@granoeste
granoeste / GoogleCastSdkAndroid#pom.xml
Last active January 3, 2016 05:09
[Android] Android Maven Configuration (pom.xml) with AppCompat and MediaRouter and GoogleCastSdkAndroid. Before that, build by changing the maven configure the GoogleCastSdkAndroid library project.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cast</groupId>
<artifactId>com.google.cast</artifactId>
<version>1.0.6</version>
<packaging>apklib</packaging>
<name>com.google.cast</name>
@granoeste
granoeste / BusProvider.java
Last active January 2, 2016 18:49
[Android] Run the post method of the Otto Bus in the Main thread always. And Discussion the Observer/Observable(Callback) pattern. - Case01: Activity/Fragment using a dedicated callback. (the observer pattern) - Case02: Activity/Fragment using a common callback. (the observer pattern) - Case03: Activity/Fragment using a LocalBroadcastManager. - …
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import com.squareup.otto.Bus;
public final class BusProvider {
private static final Object sLock = new Object();
private static MyBus sInstance;
@granoeste
granoeste / isRunningMainThread.java
Created December 27, 2013 01:57
[Android] Running on UI Thread ?
Thread.currentThread().equals(context.getMainLooper().getThread());
@granoeste
granoeste / InputOutput.java
Last active December 30, 2015 07:58
[java] I/O
/* Input / Output Memo */
BufferedReader r = new BufferedReader(
new InputStreamReader(
new FileInputStream( filename ), encoding ));
String line = r.readLine();
@granoeste
granoeste / MyApplication.java
Last active December 21, 2015 22:19
[Android] Template that uses WebView
public class MyApplication extends Application {
@Override
public void onCreate() {
// To use the CookieSyncManager, the host application has to call the following when the application starts:
CookieSyncManager.createInstance(this);
}
}