Android Open Source - AndroidPad J S O N Action






From Project

Back to project page AndroidPad.

License

The source code is released under:

Apache License

If you think the Android project AndroidPad 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.fb.droidpad;
//from  w  w  w  . ja  v a2  s .  com
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class JSONAction {
  private JSONObject json;
  
  public JSONAction(float eventX[], float eventY[], int motionEvent[]) throws JSONException {
    json = new JSONObject();
    
    int length = eventX.length;
    JSONArray array = new JSONArray();
    
    for (int i=0; i<length; i++) {
      JSONObject pointer = new JSONObject();
      pointer.put("x", eventX[i]);
      pointer.put("y", eventY[i]);
      pointer.put("motionEvent", motionEvent[i]);
      array.put(pointer);
    }
    json.put("pointers", array);
    this.json = json;
  }
  
  public void setGesture(int id) throws JSONException {
    JSONObject gesture = new JSONObject();
    gesture.put("type", id);
    json.put("gesture", gesture);
  }
  
  public String getJSON() {
    return this.json.toString();
  }
}




Java Source Code List

.TrackpadService.java
com.fb.droidpad.AboutFragment.java
com.fb.droidpad.JSONAction.java
com.fb.droidpad.MainActivity.java
com.fb.droidpad.MenuFragment.java
com.fb.droidpad.ServerSocketListener.java
com.fb.droidpad.ServerTask.java
com.fb.droidpad.SettingsFragment.java
com.fb.droidpad.TrackpadFragment.java