michael@0: /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko.home; michael@0: michael@0: import org.mozilla.gecko.R; michael@0: import org.mozilla.gecko.home.PanelLayout.FilterDetail; michael@0: michael@0: import android.content.Context; michael@0: import android.text.TextUtils; michael@0: import android.view.LayoutInflater; michael@0: import android.widget.ImageView; michael@0: import android.widget.LinearLayout; michael@0: import android.widget.TextView; michael@0: michael@0: import com.squareup.picasso.Picasso; michael@0: michael@0: class PanelBackItemView extends LinearLayout { michael@0: private final TextView title; michael@0: michael@0: public PanelBackItemView(Context context, String backImageUrl) { michael@0: super(context); michael@0: michael@0: LayoutInflater.from(context).inflate(R.layout.panel_back_item, this); michael@0: setOrientation(HORIZONTAL); michael@0: michael@0: title = (TextView) findViewById(R.id.title); michael@0: michael@0: final ImageView image = (ImageView) findViewById(R.id.image); michael@0: michael@0: if (TextUtils.isEmpty(backImageUrl)) { michael@0: image.setImageResource(R.drawable.folder_up); michael@0: } else { michael@0: Picasso.with(getContext()) michael@0: .load(backImageUrl) michael@0: .placeholder(R.drawable.folder_up) michael@0: .into(image); michael@0: } michael@0: } michael@0: michael@0: public void updateFromFilter(FilterDetail filter) { michael@0: final String backText = getResources() michael@0: .getString(R.string.home_move_up_to_filter, filter.title); michael@0: title.setText(backText); michael@0: } michael@0: }