@@ -49,6 +49,12 @@ public abstract class AbstractSpotifyPkceLoginActivity : AppCompatActivity() {
49
49
public open val state: String = Random .nextLong().toString()
50
50
public open val options: ((SpotifyApiOptions ).() -> Unit )? = null
51
51
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
+
52
58
private lateinit var authorizationIntent: Intent
53
59
private lateinit var credentialStore: SpotifyDefaultCredentialStore
54
60
@@ -144,7 +150,7 @@ public abstract class AbstractSpotifyPkceLoginActivity : AppCompatActivity() {
144
150
} else {
145
151
try {
146
152
logToConsole(" Building client PKCE api..." )
147
- setProgressBarVisible( )
153
+ setLoadingContent( true )
148
154
val api = spotifyClientPkceApi(
149
155
clientId = clientId,
150
156
redirectUri = redirectUri,
@@ -158,33 +164,25 @@ public abstract class AbstractSpotifyPkceLoginActivity : AppCompatActivity() {
158
164
logToConsole(" Successfully built client PKCE api" )
159
165
if (api.token.accessToken.isNotBlank()) {
160
166
credentialStore.spotifyToken = api.token
161
- setProgressBarInvisible( )
167
+ setLoadingContent( false )
162
168
logToConsole(" Successful PKCE auth. Executing success handler.." )
163
169
onSuccess(api)
164
170
} else {
165
- setProgressBarInvisible( )
171
+ setLoadingContent( false )
166
172
logToConsole(" Failed PKCE auth - API token was blank. Executing success handler.." )
167
173
onFailure(
168
174
IllegalArgumentException (" API token was blank" )
169
175
)
170
176
}
171
177
} catch (exception: Exception ) {
172
- setProgressBarInvisible( )
178
+ setLoadingContent( false )
173
179
logToConsole(" Got error in authorization... executing error handler" )
174
180
onFailure(exception)
175
181
}
176
182
}
177
183
178
- setProgressBarInvisible( )
184
+ setLoadingContent( false )
179
185
finish()
180
186
}
181
187
}
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
- }
190
188
}
0 commit comments