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

View File

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