Skip to content

Commit

Permalink
android [nfc]: Inline the sendEvent helper.
Browse files Browse the repository at this point in the history
This is single-use and very small, so there wasn't much we were
gaining by having it as its own method.
  • Loading branch information
gnprice committed Jul 18, 2020
1 parent f9597fa commit e9ebc89
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions android/app/src/main/java/com/zulipmobile/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.zulipmobile

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.webkit.WebView
import androidx.annotation.Nullable
import com.facebook.react.ReactActivity
import com.facebook.react.ReactApplication
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.WritableMap
import com.zulipmobile.notifications.*
import com.zulipmobile.sharing.SharingModule
Expand All @@ -26,13 +23,6 @@ open class MainActivity : ReactActivity() {
return "ZulipMobile"
}

private fun sendEvent(reactContext: ReactContext,
eventName: String,
@Nullable params: WritableMap) {
Log.d(TAG, "Sending event with shared data")
emit(reactContext, eventName, params)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WebView.setWebContentsDebuggingEnabled(true)
Expand Down Expand Up @@ -67,10 +57,12 @@ open class MainActivity : ReactActivity() {
SharingModule.initialSharedData = params
Log.d(TAG, "Sharing data as initialSharedData")
}
ReactAppStatus.BACKGROUND, ReactAppStatus.FOREGROUND ->
ReactAppStatus.BACKGROUND, ReactAppStatus.FOREGROUND -> {
// JS is running and has already reached foreground. It won't check
// initialSharedData again, but it will see a shareReceived event.
sendEvent(reactContext, "shareReceived", params)
Log.d(TAG, "Sending event with shared data")
emit(reactContext, "shareReceived", params)
}
}
}

Expand Down

0 comments on commit e9ebc89

Please sign in to comment.