Skip to main content

Posts

SuperSLiM Milestone 1

I’ve reached Milestone 1 for development on the new version of SuperSLiM. This is a complete rewrite of the library to fix long outstanding problems in the original design. You can see the roadmap for version 5 up on Trello . I expect Milestone 2 to be completed within the next couple of weeks. Milestone 1 Milestone 1 was pretty much all about getting a good foundation for the library in place. The internal graph and SLM APIs are sorted out with support for a basic layout, predictive animations, and an adapter implementation. The new design is very flexible and makes extending the library very clean and easy. Kotlin The library is now written in Kotlin. Kotlin is presently heading for a 1.0 release itself. When that happens, I’ll be doing a code review of the library to identify and address any unnecessary garbage collection or other performance related problems. What is implemented SuperSlimAdapter There is an adapter available. It implements a graph which can stor...

Again: Supporting Android Typedefs in Kotlin

Before reading on, it is important to note that Android lint checks do not run on Kotlin code. However, it is possible to annotate Kotlin code such that lint can correctly check Java code against the annotated interfaces. There is an issue tracking lint support for Kotlin here . Typedef (Enumerated Annotations) Previously , I wrote about how to get a library written in Kotlin to interoperate with IntDef and StringDef. The method I outlined got the lint check working in a partial state. However, here is what you have to do to get the annotation to work properly. In Kotlin, declare the constants that are the values in the typedef. DatePicker.kt package com.example.datepicker class MyKotlinClass { companion object { const val YEAR = 1L const val MONTH = 2L const val WEEK = 3L const val DAY = 4L } } The actual typedef is must be declared in Java. DatePickedKind.java package com.example.datepicker import android.support.annot...

Easy SDK version handling with Anko

