当前位置: 首页>>代码示例>>Java>>正文


Java FrameLayout.getFocusedChild方法代码示例

本文整理汇总了Java中android.widget.FrameLayout.getFocusedChild方法的典型用法代码示例。如果您正苦于以下问题:Java FrameLayout.getFocusedChild方法的具体用法?Java FrameLayout.getFocusedChild怎么用?Java FrameLayout.getFocusedChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.FrameLayout的用法示例。


在下文中一共展示了FrameLayout.getFocusedChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onShowCustomView

import android.widget.FrameLayout; //导入方法依赖的package包/类
@Override
public void onShowCustomView(View view, CustomViewCallback callback)
{
    if (view instanceof FrameLayout)
    {
        // A video wants to be shown
        FrameLayout frameLayout = (FrameLayout) view;
        View focusedChild = frameLayout.getFocusedChild();

        // Save video related variables
        this.isVideoFullscreen = true;
        this.videoViewContainer = frameLayout;
        this.videoViewCallback = callback;

        // Hide the non-video view, add the video view, and show it
        activityNonVideoView.setVisibility(View.INVISIBLE);
        activityVideoView.addView(videoViewContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        activityVideoView.setVisibility(View.VISIBLE);

        if (focusedChild instanceof android.widget.VideoView)
        {
            // android.widget.VideoView (typically API level <11)
            android.widget.VideoView videoView = (android.widget.VideoView) focusedChild;

            // Handle all the required events
            videoView.setOnPreparedListener(this);
            videoView.setOnCompletionListener(this);
            videoView.setOnErrorListener(this);
        }
        else
        {
            // Other classes, including:
            // - android.webkit.HTML5VideoFullScreen$VideoSurfaceView, which inherits from android.view.SurfaceView (typically API level 11-18)
            // - android.webkit.HTML5VideoFullScreen$VideoTextureView, which inherits from android.view.TextureView (typically API level 11-18)
            // - com.android.org.chromium.content.browser.ContentVideoView$VideoSurfaceView, which inherits from android.view.SurfaceView (typically API level 19+)

            // Handle HTML5 video ended event only if the class is a SurfaceView
            // Test case: TextureView of Sony Xperia T API level 16 doesn't work fullscreen when loading the javascript below
            if (webView != null && webView.getSettings().getJavaScriptEnabled() && focusedChild instanceof SurfaceView)
            {
                // Run javascript code that detects the video end and notifies the Javascript interface
                String js = "javascript:";
                js += "var _ytrp_html5_video_last;";
                js += "var _ytrp_html5_video = document.getElementsByTagName('video')[0];";
                js += "if (_ytrp_html5_video != undefined && _ytrp_html5_video != _ytrp_html5_video_last) {";
                {
                    js += "_ytrp_html5_video_last = _ytrp_html5_video;";
                    js += "function _ytrp_html5_video_ended() {";
                    {
                        js += "_VideoEnabledWebView.notifyVideoEnd();"; // Must match Javascript interface name and method of VideoEnableWebView
                    }
                    js += "}";
                    js += "_ytrp_html5_video.addEventListener('ended', _ytrp_html5_video_ended);";
                }
                js += "}";
                webView.loadUrl(js);
            }
        }

        // Notify full-screen change
        if (toggledFullscreenCallback != null)
        {
            toggledFullscreenCallback.toggledFullscreen(true);
        }
    }
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:67,代码来源:VideoEnabledWebChromeClient.java


注:本文中的android.widget.FrameLayout.getFocusedChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。