Skip to content
This repository was archived by the owner on Jun 19, 2020. It is now read-only.

Commit 076d75c

Browse files
committed
� Conflicts: � .idea/codeStyles/Project.xml
2 parents 4062020 + 1abf647 commit 076d75c

File tree

81 files changed

+390
-1578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+390
-1578
lines changed
51 Bytes
Binary file not shown.

.idea/misc.xml

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.opensource/project.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,9 @@
55
],
66
"content": "README.md",
77
"pages" : {
8-
"tutorials/realtime-database.md": "Realtime Database Tutorial",
9-
"tutorials/cloud-firestore.md": "Cloud Firestore Tutorial",
10-
"docs/README.md": "Reference Docs"
8+
"docs/analytics.md": "Analytics fireXtensions"
119
},
1210
"related": [
1311
"firebase/firebase-android-sdk"
14-
],
15-
"tabs": [
16-
{
17-
"title": "Reference Docs",
18-
"href": "http://rosariopfernandes.me/fireXtensions/"
19-
}
2012
]
2113
}

README.md

Lines changed: 5 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -3,188 +3,16 @@ https://firebaseopensource.com/projects/rosariopfernandes/firextensions
33
)
44
[![](https://jitpack.io/v/rosariopfernandes/fireXtensions.svg)](https://jitpack.io/#rosariopfernandes/fireXtensions)
55

6-
# fireXtensions [DEPRECATED]
7-
8-
**THIS LIBRARY IS NOW DEPRECATED IN FAVOR OF THE
9-
[OFFICIAL FIREBASE KTX LIBRARIES](https://firebaseopensource.com/projects/firebase/firebase-android-sdk/#kotlin_extensions).**
10-
11-
**PLEASE NOTE THAT NOT ALL THE FIREXTENSIONS ARE PRESENT IN THE OFFICIAL KTX, THAT'S BECAUSE SOME
12-
FIREXTENSIONS WOULD CAUSE MEMORY LEAKS WHILE OTHER SIMPLY DID NOT ADD MUCH VALUE TO THE SDK. IF YOU FIND
13-
A FIREXTENSION WITH NO CORRESPONDING KTX, YOU'LL HAVE TO STICK TO THE OFFICIAL KOTLIN USAGE.
14-
APOLOGIES FOR THAT.**
15-
16-
**THANKS FOR EVERYONE WHO CONTRIBUTED, SUPPORTED OR USED FIREXTENSIONS!**
6+
# fireXtensions
177

188
## Introduction
199

2010
fireXtensions are a set of Kotlin extension functions that aim to simplify the way you use the
2111
Firebase SDK for Android.
2212

23-
### Realtime Database
24-
See all examples on the [Tutorial](tutorials/realtime-database.md).
25-
26-
**Kotlin**
27-
```kotlin
28-
ref.addValueEventListener(object: ValueEventListener {
29-
override fun onDataChange(dataSnapshot: DataSnapshot) {
30-
val data = dataSnapshot.getValue(String::class.java)
31-
//Update the UI with received data
32-
}
33-
34-
override fun onCancelled(error: DatabaseError) {
35-
//print error.message
36-
}
37-
})
38-
```
39-
40-
**fireXtensions**
41-
```kotlin
42-
ref.observe<DataSnapshot> { dataSnapshot, _ ->
43-
dataSnapshot?.let {
44-
val data = dataSnapshot.getValue(String::class.java)
45-
//Update the UI with received data
46-
}
47-
}
48-
```
49-
----
50-
**Kotlin**
51-
```kotlin
52-
ref.addValueEventListener(object: ValueEventListener {
53-
override fun onDataChange(dataSnapshot: DataSnapshot) {
54-
val todo = dataSnapshot.getValue(Todo::class.java)
55-
//Update the UI with received data
56-
}
57-
58-
override fun onCancelled(error: DatabaseError) {
59-
//print error.message
60-
}
61-
})
62-
```
63-
64-
**fireXtensions**
65-
```kotlin
66-
ref.observe<Todo> { todo, _ ->
67-
todo?.let {
68-
//Update the UI with received data
69-
}
70-
}
71-
```
72-
----
73-
74-
**Kotlin**
75-
```kotlin
76-
ref.addValueEventListener(object: ValueEventListener {
77-
override fun onDataChange(dataSnapshot: DataSnapshot) {
78-
val todos = ArrayList<Todo>()
79-
for (snapshot in dataSnapshot.children) {
80-
val todo = dataSnapshot.getValue(Todo::class.java)
81-
todos.add(todo!!)
82-
}
83-
//Update the UI with received list
84-
}
85-
86-
override fun onCancelled(error: DatabaseError) {
87-
//print error.message
88-
}
89-
})
90-
```
91-
**fireXtensions**
92-
```kotlin
93-
ref.observeChildren<Todo> { todos, error ->
94-
todos?.let {
95-
//Update the UI with received list
96-
}
97-
error.let {
98-
//print error.message
99-
}
100-
}
101-
```
102-
More can be found on the [Tutorial](tutorials/realtime-database.md).
103-
104-
----
105-
106-
### Cloud Firestore
107-
See all examples on the [Tutorial](tutorials/cloud-firestore.md).
108-
109-
**Kotlin**
110-
```kotlin
111-
val docRef = db.collection("cities").document("SF")
112-
// Source can be CACHE, SERVER or DEFAULT
113-
docRef.get(Source.CACHE).addOnCompleteListener { task ->
114-
if (task.isSuccessful()) {
115-
val document = task.result
116-
if (document.exists()) {
117-
Log.d(TAG, "DocumentSnapshot data: " + document.data)
118-
} else {
119-
Log.d(TAG, "No such document")
120-
}
121-
} else {
122-
Log.d(TAG, "get failed with ", task.exception)
123-
}
124-
}
125-
```
126-
127-
**fireXtensions**
128-
```kotlin
129-
// Source can be CACHE, SERVER or DEFAULT
130-
docRef.getDocument<DocumentSnapshot>(Source.CACHE) { document, exception ->
131-
document?.let {
132-
Log.d(TAG, "DocumentSnapshot data: " + document.data)
133-
}
134-
exception?.let {
135-
Log.d(TAG, "get failed with ", exception)
136-
}
137-
}
138-
```
139-
----
140-
141-
**Kotlin**
142-
```kotlin
143-
val docRef = db.collection("cities").document("BJ")
144-
docRef.get().addOnCompleteListener { task ->
145-
if (task.isSuccessful()) {
146-
val city = task.result.toObject(City::class.java)
147-
//Update UI with city
148-
}
149-
}
150-
```
151-
152-
**fireXtensions**
153-
```kotlin
154-
docRef.getDocument<City>() { city, _ ->
155-
city?.let {
156-
//update UI with city
157-
}
158-
}
159-
```
160-
More can be found on the [Tutorial](tutorials/cloud-firestore.md).
161-
162-
163-
## Getting Started
164-
Step 1 - Add the jitpack maven in your root build.gradle at the end of repositories:
165-
```gradle
166-
allprojects {
167-
repositories {
168-
...
169-
maven { url 'https://jitpack.io' }
170-
}
171-
}
172-
```
173-
Step 2 - Add **one** of the dependencies to your app's build.gradle:
174-
```gradle
175-
dependencies {
176-
// You can either import the whole library
177-
implementation 'com.github.rosariopfernandes:fireXtensions:0.3.4'
178-
179-
// or import database extensions only
180-
implementation 'com.github.rosariopfernandes.fireXtensions:database:0.3.4'
181-
182-
// or import firestore extensions only
183-
implementation 'com.github.rosariopfernandes.fireXtensions:firestore:0.3.4'
184-
}
185-
```
13+
## Available modules
18614

187-
Reference Docs: [rosariopfernandes.me/fireXtensions](http://rosariopfernandes.me/fireXtensions/)
15+
- [Analytics](docs/analytics.md)
18816

18917
## Contributing
19018
Anyone and everyone is welcome to contribute. Please take a moment to
@@ -193,7 +21,5 @@ review the [contributing guidelines](CONTRIBUTING.md).
19321
## License
19422
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
19523

196-
## Acknowledgments
197-
* Inspired by [Android KTX](https://github.com/android/android-ktx)
198-
* Some function names are based on the
199-
[Official Firebase SDK for iOS](https://firebase.google.com/docs/database/ios/read-and-write).
24+
## Acknowledgment
25+
Inspired by [Firebase KTX](https://firebaseopensource.com/projects/firebase/firebase-android-sdk/#kotlin_extensions)

analytics/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

analytics/build.gradle

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'com.github.dcendents.android-maven'
3+
group='io.github.rosariopfernandes'
4+
apply plugin: 'kotlin-android'
5+
apply plugin: 'kotlin-android-extensions'
6+
apply plugin: 'org.jetbrains.dokka-android'
7+
8+
android {
9+
compileSdkVersion 29
10+
buildToolsVersion "29.0.0"
11+
12+
13+
defaultConfig {
14+
minSdkVersion 16
15+
targetSdkVersion 29
16+
versionCode 1
17+
versionName '$firextensions_version'
18+
19+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
20+
consumerProguardFiles 'consumer-rules.pro'
21+
}
22+
23+
buildTypes {
24+
release {
25+
minifyEnabled false
26+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27+
}
28+
}
29+
30+
}
31+
32+
dependencies {
33+
implementation fileTree(dir: 'libs', include: ['*.jar'])
34+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
35+
implementation 'androidx.appcompat:appcompat:1.1.0'
36+
implementation 'androidx.core:core-ktx:1.2.0'
37+
38+
implementation 'com.google.firebase:firebase-common-ktx:19.3.0'
39+
implementation 'com.google.firebase:firebase-analytics:17.2.3'
40+
41+
42+
testImplementation 'junit:junit:4.12'
43+
testImplementation 'org.robolectric:robolectric:4.3.1'
44+
testImplementation 'androidx.test:core:1.2.0'
45+
testImplementation "com.google.truth:truth:1.0"
46+
androidTestImplementation 'androidx.test:runner:1.2.0'
47+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
48+
}
49+
50+
dokka {
51+
outputDirectory = "docs/reference"
52+
}

analytics/consumer-rules.pro

Whitespace-only changes.

analytics/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.github.rosariopfernandes.firextensions.analytics" />

0 commit comments

Comments
 (0)