blob: 3a17bb6b5f13465e4187f0f1b53c6b9d2467df60 [file] [log] [blame]
Dmitri Plotnikovfda2edd2010-04-23 17:58:29 -07001/*
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 */
16package com.android.contacts;
17
18import com.android.contacts.widget.TextHighlightingAnimation;
19
20import android.view.View;
21import android.widget.ListView;
22
23/**
24 * A {@link TextHighlightingAnimation} that redraws just the contact display name in a
25 * list item.
26 */
27public class ContactNameHighlightingAnimation extends TextHighlightingAnimation {
28 private final ListView mListView;
29
30 public ContactNameHighlightingAnimation(ListView listView, int duration) {
31 super(duration);
32 this.mListView = listView;
33 }
34
35 /**
36 * Redraws all visible items of the list corresponding to contacts
37 */
38 @Override
39 protected void invalidate() {
40 int childCount = mListView.getChildCount();
41 for (int i = 0; i < childCount; i++) {
42 View itemView = mListView.getChildAt(i);
43 if (itemView instanceof ContactListItemView) {
44 final ContactListItemView view = (ContactListItemView)itemView;
45 view.getNameTextView().invalidate();
46 }
47 }
48 }
49
50 @Override
51 protected void onAnimationStarted() {
52 mListView.setScrollingCacheEnabled(false);
53 }
54
55 @Override
56 protected void onAnimationEnded() {
57 mListView.setScrollingCacheEnabled(true);
58 }
59}