Made checkStyle happy
This commit is contained in:
parent
bff238774e
commit
d8f7db4715
26 changed files with 1448 additions and 664 deletions
|
|
@ -5,7 +5,7 @@ import android.util.AttributeSet;
|
|||
import android.view.SurfaceView;
|
||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||
|
||||
import static com.google.android.exoplayer2.ui.AspectRatioFrameLayout.*;
|
||||
import static com.google.android.exoplayer2.ui.AspectRatioFrameLayout.RESIZE_MODE_ZOOM;
|
||||
|
||||
public class ExpandableSurfaceView extends SurfaceView {
|
||||
private int resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT;
|
||||
|
|
@ -15,21 +15,27 @@ public class ExpandableSurfaceView extends SurfaceView {
|
|||
private float scaleX = 1.0f;
|
||||
private float scaleY = 1.0f;
|
||||
|
||||
public ExpandableSurfaceView(Context context, AttributeSet attrs) {
|
||||
public ExpandableSurfaceView(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
if (videoAspectRatio == 0.0f) return;
|
||||
if (videoAspectRatio == 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
final boolean verticalVideo = videoAspectRatio < 1;
|
||||
// Use maxHeight only on non-fit resize mode and in vertical videos
|
||||
int height = maxHeight != 0 && resizeMode != AspectRatioFrameLayout.RESIZE_MODE_FIT && verticalVideo ? maxHeight : baseHeight;
|
||||
int height = maxHeight != 0
|
||||
&& resizeMode != AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
&& verticalVideo ? maxHeight : baseHeight;
|
||||
|
||||
if (height == 0) return;
|
||||
if (height == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final float viewAspectRatio = width / ((float) height);
|
||||
final float aspectDeformation = videoAspectRatio / viewAspectRatio - 1;
|
||||
|
|
@ -61,27 +67,32 @@ public class ExpandableSurfaceView extends SurfaceView {
|
|||
}
|
||||
|
||||
/**
|
||||
* Scale view only in {@link #onLayout} to make transition for ZOOM mode as smooth as possible
|
||||
* Scale view only in {@link #onLayout} to make transition for ZOOM mode as smooth as possible.
|
||||
*/
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
protected void onLayout(final boolean changed,
|
||||
final int left, final int top, final int right, final int bottom) {
|
||||
setScaleX(scaleX);
|
||||
setScaleY(scaleY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param base The height that will be used in every resize mode as a minimum height
|
||||
* @param max The max height for vertical videos in non-FIT resize modes
|
||||
* @param max The max height for vertical videos in non-FIT resize modes
|
||||
*/
|
||||
public void setHeights(final int base, final int max) {
|
||||
if (baseHeight == base && maxHeight == max) return;
|
||||
if (baseHeight == base && maxHeight == max) {
|
||||
return;
|
||||
}
|
||||
baseHeight = base;
|
||||
maxHeight = max;
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void setResizeMode(@AspectRatioFrameLayout.ResizeMode final int newResizeMode) {
|
||||
if (resizeMode == newResizeMode) return;
|
||||
if (resizeMode == newResizeMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
resizeMode = newResizeMode;
|
||||
requestLayout();
|
||||
|
|
@ -93,9 +104,11 @@ public class ExpandableSurfaceView extends SurfaceView {
|
|||
}
|
||||
|
||||
public void setAspectRatio(final float aspectRatio) {
|
||||
if (videoAspectRatio == aspectRatio) return;
|
||||
if (videoAspectRatio == aspectRatio) {
|
||||
return;
|
||||
}
|
||||
|
||||
videoAspectRatio = aspectRatio;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue