Skip to content

Instantly share code, notes, and snippets.

View kassadin's full-sized avatar
:octocat:
新年好

kassadin

:octocat:
新年好
View GitHub Profile
@kassadin
kassadin / OkHttpStack.java
Last active August 29, 2015 14:27 — forked from JakeWharton/OkHttpStack.java
A `HttpStack` implementation for Volley that uses OkHttp as its transport.
import com.android.volley.toolbox.HurlStack;
import com.squareup.okhttp.OkHttpClient;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* An {@link com.android.volley.toolbox.HttpStack HttpStack} implementation which
* uses OkHttp as its transport.
*/
@kassadin
kassadin / DateUtils.java
Last active August 29, 2015 14:26 — forked from kjsolo/DateUtils.java
Android,智能格式化中文时间
public class DateUtils {
public static String formatDateTime(Date date) {
String text;
long dateTime = date.getTime();
if (isSameDay(dateTime)) {
Calendar calendar = GregorianCalendar.getInstance();
if (inOneMinute(dateTime, calendar.getTimeInMillis())) {
return "刚刚";
} else if (inOneHour(dateTime, calendar.getTimeInMillis())) {
@kassadin
kassadin / OkHttpStack.java
Last active August 29, 2015 14:25 — forked from bryanstern/OkHttpStack.java
An OkHttp backed HttpStack for Volley
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 Circle Internet Financial
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@kassadin
kassadin / 0_reuse_code.js
Last active August 29, 2015 14:16
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
@kassadin
kassadin / AlertOnBack
Last active August 29, 2015 14:06
android 退出时弹出对话框
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("程序名称")
.setCancelable(true)
.setMessage("确定退出?")
.setPositiveButton("是的", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// System.exit(0);