mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-05 07:41:23 +00:00
Fixed rounding of subscription groups.
This commit is contained in:
parent
8ffd5f411f
commit
3fc92e4065
5 changed files with 52 additions and 47 deletions
|
@ -3,45 +3,31 @@ package com.futo.platformplayer.views.adapters.viewholders
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.futo.platformplayer.R
|
import com.futo.platformplayer.R
|
||||||
import com.futo.platformplayer.api.media.PlatformID
|
|
||||||
import com.futo.platformplayer.api.media.models.channels.IPlatformChannel
|
|
||||||
import com.futo.platformplayer.constructs.Event1
|
import com.futo.platformplayer.constructs.Event1
|
||||||
import com.futo.platformplayer.constructs.TaskHandler
|
|
||||||
import com.futo.platformplayer.dp
|
|
||||||
import com.futo.platformplayer.logging.Logger
|
|
||||||
import com.futo.platformplayer.models.SubscriptionGroup
|
import com.futo.platformplayer.models.SubscriptionGroup
|
||||||
import com.futo.platformplayer.polycentric.PolycentricCache
|
|
||||||
import com.futo.platformplayer.selectBestImage
|
|
||||||
import com.futo.platformplayer.states.StateApp
|
|
||||||
import com.futo.platformplayer.views.adapters.AnyAdapter
|
import com.futo.platformplayer.views.adapters.AnyAdapter
|
||||||
import com.futo.platformplayer.views.others.CreatorThumbnail
|
|
||||||
import com.futo.polycentric.core.toURLInfoSystemLinkUrl
|
|
||||||
import com.google.android.material.imageview.ShapeableImageView
|
import com.google.android.material.imageview.ShapeableImageView
|
||||||
import com.google.android.material.shape.CornerFamily
|
|
||||||
import com.google.android.material.shape.ShapeAppearanceModel
|
|
||||||
|
|
||||||
class SubscriptionGroupBarViewHolder(private val _viewGroup: ViewGroup) : AnyAdapter.AnyViewHolder<SubscriptionGroup>(
|
class SubscriptionGroupBarViewHolder(private val _viewGroup: ViewGroup) : AnyAdapter.AnyViewHolder<SubscriptionGroup>(
|
||||||
LayoutInflater.from(_viewGroup.context).inflate(R.layout.view_subscription_group_bar, _viewGroup, false)) {
|
LayoutInflater.from(_viewGroup.context).inflate(R.layout.view_subscription_group_bar, _viewGroup, false)) {
|
||||||
private var _group: SubscriptionGroup? = null;
|
private var _group: SubscriptionGroup? = null;
|
||||||
|
|
||||||
|
private val _root: FrameLayout;
|
||||||
private val _image: ShapeableImageView;
|
private val _image: ShapeableImageView;
|
||||||
private val _textSubGroup: TextView;
|
private val _textSubGroup: TextView;
|
||||||
|
|
||||||
|
|
||||||
val onClick = Event1<SubscriptionGroup>();
|
val onClick = Event1<SubscriptionGroup>();
|
||||||
val onClickLong = Event1<SubscriptionGroup>();
|
val onClickLong = Event1<SubscriptionGroup>();
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
_root = _view.findViewById(R.id.root);
|
||||||
_image = _view.findViewById(R.id.image);
|
_image = _view.findViewById(R.id.image);
|
||||||
_textSubGroup = _view.findViewById(R.id.text_sub_group);
|
_textSubGroup = _view.findViewById(R.id.text_sub_group);
|
||||||
|
|
||||||
val dp6 = 6.dp(_view.resources);
|
|
||||||
_image.shapeAppearanceModel = ShapeAppearanceModel.builder()
|
|
||||||
.setAllCorners(CornerFamily.ROUNDED, dp6.toFloat())
|
|
||||||
.build()
|
|
||||||
|
|
||||||
_view.setOnClickListener {
|
_view.setOnClickListener {
|
||||||
_group?.let {
|
_group?.let {
|
||||||
onClick.emit(it);
|
onClick.emit(it);
|
||||||
|
@ -58,9 +44,9 @@ class SubscriptionGroupBarViewHolder(private val _viewGroup: ViewGroup) : AnyAda
|
||||||
override fun bind(value: SubscriptionGroup) {
|
override fun bind(value: SubscriptionGroup) {
|
||||||
_group = value;
|
_group = value;
|
||||||
val img = value.image;
|
val img = value.image;
|
||||||
if(img != null)
|
if(img != null) {
|
||||||
img.setImageView(_image)
|
img.setImageView(_image)
|
||||||
else {
|
} else {
|
||||||
_image.setImageResource(0);
|
_image.setImageResource(0);
|
||||||
|
|
||||||
if(value is SubscriptionGroup.Add)
|
if(value is SubscriptionGroup.Add)
|
||||||
|
@ -68,10 +54,11 @@ class SubscriptionGroupBarViewHolder(private val _viewGroup: ViewGroup) : AnyAda
|
||||||
}
|
}
|
||||||
_textSubGroup.text = value.name;
|
_textSubGroup.text = value.name;
|
||||||
|
|
||||||
if(value is SubscriptionGroup.Selectable && value.selected)
|
if (value is SubscriptionGroup.Selectable && value.selected) {
|
||||||
_view.setBackgroundColor(_view.context.resources.getColor(R.color.colorPrimary, null));
|
_root.setBackgroundResource(R.drawable.background_primary_round_6dp)
|
||||||
else
|
} else {
|
||||||
_view.setBackgroundColor(_view.context.resources.getColor(R.color.transparent, null));
|
_root.background = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
6
app/src/main/res/drawable/background_dark_round_6dp.xml
Normal file
6
app/src/main/res/drawable/background_dark_round_6dp.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="#99000000" />
|
||||||
|
<corners android:radius="6dp" />
|
||||||
|
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
|
||||||
|
</shape>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="#2D63ED" />
|
||||||
|
<corners android:radius="6dp" />
|
||||||
|
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
|
||||||
|
</shape>
|
|
@ -1,25 +1,28 @@
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="78dp"
|
android:layout_width="78dp"
|
||||||
android:layout_height="54dp"
|
android:layout_height="54dp"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:padding="2dp"
|
|
||||||
android:layout_margin="2dp"
|
android:layout_margin="2dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:id="@+id/root">
|
android:id="@+id/root"
|
||||||
|
android:background="@drawable/background_primary_round_6dp">
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
android:src="@drawable/xp_book" />
|
android:src="@drawable/xp_book"
|
||||||
<LinearLayout
|
app:shapeAppearanceOverlay="@style/roundedCorners_6dp"
|
||||||
|
android:layout_margin="2dp" />
|
||||||
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#99000000"
|
android:background="@drawable/background_dark_round_6dp"
|
||||||
android:gravity="center">
|
android:gravity="center"
|
||||||
|
android:layout_margin="2dp" />
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_sub_group"
|
android:id="@+id/text_sub_group"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -30,7 +33,6 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:textSize="12dp"
|
android:textSize="12dp"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:text="News" />
|
android:layout_gravity="center"
|
||||||
</LinearLayout>
|
tools:text="News" />
|
||||||
|
</FrameLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
<item name="cornerFamily">rounded</item>
|
<item name="cornerFamily">rounded</item>
|
||||||
<item name="cornerSize">4dp</item>
|
<item name="cornerSize">4dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
<style name="roundedCorners_6dp" parent="">
|
||||||
|
<item name="cornerFamily">rounded</item>
|
||||||
|
<item name="cornerSize">6dp</item>
|
||||||
|
</style>
|
||||||
<style name="roundedCorners_10dp" parent="">
|
<style name="roundedCorners_10dp" parent="">
|
||||||
<item name="cornerFamily">rounded</item>
|
<item name="cornerFamily">rounded</item>
|
||||||
<item name="cornerSize">10dp</item>
|
<item name="cornerSize">10dp</item>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue