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.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.acra.ACRA
|
|
||||||
import org.acra.ktx.sendSilentlyWithAcra
|
|
||||||
import org.kodein.di.DIAware
|
import org.kodein.di.DIAware
|
||||||
import org.kodein.di.android.closestDI
|
import org.kodein.di.android.closestDI
|
||||||
import org.kodein.di.instance
|
import org.kodein.di.instance
|
||||||
@ -324,7 +322,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
|||||||
private fun handleGDPRDialog(GDPRShown: Boolean) {
|
private fun handleGDPRDialog(GDPRShown: Boolean) {
|
||||||
val messageDigest: MessageDigest = MessageDigest.getInstance("SHA-256")
|
val messageDigest: MessageDigest = MessageDigest.getInstance("SHA-256")
|
||||||
messageDigest.update(appSettingsService.getBaseUrl().toByteArray())
|
messageDigest.update(appSettingsService.getBaseUrl().toByteArray())
|
||||||
ACRA.errorReporter.putCustomData("unique_id", String(messageDigest.digest()))
|
|
||||||
if (!GDPRShown) {
|
if (!GDPRShown) {
|
||||||
val alertDialog = AlertDialog.Builder(this).create()
|
val alertDialog = AlertDialog.Builder(this).create()
|
||||||
alertDialog.setTitle(getString(R.string.gdpr_dialog_title))
|
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.android.x.closestDI
|
||||||
import org.kodein.di.instance
|
import org.kodein.di.instance
|
||||||
import java.net.MalformedURLException
|
import java.net.MalformedURLException
|
||||||
|
import java.net.SocketTimeoutException
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.ExecutionException
|
import java.util.concurrent.ExecutionException
|
||||||
@ -255,74 +256,69 @@ class ArticleFragment : Fragment(), DIAware {
|
|||||||
binding.progressBar.visibility = View.VISIBLE
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
val response = mercuryApi.query(url)
|
try {
|
||||||
if (response.success) {
|
val response = mercuryApi.query(url)
|
||||||
try {
|
if (response.success && response.data != null && !response.data?.content.isNullOrEmpty()) {
|
||||||
if (response.data != null && response.data!!.content != null && !response.data!!.content.isNullOrEmpty()) {
|
binding.titleView.text = response.data!!.title.orEmpty()
|
||||||
|
try {
|
||||||
|
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)
|
||||||
|
url = response.data!!.url
|
||||||
|
} catch (e: MalformedURLException) {
|
||||||
|
// Mercury returned a relative url
|
||||||
|
e.sendSilentlyWithAcraWithName("getContentFromMercury > malformedurlexception")
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
contentText = response.data!!.content.orEmpty()
|
||||||
|
htmlToWebview()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.sendSilentlyWithAcraWithName("getContentFromMercury > contenttext or html")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!response.data?.lead_image_url.isNullOrEmpty() && context != null) {
|
||||||
try {
|
try {
|
||||||
binding.titleView.text = response.data!!.title
|
binding.imageView.visibility = View.VISIBLE
|
||||||
if (typeface != null) {
|
|
||||||
binding.titleView.typeface = typeface
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
// Note: Mercury may return relative urls... If it does the url val will not be changed.
|
Glide
|
||||||
URL(response.data!!.url)
|
.with(requireContext())
|
||||||
url = response.data!!.url
|
.asBitmap()
|
||||||
} catch (e: MalformedURLException) {
|
.load(
|
||||||
// Mercury returned a relative url
|
response.data!!.lead_image_url.orEmpty()
|
||||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > malformedurlexception")
|
)
|
||||||
}
|
.apply(RequestOptions.fitCenterTransform())
|
||||||
} catch (e: Exception) {
|
.into(binding.imageView)
|
||||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > title or typeface")
|
} catch (e: Exception) {
|
||||||
}
|
e.sendSilentlyWithAcraWithName("getContentFromMercury > glide lead image")
|
||||||
|
|
||||||
try {
|
|
||||||
contentText = response.data!!.content.orEmpty()
|
|
||||||
htmlToWebview()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > contenttext or html")
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (response.data!!.lead_image_url != null && !response.data!!.lead_image_url.isNullOrEmpty() && context != null) {
|
|
||||||
binding.imageView.visibility = View.VISIBLE
|
|
||||||
try {
|
|
||||||
Glide
|
|
||||||
.with(requireContext())
|
|
||||||
.asBitmap()
|
|
||||||
.load(
|
|
||||||
response.data!!.lead_image_url.orEmpty()
|
|
||||||
)
|
|
||||||
.apply(RequestOptions.fitCenterTransform())
|
|
||||||
.into(binding.imageView)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > glide lead image")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
binding.imageView.visibility = View.GONE
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > outside glide lead image")
|
e.sendSilentlyWithAcraWithName("getContentFromMercury > outside glide lead image")
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
binding.nestedScrollView.scrollTo(0, 0)
|
|
||||||
|
|
||||||
binding.progressBar.visibility = View.GONE
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > scrollview")
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
binding.imageView.visibility = View.GONE
|
||||||
openInBrowserAfterFailing()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > open after fail")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
e.sendSilentlyWithAcraWithName("getContentFromMercury > whole thing")
|
try {
|
||||||
|
binding.nestedScrollView.scrollTo(0, 0)
|
||||||
|
binding.progressBar.visibility = View.GONE
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.sendSilentlyWithAcraWithName("getContentFromMercury > scrollview")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
openInBrowserAfterFailing()
|
||||||
}
|
}
|
||||||
} else {
|
} catch (e: SocketTimeoutException) {
|
||||||
|
openInBrowserAfterFailing()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.sendSilentlyWithAcraWithName("getContentFromMercury > whole thing")
|
||||||
openInBrowserAfterFailing()
|
openInBrowserAfterFailing()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user