Skip to content

Commit

Permalink
prevent multiple instances
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Oct 17, 2024
1 parent 18c3980 commit 61a154c
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 25 deletions.
14 changes: 14 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
## 更新日誌

### v1.3.7.20-kitkat

* 解決EPG和proxy無法置空的問題
* 修復獲取時間錯誤問題
* 可以直接配置视频源文本

### v1.3.7.19

* 解决重复启动的问题

### v1.3.7.18

* 解決EPG和proxy無法置空的問題
Expand All @@ -9,6 +19,10 @@
* 修復獲取時間錯誤問題
* 可以直接配置视频源文本

### v1.3.7.19-kitkat

* 兼容安卓4.4

### v1.3.7.15

* 修復無法配置的問題
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="landscape">
android:screenOrientation="landscape"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/lizongying/mytv0/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class MainViewModel : ViewModel() {
fun reset(context: Context) {
val str = context.resources.openRawResource(R.raw.channels).bufferedReader()
.use { it.readText() }
Log.i(TAG, "config file: $str")

try {
str2List(str)
} catch (e: Exception) {
Expand Down Expand Up @@ -200,7 +200,6 @@ class MainViewModel : ViewModel() {
}
} else {
CoroutineScope(Dispatchers.IO).launch {
Log.i(TAG, "uri $uri")
update(uri.toString())
}
}
Expand Down
14 changes: 0 additions & 14 deletions app/src/main/java/com/lizongying/mytv0/PortUtil.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
package com.lizongying.mytv0

import java.io.IOException
import java.net.Inet4Address
import java.net.NetworkInterface
import java.net.ServerSocket

object PortUtil {

fun findFreePort(): Int {
var port = -1
try {
ServerSocket(0).use { socket ->
port = socket.localPort
}
} catch (e: IOException) {
e.printStackTrace()
}
return port
}

fun lan(): String? {
val networkInterfaces = NetworkInterface.getNetworkInterfaces()
while (networkInterfaces.hasMoreElements()) {
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/lizongying/mytv0/SimpleServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.content.Context
import android.net.Uri
import android.os.Handler
import android.os.Looper
import android.util.Log
import com.google.gson.Gson
import com.lizongying.mytv0.data.ReqSettings
import com.lizongying.mytv0.data.RespSettings
Expand Down Expand Up @@ -117,7 +116,6 @@ class SimpleServer(private val context: Context, private val viewModel: MainView
readBody(session)?.let {
handler.post {
val req = Gson().fromJson(it, ReqSettings::class.java)
Log.i(TAG, "req $req")
if (req.proxy != null) {
SP.proxy = req.proxy
R.string.default_proxy_set_success.showToast()
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/lizongying/mytv0/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,11 @@ object Utils {

suspend fun getISP(): ISP {
return withContext(Dispatchers.IO) {
val client = okhttp3.OkHttpClient.Builder().build()
val request = okhttp3.Request.Builder()
.url("https://api.myip.la/json")
.build()
try {
client.newCall(request).execute().use { response ->
HttpClient.okHttpClient.newCall(request).execute().use { response ->
if (!response.isSuccessful) return@withContext UNKNOWN
val string = response.body?.string()
val isp = Gson().fromJson(string, IpInfo::class.java).location.isp_domain
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/lizongying/mytv0/models/TVGroupModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ class TVGroupModel : ViewModel() {
(_tvGroup.value as List<TVListModel>)[1].initTVList()
}

fun clear() {
fun clearData() {
if (SP.showAllChannels) {
_tvGroup.value =
mutableListOf(getFavoritesList()!!, getAllList()!!)
setPosition(0)
getAllList()?.clear()
getAllList()?.clearData()
} else {
_tvGroup.value = mutableListOf(getFavoritesList()!!)
setPosition(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class TVListModel(private val name: String, private val groupIndex: Int) : ViewM
_tvList.value = mutableListOf()
}

fun clear() {
fun clearData() {
initTVList()
setPosition(0)
}
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version_code": 16975634, "version_name": "v1.3.7.18"}
{"version_code": 16975635, "version_name": "v1.3.7.19"}

0 comments on commit 61a154c

Please sign in to comment.