Android REST Controller with Simple Cache Control Headers using Retrofit 1.9.0 + OkHttp 2.2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// on error the server sends JSON | |
/* | |
{ "error": { "data": { "message":"A thing went wrong" } } } | |
*/ | |
// create model classes.. | |
public class ErrorResponse { | |
Error error; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%@ 对象 | |
%d, %i 整数 | |
%u 无符整形 | |
%f 浮点/双字 | |
%x, %X 二进制整数 | |
%o 八进制整数 | |
%zu size_t | |
%p 指针 | |
%e 浮点/双字 (科学计算) | |
%g 浮点/双字 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
/** |
OlderNewer