OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.chrome.browser.download.ui; | |
6 | |
7 import android.content.Context; | |
8 import android.text.format.Formatter; | |
9 import android.util.AttributeSet; | |
10 import android.view.View; | |
11 import android.widget.FrameLayout; | |
12 import android.widget.ImageView; | |
13 import android.widget.TextView; | |
14 | |
15 import org.chromium.chrome.R; | |
16 | |
17 /** A header that presents users the option to view or hide the suggested offlin e pages. */ | |
18 public class OfflineGroupHeaderView extends FrameLayout { | |
19 private TextView mPageCountHeader; | |
20 private TextView mFileSizeView; | |
21 private ImageView mImageView; | |
22 | |
23 private DownloadItemGroup mGroup; | |
24 private DownloadHistoryAdapter mAdapter; | |
25 | |
26 public OfflineGroupHeaderView(Context context, AttributeSet attrs) { | |
27 super(context, attrs); | |
28 setOnClickListener(new View.OnClickListener() { | |
29 @Override | |
30 public void onClick(View v) { | |
31 boolean currentState = mGroup.isSuggestedOfflinePagesSectionExpa nded(); | |
32 mAdapter.setSuggestedPagesHeaderState(mGroup, !currentState); | |
33 mImageView.setImageResource( | |
34 currentState ? R.drawable.ic_expanded : R.drawable.ic_co llapsed); | |
gone
2017/02/10 22:49:52
Did you missed Theresa's comment about content des
shaktisahu
2017/02/11 00:39:06
Done. Thanks.
| |
35 } | |
36 }); | |
37 } | |
38 | |
39 @Override | |
40 protected void onFinishInflate() { | |
41 super.onFinishInflate(); | |
42 mPageCountHeader = (TextView) findViewById(R.id.page_count_text); | |
43 mFileSizeView = (TextView) findViewById(R.id.filesize_view); | |
44 mImageView = (ImageView) findViewById(R.id.expand_icon); | |
45 } | |
46 | |
47 /** | |
48 * @param adapter The adapter associated with this header. | |
49 */ | |
50 public void setAdapter(DownloadHistoryAdapter adapter) { | |
51 mAdapter = adapter; | |
52 } | |
53 | |
54 /** | |
55 * Associates this header with a group. | |
56 * @param group The group currently associated with this header. | |
57 */ | |
58 public void setGroup(DownloadItemGroup group) { | |
59 mGroup = group; | |
60 updateTitleText(group.getNumSuggestedOfflinePages()); | |
61 mImageView.setImageResource(mGroup.isSuggestedOfflinePagesSectionExpande d() | |
62 ? R.drawable.ic_collapsed | |
63 : R.drawable.ic_expanded); | |
64 } | |
65 | |
66 private void updateTitleText(int pageCount) { | |
67 mPageCountHeader.setText(getResources().getString( | |
68 R.string.download_manager_offline_header_title, pageCount)); | |
69 mFileSizeView.setText( | |
70 Formatter.formatFileSize(getContext(), mGroup.getSuggestedOfflin ePagesFileSize())); | |
71 } | |
72 } | |
OLD | NEW |