在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ Android/ <a rel="nofollow" href="http://www.vogella.com/tutorials/Android
Launch mode 和 Intent flags專題
Canvas &amp; Drawables
UTAustinX_UT.9.01x: Effective Thinking Through Mathematics
《JavaScript 語言精粹》
Memory leak專題
React基礎(chǔ)
《Test Driven Development: By Example》一書
Developer tools
安卓開發(fā)技能樹
<a rel="nofollow" href="https://mp.weixin.qq.com/s?__biz=MzA3NDM
Best Practices for Interaction and Engagement
各個安卓版本引入的主要新特性
Building Apps with Connectivity &amp; the Cloud
List.toArray()再強轉(zhuǎn)是一定會失敗的
深入Android frameworks
Google dev 100 days系列視頻
Building Apps with Contacts &amp; Sign-In
關(guān)系型數(shù)據(jù)庫設(shè)計范式
《App研發(fā)錄》一書
REST API設(shè)計
Google IO 2015摘要
自定義View/ViewGroup以及高性能實現(xiàn)自定義UI
安卓系統(tǒng)點擊事件處理
《50 Android Hacks》一書
Building Apps with Content Sharing
Flux基礎(chǔ)
<a rel="nofollow" href="http://developer.android.com/training/in
依賴注入(以Dagger 2為例)
Java同步機制
Java對象內(nèi)存的使用情況
JSR133(Java memory model)
Google官方Material Design手冊(<a rel="nofollow" href="http://develop
Futurice公司安卓團隊的建議
安卓性能優(yōu)化
  • 1.
Best Practices for Performance
<a rel="nofollow" href="http://www.vogella.com/tutorials/Android
<a rel="nofollow" href="http://blog.danlew.net/2014/11/19/styles
Handling Runtime Changes
<a rel="nofollow" href="http://www.vogella.com/tutorials/Android
Building Apps with Graphics &amp; Animation
<a rel="nofollow" href="http://tools.android.com/tech-docs/new-b
Android項目架構(gòu)
MVP(Model-View-Presenter)模式
<a rel="nofollow" href="http://www.infoq.com/cn/es6-in-depth/"">
《Android源碼設(shè)計模式解析與實戰(zhàn)》一書
Rx在Android中的最佳實踐
函數(shù)調(diào)用時,傳遞參數(shù)應(yīng)該是不可變的(Immutable)
ProGuard
面向?qū)ο罅笤瓌t(SOLID+)
深入理解Java虛擬機
深入Java深淺拷貝、immutable、unmodifiable
Best Practices for User Input
UI上的一些高效方式/最佳實踐
<a rel="nofollow" href="https://blog.stylingandroid.com/ripples-
Best Practices for User Interface
安卓測試驅(qū)動開發(fā)/安卓測試驗證
暗時間:學(xué)會正確思考
技術(shù)筆記
Aspect Oriented Programming(AOP)
Best Practices for Background Jobs
安卓系統(tǒng)動效專題
Feed系統(tǒng)的設(shè)計
Data binding(MVVM,Model-View-ViewModel)
Effective Java一書筆記
<a rel="nofollow" href="http://developer.android.com/training/in
Rx (Reactive eXtention)
MultiDex專題
一些很棒的點子
WebRTC

<a rel="nofollow" href="http://www.vogella.com/tutorials/Android

優(yōu)點

  • 簡化對UI的重用,將UI和交互放到Fragment里面,可以方便的針對不同設(shè)備設(shè)置不同的UI(如pad顯示兩個fragment,phone顯示一個);

完整生命周期

http://wiki.jikexueyuan.com/project/notes/images/FullFragmentAndActivityLifeCycle.png" alt="FullFragmentAndActivityLifeCycle.png" />

