Skip to content

Instantly share code, notes, and snippets.

View kumarkundan's full-sized avatar
🏠
Working from home

Kumar Kundan kumarkundan

🏠
Working from home
View GitHub Profile
@JonCatmull
JonCatmull / smart-date.pipe.ts
Created December 21, 2016 10:50
Relative date Pipe for Angular2 + TypeScript . Convert date or timestamp into relative date string e.g. "5 days ago" or to local date string e.g. "11/12/2016"
import { Pipe, PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common';
import { RelativeDatePipe } from './relative-date.pipe'; // https://gist.github.com/JonCatmull/e00afb1c96298a4e386ea1b5d091702a
const secondsInAday = 86400;
/*
* Turn Date into realtive date (e.g. "5 days ago") unless date is
* more than relativeMax days ago.
@jpardogo
jpardogo / BaseAllAdapters.java
Last active June 14, 2018 08:40
Java classes to create a common base adapter strategy that acts as base for common adapters and multiple view types adapters in an android app
public abstract class BaseAllAdapters<T> extends BaseAdapter {
protected Context mContext;
protected LongSparseArray<DelegateAdapter> mDelegateAdapterSparseArray;
private int mViewLayoutId = 0;
private List<ListItem<T>> mItems;
/*Constructor if we dont use mutiple view types in the list*/
public BaseAllAdapters(Context context, int viewLayoutId) {
mContext = context;