| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.ntp; | 5 package org.chromium.chrome.browser.ntp; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.res.Resources; | 8 import android.content.res.Resources; |
| 9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
| 10 import android.graphics.drawable.BitmapDrawable; | 10 import android.graphics.drawable.BitmapDrawable; |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 public int getGroupType(int groupPosition) { | 731 public int getGroupType(int groupPosition) { |
| 732 return getGroup(groupPosition).getGroupType().ordinal(); | 732 return getGroup(groupPosition).getGroupType().ordinal(); |
| 733 } | 733 } |
| 734 | 734 |
| 735 @Override | 735 @Override |
| 736 public int getGroupTypeCount() { | 736 public int getGroupTypeCount() { |
| 737 return GroupType.values().length; | 737 return GroupType.values().length; |
| 738 } | 738 } |
| 739 | 739 |
| 740 private void addGroup(Group group) { | 740 private void addGroup(Group group) { |
| 741 if (!DeviceFormFactor.isTablet(mActivity)) { | 741 if (!DeviceFormFactor.isTablet()) { |
| 742 mGroups.add(group); | 742 mGroups.add(group); |
| 743 } else { | 743 } else { |
| 744 if (mGroups.size() == 0) { | 744 if (mGroups.size() == 0) { |
| 745 mGroups.add(mInvisibleSeparatorGroup); | 745 mGroups.add(mInvisibleSeparatorGroup); |
| 746 } | 746 } |
| 747 mGroups.add(group); | 747 mGroups.add(group); |
| 748 mGroups.add(mInvisibleSeparatorGroup); | 748 mGroups.add(mInvisibleSeparatorGroup); |
| 749 } | 749 } |
| 750 } | 750 } |
| 751 | 751 |
| 752 @Override | 752 @Override |
| 753 public void notifyDataSetChanged() { | 753 public void notifyDataSetChanged() { |
| 754 mGroups.clear(); | 754 mGroups.clear(); |
| 755 addGroup(mRecentlyClosedTabsGroup); | 755 addGroup(mRecentlyClosedTabsGroup); |
| 756 for (ForeignSession session : mRecentTabsManager.getForeignSessions()) { | 756 for (ForeignSession session : mRecentTabsManager.getForeignSessions()) { |
| 757 if (!mHasForeignDataRecorded) { | 757 if (!mHasForeignDataRecorded) { |
| 758 RecordHistogram.recordEnumeratedHistogram("HistoryPage.OtherDevi
cesMenu", | 758 RecordHistogram.recordEnumeratedHistogram("HistoryPage.OtherDevi
cesMenu", |
| 759 OtherSessionsActions.HAS_FOREIGN_DATA, OtherSessionsActi
ons.LIMIT); | 759 OtherSessionsActions.HAS_FOREIGN_DATA, OtherSessionsActi
ons.LIMIT); |
| 760 mHasForeignDataRecorded = true; | 760 mHasForeignDataRecorded = true; |
| 761 } | 761 } |
| 762 addGroup(new ForeignSessionGroup(session)); | 762 addGroup(new ForeignSessionGroup(session)); |
| 763 } | 763 } |
| 764 if (mRecentTabsManager.shouldDisplaySyncPromo()) { | 764 if (mRecentTabsManager.shouldDisplaySyncPromo()) { |
| 765 addGroup(new SyncPromoGroup()); | 765 addGroup(new SyncPromoGroup()); |
| 766 } | 766 } |
| 767 | 767 |
| 768 // Add separator line after the recently closed tabs group. | 768 // Add separator line after the recently closed tabs group. |
| 769 int recentlyClosedIndex = mGroups.indexOf(mRecentlyClosedTabsGroup); | 769 int recentlyClosedIndex = mGroups.indexOf(mRecentlyClosedTabsGroup); |
| 770 if (DeviceFormFactor.isTablet(mActivity)) { | 770 if (DeviceFormFactor.isTablet()) { |
| 771 if (recentlyClosedIndex != mGroups.size() - 2) { | 771 if (recentlyClosedIndex != mGroups.size() - 2) { |
| 772 mGroups.set(recentlyClosedIndex + 1, mVisibleSeparatorGroup); | 772 mGroups.set(recentlyClosedIndex + 1, mVisibleSeparatorGroup); |
| 773 } | 773 } |
| 774 } else if (recentlyClosedIndex != mGroups.size() - 1) { | 774 } else if (recentlyClosedIndex != mGroups.size() - 1) { |
| 775 mGroups.add(recentlyClosedIndex + 1, mVisibleSeparatorGroup); | 775 mGroups.add(recentlyClosedIndex + 1, mVisibleSeparatorGroup); |
| 776 } | 776 } |
| 777 | 777 |
| 778 super.notifyDataSetChanged(); | 778 super.notifyDataSetChanged(); |
| 779 } | 779 } |
| 780 | 780 |
| 781 @Override | 781 @Override |
| 782 public int getChildType(int groupPosition, int childPosition) { | 782 public int getChildType(int groupPosition, int childPosition) { |
| 783 return mGroups.get(groupPosition).getChildType().ordinal(); | 783 return mGroups.get(groupPosition).getChildType().ordinal(); |
| 784 } | 784 } |
| 785 | 785 |
| 786 @Override | 786 @Override |
| 787 public int getChildTypeCount() { | 787 public int getChildTypeCount() { |
| 788 return ChildType.values().length; | 788 return ChildType.values().length; |
| 789 } | 789 } |
| 790 } | 790 } |
| OLD | NEW |