Android Open Source - kido-android-tasks Kidozen Helper






From Project

Back to project page kido-android-tasks.

License

The source code is released under:

MIT License

If you think the Android project kido-android-tasks listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.kidozen.examples.services;
//  ww w .  j  av a 2 s.c o  m
import kidozen.client.KZApplication;
import kidozen.client.ServiceEvent;
import kidozen.client.ServiceEventListener;
import kidozen.client.Storage;

import org.json.JSONObject;

import android.util.Log;

public class KidozenHelper {
  private static final String TAG = "KidozenHelper";

  // TODO: Check if this can be included in the settings
  public static final String TENANT_MARKET_PLACE = "http://kidodemo.dev.kidozen.com/";
  public static final String APPLICATION = "tasks";
  public static final String PROVIDER = "Kidozen";
  public static final String KIDOZEN_USERNAME = "demo@kidozen.com";
  public static final String KIDOZEN_PASSWORD = "pass";
  public static final String SENDER_ID = "921202932497";

  // Kidozen application object
  public static KZApplication kidozenApplication;

  // Kidozen storage object
  public static Storage kidozenStorage;

  // Http status codes
  public static final int STATUS_OK = 200;
  public static final int STATUS_CREATED = 201;

  
  public void setUpKidozenApplication()
      throws Exception {
    Log.i(TAG, "setUpKidozen()");

    KidozenHelper.kidozenApplication = new KZApplication(
        KidozenHelper.TENANT_MARKET_PLACE, KidozenHelper.APPLICATION,
        applicationFinishCallback);
  }
  /**
   * Callback after creating an object of kidozen application
   */
  private ServiceEventListener applicationFinishCallback = new ServiceEventListener() {

    public void onFinish(ServiceEvent e) {
      Log.i(TAG, "applicationFinishCallback, STATUS: " + e.StatusCode);
    }
  };

  public void kidozenAuthentication(String userName, String password) {
    Log.i(TAG, "kidozenAuthentication()");

    kidozenApplication.Authenticate(KidozenHelper.PROVIDER, userName,
        password, authenticateCompletionListener);
  }

  private ServiceEventListener authenticateCompletionListener = new ServiceEventListener() {

    public void onFinish(ServiceEvent e) {
      Log.i(TAG, "authenticateCompletionListener, STATUS: " + e.StatusCode);

      if (e.StatusCode == KidozenHelper.STATUS_OK) {
        try {
          KidozenHelper.kidozenStorage = KidozenHelper.kidozenApplication.Storage("tasks");
        } catch (Exception e1) {
          Log.e(TAG, "kidozenAuthentication(), authenticateCompletionListener");
        }
      }

    }
  };
  
  public void CreateTask (JSONObject task, ServiceEventListener onCreateCallback) {
    KidozenHelper.kidozenStorage.Create(task, onCreateCallback);
  }
  
  public void GetTasks (String filter, ServiceEventListener onGetTasksFinish) {
    KidozenHelper.kidozenStorage.Query(filter, onGetTasksFinish);
  }
  
  public void UpdateTask(JSONObject task, String id, ServiceEventListener onUpdateCallback) {
    KidozenHelper.kidozenStorage.Update(task,id, onUpdateCallback);
  }
}




Java Source Code List

com.kidozen.examples.services.DataHelper.java
com.kidozen.examples.services.IKidozenApplicationSetup.java
com.kidozen.examples.services.IKidozenAuthentication.java
com.kidozen.examples.services.IKidozenEmail.java
com.kidozen.examples.services.ITaskDeleteComplete.java
com.kidozen.examples.services.ITaskQueryComplete.java
com.kidozen.examples.services.ITaskSaveComplete.java
com.kidozen.examples.services.ITaskServicesResponse.java
com.kidozen.examples.services.ITaskUpdateComplete.java
com.kidozen.examples.services.KidozenHelper.java
com.kidozen.examples.services.SharedKidozen.java
com.kidozen.examples.tasks.MainActivity.java
com.kidozen.examples.tasks.TasksFragment.java