- Description and goals
- Learning process
- https://github.com/CamilleBC/Commune#
- 2018/09/20: ContentProvider with CursorLoader, a RecyclerView and a custom adapter.
- 2018/09/21: SearchView, custom query for the CursorLoader, and photo thumbnail’s URI.
- To be continued…
My first goal with Commune is to understand how to articulate the different Android components, the Matrix protocol, and manage event planning as well. We’ll see where it goes from there.
The ultimate goal is the far future is to create an open-source tool to manage communities of various size. Just one app to communicate with your friends, coworkers, co-citizens, etc.
Send a simple message, create a group chat, plan an event and share some interesting stuff.
I will try to describe in a chronological order what my project taught me about Android apps’ architecture and development.
[2018/09/20] commit 938fcfa
At this stage, I am discovering the way Android manages data.
The android guide describes a way to link a SimpleCursorLoarder to a ListView.
I have tried to use a RecyclerView adapter because it is much more versatile than the basic ListView. The RecyclerView doesn’t have an easy way to plug the CursorLoader in. I have used an implementation found on the web, that I have tried to understand and implement. I have not yet cleaned it, nor did I try to use “proper” Kotlin syntax.
I first tried to replace the CursorLoader by a ViewModel with a Room and some DAO (Data Access Object) and LiveData, before understanding that both were an API layer on some Database. I had to either create a custom Room+ViewModel layer to get data from the phone’s contact database, or reuse the existing ContentProvider with a CursorLoader. I chose to do the latter, as I don’t feel confident enough yet to create my own custom layer.
As of now the app only displays a list of all contacts in the phone. It updates in real time when the contacts are updated on the phone.
[2018/09/21] commit 9f579e6
I implemented a menu with a SearchView. On text edition and submission, the SQL query is upated, sent to the CursorLoader, and the LoaderManager is restarted. It doesn’t wait for completion when the user is typing, as there is no need to wait for the CursorLoader to return if the query is updating.
I also request the thumbnail URI to display a picture on the RecyclerView, as I find it nicer to look at.
I have started to implement the searchable interface to the activity. The plan is for the activity to be callable with an Intent, and to be able to return a contact’s data, either on user selection or because only one result fits, or a failure if no contact matches the query.
Written with StackEdit.