Android Open Source - growthpush-android Tag






From Project

Back to project page growthpush-android.

License

The source code is released under:

Apache License

If you think the Android project growthpush-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.growthpush.model;
/*from w  ww.j  ava  2  s.  c o  m*/
import java.util.HashMap;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import com.growthpush.GrowthPush;

public class Tag extends Model {

  private int tagId;
  private String name;
  private long clientId;
  private String value;

  public Tag() {
    super();
  }

  public Tag(String name, String value) {
    this();
    setName(name);
    setValue(value);
  }

  public Tag save(GrowthPush growthPush) {

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("clientId", growthPush.getClient().getId());
    params.put("code", growthPush.getClient().getCode());
    params.put("name", name);
    params.put("value", value);

    JSONObject jsonObject = post("tags", params);
    if (jsonObject != null)
      setJsonObject(jsonObject);

    return this;

  }

  public int getTagId() {
    return tagId;
  }

  public void setTagId(int tagId) {
    this.tagId = tagId;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public long getClientId() {
    return clientId;
  }

  public void setClientId(long clientId) {
    this.clientId = clientId;
  }

  public String getValue() {
    return value;
  }

  public void setValue(String value) {
    this.value = value;
  }

  public JSONObject getJsonObject() {

    JSONObject jsonObject = new JSONObject();
    try {
      jsonObject.put("tagId", getTagId());
      jsonObject.put("clientId", getClientId());
      jsonObject.put("value", getValue());
    } catch (JSONException e) {
    }

    return jsonObject;

  }

  public void setJsonObject(JSONObject jsonObject) {

    try {
      if (jsonObject.has("tagId"))
        setTagId(jsonObject.getInt("tagId"));
      if (jsonObject.has("clientId"))
        setClientId(jsonObject.getLong("clientId"));
      if (jsonObject.has("value"))
        setValue(jsonObject.getString("value"));
    } catch (JSONException e) {
      throw new IllegalArgumentException("Failed to parse JSON.");
    }

  }

}




Java Source Code List

com.growthpush.BroadcastReceiver.java
com.growthpush.GrowthPushException.java
com.growthpush.GrowthPush.java
com.growthpush.Logger.java
com.growthpush.Preference.java
com.growthpush.Thread.java
com.growthpush.bridge.ExternalFrameworkBridge.java
com.growthpush.bridge.ExternalFrameworkBroadcastReceiver.java
com.growthpush.growthpushsample.MainActivity.java
com.growthpush.handler.BaseReceiveHandler.java
com.growthpush.handler.DefaultReceiveHandler.java
com.growthpush.handler.OnlyAlertReceiveHandler.java
com.growthpush.handler.OnlyNotificationReceiveHandler.java
com.growthpush.handler.ReceiveHandler.java
com.growthpush.model.ClientStatus.java
com.growthpush.model.Client.java
com.growthpush.model.Environment.java
com.growthpush.model.Error.java
com.growthpush.model.Event.java
com.growthpush.model.Model.java
com.growthpush.model.Tag.java
com.growthpush.utils.DeviceUtils.java
com.growthpush.utils.IOUtils.java
com.growthpush.utils.PermissionUtils.java
com.growthpush.utils.SystemUtils.java
com.growthpush.view.AlertActivity.java
com.growthpush.view.AlertFragment.java
com.growthpush.view.DialogCallback.java