Loading src/com/android/contacts/activities/ContactDetailActivity.java +2 −32 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import com.android.contacts.detail.ContactDetailUpdatesFragment; import com.android.contacts.detail.ContactDetailViewPagerAdapter; import com.android.contacts.detail.ContactLoaderFragment; import com.android.contacts.detail.ContactLoaderFragment.ContactLoaderFragmentListener; import com.android.contacts.detail.TabCarouselScrollManager; import com.android.contacts.interactions.ContactDeletionInteraction; import com.android.contacts.model.AccountWithDataSet; import com.android.contacts.util.PhoneCapabilityTester; Loading Loading @@ -55,8 +56,6 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; import android.widget.CheckBox; import android.widget.Toast; Loading Loading @@ -153,8 +152,7 @@ public class ContactDetailActivity extends ContactsActivity { } mDetailFragment.setListener(mFragmentListener); mDetailFragment.setVerticalScrollListener(mVerticalScrollListener); mUpdatesFragment.setVerticalScrollListener(mVerticalScrollListener); TabCarouselScrollManager.bind(mTabCarousel, mDetailFragment, mUpdatesFragment); mDetailFragment.setData(mLookupUri, mContactData); mUpdatesFragment.setData(mLookupUri, mContactData); Loading Loading @@ -555,34 +553,6 @@ public class ContactDetailActivity extends ContactsActivity { } }; private OnScrollListener mVerticalScrollListener = new OnScrollListener() { @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mTabCarousel == null) { return; } // If the FIRST item is not visible on the screen, then the carousel must be pinned // at the top of the screen. if (firstVisibleItem != 0) { mTabCarousel.setY(-mTabCarousel.getAllowedVerticalScrollLength()); return; } View topView = view.getChildAt(firstVisibleItem); if (topView == null) { return; } int amtToScroll = Math.max((int) view.getChildAt(firstVisibleItem).getY(), - mTabCarousel.getAllowedVerticalScrollLength()); mTabCarousel.setY(amtToScroll); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) {} }; /** * This interface should be implemented by {@link Fragment}s within this * activity so that the activity can determine whether the currently Loading src/com/android/contacts/detail/ContactDetailLayoutController.java +1 −32 Original line number Diff line number Diff line Loading @@ -29,8 +29,6 @@ import android.support.v4.view.ViewPager.OnPageChangeListener; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; /** * Determines the layout of the contact card. Loading Loading @@ -115,8 +113,6 @@ public class ContactDetailLayoutController { } mDetailFragment.setListener(mContactDetailFragmentListener); mDetailFragment.setVerticalScrollListener(mVerticalScrollListener); mUpdatesFragment.setVerticalScrollListener(mVerticalScrollListener); switch (mLayoutMode) { case VIEW_PAGER_AND_CAROUSEL: { Loading Loading @@ -151,6 +147,7 @@ public class ContactDetailLayoutController { } transaction.commit(); mFragmentManager.executePendingTransactions(); TabCarouselScrollManager.bind(mTabCarousel, mDetailFragment, mUpdatesFragment); break; } case TWO_COLUMN: { Loading Loading @@ -306,32 +303,4 @@ public class ContactDetailLayoutController { mViewPager.setCurrentItem(position); } }; private OnScrollListener mVerticalScrollListener = new OnScrollListener() { @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mTabCarousel == null) { return; } // If the FIRST item is not visible on the screen, then the carousel must be pinned // at the top of the screen. if (firstVisibleItem != 0) { mTabCarousel.setY(-mTabCarousel.getAllowedVerticalScrollLength()); return; } View topView = view.getChildAt(firstVisibleItem); if (topView == null) { return; } int amtToScroll = Math.max((int) view.getChildAt(firstVisibleItem).getY(), -mTabCarousel.getAllowedVerticalScrollLength()); mTabCarousel.setY(amtToScroll); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) {} }; } src/com/android/contacts/detail/TabCarouselScrollManager.java 0 → 100644 +74 −0 Original line number Diff line number Diff line /* * 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.contacts.detail; import android.view.View; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; /** * Takes care of managing scrolling for the side-by-side views using the tab carousel. */ public class TabCarouselScrollManager { private final ContactDetailTabCarousel mTabCarousel; private final ContactDetailFragment mAboutFragment; private final ContactDetailUpdatesFragment mUpdatesFragment; private final OnScrollListener mVerticalScrollListener = new OnScrollListener() { @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mTabCarousel == null) { return; } // If the FIRST item is not visible on the screen, then the carousel must be pinned // at the top of the screen. if (firstVisibleItem != 0) { mTabCarousel.setY(-mTabCarousel.getAllowedVerticalScrollLength()); return; } View topView = view.getChildAt(firstVisibleItem); if (topView == null) { return; } int amtToScroll = Math.max((int) view.getChildAt(firstVisibleItem).getY(), -mTabCarousel.getAllowedVerticalScrollLength()); mTabCarousel.setY(amtToScroll); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) {} }; private TabCarouselScrollManager(ContactDetailTabCarousel tabCarousel, ContactDetailFragment aboutFragment, ContactDetailUpdatesFragment updatesFragment) { mTabCarousel = tabCarousel; mAboutFragment = aboutFragment; mUpdatesFragment = updatesFragment; } public void bind() { mAboutFragment.setVerticalScrollListener(mVerticalScrollListener); mUpdatesFragment.setVerticalScrollListener(mVerticalScrollListener); } public static void bind(ContactDetailTabCarousel tabCarousel, ContactDetailFragment aboutFragment, ContactDetailUpdatesFragment updatesFragment) { TabCarouselScrollManager scrollManager = new TabCarouselScrollManager(tabCarousel, aboutFragment, updatesFragment); scrollManager.bind(); } } Loading
src/com/android/contacts/activities/ContactDetailActivity.java +2 −32 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import com.android.contacts.detail.ContactDetailUpdatesFragment; import com.android.contacts.detail.ContactDetailViewPagerAdapter; import com.android.contacts.detail.ContactLoaderFragment; import com.android.contacts.detail.ContactLoaderFragment.ContactLoaderFragmentListener; import com.android.contacts.detail.TabCarouselScrollManager; import com.android.contacts.interactions.ContactDeletionInteraction; import com.android.contacts.model.AccountWithDataSet; import com.android.contacts.util.PhoneCapabilityTester; Loading Loading @@ -55,8 +56,6 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; import android.widget.CheckBox; import android.widget.Toast; Loading Loading @@ -153,8 +152,7 @@ public class ContactDetailActivity extends ContactsActivity { } mDetailFragment.setListener(mFragmentListener); mDetailFragment.setVerticalScrollListener(mVerticalScrollListener); mUpdatesFragment.setVerticalScrollListener(mVerticalScrollListener); TabCarouselScrollManager.bind(mTabCarousel, mDetailFragment, mUpdatesFragment); mDetailFragment.setData(mLookupUri, mContactData); mUpdatesFragment.setData(mLookupUri, mContactData); Loading Loading @@ -555,34 +553,6 @@ public class ContactDetailActivity extends ContactsActivity { } }; private OnScrollListener mVerticalScrollListener = new OnScrollListener() { @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mTabCarousel == null) { return; } // If the FIRST item is not visible on the screen, then the carousel must be pinned // at the top of the screen. if (firstVisibleItem != 0) { mTabCarousel.setY(-mTabCarousel.getAllowedVerticalScrollLength()); return; } View topView = view.getChildAt(firstVisibleItem); if (topView == null) { return; } int amtToScroll = Math.max((int) view.getChildAt(firstVisibleItem).getY(), - mTabCarousel.getAllowedVerticalScrollLength()); mTabCarousel.setY(amtToScroll); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) {} }; /** * This interface should be implemented by {@link Fragment}s within this * activity so that the activity can determine whether the currently Loading
src/com/android/contacts/detail/ContactDetailLayoutController.java +1 −32 Original line number Diff line number Diff line Loading @@ -29,8 +29,6 @@ import android.support.v4.view.ViewPager.OnPageChangeListener; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; /** * Determines the layout of the contact card. Loading Loading @@ -115,8 +113,6 @@ public class ContactDetailLayoutController { } mDetailFragment.setListener(mContactDetailFragmentListener); mDetailFragment.setVerticalScrollListener(mVerticalScrollListener); mUpdatesFragment.setVerticalScrollListener(mVerticalScrollListener); switch (mLayoutMode) { case VIEW_PAGER_AND_CAROUSEL: { Loading Loading @@ -151,6 +147,7 @@ public class ContactDetailLayoutController { } transaction.commit(); mFragmentManager.executePendingTransactions(); TabCarouselScrollManager.bind(mTabCarousel, mDetailFragment, mUpdatesFragment); break; } case TWO_COLUMN: { Loading Loading @@ -306,32 +303,4 @@ public class ContactDetailLayoutController { mViewPager.setCurrentItem(position); } }; private OnScrollListener mVerticalScrollListener = new OnScrollListener() { @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mTabCarousel == null) { return; } // If the FIRST item is not visible on the screen, then the carousel must be pinned // at the top of the screen. if (firstVisibleItem != 0) { mTabCarousel.setY(-mTabCarousel.getAllowedVerticalScrollLength()); return; } View topView = view.getChildAt(firstVisibleItem); if (topView == null) { return; } int amtToScroll = Math.max((int) view.getChildAt(firstVisibleItem).getY(), -mTabCarousel.getAllowedVerticalScrollLength()); mTabCarousel.setY(amtToScroll); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) {} }; }
src/com/android/contacts/detail/TabCarouselScrollManager.java 0 → 100644 +74 −0 Original line number Diff line number Diff line /* * 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.contacts.detail; import android.view.View; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; /** * Takes care of managing scrolling for the side-by-side views using the tab carousel. */ public class TabCarouselScrollManager { private final ContactDetailTabCarousel mTabCarousel; private final ContactDetailFragment mAboutFragment; private final ContactDetailUpdatesFragment mUpdatesFragment; private final OnScrollListener mVerticalScrollListener = new OnScrollListener() { @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mTabCarousel == null) { return; } // If the FIRST item is not visible on the screen, then the carousel must be pinned // at the top of the screen. if (firstVisibleItem != 0) { mTabCarousel.setY(-mTabCarousel.getAllowedVerticalScrollLength()); return; } View topView = view.getChildAt(firstVisibleItem); if (topView == null) { return; } int amtToScroll = Math.max((int) view.getChildAt(firstVisibleItem).getY(), -mTabCarousel.getAllowedVerticalScrollLength()); mTabCarousel.setY(amtToScroll); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) {} }; private TabCarouselScrollManager(ContactDetailTabCarousel tabCarousel, ContactDetailFragment aboutFragment, ContactDetailUpdatesFragment updatesFragment) { mTabCarousel = tabCarousel; mAboutFragment = aboutFragment; mUpdatesFragment = updatesFragment; } public void bind() { mAboutFragment.setVerticalScrollListener(mVerticalScrollListener); mUpdatesFragment.setVerticalScrollListener(mVerticalScrollListener); } public static void bind(ContactDetailTabCarousel tabCarousel, ContactDetailFragment aboutFragment, ContactDetailUpdatesFragment updatesFragment) { TabCarouselScrollManager scrollManager = new TabCarouselScrollManager(tabCarousel, aboutFragment, updatesFragment); scrollManager.bind(); } }