From 19863366e025e6d287be3ccd5173540bc3c2f1d9 Mon Sep 17 00:00:00 2001 From: fr3ts0n Date: Sun, 21 Jun 2015 10:46:11 +0200 Subject: [PATCH] Gauge settings stored in PIDs (for re-usage in list view) --- project.properties | 2 +- src/com/fr3ts0n/ecu/EcuDataPv.java | 12 ++++++++++++ .../ecu/gui/androbd/ObdGaugeAdapter.java | 19 +++++++++++-------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/project.properties b/project.properties index 3cc35f78..a96b6f8a 100644 --- a/project.properties +++ b/project.properties @@ -11,5 +11,5 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-17 +target=android-22 android.package.excludes=com/fr3ts0n/pvs/gui/,com/fr3ts0n/ecu/gui/application/,com/fr3ts0n/ecu/prot/Kw1281Prot.java,com/fr3ts0n/prot/gui/ diff --git a/src/com/fr3ts0n/ecu/EcuDataPv.java b/src/com/fr3ts0n/ecu/EcuDataPv.java index cdef9b71..b5f1ab48 100755 --- a/src/com/fr3ts0n/ecu/EcuDataPv.java +++ b/src/com/fr3ts0n/ecu/EcuDataPv.java @@ -49,6 +49,8 @@ public class EcuDataPv extends IndexedProcessVar "UNITS", }; + private transient Object renderingComponent; + /** * Creates a new instance of EcuDataPv */ @@ -78,4 +80,14 @@ public String getUnits() } return result; } + + public Object getRenderingComponent() + { + return renderingComponent; + } + + public void setRenderingComponent(Object renderingComponent) + { + this.renderingComponent = renderingComponent; + } } diff --git a/src/com/fr3ts0n/ecu/gui/androbd/ObdGaugeAdapter.java b/src/com/fr3ts0n/ecu/gui/androbd/ObdGaugeAdapter.java index 48b8b5cb..141d5abc 100644 --- a/src/com/fr3ts0n/ecu/gui/androbd/ObdGaugeAdapter.java +++ b/src/com/fr3ts0n/ecu/gui/androbd/ObdGaugeAdapter.java @@ -82,6 +82,7 @@ public void remove(EcuDataPv object) { object.remove(FID_GAUGE_SERIES); object.removePvChangeListener(this); + object.setRenderingComponent(null); super.remove(object); } @@ -116,7 +117,10 @@ public View getView(int position, View convertView, ViewGroup parent) CategorySeries category = (CategorySeries) currPv.get(FID_GAUGE_SERIES); int pid = currPv.getAsInt(EcuDataPv.FID_PID); - // get data PV + // get rendering component from PV + convertView = (View)currPv.getRenderingComponent(); + + // if no component assigned to PV, then create one if (convertView == null) { convertView = mInflater.inflate(resourceId, parent, false); @@ -129,6 +133,9 @@ public View getView(int position, View convertView, ViewGroup parent) holder.tvDescr = (TextView) convertView.findViewById(R.id.label); holder.gauge = (FrameLayout) convertView.findViewById(R.id.gauge); + holder.tvDescr.setTextColor(ChartActivity.getColor(pid)); + holder.tvDescr.setText(String.valueOf(currPv.get(EcuDataPv.FID_DESCRIPT))); + Number minValue = (Number) currPv.get(EcuDataPv.FID_MIN); Number maxValue = (Number) currPv.get(EcuDataPv.FID_MAX); if (minValue == null) minValue = 0f; @@ -169,14 +176,10 @@ public View getView(int position, View convertView, ViewGroup parent) holder.gauge.addView(ChartFactory.getDialChartView(getContext(), category, renderer), 0); convertView.setTag(holder); - } - else - { - holder = (ViewHolder)convertView.getTag(); - } - holder.tvDescr.setTextColor(ChartActivity.getColor(pid)); - holder.tvDescr.setText(String.valueOf(currPv.get(EcuDataPv.FID_DESCRIPT))); + // assign rendering component to PV (for re-usage) + currPv.setRenderingComponent(convertView); + } return convertView; }