This is the first blog-post of the coroutine series. I know lots of coroutine guidelines, blog posts, and videos on the internet. This is going to be yet another series. More coroutine doesn’t kill anyone. :)

Before we jump into the Coroutines, I want to step back and look at the existing concepts that we are using.

Concurrency

We always write code that executes and returns the value. If we are lucky, the method does its job and returns immediately but generally, we are not. We always wait for the result. This is why we use threads in our projects.

Concurrency…


To prevent MITM(Man in the Middle) attack, we may apply SSL pinning to our apps. There are couple of methods to apply secure socket layer pinning to our apps. It will be more understandable If you want to understand SSL handshake before you deep dive into pinning. Here are some links about SSL and three-way handshaking.

To sum up, in a couple of words, we encrypt our data with our public key, so only our server can decrypt that data with the private key. So If we are using public wifi…


https://unsplash.com/photos/Wpn9NX84SeI

Most of the time, we don’t spend time to develop our Android app’s UI, we just drag and drop views and start writing our app. I have observed that most of us don’t care that much about the user interface. And I believe that it’s wrong. Mobile developers should care about UI/UX too. I am not saying “Be an expert on mobile UI” but we should understand design language and it’s concept.

Previously I wrote something about material design shadows and I got lots of good feedback. I would like to thank all of you. “Mastering Shadows in Android” explains…


https://unsplash.com/photos/hklRkhJyo5I

If we want to create better apps, I believe that we need to follow material design guideline.In general terms, Material design is a three-dimensional environment containing light, material, and cast shadows. Light and Shadow are important for us if we want to follow material design guideline in our application development process.

I will try to explain following topics in this article.

  • 3D in Android
  • Depth
  • Z value, elevation and Translation Z
  • Light
  • Button state (Pressed and Resting)
  • Outline
  • Custom Outline with ViewOutlineProvider

Before deep dive into shadow and light, I want to show you what our environment is.

What is 3D?

The material…


Bu yılı bitirmek üzereyiz. Ve koca bir yıl ne yaptık? Hiç! Koca bir hiç! Şaka şaka. Tabi ki de böyle depresif laflara girmeyeceğim.😀 Yıl biterken evde boş boş oturduğum bi cumartesi akşamı (bu akşam) bu yıl neler yaptığımı log tarzında buraya yazmak istedim.

Aslında 2018'de motivasyon amaçlı ne sözler versem de kendime yapmasam acaba diye düşünürken 2017'yi yazmak aklıma geldi. Bu yıl da aslında fena bi yıl sayılmaz diye düşündüm ve neler yaşadığımı bi listelemek istedim.

Öncelikle yazılımcılar olarak fazla sosyal olmayan bir hayatımız olduğunu göz önünde bulundurursak motivasyonlarımız da genelde şu şekilde oluyor, nasıl daha çok blog yazabilirim, daha…


If you didn’t read part 1 and part 2, I suggest you to read them first. You can find links at the bottom.

TLDR;

You can use DaggerActivity, DaggerFragment, DaggerApplication to reduce boilerplate in your Activity/Fragment/Application.

Also you can use AndroidInjector<T> in your dagger components to reduce boilerplate too.

DaggerAppCompatActivity and DaggerFragment

Remember that we call AndroidInjection.inject() every activity or fragment that we wanted to use dagger. And also, If you want to use Injection in your fragment, you should also implement HasSupportFragmentInject interface and override fragment injector in your activity.

Recently, I moved that code to my base activity and base fragment. Why…


Kotlin is new trend and I see everyone is switching to Kotlin language in Android Development. So In my next tips, I will use more Kotlin.

1 — Operator Overloading in Kotlin

Kotlin allows us to provide implementations for a predefined set of operators on our types. These operators have symbolic representation like *,-,+ etc. Lets examine it with a little snippet.

If you use RxJava in your android project, you need to create a CompositeDisposable and add every disposable that you created to the CompositeDisposable. Without operator overloading, we do it like the following;

val disposables = CompositeDisposable()
val observable1 = your_observable
disposables.add(observable1)

You can…


1 — @BindingAdapter and Kotlin

@BindingAdapter is maybe the most powerful feature of databinding library in android world. It allows you to create your custom attribute. To see an example to usage, you can check 2.tip in log #10 . In java, we used to create @BindingAdapter just like that;

public class BindingTextUtils {

@BindingAdapter({"imageUrl"})
public static void loadImage(ImageView v, String url) {
Picasso.with(view.getContext()).load(url).into(view)
}
}

But, in kotlin it is a bit different. I though that I can just change static method to companion object.

class BindingAdapterUtils {

companion object {

@BindingAdapter(value = "imageUrl")
fun load(view: ImageView, url: String) = Picasso.with(view.context).load(url).into(view)
}
}

But…


1 — Mutate your drawable!

Let say you have to change filter of drawable. What would you do? It is an easy question. You will do something like that.

val drawable = ContextCompat.getDrawable(context, R.drawable.icon)
drawable.setColorFilter(Color.WHITE)

Everything seems OK. Until you need to use same resource in different page.I want to share official documentation about Drawable.

All drawables instances loaded from the same resource share a common state; if you modify the state of one instance, all the other instances will receive the same modification.

So If you load R.drawable.icon in another activity you will see latest modification which is applied previous activity. …

Mert SIMSEK

Software Engineer at Storytel

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store