Skip to content

Instantly share code, notes, and snippets.

View extralam's full-sized avatar
🎯
Focusing

Alan Lam extralam

🎯
Focusing
View GitHub Profile
@extralam
extralam / top_shadow.xml
Created September 7, 2016 09:48
A Top Shadow line background
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding android:top="1dp" />
<solid android:color="#00CCCCCC" />
<corners android:radius="3dp" />
</shape>
@extralam
extralam / SquareToolbarMenuButton.java
Created February 22, 2016 07:12
SquareToolbarMenuButton
package com.extralam.app.ui;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageButton;
import com.extralam.app.R;
/**
@extralam
extralam / jquery.ajaxqueue.js
Last active December 17, 2020 10:33 — forked from guybedford/jquery.ajaxqueue.js
jQuery AJAX queues
/*
:: Enhanced Version @extralam ::
Allows for ajax requests to be run synchronously in a queue , remove queue
Usage::
var queue = new $.AjaxQueue();
// add with tag name or not , both ok
queue.add('test',{
url: 'url',
@extralam
extralam / PicassoHelper.java
Last active January 8, 2017 00:24
Android Picasso Rewrite Retry Policy
public class PicassoHelper{
private static final boolean isDebug = false;
private static final int MAX_RETRY_TIME = 10; // Default is 3 in Picasso
private static final int MAX_DOWNLOADING_THREAD = 4; // Recommand in Volley , it is 4
private static Picasso sPicasso;
/**
* Default Picasso is
@extralam
extralam / FragmentTabHostIos.java
Created July 10, 2015 17:04
Enhancement of FragmentTabHost - iOS like Style , maintain fragment's state in the application . Tab change do not recreate the fragment.
package yourpackagename;
/*
* Copyright (C) 2012 The Android Open Source Project
*
* 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
@extralam
extralam / RoundedRelativeLayout.java
Created June 12, 2015 03:34
Make a Rounded RelativeLayout
package com.goxip.app.ui;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.os.Build;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Region.Op;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.TextView;
public class VerticalTextView extends TextView {
final boolean topDown;
@extralam
extralam / UrlCacheHelper.java
Created February 13, 2015 02:42
Simple Url return cache
package com.extralam.utils;
import android.support.v4.util.LruCache;
/**
* A Simple url return cache;
*/
public class UrlCacheHelper {
private static final int CACHE_FACTOR = 8;
@extralam
extralam / SimpleBackgroundTask.java
Created December 22, 2014 03:24
Extends AsyncTask , Check Activity finished or not before send back to UI Thread. and change execute to THREAD_POOL_EXECUTOR
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Build;
import java.lang.ref.WeakReference;
abstract public class SimpleBackgroundTask<T> extends AsyncTask<Object, Void, T> {
private WeakReference<Activity> weakActivity;
@extralam
extralam / BaseRecycleViewAdapter.java
Last active August 29, 2015 14:10
BaseRecycleViewAdapter For RecycleView v7 ( include back onItemClickListener, headerview, footerview)
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;