Skip to content

Instantly share code, notes, and snippets.

View johnkil's full-sized avatar

Evgenii Shishkin johnkil

View GitHub Profile
@johnkil
johnkil / ViewHoldingAdapter.java
Created April 26, 2012 18:31 — forked from JakeWharton/ViewHoldingAdapter.java
Template for a list adapter which uses a view holder to cache lookups.
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder vh = ViewHolder.get(convertView, parent);
Item item = getItem(position);
vh.title.setText(item.title);
vh.subtitle.setText(item.subtitle);
return vh.root;
}
@johnkil
johnkil / AspectRatioImageView.java
Created June 2, 2012 05:13 — forked from JakeWharton/AspectRatioImageView.java
ImageView that respects an aspect ratio applied to a specific measurement.
// Copyright 2012 Square, Inc.
package com.squareup.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;
/** Maintains an aspect ratio based on either width or height. Disabled by default. */
public class AspectRatioImageView extends ImageView {
/**
* Execute an {@link AsyncTask} on a thread pool.
*
* @param task Task to execute.
* @param args Optional arguments to pass to {@link AsyncTask#execute(Object[])}.
* @param <T> Task argument type.
*/
public <T> void execute(AsyncTask<T, ?, ?> task, T... args) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.DONUT) {
throw new UnsupportedOperationException("This class can only be used on API 4 and newer.");
@johnkil
johnkil / .gitignore
Created September 11, 2012 14:25 — forked from keyboardsurfer/.gitignore
Android gitignore
# built application files
*.apk
*.ap_
*.jar
# keystore
*.keystore
# files for the dex VM
*.dex
@johnkil
johnkil / FeedbackAndroid.java
Created November 10, 2012 09:57 — forked from TomTasche/feedback_android.java
Use built-in feedback mechanism on Android
// more information here: http://blog.tomtasche.at/2012/10/use-built-in-feedback-mechanism-on.html
try {
int i = 3 / 0;
} catch (Exception e) {
ApplicationErrorReport report = new ApplicationErrorReport();
report.packageName = report.processName = getApplication()
.getPackageName();
report.time = System.currentTimeMillis();
report.type = ApplicationErrorReport.TYPE_CRASH;
@johnkil
johnkil / LicensesActivity.java
Created November 21, 2012 11:38 — forked from cyrilmottier/LicensesActivity.java
"Open source licenses" screen
package com.cyrilmottier.android.citybikes;
import android.os.Bundle;
import com.cyrilmottier.android.avelov.R;
import com.cyrilmottier.android.citybikes.app.BaseActivity;
public class LicensesActivity extends BaseActivity {
private WebView mWebView;
@johnkil
johnkil / ScaleFadePageTransformer.java
Created December 4, 2012 06:23 — forked from jgilfelt/ScaleFadePageTransformer.java
An ICS+ app/widget drawer style PageTransformer for your ViewPager
/***
* Copyright (c) 2012 readyState Software Ltd
*
* 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
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import roboguice.activity.event.OnPauseEvent;
import roboguice.activity.event.OnResumeEvent;
import roboguice.event.EventManager;
import roboguice.event.Observes;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import com.google.inject.Inject;
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;
package your.awesome.app;
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;
import com.android.volley.toolbox.ImageLoader.ImageCache;
public class LruBitmapCache extends LruCache<String, Bitmap> implements ImageCache {
public LruBitmapCache(int maxSize) {
super(maxSize);