Skip to content

Commit

Permalink
fix: discord status code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelonion committed Mar 1, 2024
1 parent a5567ef commit 5e307bb
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -808,40 +808,40 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
reload()
}

val imageSwitcher: ImageView = findViewById(R.id.imageSwitcher)
imageSwitcher.visibility = View.VISIBLE
val temp3: String = PrefManager.getVal(PrefName.DiscordStatus)
var temp5 = when (temp3) {
binding.imageSwitcher.visibility = View.VISIBLE
var initialStatus = when (PrefManager.getVal<String>(PrefName.DiscordStatus)) {
"online" -> R.drawable.discord_status_online
"idle" -> R.drawable.discord_status_idle
"dnd" -> R.drawable.discord_status_dnd
else -> R.drawable.discord_status_online
}
imageSwitcher.setImageResource(temp5)
binding.imageSwitcher.setImageResource(initialStatus)

val zoomInAnimation = AnimationUtils.loadAnimation(this, R.anim.bounce_zoom)
imageSwitcher.setOnClickListener {
temp5 = when (temp5) {
R.drawable.discord_status_online -> R.drawable.discord_status_idle
R.drawable.discord_status_idle -> R.drawable.discord_status_dnd
R.drawable.discord_status_dnd -> R.drawable.discord_status_online
binding.imageSwitcher.setOnClickListener {
var status = "online"
initialStatus = when (initialStatus) {
R.drawable.discord_status_online -> {
status = "idle"
R.drawable.discord_status_idle
}
R.drawable.discord_status_idle -> {
status = "dnd"
R.drawable.discord_status_dnd
}
R.drawable.discord_status_dnd -> {
status = "online"
R.drawable.discord_status_online
}
else -> R.drawable.discord_status_online
}

val status = when (temp5) {
R.drawable.discord_status_online -> "online"
R.drawable.discord_status_idle -> "idle"
R.drawable.discord_status_dnd -> "dnd"
else -> "online"
}

PrefManager.setVal(PrefName.DiscordStatus, status)
imageSwitcher.setImageResource(temp5)
imageSwitcher.startAnimation(zoomInAnimation)
binding.imageSwitcher.setImageResource(initialStatus)
binding.imageSwitcher.startAnimation(zoomInAnimation)
}
} else {
val imageSwitcher: ImageView = findViewById(R.id.imageSwitcher)
imageSwitcher.visibility = View.GONE
binding.imageSwitcher.visibility = View.GONE
binding.settingsDiscordAvatar.setImageResource(R.drawable.ic_round_person_24)
binding.settingsDiscordUsername.visibility = View.GONE
binding.settingsDiscordLogin.setText(R.string.login)
Expand Down

0 comments on commit 5e307bb

Please sign in to comment.