Skip to content

Commit

Permalink
better animation?
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-Mr committed Apr 20, 2024
1 parent c6908cd commit 99d5218
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/src/main/java/com/maary/shareas/WallpaperViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ class WallpaperViewModel : ViewModel() {
private val _upscaleProgressState = MutableStateFlow(0)
val upscaleProgressState = _upscaleProgressState.asStateFlow()

fun getUpscaleProgress(): Int {
return _upscaleProgressState.value
}

private val _upscaleToggleState = MutableStateFlow(upscaleToggle)
val upscaleToggleState = _upscaleToggleState.asStateFlow()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.activity.OnBackPressedCallback
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
Expand Down Expand Up @@ -63,8 +64,11 @@ class UpscaleFragment : Fragment() {
viewModel.upscale(requireContext(), binding.menuChooseModelTextview.text.toString())
}
false -> {
activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
binding.buttonUpscaleToggle.setIconResource(R.drawable.ic_play)
binding.progressUpscale.setProgressCompat(0, true)
if (viewModel.getUpscaleProgress() != 100) {
binding.progressUpscale.setProgressCompat(0, true)
}
}
}
}
Expand Down Expand Up @@ -108,6 +112,7 @@ class UpscaleFragment : Fragment() {
binding.menuChooseModelTextview.setText(resources.getStringArray(R.array.model_names)[2], false)

binding.buttonUpscaleToggle.setOnClickListener {
activity?.window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
viewModel.upscaleToggle = !viewModel.upscaleToggle
}

Expand Down

0 comments on commit 99d5218

Please sign in to comment.