forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xplat/js/react-native-github/packages/react-native/ReactAndroid/src/m…
…ain/java/com/facebook/react/common/network/OkHttpCallUtil.java Summary: Changelog: [Internal] Differential Revision: D60233395
- Loading branch information
1 parent
eae2240
commit 5f1306e
Showing
3 changed files
with
34 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
...t-native/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
...act-native/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.common.network | ||
|
||
import okhttp3.OkHttpClient | ||
|
||
/** | ||
* Helper class that provides the necessary methods for canceling queued and running OkHttp calls | ||
*/ | ||
public object OkHttpCallUtil { | ||
@JvmStatic | ||
public fun cancelTag(client: OkHttpClient, tag: Any) { | ||
for (call in client.dispatcher().queuedCalls()) { | ||
if (tag == call.request().tag()) { | ||
call.cancel() | ||
return | ||
} | ||
} | ||
for (call in client.dispatcher().runningCalls()) { | ||
if (tag == call.request().tag()) { | ||
call.cancel() | ||
return | ||
} | ||
} | ||
} | ||
} |