Skip to content

Instantly share code, notes, and snippets.

@Leaking
Leaking / SimpleDividerItemDecoration
Last active May 5, 2020 20:33
A simple RecyclerView ItemDecoration drawing a horizon line and you can set the height and the color.It looks like the listview divider.
package com.quinn.xmpp.ui.widget;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.quinn.xmpp.R;
@Leaking
Leaking / dispatchTouchEvent源码解析
Created March 18, 2015 13:21
android事件分发dispatchTouchEvent方法的源码解析
package cc.aa;
import android.os.Environment;
import android.view.MotionEvent;
import android.view.View;
public class UnderstandDispatchTouchEvent {
/**
* dispatchTouchEvent()源码学习及其注释
* 常说事件传递中的流程是:dispatchTouchEvent->onInterceptTouchEvent->onTouchEvent
@Leaking
Leaking / Sort Algorithm
Created April 6, 2015 05:21
Sort Algorithm
/**
* 冒泡排序
*
* @param a
*/
public static void bubbleSort(int[] a) {
int temp;
for (int i = 0; i < a.length; i++)
for (int j = 0; j < a.length - i - 1; j++) {
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
//.setUsernameAndPassword("peter", "123456")
.setServiceName("quinndemacbook-pro.local")
.setDebuggerEnabled(true)
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setHost("10.180.145.92")
.setPort(5222)
.build();
conn = new XMPPTCPConnection(config);
new Thread(new Runnable() {
@Leaking
Leaking / screenshot.sh
Last active July 2, 2019 03:58
Bash script to take screenshot on android and export to for Mac Desktop
#! /bin/bash
adb shell screencap -p /sdcard/test.png
#adb pull /sdcard/test.png ~/Desktop/test.png
dir=~/Desktop/
curr=`date "+%Y-%m-%d %H:%M:%S"`
name=${dir}"screenshot"${curr}".png"
echo "${name}"
adb pull /sdcard/test.png "$name"
adb shell rm /sdcard/test.png
@Leaking
Leaking / record.sh
Created August 17, 2016 12:50
Bash script to take screen-record on android and export to for Mac Desktop
#! /bin/bash
adb shell screenrecord --time-limit 12 /sdcard/demo.mp4
dir=~/Desktop/
curr=`date "+%Y-%m-%d %H:%M:%S"`
name=${dir}"screenrecord"${curr}".mp4"
echo "${name}"
adb pull /sdcard/demo.mp4 "$name"
adb shell rm /sdcard/demo.mp4
@Leaking
Leaking / find TrustManager From SSLContext
Created December 3, 2017 12:38
find TrustManager From SSLContext
private X509TrustManager findTrustManagerFromSocketFactory(SSLContext mCtx) {
try {
//SSLContext --> contextSpi(OpenSSLContextImpl) --> sslParameters(SSLParametersImpl) --> x509TrustManager(X509TrustManager)
// find OpenSSLContextImpl
Field contextSpiField = mCtx.getClass().getDeclaredField("contextSpi");
contextSpiField.setAccessible(true);
Object openSSLContextImplObj = contextSpiField.get(mCtx);
// find SSLParametersImpl
@Leaking
Leaking / gist:e15760ff075cd5a1cbe993d6c6b9299b
Created December 4, 2017 09:45
getTrustManagerFromSSLSocketFactory
// 18(samsung) 19 (oppo) sslSocketFactory -- sslParameters -- trustManager
// 22(oppo) 24(hw) 27(nexus) sslSocketFactory -- sslParameters -- x509TrustManager
public TrustManager getTrustManagerFromSSLSocketFactory(SSLSocketFactory sslSocketFactory) {
try {
TrustManager result = null;
Field fieldSslPm = sslSocketFactory.getClass().getDeclaredField("sslParameters");
fieldSslPm.setAccessible(true);
Object objSSLParameters = fieldSslPm.get(sslSocketFactory);
if(Build.VERSION.SDK_INT > 19) {
Field fieldTmg = objSSLParameters.getClass().getDeclaredField("x509TrustManager");
@Leaking
Leaking / gist:8e0ac94aeb80800c2376f39010eac41d
Created April 10, 2018 03:25
Get excel picture dimension using apache poi
/**
* 获取图片大小
*/
public static Dimension getDimensionFromAnchor(Picture picture) {
ClientAnchor anchor = picture.getClientAnchor();
boolean isHSSF = (anchor instanceof HSSFClientAnchor);
Sheet sheet = picture.getSheet();
double w = 0;
int col2 = anchor.getCol1();
@Leaking
Leaking / FragmentArgumentDelegate.kt
Created July 28, 2018 07:09 — forked from yanngx/FragmentArgumentDelegate.kt
Fragment arguments without hassle !
package be.brol
import android.os.Binder
import android.os.Bundle
import android.support.v4.app.BundleCompat
import android.support.v4.app.Fragment
/**
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate
* Just write the property in newInstance and read it like any other property after the fragment has been created