Skip to content

Instantly share code, notes, and snippets.

HttpURLConnection hc = (HttpURLConnection) connection;
HttpsURLConnection huc = (HttpsURLConnection) hc;
huc.setHostnameVerifier(mHostnameVerifier);
huc.setSSLSocketFactory(initSSLSocketFactory(new FakeTrustManager()));
private SSLSocketFactory initSSLSocketFactory(manager)
throws KeyManagementException, NoSuchAlgorithmException {
// Install the all-trusting trust manager
final SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, new TrustManager[]{manager},
package com.scurab.android.anuitor.reflect;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.view.View;
import java.lang.reflect.Method;
import java.util.ArrayList;
@jbruchanov
jbruchanov / TextRenderHelper.java
Last active August 29, 2015 14:00
TextRenderHelper
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
g.setFont(new Font("Arial", Font.PLAIN, 24));
FontMetrics fm = g.getFontMetrics();
TextRenderHelper helper = new TextRenderHelper(fm, "Hello World\nHello World Hello World Hello World Hello World", 300, 60);
for (TextRenderHelper.LineRenderContext lrc : helper.prepareForRender(TextRenderHelper.Gravity.CENTER, TextRenderHelper.Gravity.CENTER)) {
g.drawString(lrc.text, lrc.x, lrc.y);
}
private static class TextRenderHelper{