diff options
Diffstat (limited to 'src/com')
3 files changed, 28 insertions, 20 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java index d7c387e57..c2a1b03b7 100644 --- a/src/com/android/dialer/list/PhoneFavoriteFragment.java +++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java @@ -144,18 +144,17 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen private CallLogAdapter mCallLogAdapter; private CallLogQueryHandler mCallLogQueryHandler; - private TextView mEmptyView; private PhoneFavoriteListView mListView; + private View mShowAllContactsButton; private final HashMap<Long, Integer> mItemIdTopMap = new HashMap<Long, Integer>(); private final HashMap<Long, Integer> mItemIdLeftMap = new HashMap<Long, Integer>(); /** - * Layout used when contacts load is slower than expected and thus "loading" view should be - * shown. + * Layout used when there are no favorites. */ - private View mLoadingView; + private View mEmptyView; private final ContactTileView.Listener mContactTileAdapterListener = new ContactTileAdapterListener(); @@ -171,7 +170,6 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen // Construct two base adapters which will become part of PhoneFavoriteMergedAdapter. // We don't construct the resultant adapter at this moment since it requires LayoutInflater // that will be available on onCreateView(). - mContactTileAdapter = new PhoneFavoritesTileAdapter(activity, mContactTileAdapterListener, this, getResources().getInteger(R.integer.contact_tile_column_count_in_favorites_new), @@ -214,7 +212,8 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen mListView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); mListView.setOnItemSwipeListener(mContactTileAdapter); - mLoadingView = inflater.inflate(R.layout.phone_loading_contacts, mListView, false); + mEmptyView = inflater.inflate(R.layout.phone_no_favorites, mListView, false); + mShowAllContactsButton = inflater.inflate(R.layout.show_all_contact_button, mListView, false); mShowAllContactsButton.setOnClickListener(new OnClickListener() { @@ -224,8 +223,9 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen } }); + mContactTileAdapter.setEmptyView(mEmptyView); mAdapter = new PhoneFavoriteMergedAdapter(getActivity(), mContactTileAdapter, - mCallLogAdapter, mLoadingView, mShowAllContactsButton); + mCallLogAdapter, mShowAllContactsButton); mListView.setAdapter(mAdapter); @@ -233,10 +233,6 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen mListView.setFastScrollEnabled(false); mListView.setFastScrollAlwaysVisible(false); - mEmptyView = (TextView) listLayout.findViewById(R.id.contact_tile_list_empty); - mEmptyView.setText(getString(R.string.listTotalAllContactsZero)); - mListView.setEmptyView(mEmptyView); - return listLayout; } diff --git a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java index 57ae2c147..575ef0a24 100644 --- a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java @@ -52,7 +52,6 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { private static final int ALL_CONTACTS_BUTTON_ITEM_ID = -1; private final PhoneFavoritesTileAdapter mContactTileAdapter; private final CallLogAdapter mCallLogAdapter; - private final View mLoadingView; private final View mShowAllContactsButton; private final int mCallLogPadding; @@ -99,7 +98,6 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { public PhoneFavoriteMergedAdapter(Context context, PhoneFavoritesTileAdapter contactTileAdapter, CallLogAdapter callLogAdapter, - View loadingView, View showAllContactsButton) { final Resources resources = context.getResources(); mContext = context; @@ -109,7 +107,6 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { mObserver = new CustomDataSetObserver(); mCallLogAdapter.registerDataSetObserver(mObserver); mContactTileAdapter.registerDataSetObserver(mObserver); - mLoadingView = loadingView; mShowAllContactsButton = showAllContactsButton; mCallLogQueryHandler = new CallLogQueryHandler(mContext.getContentResolver(), mCallLogQueryHandlerListener); @@ -242,9 +239,6 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { @Override public boolean areAllItemsEnabled() { - // If "all" section is being loaded we'll show mLoadingView, which is not enabled. - // Otherwise check the all the other components in the ListView and return appropriate - // result. return mCallLogAdapter.areAllItemsEnabled() && mContactTileAdapter.areAllItemsEnabled(); } diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java index 91acc6fe0..966233862 100644 --- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java @@ -74,6 +74,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements private Context mContext; private Resources mResources; + private View mEmptyView; + /** Contact data stored in cache. This is used to populate the associated view. */ protected ArrayList<ContactEntry> mContactEntries = null; /** Back up of the temporarily removed Contact during dragging. */ @@ -367,10 +369,15 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements return mNumFrequents; } + private boolean isEmptyView(int position) { + return position == 0 && (mContactEntries == null || mContactEntries.isEmpty()); + } + @Override public int getCount() { if (mContactEntries == null || mContactEntries.isEmpty()) { - return 0; + // empty view + return 1; } int total = mContactEntries.size(); @@ -493,7 +500,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements @Override public boolean isEnabled(int position) { - return true; + return !isEmptyView(position); } @Override @@ -509,8 +516,13 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements if (DEBUG) { Log.v(TAG, "get view for " + String.valueOf(position)); } + int itemViewType = getItemViewType(position); + if (itemViewType == ViewTypes.EMPTY) { + return mEmptyView; + } + ContactTileRow contactTileRowView = (ContactTileRow) convertView; ArrayList<ContactEntry> contactList = getItem(position); @@ -542,6 +554,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements @Override public int getItemViewType(int position) { + if (isEmptyView(position)) return ViewTypes.EMPTY; if (position < getRowCount(getMaxContactsInTiles())) { return ViewTypes.TOP; } else { @@ -1129,9 +1142,10 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements } protected static class ViewTypes { - public static final int COUNT = 2; + public static final int COUNT = 3; public static final int FREQUENT = 0; public static final int TOP = 1; + public static final int EMPTY = 2; } @Override @@ -1158,4 +1172,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements public boolean isSwipeEnabled() { return !mAwaitingRemove; } + + public void setEmptyView(View emptyView) { + mEmptyView = emptyView; + } } |