Reintroduce network checks where required
This commit is contained in:
parent
d654b1b0bd
commit
d1481a1db6
@ -43,7 +43,7 @@ class LoadingWorker(val context: Context, params: WorkerParameters) : Worker(con
|
||||
override fun doWork(): Result {
|
||||
val settings = Settings()
|
||||
val periodicRefresh = settings.getBoolean("periodic_refresh", false)
|
||||
if (periodicRefresh) {
|
||||
if (periodicRefresh && repository.isNetworkAvailable()) {
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val notificationManager =
|
||||
|
@ -278,6 +278,7 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
binding.progressBar.visibility = View.VISIBLE
|
||||
val parser = MercuryApi()
|
||||
|
||||
if (repository.isNetworkAvailable()) {
|
||||
parser.parseUrl(url).enqueue(
|
||||
object : Callback<ParsedContent> {
|
||||
override fun onResponse(
|
||||
@ -315,7 +316,10 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
Glide
|
||||
.with(requireContext())
|
||||
.asBitmap()
|
||||
.loadMaybeBasicAuth(config, response.body()!!.lead_image_url.orEmpty())
|
||||
.loadMaybeBasicAuth(
|
||||
config,
|
||||
response.body()!!.lead_image_url.orEmpty()
|
||||
)
|
||||
.apply(RequestOptions.fitCenterTransform())
|
||||
.into(binding.imageView)
|
||||
} catch (e: Exception) {
|
||||
@ -357,6 +361,7 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun htmlToWebview() {
|
||||
val stringColor = String.format("#%06X", 0xFFFFFF and appColors.colorAccent)
|
||||
|
@ -378,7 +378,7 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
||||
}
|
||||
}
|
||||
|
||||
private fun isNetworkAvailable() = isConnectionAvailable.value && !offlineOverride
|
||||
fun isNetworkAvailable() = isConnectionAvailable.value && !offlineOverride
|
||||
|
||||
// TODO: Handle offline actions
|
||||
}
|
Loading…
Reference in New Issue
Block a user