Dmitri Plotnikov | fda2edd | 2010-04-23 17:58:29 -0700 | [diff] [blame] | 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; |
| 17 | |
Dmitri Plotnikov | aebce36 | 2010-04-23 19:02:38 -0700 | [diff] [blame^] | 18 | import com.android.contacts.list.ContactListItemView; |
Dmitri Plotnikov | fda2edd | 2010-04-23 17:58:29 -0700 | [diff] [blame] | 19 | import com.android.contacts.widget.TextHighlightingAnimation; |
| 20 | |
| 21 | import android.view.View; |
| 22 | import android.widget.ListView; |
| 23 | |
| 24 | /** |
| 25 | * A {@link TextHighlightingAnimation} that redraws just the contact display name in a |
| 26 | * list item. |
| 27 | */ |
| 28 | public class ContactNameHighlightingAnimation extends TextHighlightingAnimation { |
| 29 | private final ListView mListView; |
| 30 | |
| 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 |
| 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 |
| 52 | protected void onAnimationStarted() { |
| 53 | mListView.setScrollingCacheEnabled(false); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | protected void onAnimationEnded() { |
| 58 | mListView.setScrollingCacheEnabled(true); |
| 59 | } |
| 60 | } |