├── .gitignore ├── Example ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── tgio │ │ └── parselivequery │ │ └── example │ │ ├── Application.java │ │ └── MainActivity.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── LICENSE ├── README.md ├── Server ├── package.json └── server.js ├── bintray.gradle ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── install.gradle ├── parse-livequery ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── tgio │ │ └── parselivequery │ │ ├── BaseQuery.java │ │ ├── Constants.java │ │ ├── Event.java │ │ ├── LiveQueryClient.java │ │ ├── LiveQueryEvent.java │ │ ├── RxBus.java │ │ ├── Subscription.java │ │ └── interfaces │ │ └── OnListener.java │ └── res │ └── values │ └── strings.xml ├── script.sh └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | /script.sh 9 | /Server/logs -------------------------------------------------------------------------------- /Example/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Example/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | android { 3 | compileSdkVersion 25 4 | buildToolsVersion '25.0.2' 5 | 6 | defaultConfig { 7 | applicationId "tgio.parselivequery.example" 8 | minSdkVersion 16 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile project(':parse-livequery') 23 | compile 'com.android.support:appcompat-v7:25.1.0' 24 | compile 'com.parse:parse-android:1.13.1' 25 | // compile 'com.github.tgio:parse-livequery:1.0.3' 26 | } 27 | -------------------------------------------------------------------------------- /Example/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/pro/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /Example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Example/src/main/java/tgio/parselivequery/example/Application.java: -------------------------------------------------------------------------------- 1 | package tgio.parselivequery.example; 2 | 3 | import com.parse.Parse; 4 | 5 | import tgio.parselivequery.LiveQueryClient; 6 | 7 | /** 8 | * Created by pro on 16-07-08. 9 | */ 10 | public class Application extends android.app.Application { 11 | public static final String WS_URL = "ws://192.168.0.100:4040/"; 12 | public static final String MY_APP_ID = "myAppId"; 13 | public static String SERVER = "http://192.168.0.100:1337/parse/"; 14 | public static String CLIENT_KEY = "2ead5328dda34e688816040a0e78948a"; 15 | 16 | @Override 17 | public void onCreate() { 18 | super.onCreate(); 19 | Parse.initialize(new Parse.Configuration.Builder(this) 20 | .applicationId(MY_APP_ID) 21 | .server(SERVER) 22 | .clientKey(CLIENT_KEY) 23 | .build() 24 | ); 25 | 26 | LiveQueryClient.init(WS_URL, MY_APP_ID, true); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Example/src/main/java/tgio/parselivequery/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package tgio.parselivequery.example; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.util.Log; 6 | import android.view.View; 7 | import android.widget.Button; 8 | import android.widget.EditText; 9 | import android.widget.TextView; 10 | 11 | import com.parse.ParseObject; 12 | 13 | import org.json.JSONObject; 14 | 15 | import tgio.parselivequery.LiveQueryClient; 16 | import tgio.parselivequery.BaseQuery; 17 | import tgio.parselivequery.LiveQueryEvent; 18 | import tgio.parselivequery.Subscription; 19 | import tgio.parselivequery.interfaces.OnListener; 20 | 21 | public class MainActivity extends AppCompatActivity { 22 | 23 | private TextView resultView; 24 | private Button mConnectButton; 25 | private Button mDisconnectButton; 26 | private Button mUnsubscribeButton; 27 | private Button mSendButton; 28 | private EditText mMessageEditText; 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_main); 34 | 35 | resultView = (TextView) findViewById(R.id.resultView); 36 | mUnsubscribeButton = (Button) findViewById(R.id.unsubscribe); 37 | mConnectButton = (Button) findViewById(R.id.connect); 38 | mDisconnectButton = (Button) findViewById(R.id.disconnect); 39 | mSendButton = (Button) findViewById(R.id.send); 40 | mMessageEditText = (EditText) findViewById(R.id.message); 41 | 42 | // Connection, when starts or by Connect Button 43 | //LiveQueryClient.connect(); 44 | 45 | LiveQueryClient.on(LiveQueryEvent.CONNECTED, new OnListener() { 46 | @Override 47 | public void on(final JSONObject object) { 48 | // Subscribe to any event if you need as soon as connect to server 49 | runOnUiThread(new Runnable() { 50 | @Override 51 | public void run() { 52 | resultView.append(object.toString() + "\n"); 53 | } 54 | }); 55 | 56 | } 57 | }); 58 | 59 | LiveQueryClient.on(LiveQueryEvent.SUBSCRIBED, new OnListener() { 60 | @Override 61 | public void on(final JSONObject object) { 62 | runOnUiThread(new Runnable() { 63 | @Override 64 | public void run() { 65 | resultView.append(object.toString() + "\n"); 66 | } 67 | }); 68 | } 69 | }); 70 | 71 | // Subscription 72 | final Subscription subscription = new BaseQuery.Builder("Message") 73 | .where("body", "asd") 74 | .addField("body") 75 | .build() 76 | .subscribe(); 77 | 78 | // Listen 79 | subscription.on(LiveQueryEvent.CREATE, new OnListener() { 80 | @Override 81 | public void on(final JSONObject object) { 82 | Log.e("CREATE", object.toString()); 83 | runOnUiThread(new Runnable() { 84 | @Override 85 | public void run() { 86 | resultView.append(object.toString() + "\n"); 87 | } 88 | }); 89 | } 90 | }); 91 | 92 | // Listen ALL events 93 | // subscription.on(LiveQueryEvent.ALL, new OnListener() { 94 | // @Override 95 | // public void on(final JSONObject object) { 96 | // runOnUiThread(new Runnable() { 97 | // @Override 98 | // public void run() { 99 | // resultView.append(object.toString() + "\n"); 100 | // } 101 | // }); 102 | // } 103 | // }); 104 | 105 | // Unsubscribe 106 | mUnsubscribeButton.setOnClickListener(new View.OnClickListener() { 107 | @Override 108 | public void onClick(View v) { 109 | subscription.unsubscribe(); 110 | } 111 | }); 112 | 113 | // Connect 114 | mConnectButton.setOnClickListener(new View.OnClickListener() { 115 | @Override 116 | public void onClick(View v) { 117 | LiveQueryClient.connect(); 118 | } 119 | }); 120 | 121 | // Disconnect 122 | mDisconnectButton.setOnClickListener(new View.OnClickListener() { 123 | @Override 124 | public void onClick(View v) { 125 | LiveQueryClient.disconnect(); 126 | } 127 | }); 128 | 129 | // Send Message for testing, text must be "asd" 130 | mSendButton.setOnClickListener(new View.OnClickListener() { 131 | @Override 132 | public void onClick(View v) { 133 | String message = mMessageEditText.getText().toString().trim(); 134 | mMessageEditText.setText(""); 135 | if (message.length() > 0) { 136 | ParseObject po = new ParseObject("Message"); 137 | po.put("body", message); 138 | po.saveInBackground(); 139 | } 140 | } 141 | }); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /Example/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 17 | 18 | 23 | 24 |