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 package

    The MobileApp class and the MainActivity class are in this package.

    The MobileApp class inherits the Application 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 the AppCompatActivity 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 package

    This package includes the classes for the title screen.

    When the internal view in the MainActivity class has a TitleFragment instance, the title screen opens. Tapping the "LOGIN" button displays LoginDialogFragment and tapping the "REGISTER" button displays RegistrationDialogFragment 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 package

    This package includes the classes for the data listing screen.

    When the internal view in the MainActivity class has a BalanceListFragment instance, the data listing screen opens.

    As with the implementation of the ListFragment class, each KiiObject is obtained via the KiiObjectAdapter 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 package

    This package consists of the Field interface that defines constants in the KiiObject in Kii Balance and the Constants class that defines AppID and so on.

  • The com.kii.util package

    This 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 the ProgressDialogFragment 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.

Go to Implemented Technique: Butter Knife.