DO NOT MERGE: Optimize Dashboard loading
- prevent loading categories twice
- add some logging to see the time taken for building the Dashboard titles
Change-Id: I31724c0e66fe3b453a87f12476f58db84c73423f
(cherry picked from commit b644f29313
)
This commit is contained in:
committed by
Dave Langemak
parent
6654884417
commit
42c4b0abe5
@@ -329,7 +329,9 @@ public class SettingsActivity extends Activity
|
|||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_BUILD_CATEGORIES: {
|
case MSG_BUILD_CATEGORIES: {
|
||||||
|
if(mNeedToRebuildCategories) {
|
||||||
buildDashboardCategories(mCategories);
|
buildDashboardCategories(mCategories);
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -346,7 +348,7 @@ public class SettingsActivity extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<DashboardCategory> getDashboardCategories() {
|
public List<DashboardCategory> getDashboardCategories() {
|
||||||
if (mNeedToRebuildCategories) {
|
if (mNeedToRebuildCategories || mCategories.size() == 0) {
|
||||||
buildDashboardCategories(mCategories);
|
buildDashboardCategories(mCategories);
|
||||||
mNeedToRebuildCategories = false;
|
mNeedToRebuildCategories = false;
|
||||||
}
|
}
|
||||||
@@ -497,18 +499,13 @@ public class SettingsActivity extends Activity
|
|||||||
switchToFragment( initialFragmentName, initialArguments, true, false,
|
switchToFragment( initialFragmentName, initialArguments, true, false,
|
||||||
mInitialTitle, false);
|
mInitialTitle, false);
|
||||||
} else {
|
} else {
|
||||||
// We need to build the Categories in all cases
|
|
||||||
buildDashboardCategories(mCategories);
|
|
||||||
|
|
||||||
// No UP if we are displaying the main Dashboard
|
// No UP if we are displaying the main Dashboard
|
||||||
mDisplayHomeAsUpEnabled = false;
|
mDisplayHomeAsUpEnabled = false;
|
||||||
if (mCategories.size() > 0) {
|
|
||||||
mInitialTitle = getText(R.string.dashboard_title);
|
mInitialTitle = getText(R.string.dashboard_title);
|
||||||
switchToFragment(DashboardSummary.class.getName(), null, false, false,
|
switchToFragment(DashboardSummary.class.getName(), null, false, false,
|
||||||
mInitialTitle, false);
|
mInitialTitle, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
mActionBar = getActionBar();
|
mActionBar = getActionBar();
|
||||||
if (mActionBar != null) {
|
if (mActionBar != null) {
|
||||||
|
@@ -27,6 +27,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -79,6 +80,7 @@ public class DashboardSummary extends Fragment implements OnAccountsUpdateListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void rebuildUI(Context context) {
|
private void rebuildUI(Context context) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
|
|
||||||
mDashboard.removeAllViews();
|
mDashboard.removeAllViews();
|
||||||
@@ -116,6 +118,8 @@ public class DashboardSummary extends Fragment implements OnAccountsUpdateListen
|
|||||||
// Add the category
|
// Add the category
|
||||||
mDashboard.addView(categoryView);
|
mDashboard.addView(categoryView);
|
||||||
}
|
}
|
||||||
|
long delta = System.currentTimeMillis() - start;
|
||||||
|
Log.d(LOG_TAG, "rebuildUI took: " + delta + " ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user