mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Move the tablayout to the top
This commit is contained in:
parent
5a548b227f
commit
ff2abfa83d
2 changed files with 29 additions and 33 deletions
|
@ -7,12 +7,14 @@ import android.content.res.Configuration
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewGroup.FOCUS_AFTER_DESCENDANTS
|
import android.view.ViewGroup.FOCUS_AFTER_DESCENDANTS
|
||||||
import android.view.ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
import android.view.ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
||||||
import android.view.animation.AlphaAnimation
|
import android.view.animation.AlphaAnimation
|
||||||
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
@ -23,6 +25,7 @@ import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.viewpager2.widget.ViewPager2
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.google.android.material.tabs.TabLayout
|
||||||
import com.google.android.material.tabs.TabLayoutMediator
|
import com.google.android.material.tabs.TabLayoutMediator
|
||||||
import com.lagradost.cloudstream3.APIHolder
|
import com.lagradost.cloudstream3.APIHolder
|
||||||
import com.lagradost.cloudstream3.APIHolder.allProviders
|
import com.lagradost.cloudstream3.APIHolder.allProviders
|
||||||
|
@ -132,7 +135,6 @@ class LibraryFragment : Fragment() {
|
||||||
|
|
||||||
binding?.libraryRoot?.findViewById<TextView>(R.id.search_src_text)?.apply {
|
binding?.libraryRoot?.findViewById<TextView>(R.id.search_src_text)?.apply {
|
||||||
tag = "tv_no_focus_tag"
|
tag = "tv_no_focus_tag"
|
||||||
nextFocusDownId = R.id.search_result_root
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding?.mainSearch?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
binding?.mainSearch?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||||
|
@ -374,7 +376,10 @@ class LibraryFragment : Fragment() {
|
||||||
|
|
||||||
(viewpager.adapter as? ViewpagerAdapter)?.pages = pages
|
(viewpager.adapter as? ViewpagerAdapter)?.pages = pages
|
||||||
//fix focus on the viewpager itself
|
//fix focus on the viewpager itself
|
||||||
(viewpager.getChildAt(0) as RecyclerView).tag = "tv_no_focus_tag"
|
(viewpager.getChildAt(0) as RecyclerView).apply {
|
||||||
|
tag = "tv_no_focus_tag"
|
||||||
|
//isFocusable = false
|
||||||
|
}
|
||||||
|
|
||||||
// Using notifyItemRangeChanged keeps the animations when sorting
|
// Using notifyItemRangeChanged keeps the animations when sorting
|
||||||
viewpager.adapter?.notifyItemRangeChanged(
|
viewpager.adapter?.notifyItemRangeChanged(
|
||||||
|
@ -419,10 +424,8 @@ class LibraryFragment : Fragment() {
|
||||||
) { tab, position ->
|
) { tab, position ->
|
||||||
tab.text = pages.getOrNull(position)?.title?.asStringNull(context)
|
tab.text = pages.getOrNull(position)?.title?.asStringNull(context)
|
||||||
tab.view.tag = "tv_no_focus_tag"
|
tab.view.tag = "tv_no_focus_tag"
|
||||||
tab.view.nextFocusUpId = R.id.search_result_root
|
tab.view.nextFocusDownId = R.id.search_result_root
|
||||||
/*tab.view.setOnFocusChangeListener { view, b ->
|
|
||||||
Log.d("King", libraryTabLayout.focusedChild)
|
|
||||||
}*/
|
|
||||||
tab.view.setOnClickListener {
|
tab.view.setOnClickListener {
|
||||||
val currentItem =
|
val currentItem =
|
||||||
binding?.viewpager?.currentItem ?: return@setOnClickListener
|
binding?.viewpager?.currentItem ?: return@setOnClickListener
|
||||||
|
@ -464,7 +467,6 @@ class LibraryFragment : Fragment() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
(binding?.viewpager?.adapter as? ViewpagerAdapter)?.rebind()
|
(binding?.viewpager?.adapter as? ViewpagerAdapter)?.rebind()
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
android:contentDescription="@string/change_providers_img_des"
|
android:contentDescription="@string/change_providers_img_des"
|
||||||
android:nextFocusLeft="@id/nav_rail_view"
|
android:nextFocusLeft="@id/nav_rail_view"
|
||||||
android:nextFocusRight="@id/library_sort"
|
android:nextFocusRight="@id/library_sort"
|
||||||
android:nextFocusDown="@id/search_result_root"
|
|
||||||
android:tag="@string/tv_no_focus_tag"
|
android:tag="@string/tv_no_focus_tag"
|
||||||
android:src="@drawable/ic_baseline_extension_24"
|
android:src="@drawable/ic_baseline_extension_24"
|
||||||
app:tint="?attr/textColor" />
|
app:tint="?attr/textColor" />
|
||||||
|
@ -55,7 +54,6 @@
|
||||||
android:contentDescription="@string/change_providers_img_des"
|
android:contentDescription="@string/change_providers_img_des"
|
||||||
android:nextFocusLeft="@id/provider_selector"
|
android:nextFocusLeft="@id/provider_selector"
|
||||||
android:nextFocusRight="@id/list_selector"
|
android:nextFocusRight="@id/list_selector"
|
||||||
android:nextFocusDown="@id/search_result_root"
|
|
||||||
android:tag="@string/tv_no_focus_tag"
|
android:tag="@string/tv_no_focus_tag"
|
||||||
android:src="@drawable/ic_baseline_sort_24"
|
android:src="@drawable/ic_baseline_sort_24"
|
||||||
app:tint="?attr/textColor" />
|
app:tint="?attr/textColor" />
|
||||||
|
@ -71,7 +69,6 @@
|
||||||
android:contentDescription="@string/change_providers_img_des"
|
android:contentDescription="@string/change_providers_img_des"
|
||||||
android:nextFocusLeft="@id/library_sort"
|
android:nextFocusLeft="@id/library_sort"
|
||||||
android:nextFocusRight="@id/main_search"
|
android:nextFocusRight="@id/main_search"
|
||||||
android:nextFocusDown="@id/search_result_root"
|
|
||||||
android:tag="@string/tv_no_focus_tag"
|
android:tag="@string/tv_no_focus_tag"
|
||||||
android:src="@drawable/ic_baseline_filter_list_24"
|
android:src="@drawable/ic_baseline_filter_list_24"
|
||||||
app:tint="?attr/textColor" />
|
app:tint="?attr/textColor" />
|
||||||
|
@ -82,7 +79,6 @@
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:background="@drawable/search_background"
|
android:background="@drawable/search_background"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
android:nextFocusDown="@id/search_result_root"
|
|
||||||
app:layout_scrollFlags="scroll|enterAlways">
|
app:layout_scrollFlags="scroll|enterAlways">
|
||||||
|
|
||||||
<androidx.appcompat.widget.SearchView
|
<androidx.appcompat.widget.SearchView
|
||||||
|
@ -108,6 +104,25 @@
|
||||||
</androidx.appcompat.widget.SearchView>
|
</androidx.appcompat.widget.SearchView>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<com.google.android.material.tabs.TabLayout
|
||||||
|
android:id="@+id/library_tab_layout"
|
||||||
|
style="@style/Theme.Widget.Tabs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_gravity="top"
|
||||||
|
android:nextFocusDown="@id/search_result_root"
|
||||||
|
android:background="?attr/primaryGrayBackground"
|
||||||
|
android:paddingHorizontal="5dp"
|
||||||
|
app:layout_scrollFlags="noScroll"
|
||||||
|
app:tabGravity="center"
|
||||||
|
app:tabIndicator="@drawable/indicator_background"
|
||||||
|
app:tabIndicatorColor="?attr/white"
|
||||||
|
app:tabIndicatorGravity="center"
|
||||||
|
app:tabIndicatorHeight="30dp"
|
||||||
|
app:tabMode="scrollable"
|
||||||
|
app:tabSelectedTextColor="?attr/primaryBlackBackground"
|
||||||
|
app:tabTextAppearance="@style/TabNoCaps"
|
||||||
|
app:tabTextColor="?attr/textColor" />
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
@ -121,7 +136,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingBottom="40dp"
|
android:paddingBottom="40dp"
|
||||||
android:focusable="false"
|
android:focusable="true"
|
||||||
android:tag="@string/tv_no_focus_tag"
|
android:tag="@string/tv_no_focus_tag"
|
||||||
tools:listitem="@layout/library_viewpager_page" />
|
tools:listitem="@layout/library_viewpager_page" />
|
||||||
|
|
||||||
|
@ -182,25 +197,4 @@
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<com.google.android.material.tabs.TabLayout
|
|
||||||
android:id="@+id/library_tab_layout"
|
|
||||||
style="@style/Theme.Widget.Tabs"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="40dp"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:nextFocusUp="@id/search_result_root"
|
|
||||||
android:background="?attr/primaryGrayBackground"
|
|
||||||
android:nextFocusLeft="@id/nav_rail_view"
|
|
||||||
android:paddingHorizontal="5dp"
|
|
||||||
app:layout_scrollFlags="noScroll"
|
|
||||||
app:tabGravity="center"
|
|
||||||
app:tabIndicator="@drawable/indicator_background"
|
|
||||||
app:tabIndicatorColor="?attr/white"
|
|
||||||
app:tabIndicatorGravity="center"
|
|
||||||
app:tabIndicatorHeight="30dp"
|
|
||||||
app:tabMode="scrollable"
|
|
||||||
app:tabSelectedTextColor="?attr/primaryBlackBackground"
|
|
||||||
app:tabTextAppearance="@style/TabNoCaps"
|
|
||||||
app:tabTextColor="?attr/textColor" />
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue