aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-02-17 16:29:46 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-02-17 16:29:46 +0000
commit419cb3529dd8f59790ee9a6aa869b7afe3c21f0c (patch)
tree6338ac2684de202e48a8527c51bcb1b6abaad31b /src/net/cbaines
parentc15c37286de9bb55bed43f63a38911e9633ced28 (diff)
downloadsouthamptonuniversitymap-419cb3529dd8f59790ee9a6aa869b7afe3c21f0c.tar
southamptonuniversitymap-419cb3529dd8f59790ee9a6aa869b7afe3c21f0c.tar.gz
Improved toasts, changed the way the map works, one tap gets you a toast with info, two taps gets you the activity, and a long
press changes the favourites state.
Diffstat (limited to 'src/net/cbaines')
-rw-r--r--src/net/cbaines/suma/BuildingNumOverlay.java35
-rw-r--r--src/net/cbaines/suma/BusActivity.java3
-rw-r--r--src/net/cbaines/suma/BusSpecificStopView.java21
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java3
-rw-r--r--src/net/cbaines/suma/BusStopOverlay.java42
-rw-r--r--src/net/cbaines/suma/SouthamptonUniversityMapActivity.java3
-rw-r--r--src/net/cbaines/suma/StopView.java20
-rw-r--r--src/net/cbaines/suma/TimetableAdapter.java4
8 files changed, 110 insertions, 21 deletions
diff --git a/src/net/cbaines/suma/BuildingNumOverlay.java b/src/net/cbaines/suma/BuildingNumOverlay.java
index 4bd5f3a..baa92b5 100644
--- a/src/net/cbaines/suma/BuildingNumOverlay.java
+++ b/src/net/cbaines/suma/BuildingNumOverlay.java
@@ -25,7 +25,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-
import org.osmdroid.views.MapView;
import org.osmdroid.views.MapView.Projection;
import org.osmdroid.views.overlay.Overlay;
@@ -62,13 +61,13 @@ public class BuildingNumOverlay extends Overlay {
private static final String TAG = "BuildingNumOverlay";
- private final Context context;
+ private final SouthamptonUniversityMapActivity context;
private Dao<Building, String> buildingDao;
private float userScale = 1f;
- public BuildingNumOverlay(Context context, List<Building> buildings) throws SQLException {
+ public BuildingNumOverlay(SouthamptonUniversityMapActivity context, List<Building> buildings) throws SQLException {
super(context);
this.context = context;
@@ -192,12 +191,23 @@ public class BuildingNumOverlay extends Overlay {
} else {
Log.i(TAG, "building Pressed " + building.id);
- Toast.makeText(context, building.name + " (" + building.id + ")", Toast.LENGTH_SHORT).show();
+ if (context.activityToast == null) {
+ context.activityToast = Toast.makeText(context, building.name + " (" + building.id + ")", Toast.LENGTH_SHORT);
+ } else {
+ context.activityToast.setDuration(Toast.LENGTH_SHORT);
+ context.activityToast.setText(building.name + " (" + building.id + ")");
+ }
+ context.activityToast.show();
+
return true;
}
}
+ public boolean onDoubleTap(final MotionEvent e, final MapView mapView) {
+ return false;
+ }
+
@Override
public boolean onLongPress(final MotionEvent event, final MapView mapView) {
if (!this.isEnabled())
@@ -214,9 +224,22 @@ public class BuildingNumOverlay extends Overlay {
if (building.favourite) {
building.favourite = false;
- Toast.makeText(context, building.id + " removed from favourites", Toast.LENGTH_SHORT).show();
+ if (context.activityToast == null) {
+ context.activityToast = Toast.makeText(context, building.id + " removed from favourites", Toast.LENGTH_SHORT);
+ } else {
+ context.activityToast.setDuration(Toast.LENGTH_SHORT);
+ context.activityToast.setText(building.id + " removed from favourites");
+ }
+ context.activityToast.show();
+
} else {
- Toast.makeText(context, building.id + " made a favourite", Toast.LENGTH_SHORT).show();
+ if (context.activityToast == null) {
+ context.activityToast = Toast.makeText(context, building.id + " made a favourite", Toast.LENGTH_SHORT);
+ } else {
+ context.activityToast.setDuration(Toast.LENGTH_SHORT);
+ context.activityToast.setText(building.id + " made a favourite");
+ }
+ context.activityToast.show();
building.favourite = true;
}
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java
index 25f373a..4b59117 100644
--- a/src/net/cbaines/suma/BusActivity.java
+++ b/src/net/cbaines/suma/BusActivity.java
@@ -21,6 +21,7 @@ import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
+import android.widget.Toast;
import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;
@@ -38,6 +39,8 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
private TextView busContentMessage;
private LinearLayout busActivityContentLayout;
+ Toast activityToast;
+
/**
* The bus this activity is focused on
*/
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java
index cad7524..fc14fcb 100644
--- a/src/net/cbaines/suma/BusSpecificStopView.java
+++ b/src/net/cbaines/suma/BusSpecificStopView.java
@@ -46,11 +46,11 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
private final TextView location;
private final TextView time;
private String onClickMessage = "";
- private final Context context;
+ private final BusActivity context;
private Stop stop;
- public BusSpecificStopView(Context context, Stop stop) {
+ public BusSpecificStopView(BusActivity context, Stop stop) {
super(context);
this.context = context;
@@ -147,8 +147,13 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
}
public void onClick(View v) {
- Toast.makeText(context, onClickMessage, Toast.LENGTH_SHORT).show();
-
+ if (context.activityToast == null) {
+ context.activityToast = Toast.makeText(context, onClickMessage, Toast.LENGTH_SHORT);
+ } else {
+ context.activityToast.setText(onClickMessage);
+ context.activityToast.setDuration(Toast.LENGTH_SHORT);
+ }
+ context.activityToast.show();
}
@Override
@@ -165,7 +170,13 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
i.putExtra("poiPoint", stop.busStop.point.toDoubleString());
((Activity) context).startActivityForResult(i, 0);
} else {
- Toast.makeText(context, "Arival prediction not avalible for timetabled buses", Toast.LENGTH_SHORT).show();
+ if (context.activityToast == null) {
+ context.activityToast = Toast.makeText(context, "Arival prediction not avalible for timetabled buses", Toast.LENGTH_SHORT);
+ } else {
+ context.activityToast.setText("Arival prediction not avalible for timetabled buses");
+ context.activityToast.setDuration(Toast.LENGTH_SHORT);
+ }
+ context.activityToast.show();
}
} catch (SQLException e) {
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index 9910ad3..1c325ec 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -52,6 +52,7 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
+import android.widget.Toast;
import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;
import com.j256.ormlite.dao.Dao;
@@ -100,6 +101,8 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
private HashSet<BusRoute> routes = new HashSet<BusRoute>();
+ Toast activityToast;
+
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bustimes);
diff --git a/src/net/cbaines/suma/BusStopOverlay.java b/src/net/cbaines/suma/BusStopOverlay.java
index 59212ef..f912d19 100644
--- a/src/net/cbaines/suma/BusStopOverlay.java
+++ b/src/net/cbaines/suma/BusStopOverlay.java
@@ -60,7 +60,7 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants {
private static final String TAG = "BusStopOverlay";
- private final Context context;
+ private final SouthamptonUniversityMapActivity context;
private Dao<BusStop, String> busStopDao;
@@ -68,7 +68,7 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants {
private boolean[] routes = new boolean[5];
- public BusStopOverlay(Context context, List<BusStop> busStops) throws SQLException {
+ public BusStopOverlay(SouthamptonUniversityMapActivity context, List<BusStop> busStops) throws SQLException {
super(context);
this.context = context;
@@ -198,6 +198,28 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants {
if (busStop == null) {
Log.i(TAG, "No busStop pressed");
+ return false;
+ } else {
+ Log.i(TAG, "busStop Pressed " + busStop.id);
+
+ if (context.activityToast == null) {
+ context.activityToast = Toast.makeText(context, busStop.description + " (" + busStop.id + ")", Toast.LENGTH_SHORT);
+ } else {
+ context.activityToast.setDuration(Toast.LENGTH_SHORT);
+ context.activityToast.setText(busStop.description + " (" + busStop.id + ")");
+ }
+ context.activityToast.show();
+
+ return true;
+ }
+ }
+
+ public boolean onDoubleTap(final MotionEvent event, final MapView mapView) {
+
+ BusStop busStop = getSelectedItem(event, mapView);
+
+ if (busStop == null) {
+ Log.i(TAG, "No busStop pressed");
return false;
} else {
@@ -226,9 +248,21 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants {
if (busStop.favourite) {
busStop.favourite = false;
- Toast.makeText(context, busStop.id + " removed from favourites", Toast.LENGTH_SHORT).show();
+ if (context.activityToast == null) {
+ context.activityToast = Toast.makeText(context, busStop.id + " removed from favourites", Toast.LENGTH_SHORT);
+ } else {
+ context.activityToast.setDuration(Toast.LENGTH_SHORT);
+ context.activityToast.setText(busStop.id + " removed from favourites");
+ }
+ context.activityToast.show();
} else {
- Toast.makeText(context, busStop.id + " made a favourite", Toast.LENGTH_SHORT).show();
+ if (context.activityToast == null) {
+ context.activityToast = Toast.makeText(context, busStop.id + " made a favourite", Toast.LENGTH_SHORT);
+ } else {
+ context.activityToast.setDuration(Toast.LENGTH_SHORT);
+ context.activityToast.setText(busStop.id + " made a favourite");
+ }
+ context.activityToast.show();
busStop.favourite = true;
}
diff --git a/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java b/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java
index 26996a0..1412e3b 100644
--- a/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java
+++ b/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java
@@ -69,6 +69,7 @@ import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.TextView;
+import android.widget.Toast;
import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;
import com.j256.ormlite.dao.Dao;
@@ -142,6 +143,8 @@ public class SouthamptonUniversityMapActivity extends OrmLiteBaseActivity<Databa
private POIDialog favDialog;
+ Toast activityToast;
+
private SouthamptonUniversityMapActivity instance;
private static final String TAG = "SUM";
diff --git a/src/net/cbaines/suma/StopView.java b/src/net/cbaines/suma/StopView.java
index cc60280..011964d 100644
--- a/src/net/cbaines/suma/StopView.java
+++ b/src/net/cbaines/suma/StopView.java
@@ -45,11 +45,11 @@ public class StopView extends LinearLayout implements OnClickListener, OnLongCli
private final TextView name;
private final TextView time;
private String onClickMessage = "";
- private final Context context;
+ private final BusStopActivity context;
private Stop stop;
- public StopView(Context context, Stop stop) {
+ public StopView(BusStopActivity context, Stop stop) {
super(context);
this.context = context;
@@ -107,7 +107,13 @@ public class StopView extends LinearLayout implements OnClickListener, OnLongCli
}
public void onClick(View v) {
- Toast.makeText(context, onClickMessage, Toast.LENGTH_SHORT).show();
+ if (context.activityToast == null) {
+ context.activityToast = Toast.makeText(context, onClickMessage, Toast.LENGTH_SHORT);
+ } else {
+ context.activityToast.setText(onClickMessage);
+ context.activityToast.setDuration(Toast.LENGTH_SHORT);
+ }
+ context.activityToast.show();
}
@@ -126,7 +132,13 @@ public class StopView extends LinearLayout implements OnClickListener, OnLongCli
i.putExtra("busStopID", stop.busStop.id);
((Activity) context).startActivityForResult(i, 0);
} else {
- Toast.makeText(context, "Arival prediction not avalible for timetabled buses", Toast.LENGTH_SHORT).show();
+ if (context.activityToast == null) {
+ context.activityToast = Toast.makeText(context, "Arival prediction not avalible for timetabled buses", Toast.LENGTH_SHORT);
+ } else {
+ context.activityToast.setText("Arival prediction not avalible for timetabled buses");
+ context.activityToast.setDuration(Toast.LENGTH_SHORT);
+ }
+ context.activityToast.show();
}
} catch (SQLException e) {
diff --git a/src/net/cbaines/suma/TimetableAdapter.java b/src/net/cbaines/suma/TimetableAdapter.java
index b4dfab5..ae4407f 100644
--- a/src/net/cbaines/suma/TimetableAdapter.java
+++ b/src/net/cbaines/suma/TimetableAdapter.java
@@ -29,14 +29,14 @@ import android.widget.BaseAdapter;
public class TimetableAdapter extends BaseAdapter {
- private final Context context;
+ private final BusStopActivity context;
private Timetable timetable;
private final Animation a;
private boolean[] changed;
private static final String TAG = "TimetableAdapter";
- public TimetableAdapter(Context context, Timetable timetable) {
+ public TimetableAdapter(BusStopActivity context, Timetable timetable) {
this.context = context;
this.timetable = timetable;
this.a = AnimationUtils.loadAnimation(context, R.anim.updated_stop_view);