码迷,mamicode.com
首页 > 其他好文 > 详细

activiti 里面各个方法理解

时间:2016-05-20 11:25:31      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:

/** 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 里面各个方法理解

标签:

原文地址:http://www.cnblogs.com/liu-fei/p/5511278.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!