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
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; |
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.yourapp; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.List; | |
import com.example.yourapp.AuthenticationModel; | |
import retrofit.client.Header; | |
import retrofit.client.OkClient; |
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.util.Log; | |
import com.squareup.leakcanary.AnalysisResult; | |
import com.squareup.leakcanary.DisplayLeakService; | |
import com.squareup.leakcanary.HeapDump; | |
import retrofit.RestAdapter; | |
import retrofit.RetrofitError; | |
import retrofit.http.Multipart; | |
import retrofit.http.POST; | |
import retrofit.http.Part; | |
import retrofit.mime.TypedFile; |
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
###################################################################### | |
### How to run this script: mitmdump -q -s mitmproxy_localytics.py ### | |
###################################################################### | |
import re | |
import gzip | |
from StringIO import StringIO | |
import json | |
from pprint import pprint | |
class color: |
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
[alias] | |
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate | |
lr = log --pretty=format:"%Creset%s%Cblue\\ [%cn]" --decorate | |
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat | |
lnc = log --pretty=format:"%h\\ %s\\ [%cn]" | |
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short | |
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative | |
le = log --oneline --decorate | |
dag = log --graph --oneline --decorate --all | |
brdiff = log --graph --pretty=format:"%Cred%h%Creset\\ -%C(yellow)%d%Creset\\ %s\\ %Cgreen(%cr)%Creset\\" --abbrev-commit --date=relative |
Centralize the support libraries dependencies in gradle
Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.
A very good way is to separate gradle build files, defining something like:
root
--gradleScript
----dependencies.gradle
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
<!-- You can change the parent around to whatever you normally use --> | |
<style name="DebugColors" parent="Theme.AppCompat"> | |
<!-- System colors --> | |
<item name="android:windowBackground">@color/__debugWindowBackground</item> | |
<item name="android:colorPressedHighlight">#FF4400</item> | |
<item name="android:colorLongPressedHighlight">#FF0044</item> | |
<item name="android:colorFocusedHighlight">#44FF00</item> | |
<item name="android:colorActivatedHighlight">#00FF44</item> |
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
03-04 11:21:58.523 10153-12159/com.mypackage.myapp D/LeakCanary: In com.mypackage.myapp:1.9.2:41. | |
03-04 11:21:58.524 10153-12159/com.mypackage.myapp D/LeakCanary: * com.mypackage.myapp.activities.MyReactActivity has leaked: | |
03-04 11:21:58.524 10153-12159/com.mypackage.myapp D/LeakCanary: * GC ROOT org.chromium.base.SystemMessageHandler.mLooper | |
03-04 11:21:58.524 10153-12159/com.mypackage.myapp D/LeakCanary: * references android.os.Looper.mThread | |
03-04 11:21:58.524 10153-12159/com.mypackage.myapp D/LeakCanary: * references thread java.lang.Thread.localValues (named 'main') | |
03-04 11:21:58.524 10153-12159/com.mypackage.myapp D/LeakCanary: * references java.lang.ThreadLocal$Values.table | |
03-04 11:21:58.524 10153-12159/com.mypackage.myapp D/LeakCanary: * references array java.lang.Object[].[71] | |
03-04 11:21:58.524 10153-12159/com.mypackage.myapp D/LeakCanary: * references com.facebook.react.bridge.queue.MessageQueueThreadImpl.mHandler | |
03-04 11:21:58.524 10153-12159/com.mypackage.myapp D/LeakCanary: * references com. |
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
"scripts": { | |
"start": "node node_modules/react-native/local-cli/cli.js start", | |
"rc-start": "npm start -- --reset-cache", | |
"clean": "rm -rf $TMPDIR/react-* && watchman watch-del-all && npm cache clean", | |
"clean-start": "npm run clean && npm run rc-start", | |
"fresh-install": "rm -rf $TMPDIR/react-* && watchman watch-del-all && rm -rf ios/build/ModuleCache/* && rm -rf node_modules/ && npm cache clean && npm install", | |
"fresh-start" : "npm run fresh-install && npm run rc-start", | |
"tron": "node_modules/.bin/reactotron" | |
} |