From 2309e15261ac3650cc15bf6363500664494fe24d Mon Sep 17 00:00:00 2001 From: Ritvik Saraf <13ritvik@gmail.com> Date: Sun, 3 Mar 2019 18:20:15 +0530 Subject: [PATCH] fixed scroll w/ comments and related streams disabled --- .../newpipe/fragments/EmptyFragment.java | 17 +++++++++++ .../fragments/detail/VideoDetailFragment.java | 6 ++++ .../fragment_video_detail.xml | 2 ++ app/src/main/res/layout/fragment_comments.xml | 3 +- app/src/main/res/layout/fragment_empty.xml | 29 +++++++++++++++++++ .../res/layout/fragment_related_streams.xml | 3 +- .../main/res/layout/fragment_video_detail.xml | 1 + 7 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/fragments/EmptyFragment.java create mode 100644 app/src/main/res/layout/fragment_empty.xml diff --git a/app/src/main/java/org/schabi/newpipe/fragments/EmptyFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/EmptyFragment.java new file mode 100644 index 000000000..0666667d6 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/fragments/EmptyFragment.java @@ -0,0 +1,17 @@ +package org.schabi.newpipe.fragments; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import org.schabi.newpipe.BaseFragment; +import org.schabi.newpipe.R; + +public class EmptyFragment extends BaseFragment { + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_empty, container, false); + } +} diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 269125e27..8c87c1875 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -65,6 +65,7 @@ import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.extractor.stream.VideoStream; import org.schabi.newpipe.fragments.BackPressable; import org.schabi.newpipe.fragments.BaseStateFragment; +import org.schabi.newpipe.fragments.EmptyFragment; import org.schabi.newpipe.fragments.list.comments.CommentsFragment; import org.schabi.newpipe.fragments.list.videos.RelatedVideosFragment; import org.schabi.newpipe.info_list.InfoItemDialog; @@ -179,6 +180,7 @@ public class VideoDetailFragment private static final String COMMENTS_TAB_TAG = "COMMENTS"; private static final String RELATED_TAB_TAG = "NEXT VIDEO"; + private static final String EMPTY_TAB_TAG = "EMPTY TAB"; private AppBarLayout appBarLayout; private ViewPager viewPager; @@ -824,6 +826,10 @@ public class VideoDetailFragment pageAdapter.addFragment(new Fragment(), RELATED_TAB_TAG); } + if(pageAdapter.getCount() == 0){ + pageAdapter.addFragment(new EmptyFragment(), EMPTY_TAB_TAG); + } + pageAdapter.notifyDataSetUpdate(); if(pageAdapter.getCount() < 2){ diff --git a/app/src/main/res/layout-large-land/fragment_video_detail.xml b/app/src/main/res/layout-large-land/fragment_video_detail.xml index 2df22ab48..8cdc2f307 100644 --- a/app/src/main/res/layout-large-land/fragment_video_detail.xml +++ b/app/src/main/res/layout-large-land/fragment_video_detail.xml @@ -179,6 +179,7 @@ android:id="@+id/detail_content_root_hiding" android:layout_width="match_parent" android:layout_height="match_parent" + android:paddingBottom="10dp" android:layout_below="@+id/detail_title_root_layout" android:orientation="vertical" android:visibility="gone" @@ -492,6 +493,7 @@ android:id="@+id/relatedStreamsLayout" android:layout_width="0dp" android:layout_height="match_parent" + android:layout_marginTop="10dp" android:layout_weight="3"> diff --git a/app/src/main/res/layout/fragment_comments.xml b/app/src/main/res/layout/fragment_comments.xml index ad246acc9..64d4d73bd 100644 --- a/app/src/main/res/layout/fragment_comments.xml +++ b/app/src/main/res/layout/fragment_comments.xml @@ -3,8 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingTop="10dp"> + android:layout_height="match_parent"> + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_related_streams.xml b/app/src/main/res/layout/fragment_related_streams.xml index 0b3f66092..5bb0b9497 100644 --- a/app/src/main/res/layout/fragment_related_streams.xml +++ b/app/src/main/res/layout/fragment_related_streams.xml @@ -3,8 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingTop="10dp"> + android:layout_height="match_parent">