Skip to content

Instantly share code, notes, and snippets.

View svangsgaard's full-sized avatar

Steffen Vangsgaard svangsgaard

  • Aalborg, Denmark
View GitHub Profile
@svangsgaard
svangsgaard / BitmapLruCache.java
Created June 26, 2013 09:23
A very simple BitmapCache - a wrapper around LruCache<String, Bitmap>. Can be used with volley.
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;
import com.android.volley.toolbox.ImageLoader.ImageCache;
public class BitmapLruCache extends LruCache<String, Bitmap> implements ImageCache {
public static int getDefaultLruCacheSize() {
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
final int cacheSize = maxMemory / 8;
@svangsgaard
svangsgaard / VolleyHelper.java
Last active April 22, 2022 01:53
A helper class to Google volley. Made with inspiration from AFNetworking. Usage: volley = new VolleyHelper(this, "<BASEURL>"/*Maybe get url from getString*/); volley.post("<service_name>", null, new Listener<JSONObject>() { @OverRide public void onResponse(JSONObject response) { Log.i("Got JSON", response.toString()); } }, new ErrorListener() { @…
import org.json.JSONObject;
import android.content.Context;
import com.android.volley.Request.Method;
import com.android.volley.RequestQueue;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.toolbox.ImageLoader;