diff options
Diffstat (limited to 'src/net/cbaines/suma')
-rw-r--r-- | src/net/cbaines/suma/BusActivity.java | 13 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusSpecificStopView.java | 25 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusStopActivity.java | 6 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusStopSpecificStopView.java (renamed from src/net/cbaines/suma/StopView.java) | 10 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java (renamed from src/net/cbaines/suma/TimetableAdapter.java) | 10 | ||||
-rw-r--r-- | src/net/cbaines/suma/Stop.java | 2 |
6 files changed, 30 insertions, 36 deletions
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java index c1519ec..3292ce8 100644 --- a/src/net/cbaines/suma/BusActivity.java +++ b/src/net/cbaines/suma/BusActivity.java @@ -20,11 +20,8 @@ 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; - -public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements Preferences { +public class BusActivity extends ToastHelperActivity implements Preferences { final static String TAG = "BusActivity"; private TextView busIDTextView; @@ -33,8 +30,6 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements private TextView busContentMessage; private LinearLayout busActivityContentLayout; - Toast activityToast; - /** * The bus this activity is focused on */ @@ -122,11 +117,13 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements if (bus.destinationString != null) { Log.i(TAG, "Bus destination string is " + bus.destinationString); - busDestTextView.setText(bus.destinationString); + busDestTextView + .setText(getResources().getString(R.string.bus_activity_destination_label) + bus.destinationString); busDestTextView.setVisibility(View.VISIBLE); } else { Log.i(TAG, "Bus destination string is null"); - busDestTextView.setVisibility(View.GONE); + busDestTextView.setText(getResources().getString(R.string.bus_activity_no_destination_message)); + busDestTextView.setVisibility(View.VISIBLE); } busStops = bus.route.getRouteSection(instance, bus.direction); diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java index deaf932..5ab7cd5 100644 --- a/src/net/cbaines/suma/BusSpecificStopView.java +++ b/src/net/cbaines/suma/BusSpecificStopView.java @@ -24,6 +24,7 @@ import java.text.DateFormat; import android.app.Activity; import android.content.Intent; +import android.content.res.Resources; import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; @@ -48,6 +49,9 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener private Stop stop; + private String onClickHelpMessage; + private String onClickUnidentifiedMessage; + public BusSpecificStopView(BusActivity context, Stop stop) { super(context); @@ -62,6 +66,10 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener time.setTextSize(22f); time.setGravity(Gravity.RIGHT); + Resources resources = context.getResources(); + onClickHelpMessage = resources.getString(R.string.bus_stop_view_on_click_toast_help_message); + onClickUnidentifiedMessage = resources.getString(R.string.bus_stop_view_on_click_toast_unidentified_message); + setStop(stop); addView(location, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); @@ -136,13 +144,7 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener } public void onClick(View v) { - 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(); + context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT); } public boolean onLongClick(View v) { // TODO @@ -159,14 +161,7 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener i.putExtra("poiPoint", stop.busStop.point.toDoubleString()); ((Activity) context).startActivityForResult(i, 0); } else { - 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(); + context.makeToast(onClickUnidentifiedMessage, Toast.LENGTH_SHORT); } } catch (SQLException e) { diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java index 9f422af..9c49ff7 100644 --- a/src/net/cbaines/suma/BusStopActivity.java +++ b/src/net/cbaines/suma/BusStopActivity.java @@ -484,11 +484,11 @@ public class BusStopActivity extends ToastHelperActivity implements OnCheckedCha } else { busTimeList.setVisibility(View.VISIBLE); busStopMessage.setVisibility(View.GONE); - TimetableAdapter adapter; - if ((adapter = (TimetableAdapter) busTimeList.getAdapter()) != null) { + BusStopSpecificTimetableAdapter adapter; + if ((adapter = (BusStopSpecificTimetableAdapter) busTimeList.getAdapter()) != null) { adapter.updateTimetable(visibleTimetable); } else { - adapter = new TimetableAdapter(this, visibleTimetable); + adapter = new BusStopSpecificTimetableAdapter(this, visibleTimetable); busTimeList.setAdapter(adapter); } busTimeContentLayout.setGravity(Gravity.TOP); diff --git a/src/net/cbaines/suma/StopView.java b/src/net/cbaines/suma/BusStopSpecificStopView.java index fa76131..c7f9bd8 100644 --- a/src/net/cbaines/suma/StopView.java +++ b/src/net/cbaines/suma/BusStopSpecificStopView.java @@ -31,13 +31,14 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.widget.LinearLayout; +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 StopView extends LinearLayout implements OnClickListener, OnLongClickListener { +public class BusStopSpecificStopView extends LinearLayout implements OnClickListener, OnLongClickListener { // private final ImageView icon; @@ -45,6 +46,7 @@ public class StopView extends LinearLayout implements OnClickListener, OnLongCli private final TextView name; private final TextView time; + private String onClickMessage = ""; private final BusStopActivity context; @@ -53,7 +55,7 @@ public class StopView extends LinearLayout implements OnClickListener, OnLongCli private String onClickHelpMessage; private String onClickUnidentifiedMessage; - public StopView(BusStopActivity context, Stop stop) { + public BusStopSpecificStopView(BusStopActivity context, Stop stop) { super(context); this.context = context; @@ -68,8 +70,8 @@ public class StopView extends LinearLayout implements OnClickListener, OnLongCli time.setGravity(Gravity.RIGHT); Resources resources = context.getResources(); - onClickHelpMessage = resources.getString(R.string.stop_view_on_click_toast_help_message); - onClickUnidentifiedMessage = resources.getString(R.string.stop_view_on_click_toast_unidentified_message); + onClickHelpMessage = resources.getString(R.string.bus_stop_stop_view_on_click_toast_help_message); + onClickUnidentifiedMessage = resources.getString(R.string.bus_stop_stop_view_on_click_toast_unidentified_message); setStop(stop); diff --git a/src/net/cbaines/suma/TimetableAdapter.java b/src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java index 16b3ac9..511f427 100644 --- a/src/net/cbaines/suma/TimetableAdapter.java +++ b/src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java @@ -26,7 +26,7 @@ import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.BaseAdapter; -public class TimetableAdapter extends BaseAdapter { +public class BusStopSpecificTimetableAdapter extends BaseAdapter { private final BusStopActivity context; private Timetable timetable; @@ -35,7 +35,7 @@ public class TimetableAdapter extends BaseAdapter { private static final String TAG = "TimetableAdapter"; - public TimetableAdapter(BusStopActivity context, Timetable timetable) { + public BusStopSpecificTimetableAdapter(BusStopActivity context, Timetable timetable) { this.context = context; this.timetable = timetable; this.a = AnimationUtils.loadAnimation(context, R.anim.updated_stop_view); @@ -44,11 +44,11 @@ public class TimetableAdapter extends BaseAdapter { public View getView(int position, View convertView, ViewGroup parent) { Log.i(TAG, "Returning stop " + position + " " + timetable.get(position)); - StopView stopView; + BusStopSpecificStopView stopView; if (convertView == null) { - stopView = new StopView(context, timetable.get(position)); + stopView = new BusStopSpecificStopView(context, timetable.get(position)); } else { - stopView = (StopView) convertView; + stopView = (BusStopSpecificStopView) convertView; stopView.setStop(timetable.get(position)); } diff --git a/src/net/cbaines/suma/Stop.java b/src/net/cbaines/suma/Stop.java index 3221ed5..9db9978 100644 --- a/src/net/cbaines/suma/Stop.java +++ b/src/net/cbaines/suma/Stop.java @@ -47,7 +47,7 @@ public class Stop { BusStop busStop; /** - * The time that the bus is estimated to arrive + * The time that the bus is estimated to arrive, if this is null, the time is still being loaded */ Date arivalTime; |