Kotlin supports a technique called conventions, everyone should be familiar with. For example, if you define a special method plus in your class, you can use the + operator by convention: That’s called Kotlin Operator Overloading. In this article, I want to show you which conventions you can use and I will also provide a few Kotlin code examples that demonstrate the concepts. Kotlin defines conventions that we can apply by implementing methods that comply with predefined names like plus.

Continue reading

When we use Fragment in our app, we often time need access to Context or Activity. We do it by calling methods such as getContext() and getActivity() methods. But, in kotlin, these methods return nullables and we end up using code like this. fun myTempMethod() { context?.let { // Do something here regarding context } // Or we do it like this var myNonNullActivity = activity!! } For example, we need Activity in asking permissions.

Continue reading

100 Days Of Code in Open Source What I got in 100 days and what you can get from Open Source? Let me start by saying this. ***Open Source is just great. ***You will never know what kind of surprise is coming next and how? In this article, I’m going to tell you a story of 100 days and what kind of surprises I got. So, without further delay, let’s get started.

Continue reading

At my current project at work, I have a situation to add a third-party library locally instead of fetching it from jCenter or JitPack.io. So, my first task is to download AAR or JAR file of the library. The reason of using AAR/JAR is to avoid compiling of library on each build of the project to decrease build time. Here’s how First, you need to include it in your project using traditional way of implementation as you do with Android Studio.

Continue reading

Few days ago, I launched an Android library called as Medium Clap, which allows developers to create Medium clapping effect in Floating Action Buttons with few lines of the code. The library went on to be featured in different android newsletters and became #1 on Github Trending in Kotlin. But, one question which I was being asked over and over again was how to publish android libraries, especially those written in Kotlin, on jCenter.

Continue reading

Today, I had a case in my app where there was an EditText and TextView. The goal was that when EditText is changed, then TextView value will be updated instantly. So TextView value will be like this: textView = "SOME URDU STRING 1" + editTextValue + "ANOTHER URDU STRING" First, I added a String value in my strings.xml file which was like this: <resources> <string name="app_name">AppName</string> <string name="sarbarah_str">آپ کا گھر کے سربراہ %s سے کیا رشتہ ہے؟</string> // My String </resources> Please note the %s in the string.

Continue reading

A lot apps use Retrofit or OkHttp for the networking, and when it comes to testing the networked operations, then it becomes a little tricky. As network calls can take a little time, and test fails early due to the delay. In such cases, Idling Registry is used for testing. If you are using Retrofit or OkHttp, then there’s this OkHttp Idling Resource which makes testing idling resources and network calls a lot more easier with few lines of code.

Continue reading

Author's picture

Wajahat Karim

Android Developer. Open Source Contributor. Writer. Speaker

Senior Android Developer

Karachi, Pakistan