Android Open Source - growthpush-android External Framework Bridge






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.bridge;
// w ww.ja  v a2 s . c  o m
import java.util.ArrayList;
import java.util.List;

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

import android.os.Bundle;

public abstract class ExternalFrameworkBridge {

  protected List<String> customFileds = new ArrayList<String>();

  public void callbackWithStoredCustomFiled() {
    if (!customFileds.isEmpty()) {
      String message = customFileds.get(0);
      callbackExternalFramework(message);
      customFileds.remove(0);
    }
  }

  public void callbackExternalFrameworkWithExtra(Bundle bundle) {
    String message = serializeCustomFiled(bundle);
    callbackExternalFramework(message);
  }

  protected abstract void callbackExternalFramework(final String customFiled);

  private String serializeCustomFiled(Bundle bundle) {

    JSONObject json = new JSONObject();
    for (String key : bundle.keySet()) {

      String value = bundle.get(key).toString();
      if (key.equals("showDialog") || key.equals("collapse_key") || key.equals("from"))
        continue;
      try {
        if (key.equals("growthpush"))
          json.put(key, new JSONObject(value));
        else
          json.put(key, value);
      } catch (JSONException e) {
      }
    }

    return json.toString() != null ? json.toString() : null;

  }

}




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