Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ckurtm
ckurtm / AndroidManifest.xml
Created November 2, 2015 06:18
Example on how to use adb to start an Activity,BroadcastReceiver or Service from adb and include intent extras too. for Activity: adb shell am start -n "com.peirr.test/com.peirr.test.MyActivity" --es name "John" --ei age 30 for BroadcastReceiver adb shell am broadcast -n "com.peirr.test/com.peirr.test.MyReceiver" --es name "John" --ei age 30 for…
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.peirr.test">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@ckurtm
ckurtm / ThreeTenABP
Created February 16, 2016 11:38
ThreeTenABP quick start
LocalDateTime ldt = LocalDateTime.now();
int ld = ldt.getDayOfMonth();
int lm = ldt.getMonthValue();
int ly = ldt.getYear();
Log.d(TAG,"3ten : "+ldt.toString());
Log.d(TAG,"3ten : [day: "+ld+"] [month: "+lm+"] [year: "+ly+"]");
Log.d(TAG,"3ten : [day: "+ldt.getDayOfWeek().name()+"] [month: "+ldt.getMonth().name()+"] [year: "+ldt.getYear()+"]");
ldt.withYear(2000);
@ckurtm
ckurtm / Jodatime.java
Last active February 16, 2016 11:37
Jodatime quick start
DateTime dt = DateTime.now();
int jd = dt.getDayOfMonth();
int jm = dt.getMonthOfYear();
int jy = dt.getYear();
Log.d(TAG,"Joda : "+ dt.toString());
Log.d(TAG,"Joda : [day: "+jd+"] [month: "+jm+"] [year: "+jy+"]");
Log.d(TAG,"Joda : [day: "+dt.dayOfWeek().getAsText()+"] [month: "+dt.monthOfYear().getAsText()+"] [year: "+dt.year().getAsText()+"]");
dt.withYear(2000);
dt.plusHours(2);
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
@ckurtm
ckurtm / HeadlessFragment.java
Created November 26, 2015 08:42 — forked from keyboardr/HeadlessFragment.java
A file template for creating a headless Fragment. The attach() methods add the fragment to the parent if it doesn't already exist and returns the attached fragment. The methods ensure that the parent implements the parent interface. If needed, parameters may be added to the attach() methods to supply fragment arguments.
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
#parse("File Header.java")
public class ${NAME} extends Fragment {
private static final String FRAG_TAG = ${NAME}.class.getCanonicalName();
@ckurtm
ckurtm / TintActivity.java
Created October 29, 2015 08:20
Dynamically change color of a drawable using TintDrawables
package com.peirra.tint;
import android.graphics.Color;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import java.util.Random;
@ckurtm
ckurtm / DrawableDrawableResoureDecoder.java
Last active August 29, 2015 14:27 — forked from TWiStErRob/DrawableDrawableResoureDecoder.java
Glide 3.6.0 proof of concept for loading a Drawable as Drawable through Glide
class DrawableResoureDecoder implements ResourceDecoder<Drawable, Drawable> {
@Override public Resource<Drawable> decode(Drawable source, int width, int height) throws IOException {
return new DrawableResource<Drawable>(source) {
@Override public int getSize() { return 1; }
@Override public void recycle() { }
};
}
@Override public String getId() { return "DrawableDrawableResourceDecoder"; }
}