Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f085cb4

Browse files
harshithdwivedisamtstern
authored andcommitted
feat : more idiomatic kotlin (firebase#53)
1 parent ff4aa10 commit f085cb4

File tree

52 files changed

+324
-367
lines changed

Some content is hidden

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

52 files changed

+324
-367
lines changed

admob/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
34

45
android {
56
compileSdkVersion 27

admob/app/src/main/java/com/google/firebase/example/admob/kotlin/MainActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ class MainActivity : AppCompatActivity() {
1414
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID")
1515
}
1616
// [END ads_on_create]
17-
1817
}

appindexing/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
34

45
android {
56
compileSdkVersion 27

appindexing/app/src/main/java/com/google/firebase/example/appindexing/kotlin/AppIndexingUpdateReceiver.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ class AppIndexingUpdateReceiver : BroadcastReceiver() {
1515
AppIndexingUpdateService.enqueueWork(context)
1616
}
1717
}
18-
1918
}
2019
// [END appindexing_update_receiver]

appindexing/app/src/main/java/com/google/firebase/example/appindexing/kotlin/AppIndexingUpdateService.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,24 @@ import com.google.firebase.appindexing.FirebaseAppIndex
77
import com.google.firebase.appindexing.Indexable
88
import com.google.firebase.appindexing.builders.Indexables
99
import com.google.firebase.example.appindexing.model.Recipe
10-
import java.util.*
1110

