summaryrefslogtreecommitdiffstats
path: root/mobile/android/base/java/org/mozilla/gecko/home/PanelHeaderView.java
blob: 50c4dbc075cbe1c49a41cc1e80fbb94568f0444d (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
package org.mozilla.gecko.home;

import android.annotation.SuppressLint;
import android.content.Context;
import android.widget.ImageView;

@SuppressLint("ViewConstructor") // View is only created from code
public class PanelHeaderView extends ImageView {
    public PanelHeaderView(Context context, HomeConfig.HeaderConfig config) {
        super(context);

        setAdjustViewBounds(true);

        ImageLoader.with(context)
            .load(config.getImageUrl())
            .into(this);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);

        // Always span the whole width and adjust height as needed.
        widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);

        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}