From 91a53f56aef2ed1bbbe1ae1d183136522624acec Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 1 Mar 2012 22:02:02 +0000 Subject: Transparent toasts, and more improvemens. --- gen/net/cbaines/suma/R.java | 16 ++- res/layout/toast_view.xml | 2 +- res/values/strings.xml | 14 +- src/net/cbaines/suma/BusActivity.java | 13 +- src/net/cbaines/suma/BusSpecificStopView.java | 25 ++-- src/net/cbaines/suma/BusStopActivity.java | 6 +- src/net/cbaines/suma/BusStopSpecificStopView.java | 153 +++++++++++++++++++++ .../suma/BusStopSpecificTimetableAdapter.java | 92 +++++++++++++ src/net/cbaines/suma/Stop.java | 2 +- src/net/cbaines/suma/StopView.java | 151 -------------------- src/net/cbaines/suma/TimetableAdapter.java | 92 ------------- 11 files changed, 288 insertions(+), 278 deletions(-) create mode 100644 src/net/cbaines/suma/BusStopSpecificStopView.java create mode 100644 src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java delete mode 100644 src/net/cbaines/suma/StopView.java delete mode 100644 src/net/cbaines/suma/TimetableAdapter.java diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java index ea2dbeb..49cba3e 100644 --- a/gen/net/cbaines/suma/R.java +++ b/gen/net/cbaines/suma/R.java @@ -194,6 +194,18 @@ public final class R { public static final int buildingImageDescription=0x7f070053; public static final int building_non_residential=0x7f070007; public static final int building_residential=0x7f070006; + /** Bus Activity + */ + public static final int bus_activity_destination_label=0x7f070059; + public static final int bus_activity_no_destination_message=0x7f07005a; + /** Bus Stop Specific Stop View Strings + */ + public static final int bus_stop_stop_view_on_click_toast_help_message=0x7f070055; + public static final int bus_stop_stop_view_on_click_toast_unidentified_message=0x7f070056; + /** Bus Specific Stop View Strings + */ + public static final int bus_stop_view_on_click_toast_help_message=0x7f070057; + public static final int bus_stop_view_on_click_toast_unidentified_message=0x7f070058; public static final int bustimes_favourite_checkbox_label=0x7f070032; public static final int credits_help_message=0x7f070019; public static final int donate_button=0x7f07001a; @@ -243,10 +255,6 @@ public final class R { public static final int preferences_uni_link_live_bus_times=0x7f070027; public static final int preferences_uni_link_live_bus_times_disabled=0x7f070029; public static final int preferences_uni_link_live_bus_times_enabled=0x7f070028; - /** Stop View Strings - */ - public static final int stop_view_on_click_toast_help_message=0x7f070055; - public static final int stop_view_on_click_toast_unidentified_message=0x7f070056; public static final int view_help_message=0x7f070015; } public static final class xml { diff --git a/res/layout/toast_view.xml b/res/layout/toast_view.xml index 6431e6b..51d7561 100644 --- a/res/layout/toast_view.xml +++ b/res/layout/toast_view.xml @@ -3,7 +3,7 @@ android:id="@+id/toastViewLinearLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="#000000" + android:background="#F01D1D1D" android:gravity="center_horizontal" android:orientation="vertical" android:padding="10dp" > diff --git a/res/values/strings.xml b/res/values/strings.xml index da4a2cc..05ed277 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -134,8 +134,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.< Image of the Building Double tap for more info - - Hold to view the bus schedule - Bus schedules not available for unidentified buses + + Hold to view the bus schedule + Bus schedules not available for unidentified buses + + + Hold to view the bus stop + Arrival prediction not available for timetabled buses + + + Destination:\u0020 + No given destination \ No newline at end of file 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 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 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 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/BusStopSpecificStopView.java b/src/net/cbaines/suma/BusStopSpecificStopView.java new file mode 100644 index 0000000..c7f9bd8 --- /dev/null +++ b/src/net/cbaines/suma/BusStopSpecificStopView.java @@ -0,0 +1,153 @@ +/* + * Southampton University Map App + * Copyright (C) 2011 Christopher Baines + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package net.cbaines.suma; + +import java.sql.SQLException; +import java.text.DateFormat; + +import android.content.Intent; +import android.content.res.Resources; +import android.net.Uri; +import android.util.Log; +import android.view.Gravity; +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 BusStopSpecificStopView extends LinearLayout implements OnClickListener, OnLongClickListener { + + // private final ImageView icon; + + // private static final String TAG = "StopView"; + + private final TextView name; + private final TextView time; + + private String onClickMessage = ""; + private final BusStopActivity context; + + private Stop stop; + + private String onClickHelpMessage; + private String onClickUnidentifiedMessage; + + public BusStopSpecificStopView(BusStopActivity context, Stop stop) { + super(context); + + this.context = context; + + this.setOrientation(HORIZONTAL); + + name = new TextView(context); + name.setTextSize(22f); + + time = new TextView(context); + time.setTextSize(22f); + time.setGravity(Gravity.RIGHT); + + Resources resources = context.getResources(); + 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); + + addView(name, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + addView(time, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); + } + + public void setStop(Stop stop) { + + // Log.i(TAG, "Time of arival " + stop.arivalTime); + + this.stop = stop; + + name.setText(stop.bus.getName()); + time.setText(stop.getTimeToArival()); + + DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); + + try { + Dao busDao = helper.getBusDao(); + + busDao.refresh(stop.bus); + + if (stop.bus.id != null) { + if (stop.live) { + onClickMessage = "Bus " + stop.bus.toString() + " at " + + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); + } else { + onClickMessage = "Timetabled bus " + stop.bus.toString() + " at " + + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); + } + } else { + if (stop.live) { + onClickMessage = "Unidentified bus (" + stop.bus.getName() + ") at " + + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); + } else { + onClickMessage = "Timetabled bus (" + stop.bus.getName() + ") at " + + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); + } + } + } catch (SQLException e) { + e.printStackTrace(); + } + + this.setOnClickListener(this); + this.setOnLongClickListener(this); + } + + public void onClick(View v) { + context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT); + } + + public boolean onLongClick(View v) { + DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); + + try { + Dao busDao = helper.getBusDao(); + Dao busRouteDao = helper.getBusRouteDao(); + + busDao.refresh(stop.bus); + busRouteDao.refresh(stop.bus.route); + + Log.i("StopView", "Bus route " + stop.bus.route + " Uni-Link " + stop.bus.route.uniLink + " Bus ID " + stop.bus.id); + + if (stop.bus.id != null && stop.bus.route.uniLink) { + Uri uri = Uri.parse("http://id.southampton.ac.uk/bus/" + stop.bus.id); + + Intent busStopIntent = new Intent(Intent.ACTION_VIEW, uri); + busStopIntent.putExtra("busStopID", stop.busStop.id); + context.startActivity(busStopIntent); + } else { + context.makeToast(onClickUnidentifiedMessage, Toast.LENGTH_SHORT); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return true; + } +} diff --git a/src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java b/src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java new file mode 100644 index 0000000..511f427 --- /dev/null +++ b/src/net/cbaines/suma/BusStopSpecificTimetableAdapter.java @@ -0,0 +1,92 @@ +/* + * Southampton University Map App + * Copyright (C) 2011 Christopher Baines + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package net.cbaines.suma; + +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.BaseAdapter; + +public class BusStopSpecificTimetableAdapter extends BaseAdapter { + + private final BusStopActivity context; + private Timetable timetable; + private final Animation a; + private boolean[] changed; + + private static final String TAG = "TimetableAdapter"; + + public BusStopSpecificTimetableAdapter(BusStopActivity context, Timetable timetable) { + this.context = context; + this.timetable = timetable; + this.a = AnimationUtils.loadAnimation(context, R.anim.updated_stop_view); + } + + public View getView(int position, View convertView, ViewGroup parent) { + Log.i(TAG, "Returning stop " + position + " " + timetable.get(position)); + + BusStopSpecificStopView stopView; + if (convertView == null) { + stopView = new BusStopSpecificStopView(context, timetable.get(position)); + } else { + stopView = (BusStopSpecificStopView) convertView; + stopView.setStop(timetable.get(position)); + } + + if (changed == null || changed[position]) { + a.reset(); + stopView.startAnimation(a); + Log.i(TAG, "Animating it"); + } + + return stopView; + } + + public int getCount() { + return timetable.size(); + } + + public Object getItem(int position) { + return position; + } + + public long getItemId(int position) { + return position; + } + + public void updateTimetable(Timetable newTimetable) { + Log.v(TAG, "Old timetable " + timetable); + Log.v(TAG, "Adaptor loading new timetable"); + changed = new boolean[newTimetable.size()]; + for (int i = 0; i < newTimetable.size(); i++) { + if (!timetable.contains(newTimetable.get(i), true)) { + changed[i] = true; + Log.i(TAG, "Old timetable does not contain: " + newTimetable.get(i)); + } else { + Log.i(TAG, "Old timetable contains: " + newTimetable.get(i)); + changed[i] = false; + } + } + timetable = newTimetable; + this.notifyDataSetChanged(); + } +} 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; diff --git a/src/net/cbaines/suma/StopView.java b/src/net/cbaines/suma/StopView.java deleted file mode 100644 index fa76131..0000000 --- a/src/net/cbaines/suma/StopView.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Southampton University Map App - * Copyright (C) 2011 Christopher Baines - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package net.cbaines.suma; - -import java.sql.SQLException; -import java.text.DateFormat; - -import android.content.Intent; -import android.content.res.Resources; -import android.net.Uri; -import android.util.Log; -import android.view.Gravity; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.View.OnLongClickListener; -import android.widget.LinearLayout; -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 { - - // private final ImageView icon; - - // private static final String TAG = "StopView"; - - private final TextView name; - private final TextView time; - private String onClickMessage = ""; - private final BusStopActivity context; - - private Stop stop; - - private String onClickHelpMessage; - private String onClickUnidentifiedMessage; - - public StopView(BusStopActivity context, Stop stop) { - super(context); - - this.context = context; - - this.setOrientation(HORIZONTAL); - - name = new TextView(context); - name.setTextSize(22f); - - time = new TextView(context); - time.setTextSize(22f); - 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); - - setStop(stop); - - addView(name, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); - addView(time, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); - } - - public void setStop(Stop stop) { - - // Log.i(TAG, "Time of arival " + stop.arivalTime); - - this.stop = stop; - - name.setText(stop.bus.getName()); - time.setText(stop.getTimeToArival()); - - DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); - - try { - Dao busDao = helper.getBusDao(); - - busDao.refresh(stop.bus); - - if (stop.bus.id != null) { - if (stop.live) { - onClickMessage = "Bus " + stop.bus.toString() + " at " - + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); - } else { - onClickMessage = "Timetabled bus " + stop.bus.toString() + " at " - + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); - } - } else { - if (stop.live) { - onClickMessage = "Unidentified bus (" + stop.bus.getName() + ") at " - + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); - } else { - onClickMessage = "Timetabled bus (" + stop.bus.getName() + ") at " - + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); - } - } - } catch (SQLException e) { - e.printStackTrace(); - } - - this.setOnClickListener(this); - this.setOnLongClickListener(this); - } - - public void onClick(View v) { - context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT); - } - - public boolean onLongClick(View v) { - DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); - - try { - Dao busDao = helper.getBusDao(); - Dao busRouteDao = helper.getBusRouteDao(); - - busDao.refresh(stop.bus); - busRouteDao.refresh(stop.bus.route); - - Log.i("StopView", "Bus route " + stop.bus.route + " Uni-Link " + stop.bus.route.uniLink + " Bus ID " + stop.bus.id); - - if (stop.bus.id != null && stop.bus.route.uniLink) { - Uri uri = Uri.parse("http://id.southampton.ac.uk/bus/" + stop.bus.id); - - Intent busStopIntent = new Intent(Intent.ACTION_VIEW, uri); - busStopIntent.putExtra("busStopID", stop.busStop.id); - context.startActivity(busStopIntent); - } else { - context.makeToast(onClickUnidentifiedMessage, Toast.LENGTH_SHORT); - } - } catch (SQLException e) { - e.printStackTrace(); - } - return true; - } -} diff --git a/src/net/cbaines/suma/TimetableAdapter.java b/src/net/cbaines/suma/TimetableAdapter.java deleted file mode 100644 index 16b3ac9..0000000 --- a/src/net/cbaines/suma/TimetableAdapter.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Southampton University Map App - * Copyright (C) 2011 Christopher Baines - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package net.cbaines.suma; - -import android.util.Log; -import android.view.View; -import android.view.ViewGroup; -import android.view.animation.Animation; -import android.view.animation.AnimationUtils; -import android.widget.BaseAdapter; - -public class TimetableAdapter extends BaseAdapter { - - private final BusStopActivity context; - private Timetable timetable; - private final Animation a; - private boolean[] changed; - - private static final String TAG = "TimetableAdapter"; - - public TimetableAdapter(BusStopActivity context, Timetable timetable) { - this.context = context; - this.timetable = timetable; - this.a = AnimationUtils.loadAnimation(context, R.anim.updated_stop_view); - } - - public View getView(int position, View convertView, ViewGroup parent) { - Log.i(TAG, "Returning stop " + position + " " + timetable.get(position)); - - StopView stopView; - if (convertView == null) { - stopView = new StopView(context, timetable.get(position)); - } else { - stopView = (StopView) convertView; - stopView.setStop(timetable.get(position)); - } - - if (changed == null || changed[position]) { - a.reset(); - stopView.startAnimation(a); - Log.i(TAG, "Animating it"); - } - - return stopView; - } - - public int getCount() { - return timetable.size(); - } - - public Object getItem(int position) { - return position; - } - - public long getItemId(int position) { - return position; - } - - public void updateTimetable(Timetable newTimetable) { - Log.v(TAG, "Old timetable " + timetable); - Log.v(TAG, "Adaptor loading new timetable"); - changed = new boolean[newTimetable.size()]; - for (int i = 0; i < newTimetable.size(); i++) { - if (!timetable.contains(newTimetable.get(i), true)) { - changed[i] = true; - Log.i(TAG, "Old timetable does not contain: " + newTimetable.get(i)); - } else { - Log.i(TAG, "Old timetable contains: " + newTimetable.get(i)); - changed[i] = false; - } - } - timetable = newTimetable; - this.notifyDataSetChanged(); - } -} -- cgit v1.2.3