diff options
author | Yorke Lee <yorkelee@google.com> | 2014-06-04 09:51:51 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2014-06-04 09:51:51 -0700 |
commit | 757ca2485e5bf9b52a0c929384d4c198e25a706f (patch) | |
tree | 49f267f41e79972dffb061fca45181b960283f5c | |
parent | d4a57a94d55840782a444bda20ae45d387fc2230 (diff) |
Correctly reset all wrapped CallLogListItemView attributes
Since we are doing our own internal recycling of CallLogListItemViews
for the ShortcutCardsAdapter, make sure to correctly reset all related
attributes when adding a new child view
Bug: 15413649
Change-Id: Ic4907082646f9d8ad9a5ac157ed58b219984d5d3
-rw-r--r-- | src/com/android/dialer/list/ShortcutCardsAdapter.java | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/com/android/dialer/list/ShortcutCardsAdapter.java b/src/com/android/dialer/list/ShortcutCardsAdapter.java index 128871dcd..088535ab7 100644 --- a/src/com/android/dialer/list/ShortcutCardsAdapter.java +++ b/src/com/android/dialer/list/ShortcutCardsAdapter.java @@ -31,6 +31,7 @@ import android.widget.LinearLayout; import com.android.dialer.R; import com.android.dialer.calllog.CallLogAdapter; +import com.android.dialer.calllog.CallLogListItemView; import com.android.dialer.calllog.CallLogNotificationsHelper; import com.android.dialer.calllog.CallLogQueryHandler; import com.android.dialer.list.SwipeHelper.OnItemGestureListener; @@ -188,10 +189,7 @@ public class ShortcutCardsAdapter extends BaseAdapter { final View view = mCallLogAdapter.getView(position, convertView == null ? null : wrapper.getChildAt(0), parent); wrapper.removeAllViews(); - final View callLogItem = view.findViewById(R.id.call_log_list_item); - // Reset the internal call log item view if it is being recycled - callLogItem.setTranslationX(0); - callLogItem.setAlpha(1); + wrapper.prepareChildView(view); wrapper.addView(view); return wrapper; } @@ -225,8 +223,7 @@ public class ShortcutCardsAdapter extends BaseAdapter { densityScale, pagingTouchSlop); } - @Override - public void addView(View view) { + private void prepareChildView(View view) { view.setBackgroundResource(R.drawable.rounded_corner_bg); final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( @@ -251,7 +248,13 @@ public class ShortcutCardsAdapter extends BaseAdapter { R.dimen.recent_call_log_item_translation_z); view.setTranslationZ(mPreviousTranslationZ); - super.addView(view); + final CallLogListItemView callLogItem = + (CallLogListItemView) view.findViewById(R.id.call_log_list_item); + // Reset the internal call log item view if it is being recycled + callLogItem.setTranslationX(0); + callLogItem.setAlpha(1); + callLogItem.setClipBounds(null); + setChildrenOpacity(callLogItem, 1.0f); } @Override @@ -346,9 +349,13 @@ public class ShortcutCardsAdapter extends BaseAdapter { // If the view has any children, fade them out of view. final ViewGroup viewGroup = (ViewGroup) viewToClip; + setChildrenOpacity(viewGroup, Math.max(0, 1 - 3 * ratioHidden)); + } + + private void setChildrenOpacity(ViewGroup viewGroup, float alpha) { final int count = viewGroup.getChildCount(); for (int i = 0; i < count; i++) { - viewGroup.getChildAt(i).setAlpha(Math.max(0, 1 - 3 * ratioHidden)); + viewGroup.getChildAt(i).setAlpha(alpha); } } } |