1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.contacts.list; 17 18 import android.view.View; 19 import android.widget.ListView; 20 21 import com.android.contacts.widget.TextHighlightingAnimation; 22 23 /** 24 * A {@link TextHighlightingAnimation} that redraws just the contact display name in a 25 * list item. 26 */ 27 public class ContactNameHighlightingAnimation extends TextHighlightingAnimation { 28 private final ListView mListView; 29 private boolean mSavedScrollingCacheEnabledFlag; 30 ContactNameHighlightingAnimation(ListView listView, int duration)31 public ContactNameHighlightingAnimation(ListView listView, int duration) { 32 super(duration); 33 this.mListView = listView; 34 } 35 36 /** 37 * Redraws all visible items of the list corresponding to contacts 38 */ 39 @Override invalidate()40 protected void invalidate() { 41 int childCount = mListView.getChildCount(); 42 for (int i = 0; i < childCount; i++) { 43 View itemView = mListView.getChildAt(i); 44 if (itemView instanceof ContactListItemView) { 45 final ContactListItemView view = (ContactListItemView)itemView; 46 view.getNameTextView().invalidate(); 47 } 48 } 49 } 50 51 @Override onAnimationStarted()52 protected void onAnimationStarted() { 53 mSavedScrollingCacheEnabledFlag = mListView.isScrollingCacheEnabled(); 54 mListView.setScrollingCacheEnabled(false); 55 } 56 57 @Override onAnimationEnded()58 protected void onAnimationEnded() { 59 mListView.setScrollingCacheEnabled(mSavedScrollingCacheEnabledFlag); 60 } 61 } 62