Chromium Code Reviews| 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 to view or hide the suggested offline pages. */ | |
|
Theresa
2017/02/03 19:53:06
nit: ... the option to view or...
shaktisahu
2017/02/04 18:57:43
Done.
| |
| 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 if (mGroup.isSuggestedOfflinePagesSectionExpanded()) { | |
| 32 mAdapter.collapseSuggestedPagesHeader(mGroup); | |
| 33 mImageView.setImageResource(R.drawable.ic_expanded); | |
| 34 } else { | |
| 35 mAdapter.expandSuggestedPagesHeader(mGroup); | |
| 36 mImageView.setImageResource(R.drawable.ic_collapsed); | |
| 37 } | |
| 38 } | |
| 39 }); | |
| 40 } | |
| 41 | |
| 42 @Override | |
| 43 protected void onFinishInflate() { | |
| 44 super.onFinishInflate(); | |
| 45 mPageCountHeader = (TextView) findViewById(R.id.page_count_text); | |
| 46 mFileSizeView = (TextView) findViewById(R.id.filesize_view); | |
| 47 mImageView = (ImageView) findViewById(R.id.expand_icon); | |
| 48 } | |
| 49 | |
| 50 public void bindGroupAndAdapter(DownloadItemGroup group, DownloadHistoryAdap ter adapter) { | |
| 51 mGroup = group; | |
| 52 mAdapter = adapter; | |
| 53 updateTitleText(group.getSuggestedOfflinePageCount()); | |
| 54 mImageView.setImageResource(mGroup.isSuggestedOfflinePagesSectionExpande d() | |
| 55 ? R.drawable.ic_collapsed | |
| 56 : R.drawable.ic_expanded); | |
| 57 } | |
| 58 | |
| 59 public void updateTitleText(int pageCount) { | |
| 60 mPageCountHeader.setText(getResources().getString( | |
| 61 R.string.download_manager_offline_header_title, pageCount)); | |
| 62 mFileSizeView.setText( | |
| 63 Formatter.formatFileSize(getContext(), mGroup.getSuggestedOfflin ePagesFileSize())); | |
| 64 } | |
| 65 } | |
| OLD | NEW |