Most of you have heard about TypeAdapter which is used to customize JSON conversions. Sometimes API can be designed that way that it wont fit your needs on client side. Thus you have to modify the response.

Below an example of modifying the type of the response is shown. Specifically a List of Objects is parsed into HashMap

Suppose we expect this Json response:


"response": {
.... "values": [
{
"key": "foo_key",
"label": "foo_label"
},
{
"key": "foo_key_2",
"label": "foo_label_2"
}
]
}

From this response, normally it is expected that we parse it to List<Foo> values:

Response response …


Most of you have heard about Kotlin which is now officially supported from Google itself. Thus I wont deep-dive into Kotlin, but you can follow this and this link as a starting point.

I am going to explain on how to implement Dagger 2 in your Android projects for using with Kotlin.

Firstly you have to configure Gradle build tool for supporting Kotlin

  • Add Kotlin Gradle Plugin in your top build.gradle file:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
//Kotlin android extensions
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
//Kotlin Annotation Processing (KAPT) plugin
apply plugin: 'kotlin-kapt'
  • Add dependency to your dependencies in inner build.gradle file:
implementation "com.google.dagger:dagger:$daggerVersion" kapt


RxJava is a very powerful library for asynchronous jobs offering variety of features which can be combined and implemented in multiple ways.

This article focuses on how we can use some of those features for handling an Instant Search feature effectively.

Suppose we make an instant search feature for searching images usingSearchViewas below and we make a request on onQueryTextChange:

searchView.setOnQueryTextListener(
new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
//Here we request a search
presenter.instantSearch(newText);
return false;
}
});

On the other side we do the magic by holding a…


This article is about handling Errors on a single place (example uses MVP architecture) using RxJava2 and Retrofit2. It won’t cover Rx, Retrofit or MVP architecture as there are a lot of good examples out there, instead it is focused only on a Error handling strategy through DisposableObserver.

Suppose we have a request in `Retrofit2` as below:

@GET("search/images")
Observable<GetImagesResponse> getImages(
@Query("page") int page,
@Query("page_size") int pageSize,
@Query("phrase") String phrase
);

Usually when making such a request we handle it as following:

getImages(pageNo, pageCount, phrase)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new …


While implementing In App Subscriptions i found out that the process of implementing it was not that complicated, but there were some hidden facts that took me time to figure out. And as there is no much examples out there about this case i decided to write an article that may be helpful for someone dealing with In App Billing.

Play Store

First of all you must have a Google Play Developer Account for implementing and testing In App related cases.


This page is left blank intentionally

Haris Krasniqi

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