Skip to content

Commit

Permalink
added several try-catches;
Browse files Browse the repository at this point in the history
v1.6.2
  • Loading branch information
truefedex committed Oct 27, 2021
1 parent a988121 commit 514de35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ android {
applicationId = "com.phlox.tvwebbrowser"
minSdk = 21
targetSdk = 30
versionCode = 45
versionName = "1.6.1"
versionCode = 46
versionName = "1.6.2"

javaCompileOptions {
annotationProcessorOptions {
Expand All @@ -42,7 +42,7 @@ android {
}
buildTypes {
getByName("release") {
isDebuggable = true
isDebuggable = false
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
signingConfig=signingConfigs.getByName("release")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.brave.adblock.AdBlockClient
import com.brave.adblock.Utils
import com.phlox.tvwebbrowser.R
import com.phlox.tvwebbrowser.TVBro
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
import java.lang.Exception
import java.net.URL
import java.util.*
import javax.net.ssl.HttpsURLConnection


class AdblockViewModel(val app: Application) : AndroidViewModel(app) {
companion object {
Expand Down Expand Up @@ -77,9 +73,14 @@ class AdblockViewModel(val app: Application) : AndroidViewModel(app) {
success = true
return@ioContext
}
val easyList = URL(adBlockListURL).openConnection().inputStream.bufferedReader().use { it.readText() }
success = client.parse(easyList)
client.serialize(serializedFile.absolutePath)
try {
val easyList = URL(adBlockListURL).openConnection().inputStream.bufferedReader()
.use { it.readText() }
success = client.parse(easyList)
client.serialize(serializedFile.absolutePath)
} catch (e: Exception) {
e.printStackTrace()
}
}
this@AdblockViewModel.client = client
lastUpdateListTime = now.timeInMillis
Expand All @@ -98,6 +99,12 @@ class AdblockViewModel(val app: Application) : AndroidViewModel(app) {
} catch (e: Exception) {
return false
}
return baseHost != null && client.matches(request.url.toString(), filterOption, baseHost)
val result = try {
baseHost != null && client.matches(request.url.toString(), filterOption, baseHost)
} catch (e: Exception) {
e.printStackTrace()
false
}
return result
}
}

0 comments on commit 514de35

Please sign in to comment.