Comments (11)
updated
So I have some of my own ideas on this too, I've added them below, but first I'd like to ask for a clarification.
How should your proposal handle multiple configurations of the same SLM?
Okay, on to my thoughts.
I have actually been thinking about this lots. First, this was because I wanted to move SLM referencing and configuration to only the first item in the section. I remember there was some technical reason why I couldn't, but I can't remember it right now and I forgot to write it down, so I guess it warrants another look.
I completely agree with the issue of verbosity and boilerplate in initialisation. My thoughts actually turned to an idea of adding enum options to the sectionManager attr. This has also included adding pass through attrs for SLM configuration through attrs too.
For example, configuration for using grid layout on content items:
<!-- TextView as a section header. -->
<TextView
app:slm_sectionManager="grid"
app:slm_grid_numColumns="4"
app:slm_grid_minimumColumnWidth="96dp"
/>
or linear layout:
<TextView
app:slm_sectionManager="linear"
/>
This would also mean configuration through layout params:
GridSLM.LayoutParams params =
new GridSLM.LayoutParams(viewHolder.getLayoutParams());
params.setSLM(GridSLM.TAG);
params.setColumnWidthResId(R.dimen.minumum_column_width);
// or
params.setNumColumns(4);
For custom SLMs there still needs to be a key to identify them. Perhaps an SLM could be registered against a String value to make identification easy, or the documentation can encourage people to use R.integer.my_slm_id, or perhaps R.id.my_slm.
XML for custom SLMs could look like this:
<TextView
app:slm_sectionManager="@+id/my_slm"
/>
and initialisation:
LayoutManager layoutManager;
layoutManager = LayoutManager.addSLM(R.id.my_slm, new MySLM()).build();
or
layoutManager = new LayoutManager();
layoutManager.addSLM(R.id.my_slm, new MySLM());
recyclerView.setLayoutManager(layoutManager);
configuring layout params:
LayoutManager.LayoutParams params = viewHolder.getLayoutParams();
params.setSLM(R.id.my_slm);
from superslim.
Ah yes, I just looked through the code and I've rediscovered why the section manager needs to be referenced, and configured, in every item. The entry points for calculating the scroll indicator values don't provide the recycler so I can't get the first item of a section if it isn't current displayed.
However, I guess I can get around it by caching section data. Now that I think about it, it seems feasible. #42.
from superslim.
I like the enum, very straightforward. Perhaps add an abstract enum to SectionLayoutManager, forcing all SLM's to implement/extend the enum themselves. I haven't written much in terms of custom xml tags, but would this allow us to do the following?
<TextView
app:slm_sectionManager="myEnum"
/>
from superslim.
That would be nice, unfortunately the enums are defined here https://github.com/TonicArtos/SuperSLiM/blob/master/library/src/main/res/values/attrs.xml
from superslim.
I can do something like
<attr name="slm_sectionManager" format="enum|string|reference" />
but I think enum|reference is good. I'll experiment when I look at it.
from superslim.
Ah I see. I like your idea of registering a String, a set id reminds me of the unintuitive @id/android:list for ListFragments.
from superslim.
Well, enum|string will make the interface look the same for custom layouts as for the internal ones, but you need to addSLM("myslm", new MySLM())
.
from superslim.
Oh nice! That looks perfect to me.
from superslim.
It does look pretty good.
from superslim.
This might be a good candidate for 3.0, as the layoutId->sectionManager is an API breaking change.
from superslim.
I am going straight to 0.4.
from superslim.
Related Issues (20)
- Flexbox layout
- Dynamic sticky content
- Built in elevation change for sticky content.
- Infinite scroll
- Collapsible/expandable sections
- Sticky footers weirdly wobble on horizontal scroll. HOT 1
- Toggling collapsible sections loses items.
- Prepare milestone 5 release
- Update Readme.md
- On layout a sticky footer always sits above sticky inset (section state inset parameter).
- Sticky footer HOT 2
- RecycleView scrolls over sticky header
- Crash On RecyclerView Refresh
- Does SuperSLiM supports sub headers ? HOT 10
- Mocking framework
- i cannot build the project
- NPE at LayoutManager#onItemsUpdated
- Androidx HOT 1
- Is this covered by the Apache 2.0 License?
- Scrolling issue with Sticky Headers on
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from superslim.