From 3c90185a806ca7d2227b85d6f86a4e63b9da2373 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Thu, 12 Dec 2013 12:44:48 +0100 Subject: [PATCH] Backed out changeset f279d53c2d4d (bug 942231) for Android Bustage on a CLOSED TREE --- mobile/android/base/home/HomeAdapter.java | 52 +++++++++++------------ mobile/android/base/home/HomePager.java | 22 +++++----- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/mobile/android/base/home/HomeAdapter.java b/mobile/android/base/home/HomeAdapter.java index 2d424face292..caaab89a79b9 100644 --- a/mobile/android/base/home/HomeAdapter.java +++ b/mobile/android/base/home/HomeAdapter.java @@ -21,22 +21,22 @@ import java.util.EnumMap; class HomeAdapter extends FragmentStatePagerAdapter { private final Context mContext; - private final ArrayList mPageInfos; + private final ArrayList mTabs; private final EnumMap mPages; - private OnAddPageListener mAddPageListener; + private OnAddTabListener mAddTabListener; - interface OnAddPageListener { - public void onAddPage(String title); + interface OnAddTabListener { + public void onAddTab(String title); } - final class PageInfo { + final class TabInfo { private final Page page; private final Class clss; private final Bundle args; private final String title; - PageInfo(Page page, Class clss, Bundle args, String title) { + TabInfo(Page page, Class clss, Bundle args, String title) { this.page = page; this.clss = clss; this.args = args; @@ -49,31 +49,31 @@ class HomeAdapter extends FragmentStatePagerAdapter { mContext = context; - mPageInfos = new ArrayList(); + mTabs = new ArrayList(); mPages = new EnumMap(Page.class); } @Override public int getCount() { - return mPageInfos.size(); + return mTabs.size(); } @Override public Fragment getItem(int position) { - PageInfo info = mPageInfos.get(position); + TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.args); } @Override public CharSequence getPageTitle(int position) { - PageInfo info = mPageInfos.get(position); + TabInfo info = mTabs.get(position); return info.title.toUpperCase(); } @Override public Object instantiateItem(ViewGroup container, int position) { Fragment fragment = (Fragment) super.instantiateItem(container, position); - mPages.put(mPageInfos.get(position).page, fragment); + mPages.put(mTabs.get(position).page, fragment); return fragment; } @@ -81,36 +81,36 @@ class HomeAdapter extends FragmentStatePagerAdapter { @Override public void destroyItem(ViewGroup container, int position, Object object) { super.destroyItem(container, position, object); - mPages.remove(mPageInfos.get(position).page); + mPages.remove(mTabs.get(position).page); } - public void setOnAddPageListener(OnAddPageListener listener) { - mAddPageListener = listener; + public void setOnAddTabListener(OnAddTabListener listener) { + mAddTabListener = listener; } - public void addPage(Page page, Class clss, Bundle args, String title) { - addPage(-1, page, clss, args, title); + public void addTab(Page page, Class clss, Bundle args, String title) { + addTab(-1, page, clss, args, title); } - public void addPage(int index, Page page, Class clss, Bundle args, String title) { - PageInfo info = new PageInfo(page, clss, args, title); + public void addTab(int index, Page page, Class clss, Bundle args, String title) { + TabInfo info = new TabInfo(page, clss, args, title); if (index >= 0) { - mPageInfos.add(index, info); + mTabs.add(index, info); } else { - mPageInfos.add(info); + mTabs.add(info); } notifyDataSetChanged(); - if (mAddPageListener != null) { - mAddPageListener.onAddPage(title); + if (mAddTabListener != null) { + mAddTabListener.onAddTab(title); } } public int getItemPosition(Page page) { - for (int i = 0; i < mPageInfos.size(); i++) { - PageInfo info = mPageInfos.get(i); + for (int i = 0; i < mTabs.size(); i++) { + TabInfo info = mTabs.get(i); if (info.page == page) { return i; } @@ -120,13 +120,13 @@ class HomeAdapter extends FragmentStatePagerAdapter { } public Page getPageAtPosition(int position) { - PageInfo info = mPageInfos.get(position); + TabInfo info = mTabs.get(position); return info.page; } public void setCanLoadHint(boolean canLoadHint) { // Update fragment arguments for future instances - for (PageInfo info : mPageInfos) { + for (TabInfo info : mTabs) { info.args.putBoolean(HomePager.CAN_LOAD_ARG, canLoadHint); } diff --git a/mobile/android/base/home/HomePager.java b/mobile/android/base/home/HomePager.java index 66253b1be0f6..f1d42dd4aa69 100644 --- a/mobile/android/base/home/HomePager.java +++ b/mobile/android/base/home/HomePager.java @@ -8,7 +8,7 @@ package org.mozilla.gecko.home; import org.mozilla.gecko.R; import org.mozilla.gecko.animation.PropertyAnimator; import org.mozilla.gecko.animation.ViewHelper; -import org.mozilla.gecko.home.HomeAdapter.OnAddPageListener; +import org.mozilla.gecko.home.HomeAdapter.OnAddTabListener; import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.util.HardwareUtils; @@ -32,7 +32,7 @@ public class HomePager extends ViewPager { private volatile boolean mLoaded; private Decor mDecor; - private final OnAddPageListener mAddPageListener; + private final OnAddTabListener mAddTabListener; // List of pages in order. @RobocopTarget @@ -90,9 +90,9 @@ public class HomePager extends ViewPager { super(context, attrs); mContext = context; - mAddPageListener = new OnAddPageListener() { + mAddTabListener = new OnAddTabListener() { @Override - public void onAddPage(String title) { + public void onAddTab(String title) { if (mDecor != null) { mDecor.onAddPagerView(title); } @@ -163,26 +163,26 @@ public class HomePager extends ViewPager { } final HomeAdapter adapter = new HomeAdapter(mContext, fm); - adapter.setOnAddPageListener(mAddPageListener); + adapter.setOnAddTabListener(mAddTabListener); // Only animate on post-HC devices, when a non-null animator is given final boolean shouldAnimate = (animator != null && Build.VERSION.SDK_INT >= 11); - adapter.addPage(Page.TOP_SITES, TopSitesPage.class, new Bundle(), + adapter.addTab(Page.TOP_SITES, TopSitesPage.class, new Bundle(), getContext().getString(R.string.home_top_sites_title)); - adapter.addPage(Page.BOOKMARKS, BookmarksPage.class, new Bundle(), + adapter.addTab(Page.BOOKMARKS, BookmarksPage.class, new Bundle(), getContext().getString(R.string.bookmarks_title)); // We disable reader mode support on low memory devices. Hence the // reading list page should not show up on such devices. if (!HardwareUtils.isLowMemoryPlatform()) { - adapter.addPage(Page.READING_LIST, ReadingListPage.class, new Bundle(), + adapter.addTab(Page.READING_LIST, ReadingListPage.class, new Bundle(), getContext().getString(R.string.reading_list_title)); } - // On phones, the history page is the first one. On tablets, the - // history page is the last. - adapter.addPage(HardwareUtils.isTablet() ? -1 : 0, + // On phones, the history tab is the first tab. On tablets, the + // history tab is the last tab. + adapter.addTab(HardwareUtils.isTablet() ? -1 : 0, Page.HISTORY, HistoryPage.class, new Bundle(), getContext().getString(R.string.home_history_title));