Skip to content

Commit

Permalink
[Sample App] Modernized sample app (#1622)
Browse files Browse the repository at this point in the history
Upgraded all dependencies, migrated RxJava to coroutines, and ViewBinding
  • Loading branch information
gpeal authored Sep 12, 2020
1 parent 6e90fe5 commit 1e40a1f
Show file tree
Hide file tree
Showing 84 changed files with 917 additions and 945 deletions.
78 changes: 40 additions & 38 deletions LottieSample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

androidExtensions {
experimental = true
features = ["parcelize"]
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]
}
}

android {
Expand Down Expand Up @@ -34,6 +41,9 @@ android {
minifyEnabled false
}
}
viewBinding {
enabled = true
}
lintOptions {
ignore 'InvalidPackage'
textReport true
Expand Down Expand Up @@ -62,60 +72,52 @@ dependencies {
implementation project(':lottie')
implementation 'androidx.multidex:multidex:2.0.1'

implementation "androidx.fragment:fragment:1.2.1"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.fragment:fragment-ktx:1.2.5"
implementation "androidx.appcompat:appcompat:1.2.0"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.paging:paging-runtime-ktx:2.1.1"
implementation "androidx.paging:paging-rxjava2-ktx:2.1.1"
implementation "androidx.paging:paging-runtime:3.0.0-alpha5"
implementation "androidx.paging:paging-runtime-ktx:3.0.0-alpha06"
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation "androidx.browser:browser:1.2.0"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
kapt "androidx.lifecycle:lifecycle-common-java8:2.2.0"
implementation "com.google.android.material:material:1.1.0"
implementation "com.google.android.material:material:1.2.1"

implementation 'com.airbnb.android:epoxy:3.9.0'
implementation 'com.airbnb.android:epoxy-paging:3.9.0'
kapt 'com.airbnb.android:epoxy-processor:3.9.0'
implementation 'com.airbnb.android:mvrx:1.3.0'
implementation 'com.airbnb.android:epoxy:4.0.0-beta6'
kapt 'com.airbnb.android:epoxy-processor:4.0.0-beta6'
implementation 'com.airbnb.android:mvrx:1.5.1'

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
implementation 'com.matthew-tamlin:sliding-intro-screen:3.2.0'
implementation 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.2'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
implementation 'com.amazonaws:aws-android-sdk-s3:2.7.+'
implementation ('com.amazonaws:aws-android-sdk-mobile-client:2.7.+@aar') { transitive = true }
implementation ('com.amazonaws:aws-android-sdk-auth-userpools:2.7.+@aar') { transitive = true }
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.1'
implementation 'com.amazonaws:aws-android-sdk-s3:2.8.3'
implementation ('com.amazonaws:aws-android-sdk-mobile-client:2.8.3@aar') { transitive = true }
implementation ('com.amazonaws:aws-android-sdk-auth-userpools:2.8.3@aar') { transitive = true }
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.okhttp3:okhttp:4.8.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'

debugImplementation("androidx.fragment:fragment-testing:1.2.0-rc04")
debugImplementation("androidx.fragment:fragment-testing:1.3.0-alpha08")

testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'

androidTestImplementation 'androidx.test:core:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.1.0-alpha4'
androidTestImplementation "androidx.fragment:fragment-testing:1.2.0-rc04"
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'io.reactivex.rxjava2:rxjava:2.2.1'
androidTestImplementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
androidTestImplementation 'com.squareup.okhttp3:okhttp:3.11.0'
androidTestImplementation 'androidx.test:core:1.3.0-rc01'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'com.squareup.okhttp3:okhttp:4.8.1'
androidTestImplementation 'io.jsonwebtoken:jjwt:0.9.0'
androidTestImplementation 'com.amazonaws:aws-android-sdk-core:2.6.31'
androidTestImplementation 'com.amazonaws:aws-android-sdk-s3:2.6.31'
androidTestImplementation "org.mockito:mockito-android:2.28.2"
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0"
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.Context
import android.graphics.Bitmap
import android.os.Build
import android.util.Log
import com.airbnb.lottie.BuildConfig
import com.airbnb.lottie.L
import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.mobileconnectors.s3.transferutility.TransferObserver
Expand All @@ -14,20 +13,10 @@ import com.amazonaws.services.s3.model.CannedAccessControlList
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Credentials
import okhttp3.MediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.Response
import kotlinx.coroutines.*
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.toRequestBody
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
Expand Down Expand Up @@ -61,7 +50,7 @@ class HappoSnapshotter(
private val happoSecretKey = BC.HappoSecretKey
private val gitBranch = URLEncoder.encode((if (BC.BITRISE_GIT_BRANCH == "null") BC.GIT_BRANCH else BC.BITRISE_GIT_BRANCH).replace("/", "_"), "UTF-8")
private val androidVersion = "android${Build.VERSION.SDK_INT}"
private val reportNamePrefixes = listOf(BC.GIT_SHA, gitBranch, BuildConfig.VERSION_NAME).filter { it.isNotBlank() }
private val reportNamePrefixes = listOf(BC.GIT_SHA, gitBranch, BC.VERSION_NAME).filter { it.isNotBlank() }
private val reportNames = reportNamePrefixes.map { "$it-$androidVersion" }

private val okhttp = OkHttpClient()
Expand Down Expand Up @@ -104,7 +93,7 @@ class HappoSnapshotter(
}

private suspend fun upload(reportName: String, json: JsonElement) {
val body = RequestBody.create(MediaType.get("application/json"), json.toString())
val body = json.toString().toRequestBody("application/json".toMediaType())
val request = Request.Builder()
.addHeader("Authorization", Credentials.basic(happoApiKey, happoSecretKey, Charset.forName("UTF-8")))
.url("https://happo.io/api/reports/$reportName")
Expand All @@ -115,7 +104,7 @@ class HappoSnapshotter(
if (response.isSuccessful) {
Log.d(TAG, "Uploaded $reportName to happo")
} else {
throw IllegalStateException("Failed to upload $reportName to Happo. Failed with code ${response.code()}. " + response.body()?.string())
throw IllegalStateException("Failed to upload $reportName to Happo. Failed with code ${response.code}. " + response.body?.string())
}
}

Expand Down
Loading

0 comments on commit 1e40a1f

Please sign in to comment.