Closed AEFeinstein closed 9 years ago
I was working on this, but I am not quite sure how to build it.
I was trying to figure out how to fill the cursor with the proper data whether the fragment is the list of formats, or the banned list. I was using a string variable to store the selected format, and the solution to the problem I came up with was to check if the format string is null and then fill the cursor with the formats, then I would have to check again to construct BannedItems for the format list, instead of the banned lists.
This solution seems wrong to me. For the RulesItems there is only one dbadapter method to fill the cursor, and one block for constructing the RulesItems, whether it is the list of sections, or the actual rules details. I could not see a way to do this for the BannedItems, that is why I wanted to use if(format==null) blocks for the dbadapter calls and BannedItem constructors.
I apologize if my question is poorly worded or vague, but I really wanted to complete this enhancement, and I just did not know how to proceed.
Thanks.
I think you want to do a similar thing as with the BannedItem inner class, but make a new inner class called LegalSetsItem. Having each LegalSetItem have a format, except the header would have a null one, sounds fine
As for the cursor, this template should work, just replace actual table and column names with the static final strings, and add the GROUP_CONCAT part:
SELECT sets.suggest_text_1 FROM legal_sets JOIN sets ON legal_sets.expansion = sets.code where legal_sets.format = 'Modern'
Thanks for the help!
At first I was unclear what you meant. I thought you wanted the banned and restricted cards to fall under set headings, so I did that. Then I realized you just wanted a banned and restricted list, as well as a list of legal sets in the same fragment.
Everything was working until 6c5b9dd22145130304d34f95152a72a02c78c5b8 and now I get indexoutofbounds error from RulesListAdapter.getPositionForSection when I tap extended, legacy, or modern. All I did was change the query and altered BannedItem a little, so I don't understand how I introduced this.
I want to be helpful to you in building MTGFamiliar and I am very grateful that I am allowed to work on an app that I love, but I don't want to have you do a bunch of work just to help me out. I was just hoping you would have a quick insight for me.
Thanks.
I'll look at it in a few days. I'm a little busy right now. Please continue contributing. It ends up being less work for me in the long run!
I checked out 6c5b9dd22145130304d34f95152a72a02c78c5b8 and was not able to replicate the issue you described. Everything looks pretty good to me. Try cleaning, rebuilding, and reloading the APK maybe?
I cleaned, rebuilded, reloaded APK with same result. Then I completely removed android studio and mtg-familiar/ from my machine and reloaded. Then I rewrote the changes to this: dd9d5ff2cad83dd173db3510e6fbff136d35bd84.
Same issue. When I get to the list of formats, tapping the first two (Block and Commander), or the last two (Standard and Vintage), brings me to the banned list as expected, but tapping Extended, Legacy, or Modern stops the app giving me this in logcat:
Process: com.gelakinetic.mtgfam, PID: 12902 java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 at com.gelakinetic.mtgfam.fragments.RulesFragment$RulesListAdapter.getPositionForSection(RulesFragment.java:831) ... ...
I am not sure how to proceed with debugging, I took a look at the lines that logcat referenced but I am not really understanding what is happening. After that, I am not sure what steps to take to debug this.
Can you paste the logcat stack trace here?
11-17 09:30:35.322 29426-29426/com.gelakinetic.mtgfam E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.gelakinetic.mtgfam, PID: 29426 java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 at com.gelakinetic.mtgfam.fragments.RulesFragment$RulesListAdapter.getPositionForSection(RulesFragment.java:831) at android.widget.FastScroller.getPosFromItemCount(FastScroller.java:1174) at android.widget.FastScroller.onItemCountChanged(FastScroller.java:453) at android.widget.AbsListView.onLayout(AbsListView.java:2546) at android.view.View.layout(View.java:15762) at android.view.ViewGroup.layout(ViewGroup.java:4867) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531) at android.widget.LinearLayout.onLayout(LinearLayout.java:1440) at android.view.View.layout(View.java:15762) at android.view.ViewGroup.layout(ViewGroup.java:4867) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) at android.widget.FrameLayout.onLayout(FrameLayout.java:388) at android.view.View.layout(View.java:15762) at android.view.ViewGroup.layout(ViewGroup.java:4867) at com.gelakinetic.mtgfam.helpers.IndeterminateRefreshLayout.onLayout(IndeterminateRefreshLayout.java:130) at android.view.View.layout(View.java:15762) at android.view.ViewGroup.layout(ViewGroup.java:4867) at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:887) at android.view.View.layout(View.java:15762) at android.view.ViewGroup.layout(ViewGroup.java:4867) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) at android.widget.FrameLayout.onLayout(FrameLayout.java:388) at android.view.View.layout(View.java:15762) at android.view.ViewGroup.layout(ViewGroup.java:4867) at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:459) at android.view.View.layout(View.java:15762) at android.view.ViewGroup.layout(ViewGroup.java:4867) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) at android.widget.FrameLayout.onLayout(FrameLayout.java:388) at android.view.View.layout(View.java:15762) at android.view.ViewGroup.layout(ViewGroup.java:4867) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2356) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2069) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6632) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:814) at android.view.Choreographer.doCallbacks(Choreographer.java:614) at android.view.Choreographer.doFrame(Choreographer.java:584) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:800) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5487) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method)
Oh, this has something to do with the fast scroller for the glossary (when you scroll and grab the bar to show alphabetical indices). It looks like the following code from line 744 only checks for RuleItems, where it would have to also check for BannedItem (and any other *Items added).
Replace:
boolean isGlossary = true;
for (DisplayItem item : items) {
if (RuleItem.class.isInstance(item)) {
isGlossary = false;
break;
}
}
With:
boolean isGlossary = true;
for (DisplayItem item : items) {
if (RuleItem.class.isInstance(item) || BannedItem.class.isInstance(item)) {
isGlossary = false;
break;
}
}
Merged in 2f94e0dfc021f2a4263befec5edb060acbec6f59
In the same vein as the banned & restricted display items in the rules fragment, we could show a list of sets legal for a given format. It would be nice to display the sets interleaved with the banned & restricted items.
A hierarchical view would make it more navigable. The first view would just have a list of formats, and tapping a format would show a new page with the banned & restricted cards, as well as a list of legal sets.