This commit is contained in:
tom5079
2021-06-18 07:27:33 +09:00
parent 760194bde8
commit 237d5accc5
2 changed files with 11 additions and 6 deletions

View File

@@ -26,7 +26,10 @@ import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.swiperefreshlayout.widget.CircularProgressDrawable
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import okhttp3.*
import org.kodein.di.DIAware
import org.kodein.di.android.x.closestDI
@@ -59,6 +62,10 @@ class ManageFavoritesFragment : PreferenceFragmentCompat(), DIAware {
.build()
).build()
MainScope().launch {
it.icon = CircularProgressDrawable(context)
}
client.newCall(request).enqueue(object: Callback {
override fun onFailure(call: Call, e: IOException) {
val view = view ?: return
@@ -71,6 +78,10 @@ class ManageFavoritesFragment : PreferenceFragmentCompat(), DIAware {
return
}
MainScope().launch {
it.icon = null
}
Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
putExtra(Intent.EXTRA_TEXT, response.body?.use { it.string() }?.replace("\n", ""))

View File

@@ -135,8 +135,6 @@ class SavedSourceSet(private val file: File) {
@Synchronized
fun add(source: String, value: String) {
load()
_map[source]?.remove(value)
if (!_map.containsKey(source))
@@ -149,8 +147,6 @@ class SavedSourceSet(private val file: File) {
@Synchronized
fun addAll(from: Map<String, Set<String>>) {
load()
for (source in from.keys) {
if (_map.containsKey(source)) {
_map[source]!!.removeAll(from[source]!!)
@@ -165,8 +161,6 @@ class SavedSourceSet(private val file: File) {
@Synchronized
fun remove(source: String, value: String): Boolean {
load()
return (_map[source]?.remove(value) ?: false).also {
save()
}