In a Nutshell
The Android Libary is written in JAVA and it contains all the code that a developer will need to connect to any of the supported Cloud Services, and to perform the supported Actions. In a series of articles we will describe this code and we will give example of its usage.
We use the Library by creating an instance of the Rainbow class. In order to do this, however, we need first to initialize it by calling the static method init:
You call this method only once in your app. The <Context> can be the application context or the root activity. If your app has only one activity then it is OK to set it to the context of that activity. Otherwise, it should be the application context. Then, we get the instance of the Rainbow class by calling the getInstance() method:
Rainbow rainbow = Rainbow.getInstance();
We use that instance to get the list of available Cloud Services. If a user is already connected to a service, that instance will give us an object of that account. Once we have that object we can perform all supported actions on that Cloud Account. But, before we get there it is important to describe the way that the Rainbow Library is designed.
The code of the Rainbow SDK consists of five packages:
- API: Code to connect to a Service and create an Account (ServiceItem)
- Service: Code that keeps track of the connected accounts (ServiceItems). It is also responsible for refreshing the Access Token
- ServiceItem: This object represents an account. It has all the variables that we need to connect to that account
- Cloud Manager: This is where the magic takes place. With this code we can perform all supported actions to an account.
- Transfer: Code that perform all kind of requests.
All classes start with an “R”. Thus, we have the RIDriveAPI.h and RIDriveAPI.m files. These two files have the API code for the iDrive Cloud Service.
The name of each of these package is a link. Click on it to learn more about it. In the meantime, it is important to state here that in order to create an instance of a Cloud Manager, we need an instance of a ServiceItem class. All ServiceItems are stored in an instance of the Service class. The Service class, uses an instance of the API class to create an instance of a ServiceItem.
Even though the above looks cumbersome and difficult to comprehend, it is extremely easy to use. As you can see in the Demo code, the Rainbow SDK takes care of all these steps, and you do not need to worry about anything.