Skip to content

Instantly share code, notes, and snippets.

View navi25's full-sized avatar
📱
Tinkering with Android

Navendra Jha navi25

📱
Tinkering with Android
View GitHub Profile
@navi25
navi25 / CleanArchitecture.md
Created August 1, 2018 19:15 — forked from ygrenzinger/CleanArchitecture.md
Summary of Clean Architecture by Robert C. Martin

Summary of book "Clean Architecture" by Robert C. Martin

Uncle Bob, the well known author of Clean Code, is coming back to us with a new book called Clean Architecture which wants to take a larger view on how to create software.

Even if Clean Code is one of the major book around OOP and code design (mainly by presenting the SOLID principles), I was not totally impressed by the book.

Clean Architecture leaves me with the same feeling, even if it's pushing the development world to do better, has some good stories and present robust principles to build software.

The book is build around 34 chapters organised in chapters.

@navi25
navi25 / GreetingGenerator.kt
Created December 24, 2018 04:43
A sample greeting generator annotation in Kotlin
package io.navendra.annotation
/**
* Custom Annotation class
* For more information check - "https://kotlinlang.org/docs/reference/annotations.html"
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
@MustBeDocumented
@navi25
navi25 / FileGenerator.kt
Created December 24, 2018 04:47
A simple abstract processor class to generate Greeting Class based on GreetingGenerator Annotation.
package io.navendra.codegen
import com.google.auto.service.AutoService
import io.navendra.annotation.GreetingGenerator
import io.navendra.codegen.simplePoet.KotlinClassBuilder
import java.io.File
import javax.annotation.processing.*
import javax.lang.model.SourceVersion
import javax.lang.model.element.TypeElement
@navi25
navi25 / FileGenerator.kt
Created December 24, 2018 04:47
A simple abstract processor class to generate Greeting Class based on GreetingGenerator Annotation.
package io.navendra.codegen
import com.google.auto.service.AutoService
import io.navendra.annotation.GreetingGenerator
import io.navendra.codegen.simplePoet.KotlinClassBuilder
import java.io.File
import javax.annotation.processing.*
import javax.lang.model.SourceVersion
import javax.lang.model.element.TypeElement
@navi25
navi25 / KotlinClassBuilder.kt
Last active December 24, 2018 09:02
A custom Kotlin code generator that generates a basic class with basic greeting method.
package io.navendra.codegen.simplePoet
/**
* Custom Kotlin Class Builder which returns file content string
* This is for learning purpose only.
* Use KotlinPoet for production app
* KotlinPoet can be found at https://github.com/square/kotlinpoet
*/
class KotlinClassBuilder(className: String,
packageName:String,
@navi25
navi25 / MainAcitivty.kt
Created December 24, 2018 06:19
A MainActivity class for consuming our simple MerryAnnotation processor
package io.navendra.merryannotation
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import io.navendra.annotation.GreetingGenerator
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
val TAG = MainActivity::class.java.simpleName
//In local.properties
tmdb_api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
//In build.gradle (Module: app)
buildTypes.each {
Properties properties = new Properties()
properties.load(project.rootProject.file("local.properties").newDataInputStream())
def tmdbApiKey = properties.getProperty("tmdb_api_key", "")
it.buildConfigField 'String', "TMDB_API_KEY", tmdbApiKey
//ApiFactory to create TMDB Api
object Apifactory{
//Creating Auth Interceptor to add api_key query in front of all the requests.
private val authInterceptor = Interceptor {chain->
val newUrl = chain.request().url()
.newBuilder()
.addQueryParameter("api_key", AppConstants.tmdbApiKey)
.build()
// Data Model for TMDB Movie item
data class TmdbMovie(
val id: Int,
val vote_average: Double,
val title: String,
val overview: String,
val adult: Boolean
)
// Data Model for the Response returned from the TMDB Api
// build.gradle(Module: app)
dependencies {
def moshiVersion="1.8.0"
def retrofit2_version = "2.5.0"
def okhttp3_version = "3.12.0"
def kotlinCoroutineVersion = "1.0.1"
def picassoVersion = "2.71828"