OSDN Git Service

Eleven: Cleanup all the whitespace
[android-x86/packages-apps-Eleven.git] / src / com / cyanogenmod / eleven / widgets / SquareImageView.java
1 /*
2  * Copyright (C) 2012 Andrew Neal
3  * Copyright (C) 2014 The CyanogenMod Project
4  * Licensed under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with the
6  * License. You may obtain a copy of the License at
7  * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
8  * or agreed to in writing, software distributed under the License is
9  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10  * KIND, either express or implied. See the License for the specific language
11  * governing permissions and limitations under the License.
12  */
13
14 package com.cyanogenmod.eleven.widgets;
15
16 import android.content.Context;
17 import android.util.AttributeSet;
18 import android.widget.ImageView;
19
20 /**
21  * A custom {@link ImageView} that is sized to be a perfect square, otherwise
22  * functions like a typical {@link ImageView}.
23  *
24  * @author Andrew Neal (andrewdneal@gmail.com)
25  */
26 public class SquareImageView extends LayoutSuppressingImageView {
27
28     /**
29      * @param context The {@link Context} to use
30      * @param attrs The attributes of the XML tag that is inflating the view.
31      */
32     public SquareImageView(final Context context, final AttributeSet attrs) {
33         super(context, attrs);
34
35     }
36
37     /**
38      * {@inheritDoc}
39      */
40     @Override
41     public void onMeasure(final int widthSpec, final int heightSpec) {
42         super.onMeasure(widthSpec, heightSpec);
43         final int mSize = Math.min(getMeasuredWidth(), getMeasuredHeight());
44         setMeasuredDimension(mSize, mSize);
45     }
46
47 }