Hello everyone 🙋♂️ In this medium series I will talk about Clean Architecture in Android Development. Then I will explain my library: a base library for clean architecture projects. Finally I will show my tech stack that I used in my library and demo app that uses that library. Library and demo app is hosted on my github:
It is written with Kotlin in modular way. So you can use it some of its layers or all layers at once.
List of my tech stack: Kotlin, Clean Architecture, MVVM, Kotlin Coroutines, Repository Pattern, Dependency Injection with Koin, Data Binding, Unit testing up to Activity/Fragment with MockK, Coil for image loading, Retrofit2, Elements library for using RecyclerView. …
Hello everyone🙋♂️ In this part I will show you my Clean App Base Library. It mainly consists of base classes for the structures that I talked about Part I and some base methods to reduce our code one line in some places. Here is a link of my lib:
You can find here the source code and installation instructions.
Firstly, whenever I start a project I was creating the same base classes for the same reasons. Because I use clean architecture, there are many classes. This library saves developer from creating classes again and again.
Secondly, especially in presentation showing data that comes from domain level requires lots of code. Most basic flow is like this: Activity requests some data to show. By the meantime it must show a loading indicator. For this it observes a live data from view model. That live data returns DataHolder<T> . Activity then behaves differently according to the data holder’s type. If it is Success, uses data. If it is Loading, shows loading indicator. If it is Fail shows some error dialog. That was the observer side. In the view model firstly observed data holder’s value must set be to DataHolder.Loading. Then the interactor must be executed in view model scope. Then coming data must be passed to observed live data. Of course that execution can be more parametrized. Different dispatchers can be needed or execution result can be intercepted by view model. …
Hello everyone 🙋♂️ In this part I will show the demo app of Clean App Base Library.
It gets users from a server and lists them. If any user clicked a detail page opened. In the detail page user details and editing profile picture implemented as two tabs.
It uses Fakejson as the data source. It is a really good tool to mock a server. It can respond how you want the answer or can respond built-in data or list.
It is an one-module app that consists of three packages. I named every package as an app feature. These are: core
, detail
and main
. They are all divided by three familiar packages: data
,domain
and presentation
. …
Hello everyone 🙋♂️ In this part I will show you some Android libraries that I used when implementing demo project. Also ,I will show you how I implemented unit testing.
This is one of the reasons why clean architecture is necessary. Clean architecture makes unit testing painless and easy. I’ve implemented unit test for both libraries and the demo app.
I use Mockk library because it goes well with Kotlin. Besides it gives us nice DSL functionalities to play with.
To make unit tests easier, I’ve followed 3 rules when writing the app code:
1- Don’t make Swiss Army Knife Classes! …
Hi everyone 🙋♂️ In this article I will give a little hint that can save you from angry hours and smashing your keyboard 😁 If your module cannot be found by gradle sync you are at the right article.
When you intend to publish your awesome library you may want to distribute of its one module as one library. For example if you are making a image loader library you may want seperate image filter features from main library. Or image transformation or image animation…
I will not write about publishing an Android library on Jitpack, if you are reading this you must know how to do it. …
Herkese merhaba arkadaşlar. Bu yazımda Huawei Push Kit kullanarak bir canlı arama uygulamasının çalma ekranının yapımını anlatacağım. Öncelikle HMS Push Kit’i uygulamanıza entegre etmeniz gerekiyor. Push Kit Data mesajı ve Notification mesajı olmak üzere 2 mesaj tipini desteklemektedir. Notification, sistemin uygulamanızın çalıştırmaya gerek duymadan Bildirim Merkezinde (NC) gösterdiği standart bildirimdir.
Uygulamanızda tarih ve saati seçilen dil/bölge ayarlarına göre göstermek özellikle birden çok ülkede kullanılacaksa önemlidir. Örneğin Türkiye için tarih “Gün.Ay.Yıl Saat:Dakika” şeklinde kabul görmüşken Amerika için bu format “Ay/Gün/Yıl Saat:Dakika PM/AM” şeklindedir.
Elimizdeki java.util.Date nesnesini yerel formata çevirmek için java.text.DateFormat sınıfını kullanabiliriz. DateFormat nesnesini şu şekilde elde edebiliriz:
Tarih için:
DateFormat dateFormatDate = android.text.format.DateFormat.getDateFormat(context)
Saat için:
DateFormat dateFormatTime = android.text.format.DateFormat.getTimeFormat(context)
Sonraki adımda dateFormatDate ve dateFormatTime nesnelerinden String sonucu almamız gerekiyor:
String dateStr = dateFormatDate.format(date); android.text.format.DateFormat.getTimeFormat(context)String timeStr = dateFormatTime.format(date); android.text.format.DateFormat.getTimeFormat(context)
Ondan sonra bu iki sonucu birleştirip aşağıdaki gibi kullanabilirsiniz:
String localDateTimeString=dateStr+” “+timeStr
Bunun sonucunda Türkçe ve İngilizce dili seçilmiş iki telefonun ekran görüntüsü şöyle olacaktır:
İyi kodlamalar :)
About