Anko is a library for Kotlin that implements a bunch of DSLs that significantly simplifies and cleans up your Android code. One of the small pieces it offers are some extension functions to selectively execute code based on the current configuration. It looks like this: configuration(screenSize = ScreenSize.LARGE, orientation = Orientation.LANDSCAPE) { // This code will be only executed // if the screen is large and its orientation is landscape } Since it was available I thought it’d be nice to use it to tidy up my code that targets different versions of the Android SDK. configuration(fromSdk = Build.VERSION_CODES.M) { // This code will be only executed // on sdk versions 23 and later } However, this has a problem because I want to target multiple version ranges of the SDK. Fortunately, it turns out the function returns null if the configuration check fails. With the power of Elvis ( ?: ) the null return can distinguish when the closure hasn’t been executed and ...

Kotlin, IntDef, and Android libraries

Lately I’ve been investing time into Kotlin. Tonight, I was particularly interested in its utility for Android libraries. IntDef Update : Actually, lint doesn’t quite interoperate properly with Kotlin. So, while the following gets IntDefs and the related support annotations working 90%, you have to do things a little different, which I’ve outlined here . First up is how to use the support library’s IntDef annotation in Kotlin. This is especially important for library development since it is considered best practice to avoid enum usage for Android development. I don’t really want to go into the arguments about this practice, this is just how to use it. As it turns out, this is pretty easy. In Kotlin, using IntDef looks like this; companion object { const val YEAR = 1L const val MONTH = 2L const val WEEK = 3L const val DAY = 4L } @IntDef(YEAR, MONTH, WEEK, DAY) annotation class TimePeriod and the same code in Java looks like this: public static final lon...

SuperSLiM 'should've been a weekly' update

In the past few weeks I should have written a couple of regular weekly updates, but I didn't, and I feel bad about that. Anyway, on to the good things. SuperSLiM has been making good progress with a complete adapter interface, a near complete database backed example app, and a working but not fully tested linear layout. SectionGraphAdapter In testing the new section graph adapter functions well with the stock recycler view layouts and is working with the SuperSLiM LinearSLM. This will resolve version 0.4 issues with dynamic data. At the moment the section graph has to maintain quite a bit of metadata to map items into the flat structure the recycler view expects. This means performing changes to the section graph can perform quite a bit of work at times. For some cases it may be worth using a slightly different implementation which sacrifices access performance from the recycler view side for increased performance when making changes to the graph. Also, I found it trivial to...

SuperSLiM weekly update

This week I have had less time for SuperSLiM than I imagined, but with the time I've had, I have continued work on the public API and the internal state for the library. Much of the work has been pen and paper documentation and modelling, but much of an example of how to write a data driven app with SuperSLiM has been written as a by-product. For the public API I've settled on using a graph as a proxy to control the output of the library. In the previous post I discussed the section graph and its interaction with the traditional RecyclerView adapter. In the end I decided to go ahead with embedding the adapter into the section graph, which I believe makes working with RecyclerView and SuperSLiM quite simple. Now you simply add, remove, and update sections and items in the graph. There is no need to turn the graph structure into the sequence of views that RecyclerView requires, SuperSLiM does it all in the background. The step after working on the changes to the public API w...

SuperSLiM section graph

In the last post I discussed I was working on the public API for SuperSLiM. This work really concerns the role of RecyclerView.Adapter in the API, that is, if SuperSLiM requires you to create and maintain a section graph, then do you also need to implement an adapter? First, why is it important to explicitly create a section graph? In past versions, SuperSLiM generated a section graph from the adapter. This worked well enough at first, and it was nice that the API was basically the same as a normal layout manager. As it turned out, simply using the adapter and bundling all the side-channel data into layout parameters resulted in a lot of extra work being done to generate the section data. This was most noticeable when views that weren't even to be displayed would be bound multiple times. While caching fixed many of these problems, ultimately this played havoc with image caching and loading, and often resulted in unpredictable performance issues. To solve these problems I decid...

SuperSLiM weekly update

This is my first weekly update for SuperSLiM. For the last week I have been primarily been working on the public API for SuperSLiM. I have also worked to finish the modifications of LinearSLM to support nested sections and the new internal API. As I want to ensure the public API is easy to use and understand, I have been experimenting with what it is like to use it in real applications. At the moment my biggest issue with the API is that, at the moment there are two chores to be completed when you have data changes, keeping the section graph up to date, and notifying data changes through the recycler view. I am considering ways to get this down to one task, which may require proxying the notify calls through the section graph, or making the library able to notify section graph changes, from notify calls, back to the client. I am also finding myself consistently writing helper classes to construct and manage the copy of the section graph in the adapter, I think the library could pr...

Help support SuperSLiM and get all the cool things.

It is time to talk about SuperSLiM, where is it going and how to get there. For the past few months I've been working on a new version that will fix many outstanding problems with the library. Among the changes coming is a new adapter API, a new SLM API, additional controls for headers, support for nested sections and headers, and lots of little fixes and rationalisations that will make SuperSLiM much better. I have also been working on the library to make it easy to test individual parts outside of the Android SDK, this is super important work, and much better than simply running SuperSLiM through Robolectric. Finally, there is the big problem with version 0.4, working with dynamic data is a big pain if you are using SuperSLiM, the new API is the fix for this, and it will be coming with example code and tests to demonstrate the best ways of getting your data changes into SuperSLiM. Well, that was a lot.. sounds good right? Not quite. You see, I have been working on a number of ...

SuperSLiM version 0.4.12 released.

There are two small fixes in this update. The grid slm should now honour the RTL layout direction. Also, when the recycler view is rotated or recreated, it should now restore to the correct adapter position. I am now publishing directly to both JCenter and Maven Central. For JCenter users, this means you should see the updates in a more timely fashion. GitHub Page Release Notes Changes this version Fix RTL layout in grid SLM (#16). Fix position restoration (#85).

SuperSLiM version 0.4.10.1 released

SuperSLiM v0.4.10.1 is now available. Sorry, I've been lax announcing updates recently. I'll make sure to keep on top of it from now on. Also, I'd like to thank all of you who have been contributing to the project. Your pull requests and issues really help the project along. For those of you who have generously donated, your support is very much appreciated. Work on version 0.5 has been continuing, though it has been slow due to other commitments. Due in version 0.5 is a new adapter API with robust data change support, subsections, and header elevation controls. Most of the API difference is a change to declaring the section graph ahead of time, rather than indirectly through header/section layout parameters. Don't worry, you'll still be able to configure parts of SuperSLiM through layout parameters, but section type, and section indices are loaded through the section graph, and changes to it are tracked through your data change notifications. Version 0.4.1...

SuperSLiM Status Report

GitHub project page I've moved some things around on the wiki. In preparation for the next release, when it is ready, I've started versioning some of the wiki pages. My plan is for each major release to have it's own subsection on the wiki. Also, I've set the latest stable branch (early_release_4) as the default branch in GitHub. You'll have to navigate to the master branch to see the latest development. Version 0.4 The past few weeks SuperSLiM have seen a number of small maintenance releases for version 0.4. The latest release is now 0.4.7. I've actually been treating the 0.4 release series as a stable kind of pre-release. It is my plan to continue to support it, for a short while, past the release of the next version. Development Development on the next major version (0.5) is progressing nicely. A number of major features have been implemented and are currently having the kinks worked out. The staggered grid section layout and support for da...

Version 0.4.0 released

SuperSLiM has seen lots of development this week, though a few less releases this time. Much of the work has been to iron out issues in the layout and scrolling code, culminating with a complete overhaul of it all. Now performance is much better and you don't get the weird problems that cropped up in v0.3. Oh yeah, and you still have a nice smooth scroll indicator. Changes This release has big changes to initialisation. Old code like: LayoutManager lm = new LayoutManager(); SectionLayoutManager linear = new LinearSectionLayoutManager(lm); SectionLayoutManager grid = new GridSectionLayoutManager(lm, getActivity()); grid.setColumnMinimumWidth((int) getResources() .getDimension(R.dimen.grid_column_width)); lm.registerSectionLayoutManager(0, linear); lm.registerSectionLayoutManager(1, grid); mRecyclerView.setLayoutManager(lm); is now: mRecyclerView.setLayoutManager( new LayoutManager(getActivity()); and in your adapter you can set the section layo...

State of the SuperSLiM

It has been a busy time for development on SuperSLiM. Moving forward, in the next few weeks, I'd like to get to a stage where all the basics are complete. If you can help me with that, I'd really appreciate it. Just as little as telling me how you are using SuperSLiM is helpful, but also, I would love it if you are able to file any  issues  you encounter, and contribute any code. About the Google+ Community . I am hoping it can become a useful forum to engage with you, the users, and for you to discuss how you are using SuperSLiM. It would be fantastic if you can post any projects you are using SuperSLiM in, or interesting things or ideas you have for SuperSLiM. If you have any code snippets you want to discuss, just host it in a gist  and link it in a post. That's enough of that. Here is a breakdown of recent development. Releases A few early releases have been made to Maven Central. The latest release is v0.2.1 and it should be indexed in the next few hours. ...

RTL support in RecyclerView

As I was implementing RTL support for SuperSLiM I discovered that child views of the RecyclerView are not inheriting the current text or layout direction. I poked around for a bit trying to figure out what is going on but I decided to do the quick fix for the example app and move on. So for your views inflated in a RecyclerView.Adapter, just add android:textDirection="locale" or android:layoutDirection="locale" to pick up the correct layout direction. 

SuperSLiM v0.1.0 released

SuperSLiM is now published on MavenCentral at version 0.1.0. To include it in your project just add the following to your build.gradle. dependencies {     compile 'com.tonicartos:superslim:0.1.0' } Alternatively, if you always want the latest version you can wildcard the version number.  dependencies {     compile 'com.tonicartos:superslim:+' } Please note, there are breaking changes planned in the near future, and the latest round of changes also considerable changed things too. Functional changes in this version LayoutParam changes Attribute alignHeader changed to headerDisplay and type changed from enum to flag . alignHeader enum values remapped to flags. Consequently inlined headers can now be displayed overlaying content views. LayoutParam attribute isSticky removed and is now a flag in headerDisplay. Removal of scroll indicator support This was done in preparation for changes to how SectionLayoutManagers are implemented. Also,...