genious7 / FanFictionReader

An android app that improves browsing Fan Fiction stories on a mobile device
GNU General Public License v3.0
56 stars 24 forks source link

My Library menu: remember filter settings #48

Closed orionlee closed 5 years ago

orionlee commented 5 years ago

Closes #43 , adopting behavior (1)

genious7 commented 5 years ago

Had to revert this commit; it was causing crashes under some uses. Currently, I'm rather busy so I have not performed any in depth debugging. That being said, I'm not sure if the selected approach is the best one; the fandom filter may end up "off" if new fandoms are added whilst browsing.

orionlee commented 5 years ago

@genious7 I should be able to investigate the issue if there is any log / stacktrace.

genious7 commented 5 years ago
#0. Crashed: main
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
       at android.app.ActivityThread.-wrap11(Unknown Source)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6944)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

--

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.spicymango.fanfictionreader/com.spicymango.fanfictionreader.menu.librarymenu.LibraryMenuActivity}: java.lang.IndexOutOfBoundsException: The requested position is greater than the number of spinner positions
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
       at android.app.ActivityThread.-wrap11(Unknown Source)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6944)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Caused by java.lang.IndexOutOfBoundsException: The requested position is greater than the number of spinner positions
       at com.spicymango.fanfictionreader.menu.storymenu.FilterDialog.SpinnerData.setSelected(SourceFile:170)
       at com.spicymango.fanfictionreader.menu.librarymenu.LibraryLoader.filter(SourceFile:111)
       at com.spicymango.fanfictionreader.menu.librarymenu.LibraryMenuActivity$LibraryMenuFragment.onFilter(SourceFile:403)
       at com.spicymango.fanfictionreader.menu.librarymenu.LibraryMenuActivity.doFilter(SourceFile:113)
       at com.spicymango.fanfictionreader.menu.librarymenu.LibraryMenuActivity.onStart(SourceFile:102)
       at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1340)
       at android.app.Activity.performStart(Activity.java:7200)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2920)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
       at android.app.ActivityThread.-wrap11(Unknown Source)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6944)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
orionlee commented 5 years ago

@genious7 You're right in that the PR can fail when the list of categories (fandoms) changes in My Library. The remaining filters are okay, as their options are static.

As you suggest, one way to make it work is instead of storing the selected filters by index, store the semantic value. Codewise, that means instead of storing mSelected (int), store mFilters (String) of the SpinnerData.