|
1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 package org.mozilla.gecko.home; |
|
7 |
|
8 import org.mozilla.gecko.R; |
|
9 import org.mozilla.gecko.home.PanelLayout.FilterDetail; |
|
10 |
|
11 import android.content.Context; |
|
12 import android.text.TextUtils; |
|
13 import android.view.LayoutInflater; |
|
14 import android.widget.ImageView; |
|
15 import android.widget.LinearLayout; |
|
16 import android.widget.TextView; |
|
17 |
|
18 import com.squareup.picasso.Picasso; |
|
19 |
|
20 class PanelBackItemView extends LinearLayout { |
|
21 private final TextView title; |
|
22 |
|
23 public PanelBackItemView(Context context, String backImageUrl) { |
|
24 super(context); |
|
25 |
|
26 LayoutInflater.from(context).inflate(R.layout.panel_back_item, this); |
|
27 setOrientation(HORIZONTAL); |
|
28 |
|
29 title = (TextView) findViewById(R.id.title); |
|
30 |
|
31 final ImageView image = (ImageView) findViewById(R.id.image); |
|
32 |
|
33 if (TextUtils.isEmpty(backImageUrl)) { |
|
34 image.setImageResource(R.drawable.folder_up); |
|
35 } else { |
|
36 Picasso.with(getContext()) |
|
37 .load(backImageUrl) |
|
38 .placeholder(R.drawable.folder_up) |
|
39 .into(image); |
|
40 } |
|
41 } |
|
42 |
|
43 public void updateFromFilter(FilterDetail filter) { |
|
44 final String backText = getResources() |
|
45 .getString(R.string.home_move_up_to_filter, filter.title); |
|
46 title.setText(backText); |
|
47 } |
|
48 } |