Skip to content

Instantly share code, notes, and snippets.

@mnadeem
mnadeem / ScalableThreadPoolExecutor.java
Last active October 4, 2021 11:58
Salable thread pool executor (TPE) which first creates threads up to maximum pool size then queue up the work (Queue depends upon Executor)
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TransferQueue;
import java.util.concurrent.locks.ReentrantLock;
public final class ScalableThreadPoolExecutor extends ThreadPoolExecutor {
@gelldur
gelldur / FullscreenFragment.java
Created September 11, 2015 12:48
FullscreenFragment - simple android fragment that will make fullscreen for you. Remember to: "You must manually call onKeyDown and onWindowFocusChanged."
package com.dexode.fragment;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;
public Bitmap getScreenshotFromRecyclerView(RecyclerView view) {
RecyclerView.Adapter adapter = view.getAdapter();
Bitmap bigBitmap = null;
if (adapter != null) {
int size = adapter.getItemCount();
int height = 0;
Paint paint = new Paint();
int iHeight = 0;
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
package com.firebase.utils;
import java.util.Date;
/**
* Fancy ID generator that creates 20-character string identifiers with the
* following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't
package com.example.android.view;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;