Skip to content

Commit

Permalink
(#2) Add Firebase analytics.
Browse files Browse the repository at this point in the history
  • Loading branch information
myung jun Hyun committed Feb 20, 2020
1 parent 9c3557e commit 8b6ab88
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 54 deletions.
7 changes: 2 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
Expand Down Expand Up @@ -83,9 +84,7 @@ dependencies {
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"

// firebase
implementation "com.google.firebase:firebase-auth:$firebase_auth_version"
implementation "com.google.firebase:firebase-firestore:$firebase_firestore_version"
implementation "com.google.firebase:firebase-core:$firebase_core_version"
implementation 'com.google.firebase:firebase-analytics:17.2.2'

// reactive extensions
implementation "io.reactivex.rxjava2:rxjava:$rxjava_version"
Expand All @@ -110,5 +109,3 @@ dependencies {

implementation 'joda-time:joda-time:2.10.4'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
31 changes: 8 additions & 23 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,37 @@
{
"project_info": {
"project_number": "597478389411",
"firebase_url": "https://mash-up-group-dev.firebaseio.com",
"project_id": "mash-up-group-dev",
"storage_bucket": "mash-up-group-dev.appspot.com"
"project_number": "581346452831",
"firebase_url": "https://mash-up-branding.firebaseio.com",
"project_id": "mash-up-branding",
"storage_bucket": "mash-up-branding.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:597478389411:android:c47901b49939e134",
"mobilesdk_app_id": "1:581346452831:android:fdf96ca12b5fcac38682ea",
"android_client_info": {
"package_name": "com.mashup"
}
},
"oauth_client": [
{
"client_id": "597478389411-19ehgumjch2elmoo04fenm3t6t3u3v8v.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.mashup",
"certificate_hash": "ef34437c94225a33ded1a0a6b8c8ee7b9f6a459b"
}
},
{
"client_id": "597478389411-t2sha7meoh1m0irjo458668toujcieji.apps.googleusercontent.com",
"client_id": "581346452831-oeucev3imlc3rubofn7eq8av5snsclil.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBEE3Rg6FRCcvV66UU2nbPpypMEw4v9mFc"
"current_key": "AIzaSyDnF-Syz3Q3O9N-jy-YX1Jx3MeyLFPmivM"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 2,
"other_platform_oauth_client": [
{
"client_id": "597478389411-t2sha7meoh1m0irjo458668toujcieji.apps.googleusercontent.com",
"client_id": "581346452831-oeucev3imlc3rubofn7eq8av5snsclil.apps.googleusercontent.com",
"client_type": 3
}
]
},
"ads_service": {
"status": 2
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/mashup/app/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.LiveData
import androidx.navigation.NavController
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.firebase.analytics.FirebaseAnalytics
import com.mashup.R
import com.mashup.util.setupWithNavController

class MainActivity : AppCompatActivity() {
private lateinit var firebaseAnalytics: FirebaseAnalytics

private var currentNavController: LiveData<NavController>? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
firebaseAnalytics = FirebaseAnalytics.getInstance(this)
if (savedInstanceState == null) {
setupBottomNavigationBar()
} // Else, need to wait for onRestoreInstanceState
Expand Down
50 changes: 25 additions & 25 deletions app/src/main/java/com/mashup/ext/FirestoreExt.kt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
package com.mashup.ext

import com.google.firebase.firestore.DocumentReference
import com.google.firebase.firestore.Query
import io.reactivex.Single

inline fun <reified T> Query.toSingle(): Single<List<T>> = Single.create { emitter ->
get().addOnSuccessListener {
emitter.onSuccess(it.toObjects(T::class.java))
}.addOnFailureListener {
emitter.onError(it)
}
}


inline fun <reified T> DocumentReference.toSingle(): Single<T> = Single.create { emitter ->
get().addOnSuccessListener {
val item = it.toObject(T::class.java)
if (item == null) {
emitter.onError(NullPointerException("item is null"))
} else {
emitter.onSuccess(item)
}
}.addOnFailureListener {
emitter.onError(it)
}
}
//import com.google.firebase.firestore.DocumentReference
//import com.google.firebase.firestore.Query
//import io.reactivex.Single
//
//inline fun <reified T> Query.toSingle(): Single<List<T>> = Single.create { emitter ->
// get().addOnSuccessListener {
// emitter.onSuccess(it.toObjects(T::class.java))
// }.addOnFailureListener {
// emitter.onError(it)
// }
//}
//
//
//inline fun <reified T> DocumentReference.toSingle(): Single<T> = Single.create { emitter ->
// get().addOnSuccessListener {
// val item = it.toObject(T::class.java)
// if (item == null) {
// emitter.onError(NullPointerException("item is null"))
// } else {
// emitter.onSuccess(item)
// }
// }.addOnFailureListener {
// emitter.onError(it)
// }
//}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ buildscript {

firebase_firestore_version = "17.1.5"
firebase_auth_version = "16.1.0"
google_services_version = "4.0.1"
google_services_version = "4.3.3"
firebase_core_version = "16.0.1"
koin_version = '2.0.0-rc-2'
}
Expand Down

0 comments on commit 8b6ab88

Please sign in to comment.