summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJae Seo <jaeseo@google.com>2014-06-03 23:58:49 -0700
committerDongwon Kang <dwkang@google.com>2014-06-08 21:42:39 +0900
commit1bfce9fb9bffe8bd620fd1683572ae620f91772f (patch)
tree9b2931df0f11a53929dbe9b3bc31e6d77e03370b /media
parentacb119f0a257e4e542a4450f60405b21a53f3545 (diff)
downloadframeworks_base-1bfce9fb9bffe8bd620fd1683572ae620f91772f.zip
frameworks_base-1bfce9fb9bffe8bd620fd1683572ae620f91772f.tar.gz
frameworks_base-1bfce9fb9bffe8bd620fd1683572ae620f91772f.tar.bz2
TIF: Address the feedback from the API review - 3/3
- Change TvView to be a generic ViewGroup with a single SurfaceView child Bug: 15345342 Change-Id: I86ed94b7020aabb6e093e391ab9477c1f801919a
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/tv/TvView.java36
1 files changed, 30 insertions, 6 deletions
diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java
index c2459a6..4495195 100644
--- a/media/java/android/media/tv/TvView.java
+++ b/media/java/android/media/tv/TvView.java
@@ -33,12 +33,13 @@ import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import android.view.ViewGroup;
import android.view.ViewRootImpl;
/**
* View playing TV
*/
-public class TvView extends SurfaceView {
+public class TvView extends ViewGroup {
private static final String TAG = "TvView";
// STOPSHIP: Turn debugging off.
private static final boolean DEBUG = true;
@@ -57,6 +58,7 @@ public class TvView extends SurfaceView {
private final Handler mHandler = new Handler();
private TvInputManager.Session mSession;
+ private final SurfaceView mSurfaceView;
private Surface mSurface;
private boolean mOverlayViewCreated;
private Rect mOverlayViewFrame;
@@ -122,7 +124,14 @@ public class TvView extends SurfaceView {
public TvView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- getHolder().addCallback(mSurfaceHolderCallback);
+ mSurfaceView = new SurfaceView(context, attrs, defStyleAttr) {
+ @Override
+ protected void updateWindow(boolean force, boolean redrawNeeded) {
+ super.updateWindow(force, redrawNeeded);
+ relayoutSessionOverlayView();
+ }};
+ mSurfaceView.getHolder().addCallback(mSurfaceHolderCallback);
+ addView(mSurfaceView);
mTvInputManager = (TvInputManager) getContext().getSystemService(Context.TV_INPUT_SERVICE);
}
@@ -305,11 +314,26 @@ public class TvView extends SurfaceView {
super.onDetachedFromWindow();
}
- /** @hide */
@Override
- protected void updateWindow(boolean force, boolean redrawNeeded) {
- super.updateWindow(force, redrawNeeded);
- relayoutSessionOverlayView();
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ mSurfaceView.layout(0, 0, right - left, bottom - top);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ mSurfaceView.measure(widthMeasureSpec, heightMeasureSpec);
+ int width = mSurfaceView.getMeasuredWidth();
+ int height = mSurfaceView.getMeasuredHeight();
+ int childState = mSurfaceView.getMeasuredState();
+ setMeasuredDimension(resolveSizeAndState(width, widthMeasureSpec, childState),
+ resolveSizeAndState(height, heightMeasureSpec,
+ childState << MEASURED_HEIGHT_STATE_SHIFT));
+ }
+
+ @Override
+ public void setVisibility(int visibility) {
+ super.setVisibility(visibility);
+ mSurfaceView.setVisibility(visibility);
}
private void release() {