Skip to content

Commit bfa7de9

Browse files
authored
Merge pull request #326 from adamint/dev/adamint/fix-progress-bar-and-maven-central-issues
Remove progress bar entirely, allow custom loading logic during PKCE login
2 parents 64c1843 + 4216255 commit bfa7de9

File tree

3 files changed

+11
-139
lines changed

3 files changed

+11
-139
lines changed

src/androidMain/kotlin/com/adamratzman/spotify/auth/pkce/AbstractSpotifyPkceLoginActivity.kt

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ public abstract class AbstractSpotifyPkceLoginActivity : AppCompatActivity() {
4949
public open val state: String = Random.nextLong().toString()
5050
public open val options: ((SpotifyApiOptions).() -> Unit)? = null
5151

52+
/**
53+
* Custom logic to invoke when loading begins ([isLoading] is true) or ends ([isLoading] is false).
54+
* You can update the view here.
55+
*/
56+
public open fun setLoadingContent(isLoading: Boolean) = {}
57+
5258
private lateinit var authorizationIntent: Intent
5359
private lateinit var credentialStore: SpotifyDefaultCredentialStore
5460

@@ -144,7 +150,7 @@ public abstract class AbstractSpotifyPkceLoginActivity : AppCompatActivity() {
144150
} else {
145151
try {
146152
logToConsole("Building client PKCE api...")
147-
setProgressBarVisible()
153+
setLoadingContent(true)
148154
val api = spotifyClientPkceApi(
149155
clientId = clientId,
150156
redirectUri = redirectUri,
@@ -158,33 +164,25 @@ public abstract class AbstractSpotifyPkceLoginActivity : AppCompatActivity() {
158164
logToConsole("Successfully built client PKCE api")
159165
if (api.token.accessToken.isNotBlank()) {
160166
credentialStore.spotifyToken = api.token
161-
setProgressBarInvisible()
167+
setLoadingContent(false)
162168
logToConsole("Successful PKCE auth. Executing success handler..")
163169
onSuccess(api)
164170
} else {
165-
setProgressBarInvisible()
171+
setLoadingContent(false)
166172
logToConsole("Failed PKCE auth - API token was blank. Executing success handler..")
167173
onFailure(
168174
IllegalArgumentException("API token was blank")
169175
)
170176
}
171177
} catch (exception: Exception) {
172-
setProgressBarInvisible()
178+
setLoadingContent(false)
173179
logToConsole("Got error in authorization... executing error handler")
174180
onFailure(exception)
175181
}
176182
}
177183

178-
setProgressBarInvisible()
184+
setLoadingContent(false)
179185
finish()
180186
}
181187
}
182-
183-
private fun setProgressBarInvisible() {
184-
findViewById<FrameLayout>(R.id.progress_overlay).visibility = View.INVISIBLE
185-
}
186-
187-
private fun setProgressBarVisible() {
188-
findViewById<FrameLayout>(R.id.progress_overlay).visibility = View.VISIBLE
189-
}
190188
}
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:wheel="http://schemas.android.com/apk/res-auto"
43
android:id="@+id/progress_overlay"
54
android:layout_width="match_parent"
65
android:layout_height="match_parent"
@@ -10,15 +9,4 @@
109
android:clickable="true"
1110
android:focusable="true"
1211
android:visibility="gone">
13-
14-
<com.pnikosis.materialishprogress.ProgressWheel
15-
android:id="@+id/progress_wheel"
16-
android:layout_width="80dp"
17-
android:layout_height="80dp"
18-
android:layout_gravity="center"
19-
android:indeterminate="true"
20-
android:indeterminateTint="#5588FF"
21-
wheel:matProg_barColor="#5588FF"
22-
wheel:matProg_progressIndeterminate="true" />
23-
2412
</FrameLayout>

src/commonTest/kotlin/com.adamratzman/spotify/utilities/HttpConnectionTests.kt

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)