summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Attwell <brianattwell@google.com>2014-09-12 23:39:22 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-12 23:39:23 +0000
commitbd97cd041453dc8545deaa7ad17e8bd99d53e0de (patch)
tree958c63ffee0c7535466a07ed80d3c5085b04f23a
parent515bd5d6bd69220eb80f6d58eb5bf9540ef5b50a (diff)
parent1d939e45d7658f25a6a8635ccecaa4d43014cfd5 (diff)
Merge "When view's expand, scroll them onto screen" into lmp-dev
-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 9dbfd4464..2f0ee5370 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.