Java Code Examples for androidx.collection.ArrayMap#size()
The following examples show how to use
androidx.collection.ArrayMap#size() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HealthStatsMetrics.java From Battery-Metrics with MIT License | 6 votes |
private void addMeasurements(JSONObject output) throws JSONException { JSONObject measurementsObj = new JSONObject(); for (int i = 0, count = measurements.size(); i < count; i++) { ArrayMap<String, Long> value = measurements.valueAt(i); JSONObject valueOutput = new JSONObject(); for (int j = 0, valueSize = value.size(); j < valueSize; j++) { long v = value.valueAt(j); if (v != 0) { valueOutput.put(value.keyAt(j), v); } } if (valueOutput.length() > 0) { measurementsObj.put(getKeyName(measurements.keyAt(i)), valueOutput); } } if (measurementsObj.length() > 0) { output.put("measurements", measurementsObj); } }
Example 2
Source File: HealthStatsMetrics.java From Battery-Metrics with MIT License | 6 votes |
private void addTimers(JSONObject output) throws JSONException { JSONObject timersObj = new JSONObject(); for (int i = 0, count = timers.size(); i < count; i++) { JSONObject valueOutput = new JSONObject(); ArrayMap<String, TimerMetrics> value = timers.valueAt(i); for (int j = 0, valueCount = value.size(); j < valueCount; j++) { TimerMetrics v = value.valueAt(j); if (v.count != 0 || v.timeMs != 0) { valueOutput.put(value.keyAt(j), v.toJSONObject()); } } if (valueOutput.length() > 0) { timersObj.put(getKeyName(timers.keyAt(i)), valueOutput); } } if (timersObj.length() > 0) { output.put("timers", timersObj); } }
Example 3
Source File: HealthStatsMetrics.java From Battery-Metrics with MIT License | 6 votes |
private void addStats(JSONObject output) throws JSONException { JSONObject statsObj = new JSONObject(); for (int i = 0, count = stats.size(); i < count; i++) { JSONObject valueOutput = new JSONObject(); ArrayMap<String, HealthStatsMetrics> value = stats.valueAt(i); for (int j = 0, valueCount = value.size(); j < valueCount; j++) { JSONObject v = value.valueAt(j).toJSONObject(); if (v.length() > 0) { valueOutput.put(value.keyAt(j), v); } } if (valueOutput.length() > 0) { statsObj.put(getKeyName(stats.keyAt(i)), valueOutput); } } if (statsObj.length() > 0) { output.put("stats", statsObj); } }
Example 4
Source File: BasePresenterSelector.java From LeanbackTvSample with MIT License | 5 votes |
@Override public Presenter getPresenter(Object item) { Class<?> cls = item.getClass(); Presenter presenter; presenter = mClassSingleMap.get(cls); if (presenter != null) { return presenter; } ArrayMap<Class<?>, Presenter> presenters = mClassMap.get(cls); if (presenters != null) { if (presenters.size() == 1) { return presenters.valueAt(0); } else if (presenters.size() > 1) { if (item instanceof ListRow) { ListRow listRow = (ListRow) item; Presenter childPresenter = listRow.getAdapter().getPresenter(listRow); Class<?> childCls = childPresenter.getClass(); do { presenter = presenters.get(childCls); childCls = childCls.getSuperclass(); } while (presenter == null && childCls != null); } else { throw new NullPointerException("presenter == null, please add presenter to PresenterSelector"); } } } if (presenter == null) { throw new NullPointerException("presenter == null, please add presenter to PresenterSelector"); } return presenter; }
Example 5
Source File: HealthStatsMetricsSerializer.java From Battery-Metrics with MIT License | 4 votes |
@Override public void serializeContents(HealthStatsMetrics metrics, DataOutput output) throws IOException { writeString(metrics.dataType, output); int measurementLength = metrics.measurement.size(); output.writeInt(measurementLength); for (int i = 0; i < measurementLength; i++) { output.writeInt(metrics.measurement.keyAt(i)); output.writeLong(metrics.measurement.valueAt(i)); } int timerLength = metrics.timer.size(); output.writeInt(timerLength); for (int i = 0; i < timerLength; i++) { output.writeInt(metrics.timer.keyAt(i)); writeTimer(metrics.timer.valueAt(i), output); } int measurementsLength = metrics.measurements.size(); output.writeInt(measurementsLength); for (int i = 0; i < measurementsLength; i++) { output.writeInt(metrics.measurements.keyAt(i)); ArrayMap<String, Long> currentMeasurement = metrics.measurements.valueAt(i); int currentMeasurementLength = currentMeasurement.size(); output.writeInt(currentMeasurementLength); for (int j = 0; j < currentMeasurementLength; j++) { writeString(currentMeasurement.keyAt(j), output); output.writeLong(currentMeasurement.valueAt(j)); } } int timersLength = metrics.timers.size(); output.writeInt(timersLength); for (int i = 0; i < timersLength; i++) { output.writeInt(metrics.timers.keyAt(i)); ArrayMap<String, TimerMetrics> currentTimer = metrics.timers.valueAt(i); int currentTimerLength = currentTimer.size(); output.writeInt(currentTimerLength); for (int j = 0; j < currentTimerLength; j++) { writeString(currentTimer.keyAt(j), output); writeTimer(currentTimer.valueAt(j), output); } } int statsLength = metrics.stats.size(); output.writeInt(statsLength); for (int i = 0; i < statsLength; i++) { output.writeInt(metrics.stats.keyAt(i)); ArrayMap<String, HealthStatsMetrics> currentStats = metrics.stats.valueAt(i); int currentStatsLength = currentStats.size(); output.writeInt(currentStatsLength); for (int j = 0; j < currentStatsLength; j++) { writeString(currentStats.keyAt(j), output); serializeContents(currentStats.valueAt(j), output); } } }