Skip to content

Instantly share code, notes, and snippets.

View MankIndX's full-sized avatar

MankIndX

  • Beijing, China
View GitHub Profile
@MankIndX
MankIndX / Foreground.java
Created August 10, 2017 02:33 — forked from steveliles/Foreground.java
Class for detecting and eventing whether an Android app is currently foreground or background (requires API level 14+)
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;
public class NullIfEmptyStrAdapter extends TypeAdapter<String> {
@Override
public void write(JsonWriter out, String value) throws IOException {
out.value(value);
}
@Override
public String read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
/**
* Transform pictures to desired size and format according to Qiniu Api
*/
public class QiniuReqTransformer implements Picasso.RequestTransformer {
@Override
public Request transformRequest(Request request) {
if (request.resourceId != 0) {
return request; // Don't transform resource requests.
}
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="FileLength">
<property name="max" value="500"/>
<property name="fileExtensions" value="java"/>
</module>
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress checks="[a-zA-Z0-9]*" files="R.java" />
<suppress checks="[a-zA-Z0-9]*" files="BuildConfig.java" />
<suppress checks="[a-zA-Z0-9]*" files="Test" />
@MankIndX
MankIndX / code_style.xml
Created November 18, 2016 09:42
Java code style
<code_scheme name="code_style">
<option name="AUTODETECT_INDENTS" value="false" />
<option name="PREFER_LONGER_NAMES" value="false" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
@MankIndX
MankIndX / pre-commit
Created November 18, 2016 09:37
checkstyle check changed java source before git commit
#!/bin/sh
#
# To use this you need:
# 1. checkstyle's jar file somewhere
# 2. a checkstyle XML check file somewhere
# 3. java environment
# 4. To configure git:
# * git config --add checkstyle.jar <location of jar>
# * git config --add checkstyle.checkfile <location of checkfile>
# 5. Put this in your .git/hooks directory as pre-commit