-
Notifications
You must be signed in to change notification settings - Fork 548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Q] Mimic an ExpandableListView #153
Comments
For example I tried to use one class extending AbstractExpandableHeaderItem and one extending AbstractSectionableItem, but I always run into java.lang.ClassCastException: com.faendir.lightning_launcher.multitool.scriptmanager.ScriptGroupLayoutItem$ViewHolder cannot be cast to com.faendir.lightning_launcher.multitool.scriptmanager.ScriptLayoutItem$ViewHolder
at com.faendir.lightning_launcher.multitool.scriptmanager.ScriptLayoutItem.bindViewHolder(ScriptLayoutItem.java:20)
at eu.davidea.flexibleadapter.FlexibleAdapter.onBindViewHolder(FlexibleAdapter.java:1136)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5801)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5037)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4913)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1414)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3260)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3069)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3518)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:131)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1319)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:817)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1191)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16630)
... My setup code is ArrayList<AbstractFlexibleItem> testList = new ArrayList<>();
ScriptGroupLayoutItem groupLayoutItem = new ScriptGroupLayoutItem(new ScriptGroup("TestGroup",true));
ScriptLayoutItem scriptLayoutItem = new ScriptLayoutItem(groupLayoutItem,s);
groupLayoutItem.addSubItem(scriptLayoutItem);
testList.add(groupLayoutItem);
FlexibleAdapter<AbstractFlexibleItem> flexibleAdapter = new FlexibleAdapter<>(testList);
flexibleAdapter.expandItemsAtStartUp()
.setAutoScrollOnExpand(true)
.setAutoCollapseOnExpand(false)
.setAnimationOnScrolling(true)
.setAnimationOnReverseScrolling(true);
recyclerView.setAdapter(flexibleAdapter); |
Hello @F43nd1r! Then, be sure to use only the SNAPSHOT release until next beta. Regarding the example, the code for creating items in the demoApp didn't help you? |
Is that documented somewhere? If yes, my bad. If not, it should be.
After several hours I slowly start to understand how it works. The relevant code is split up in so many classes, it really takes some time to seek through it all (particularly the DatabaseService isn't used via reference but via singleton, which makes it very hard to understand the correlation). |
Okay now I have another problem: I can't collapse the group, whenever the item should be hidden it gets duplicated instead. |
Can you also write some code here? Layout resource is documented in item interfaces wiki page. You actually don't need to know how the database list is provided in the demo app, you can initialize the list how you want, that is just a demo to easily show different examples. What you need to know how to create the classes of the items and the view holders with the relative listeners. But wiki pages also explain everything. |
Code is here. Initialization is inside the |
I've analyzed your code, but I don't find anything wrong for now. I also published a new SNAPSHOT with also a little fix for multilevel expandable, but I don't think it is related to your problem. |
07-31 05:28:58.818 1929-1929/com.faendir.lightning_launcher.multitool I/FlexibleAdapter: Mapped viewType 17367046 from ScriptGroupLayoutItem
07-31 05:28:58.819 1929-1929/com.faendir.lightning_launcher.multitool I/FlexibleAdapter: Mapped viewType 17367043 from ScriptLayoutItem
07-31 05:30:24.759 1929-1929/com.faendir.lightning_launcher.multitool V/FlexibleAdapter: Request to Collapse on position=0 expanded=true hasSubItemsSelected=false
07-31 05:30:24.759 1929-1929/com.faendir.lightning_launcher.multitool V/FlexibleAdapter: Collapsed 1 subItems on position 0
07-31 05:30:26.733 1929-1929/com.faendir.lightning_launcher.multitool V/FlexibleAdapter: Expanded 1 subItems on position=0 This looks perfectly fine, but sadly doesn't mirror the behaviour. I still have two items afterwards. |
I'm trying your app but I can't have the list you have. How can I have the list to test?
|
However the problem is here, dear @F43nd1r:
This equals method returns always @Override
public boolean equals(Object o) {
return group.equals(o);
} And also this is documented, for this time it passes, but for the next time please read the javaDoc of the methods and also the Wiki pages. However, I would like to try your app, but I can't have the list loaded :-( |
I feel so dumb right now... I'm sorry. Yes it works now.
I'm sorry, this app is a helper for Lightning Launcher and requires another low-level helper, the Repository Importer to work. It won't be able to do anything without these, because the list of scripts displayed here is the list of scripts in the launcher (and the importer provides the service which loads these scripts from it). |
Well the request was mainly to resolve your problem. Just if you want to mention the usage of this library in your app and to add your app in the main page, I will thank you. If you decide to use it eventually. |
Of course your library will be added to the credits section in the play store, if I publish an update with it. (Right now there is no 'About' section in the app itself and I'm not sure if I'm legally required to add it, but if it exists some time, it'll be added there too.) For now I have to get a lot of things working first. Right now I'm working on multi selection. You might see another issue from me in the future if I can't sort it out with help of the docs & sample. |
Ok, the library is still in beta, something might not work as expected, even if, now it seems quite stable. |
I want to create a view that is similar to an ExpandableListView.
I do not understand how I would approach this. I have read the guide on sections, but whatever I tried didn't work at all or behaved really weird.
Can you give me a simple (!) example how to create expandable (text-only) groups with (text-only) childs?
The text was updated successfully, but these errors were encountered: