| 175 | |
| 176 | let lastActivity: WeakRef<androidx.appcompat.app.AppCompatActivity>; |
| 177 | export class Firebase { |
| 178 | static _onResumeQueue = []; |
| 179 | static addToResumeQueue(callback: () => void) { |
| 180 | if (typeof callback !== 'function') { |
| 181 | return; |
| 182 | } |
| 183 | Firebase._onResumeQueue.push(callback); |
| 184 | } |
| 185 | static _activityResultContractsQueue = fromObject({}); |
| 186 | |
| 187 | static registerActivityResultContracts(callback: (args: AndroidActivityEventData & { dispose: boolean }) => void) { |
| 188 | if (typeof callback !== 'function') { |
| 189 | return; |
| 190 | } |
| 191 | Firebase._activityResultContractsQueue.on('register', callback); |
| 192 | } |
| 193 | |
| 194 | static unregisterActivityResultContracts(callback: (args: AndroidActivityEventData & { dispose: boolean }) => void) { |
| 195 | if (typeof callback !== 'function') { |
| 196 | return; |
| 197 | } |
| 198 | Firebase._activityResultContractsQueue.off('register', callback); |
| 199 | } |
| 200 | static _appDidLaunch = false; |
| 201 | static _inForeground = false; |
| 202 | static get inForeground() { |
| 203 | return Firebase._inForeground; |
| 204 | } |
| 205 | constructor() { |
| 206 | if (firebaseInstance) { |
| 207 | return firebaseInstance; |
| 208 | } |
| 209 | firebaseInstance = this; |
| 210 | Application.android.on('activityResumed', (args) => { |
| 211 | Firebase._inForeground = true; |
| 212 | Firebase._appDidLaunch = true; |
| 213 | Firebase._onResumeQueue.forEach((callback) => { |
| 214 | callback(); |
| 215 | }); |
| 216 | }); |
| 217 | |
| 218 | Application.android.on('activityPaused', (args) => { |
| 219 | Firebase._inForeground = false; |
| 220 | }); |
| 221 | |
| 222 | Application.android.once('activityCreated', (args: any) => { |
| 223 | if (!lastActivity) { |
| 224 | lastActivity = new WeakRef(args.activity); |
| 225 | Firebase._activityResultContractsQueue.notify({ |
| 226 | eventName: 'register', |
| 227 | activity: args.activity, |
| 228 | dispose: false, |
| 229 | }); |
| 230 | } |
| 231 | }); |
| 232 | |
| 233 | Application.android.on('activityDestroyed', (args) => { |
| 234 | const activity = lastActivity?.get?.(); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…