Github地址:https://github.com/orhanobut/logger
引入:
compile 'com.orhanobut:logger:1.15'
初始化:
Logger.init();//在application中
用法方式:
Logger.d("hello");?
Logger.e("hello");?
Logger.w("hello");?
Logger.v("hello");?
Logger.wtf("hello");?
Logger.json(JSON_CONTENT);?
Logger.xml(XML_CONTENT);?
Logger.log(DEBUG, "tag", "message", throwable);
參數設置:
Logger
.init(YOUR_TAG)? ? ? ? ? ? ? ? // default PRETTYLOGGER or use just init()?
.methodCount(3)? ? ? ? ? ? ? ? // default 2?
.hideThreadInfo()? ? ? ? ? ? ? // default shown?
.logLevel(LogLevel.NONE)? ? ? ? // default LogLevel.FULL?
.methodOffset(2)? ? ? ? ? ? ? ? // default 0?
.logAdapter(new AndroidLogAdapter()); //default AndroidLogAdapter?
GsonFormat Github地址:https://github.com/zzz40500/GsonFormat
Gson Github地址:https://github.com/google/gson
引入:
compile 'com.google.code.gson:gson:2.7'
Gson 用法教程:
地址:http://ocnyang.com/tags/Gson/
Github地址:https://github.com/JakeWharton/butterknife
引入:
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
Github地址:https://github.com/square/leakcanary
引入:
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'?
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'?
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'?
Github地址:https://github.com/bumptech/glide
引入:
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:19.1.0' //v4包
Glide 用法教程:
地址:http://ocnyang.com/tags/Glide/
Github地址:https://github.com/hdodenhof/CircleImageView
引入:
compile 'de.hdodenhof:circleimageview:2.1.0'
Rxjava + Retrofit + okhttp 網絡請求框架
三個庫的地址請自行查找,這里提供一個介紹用法的 Demo 地址
Github地址:https://github.com/rengwuxian/RxJavaSamples
(基本的使用,不做三者的封裝(因為目前還找不到好的封裝框架))
引入:
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'io.reactivex:rxjava:1.2.1'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
Okhttp 教程:
地址:http://ocnyang.com/tags/OkHttp/
Retrofit2 教程:
地址:http://ocnyang.com/tags/Retrofit2/
Github地址:https://github.com/Cleveroad/slidingtutorial-android
引入:
compile 'com.cleveroad:slidingtutorial:1.0.5'
Github地址:https://github.com/JakeWharton/NineOldAndroids
引入:
compile 'com.nineoldandroids:library:2.4.0'
說明:非本項目使用,貌似引入的某個開源庫依賴此庫
Github地址:https://github.com/JulienGenoud/android-percent-support-lib-sample
引入:
compile 'com.android.support:percent:25.3.0'
Github地址:https://github.com/pwittchen/ReactiveNetwork
引入:
compile 'com.github.pwittchen:reactivenetwork-rx2:0.9.0'
設想:
網絡的檢測邏輯的代碼放在了BaseActivity中,
網絡變化時,需要自動顯示網絡錯誤的布局主要繼承這個Base類就行了,
同時這個類開放的有網絡變化時的回調接口。
自動顯示網絡錯誤的布局的幾種設想:
第一種:當網絡無連接時可以顯示一個大的網絡錯誤布局, 或者跳轉到一個網絡錯誤布局,當網絡連接上的時候再自動跳轉回來
(用戶也可以通過點擊返回,在無網絡的情況下的頁面)。
第二種:當網絡無連接、網絡請求數據錯誤時都顯示一個小警示布局提醒網絡錯誤。
第三種:上面兩種結合在一起,同時在網絡請求數據錯誤的時候,就加載一定數量的網絡錯誤數據集合。
Github地址:https://github.com/square/picasso
引入:
compile 'com.squareup.picasso:picasso:2.3.2'
貌似只引入了庫,并沒有真正使用
Github地址:https://github.com/daimajia/AndroidImageSlider
引入:
compile "com.android.support:support-v4:+"
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5@aar'
才發現,好幾個庫都是它在依賴呀,由于沒有用到,下個版本可能會刪除這個引入
BaseRecyclerViewAdapterHelper RecycleView 拓展庫
Github 地址:https://github.com/CymChad/BaseRecyclerViewAdapterHelper
引入:
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:VERSION_CODE'
中文 Wiki:
地址:https://github.com/CymChad/BaseRecyclerViewAdapterHelper/wiki/%E9%A6%96%E9%A1%B5
Github 地址:https://github.com/greenrobot/greenDAO
引入:
較為繁瑣,詳細查看 Github 地址
Github 地址:https://github.com/greenrobot/EventBus
引入:
compile 'org.greenrobot:eventbus:3.0.0'
用法簡述::
1.Define events:
? public static class MessageEvent { /* Additional fields if needed */ }?
2.Prepare subscribers: Declare and annotate your subscribing method, optionally specify a thread mode:
? @Subscribe(threadMode = ThreadMode.MAIN)?
? public void onMessageEvent(MessageEvent event) {/* Do something */};
Register and unregister your subscriber. For example on Android, activities and fragments should usually register according to their life cycle:
@Override
public void onStart() {
? ? super.onStart();
? ? EventBus.getDefault().register(this);
}
@Override
public void onStop() {
? ? super.onStop();
? ? EventBus.getDefault().unregister(this);
}
3.Post events:
? EventBus.getDefault().post(new MessageEvent());
Github 地址:https://github.com/traex/RippleEffect
引入:
compile 'com.github.traex.rippleeffect:library:1.3'
Github 地址:https://github.com/crazycodeboy/TakePhoto
引入:
compile 'com.jph.takephoto:takephoto_library:4.0.3'
Github 地址:https://github.com/QuadFlask/colorpicker
引入:
compile 'com.github.QuadFlask:colorpicker:0.0.13'
android-autofittextview 自適應大小文本控件
Github 地址:https://github.com/grantland/android-autofittextview
引入:
compile 'me.grantland:autofittextview:0.2.+'
Github 地址:https://github.com/hanks-zyh/HTextView
引入:
compile 'hanks.xyz:htextview-library:0.1.5'
對比了一些通過Zxing封裝的二維碼識別的項目,獨獨比較喜歡這個。
Github 地址:https://github.com/bingoogolapple/BGAQRCode-Android
引入:
compile 'com.google.zxing:core:3.2.1'
compile 'cn.bingoogolapple:bga-qrcodecore:latestVersion@aar'
compile 'cn.bingoogolapple:bga-zxing:latestVersion@aar'
Github 地址:https://github.com/PhilJay/MPAndroidChart
引入:
//在 Android 開發中使用過圖表的,應該都會知道這個庫吧。
compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
material-calendarview 材料設計日歷控件
Github 地址:https://github.com/prolificinteractive/material-calendarview
引入:
compile 'com.prolificinteractive:material-calendarview:1.4.3'
Github 地址:https://github.com/google/flexbox-layout
引入:
compile 'com.google.android:flexbox:0.3.0-alpha3'
Github 地址:https://github.com/flavioarfaria/KenBurnsView
引入:
compile 'com.flaviofaria:kenburnsview:1.0.7'
Github 地址:https://github.com/MiguelCatalan/MaterialSearchView
引入:
compile 'com.miguelcatalan:materialsearchview:1.4.0'
引入:
compile 'com.android.support:cardview-v7:25.1.1'//卡片
Github 地址:https://github.com/hackware1993/MagicIndicator
引入:
compile 'com.github.hackware1993:MagicIndicator:1.5.0'
記得鴻洋大神也開源一個差不多的庫,也挺不錯的。
小米推送(本來沒想用小米的,抵不住前幾年小米手機買的好名氣大,我就用用試試。這里說一下和其他平臺的不足點,目前發現小米推送不支持富文本的)
ShareSDK Mob 平臺的社會化分享和登錄
SMSSDK Mob 平臺的手機短信驗證(感覺 Mob 平臺名氣穩健,一方面是名字取得好呀,一方面永久免費)
友盟統計 (這個小應用大部分都會用吧)
項目地址:http://blog.csdn.net/lmj623565791/article/details/48649563
注意三點:
ToolBar高度設置為wrap_content?
ToolBar添加屬性android:fitsSystemWindows="true"?
header_just_username.xml的根布局RelativeLayout,添加屬性? android:fitsSystemWindows="true"?
android:fitsSystemWindows這個屬性,主要是通過調整當前設置這個屬性的view的padding去為我們的status_bar留下空間。?
為了Android4.4適配:
那么只需要在Activity里面去寫上(設置Toolbar之后):StatusBarCompat.compat(this);就可以了。
如果你希望自己設置狀態看顏色,那么就用這個方法:
StatusBarCompat.compat(this, getResources().getColor(R.color.status_bar_color));
關于沉浸式的說明,6.0及以上不能達到半透明的效果。 同時沉浸式和夜間模式結合要考慮兩方面。
具體差別請看V21/style
Android應用自動更新庫(android-auto-update)
項目地址:https://github.com/feicien/android-auto-update
用法:
導入library項目(本項目是直接把library直接復制放在了 /update 目錄下)
提供2種版本檢查方式,在你的項目中添加以下代碼即可
? 使用Dialog? `UpdateChecker.checkForDialog(this);`?
? 使用Notification? UpdateChecker.checkForNotification(this);?
添加權限
? 添加訪問網絡的權限?
? 添加寫SDCard權限(可選,非必須)?
? 如果添加這個權限 apk下載在sdcard中的Android/data/包名/cache目錄下 否則下載到 內存中的 /data/data/包名/cache中?
? ?
根據Demo直接使用,可定制的東西很少,當然引導頁本身也沒什么可定制的,
就看自己喜歡不喜歡這個引導頁的設計了
項目地址:https://github.com/Cleveroad/slidingtutorial-android
這個引導頁在布局上用到的全是百分比布局
需要自己定制的可能是最后一頁添加一個按鈕的點擊事件
依賴nineoldandorid開源動畫庫
Slidinglayout其實就是一個自定義的布局
XML樣式參數:
background_view?背景?view
sliding_mode?滑動模式,both為上下可彈跳,top?為頂部彈跳,bottom?為底部彈跳,默認為 both?sliding_pointer_mode?手指模式,one為只識別一個手指,more為支持多指滑動,默認為more?top_max?當滑動模式為top時才有效,用于可滑動的最大距離,如"top_max:200dp",默認為-1(不限制)
常用API:
public void setSlidingOffset(float slidingOffset)設置控件的滑動阻力,有效值為0.1F~1.0F,值越小阻力越大,默認為0.5F
public void setTargetView(View view)設置控件的前景View
public void setBackgroundView(View view)?設置控件的背景View
public void setSlidingListener(SlidingListener slidingListener)?給控件設置監聽,可以監聽滑動情況
public void setSlidingMode(int mode)?設置滑動模式
public void setSlidingDistance(int max)?設置最大滑動距離,僅在top模式下有效
(本應用中還未使用)
博客參考地址:http://www.lxweimin.com/p/3b55e84742e5
項目地址:https://github.com/D-clock/AndroidStudyCode
DayNightActivity的例子的方式是在設置頁的的代碼方式。
在其他有夜間模式的頁面,只要在setcontentView之前判斷目前設置的模式然后設置 此種模式就行了。即實現initData();initTheme();方法就行了,同時可以在BaseActivity中實現。
(目前應用的問題,個人感覺就是這個設計的有問題)
下面具有導航欄的主體app的設計思路。
由于這種導航是一級導航,目前不建議在app的一級頁面就采用?viewpager+Fragment?或導航欄+?Fragment?的形式設計。
建議采用獨立?activity+include?布局 +?android:launchMode="singleTask"?+?theme:@style/noAnimation?(取消activity跳轉自帶的原生動畫)的形式
這樣的好處:能將每個一級功能分類頁相互分離開來不相互影響。經過觀察和猜想知乎采用的應該是這種方式。這樣的方式也能達到和上面一樣的效果,同時又解決了Fragment帶來的不便。
關于主導航頁返回鍵的監聽處理方式:
一種是在每個主導航頁中設置監聽,點擊一次沒反應,連點擊兩次退出程序。
另外一種:點擊一次返回到main主導航頁面,在main頁面點擊一次直接退出程序(這也是知乎實現的方式,同時因為在main頁面點擊一次就直接退出了,所以在其他主導航頁面如果連續點擊兩次也能達到直接退出程序的效果。)