forked from Louvorg/ReaderForSelfoss-multiplatform
		
	Cleaning, and fixing socket timeout log.
This commit is contained in:
		| @@ -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,74 +256,69 @@ class ArticleFragment : Fragment(), DIAware { | ||||
|             binding.progressBar.visibility = View.VISIBLE | ||||
|  | ||||
|             CoroutineScope(Dispatchers.Main).launch { | ||||
|                  val response = mercuryApi.query(url) | ||||
|                 if (response.success) { | ||||
|                     try { | ||||
|                         if (response.data != null && response.data!!.content != null && !response.data!!.content.isNullOrEmpty()) { | ||||
|                 try { | ||||
|                     val response = mercuryApi.query(url) | ||||
|                     if (response.success && response.data != 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 { | ||||
|                                 binding.titleView.text = response.data!!.title | ||||
|                                 if (typeface != null) { | ||||
|                                     binding.titleView.typeface = typeface | ||||
|                                 } | ||||
|                                 binding.imageView.visibility = View.VISIBLE | ||||
|                                 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") | ||||
|                                 } | ||||
|                             } catch (e: Exception) { | ||||
|                                 e.sendSilentlyWithAcraWithName("getContentFromMercury > title or typeface") | ||||
|                             } | ||||
|  | ||||
|                             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 | ||||
|                                     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") | ||||
|                                 } | ||||
|                             } catch (e: Exception) { | ||||
|                                 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 { | ||||
|                             try { | ||||
|                                 openInBrowserAfterFailing() | ||||
|                             } catch (e: Exception) { | ||||
|                                 e.sendSilentlyWithAcraWithName("getContentFromMercury > open after fail") | ||||
|                             } | ||||
|                             binding.imageView.visibility = View.GONE | ||||
|                         } | ||||
|                     } 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() | ||||
|                 } | ||||
|             } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user