aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/BuildingActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/BuildingActivity.java')
-rw-r--r--src/net/cbaines/suma/BuildingActivity.java157
1 files changed, 119 insertions, 38 deletions
diff --git a/src/net/cbaines/suma/BuildingActivity.java b/src/net/cbaines/suma/BuildingActivity.java
index 987d139..930c2d1 100644
--- a/src/net/cbaines/suma/BuildingActivity.java
+++ b/src/net/cbaines/suma/BuildingActivity.java
@@ -19,67 +19,148 @@
package net.cbaines.suma;
+import java.io.IOException;
import java.io.InputStream;
-import java.util.HashSet;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
import android.content.Context;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
-
+import android.util.Log;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.ImageButton;
+import android.widget.TextView;
+
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryExecution;
+import com.hp.hpl.jena.query.QueryExecutionFactory;
+import com.hp.hpl.jena.query.QueryFactory;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.tdb.TDBFactory;
import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;
-public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> {
+public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> implements OnCheckedChangeListener {
- final static String TAG = "BusTimeActivity";
+ final static String TAG = "BusTimeActivity";
- private boolean dataChanged;
+ private boolean dataChanged;
- private Context instance;
+ private Context instance;
- private HashSet<BusRoute> routes = new HashSet<BusRoute>();
+ private ImageButton imageButton;
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.bustimes);
+ private TextView buildingName;
+ private TextView buildingID;
- final DatabaseHelper helper = getHelper();
+ private CheckBox favouritesCheckBox;
- // create an empty model
- // Model model = ModelFactory.createDefaultModel();
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.building_activity);
+ instance = this;
- // use the FileManager to find the input file
- InputStream in = getResources().openRawResource(R.raw.u9);
- if (in == null) {
- throw new IllegalArgumentException("File not found");
- }
+ String ID = getIntent().getExtras().getString("buildingID");
+
+ favouritesCheckBox = (CheckBox) findViewById(R.id.buildingActivityFavouriteCheckBox);
+ // favouritesCheckBox.setChecked(busStop.favourite);
+ favouritesCheckBox.setOnCheckedChangeListener(this);
+
+ buildingName = (TextView) findViewById(R.id.buildingActivityName);
+ buildingID = (TextView) findViewById(R.id.buildingActivityName);
+
+ Log.i(TAG, "Building id " + ID);
+
+ buildingID.setText(ID);
+
+ try {
+ URL url = new URL("http://data.southampton.ac.uk/images/buildings/600/" + ID + ".jpg");
+
+ InputStream is = (InputStream) url.getContent();
+ Drawable image = Drawable.createFromStream(is, "src");
+
+ imageButton = new ImageButton(this);
+ imageButton = (ImageButton) findViewById(R.id.buildingActivityImage);
+ imageButton.setImageDrawable(image);
+ imageButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+
+ }
+ });
+
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
- // read the RDF/XML file
- // model.read(in, null);
-
-
+ String directory = "/data/data/net.cbaines.suma/databases";
+ Model model = TDBFactory.createModel(directory);
- instance = this;
+ String queryString = ID;
+ Query query = QueryFactory.create(queryString);
+ QueryExecution qexec = QueryExecutionFactory.create(query, model);
+ try {
+ ResultSet results = qexec.execSelect();
+ for (; results.hasNext();) {
+ QuerySolution soln = results.nextSolution();
- }
+ Log.i(TAG, "solution " + soln.toString());
- public void onResume() {
- super.onResume();
+ for (Iterator<String> iter = soln.varNames(); iter.hasNext();) {
+ Log.i(TAG, "solnVarName " + iter.next());
+ }
- }
+ // RDFNode x = soln.get("varName"); // Get a result variable by
+ // name.
+ // Resource r = soln.getResource("VarR"); // Get a result
+ // variable
+ // - must be a resource
+ // Literal l = soln.getLiteral("VarL"); // Get a result variable
+ // -
+ // must be a literal
+ }
+ } finally {
+ qexec.close();
+ }
- public void onPause() {
+ }
+
+ public void onResume() {
+ super.onResume();
+
+ }
- super.onPause();
- }
+ public void onPause() {
- public void finish() {
- setResult(RESULT_OK, getIntent());
+ super.onPause();
+ }
- super.finish();
- }
+ public void finish() {
+ setResult(RESULT_OK, getIntent());
- @Override
- public Object onRetainNonConfigurationInstance() {
- return null;
- }
+ super.finish();
+ }
+
+ @Override
+ public Object onRetainNonConfigurationInstance() {
+ return null;
+ }
+
+ public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
+ // TODO Auto-generated method stub
+
+ }
}