-
Notifications
You must be signed in to change notification settings - Fork 0
Add default values for the StreamClient factory method
#33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
65dc1e8
Add default parameters for the creation method
aleksandar-apostolov 4808568
Update tests
aleksandar-apostolov 40b6e2b
Merge branch 'develop' into default-constructor
aleksandar-apostolov b4bd23b
Spotless
aleksandar-apostolov d5415ed
Merge remote-tracking branch 'origin/default-constructor' into defaul…
aleksandar-apostolov 742986e
Remove delay
aleksandar-apostolov e1b74c1
Remove redundant dispatchers
aleksandar-apostolov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
91 changes: 91 additions & 0 deletions
91
app/src/main/java/io/getstream/android/core/sample/SampleApp.kt
This file contains hidden or 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,91 @@ | ||
| /* | ||
| * Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-core-android/blob/main/LICENSE | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.getstream.android.core.sample | ||
|
|
||
| import android.annotation.SuppressLint | ||
| import android.app.Application | ||
| import android.os.Build | ||
| import io.getstream.android.core.api.StreamClient | ||
| import io.getstream.android.core.api.authentication.StreamTokenProvider | ||
| import io.getstream.android.core.api.model.config.StreamClientSerializationConfig | ||
| import io.getstream.android.core.api.model.value.StreamApiKey | ||
| import io.getstream.android.core.api.model.value.StreamHttpClientInfoHeader | ||
| import io.getstream.android.core.api.model.value.StreamToken | ||
| import io.getstream.android.core.api.model.value.StreamUserId | ||
| import io.getstream.android.core.api.model.value.StreamWsUrl | ||
| import io.getstream.android.core.api.serialization.StreamEventSerialization | ||
| import kotlinx.coroutines.CoroutineScope | ||
| import kotlinx.coroutines.Dispatchers | ||
| import kotlinx.coroutines.SupervisorJob | ||
|
|
||
| class SampleApp : Application() { | ||
|
|
||
| lateinit var streamClient: StreamClient | ||
| private val userId = StreamUserId.fromString("sample-user") | ||
| private val token = | ||
| StreamToken.fromString( | ||
| "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoicGV0YXIifQ.mZFi4iSblaIoyo9JDdcxIkGkwI-tuApeSBawxpz42rs" | ||
| ) | ||
aleksandar-apostolov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private val coroutinesScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) | ||
|
|
||
| companion object { | ||
| lateinit var instance: SampleApp | ||
| } | ||
|
|
||
| @SuppressLint("NotKeepingInstance") | ||
aleksandar-apostolov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| override fun onCreate() { | ||
| super.onCreate() | ||
| instance = this | ||
| streamClient = | ||
| StreamClient( | ||
| context = this.applicationContext, | ||
| scope = coroutinesScope, | ||
| apiKey = StreamApiKey.fromString("pd67s34fzpgw"), | ||
| userId = userId, | ||
| products = listOf("feeds", "chat", "video"), | ||
| wsUrl = | ||
| StreamWsUrl.fromString( | ||
| "wss://chat-edge-frankfurt-ce1.stream-io-api.com/api/v2/connect" | ||
| ), | ||
| clientInfoHeader = | ||
| StreamHttpClientInfoHeader.create( | ||
| product = "android-core", | ||
| productVersion = "1.1.0", | ||
| os = "Android", | ||
| apiLevel = Build.VERSION.SDK_INT, | ||
| deviceModel = "Pixel 7 Pro", | ||
| app = "Stream Android Core Sample", | ||
| appVersion = "1.0.0", | ||
| ), | ||
| tokenProvider = | ||
| object : StreamTokenProvider { | ||
| override suspend fun loadToken(userId: StreamUserId): StreamToken { | ||
| return token | ||
| } | ||
| }, | ||
| serializationConfig = | ||
| StreamClientSerializationConfig.default( | ||
| object : StreamEventSerialization<Unit> { | ||
| override fun serialize(data: Unit): Result<String> = Result.success("") | ||
|
|
||
| override fun deserialize(raw: String): Result<Unit> = | ||
| Result.success(Unit) | ||
| } | ||
| ), | ||
| ) | ||
| } | ||
| } | ||
158 changes: 0 additions & 158 deletions
158
app/src/main/java/io/getstream/android/core/sample/client/StreamClient.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.