Skip to content

Commit

Permalink
channel filter
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Mar 26, 2024
1 parent 8290a86 commit 65c4b0c
Show file tree
Hide file tree
Showing 26 changed files with 233 additions and 1,234 deletions.
10 changes: 10 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
## 更新日志

### v1.7.0(通用)

* 网络请求优化

### v1.6.9(安卓5及以上专用)

* 去掉港澳台和国际频道
* 解决部分情况下3、6、8等频道无法播放的问题
* 解决部分情况下启动后黑屏问题

### v1.6.8(通用)

* 修复部分设备崩溃的问题
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
android:name="android.software.leanback"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
Expand Down Expand Up @@ -39,6 +40,12 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name=".NetworkChangeReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<provider
android:name=".InitializerProvider"
android:authorities="${applicationId}.InitializerProvider"
Expand Down
Binary file removed app/src/main/ic_launcher-playstore.png
Binary file not shown.
4 changes: 2 additions & 2 deletions app/src/main/java/com/lizongying/mytv/CardPresenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class CardPresenter(
val tvViewModel = item as TVViewModel
val cardView = viewHolder.view as ImageCardView

cardView.titleText = tvViewModel.title.value
cardView.titleText = tvViewModel.getTV().title
cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT)
cardView.tag = tvViewModel.videoUrl.value

Glide.with(viewHolder.view.context)
.load(tvViewModel.logo.value)
.load(tvViewModel.getTV().logo)
.centerInside()
.into(cardView.mainImageView)

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/lizongying/mytv/ChannelFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ChannelFragment : Fragment() {
fun show(tvViewModel: TVViewModel) {
handler.removeCallbacks(hideRunnable)
handler.removeCallbacks(playRunnable)
binding.channelContent.text = (tvViewModel.id.value?.plus(1)).toString()
binding.channelContent.text = (tvViewModel.getTV().id.plus(1)).toString()
view?.visibility = View.VISIBLE
handler.postDelayed(hideRunnable, delay)
}
Expand Down
157 changes: 0 additions & 157 deletions app/src/main/java/com/lizongying/mytv/ChannelUtils.kt

This file was deleted.

28 changes: 28 additions & 0 deletions app/src/main/java/com/lizongying/mytv/ErrorFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.lizongying.mytv

import android.view.View
import androidx.core.content.ContextCompat
import androidx.leanback.app.ErrorSupportFragment

class ErrorFragment : ErrorSupportFragment() {

internal fun setErrorContent(message: String) {
imageDrawable =
ContextCompat.getDrawable(context!!, androidx.leanback.R.drawable.lb_ic_sad_cloud)
this.message = message
setDefaultBackground(TRANSLUCENT)
backgroundDrawable = ContextCompat.getDrawable(
context!!,
R.color.black
)

buttonText = resources.getString(R.string.dismiss_error)
buttonClickListener = View.OnClickListener {
fragmentManager!!.beginTransaction().remove(this@ErrorFragment).commit()
}
}

companion object {
private const val TRANSLUCENT = false
}
}
21 changes: 21 additions & 0 deletions app/src/main/java/com/lizongying/mytv/Ext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.content.pm.Signature
import android.content.pm.SigningInfo
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.os.Build
import android.util.Log
import java.security.MessageDigest
Expand Down Expand Up @@ -71,6 +73,25 @@ val Context.appSignature: String
return hashSignature(sign)
}


val Context.isNetworkConnected: Boolean
get() {
val connectivityManager =
this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val network = connectivityManager.activeNetwork
val networkCapabilities = connectivityManager.getNetworkCapabilities(network)
return networkCapabilities != null &&
(networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) ||
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) ||
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET))
} else {
val networkInfo = connectivityManager.activeNetworkInfo
return networkInfo != null && networkInfo.isConnectedOrConnecting
}
}

private fun hashSignature(signature: Signature): String {
return try {
val md = MessageDigest.getInstance("MD5")
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/lizongying/mytv/InfoFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class InfoFragment : Fragment() {
}

fun show(tvViewModel: TVViewModel) {
binding.textView.text = tvViewModel.title.value
binding.textView.text = tvViewModel.getTV().title

Glide.with(this)
.load(tvViewModel.logo.value)
.load(tvViewModel.getTV().logo)
.into(binding.infoLogo)

Log.i(TAG, "${tvViewModel.title.value} ${tvViewModel.epg.value}")
Log.i(TAG, "${tvViewModel.getTV().title} ${tvViewModel.epg.value}")
val epg = tvViewModel.epg.value?.filter { it.beginTime < Utils.getDateTimestamp() }
if (!epg.isNullOrEmpty()) {
binding.infoDesc.text = epg.last().title
Expand Down
Loading

0 comments on commit 65c4b0c

Please sign in to comment.