Skip to content

Commit

Permalink
Merge pull request #56 from horaciocome1/set-up-markdown-support
Browse files Browse the repository at this point in the history
Set up markdown support
  • Loading branch information
horaciocome1 authored Sep 10, 2019
2 parents a058607 + 6fc04cc commit 6a2409e
Show file tree
Hide file tree
Showing 138 changed files with 4,472 additions and 3,529 deletions.
20 changes: 19 additions & 1 deletion .idea/assetWizardSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions .idea/navEditor.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ android {
applicationId "io.github.horaciocome1.reaque"
minSdkVersion 16
targetSdkVersion 29
versionCode 16
versionName "1.4.2-rc-35"
versionCode 17
versionName "1.5.0-rc-60"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
Expand All @@ -51,7 +51,7 @@ android {
dataBinding {
enabled = true
}
buildToolsVersion = '29.0.0'
buildToolsVersion = '29.0.2'
}

dependencies {
Expand All @@ -64,11 +64,11 @@ dependencies {
implementation 'androidx.multidex:multidex:2.0.1'

// lifecycle
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'

// ui
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.github.horaciocome1:simple-recyclerview-touch-listener:0.2.2'
implementation 'com.github.bumptech.glide:glide:4.9.0'
Expand All @@ -79,14 +79,14 @@ dependencies {
implementation "android.arch.navigation:navigation-ui-ktx:$nav_version"

// firebase
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-firestore:20.2.0'
implementation 'com.google.firebase:firebase-storage:18.1.1'
implementation 'com.google.firebase:firebase-auth:18.1.0'
implementation 'com.google.firebase:firebase-perf:18.0.1'
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.google.firebase:firebase-firestore:21.1.0'
implementation 'com.google.firebase:firebase-storage:19.0.1'
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-perf:19.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.google.firebase:firebase-dynamic-links:18.0.0'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'com.google.firebase:firebase-dynamic-links:19.0.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'

// play services
implementation 'com.google.android.gms:play-services-auth:17.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ class BookmarksService : BookmarksInterface {
}

override fun bookmark(post: Post, onCompleteListener: (Task<Void?>?) -> Unit) {
if (post.id.isNotBlank() && auth.currentUser != null) {
val bookmarkRef = db.document("users/${auth.currentUser!!.uid}/bookmarks/${post.id}")
if (
post.id.isNotBlank()
&& auth.currentUser != null
) {
val bookmarkRef = db.document(
"users/${auth.currentUser!!.uid}" +
"/bookmarks/${post.id}"
)
val postRef = db.document("posts/${post.id}")
val userRef = db.document("users/${auth.currentUser!!.uid}")
db.runBatch {
Expand All @@ -65,8 +71,14 @@ class BookmarksService : BookmarksInterface {
}

override fun unBookmark(post: Post, onCompleteListener: (Task<Void?>?) -> Unit) {
if (post.id.isNotBlank() && auth.currentUser != null) {
val bookmarkRef = db.document("users/${auth.currentUser!!.uid}/bookmarks/${post.id}")
if (
post.id.isNotBlank()
&& auth.currentUser != null
) {
val bookmarkRef = db.document(
"users/${auth.currentUser!!.uid}" +
"/bookmarks/${post.id}"
)
val postRef = db.document("posts/${post.id}")
val userRef = db.document("users/${auth.currentUser!!.uid}")
db.runBatch {
Expand All @@ -79,9 +91,12 @@ class BookmarksService : BookmarksInterface {

override fun get(): LiveData<List<Post>> {
posts.value?.let { list ->
if (list.isEmpty() && auth.currentUser != null)
if (
list.isEmpty()
&& auth.currentUser != null
)
db.collection("users/${auth.currentUser!!.uid}/bookmarks")
.orderBy("score", Query.Direction.DESCENDING)
.orderBy("timestamp", Query.Direction.DESCENDING)
.limit(100)
.get()
.addOnSuccessListener {
Expand All @@ -97,7 +112,10 @@ class BookmarksService : BookmarksInterface {
if (post.id.isNotBlank() && auth.currentUser != null)
db.document("users/${auth.currentUser!!.uid}/bookmarks/${post.id}")
.addSnapshotListener { snapshot, exception ->
isBookmarked.value = if (exception == null && snapshot != null)
isBookmarked.value = if (
exception == null
&& snapshot != null
)
if (snapshot.exists())
Constants.States.TRUE
else
Expand All @@ -113,7 +131,11 @@ class BookmarksService : BookmarksInterface {
if (auth.currentUser != null)
db.document("users/${auth.currentUser!!.uid}")
.addSnapshotListener { snapshot, exception ->
if (exception == null && snapshot != null && snapshot.contains("bookmarks"))
if (
exception == null
&& snapshot != null
&& snapshot.contains("bookmarks")
)
hasBookmarks.value = snapshot["bookmarks"].toString().toInt() > 0
}
return hasBookmarks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,25 @@ class ConfigurationsService : ConfigurationsInterface {
isUpdateAvailable.value = false
db.document("configurations/default")
.addSnapshotListener { snapshot, exception ->
if (exception == null && snapshot != null && snapshot.contains("version_code"))
isUpdateAvailable.value = versionCode < snapshot["version_code"].toString().toInt()
if (
exception == null
&& snapshot != null
&& snapshot.contains("version_code")
)
isUpdateAvailable.value = versionCode < snapshot["version_code"].toString()
.toInt()
}
return isUpdateAvailable
}

override fun getLatestVersionName(): LiveData<String> {
db.document("configurations/default")
.addSnapshotListener { snapshot, exception ->
if (exception == null && snapshot != null && snapshot.contains("version_name"))
if (
exception == null
&& snapshot != null
&& snapshot.contains("version_name")
)
latestVersionName.value = snapshot["version_name"].toString()
}
return latestVersionName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,37 @@ class FeedService : FeedInterface {
private var _posts = mutableListOf<Post>()

private val posts: MutableLiveData<List<Post>> by lazy {
MutableLiveData<List<Post>>().apply { value = mutableListOf() }
MutableLiveData<List<Post>>().apply {
value = mutableListOf()
}
}

override fun get(): LiveData<List<Post>> {
if (_posts.isEmpty() && auth.currentUser != null)
db.collection("users/${auth.currentUser!!.uid}/feed")
.orderBy("score", Query.Direction.DESCENDING)
.limit(100)
.get()
.addOnSuccessListener {
if (it != null) {
_posts = it.posts
posts.value = _posts
}
}
if (auth.currentUser == null)
auth.addAuthStateListener {
if (
_posts.isEmpty()
&& it.currentUser != null
&& _posts.isEmpty()
)
getFeed()
}
else if (_posts.isEmpty())
getFeed()
return posts
}

private fun getFeed() {
db.collection("users/${auth.currentUser!!.uid}/feed")
.orderBy("timestamp", Query.Direction.DESCENDING)
.limit(100)
.get()
.addOnSuccessListener {
if (it != null) {
_posts = it.posts
posts.value = _posts
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ class PostsService : PostsInterface {
}

private val topicPosts: MutableLiveData<List<Post>> by lazy {
MutableLiveData<List<Post>>().apply { value = mutableListOf() }
MutableLiveData<List<Post>>().apply {
value = mutableListOf()
}
}

private val userPosts: MutableLiveData<List<Post>> by lazy {
MutableLiveData<List<Post>>().apply { value = mutableListOf() }
MutableLiveData<List<Post>>().apply {
value = mutableListOf()
}
}

private val top10Posts: MutableLiveData<List<Post>> by lazy {
MutableLiveData<List<Post>>().apply { value = mutableListOf() }
MutableLiveData<List<Post>>().apply {
value = mutableListOf()
}
}

private var postId = ""
Expand All @@ -54,12 +60,24 @@ class PostsService : PostsInterface {
post.user = auth.currentUser!!.user
val postRef = db.collection("posts").document()
post.id = postRef.id
val postOnTopicRef = db.document("topics/${post.topic.id}/posts/${postRef.id}")
val postOnUserRef = db.document("users/${post.user.id}/posts/${postRef.id}")
val userOnTopicRef = db.document("topics/${post.topic.id}/users/${post.user.id}")
val postOnTopicRef = db.document(
"topics/${post.topic.id}" +
"/posts/${postRef.id}"
)
val postOnUserRef = db.document(
"users/${post.user.id}" +
"/posts/${postRef.id}"
)
val userOnTopicRef = db.document(
"topics/${post.topic.id}" +
"/users/${post.user.id}"
)
val topicRef = db.document("topics/${post.topic.id}")
val userRef = db.document("users/${post.user.id}")
val myFeedRef = db.document("users/${post.user.id}/feed/${postRef.id}")
val myFeedRef = db.document(
"users/${post.user.id}" +
"/feed/${postRef.id}"
)
db.runBatch {
it.set(postRef, post.map)
it.set(postOnTopicRef, post.mapSimple)
Expand Down Expand Up @@ -92,7 +110,7 @@ class PostsService : PostsInterface {
if (user.id != userId && user.id.isNotBlank()) {
userPosts.value = mutableListOf()
db.collection("users/${user.id}/posts")
.orderBy("score", Query.Direction.DESCENDING)
.orderBy("timestamp", Query.Direction.DESCENDING)
.limit(100)
.get()
.addOnSuccessListener {
Expand All @@ -108,7 +126,7 @@ class PostsService : PostsInterface {
if (topic.id != topicId && topic.id.isNotBlank()) {
topicPosts.value = mutableListOf()
db.collection("topics/${topic.id}/posts")
.orderBy("score", Query.Direction.DESCENDING)
.orderBy("timestamp", Query.Direction.DESCENDING)
.limit(100)
.get()
.addOnSuccessListener {
Expand Down
Loading

0 comments on commit 6a2409e

Please sign in to comment.