Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Domi04151309 committed Jan 11, 2024
1 parent 04a2b00 commit 66580c1
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class MainActivity : BaseActivity() {
offset: Int,
dynamicSummary: Boolean,
) {
for (i in 0 until states.size) {
for (i in states.indices) {
if (states[i] != null) {
adapter.updateSwitch(
i + offset,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.domi04151309.home.activities

import android.content.Intent
import android.content.SharedPreferences
import android.net.Uri
import android.os.Build
import android.os.Bundle
Expand All @@ -26,25 +25,6 @@ class SettingsActivity : BaseActivity() {
}

class GeneralPreferenceFragment : PreferenceFragmentCompat() {
private val prefsChangedListener =
SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
if (key == P.PREF_THEME) requireActivity().recreate()
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(
prefsChangedListener,
)
}

override fun onDestroy() {
super.onDestroy()
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(
prefsChangedListener,
)
}

override fun onCreatePreferences(
savedInstanceState: Bundle?,
rootKey: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class ShortcutHueRoomActivity : BaseActivity(), RecyclerViewHelperInterface {
recyclerViewInterface: HomeRecyclerViewHelperInterface?,
) {
if (holder.response != null) {
@Suppress("UNCHECKED_CAST")
recyclerView.adapter =
SimpleListAdapter(
holder.response as List<SimpleListItem>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class ShortcutHueSceneActivity : BaseActivity(), RecyclerViewHelperInterface {
recyclerViewInterface: HomeRecyclerViewHelperInterface?,
) {
if (holder.response != null) {
@Suppress("UNCHECKED_CAST")
recyclerView.adapter =
SimpleListAdapter(
holder.response as List<SimpleListItem>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class ShortcutTasmotaActivity : BaseActivity(), RecyclerViewHelperInterface {
recyclerViewInterface: HomeRecyclerViewHelperInterface?,
) {
if (holder.response != null) {
@Suppress("UNCHECKED_CAST")
recyclerView.adapter =
SimpleListAdapter(
holder.response as List<SimpleListItem>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class HueLampListAdapter(
}

val changed = mutableListOf<Int>()
for (i in 0 until items.size) {
for (i in items.indices) {
if (items[i].hidden != newItems[i].hidden) {
changed.add(i)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class HueSceneLampListAdapter(
}

fun changeSceneBrightness(brightness: String) {
for (i in 0 until items.size) {
for (i in items.indices) {
items[i].brightness = brightness
if (items[i].state) notifyItemChanged(i)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class HueScenesFragment :
try {
val gridItems: ArrayList<SceneGridItem> = ArrayList(response.length())
val scenes: List<Pair<String, String>> = getScenes(response)
if (scenes.size > 0) {
if (scenes.isNotEmpty()) {
var completedRequests = 0
for (i in 0 until scenes.size) {
for (i in scenes.indices) {
queue.add(
JsonObjectRequest(
Request.Method.GET,
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/io/github/domi04151309/home/helpers/P.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package io.github.domi04151309.home.helpers

internal object P {
const val PREF_THEME = "theme"
const val PREF_THEME_DEFAULT = "auto"
const val PREF_COLUMNS = "columns"
const val PREF_COLUMNS_DEFAULT = "auto"
const val PREF_CONTROLS_AUTH = "controls_auth"
Expand Down

0 comments on commit 66580c1

Please sign in to comment.