OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.download.ui; | 5 package org.chromium.chrome.browser.download.ui; |
6 | 6 |
| 7 import android.annotation.SuppressLint; |
7 import android.content.Context; | 8 import android.content.Context; |
8 import android.content.res.ColorStateList; | 9 import android.content.res.ColorStateList; |
9 import android.text.format.Formatter; | 10 import android.text.format.Formatter; |
10 import android.util.AttributeSet; | 11 import android.util.AttributeSet; |
11 import android.widget.ImageView; | 12 import android.widget.ImageView; |
12 import android.widget.TextView; | 13 import android.widget.TextView; |
13 | 14 |
14 import org.chromium.base.ApiCompatibilityUtils; | 15 import org.chromium.base.ApiCompatibilityUtils; |
15 import org.chromium.chrome.R; | 16 import org.chromium.chrome.R; |
16 import org.chromium.chrome.browser.download.DownloadUtils; | 17 import org.chromium.chrome.browser.download.DownloadUtils; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 super.onAttachedToWindow(); | 76 super.onAttachedToWindow(); |
76 if (mSelectionDelegate != null) { | 77 if (mSelectionDelegate != null) { |
77 setChecked(mSelectionDelegate.isHeaderSelected(mHeader)); | 78 setChecked(mSelectionDelegate.isHeaderSelected(mHeader)); |
78 } | 79 } |
79 } | 80 } |
80 | 81 |
81 /** | 82 /** |
82 * Updates the properties of this view. | 83 * Updates the properties of this view. |
83 * @param header The associated {@link SubsectionHeader}. | 84 * @param header The associated {@link SubsectionHeader}. |
84 */ | 85 */ |
| 86 @SuppressLint("StringFormatMatches") |
85 public void displayHeader(SubsectionHeader header) { | 87 public void displayHeader(SubsectionHeader header) { |
86 this.mHeader = header; | 88 this.mHeader = header; |
| 89 // TODO(crbug.com/635567): Fix lint properly. |
87 mPageCountHeader.setText(getResources().getString( | 90 mPageCountHeader.setText(getResources().getString( |
88 R.string.download_manager_offline_header_title, header.getItemCo
unt())); | 91 R.string.download_manager_offline_header_title, header.getItemCo
unt())); |
89 mFileSizeView.setText(Formatter.formatFileSize(getContext(), header.getT
otalFileSize())); | 92 mFileSizeView.setText(Formatter.formatFileSize(getContext(), header.getT
otalFileSize())); |
90 updateExpandIcon(header.isExpanded()); | 93 updateExpandIcon(header.isExpanded()); |
91 setChecked(mSelectionDelegate.isHeaderSelected(header)); | 94 setChecked(mSelectionDelegate.isHeaderSelected(header)); |
92 setBackgroundResourceForGroupPosition(mHeader.isFirstInGroup(), mHeader.
isLastInGroup()); | 95 setBackgroundResourceForGroupPosition(mHeader.isFirstInGroup(), mHeader.
isLastInGroup()); |
93 } | 96 } |
94 | 97 |
95 private void updateExpandIcon(boolean expanded) { | 98 private void updateExpandIcon(boolean expanded) { |
96 mExpandImage.setImageResource(expanded ? R.drawable.ic_collapsed : R.dra
wable.ic_expanded); | 99 mExpandImage.setImageResource(expanded ? R.drawable.ic_collapsed : R.dra
wable.ic_expanded); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 mSelectionDelegate = delegate; | 148 mSelectionDelegate = delegate; |
146 mSelectionDelegate.addObserver(this); | 149 mSelectionDelegate.addObserver(this); |
147 } | 150 } |
148 | 151 |
149 @Override | 152 @Override |
150 public void onSubsectionHeaderSelectionStateChanged(Set<SubsectionHeader> se
lectedHeaders) { | 153 public void onSubsectionHeaderSelectionStateChanged(Set<SubsectionHeader> se
lectedHeaders) { |
151 boolean isChecked = selectedHeaders.contains(mHeader); | 154 boolean isChecked = selectedHeaders.contains(mHeader); |
152 setChecked(isChecked); | 155 setChecked(isChecked); |
153 } | 156 } |
154 } | 157 } |
OLD | NEW |