-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0314509
commit 127d9f6
Showing
8 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>App</name> | ||
<comment>Project App created by Buildship.</comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
arguments= | ||
auto.sync=false | ||
build.scans.enabled=false | ||
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) | ||
connection.project.dir= | ||
eclipse.preferences.version=1 | ||
gradle.user.home= | ||
java.home=C\:/Program Files/Java/jdk1.8.0_181 | ||
jvm.arguments= | ||
offline.mode=false | ||
override.workspace.settings=true | ||
show.console.view=true | ||
show.executions.view=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ServerConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.gazeboindustries.sextafeiramobile; | ||
|
||
import android.os.AsyncTask; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.io.PrintStream; | ||
import java.io.PrintWriter; | ||
import java.net.Socket; | ||
import java.util.ArrayList; | ||
|
||
public class ServerConnection extends AsyncTask<String, Integer, String> { | ||
private String IP = "192.168.0.5"; | ||
private int port = 5000; | ||
private Socket socket; | ||
private PrintWriter out; | ||
private BufferedReader in; | ||
private JSONObject jsonRequest; | ||
private JSONObject jsonResponse; | ||
private String data; | ||
private ArrayList<JSONArray> list; | ||
private JSONArray arrayResponse; | ||
private char[] buffer = new char[5800]; | ||
|
||
public ServerConnection(String request){ | ||
execute(request); | ||
} | ||
|
||
@Override | ||
protected String doInBackground(String... params) { | ||
try { | ||
this.socket = new Socket(IP, port); | ||
this.out = new PrintWriter(this.socket.getOutputStream(), true); | ||
this.in = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); | ||
|
||
jsonRequest = new JSONObject(); | ||
jsonRequest.put("header", "gazeboindustries09082004"); | ||
jsonRequest.put("request", params[0]); | ||
|
||
this.out.println(jsonRequest); | ||
|
||
this.in.read(buffer); | ||
|
||
data = new String(buffer); | ||
|
||
this.jsonResponse = new JSONObject(data.trim()); | ||
|
||
System.out.println(this.jsonResponse); | ||
|
||
list = new ArrayList<>(); | ||
|
||
for (int c = 0; c < jsonResponse.length(); c++){ | ||
arrayResponse = (JSONArray) jsonResponse.get(Integer.toString(c)); | ||
list.add(arrayResponse); | ||
System.out.println(list); | ||
} | ||
|
||
} catch (IOException | JSONException e) { | ||
System.out.println("DEU ERRO"); | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters