emansih / FireflyMobile

Mobile Application for Firefly III written in Kotlin
GNU General Public License v3.0
323 stars 48 forks source link

sharedPref dateTimeFormat cannot be cast to String #202

Open poiintt opened 2 years ago

poiintt commented 2 years ago

After selecting a Date Time Format in the settings this error occurs:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: xyz.hisname.fireflyiii.debug, PID: 24736
    java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:302)
        at xyz.hisname.fireflyiii.data.local.pref.AppPref.getDateTimeFormat(AppPref.kt:136)

This gets saved in the sharedPrefs after selecting the Date Time Format:


<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
    ...
    <int name="dateTimeFormat" value="1" />
</map>

This is line is causing the error: https://github.com/emansih/FireflyMobile/blob/33032edac20dd0b2eaca79046a1b386c80242176/app/src/main/java/xyz/hisname/fireflyiii/data/local/pref/AppPref.kt#L136

Possible fix:

get() = sharedPref.getInt("dateTimeFormat", 0)