Skip to content

Instantly share code, notes, and snippets.

@jingwings
jingwings / adbwifi.sh
Last active August 29, 2015 14:18 — forked from stormzhang/adbwifi.sh
#!/bin/bash
#Modify this with your IP range
MY_IP_RANGE="192\.168\.1"
#You usually wouldn't have to modify this
PORT_BASE=5555
#List the devices on the screen for your viewing pleasure
adb devices
@jingwings
jingwings / gist:d1302fe52f6900fc813f
Created August 22, 2015 00:49
SurfaceViewTempalte
package com.example.choujiang;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
/**
* Created by jingdongqi on 8/22/15.
@jingwings
jingwings / README.md
Created October 27, 2015 03:54 — forked from polbins/README.md
Android Response Caching using Retrofit 1.9 + OkHttp 2.2

Android REST Controller with Cache-Control

Android REST Controller with Simple Cache Control Headers using Retrofit 1.9.0 + OkHttp 2.2.0

@jingwings
jingwings / json.txt
Created November 20, 2015 02:53
json string demo
JSON样例:
{"keshi":"内科","data":[{"name":"心内科"},{"name":"心血管内科"},{"name":"高血压门诊"},{"name":"呼吸科"}],"doctors":[{"name":"徐光","speciality":"内分泌科","keshi":"妇科","level":"主任医生","icon":"icon.png","qr":"abc.png"},{"name":"徐光","speciality":"内分泌科","keshi":"妇科","level":"主任医生","icon":"icon.png","qr":"abc.png"}]}
校验 http://json.cn/
@jingwings
jingwings / FileManager
Created November 26, 2015 09:30
FileManager for Android
public class FileManager {
private static final String BASE_PATH = "bmreport";
private static final String IMAGE = "image";
private static final String TEMP_FILE = "temp_file";
private static final String LOG = "log";
private static final String DATA = "data";
private static final String DEBUG = "debug";
public static final String APP_CACHE_DIR = "/data/data/your package name/cache";
@jingwings
jingwings / retrofit-custom-error-handling.java
Created November 26, 2015 10:09 — forked from benvium/retrofit-custom-error-handling.java
Fairly simply Retrofit custom error handling example. Is set up so that you don't need to do much work in the 'failure' handler of a retrofit call to get the user-visible error message to show. Works on all endpoints. There's lots of exception handling as our server folks like to keep us on our toes by sending all kinds of random stuff..!
// on error the server sends JSON
/*
{ "error": { "data": { "message":"A thing went wrong" } } }
*/
// create model classes..
public class ErrorResponse {
Error error;
@jingwings
jingwings / Api.java
Created November 26, 2015 10:35 — forked from snadjafi/Api.java
android retrofit setup example
public final class Api {
//region Variables
private static final String API_HOST = Application.string(R.string.api_server);
private static final Object sLockObject = new Object();
private static Service sService = null;
static final int DISK_CACHE_SIZE = 50 * 1024 * 1024; // 50MB
//endregion
@jingwings
jingwings / format output
Created December 3, 2015 09:47
oc format output
%@ 对象
%d, %i 整数
%u 无符整形
%f 浮点/双字
%x, %X 二进制整数
%o 八进制整数
%zu size_t
%p 指针
%e 浮点/双字 (科学计算)
%g 浮点/双字
@jingwings
jingwings / JustifyTextView
Created December 10, 2015 09:47
JustifyTextView 解决TextView中英文混排自动换行的问题
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.widget.TextView;
/**
@jingwings
jingwings / curl.md
Created December 25, 2015 09:59 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin