This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-android-extensions' | |
apply plugin: 'kotlin-kapt' | |
android { | |
compileSdkVersion 25 | |
buildToolsVersion "25.0.3" | |
defaultConfig { | |
applicationId "com.example.adventure.learningbycomparing" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
buildscript { | |
repositories { | |
maven { url 'https://maven.google.com' } | |
jcenter() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:3.0.0-alpha1' | |
// NOTE: Do not place your application dependencies here; they belong |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ext { | |
versions = [ | |
support : '27.0.1', | |
constraintLayout: '1.0.2', | |
firebase : '11.8.0', | |
kotlin_version : '1.2.10', | |
moshi : "1.5.0", | |
okHttp : "3.8.1", | |
retrofit : '2.3.0', | |
dagger : '2.11', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.thorangs.retrofitcachingtest | |
import android.content.Context | |
import com.google.gson.GsonBuilder | |
import okhttp3.Cache | |
import okhttp3.OkHttpClient | |
import retrofit2.Retrofit | |
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory | |
import retrofit2.converter.gson.GsonConverterFactory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun ImageView.loadImage(url: String ="", @DrawableRes drawable: Int = R.mipmap.ic_launcher, placeHolderUrl: String = "", @NonNull placeHolderDrawable: Int = R.mipmap.ic_launcher, circular: Boolean = false) { | |
val defUrl = "" | |
@DrawableRes | |
val defDrawable = R.mipmap.ic_launcher | |
when { | |
//Displaying image from Url | |
url.isNotEmpty() && circular -> Picasso.get().load(url).placeholder(placeHolderDrawable).transform(CircleTransform()).into(this); | |
url.isNotEmpty() && !circular -> Picasso.get().load(url).placeholder(placeHolderDrawable).into(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Cascade/Chaining/Fluent Operations | |
//We can chain method/member calls without returning `this` from method/getter/setter | |
class User { | |
String name; | |
int age; | |
User({this.name = "Foo", this.age = 0}); | |
User withName(String name) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
function2(function1, 3); | |
function2(function1, 4); | |
function2(function1, 7); | |
function2(function1, 9); | |
} | |
function1(int evenOrOdd) { | |
print("$evenOrOdd is ${evenOrOdd % 2 == 0 ? "Even" : "Odd"}"); | |
} |
OlderNewer