kodecocodes / adva-materials Goto Github PK
View Code? Open in Web Editor NEWThe projects and materials that accompany the Real-World Android by Tutorials book
License: Other
The projects and materials that accompany the Real-World Android by Tutorials book
License: Other
Switch to java.time.*, and core library desugaring instead of ThreeTen Android Backport.
I'm working through real-world-android-by-tutorials Chapter 4.4 Interceptors, Im following the code as far as I can see and am getting an error "Variable 'interceptedRequest' must be initialized " adding in the code block from "Handling valid tokens"
this is the function
override fun intercept(chain: Interceptor.Chain): Response {
// Replace with your code
val token = preferences.getToken()
val tokenExpirationTime =
Instant.ofEpochSecond(preferences.getTokenExpirationTime())
val request = chain.request()
// if(chain.request().headers[NO_AUTH_HEADER] != null) return
// chain.proceed()
val interceptedRequest: Request
if(tokenExpirationTime.isAfter(Instant.now())){
interceptedRequest =
chain.createAuthenticatedRequest(token)
}else{
}
return chain.proceedDeletingTokenIfUnauthorized(interceptedRequest)
//return chain.proceed(chain.request())
}
on the 17th line the method being called "chain.proceedDeletingTokenIfUnauthorized" and being passed "interceptedRequest", its throwing that error 'Variable 'interceptedRequest' must be initialized' but not sure why, the code is exactly what it appears as in the instruction. Maybe Im just getting poor vision, but I've tried invoking the "val" interceptedRequest(), but it doesnt like that, "initialized" seems like it is expecting to be assigned...
any help is greatly appreciated, I'll keep looking at it, I hope I do not need glasses. TIA
It seems the network API does not connect anymore.
It's hard to say exactly where since the application has been made unnecessarily complicated.
The version of gradle used in this project is out-of-date, recommend to upgrade.
classpath 'com.android.tools.build:gradle:4.1.2'
Current recommended version is 7.0.0.
The Kotlin version is pretty old too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.