OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 to view or hide the suggested offline pages. */ | |
18 public class OfflineGroupHeaderView extends FrameLayout { | |
19 private TextView mPageCountHeader; | |
20 private TextView mDescription; | |
21 private TextView mFileSizeView; | |
22 private ImageView mImageView; | |
23 | |
24 private DownloadItemGroup mGroup; | |
25 private DownloadHistoryAdapter mAdapter; | |
26 | |
27 public OfflineGroupHeaderView(Context context, AttributeSet attrs) { | |
28 super(context, attrs); | |
29 setOnClickListener(new View.OnClickListener() { | |
30 @Override | |
31 public void onClick(View v) { | |
32 if (!mGroup.offlinePageExpanded()) { | |
gone
2017/02/02 23:59:48
Positive condition on top.
shaktisahu
2017/02/04 18:57:43
Done.
| |
33 mAdapter.expandOfflineHeader(mGroup); | |
34 mImageView.setImageResource(R.drawable.ic_collapsed); | |
35 } else { | |
36 mAdapter.collapseOfflineHeader(mGroup); | |
37 mImageView.setImageResource(R.drawable.ic_expanded); | |
38 } | |
39 } | |
40 }); | |
41 } | |
42 | |
43 @Override | |
44 protected void onFinishInflate() { | |
45 super.onFinishInflate(); | |
46 mPageCountHeader = (TextView) findViewById(R.id.page_count_text); | |
47 mDescription = (TextView) findViewById(R.id.description); | |
48 mFileSizeView = (TextView) findViewById(R.id.filesize_view); | |
49 mImageView = (ImageView) findViewById(R.id.expand_icon); | |
50 mDescription.setText(R.string.download_manager_offline_header_descriptio n); | |
gone
2017/02/02 23:59:48
If this text never changes, put it in the XML itse
shaktisahu
2017/02/04 18:57:43
Done.
| |
51 } | |
52 | |
53 public void bindGroupAndAdapter(DownloadItemGroup group, DownloadHistoryAdap ter adapter) { | |
54 mGroup = group; | |
55 mAdapter = adapter; | |
gone
2017/02/02 23:59:48
This should call updateTitleText directly.
shaktisahu
2017/02/04 18:57:43
Done.
| |
56 } | |
57 | |
58 public void updateTitleText(int pageCount) { | |
59 mPageCountHeader.setText(getResources().getString( | |
60 R.string.download_manager_offline_header_title, pageCount)); | |
61 mFileSizeView.setText( | |
62 Formatter.formatFileSize(getContext(), mGroup.getOfflinePagesFil eSize())); | |
63 } | |
64 } | |
OLD | NEW |