Cleaning, and fixing socket timeout log.
This commit is contained in:
parent
6947743ac0
commit
87ed5b0fa8
@ -59,8 +59,6 @@ import com.mikepenz.materialdrawer.util.updateBadge
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.acra.ACRA
|
||||
import org.acra.ktx.sendSilentlyWithAcra
|
||||
import org.kodein.di.DIAware
|
||||
import org.kodein.di.android.closestDI
|
||||
import org.kodein.di.instance
|
||||
@ -324,7 +322,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
||||
private fun handleGDPRDialog(GDPRShown: Boolean) {
|
||||
val messageDigest: MessageDigest = MessageDigest.getInstance("SHA-256")
|
||||
messageDigest.update(appSettingsService.getBaseUrl().toByteArray())
|
||||
ACRA.errorReporter.putCustomData("unique_id", String(messageDigest.digest()))
|
||||
if (!GDPRShown) {
|
||||
val alertDialog = AlertDialog.Builder(this).create()
|
||||
alertDialog.setTitle(getString(R.string.gdpr_dialog_title))
|
||||
|
@ -52,6 +52,7 @@ import org.kodein.di.DIAware
|
||||
import org.kodein.di.android.x.closestDI
|
||||
import org.kodein.di.instance
|
||||
import java.net.MalformedURLException
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.URL
|
||||
import java.util.*
|
||||
import java.util.concurrent.ExecutionException
|
||||
@ -255,15 +256,18 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
binding.progressBar.visibility = View.VISIBLE
|
||||
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
try {
|
||||
val response = mercuryApi.query(url)
|
||||
if (response.success) {
|
||||
if (response.success && response.data != null && !response.data?.content.isNullOrEmpty()) {
|
||||
binding.titleView.text = response.data!!.title.orEmpty()
|
||||
try {
|
||||
if (response.data != null && response.data!!.content != null && !response.data!!.content.isNullOrEmpty()) {
|
||||
try {
|
||||
binding.titleView.text = response.data!!.title
|
||||
if (typeface != null) {
|
||||
binding.titleView.typeface = typeface
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > typeface")
|
||||
}
|
||||
|
||||
try {
|
||||
// Note: Mercury may return relative urls... If it does the url val will not be changed.
|
||||
URL(response.data!!.url)
|
||||
@ -272,9 +276,6 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
// Mercury returned a relative url
|
||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > malformedurlexception")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > title or typeface")
|
||||
}
|
||||
|
||||
try {
|
||||
contentText = response.data!!.content.orEmpty()
|
||||
@ -283,8 +284,8 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > contenttext or html")
|
||||
}
|
||||
|
||||
if (!response.data?.lead_image_url.isNullOrEmpty() && context != null) {
|
||||
try {
|
||||
if (response.data!!.lead_image_url != null && !response.data!!.lead_image_url.isNullOrEmpty() && context != null) {
|
||||
binding.imageView.visibility = View.VISIBLE
|
||||
try {
|
||||
Glide
|
||||
@ -298,31 +299,26 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
} catch (e: Exception) {
|
||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > glide lead image")
|
||||
}
|
||||
} else {
|
||||
binding.imageView.visibility = View.GONE
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > outside glide lead image")
|
||||
}
|
||||
} else {
|
||||
binding.imageView.visibility = View.GONE
|
||||
}
|
||||
|
||||
try {
|
||||
binding.nestedScrollView.scrollTo(0, 0)
|
||||
|
||||
binding.progressBar.visibility = View.GONE
|
||||
} catch (e: Exception) {
|
||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > scrollview")
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
openInBrowserAfterFailing()
|
||||
} catch (e: Exception) {
|
||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > open after fail")
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: SocketTimeoutException) {
|
||||
openInBrowserAfterFailing()
|
||||
} catch (e: Exception) {
|
||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > whole thing")
|
||||
}
|
||||
} else {
|
||||
openInBrowserAfterFailing()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user