-
Notifications
You must be signed in to change notification settings - Fork 0
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
Roman Galeev
committed
Feb 17, 2015
1 parent
15bc3b0
commit 45f269c
Showing
27 changed files
with
183 additions
and
1,042 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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.xtend.XTEND_CONTAINER"/> | ||
<classpathentry exported="true" kind="con" path="org.eclipse.xtend.XTEND_CONTAINER"/> | ||
<classpathentry kind="src" path="xtend-gen"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" path="gen"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> | ||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> | ||
<classpathentry kind="src" path="gen"/> | ||
<classpathentry kind="output" path="bin/classes"/> | ||
</classpath> |
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 was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file added
BIN
+335 KB
http/bin/dexedLibs/android-support-v4-4d940fcb844be48f2214a7969598a162.jar
Binary file not shown.
Binary file added
BIN
+794 KB
.../bin/dexedLibs/com.google.guava_15.0.0.v201403281430-b9f365fea91ae99377b81ed27dd4977c.jar
Binary file not shown.
Binary file added
BIN
+27.1 KB
...Libs/org.eclipse.xtend.lib.macro_2.7.2.v201409160908-9472153bccd21e571609d393948389eb.jar
Binary file not shown.
Binary file added
BIN
+45.9 KB
.../dexedLibs/org.eclipse.xtend.lib_2.7.2.v201409160908-f980833436771ad194be6d809b09eedc.jar
Binary file not shown.
Binary file added
BIN
+64.2 KB
...Libs/org.eclipse.xtext.xbase.lib_2.7.2.v201409160908-175b0b017b0ad511a00b9365c47a78e8.jar
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,20 +1,2 @@ | ||
<resources> | ||
|
||
<!-- | ||
Base application theme, dependent on API level. This theme is replaced | ||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices. | ||
--> | ||
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"> | ||
<!-- | ||
Theme customizations available in newer API levels can go in | ||
res/values-vXX/styles.xml, while customizations related to | ||
backward-compatibility can go here. | ||
--> | ||
</style> | ||
|
||
<!-- Application theme. --> | ||
<style name="AppTheme" parent="AppBaseTheme"> | ||
<!-- All customizations that are NOT specific to a particular API-level can go here. --> | ||
</style> | ||
|
||
</resources> |
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 |
---|---|---|
@@ -1,5 +1,114 @@ | ||
package com.ncom.http | ||
|
||
import android.os.Handler | ||
import android.os.Message | ||
import android.util.Log | ||
import java.io.BufferedReader | ||
import java.io.InputStream | ||
import java.io.InputStreamReader | ||
import java.util.Timer | ||
import java.util.TimerTask | ||
import org.apache.http.client.methods.HttpPost | ||
import org.apache.http.entity.StringEntity | ||
import org.apache.http.impl.client.DefaultHttpClient | ||
import org.apache.http.params.HttpConnectionParams | ||
import org.apache.http.protocol.BasicHttpContext | ||
|
||
class HTTP { | ||
|
||
val MSG_DONE = 1 | ||
|
||
int socketTimeout | ||
int requestTimeout | ||
BasicHttpContext localContext | ||
|
||
new(int socketTimeout, int requestTimeout) { | ||
this.socketTimeout = socketTimeout | ||
this.requestTimeout = requestTimeout | ||
localContext = new BasicHttpContext() | ||
} | ||
|
||
new() { | ||
this(5000, 25000) | ||
} | ||
|
||
def Log(String s) { | ||
Log.d("HTTP", s) | ||
} | ||
|
||
static class Param { | ||
(String) => void callback | ||
String result | ||
|
||
new((String) => void callback, String result) { | ||
this.callback = callback | ||
this.result = result | ||
} | ||
} | ||
|
||
val cbHandler = new Handler() { | ||
override handleMessage(Message m) { | ||
val r = m.obj as Param | ||
Log("RES: " + r.result) | ||
r.callback.apply(r.result) | ||
} | ||
|
||
} | ||
|
||
static class TimeOutTask extends TimerTask { | ||
String url | ||
Thread t | ||
new(Thread t, String url) { | ||
this.t = t | ||
this.url = url | ||
} | ||
override run() { | ||
if (t.isAlive()) { | ||
t.interrupt() | ||
} | ||
} | ||
} | ||
|
||
def String convertInputStreamToString(InputStream inputStream) { | ||
val builder = new StringBuilder() | ||
val reader = new BufferedReader(new InputStreamReader(inputStream)) | ||
|
||
var line = "" | ||
while( (line = reader.readLine()) != null) { | ||
builder.append(line) | ||
} | ||
return builder.toString() | ||
} | ||
|
||
def Post(String url, String body, (String) => void callback) { | ||
Log("REQ: " + url) | ||
|
||
val r = new Thread() { | ||
|
||
override run() { | ||
|
||
val client = new DefaultHttpClient() | ||
val param = client.getParams() | ||
|
||
HttpConnectionParams.setConnectionTimeout(param, socketTimeout) | ||
HttpConnectionParams.setSoTimeout(param, socketTimeout) | ||
|
||
val req = new HttpPost(url) | ||
|
||
if (body.length() > 0) { | ||
req.setEntity(new StringEntity(body)) | ||
req.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8") | ||
} | ||
|
||
val inputStream = client.execute(req, new BasicHttpContext()).getEntity().getContent() | ||
|
||
val result = convertInputStreamToString(inputStream) | ||
|
||
cbHandler.obtainMessage(MSG_DONE, new Param(callback, result)).sendToTarget() | ||
} | ||
} | ||
|
||
new Timer(true).schedule(new TimeOutTask(r, url), requestTimeout) | ||
r.start() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
package com.ncom.http | ||
|
||
import android.os.Bundle | ||
import android.view.Menu | ||
import android.widget.TextView | ||
import android.app.Activity | ||
|
||
public class MainActivity extends Activity { | ||
|
||
|
||
override void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
request() | ||
} | ||
|
||
|
||
override boolean onCreateOptionsMenu(Menu menu) { | ||
getMenuInflater().inflate(R.menu.main, menu) | ||
return true | ||
} | ||
|
||
def request() { | ||
val http = new HTTP() | ||
val v = findViewById(R.id.textview) as TextView | ||
http.Post("http://mnp.tele2.ru/gateway.php?9273193358", "", [ String res | v.setText(res) ]) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/.HTTP.java._trace | ||
/HTTP.java | ||
/.MainActivity.java._trace | ||
/.TimeOutTask.java._trace |
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,38 @@ | ||
package com.ncom.http; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.view.Menu; | ||
import android.view.MenuInflater; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
import com.ncom.http.HTTP; | ||
import com.ncom.http.R; | ||
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | ||
|
||
@SuppressWarnings("all") | ||
public class MainActivity extends Activity { | ||
public void onCreate(final Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
this.setContentView(R.layout.activity_main); | ||
this.request(); | ||
} | ||
|
||
public boolean onCreateOptionsMenu(final Menu menu) { | ||
MenuInflater _menuInflater = this.getMenuInflater(); | ||
_menuInflater.inflate(com.ncom.http.R.menu.main, menu); | ||
return true; | ||
} | ||
|
||
public void request() { | ||
final HTTP http = new HTTP(); | ||
View _findViewById = this.findViewById(R.id.textview); | ||
final TextView v = ((TextView) _findViewById); | ||
final Procedure1<String> _function = new Procedure1<String>() { | ||
public void apply(final String res) { | ||
v.setText(res); | ||
} | ||
}; | ||
http.Post("http://mnp.tele2.ru/gateway.php?9273193358", "", _function); | ||
} | ||
} |