mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2025-03-25 17:43:58 +03:00
feat: add rotate anim to profile update btn
This commit is contained in:
parent
b091a87a37
commit
9773ea73d4
@ -105,7 +105,7 @@ class MetaFeatureSettingsActivity : BaseActivity<MetaFeatureSettingsDesign>() {
|
|||||||
val ext = "." + displayName.substringAfterLast(".")
|
val ext = "." + displayName.substringAfterLast(".")
|
||||||
if(!validDatabaseExtensions.contains(ext))
|
if(!validDatabaseExtensions.contains(ext))
|
||||||
{
|
{
|
||||||
val dialog = MaterialAlertDialogBuilder(this)
|
MaterialAlertDialogBuilder(this)
|
||||||
.setTitle("Unknown Database Format")
|
.setTitle("Unknown Database Format")
|
||||||
.setMessage("Only ${validDatabaseExtensions.joinToString("/")} are supported")
|
.setMessage("Only ${validDatabaseExtensions.joinToString("/")} are supported")
|
||||||
.setPositiveButton("OK"){ _, _ -> }
|
.setPositiveButton("OK"){ _, _ -> }
|
||||||
|
@ -6,8 +6,10 @@ import com.github.kr328.clash.common.util.ticker
|
|||||||
import com.github.kr328.clash.design.ProfilesDesign
|
import com.github.kr328.clash.design.ProfilesDesign
|
||||||
import com.github.kr328.clash.service.model.Profile
|
import com.github.kr328.clash.service.model.Profile
|
||||||
import com.github.kr328.clash.util.withProfile
|
import com.github.kr328.clash.util.withProfile
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.coroutines.selects.select
|
import kotlinx.coroutines.selects.select
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class ProfilesActivity : BaseActivity<ProfilesDesign>() {
|
class ProfilesActivity : BaseActivity<ProfilesDesign>() {
|
||||||
@ -34,9 +36,16 @@ class ProfilesActivity : BaseActivity<ProfilesDesign>() {
|
|||||||
startActivity(NewProfileActivity::class.intent)
|
startActivity(NewProfileActivity::class.intent)
|
||||||
ProfilesDesign.Request.UpdateAll ->
|
ProfilesDesign.Request.UpdateAll ->
|
||||||
withProfile {
|
withProfile {
|
||||||
queryAll().forEach { p ->
|
try {
|
||||||
if (p.imported && p.type != Profile.Type.File)
|
queryAll().forEach { p ->
|
||||||
update(p.uuid)
|
if (p.imported && p.type != Profile.Type.File)
|
||||||
|
update(p.uuid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
design.finishUpdateAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is ProfilesDesign.Request.Update ->
|
is ProfilesDesign.Request.Update ->
|
||||||
|
@ -4,6 +4,8 @@ import android.app.Dialog
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.view.animation.Animation
|
||||||
|
import android.view.animation.AnimationUtils
|
||||||
import com.github.kr328.clash.design.adapter.ProfileAdapter
|
import com.github.kr328.clash.design.adapter.ProfileAdapter
|
||||||
import com.github.kr328.clash.design.databinding.DesignProfilesBinding
|
import com.github.kr328.clash.design.databinding.DesignProfilesBinding
|
||||||
import com.github.kr328.clash.design.databinding.DialogProfilesMenuBinding
|
import com.github.kr328.clash.design.databinding.DialogProfilesMenuBinding
|
||||||
@ -29,6 +31,13 @@ class ProfilesDesign(context: Context) : Design<ProfilesDesign.Request>(context)
|
|||||||
.inflate(context.layoutInflater, context.root, false)
|
.inflate(context.layoutInflater, context.root, false)
|
||||||
private val adapter = ProfileAdapter(context, this::requestActive, this::showMenu)
|
private val adapter = ProfileAdapter(context, this::requestActive, this::showMenu)
|
||||||
|
|
||||||
|
private var allUpdating: Boolean
|
||||||
|
get() = adapter.states.allUpdating;
|
||||||
|
set(value) {
|
||||||
|
adapter.states.allUpdating = value
|
||||||
|
}
|
||||||
|
private val rotateAnimation : Animation = AnimationUtils.loadAnimation(context, R.anim.rotate_infinite)
|
||||||
|
|
||||||
override val root: View
|
override val root: View
|
||||||
get() = binding.root
|
get() = binding.root
|
||||||
|
|
||||||
@ -84,7 +93,14 @@ class ProfilesDesign(context: Context) : Design<ProfilesDesign.Request>(context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun requestUpdateAll() {
|
fun requestUpdateAll() {
|
||||||
|
allUpdating = true;
|
||||||
requests.trySend(Request.UpdateAll)
|
requests.trySend(Request.UpdateAll)
|
||||||
|
changeUpdateAllButtonStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun finishUpdateAll() {
|
||||||
|
allUpdating = false;
|
||||||
|
changeUpdateAllButtonStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun requestCreate() {
|
fun requestCreate() {
|
||||||
@ -118,4 +134,12 @@ class ProfilesDesign(context: Context) : Design<ProfilesDesign.Request>(context)
|
|||||||
|
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun changeUpdateAllButtonStatus() {
|
||||||
|
if (allUpdating) {
|
||||||
|
binding.updateView.startAnimation(rotateAnimation)
|
||||||
|
} else {
|
||||||
|
binding.updateView.clearAnimation()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,6 +4,8 @@ import android.content.Context
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.kr328.clash.design.databinding.AdapterProfileBinding
|
import com.github.kr328.clash.design.databinding.AdapterProfileBinding
|
||||||
|
import com.github.kr328.clash.design.model.ProfilePageState
|
||||||
|
import com.github.kr328.clash.design.model.ProxyPageState
|
||||||
import com.github.kr328.clash.design.ui.ObservableCurrentTime
|
import com.github.kr328.clash.design.ui.ObservableCurrentTime
|
||||||
import com.github.kr328.clash.design.util.layoutInflater
|
import com.github.kr328.clash.design.util.layoutInflater
|
||||||
import com.github.kr328.clash.service.model.Profile
|
import com.github.kr328.clash.service.model.Profile
|
||||||
@ -18,6 +20,7 @@ class ProfileAdapter(
|
|||||||
private val currentTime = ObservableCurrentTime()
|
private val currentTime = ObservableCurrentTime()
|
||||||
|
|
||||||
var profiles: List<Profile> = emptyList()
|
var profiles: List<Profile> = emptyList()
|
||||||
|
val states = ProfilePageState()
|
||||||
|
|
||||||
fun updateElapsed() {
|
fun updateElapsed() {
|
||||||
currentTime.update()
|
currentTime.update()
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.github.kr328.clash.design.model
|
||||||
|
|
||||||
|
class ProfilePageState {
|
||||||
|
var allUpdating = false
|
||||||
|
}
|
11
design/src/main/res/anim/rotate_infinite.xml
Normal file
11
design/src/main/res/anim/rotate_infinite.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:duration="1000"
|
||||||
|
android:fromDegrees="360"
|
||||||
|
android:pivotX="50%"
|
||||||
|
android:pivotY="50%"
|
||||||
|
android:toDegrees="0"
|
||||||
|
android:repeatCount="infinite"
|
||||||
|
android:interpolator="@android:anim/cycle_interpolator" />
|
||||||
|
</set>
|
Loading…
x
Reference in New Issue
Block a user