blob: 09254bf767035f161a835c3a11dacfd679e661c0 (
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
49
50
51
52
|
/* -*- 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.tabs;
import org.mozilla.gecko.R;
import org.mozilla.gecko.ThumbnailHelper;
import org.mozilla.gecko.widget.CropImageView;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
/**
* A width constrained ImageView to show thumbnails of open tabs in the tabs panel.
*/
public class TabsPanelThumbnailView extends CropImageView {
public static final String LOGTAG = "Gecko" + TabsPanelThumbnailView.class.getSimpleName();
public TabsPanelThumbnailView(final Context context) {
this(context, null);
}
public TabsPanelThumbnailView(final Context context, final AttributeSet attrs) {
this(context, attrs, 0);
}
public TabsPanelThumbnailView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected float getAspectRatio() {
return ThumbnailHelper.TABS_PANEL_THUMBNAIL_ASPECT_RATIO;
}
@Override
public void setImageDrawable(Drawable drawable) {
boolean resize = true;
if (drawable == null) {
drawable = getResources().getDrawable(R.drawable.tab_panel_tab_background);
resize = false;
setScaleType(ScaleType.FIT_XY);
}
super.setImageDrawable(drawable, resize);
}
}
|