Skip to content

Instantly share code, notes, and snippets.

View atermenji's full-sized avatar

Artur Termenji atermenji

View GitHub Profile
@cyrilmottier
cyrilmottier / ResourcesAdditions.java
Last active January 12, 2024 17:55
Lightweight key-value pairs resources for Android applications.
package com.cyrilmottier.android.resourcesadditions;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.os.Bundle;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* @author Cyril Mottier
@briangriffey
briangriffey / CuttingOffTextView.java
Created November 13, 2013 22:14
Makes sure text doesn't go beyond the boundaries of its measured height and adjusts itself to the maximum appropriate lines.
package com.vice.viceforandroid.views;
import android.content.Context;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.TextView;
/**
* Created by briangriffey on 11/13/13.
@jasonrudolph
jasonrudolph / 00-about-search-api-examples.md
Last active April 30, 2024 19:21
5 entertaining things you can find with the GitHub Search API
@JakeWharton
JakeWharton / dex.sh
Last active March 25, 2024 13:54
`classes.dex` method count helpers. Requires smali/baksmali from https://code.google.com/p/smali/ and dexdump from the build-tools in the Android SDK be on your PATH.
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
}
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)
name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.')
@swankjesse
swankjesse / RetrofitCachingExample.java
Created June 29, 2013 03:03
Demonstrate HTTP caching with OkHttp and Retrofit.
/*
* Copyright (C) 2013 Square, 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
*
* Unless required by applicable law or agreed to in writing, software
@jpeddicord
jpeddicord / build.gradle
Last active April 14, 2023 20:31
Release APK builder that asks for your key passwords interactively, so you don't have to store them in your build script or VCS. For use with the Gradle build system. CC0 license.
// additional required configuration to hook into the build script
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
@johnkil
johnkil / DbUtils.java
Last active December 16, 2015 13:48
Utilities to work with SQLite database (based on http://udinic.wordpress.com/2012/05/09/sqlite-drop-column-support).
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.text.TextUtils;
/**
@JakeWharton
JakeWharton / BindingAdapter.java
Last active July 25, 2023 05:49
An adapter base class that uses a new/bind pattern for its views.
// Apache 2.0 licensed.
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/** An implementation of {@link BaseAdapter} which uses the new/bind pattern for its views. */
public abstract class BindableAdapter<T> extends BaseAdapter {
@imminent
imminent / ObjectGraph.java
Last active October 23, 2017 07:39
Dagger `ObjectGraph` utility to hide the mess of injecting the different Android classes. Note this is inspired by https://github.com/pyricau/CleanAndroidCode/blob/master/cleanandroidcode/src/main/java/info/piwai/cleanandroidcode/base/GraphRetriever.java
import javax.annotation.Nonnull;
import android.app.Activity;
import android.app.Service;
import android.support.v4.app.Fragment;
import android.content.Context;
/**
* <p>Retrieves the {@link dagger.ObjectGraph} and injects dependencies.</p>
* @author Dandré Allison
@frankiesardo
frankiesardo / QuickReturn.java
Last active December 14, 2015 22:49
A refactored version of LarsWerkman's QuickReturnListView. It should provide an easier to use API and an easier to understand library.
public class QuickReturn {
private final static int ANIMATION_DURATION_MILLIS = 250;
private final ListView listView;
private final View quickReturnView;
private final View headerPlaceholder;
private int itemCount;
private int itemOffsetY[];