Skip to content

Commit

Permalink
Gauge settings stored in PIDs (for re-usage in list view)
Browse files Browse the repository at this point in the history
  • Loading branch information
fr3ts0n committed Jun 21, 2015
1 parent 018b9c6 commit 1986336
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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/
12 changes: 12 additions & 0 deletions src/com/fr3ts0n/ecu/EcuDataPv.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class EcuDataPv extends IndexedProcessVar
"UNITS",
};

private transient Object renderingComponent;

/**
* Creates a new instance of EcuDataPv
*/
Expand Down Expand Up @@ -78,4 +80,14 @@ public String getUnits()
}
return result;
}

public Object getRenderingComponent()
{
return renderingComponent;
}

public void setRenderingComponent(Object renderingComponent)
{
this.renderingComponent = renderingComponent;
}
}
19 changes: 11 additions & 8 deletions src/com/fr3ts0n/ecu/gui/androbd/ObdGaugeAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void remove(EcuDataPv object)
{
object.remove(FID_GAUGE_SERIES);
object.removePvChangeListener(this);
object.setRenderingComponent(null);
super.remove(object);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1986336

Please sign in to comment.