Skip to content

Instantly share code, notes, and snippets.

View Orange168's full-sized avatar
😃

Quentin Marvin Orange168

😃
View GitHub Profile
@Orange168
Orange168 / DebounceSearchEmitterFragment.java
Created April 10, 2016 14:23
RxDebounceSearch Fragment
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
_setupLogger();
_subscription = RxTextView.textChangeEvents(_inputSearchText)//
.debounce(400, TimeUnit.MILLISECONDS)// default Scheduler is Computation
.filter(new Func1<TextViewTextChangeEvent, Boolean>() {
@Override
@Orange168
Orange168 / buildConfigField.gradle
Last active May 22, 2018 02:45
gradle 常用代码
gradle.properties
marvel_public_key = 74129ef99c9fd5f7692608f17abb88f9
marvel_private_key = 281eb4f077e191f7863a11620fa1865f2940ebeb
//app build.gradle
defaultConfig {
applicationId cfg.package
minSdkVersion cfg.minSdk
targetSdkVersion cfg.targetSdk
versionCode cfg.version_code
versionName cfg.version_name
def getVersionCode = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--all', '--count'
standardOutput = stdout
}
return Integer.parseInt(stdout.toString().trim())+400
}
catch (ignored) {
@Orange168
Orange168 / Android-CleanArchitecture.gradle
Last active June 17, 2016 00:10
globalConfiguration gradle
apply from: 'buildsystem/ci.gradle'
apply from: 'buildsystem/dependencies.gradle'
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
@Orange168
Orange168 / custom_progressbar.xml
Last active July 20, 2016 13:24
style progress
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Define the background properties like color etc -->
<item android:id="@android:id/background">
<shape android:shape="line">
<stroke android:width="3dp" android:color="@color/white" />
</shape>
</item>
```
android {
buildTypes {
debug {
applicationIdSuffix ".debug"
}
jnidebug {
initWith(buildTypes.debug)
applicationIdSuffix ".jnidebug"
@Orange168
Orange168 / Singleton
Created December 22, 2016 06:09
Singleton
public class Singleton {
private volatile static Singleton INSTANCE; //声明成 volatile
private Singleton (){}
public static Singleton getSingleton() {
if (INSTANCE == null) {
synchronized (Singleton.class) {
if (INSTANCE == null) {
INSTANCE = new Singleton();
}
@Orange168
Orange168 / JPushReceive.java
Created January 21, 2017 02:53
极光推送官方案例
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import cn.jpush.android.api.JPushInterface;
import com.moement.view.main.activity.GroomingActivity;
import java.util.Iterator;
@Orange168
Orange168 / parseWeather.java
Created February 3, 2017 02:36
Pull的方式解析xml
private Weather parseWeather(String weatherXml){
//采用Pull方式解析xml
StringReader reader = new StringReader(weatherXml);
XmlPullParser xmlParser = Xml.newPullParser();
Weather weather = null;
try {
xmlParser.setInput(reader);
int eventType = xmlParser.getEventType();
while(eventType != XmlPullParser.END_DOCUMENT){
switch (eventType){
@Orange168
Orange168 / header.swig
Created February 5, 2017 11:00
添加high一下 hexo next 主题
<li> <a title="把这个链接拖到你的Chrome收藏夹工具栏中" href='javascript:(function() {
function c() {
var e = document.createElement("link");
e.setAttribute("type", "text/css");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", f);
e.setAttribute("class", l);
document.body.appendChild(e)
}