removed ui blocking methods in changelogs

This commit is contained in:
X1nto 2020-08-08 12:02:28 +04:00
parent f03e681ea8
commit bce75c1b22
3 changed files with 17 additions and 21 deletions

View File

@ -8,8 +8,9 @@ import android.widget.TextView
import androidx.fragment.app.Fragment
import com.vanced.manager.R
import com.vanced.manager.utils.InternetTools
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
class ManagerChangelogFragment : Fragment() {
@ -22,11 +23,9 @@ class ManagerChangelogFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
runBlocking {
launch {
val changelog = InternetTools.getObjectFromJson("https://x1nto.github.io/VancedFiles/manager.json", "changelog")
view.findViewById<TextView>(R.id.manager_changelog).text = changelog
}
CoroutineScope(Dispatchers.IO).launch {
val changelog = InternetTools.getObjectFromJson("https://x1nto.github.io/VancedFiles/manager.json", "changelog")
view.findViewById<TextView>(R.id.manager_changelog).text = changelog
}
}
}

View File

@ -9,8 +9,9 @@ import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import com.vanced.manager.R
import com.vanced.manager.utils.InternetTools
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
class MicrogChangelogFragment : Fragment() {
@ -23,12 +24,9 @@ class MicrogChangelogFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
runBlocking {
launch {
val baseUrl = PreferenceManager.getDefaultSharedPreferences(activity).getString("install_url", InternetTools.baseUrl)
view.findViewById<TextView>(R.id.microg_changelog).text = InternetTools.getObjectFromJson("$baseUrl/microg.json", "changelog")
}
CoroutineScope(Dispatchers.IO).launch {
val baseUrl = PreferenceManager.getDefaultSharedPreferences(activity).getString("install_url", InternetTools.baseUrl)
view.findViewById<TextView>(R.id.microg_changelog).text = InternetTools.getObjectFromJson("$baseUrl/microg.json", "changelog")
}
}
}

View File

@ -9,8 +9,9 @@ import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import com.vanced.manager.R
import com.vanced.manager.utils.InternetTools
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
class VancedChangelogFragment : Fragment() {
@ -23,14 +24,12 @@ class VancedChangelogFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
runBlocking {
launch {
val vancedVersion = activity?.let { InternetTools.getJsonString("vanced.json", "version", it).replace('.', '_') }
val baseUrl = PreferenceManager.getDefaultSharedPreferences(activity).getString("install_url", InternetTools.baseUrl)
CoroutineScope(Dispatchers.IO).launch {
val vancedVersion = activity?.let { InternetTools.getJsonString("vanced.json", "version", it).replace('.', '_') }
val baseUrl = PreferenceManager.getDefaultSharedPreferences(activity).getString("install_url", InternetTools.baseUrl)
val changelog = InternetTools.getObjectFromJson("$baseUrl/changelog/$vancedVersion.json", "message")
view.findViewById<TextView>(R.id.vanced_changelog).text = changelog
}
val changelog = InternetTools.getObjectFromJson("$baseUrl/changelog/$vancedVersion.json", "message")
view.findViewById<TextView>(R.id.vanced_changelog).text = changelog
}
}
}