Skip to content

Instantly share code, notes, and snippets.

View Orange168's full-sized avatar
😃

Quentin Marvin Orange168

😃
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@Orange168
Orange168 / GIT
Last active November 4, 2015 02:22
GIT
there are some git command and git tutorial conllection
@Orange168
Orange168 / DataBase.java
Last active December 1, 2015 06:40
some DB operation
public void save(String path, Map<Integer, Integer> map) {// int threadid,
// int position
SQLiteDatabase db = openHelper.getWritableDatabase();
db.beginTransaction();
try {
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
db.execSQL(
"insert into filedownlog(downpath, threadid, downlength) values(?,?,?)",
new Object[]{path, entry.getKey(), entry.getValue()});
}
@Orange168
Orange168 / ChangeColor.java
Created March 13, 2016 15:46
CustomTransitionFragment
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package com.example.android.animationsdemo;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageButton;
// Set the Action Bar to use tabs for navigation
ActionBar ab = getSupportActionBar();
ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Add three tabs to the Action Bar for display
ab.addTab(ab.newTab().setText("Tab 1").setTabListener(this)); //ActionBar.TabListener
ab.addTab(ab.newTab().setText("Tab 2").setTabListener(this));
ab.addTab(ab.newTab().setText("Tab 3").setTabListener(this));
@Orange168
Orange168 / AndroidApplication.java
Last active April 6, 2016 08:06
google/dragger
public class AndroidApplication extends Application {
private ApplicationComponent applicationComponent;
@Override public void onCreate() {
super.onCreate();
this.initializeInjector();
this.initializeLeakDetection();
}
@Orange168
Orange168 / RxBus.java
Created April 10, 2016 08:45
RxBusDemo
/**
* courtesy: https://gist.github.com/benjchristensen/04eef9ca0851f3a5d7bf
*/
public class RxBus {
//private final PublishSubject<Object> _bus = PublishSubject.create();
// If multiple threads are going to emit events to this
// then it must be made thread-safe like this instead
private final Subject<Object, Object> _bus = new SerializedSubject<>(PublishSubject.create());
@Orange168
Orange168 / GithubService.java
Created April 10, 2016 14:18
RetrofitFragment Rx demo
public class GithubService {
private GithubService() { }
public static GithubApi createGithubService(final String githubToken) {
Retrofit.Builder builder = new Retrofit.Builder().addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.baseUrl("https://api.github.com");
if (!TextUtils.isEmpty(githubToken)) {
@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