1211
// [START appindexing_update_service]
1312
class AppIndexingUpdateService : JobIntentService() {
1413

1514
companion object {
1615

1716
// Job-ID must be unique across your whole app.
18-
private const val UNIQUE_JOB_ID = 42;
17+
private const val UNIQUE_JOB_ID = 42
1918

2019
fun enqueueWork(context: Context) {
2120
JobIntentService.enqueueWork(context, AppIndexingUpdateService::class.java, UNIQUE_JOB_ID, Intent())
2221
}
23-
2422
}
2523

2624
override fun onHandleWork(intent: Intent) {
2725
// TODO Insert your Indexable objects — for example, the recipe notes look as follows:
2826

29-
val indexableNotes = ArrayList<Indexable>()
27+
val indexableNotes = arrayListOf<Indexable>()
3028

3129
for (recipe in getAllRecipes()) {
3230
val note = recipe.note
@@ -42,7 +40,7 @@ class AppIndexingUpdateService : JobIntentService() {
4240
}
4341

4442
if (indexableNotes.size > 0) {
45-
val notesArr: Array<Indexable> = indexableNotes.toTypedArray<Indexable>()
43+
val notesArr: Array<Indexable> = indexableNotes.toTypedArray()
4644

4745
// batch insert indexable notes into index
4846
FirebaseAppIndex.getInstance().update(*notesArr)

appindexing/app/src/main/java/com/google/firebase/example/appindexing/kotlin/MainActivity.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class MainActivity : AppCompatActivity() {
4040
// ...
4141
}
4242

43-
fun getNoteCommentAction(): Action {
43+
private fun getNoteCommentAction(): Action {
4444
return Action.Builder(Action.Builder.COMMENT_ACTION)
4545
.setObject(note.title, note.noteUrl)
4646
// Keep action data for personal connulltent on the device
@@ -63,15 +63,14 @@ class MainActivity : AppCompatActivity() {
6363
}
6464
// [END appindexing_update]
6565

66-
fun removeAll() {
66+
private fun removeAll() {
6767
// [START appindexing_remove_all]
6868
FirebaseAppIndex.getInstance().removeAll()
6969
// [END appindexing_remove_all]
7070
}
7171

72-
fun getRecipeViewAction(): Action? {
72+
private fun getRecipeViewAction(): Action? {
7373
// This is just to make some things compile.
7474
return null
7575
}
76-
7776
}

appindexing/app/src/main/java/com/google/firebase/example/appindexing/kotlin/MeasureActivity.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.google.firebase.appindexing.AndroidAppUri
1010
// [START appindexing_measure_activity]
1111
class MeasureActivity : AppCompatActivity() {
1212

13-
override fun getReferrer() : Uri? {
13+
override fun getReferrer(): Uri? {
1414

1515
// There is a built in function available from SDK>=22
1616
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
@@ -31,7 +31,6 @@ class MeasureActivity : AppCompatActivity() {
3131
} catch (e: ParseException) {
3232
// ...
3333
}
34-
3534
}
3635

3736
return null
@@ -50,7 +49,6 @@ class MeasureActivity : AppCompatActivity() {
5049

5150
// Add analytics code below to track this click from web Search
5251
// ...
53-
5452
} else if (referrer.scheme == "android-app") {
5553
// App was opened from another app
5654
val appUri = AndroidAppUri.newAndroidAppUri(referrer)
@@ -62,7 +60,6 @@ class MeasureActivity : AppCompatActivity() {
6260

6361
// Add analytics code below to track this click from the Google app
6462
// ...
65-
6663
} else if ("com.google.appcrawler" == referrerPackage) {
6764
// Make sure this is not being counted as part of app usage
6865
// ...
@@ -71,6 +68,5 @@ class MeasureActivity : AppCompatActivity() {
7168
}
7269
// ...
7370
}
74-
7571
}
7672
// [END appindexing_measure_activity]

auth/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
34

45
android {
56
compileSdkVersion 27

auth/app/src/main/java/com/google/firebase/quickstart/auth/kotlin/FirebaseUIActivity.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import com.firebase.ui.auth.AuthUI
88
import com.firebase.ui.auth.IdpResponse
99
import com.google.firebase.auth.FirebaseAuth
1010
import com.google.firebase.quickstart.auth.R
11-
import java.util.*
1211

1312
abstract class FirebaseUIActivity : AppCompatActivity() {
1413

@@ -17,10 +16,10 @@ abstract class FirebaseUIActivity : AppCompatActivity() {
1716
setContentView(R.layout.activity_firebase_ui)
1817
}
1918

20-
fun createSignInIntent() {
19+
private fun createSignInIntent() {
2120
// [START auth_fui_create_intent]
2221
// Choose authentication providers
23-
val providers = Arrays.asList<AuthUI.IdpConfig>(
22+
val providers = arrayListOf(
2423
AuthUI.IdpConfig.EmailBuilder().build(),
2524
AuthUI.IdpConfig.PhoneBuilder().build(),
2625
AuthUI.IdpConfig.GoogleBuilder().build(),
@@ -58,7 +57,7 @@ abstract class FirebaseUIActivity : AppCompatActivity() {
5857
}
5958
// [END auth_fui_result]
6059

61-
fun signOut() {
60+
private fun signOut() {
6261
// [START auth_fui_signout]
6362
AuthUI.getInstance()
6463
.signOut(this)
@@ -68,7 +67,7 @@ abstract class FirebaseUIActivity : AppCompatActivity() {
6867
// [END auth_fui_signout]
6968
}
7069

71-
fun delete() {
70+
private fun delete() {
7271
// [START auth_fui_delete]
7372
AuthUI.getInstance()
7473
.delete(this)
@@ -78,7 +77,7 @@ abstract class FirebaseUIActivity : AppCompatActivity() {
7877
// [END auth_fui_delete]
7978
}
8079

81-
fun themeAndLogo() {
80+
private fun themeAndLogo() {
8281
val providers = emptyList<AuthUI.IdpConfig>()
8382

8483
// [START auth_fui_theme_logo]
@@ -93,7 +92,7 @@ abstract class FirebaseUIActivity : AppCompatActivity() {
9392
// [END auth_fui_theme_logo]
9493
}
9594

96-
fun privacyAndTerms() {
95+
private fun privacyAndTerms() {
9796
val providers = emptyList<AuthUI.IdpConfig>()
9897
// [START auth_fui_pp_tos]
9998
startActivityForResult(
@@ -111,6 +110,5 @@ abstract class FirebaseUIActivity : AppCompatActivity() {
111110
companion object {
112111

113112
private const val RC_SIGN_IN = 123
114-
115113
}
116114
}

0 commit comments

Comments
 (0)