Building a Crypto Tracker with Kotlin in Android (Part 3)

in #utopian-io7 years ago (edited)

What Will I Learn?

  • You will learn how to make various complex UI elements in Android with XML
  • You will learn how to use dependency injection to create an activity with Android
  • You will learn how to make a reactive splash screen activity in an Android Application with Kotlin

Requirements

  • Android Studio 3.0 or Android Studio Canary
  • A basic understanding of the Android ecosystem
  • A fair understanding of Kotlin or the Java programming language

Difficulty

  • Intermediate

Description

In this tutorial, we build out all of our XML layouts and we setup our splash screen activity using dependency injection. Seven different layouts were created for this application. We have a main skeleton layout which uses a Recycler View to hold all of the coin item components inside of it as a scrolling list. We then create our coin item components and an extended coin item component which will be used to display all of the data that we are bringing in from the API. These items use text views and linear layouts to mark each data field with a tag. We create two dialog boxes, one for a settings menu and another to allow the user to close out of the application in a clean way. We also create a splash screen activity layout which has a large image view on it and the title. The final layout in this application is just a smaller header layout which will serve as a title layout.

Having created our layouts, we then create the classes and interface needed for our Splash Screen activity. We create an interface for to implement functions that will either go forward to the Home Activity or present an error message to the user based on the internet connectivity of the device. If there is no network connection, the application will stay on the splash screen and a Snackbar will open at the bottom. This Snackbar will alert the user that there is no internet connection and it will allow the user reload the application.

Because we are using the dependency injection pattern in this application, we implement our activities in such a way that they are injected into the main activity based on the context of the application at a given moment. When the application starts, the splash screen is passed in as the main activity and it is swapped out with the home activity if we have network connectivity. In this way, it is also very easy for us to provide data to our activities from other areas of the application. We inject the main resource providers into the main activity and then inject the sub activities into the main activity as well. The application compiles and runs until it requests the main activity, which will be created in the final tutorial. If we disable the network connection on the device, then the application will not crash because the home activity is never requested.

The source code for this project can be found here

Video Tutorial

Curriculum

Related Content

  • Android Applications in Kotlin
  • Desktop Applications in Kotlin
  • Intro to Kotlin Series



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

That was very fast. Thank you for your hard work.

Hey @ewq, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

This is a test comment, notify @kryzsec on discord if there are any errors please.


GuidelinesProject Update

Being A SteemStem Member

Hey @tensor I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.19
TRX 0.16
JST 0.033
BTC 64261.31
ETH 2787.80
USDT 1.00
SBD 2.66