First attempt to create an Android app for Steemit
Intro
First and foremost I have to mention that I've just started with Java. This was a quite tempting project to start work on as a tutorial/course.
Starting up...
First step was to just create a base layout in order to see the results. I wanted to use the standard Android layouts as much as possible, with material theme. In the end it will be something like this:
It is just a basic layout for now with an ImageView
, and 2 TextView
to show what is going on.
OK fair point, this was start point for coding only. The start was to download JDK, Android Studio, set up my Honor 6 in USB debug mode, create the project, figure out Android version and the required packages for Gradle build. At this point I could start the design and dig down in to coding.
After came the harder bit
As I came to crack on the code first step was to create some AsyncTask
, mostly to keep the UI responsive while HTTP requests are pending. (Later it might have a loading state/screen.)
I've created a basic HttpService as well (with HttpURLConnection.openConnection
), but that isn't so interesting here. More on the fun side was to check out what do we have on APIs?
Actually it wasn't much of fun. I've learned the basics of Gradle, Java, Android Studio, and anything else required to develop an Android app (remember I've just started Java), but I have to admit the APIs of Steemit are massively undocumented.
Where did we start?
My desire was to create a simple Steemit Reader app as a start. Instead in the API documentations I've found many things on blocks, witnessing, transactions, and many probably really useful stuff. But not for this purpose. I mean what do you expect from a social media platform's API? Normally I would expect some capabilities to retrieve my and others profiles/feeds, and do some basic interactions (posting, like, comments, etc). As some other small platforms do, like the blue one, or that bird one.
I've found some websocket server, but it was another struggle so skip it for now. First I've retrieved my account info, and from there extracted my profile image url, what I could retrieve as an image afterwards. (This should be the point for caching my details and image, and only retrieve as a scheduled task.) As tried to move forward things were getting really challenging.
The closest thing to followed user's feeds was the list of their usernames I could get. Well, this is kind of interesting also why it is not included in the account details I've started with. It is almost like a friend list, like on Instagram or Twitter. Nevermind, so this was the 3rd AsyncTask
, at least I did not have to chain this one to the other two background calls. After a small data transformation I had a bit nicer list in memory now:
try {
JSONArray followedUsersSource = new JSONArray(response);
followedUsers = new ArrayList<String>();
for (int i = 0; i < followedUsersSource.length(); i++) {
JSONObject followedUser = followedUsersSource.getJSONObject(i);
followedUsers.add(followedUser.getString("following"));
}
logView.setText(followedUsers.toString());
} catch (JSONException e) {
e.printStackTrace();
}
Yes, you've seen it right no type definition before followedUsers
, as I'll need it later if I can find a source for their feeds to retrieve.
Recap
There are a few things to be done yet. At least I want to cache the initial results of the account, and subscribe to a websocket server on app start. That way I would be able to get some notifications, and/or get a real time news feed. I want to also include the reading part to open on a separate screen, perhaps with the ability to download all the contents with images included on refreshing the feed. This way it could be an offline reader as well, and get you notifications when someone posted who you are following.
The journey of a thousand miles begins with a step.
Who knows you may create the next biggest app. Keep the dream burning
Thanks the inspiring comment, the dream is far from this app. :)
Congratulations @koeroesi86! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
You made your First Comment
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP