Class Structure
Kii Balance is designed using the following class structure.
The classes with the stereotype <<Android>>
belong to the Android SDK and that with <<Kii>>
belongs to the Kii Cloud SDK. The classes whose background is pale blue are implemented in Kii Balance.
Each class corresponds to one of the screens of the user interface as shown in the figure below. The XML files in the figure represent the layout resources stored in the app/src/main/res/layout
directory.
The classes are included in the packages below:
The
com.kii.sample.balance
packageThe
MobileApp
class and theMainActivity
class are in this package.The
MobileApp
class inherits theApplication
class of Android, and is used to initialize the Kii Cloud SDK when the mobile app starts. For more information about the implementation, see the sections for AndroidManifest.xml and the Application class in the Hello Kii tutorial.The
MainActivity
class inherits theAppCompatActivity
class in the support library. This is the only activity in Kii Balance. Switching fragments opens the corresponding screen.The
com.kii.sample.balance.title
packageThis package includes the classes for the title screen.
When the internal view in the
MainActivity
class has aTitleFragment
instance, the title screen opens. Tapping the "LOGIN" button displaysLoginDialogFragment
and tapping the "REGISTER" button displaysRegistrationDialogFragment
as a dialog on the screen.After the input is completed, the login or user registration API of the Kii Cloud SDK is called according to the implementation of each dialog class. The data listing screen opens if the call is successful.
The
com.kii.sample.balance.list
packageThis package includes the classes for the data listing screen.
When the internal view in the
MainActivity
class has aBalanceListFragment
instance, the data listing screen opens.As with the implementation of the
ListFragment
class, eachKiiObject
is obtained via theKiiObjectAdapter
class.When the "+" button or an entry in the list is tapped,
ItemEditDialogFragment
is displayed for adding or editing an entry.The
com.kii.sample.balance.kiiobject
packageThis package consists of the
Field
interface that defines constants in theKiiObject
in Kii Balance and theConstants
class that defines AppID and so on.The
com.kii.util
packageThis package contains utility classes that are shared across the program.
This package consists of the
ViewUtil
class for making screen transitions and displaying a toast message, and theProgressDialogFragment
class for indicating the progress of a task.
Key points for implementation of mobile apps are explained later in this tutorial. For the other parts, analyze the source code by using this topic as a reference.
What's Next?
Let us quickly review techniques used in the sample code.