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

Add Ktlint to enforce code styling #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
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.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package io.github.rosariopfernandes.firextensiossample

import androidx.test.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4
import org.junit.Assert.assertEquals

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.rosariopfernandes.firextensiossample

data class Todo(
var title: String,
var text: String
var title: String,
var text: String
) {
constructor(): this("", "")
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class TodoAdapter(var todos: ArrayList<Todo>?) : RecyclerView.Adapter<TodoAdapte
}

inner class TodoViewHolder(v: View) : RecyclerView.ViewHolder(v) {
var tvTitle:TextView? = null
var tvText:TextView? = null
var tvTitle: TextView? = null
var tvText: TextView? = null
init {
tvTitle = v.findViewById(R.id.tvTitle)
tvText = v.findViewById(R.id.tvText)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package io.github.rosariopfernandes.firextensiossample

import org.junit.Assert.assertEquals
import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ fun DatabaseReference.push(obj: Any): String {
* of the lambda function.
*/
inline fun DatabaseReference.push(
obj: Any,
crossinline action: (key: String?) -> Unit
obj: Any,
crossinline action: (key: String?) -> Unit
) {
val key = push().key
if (key == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import com.google.firebase.database.ValueEventListener
inline fun FirebaseDatabase.checkConnectionState(
crossinline action: (isConnected: Boolean) -> Unit
) {
getReference(".info/connected").addValueEventListener(object: ValueEventListener {
getReference(".info/connected").addValueEventListener(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
val isConnected = dataSnapshot.getValue(Boolean::class.java)
action(isConnected ?: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import com.google.firebase.database.ValueEventListener
inline fun <reified T> DatabaseReference.observe(
crossinline action: (data: T?, error: DatabaseError?) -> Unit
) {
addValueEventListener(object: ValueEventListener {
addValueEventListener(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
if(T::class.java == DataSnapshot::class.java) {
if (T::class.java == DataSnapshot::class.java) {
action(dataSnapshot as T, null)
} else {
action(dataSnapshot.getValue(T::class.java), null)
Expand All @@ -58,9 +58,9 @@ inline fun <reified T> DatabaseReference.observe(
inline fun <reified T> DatabaseReference.observeSingleEvent(
crossinline action: (data: T?, error: DatabaseError?) -> Unit
) {
addListenerForSingleValueEvent(object: ValueEventListener {
addListenerForSingleValueEvent(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
if(T::class.java == DataSnapshot::class.java) {
if (T::class.java == DataSnapshot::class.java) {
action(dataSnapshot as T, null)
} else {
action(dataSnapshot.getValue(T::class.java), null)
Expand All @@ -80,7 +80,7 @@ inline fun <reified T> DatabaseReference.observeSingleEvent(
inline fun <reified T> DatabaseReference.observeChildren(
crossinline action: (data: ArrayList<T>?, error: DatabaseError?) -> Unit
) {
addValueEventListener(object: ValueEventListener {
addValueEventListener(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
val data = ArrayList<T>()
for (snapshot in dataSnapshot.children) {
Expand All @@ -106,7 +106,7 @@ inline fun <reified T> DatabaseReference.observeChildren(
inline fun <reified T> DatabaseReference.observeSingleChildrenEvent(
crossinline action: (data: ArrayList<T>?, error: DatabaseError?) -> Unit
) {
addListenerForSingleValueEvent(object: ValueEventListener {
addListenerForSingleValueEvent(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
val data = ArrayList<T>()
for (snapshot in dataSnapshot.children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ inline fun <reified T> DocumentReference.getDocument(
} else {
action(null, NullPointerException("Document not found"))
}

} else {
action(null, task.exception)
}
Expand Down