Merge "Increase size of avatar and bussiness letter tile" into lmp-dev
diff --git a/src/com/android/contacts/common/util/ContactListViewUtils.java b/src/com/android/contacts/common/util/ContactListViewUtils.java
index 2bb5c73..24b18a7 100644
--- a/src/com/android/contacts/common/util/ContactListViewUtils.java
+++ b/src/com/android/contacts/common/util/ContactListViewUtils.java
@@ -15,16 +15,16 @@
// These two constants will help add more padding for the text inside the card.
private static final double TEXT_LEFT_PADDING_TO_CARD_PADDING_RATIO = 1.1;
- private static void addPaddingToView(ListView listView, int listSpaceWeight, int listViewWeight)
+ private static void addPaddingToView(ListView listView, int parentWidth,
+ int listSpaceWeight, int listViewWeight)
{
if (listSpaceWeight > 0 && listViewWeight > 0) {
double paddingPercent = (double) listSpaceWeight / (double)
(listSpaceWeight * 2 + listViewWeight);
- int width = listView.getWidth();
listView.setPadding(
- (int) (width * paddingPercent * TEXT_LEFT_PADDING_TO_CARD_PADDING_RATIO),
+ (int) (parentWidth * paddingPercent * TEXT_LEFT_PADDING_TO_CARD_PADDING_RATIO),
listView.getPaddingTop(),
- (int) (width * paddingPercent * TEXT_LEFT_PADDING_TO_CARD_PADDING_RATIO),
+ (int) (parentWidth * paddingPercent * TEXT_LEFT_PADDING_TO_CARD_PADDING_RATIO),
listView.getPaddingBottom());
// The EdgeEffect and ScrollBar need to span to the edge of the ListView's padding.
listView.setClipToPadding(false);
@@ -43,7 +43,7 @@
* @param rootLayout layout that contains ListView and R.id.list_card
*/
public static void applyCardPaddingToView(Resources resources,
- final ListView listView, View rootLayout) {
+ final ListView listView, final View rootLayout) {
// Set a padding on the list view so it appears in the center of the card
// in the layout if required.
final int listSpaceWeight = resources.getInteger(
@@ -65,8 +65,11 @@
SchedulingUtils.doOnPreDraw(listView, /* drawNextFrame = */ false, new Runnable() {
@Override
public void run() {
+ // Use the rootLayout.getWidth() instead of listView.getWidth() since
+ // we sometimes hide the listView until we finish loading data. This would
+ // result in incorrect padding.
ContactListViewUtils.addPaddingToView(
- listView, listSpaceWeight, listViewWeight);
+ listView, rootLayout.getWidth(), listSpaceWeight, listViewWeight);
}
});
}