使用fragment

  • 直接在layout.xml里面聲明一個Fragment
  • 使用FragmentManager動態(tài)添加、替換、移除;
    • 必須通過FragmentTransaction來完成動態(tài)改變;
    • addToBackStack()方法可以支持通過返回鍵回退到上一個Fragment;
  • Fragment的isInLayout()方法可以判斷Fragment是否已經(jīng)顯示;
  • 可以通過放在不同文件夾下(values,values-land等)的xml文件中的變量值,在代碼中動態(tài)獲取值,來達到判斷當(dāng)前運行模式/設(shè)備的目的;
  • Fragment的Transaction支持動畫;

使用Fragment進行后臺處理(Headless Fragment)

  • onCreateView返回null;
  • 結(jié)合setRetainInstance()方法,讓Fragment在應(yīng)用程序配置發(fā)生變化(橫豎屏、屏幕尺寸)時,不會被destroy,從而繼續(xù)執(zhí)行后臺任務(wù);
  • 通過為Fragment設(shè)置tag,可以在之后獲取fragment實例;
  • 效果類似于MVP中的ViewState;

Fragment不利于單元測試

  • Fragment的life cycle很復(fù)雜
  • View controllers? Not so fast.
    操作view,有很多view相關(guān)的代碼,不利于單元測試
  • Fragment transactions
    異步過程,當(dāng)接收到多個click事件,或者configuration changes時,程序?qū)⑻幱谖粗獱顟B(tài)
  • Fragment creation magic
    fragment manager可能會使用反射接口重新創(chuàng)建fragment,而fragment有可能會作為內(nèi)部類被定義,沒有public的構(gòu)造函數(shù),問題就來了
  • Fragments: lessons learned
    • Single Activity Interface:使用不同的Fragment實現(xiàn)界面,動效、生命周期將變得更容易
    • The backstack isn't an activity specific notion; you can implement a backstack within an activity.
    • There is no need for new APIs; everything we needed was there from the very beginning: activities, views, and layout inflaters.
  • Responsive UI: fragments vs custom views
  • 擴展閱讀:使用custom views構(gòu)建single activity app:Simpler Android apps with Flow and Mortar

Fragment Transactions & Activity State Loss

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
    at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1341)
    at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1352)
    at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
    at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:574)
  • 原因:在activity的state被save之后,commit FragmentTransaction,會拋出這個異常
  • 當(dāng)activity在后臺被殺死之后,會通過onSaveInstanceState回調(diào)讓程序可以保存數(shù)據(jù)(狀態(tài)),其中dialog, fragment, view的狀態(tài)由framework負(fù)責(zé)保存和恢復(fù)
  • 因為FragmentTransaction#commit()在onSaveInstanceState()后被調(diào)用了,系統(tǒng)為了防止activity state loss,拋出了該異常
  • 從3.1起,安卓系統(tǒng)對于Activity生命周期的維護發(fā)生了變化
    http://wiki.jikexueyuan.com/project/notes/images/android_activity_life_cycle_change.png" alt="android_activity_life_cycle_change.png" /> support庫的行為:
    http://wiki.jikexueyuan.com/project/notes/images/android_activity_life_cycle_change2.png" alt="android_activity_life_cycle_change2.png" />
  • 如何避免

    • Be careful when committing transactions inside Activity lifecycle methods
      只在onCreate或者響應(yīng)用戶的輸入時才會commit,不會遇到這個問題;但如果在onActivityResult、onStart、onResume等其他生命周期函數(shù)中調(diào)用,則會有風(fēng)險,尤其是onResume,推薦使用FragmentActivity#onResumeFragments()/Activity#onPostResume()中調(diào)用,而不是onResume。

      private boolean mReturningWithResult = false;
      
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          mReturningWithResult = true;
      }
      
      @Override
      protected void onPostResume() {
          super.onPostResume();
          if (mReturningWithResult) {
              // Commit your transactions here.
          }
          // Reset the boolean flag back to false for next time.
          mReturningWithResult = false;
      }
    • Avoid performing transactions inside asynchronous callback methods.
      回調(diào)內(nèi)已經(jīng)對Activity的狀態(tài)沒有保證了,強烈建議不要這么做;
    • Use commitAllowingStateLoss() only as a last resort.