From ec38659a4142e349fe71d4bf864c8d80a4e9e4d7 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Tue, 14 Feb 2017 00:15:37 +0800 Subject: [PATCH] fixed video aspect ratio --- .../fragment/ExternalBrowserPageFragment.kt | 14 ++---- .../twidere/fragment/VideoPageFragment.kt | 43 ++++++++++++------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExternalBrowserPageFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExternalBrowserPageFragment.kt index de47d5b8f..d0b415cf2 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExternalBrowserPageFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExternalBrowserPageFragment.kt @@ -6,8 +6,8 @@ import android.text.TextUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import com.commonsware.cwac.layouts.AspectLockedFrameLayout import kotlinx.android.synthetic.main.layout_media_viewer_browser_fragment.* +import kotlinx.android.synthetic.main.layout_media_viewer_texture_video_view.* import org.mariotaku.mediaviewer.library.MediaViewerFragment import org.mariotaku.twidere.R import org.mariotaku.twidere.TwidereConstants.EXTRA_MEDIA @@ -16,7 +16,7 @@ import org.mariotaku.twidere.model.ParcelableMedia class ExternalBrowserPageFragment : MediaViewerFragment() { override fun onCreateMediaView(inflater: LayoutInflater, parent: ViewGroup, - savedInstanceState: Bundle?): View { + savedInstanceState: Bundle?): View { return inflater.inflate(R.layout.layout_media_viewer_browser_fragment, parent, false) } @@ -28,15 +28,7 @@ class ExternalBrowserPageFragment : MediaViewerFragment() { webSettings.loadsImagesAutomatically = true val media = arguments.getParcelable(EXTRA_MEDIA) ?: throw NullPointerException() webView.loadUrl(if (TextUtils.isEmpty(media.media_url)) media.url else media.media_url) - webViewContainer.setAspectRatioSource(object : AspectLockedFrameLayout.AspectRatioSource { - override fun getWidth(): Int { - return media.width - } - - override fun getHeight(): Int { - return media.height - } - }) + videoContainer.setAspectRatioSource(VideoPageFragment.MediaAspectRatioSource(media, this)) } override fun onResume() { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/VideoPageFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/VideoPageFragment.kt index c28270a6a..5d4cb8657 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/VideoPageFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/VideoPageFragment.kt @@ -11,6 +11,7 @@ import android.net.Uri import android.os.Build import android.os.Bundle import android.os.Handler +import android.support.v4.app.Fragment import android.util.Pair import android.view.LayoutInflater import android.view.View @@ -57,21 +58,6 @@ class VideoPageFragment : CacheDownloadMediaViewerFragment(), IBaseFragment