티스토리 뷰
Setup
My code is fully based on Kotlin.
Latest version of Litho I am writing is 0.31.0
. Add the following dependencies to your app module build.gradle
.
//litho
implementation 'com.facebook.litho:litho-core:0.31.0'
implementation 'com.facebook.litho:litho-widget:0.31.0'
compileOnly 'com.facebook.litho:litho-annotations:0.31.0'
kapt 'com.facebook.litho:litho-processor:0.31.0'
kapt
is Kotlin annotation processor and you need it because litho generates boilerplate code for you.
Add Soloader
dependencies. Litho uses yoga library internally to manage position and layout and Soloader
needs to initialise yoga.
// SoLoader
implementation 'com.facebook.soloader:soloader:0.6.0'
Add the following dependencies to support RecyclerView. Section
is litho support for RecyclerView and you can build very fast and powerful list.
// Sections
implementation 'com.facebook.litho:litho-sections-core:0.31.0'
implementation 'com.facebook.litho:litho-sections-widget:0.31.0'
compileOnly 'com.facebook.litho:litho-sections-annotations:0.31.0'
kapt 'com.facebook.litho:litho-sections-processor:0.31.0'
If you are using Facebook image library Fresco
, then you may need to add dependency below.
// For integration with Fresco
implementation 'com.facebook.litho:litho-fresco:0.31.0'
Your app module build.gradle file will look like below (Using Android 10 and Androidx).
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.mpark.android.myapplication"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//Androidx
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
//ViewModel & Livedata
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-rc01'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-rc01"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-rc01"
//Kotlin coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"
//Litho
implementation 'com.facebook.litho:litho-core:0.31.0'
implementation 'com.facebook.litho:litho-widget:0.31.0'
compileOnly 'com.facebook.litho:litho-annotations:0.31.0'
kapt 'com.facebook.litho:litho-processor:0.31.0'
// SoLoader
implementation 'com.facebook.soloader:soloader:0.6.0'
// For integration with Fresco
implementation 'com.facebook.litho:litho-fresco:0.31.0'
// Sections
implementation 'com.facebook.litho:litho-sections-core:0.31.0'
implementation 'com.facebook.litho:litho-sections-widget:0.31.0'
compileOnly 'com.facebook.litho:litho-sections-annotations:0.31.0'
kapt 'com.facebook.litho:litho-sections-processor:0.31.0'
implementation "com.squareup.moshi:moshi-kotlin:1.8.0"
testImplementation 'junit:junit:4.12'
// For testing
testImplementation 'com.facebook.litho:litho-testing:0.31.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
'Android > Litho' 카테고리의 다른 글
6. StateValue (0) | 2019.11.10 |
---|---|
5. HeroItemSpec (0) | 2019.11.10 |
4. GroupSection Spec LifeCycle (0) | 2019.11.09 |
3. Sample Application - HeroesComponentSpec (0) | 2019.11.09 |
2. Sample Application - Intialisation (0) | 2019.11.09 |
댓글