Android Open Source - client-android Volume Event






From Project

Back to project page client-android.

License

The source code is released under:

Apache License

If you think the Android project client-android 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.qmonix.sdk;
/* w  ww.j av  a 2  s. c  om*/
import org.json.JSONObject;
import org.json.JSONException;

import com.qmonix.sdk.utils.Utils;


/**
 * Volume event class extends {@link Event Event}. Besides tag name and time when it was fired,
 * volume event also has a volume (quantity) associated associated with it.
 * <ul>
 * <li>{@link #getTag getTag} - returns event tag name
 * <li>{@link #getTimeArised getTimeArised} - returns event fire time.
 * <li>{@link #getVolume getVolume} - returns event volume.
 * <li>{@link #toJson toJson} encodes event information to JSON object.
 * </ul>
 */
public class VolumeEvent extends Event {

  protected long volume;


  /**
   * Constructs new single event with a specified tag name.
   *
   * @param tag event tag name.
   * @param timeArised Unix time stamp when event was fired.
   * @param volume event volume. Positive number.
   */
  public VolumeEvent(String tag, long timeArised, long volume) {
    super(tag, timeArised);

    if (volume < 0) {
      String msg = "Event volume must be positive integer.";
      throw new IllegalArgumentException(msg);
    }

    this.volume = volume;
  }

  /**
   * @return event volume.
   */
  public long getVolume() {
    return this.volume;
  }

  /**
   * Serializes event to JSON object which is ready to be encoded to event message. Event
   * fire time, volume and tag name are used.
   *
   * @return event encoded in JSON format.
   * @throws JSONException if fails to encode event message to JSON object.
   */
  public JSONObject toJson() throws JSONException {
    JSONObject json = super.toJson();
    json.put("volume", this.volume);

    return json;
  }
}




Java Source Code List

com.qmonix.sample.basic.MainActivity.java
com.qmonix.sdk.EventDispatchHandler.java
com.qmonix.sdk.EventDispatcher.java
com.qmonix.sdk.EventMessage.java
com.qmonix.sdk.Event.java
com.qmonix.sdk.FireableTimingEvent.java
com.qmonix.sdk.HttpEventDispatcher.java
com.qmonix.sdk.LogEventDispatcher.java
com.qmonix.sdk.QLog.java
com.qmonix.sdk.TimingEvent.java
com.qmonix.sdk.Tracker.java
com.qmonix.sdk.VolumeEvent.java
com.qmonix.sdk.helpers.HttpHelper.java
com.qmonix.sdk.helpers.exceptions.HttpHelperException.java
com.qmonix.sdk.utils.AsyncTaskResult.java
com.qmonix.sdk.utils.Utils.java