aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/BusSpecificStopView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/BusSpecificStopView.java')
-rw-r--r--src/net/cbaines/suma/BusSpecificStopView.java66
1 files changed, 17 insertions, 49 deletions
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java
index 7252802..a939cde 100644
--- a/src/net/cbaines/suma/BusSpecificStopView.java
+++ b/src/net/cbaines/suma/BusSpecificStopView.java
@@ -19,7 +19,6 @@
package net.cbaines.suma;
-import java.sql.SQLException;
import java.text.DateFormat;
import android.app.Activity;
@@ -36,9 +35,6 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
-import com.j256.ormlite.android.apptools.OpenHelperManager;
-import com.j256.ormlite.dao.Dao;
-
public class BusSpecificStopView extends LinearLayout implements OnClickListener, OnLongClickListener {
private static final String TAG = "BusSpecificStopView";
@@ -106,26 +102,16 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
time.setText("");
}
- DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
-
- try {
- Dao<Bus, Integer> busDao = helper.getBusDao();
-
- busDao.refresh(stop.bus);
-
- if (stop.arivalTime != null) {
- if (stop.live) {
- onClickMessage = stop.bus.getName() + " at " + stop.busStop.description + " at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
- } else {
- onClickMessage = stop.bus.getName() + " at " + stop.busStop.description + " at "
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime) + " (timetabled)";
- }
+ if (stop.arivalTime != null) {
+ if (stop.live) {
+ onClickMessage = stop.bus.getName() + " at " + stop.busStop.description + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
} else {
- onClickMessage = stop.busStop.description + " on route, but arival time is not avalible";
+ onClickMessage = stop.bus.getName() + " at " + stop.busStop.description + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime) + " (timetabled)";
}
- } catch (SQLException e) {
- e.printStackTrace();
+ } else {
+ onClickMessage = stop.busStop.description + " on route, but arival time is not avalible";
}
this.setOnClickListener(this);
@@ -133,14 +119,6 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
}
public void onClick(View v) {
- DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
- try {
- Dao<Bus, Integer> busDao = helper.getBusDao();
- busDao.refresh(stop.bus);
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
if (stop.bus.id != null) {
context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT);
} else {
@@ -149,28 +127,18 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
}
public boolean onLongClick(View v) { // TODO
- DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
-
- try {
- Dao<Bus, Integer> busDao = helper.getBusDao();
-
- busDao.refresh(stop.bus);
-
- if (stop.bus.id != null) {
- Uri uri = Uri.parse("geo:" + Util.E6IntToDouble(stop.busStop.point.getLatitudeE6()) + ","
- + Util.E6IntToDouble(stop.busStop.point.getLongitudeE6()) + "?z=18");
-
- Log.i(TAG, "Starting a activity for " + uri);
+ if (stop.bus.id != null) {
+ Uri uri = Uri.parse("geo:" + Util.E6IntToDouble(stop.busStop.point.getLatitudeE6()) + ","
+ + Util.E6IntToDouble(stop.busStop.point.getLongitudeE6()) + "?z=18");
- Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri);
- ((Activity) context).startActivity(mapIntent);
- } else {
- context.makeToast(onClickUnidentifiedMessage, Toast.LENGTH_SHORT);
- }
+ Log.i(TAG, "Starting a activity for " + uri);
- } catch (SQLException e) {
- e.printStackTrace();
+ Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri);
+ ((Activity) context).startActivity(mapIntent);
+ } else {
+ context.makeToast(onClickUnidentifiedMessage, Toast.LENGTH_SHORT);
}
+
return false;
}
}