X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fviewmodels%2FHeadersViewModel.kt;h=3fff326322b3fcaf7b6c92210a8df9c5808756d0;hp=ccfe79ab2ca2baf4ee7964731ba0aad1d857eb54;hb=9a15b265860ef93cf1648c0bc30036895681f46a;hpb=a9d00f526a6fc67f97d479188fae66dd7f0a6dde diff --git a/app/src/main/java/com/stoutner/privacybrowser/viewmodels/HeadersViewModel.kt b/app/src/main/java/com/stoutner/privacybrowser/viewmodels/HeadersViewModel.kt index ccfe79ab..3fff3263 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/viewmodels/HeadersViewModel.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/viewmodels/HeadersViewModel.kt @@ -19,20 +19,22 @@ package com.stoutner.privacybrowser.viewmodels +import android.app.Application import android.content.ContentResolver import android.text.SpannableStringBuilder +import androidx.lifecycle.AndroidViewModel + import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel import com.stoutner.privacybrowser.backgroundtasks.GetHeadersBackgroundTask import java.net.Proxy import java.util.concurrent.ExecutorService -class HeadersViewModel(private val urlString: String, private val userAgent: String, private val localeString: String, private val proxy: Proxy, private val contentResolver: ContentResolver, - private val executorService: ExecutorService): ViewModel() { +class HeadersViewModel(application: Application, private val urlString: String, private val userAgent: String, private val localeString: String, private val proxy: Proxy, private val contentResolver: ContentResolver, + private val executorService: ExecutorService): AndroidViewModel(application) { // Initialize the mutable live data variables. private val mutableLiveDataSourceStringArray = MutableLiveData>() private val mutableLiveDataErrorString = MutableLiveData() @@ -43,7 +45,7 @@ class HeadersViewModel(private val urlString: String, private val userAgent: Str val getSourceBackgroundTask = GetHeadersBackgroundTask() // Get the headers. - executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(urlString, userAgent, localeString, proxy, contentResolver, this, + executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(application, urlString, userAgent, localeString, proxy, contentResolver, this, false)) } } @@ -74,7 +76,7 @@ class HeadersViewModel(private val urlString: String, private val userAgent: Str val getSourceBackgroundTask = GetHeadersBackgroundTask() // Get the headers. - executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(urlString, userAgent, localeString, proxy, contentResolver, this, + executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(getApplication(), urlString, userAgent, localeString, proxy, contentResolver, this, ignoreSslErrors)) } } }