summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Attwell <brianattwell@google.com>2014-09-12 15:12:03 -0700
committerBrian Attwell <brianattwell@google.com>2014-09-12 15:59:18 -0700
commit1d939e45d7658f25a6a8635ccecaa4d43014cfd5 (patch)
tree1e0899a51747c2a53a998eff4d5942c53908f2f7 /src
parentd688f64c4a7d0ca36701fd724c36cc030d980df3 (diff)
When view's expand, scroll them onto screen
Do this for views at the top and bottom of the list. Bug: 17410384 Change-Id: I5506909ae93658dea4e86b4a541eefbec28c15e4
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index b75e1c62d..4822e84c9 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -26,13 +26,14 @@ import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
import android.database.Cursor;
+import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
import android.provider.VoicemailContract.Status;
-import android.util.Log;
+import android.util.MutableInt;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -595,7 +596,16 @@ public class CallLogFragment extends AnalyticsListFragment
ValueAnimator animator = isExpand ? ValueAnimator.ofFloat(0f, 1f)
: ValueAnimator.ofFloat(1f, 0f);
+ // Figure out how much scrolling is needed to make the view fully visible.
+ final Rect localVisibleRect = new Rect();
+ view.getLocalVisibleRect(localVisibleRect);
+ final int scrollingNeeded = localVisibleRect.top > 0 ? -localVisibleRect.top
+ : view.getMeasuredHeight() - localVisibleRect.height();
+
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+
+ private int mCurrentScroll = 0;
+
@Override
public void onAnimationUpdate(ValueAnimator animator) {
Float value = (Float) animator.getAnimatedValue();
@@ -606,6 +616,12 @@ public class CallLogFragment extends AnalyticsListFragment
viewHolder.callLogEntryView.setTranslationZ(z);
view.setTranslationZ(z); // WAR
view.requestLayout();
+
+ if (isExpand) {
+ int scrollBy = (int) (value * scrollingNeeded) - mCurrentScroll;
+ getListView().smoothScrollBy(scrollBy, /* duration = */ 0);
+ mCurrentScroll += scrollBy;
+ }
}
});
// Set everything to their final values when the animation's done.