summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2013-05-22 08:56:19 -0700
committerYorke Lee <yorkelee@google.com>2013-05-22 09:33:22 -0700
commit1b0da236015f2a7801566fb44e1c2585a44cd6a2 (patch)
tree5d2f63200b669970c95ddfc82fea720a5245dbd1
parente9e98035d8ed1a40c96881714bc698d6b4562c83 (diff)
Smart dialing caching not starting immediately
Bug 9086662 Change-Id: Iab8fc869180188930f84edb794e0a24a1a0a2229
-rw-r--r--src/com/android/dialer/dialpad/DialpadFragment.java25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 3d75e3983..54a8ab426 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -1669,11 +1669,13 @@ public class DialpadFragment extends Fragment
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
- if (mSmartDialEnabled && isVisibleToUser) {
- // This is called if the dialpad fragment is swiped into to view for the very first
- // time in the activity's lifecycle, or the user starts the dialer for the first time
- // and the dialpad fragment is displayed immediately, and is what causes the initial
- // caching process to happen.
+ if (mSmartDialEnabled && isVisibleToUser && mSmartDialCache != null) {
+ // This is called every time the dialpad fragment comes into view. The first
+ // time the dialer is launched, mSmartDialEnabled is always false as it has not been
+ // read from settings(in onResume) yet at the point where setUserVisibleHint is called
+ // for the first time, so the caching on first launch will happen in onResume instead.
+ // This covers only the case where the dialer is launched in the call log or
+ // contacts tab, and then the user swipes to the dialpad.
mSmartDialCache.cacheIfNeeded(false);
}
}
@@ -1722,12 +1724,13 @@ public class DialpadFragment extends Fragment
mContactsPrefs.getDisplayOrder());
// Don't force recache if this is the first time onResume is being called, since
// caching should already happen in setUserVisibleHint.
- if (!mFirstLaunch) {
- // This forced recache covers the case where the dialer was previously running, and
- // was brought back into the foreground. If the dialpad fragment hasn't actually
- // become visible throughout the entire activity's lifecycle, it is possible that
- // caching hasn't happened yet. In this case, we can force a recache anyway, since
- // we are not worried about startup performance anymore.
+ if (!mFirstLaunch || getUserVisibleHint()) {
+ // This forced recache covers the cases where the dialer was running before and
+ // was brought back into the foreground, or the dialer was launched for the first
+ // time and displays the dialpad fragment immediately. If the dialpad fragment
+ // hasn't actually become visible throughout the entire activity's lifecycle, it
+ // is possible that caching hasn't happened yet. In this case, we can force a
+ // recache anyway, since we are not worried about startup performance anymore.
mSmartDialCache.cacheIfNeeded(true);
}
} else {