Code Monkey home page Code Monkey logo

dhis2-android-sdk's Introduction

dhis2-android-sdk

Build Status

This project is in alpha mode. You are free to experiment with this project, but please give feedback through issues if things are not working properly. We are planning to have a stable beta version of this project by 1st June 2016

Include this project in your Android application project to take advantage of existing implementations of components that may be common for DHIS 2 Android apps!

Please note that this is a library project, and not a standalone application.

Do also note that this is an implementation of the generic DHIS 2 Java SDK. This is only an extension of the Java Client library for DHIS 2 that is the DHIS 2 Java SDK where platform specific aspects have been implemented for Android (storage and network interfaces). To read about the details and the use of the SDK, you should therefore visit the Wiki pages of the DHIS 2 Java SDK

However, briefly it can be said that the SDK includes:

  • Representations of data models such as Data Elements, Events, etc.
  • Existing implementations for connection to DHIS 2 server for retrieving data and sending data.
  • Local persistence for offline support.

The SDK requires functionality in the Web API added in the release of 2.21, so DHIS 2 versions 2.20 and lower will experience problems.

##Getting Started: In this section it is briefly explained how you can get started by logging in, loading assigned programs to device, and loading it from local storage.

###Working with RX: The SDK uses RxJava for asynchronous loading, which we encourage you to use, but if you don't want to it can simply be avoided. An example of loading Programs from local persistence into memory either using it or not using it follows: ####Using RxJava:

Observable<List<Program>> programObservable = D2.programs().list();
        programObservable.subscribe(new Action1<List<Program>>() {
            @Override
            public void call(List<Program> programs) {
                //do something
            }
        }, new Action1<Throwable>() {
            @Override
            public void call(Throwable throwable) {
                //handle error
            }
        });

####Not using RxJava:

List<Program> programs = D2.programs().list().toBlocking().first();

###Logging in:

Configuration configuration = new Configuration(serverUrl);
Observable<UserAccount> observable = D2.signIn(configuration, username, password);
        observable.subscribe(new Action1<UserAccount>() {
            @Override
            public void call(UserAccount userAccount) {
                // do something
            }
        }, new Action1<Throwable>() {
            @Override
            public void call(Throwable throwable) {
                // do something
            }
        });

###Synchronizing Assigned Programs onto device: After you have successfully logged in, you can simply load Assigned Programs by calling:

D2.me().syncAssignedPrograms();

This will load the assigned programs according to your user on the provided server, and save in local storage.

###Synchronizing Organisation Units onto device: The method for synchronizing Assigned Programs above will synchronize all Organisation Units that have Programs assigned to them, but if you want to load all Organisation Units onto your device, you can call:

D2.organisationUnits().sync();

Loading Programs from local persistence into memory: After you have successfully synchronized programs from the server onto the device, you can load it from persistence by calling:

Observable<List<Program>> programObservable = D2.programs().list();
        programObservable.subscribe(new Action1<List<Program>>() {
            @Override
            public void call(List<Program> programs) {
                //do something
            }
        }, new Action1<Throwable>() {
            @Override
            public void call(Throwable throwable) {
                //handle error
            }
        });

dhis2-android-sdk's People

Contributors

arazabishov avatar erlingfjelstad avatar longnt06658 avatar russnes avatar

Watchers

 avatar

dhis2-android-sdk's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.