use of ca.etsmtl.applets.etsmobile.views.ProgressItem in project ETSMobile-Android2 by ApplETS.
the class BandwithFragment method updateProgressBarColorItems.
private void updateProgressBarColorItems(double bandwidthQuota) {
final int[] colorChoice = new int[] { R.color.red_bandwith, R.color.blue_bandwith, R.color.green_bandwith, R.color.purple_bandwith };
int[] legendColors = new int[values.length];
final AppCompatActivity activity = (AppCompatActivity) getActivity();
progressBar.clearProgressItems();
bandwidthQuota = bandwidthQuota / 1024;
for (int i = 0, color = 0; i < values.length - 1; ++i) {
ProgressItem progressItem = new ProgressItem(colorChoice[color], (values[i] / bandwidthQuota) * 100);
progressBar.addProgressItem(progressItem);
legendColors[i] = colorChoice[color];
color++;
if (color == colorChoice.length)
color = 0;
}
if (values.length > 0) {
int lastValue = values.length - 1;
ProgressItem progressItem = new ProgressItem(R.color.grey_bandwith, (values[lastValue] / bandwidthQuota) * 100);
legendColors[lastValue] = R.color.grey_bandwith;
progressBar.addProgressItem(progressItem);
}
if (activity != null) {
final int[] colors = legendColors;
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
grid.setAdapter(new LegendAdapter(activity, rooms, colors));
}
});
}
}
Aggregations