summaryrefslogtreecommitdiff
path: root/same-android/src/main/java/com/orbekk/same/VariableTestActivity.java
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-28 11:57:48 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-28 11:57:48 +0100
commit6a030381607aaf7b44529c4d5a6552749305c3d2 (patch)
tree366ac55e7a96af649d1640dd80607fee0a40bf1f /same-android/src/main/java/com/orbekk/same/VariableTestActivity.java
parentbc2d8fa1da02037d0b9a2361f394f19e494c8cec (diff)
Run SameService in a separate process.
Diffstat (limited to 'same-android/src/main/java/com/orbekk/same/VariableTestActivity.java')
-rw-r--r--same-android/src/main/java/com/orbekk/same/VariableTestActivity.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/same-android/src/main/java/com/orbekk/same/VariableTestActivity.java b/same-android/src/main/java/com/orbekk/same/VariableTestActivity.java
index 1fffbad..3ae1a87 100644
--- a/same-android/src/main/java/com/orbekk/same/VariableTestActivity.java
+++ b/same-android/src/main/java/com/orbekk/same/VariableTestActivity.java
@@ -4,6 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import android.app.Activity;
+import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
@@ -27,6 +28,22 @@ public class VariableTestActivity extends Activity {
}
};
+ private class UpdateVariableTask
+ extends AsyncTask<String, Void, DelayedOperation.Status> {
+ @Override protected DelayedOperation.Status doInBackground(String... values) {
+ String value = values[0];
+ return variable.set(value).getStatus();
+ }
+
+ @Override protected void onPostExecute(DelayedOperation.Status status) {
+ if (!status.isOk()) {
+ Toast.makeText(VariableTestActivity.this,
+ "Update failed: " + status, Toast.LENGTH_SHORT)
+ .show();
+ }
+ }
+ }
+
private void displayVariable() {
TextView tv = (TextView)findViewById(R.id.variable_text);
if (variable.get() != null) {
@@ -37,14 +54,7 @@ public class VariableTestActivity extends Activity {
public void setVariable(View unused) {
EditText et = (EditText)findViewById(R.id.set_variable_text);
String newValue = et.getText().toString();
- logger.info("Setting variable.");
- DelayedOperation op = variable.set(newValue);
- logger.info("Waiting for delayed operation.");
- if (!op.getStatus().isOk()) {
- Toast.makeText(this, "Failed to update: " + op.getStatus(),
- Toast.LENGTH_SHORT)
- .show();
- }
+ new UpdateVariableTask().execute(newValue);
}
@Override public void onCreate(Bundle savedInstanceState) {