summaryrefslogtreecommitdiffstats
path: root/mobile/android/base/java/org/mozilla/gecko/home/PanelBackItemView.java
blob: 4772e08abbe9fa61a10e42c3fe1f1c7a223aeb08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.gecko.home;

import org.mozilla.gecko.R;
import org.mozilla.gecko.home.PanelLayout.FilterDetail;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

class PanelBackItemView extends LinearLayout {
    private final TextView title;

    public PanelBackItemView(Context context, String backImageUrl) {
        super(context);

        LayoutInflater.from(context).inflate(R.layout.panel_back_item, this);
        setOrientation(HORIZONTAL);

        title = (TextView) findViewById(R.id.title);

        final ImageView image = (ImageView) findViewById(R.id.image);

        if (TextUtils.isEmpty(backImageUrl)) {
            image.setImageResource(R.drawable.arrow_up);
        } else {
            ImageLoader.with(getContext())
                       .load(backImageUrl)
                       .placeholder(R.drawable.arrow_up)
                       .into(image);
        }
    }

    public void updateFromFilter(FilterDetail filter) {
        final String backText = getResources()
            .getString(R.string.home_move_back_to_filter, filter.title);
        title.setText(backText);
    }
}