Retrofit
Clicker
Retrofit | Clicker | |
---|---|---|
47 | 6 | |
42,662 | 6 | |
0.3% | - | |
9.1 | 1.8 | |
11 days ago | about 14 hours ago | |
HTML | Kotlin | |
Apache License 2.0 | - |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Retrofit
-
Using Retrofit Interceptors to check network connection in Android and testing it
from this point on, I will assume, you have a basic understanding of Retrofit. To get the most out of this tutorial I would actually suggest you have a retrofit client already implemented in your application.
-
Lets make a Twitch Android app. Part 1. App access tokens
Now you might think that in order to make the request we are going to use Retrofit but in reality we are going to be sending out an implicit intent like so:
-
Using OAuth2.0 and Retrofit to talk to the GitHub api on Android
This particular blog post will be us building on the information from the previous blog post and using the authorization code from the GitHub OAuth API in combination with Retrofit. To finally get a access token, which allows us to make requests to the API on a behalf of a user.
-
Show HN: Turn Your APIs into Swift Protocols
Hey HN!
If you're a fan of Swift you may have noticed that with WWDC 2023 came the (beta) release of macros. They're super powerful and expressive!
I've been wishing Swift had a [Retrofit](https://square.github.io/retrofit/) style API definition library for years, and with macros it seemed like this was now possible.
I'd like to show you all Papyrus, a library that turns your APIs into type-safe Swift protocols.
Would love to get your feedback.
https://github.com/joshuawright11/papyrus
-
Looking for android java developer mentor
When it comes to consuming APIs I can definitely recommend Retrofit. Hopefully that's enough to get you started on where to look!
-
Akka-HTTP in android
For Android you should use a more mobile friendly framework like Retrofit or if you use Kotlin you can use the multi-platform Ktor library with it's client module
-
Google play closed testing
for example https://square.github.io/retrofit/ have mentioned it in at the bottom. Similarly there maybe other rules for other dependencies. Usually I search the missing classes error in google and find some proguard rule for it.
-
What stack to use for app with functionality like event calendar?
Retrofit in combination with OkHttp for fetching data from server (which hopefully already exists)
-
Connecting an API (Java Spring) to an Android application
The first get request is to retrieve a list of objects and the second one is to get a single one. You can read more about RetroFit here.
-
Moving from iOS development and I have a question about finding dependencies
So I've been playing around with search.maven.org and perhaps I'm not quite understanding it. For example, if I look for Retrofit I'm not seeing anything that resembles retrofit above https://central.sonatype.dev/search?q=Retrofit.
Clicker
-
Weekly goals of Modderz Android app . 2024-04-22
1) System level chat messages
-
Using Retrofit Interceptors to check network connection in Android and testing it
Entire GitHub application code
-
The rules I am using to organize and document my Jetpack Compose code
live list, HERE
-
How I am documenting my interfaces in Kotlin
HERE
-
Lets make a Twitch Android app. Part 2. The secret to implementing chat
@Composable fun AnotherTesting(){ val context = LocalContext.current val html = "" AndroidView( factory = { WebView(context).apply { webViewClient = WebViewClient() webChromeClient = WebChromeClient() settings.loadsImagesAutomatically = true settings.javaScriptEnabled = true settings.allowFileAccess = true settings.javaScriptCanOpenWindowsAutomatically = true settings.mediaPlaybackRequiresUserGesture = false settings.domStorageEnabled = true settings.cacheMode = WebSettings.LOAD_NO_CACHE loadDataWithBaseURL("https://player.twitch.tv/", html, "text/html", "UTF-8", null) } } ) }
Enter fullscreen mode Exit fullscreen mode- Now I would like to point out that with this compose version I was only able to get the audio version working. This is most like do to my lack of experience of working with the
AndroidView
. So if your mind is set on using the compose system, know that you may have to mess around with theAndroidView
a little longer. However, due to the simplicity of itjust working
, I have decided to stick with the simple XML implementation
Embedding the chat
- This is a little trickier, mainly because the documentation tells us that we just need to embed the video and chat together. However, this does not result in the best user experience. Also, the user has to sign in through the WebView to chat(Which is considered an anti practice and a attack vector for hackers)
The secret : I believe the secret to creating a better twitch chat experience than the embedded version is to treat our application as a chatbot and to implement Twitch’s IRC service. The downside being that we will have to entirely recreate the Twitch chat experience. However, we will get the freedom to recreate the UI as we see fit. There is another downside of Rate Limits. At this moment I am uncertain if the each individual user would be treated as a separate bot or if all users get treated collectively as one bot. But once I find supporting documentation I will post it here.
We can implement Twitch’s IRC service with the help of WebSockets provided to us by the engineering team at square.
Technically the first thing we need to do to get the chat up and running is to authenticate our application and get a
user access token
. You can see how to do that through my previous postOnce you have a user access token, we can move on to implementing a Websocket and connecting to the twitch IRC servers. We need to create a new class and have it implement the WebSocketListener class.
You can check out my github version HERE, although with the current version you have to hard code your
user access token
.
But to get us started, it will look something like this:
class TwitchWebSocket(): WebSocketListener() { val webSocketURL = "wss://irc-ws.chat.twitch.tv:443" init { run() } private fun run() { val client: OkHttpClient = OkHttpClient.Builder() .readTimeout(1000,TimeUnit.MILLISECONDS) .writeTimeout(1000,TimeUnit.MILLISECONDS) .build() val request: Request = Request.Builder() .url(webSocketURL) .build() client.newWebSocket(request, this) // Trigger shutdown of the dispatcher's executor so this process can exit cleanly. client.dispatcher.executorService.shutdown() }
Enter fullscreen mode Exit fullscreen mode- Then we need to override the onOpen() method and send the PASS and NICK messages. Implemented like so:
override fun onOpen(webSocket: WebSocket, response: Response) { super.onOpen(webSocket, response) webSocket.send("CAP REQ :twitch.tv/tags twitch.tv/commands"); //todo: add the User access tokens after oauth: webSocket.send("PASS oauth:yourToken"); webSocket.send("NICK username"); }
Enter fullscreen mode Exit fullscreen mode- Also, we need to log the results:
override fun onMessage(webSocket: WebSocket, text: String) { Log.d("websocketStoof","onMessage: ${text}") }
Enter fullscreen mode Exit fullscreen mode- Doing everything correctly should give you back a message of:
:tmi.twitch.tv 001 :Welcome, YourUsername! :tmi.twitch.tv 002 :Your host is tmi.twitch.tv :tmi.twitch.tv 003 :This server is rather new :tmi.twitch.tv 004 :- :tmi.twitch.tv 375 :- :tmi.twitch.tv 372 :You are in a maze of twisty passages. :tmi.twitch.tv 376 :> @badge-info=;badges=;color=;display-name=;emote-sets=0,300374282;user-id=12345678;user-type= :tmi.twitch.tv GLOBALUSERSTATE
Enter fullscreen mode Exit fullscreen modeWhat is next?
- Next tutorial I will clean up the code and we will walk through actually joining a chat room. We might even be able to send our first messages through our app!!!!!!!
Conclusion
- Thank you for taking the time out of your day to read this blog post of mine. If you have any questions or concerns please comment below or reach out to me on Twitter.
- Now I would like to point out that with this compose version I was only able to get the audio version working. This is most like do to my lack of experience of working with the
-
Using OAuth2.0 and Retrofit to talk to the GitHub api on Android
GitHub
What are some alternatives?
Feign - Feign makes writing java http clients easier
OkHttp - Square’s meticulous HTTP client for the JVM, Android, and GraalVM.
Async Http Client - Asynchronous Http and WebSocket Client library for Java
unirest-java - Unirest in Java: Simplified, lightweight HTTP client library.
Android Volley
Jersey - Eclipse Jersey Project - Read our Wiki:
android-async-http - An asynchronous, callback-based Http client for Android built on top of Apache's HttpClient libraries.
RESTEasy - An Implementation of the Jakarta RESTful Web Services Specification
Dropwizard - A damn simple library for building production-ready RESTful web services.
AndroidNetworking - 🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀
robospice
Swagger - The content of swagger.io