From 2ff08a8f8d4762ab5d0aebb0b69079f0b8d20b3e Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Fri, 24 Oct 2014 17:16:39 -0700 Subject: Remove CallLogListItemView CallLogListItemView is a custom view that might have done something once, but doesn't anymore. It makes the code more complicated to read and requires a lot of casting that does nothing at all. Change-Id: I53efb35367d748aa3d164d0fb56686175967c90e --- res/layout/call_log_list_item.xml | 5 ++- src/com/android/dialer/calllog/CallLogAdapter.java | 35 ++++++++++---------- .../android/dialer/calllog/CallLogFragment.java | 6 ++-- .../dialer/calllog/CallLogListItemView.java | 38 ---------------------- .../android/dialer/list/ShortcutCardsAdapter.java | 4 +-- .../android/dialer/calllog/CallLogAdapterTest.java | 3 +- 6 files changed, 25 insertions(+), 66 deletions(-) delete mode 100644 src/com/android/dialer/calllog/CallLogListItemView.java diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml index 761f35201..c77a1f7ad 100644 --- a/res/layout/call_log_list_item.xml +++ b/res/layout/call_log_list_item.xml @@ -14,8 +14,7 @@ limitations under the License. --> - - + diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index bd20d2209..6afade407 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -74,10 +74,10 @@ public class CallLogAdapter extends GroupingListAdapter /** Interface used to inform a parent UI element that a list item has been expanded. */ public interface CallItemExpandedListener { /** - * @param view The {@link CallLogListItemView} that represents the item that was clicked + * @param view The {@link View} that represents the item that was clicked * on. */ - public void onItemExpanded(CallLogListItemView view); + public void onItemExpanded(View view); /** * Retrieves the call log view for the specified call Id. If the view is not currently @@ -86,7 +86,7 @@ public class CallLogAdapter extends GroupingListAdapter * @param callId The call Id. * @return The call log view. */ - public CallLogListItemView getViewForCallId(long callId); + public View getViewForCallId(long callId); } /** Interface used to initiate a refresh of the content. */ @@ -286,7 +286,7 @@ public class CallLogAdapter extends GroupingListAdapter private final View.OnClickListener mExpandCollapseListener = new View.OnClickListener() { @Override public void onClick(View v) { - final CallLogListItemView callLogItem = (CallLogListItemView) v.getParent().getParent(); + final View callLogItem = (View) v.getParent().getParent(); handleRowExpanded(callLogItem, true /* animate */, false /* forceExpand */); } }; @@ -296,7 +296,7 @@ public class CallLogAdapter extends GroupingListAdapter public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { - handleRowExpanded((CallLogListItemView) host, false /* animate */, + handleRowExpanded(host, false /* animate */, true /* forceExpand */); } return super.onRequestSendAccessibilityEvent(host, child, event); @@ -588,8 +588,7 @@ public class CallLogAdapter extends GroupingListAdapter @Override protected View newChildView(Context context, ViewGroup parent) { LayoutInflater inflater = LayoutInflater.from(context); - CallLogListItemView view = - (CallLogListItemView) inflater.inflate(R.layout.call_log_list_item, parent, false); + View view = inflater.inflate(R.layout.call_log_list_item, parent, false); // Get the views to bind to and cache them. CallLogListItemViews views = CallLogListItemViews.fromView(view); @@ -624,14 +623,13 @@ public class CallLogAdapter extends GroupingListAdapter /** * Binds the views in the entry to the data in the call log. * - * @param view the view corresponding to this entry + * @param callLogItemView the view corresponding to this entry * @param c the cursor pointing to the entry in the call log * @param count the number of entries in the current item, greater than 1 if it is a group */ - private void bindView(View view, Cursor c, int count) { - view.setAccessibilityDelegate(mAccessibilityDelegate); - final CallLogListItemView callLogItemView = (CallLogListItemView) view; - final CallLogListItemViews views = (CallLogListItemViews) view.getTag(); + private void bindView(View callLogItemView, Cursor c, int count) { + callLogItemView.setAccessibilityDelegate(mAccessibilityDelegate); + final CallLogListItemViews views = (CallLogListItemViews) callLogItemView.getTag(); // Default case: an item in the call log. views.primaryActionView.setVisibility(View.VISIBLE); @@ -813,11 +811,11 @@ public class CallLogAdapter extends GroupingListAdapter // Listen for the first draw if (mViewTreeObserver == null) { - mViewTreeObserver = view.getViewTreeObserver(); + mViewTreeObserver = callLogItemView.getViewTreeObserver(); mViewTreeObserver.addOnPreDrawListener(this); } - bindBadge(view, info, details, callType); + bindBadge(callLogItemView, info, details, callType); } /** @@ -886,12 +884,13 @@ public class CallLogAdapter extends GroupingListAdapter } /** - * Expands or collapses the view containing the CALLBACK, VOICEMAIL and DETAILS action buttons. + * Expands or collapses the view containing the CALLBACK/REDIAL, VOICEMAIL and DETAILS action + * buttons. * * @param callLogItem The call log entry parent view. * @param isExpanded The new expansion state of the view. */ - private void expandOrCollapseActions(CallLogListItemView callLogItem, boolean isExpanded) { + private void expandOrCollapseActions(View callLogItem, boolean isExpanded) { final CallLogListItemViews views = (CallLogListItemViews)callLogItem.getTag(); expandVoicemailTranscriptionView(views, isExpanded); @@ -1386,7 +1385,7 @@ public class CallLogAdapter extends GroupingListAdapter * @param forceExpand Whether or not to force the call log row into an expanded state regardless * of its previous state */ - private void handleRowExpanded(CallLogListItemView view, boolean animate, boolean forceExpand) { + private void handleRowExpanded(View view, boolean animate, boolean forceExpand) { final CallLogListItemViews views = (CallLogListItemViews) view.getTag(); if (forceExpand && isExpanded(views.rowId)) { @@ -1407,7 +1406,7 @@ public class CallLogAdapter extends GroupingListAdapter // Animate the collapse of the previous item if it is still visible on screen. if (mPreviouslyExpanded != NONE_EXPANDED) { - CallLogListItemView previousItem = mCallItemExpandedListener.getViewForCallId( + View previousItem = mCallItemExpandedListener.getViewForCallId( mPreviouslyExpanded); if (previousItem != null) { diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index f4db08068..dfb774996 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -548,7 +548,7 @@ public class CallLogFragment extends AnalyticsListFragment } @Override - public void onItemExpanded(final CallLogListItemView view) { + public void onItemExpanded(final View view) { final int startingHeight = view.getHeight(); final CallLogListItemViews viewHolder = (CallLogListItemViews) view.getTag(); final ViewTreeObserver observer = getListView().getViewTreeObserver(); @@ -661,7 +661,7 @@ public class CallLogFragment extends AnalyticsListFragment * @return The call log view. */ @Override - public CallLogListItemView getViewForCallId(long callId) { + public View getViewForCallId(long callId) { ListView listView = getListView(); int firstPosition = listView.getFirstVisiblePosition(); @@ -673,7 +673,7 @@ public class CallLogFragment extends AnalyticsListFragment if (view != null) { final CallLogListItemViews viewHolder = (CallLogListItemViews) view.getTag(); if (viewHolder != null && viewHolder.rowId == callId) { - return (CallLogListItemView)view; + return view; } } } diff --git a/src/com/android/dialer/calllog/CallLogListItemView.java b/src/com/android/dialer/calllog/CallLogListItemView.java deleted file mode 100644 index b8990f50a..000000000 --- a/src/com/android/dialer/calllog/CallLogListItemView.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dialer.calllog; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.LinearLayout; - -/** - * An entry in the call log. - */ -public class CallLogListItemView extends LinearLayout { - public CallLogListItemView(Context context) { - super(context); - } - - public CallLogListItemView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public CallLogListItemView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } -} diff --git a/src/com/android/dialer/list/ShortcutCardsAdapter.java b/src/com/android/dialer/list/ShortcutCardsAdapter.java index 4fe638ea1..78b774b02 100644 --- a/src/com/android/dialer/list/ShortcutCardsAdapter.java +++ b/src/com/android/dialer/list/ShortcutCardsAdapter.java @@ -32,7 +32,6 @@ import android.widget.TextView; 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; @@ -266,8 +265,7 @@ public class ShortcutCardsAdapter extends BaseAdapter { R.dimen.recent_call_log_item_translation_z); view.setTranslationZ(mPreviousTranslationZ); - final CallLogListItemView callLogItem = - (CallLogListItemView) view.findViewById(R.id.call_log_list_item); + final ViewGroup callLogItem = (ViewGroup) view.findViewById(R.id.call_log_list_item); // Reset the internal call log item view if it is being recycled callLogItem.setTranslationX(0); callLogItem.setTranslationY(0); diff --git a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java index b7f06d31c..9b3e6bcc4 100644 --- a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java @@ -21,6 +21,7 @@ import android.database.MatrixCursor; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import android.view.View; +import android.widget.LinearLayout; import com.google.common.collect.Lists; @@ -68,7 +69,7 @@ public class CallLogAdapterTest extends AndroidTestCase { mCursor = new MatrixCursor(CallLogQuery._PROJECTION); mCursor.moveToFirst(); // The views into which to store the data. - mView = new CallLogListItemView(getContext()); + mView = new LinearLayout(getContext()); mView.setTag(CallLogListItemViews.createForTest(getContext())); } -- cgit v1.2.3