Skip to content

Instantly share code, notes, and snippets.

@karlili
karlili / getHumanReadableDateDisplay.java
Created June 28, 2011 07:54
Implementation of a human readable date display
/**
* An implementation on getting the human readable date format from milliseconds
* which is commonly used in Facebook, like about x hours ago.
* Convention as follows:
* 1000 milliseconds = 1 second,
* 60 seconds = 1 minute,
* 60 minutes = 1 hour,
* 24 hours = 1 day,
* 12 days = 1 month,
* 12 month = 1 year.
@amondnet
amondnet / CenterToast.java
Last active December 22, 2016 03:30
화면 중앙에 Rounded Toast 를 띄우기 위한 Class 작성.
package io.farmers.common.toast;
import android.app.Activity;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.kpga.golfstroy.R;
@DanielGrech
DanielGrech / BlurredImageView.java
Last active December 22, 2016 03:44
Blurred Image background with a rounded image bottom center. Image view which blurs its contents only supports API 17+. Older API's will just display the image as is
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import android.util.AttributeSet;
@VladSumtsov
VladSumtsov / MyActivity.java
Last active July 29, 2019 10:09
RecycleView PullToRefresh SwipeRefreshLayout
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.togethernetworks.basesdk.BaseActivity;
import com.togethernetworks.gallery.samples.mortar.UiModule;
@JMPergar
JMPergar / ScrollViewWithMaxHeight.java
Created November 5, 2014 13:28
ScrollView that can be configured with max height
public class ScrollViewWithMaxHeight extends ScrollView {
public static int WITHOUT_MAX_HEIGHT_VALUE = -1;
private int maxHeight = WITHOUT_MAX_HEIGHT_VALUE;
public ScrollViewWithMaxHeight(Context context) {
super(context);
}
@macsystems
macsystems / Channel.java
Last active January 20, 2020 08:30
If you want to parse an RSS Feed using SimpleXML you can use this as an Start. I used this to parse RSS using RetroFit from Square
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.NamespaceList;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Text;
import java.util.List;
@heinrichreimer
heinrichreimer / SpanningGridLayoutManager.java
Last active March 11, 2024 08:26
GridLayoutManager implementation that stretches to fit all grid items on screen and disables scrolling. Useful for dashboards etc.
package com.example;
import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.ViewGroup;
public class SpanningGridLayoutManager extends GridLayoutManager {
@mtrung
mtrung / Android TimeZone Ids
Last active August 23, 2022 09:06 — forked from arpit/Android TimeZone Ids
As of July 2015, there are 582 Java/Android TimeZone Ids. Note that this list is subject to change (there are 23 additions and 2 deletions from 2011 to 2015).
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
@stepango
stepango / Instagram style EllipsizingTextView
Created September 21, 2015 07:06
Android TextView not support ellipsize if your text fills more than i line. This implementation solved this problem and allow you to use Instagram style end of line mark "[...]"
/*
* Copyright (C) 2011 Micah Hainline
* Copyright (C) 2012 Triposo
* Copyright (C) 2013 Paul Imhoff
* Copyright (C) 2014 Shahin Yousefi
* Copyright (C) 2015 Stepan Goncharov
*
* 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
@sagix
sagix / RoundedShadowedLayout.java
Last active December 22, 2016 03:26
Create a layout with border radius and shadow that mask content inside the rounded rect.
package com.octo.nicolasmouchel;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;