Optimize Dashboard loading
- prevent loading categories twice - add some logging to see the time taken for building the Dashboard titles Change-Id: I31724c0e66fe3b453a87f12476f58db84c73423f
This commit is contained in:
@@ -325,7 +325,9 @@ public class SettingsActivity extends Activity
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_BUILD_CATEGORIES: {
|
||||
buildDashboardCategories(mCategories);
|
||||
if(mNeedToRebuildCategories) {
|
||||
buildDashboardCategories(mCategories);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@@ -342,7 +344,7 @@ public class SettingsActivity extends Activity
|
||||
}
|
||||
|
||||
public List<DashboardCategory> getDashboardCategories() {
|
||||
if (mNeedToRebuildCategories) {
|
||||
if (mNeedToRebuildCategories || mCategories.size() == 0) {
|
||||
buildDashboardCategories(mCategories);
|
||||
mNeedToRebuildCategories = false;
|
||||
}
|
||||
@@ -491,16 +493,11 @@ public class SettingsActivity extends Activity
|
||||
switchToFragment( initialFragmentName, initialArguments, true, false,
|
||||
mInitialTitle, false);
|
||||
} else {
|
||||
// We need to build the Categories in all cases
|
||||
buildDashboardCategories(mCategories);
|
||||
|
||||
// No UP if we are displaying the main Dashboard
|
||||
mDisplayHomeAsUpEnabled = false;
|
||||
if (mCategories.size() > 0) {
|
||||
mInitialTitle = getText(R.string.dashboard_title);
|
||||
switchToFragment(DashboardSummary.class.getName(), null, false, false,
|
||||
mInitialTitle, false);
|
||||
}
|
||||
mInitialTitle = getText(R.string.dashboard_title);
|
||||
switchToFragment(DashboardSummary.class.getName(), null, false, false,
|
||||
mInitialTitle, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user