Skip to content

Instantly share code, notes, and snippets.

@weeravit
weeravit / WrapContentHeightViewPager.java
Created May 9, 2017 05:01 — forked from egslava/WrapContentHeightViewPager.java
Wrap content height ViewPager (Android)
package org.cnii.layoutloader.ui;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;
/**
* Special thanks to Daniel López Lacalle for his response
* (http://stackoverflow.com/questions/8394681/android-i-am-unable-to-have-viewpager-wrap-content/20784791#20784791)
public class SingletonClass implements Serializable {
private static volatile SingletonClass sSoleInstance;
//private constructor.
private SingletonClass(){
//Prevent form the reflection api.
if (sSoleInstance != null){
throw new RuntimeException("Use getInstance() method to get the single instance of this class.");
@weeravit
weeravit / ArcUtils.java
Created December 20, 2016 07:26 — forked from sheerazam/ArcUtils.java
Fresco Circular Progress Drawable
public final class ArcUtils {
private static final double FULL_CIRCLE_RADIANS = toRadians(360d);
private ArcUtils() { }
/**
* Draws a circular arc on the given {@code Canvas}.
*
* @param canvas The canvas to draw into.
* @param circleCenter The center of the circle on which to draw the arc.
@weeravit
weeravit / LollipopBitmapMemoryCacheParamsSupplier.java
Created December 19, 2016 10:49 — forked from sensen/LollipopBitmapMemoryCacheParamsSupplier.java
Fresco's custom BitmapMemoryCacheParamsSupplier for Lollipop devices
public class LollipopBitmapMemoryCacheParamsSupplier implements Supplier<MemoryCacheParams> {
private ActivityManager activityManager;
public LollipopBitmapMemoryCacheParamsSupplier(ActivityManager activityManager) {
this.activityManager = activityManager;
}
@Override
public MemoryCacheParams get() {
@weeravit
weeravit / MainActivity.java
Created November 10, 2016 07:57 — forked from fbis251/MainActivity.java
Android Glide + okhttp progress example
package com.example.glidetest.app;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ProgressBar;
import com.bumptech.glide.Glide;
import com.bumptech.glide.integration.okhttp.OkHttpUrlLoader;
@weeravit
weeravit / introrx.md
Created September 10, 2016 04:00 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@weeravit
weeravit / GagSsl.java
Created April 12, 2016 13:42 — forked from chalup/GagSsl.java
Get OkHttpClient which ignores all SSL errors.
private static OkHttpClient getUnsafeOkHttpClient() {
try {
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
@weeravit
weeravit / 0_reuse_code.js
Created November 18, 2015 04:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console