Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Commit

Permalink
Fix category saving
Browse files Browse the repository at this point in the history
Signed-off-by: enricocid <[email protected]>
  • Loading branch information
enricocid committed Feb 24, 2022
1 parent 18d9e76 commit 98f56ec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.iven.vectorify.ui.PreviewActivity.Companion.TEMP_VECTOR
import com.iven.vectorify.ui.PreviewActivity.Companion.TEMP_VECTOR_COLOR
import com.iven.vectorify.ui.PreviewActivity.Companion.TEMP_V_OFFSET
import com.iven.vectorify.utils.Utils
import com.iven.vectorify.utils.VectorsCategories
import com.maxkeppeler.sheets.color.ColorSheet
import dev.chrisbanes.insetter.Insetter
import dev.chrisbanes.insetter.windowInsetTypesOf
Expand Down Expand Up @@ -264,7 +265,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
TEMP_BACKGROUND_COLOR to mTempBackgroundColor,
TEMP_VECTOR_COLOR to mTempVectorColor,
TEMP_VECTOR to mTempVector,
TEMP_CATEGORY to mTempCategory,
TEMP_CATEGORY to VectorsCategories.safeGetVectorCategory(mTempVector),
TEMP_SCALE to mTempScale,
TEMP_H_OFFSET to mTempHorizontalOffset,
TEMP_V_OFFSET to mTempVerticalOffset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ object VectorsCategories {
//https://iconscout.com/icon/naruto
//https://github.com/PotatoProject/website/blob/master/src/assets/

@JvmStatic
fun safeGetVectorCategory(vector: Int): Int {
val categories = listOf(
TECH, SYMBOLS, ANIMALS, EMOTICONS, FUN, FOOD, NATURE,
WEATHER, SPORT, MATH, SCIENCE, CHERNOFF, MUSIC, NERDY,
BUILDINGS, ALERT, ALPHABET, ROMAN, ZODIAC, OTHERS
)

categories.iterator().withIndex().run {
while (hasNext()) {
val item = next()
if (item.value.contains(vector)) {
return item.index
}
}
}
return 0
}

@JvmStatic
val TECH = listOf(
R.drawable.android,
Expand Down

0 comments on commit 98f56ec

Please sign in to comment.