activiti 裡面各個方法理解

來源:互聯網
上載者:User

標籤:

/** Return the intent that started this activity. */
public Intent getIntent() {
return mIntent;
}

public void setIntent(Intent newIntent) {
mIntent = newIntent;
}

/** Return the application that owns this activity. */
public final Application getApplication() {
return mApplication;
}

/** Is this activity embedded inside of another activity? */
public final boolean isChild() {
return mParent != null;
}

/** Return the parent activity if this view is an embedded child. */
public final Activity getParent() {
return mParent;
}

/** Retrieve the window manager for showing custom windows. */
public WindowManager getWindowManager() {
return mWindowManager;
}

public Window getWindow() {
return mWindow;
}

/**
* Return the LoaderManager for this activity, creating it if needed.
*/
public LoaderManager getLoaderManager() {
if (mLoaderManager != null) {
return mLoaderManager;
}
mCheckedForLoaderManager = true;
mLoaderManager = getLoaderManager("(root)", mLoadersStarted, true);
return mLoaderManager;
}

LoaderManager : 首先是查詢資料的邏輯放在了UI產生的同個線程中,這個就意味著在查詢資料的時候,UI頁面產生的工作被阻塞住了。UI一旦被阻塞使用者就會被感知出來了,因此就會出現各種無相應頁面(Application Not Response),或者activity頁面延遲的現象,這對使用者體驗來說是不可接受的。

 其次是在渲染頁面的時候需要固定需要進行一次資料查詢,但是這個是很不節省資源的。假如一個Activity從一個停止狀態回到前台,那麼這個時候儘管資料並沒有變化,但是也需要進行一次query操作。在浪費資源的同時也再次增加了頁面渲染失敗的風險。

還有就是當資料變化的時候如何通知頁面進行修改呢?這個時候往往就又要建立一個monitor的角色,來當資料來源變化的時候來讓頁面重新調用requery。

因此在Android的越來越提倡使用者體驗的今天,載入器和載入管理器(Loader,LoaderManager)就出現了。

Loader有什麼作用?1 在單獨的線程中讀取資料2 監視資料的更新

而LoaderManager就是載入器的管理器,一個LoaderManager可以管理一個或多個Loader,一個Activity或者Fragment只能有一個LoadManager。LoaderManager管理Loader的初始化,重啟和銷毀操作。

activiti 裡面各個方法理解

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.