-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draft Add watch provider filter view.
- Loading branch information
1 parent
9833566
commit 4e2b1ae
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/battlelancer/seriesguide/shows/WatchProviderFilterAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2024 Uwe Trottmann | ||
|
||
package com.battlelancer.seriesguide.shows | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView.ViewHolder | ||
import com.battlelancer.seriesguide.databinding.ItemWatchProviderBinding | ||
import com.battlelancer.seriesguide.streaming.SgWatchProvider | ||
|
||
class WatchProviderFilterAdapter : | ||
ListAdapter<SgWatchProvider, WatchProviderViewHolder>(WatchProviderDiffCallback) { | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WatchProviderViewHolder { | ||
return WatchProviderViewHolder.create(parent) | ||
} | ||
|
||
override fun onBindViewHolder(holder: WatchProviderViewHolder, position: Int) { | ||
holder.bind(getItem(position)) | ||
} | ||
} | ||
|
||
class WatchProviderViewHolder(private val binding: ItemWatchProviderBinding) : | ||
ViewHolder(binding.root) { | ||
|
||
fun bind(watchProvider: SgWatchProvider) { | ||
TODO() | ||
} | ||
|
||
companion object { | ||
fun create(parent: ViewGroup): WatchProviderViewHolder = | ||
WatchProviderViewHolder( | ||
ItemWatchProviderBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false | ||
) | ||
) | ||
} | ||
} | ||
|
||
object WatchProviderDiffCallback : DiffUtil.ItemCallback<SgWatchProvider>() { | ||
override fun areItemsTheSame(oldItem: SgWatchProvider, newItem: SgWatchProvider): Boolean { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun areContentsTheSame(oldItem: SgWatchProvider, newItem: SgWatchProvider): Boolean { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/battlelancer/seriesguide/shows/WatchProviderFilterView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2024 Uwe Trottmann | ||
|
||
package com.battlelancer.seriesguide.shows | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import android.widget.LinearLayout | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import com.battlelancer.seriesguide.databinding.ViewFilterWatchProvidersBinding | ||
import com.battlelancer.seriesguide.streaming.SgWatchProvider | ||
|
||
class WatchProviderFilterView @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : LinearLayout(context, attrs, defStyleAttr) { | ||
|
||
private val binding: ViewFilterWatchProvidersBinding | ||
private val adapter: WatchProviderFilterAdapter | ||
|
||
init { | ||
orientation = VERTICAL | ||
|
||
// can't do in onFinishInflate as that is only called when inflating from XML | ||
binding = ViewFilterWatchProvidersBinding.inflate(LayoutInflater.from(context), this) | ||
|
||
adapter = WatchProviderFilterAdapter() | ||
binding.recyclerViewProviderFilter.also { | ||
it.layoutManager = LinearLayoutManager(context) | ||
it.adapter = adapter | ||
} | ||
} | ||
|
||
fun setWatchProviders(watchProviders: List<SgWatchProvider>) { | ||
adapter.submitList(watchProviders) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<!-- SPDX-License-Identifier: Apache-2.0 --> | ||
<!-- Copyright 2024 Uwe Trottmann --> | ||
|
||
<merge xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
tools:orientation="vertical" | ||
tools:parentTag="android.widget.LinearLayout"> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/recyclerViewProviderFilter" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
</merge> |