Skip to content

Commit

Permalink
fix sources with default checked
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Dec 20, 2024
1 parent 45a4123 commit 59c8f31
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
17 changes: 11 additions & 6 deletions app/src/main/java/com/lizongying/mytv0/SourcesAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.view.marginEnd
import androidx.core.view.marginStart
import androidx.core.view.setPadding
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.lizongying.mytv0.databinding.SourcesItemBinding
Expand All @@ -28,18 +30,21 @@ class SourcesAdapter(
val inflater = LayoutInflater.from(context)
val binding = SourcesItemBinding.inflate(inflater, parent, false)

binding.num.layoutParams.width = application.px2Px(binding.num.layoutParams.width)
binding.num.layoutParams.height = application.px2Px(binding.num.layoutParams.height)
binding.num.textSize = application.px2PxFont(binding.num.textSize)

binding.title.layoutParams.width = application.px2Px(binding.title.layoutParams.width)
binding.title.layoutParams.height = application.px2Px(binding.title.layoutParams.height)
val layoutParams = binding.title.layoutParams as ViewGroup.MarginLayoutParams
layoutParams.marginStart = application.px2Px(binding.title.marginStart)
layoutParams.marginEnd = application.px2Px(binding.title.marginEnd)
binding.title.layoutParams = layoutParams
binding.title.textSize = application.px2PxFont(binding.title.textSize)

binding.heart.layoutParams.width = application.px2Px(binding.heart.layoutParams.width)
binding.heart.layoutParams.height = application.px2Px(binding.heart.layoutParams.height)

binding.title.textSize = application.px2PxFont(binding.title.textSize)

val layoutParamsHeart = binding.heart.layoutParams as ViewGroup.MarginLayoutParams
layoutParamsHeart.marginStart = application.px2Px(binding.heart.marginStart)
binding.heart.layoutParams = layoutParamsHeart
binding.heart.setPadding(application.px2Px(binding.heart.paddingTop))

return ViewHolder(context, binding)
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/lizongying/mytv0/models/Sources.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class Sources {
// Log.i(TAG, "setChecked $position")
// setChecked(position)
// }
//
// SP.sources = gson.toJson(sources, type) ?: ""
return true
}
}
Expand Down Expand Up @@ -111,7 +113,7 @@ class Sources {
if (!SP.sources.isNullOrEmpty()) {
try {
val sources: List<Source> = gson.fromJson(SP.sources!!, type)
setSources(sources)
setSources(sources.map { it.apply { checked = false } })
} catch (e: Exception) {
e.printStackTrace()
SP.sources = SP.DEFAULT_SOURCES
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/res/layout/sources_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,42 @@
android:id="@+id/num"
android:layout_width="50dp"
android:layout_height="50dp"
android:singleLine="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:textColor="@color/title_blur"
tools:text="99"
android:singleLine="true"
android:ellipsize="start"
android:textSize="16sp"
android:gravity="center" />

<TextView
android:id="@+id/title"
android:layout_width="520dp"
android:layout_width="500dp"
android:layout_height="50dp"
android:paddingEnd="30dp"
android:singleLine="true"
app:layout_constraintStart_toStartOf="@id/num"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:textColor="@color/title_blur"
tools:text="https://ali-m-l.cztv.com/channels/lantian/channel007/1080p.m3u8"
tools:text="https://ali-m-l.cztv.com/channels/lantian/channel007/1080p.m3u8https://ali-m-l.cztv.com/channels/lantian/channel007/1080p.m3u8"
android:singleLine="true"
android:ellipsize="start"
android:textSize="16sp"
android:gravity="center_vertical" />

<ImageView
android:id="@+id/heart"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/baseline_done_24"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:clickable="true"
android:focusable="false"
android:padding="5dp"
android:layout_marginEnd="5dp"/>
android:padding="15dp"
android:gravity="center" />
</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/raw/mobile.txt

Large diffs are not rendered by default.

0 comments on commit 59c8f31

Please sign in to comment.