use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by LineageOS.
the class ChartDataUsagePreference method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
UsageView chart = (UsageView) holder.findViewById(R.id.data_usage);
if (mNetwork == null)
return;
int top = getTop();
chart.clearPaths();
chart.configureGraph(toInt(mEnd - mStart), top);
calcPoints(chart);
chart.setBottomLabels(new CharSequence[] { Utils.formatDateRange(getContext(), mStart, mStart), Utils.formatDateRange(getContext(), mEnd, mEnd) });
bindNetworkPolicy(chart, mPolicy, top);
}
use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by LineageOS.
the class BatteryHistoryPreference method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
final long startTime = System.currentTimeMillis();
if (mBatteryInfo == null) {
return;
}
((TextView) view.findViewById(R.id.charge)).setText(mBatteryInfo.batteryPercentString);
mSummaryView = (TextView) view.findViewById(R.id.bottom_summary);
if (mSummary != null) {
mSummaryView.setText(mSummary);
}
if (hideSummary) {
mSummaryView.setVisibility(View.GONE);
}
UsageView usageView = (UsageView) view.findViewById(R.id.battery_usage);
usageView.findViewById(R.id.label_group).setAlpha(.7f);
mBatteryInfo.bindHistory(usageView);
BatteryUtils.logRuntime(TAG, "onBindViewHolder", startTime);
}
use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by LineageOS.
the class BatteryInfoTest method assertOnlyHistory.
private void assertOnlyHistory(BatteryInfo info) {
mockBatteryStatsHistory();
UsageView view = mock(UsageView.class);
doReturn(mContext).when(view).getContext();
info.bindHistory(view);
verify(view, times(1)).configureGraph(anyInt(), anyInt());
verify(view, times(1)).addPath(any(SparseIntArray.class));
verify(view, never()).addProjectedPath(any(SparseIntArray.class));
}
use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by LineageOS.
the class BatteryInfoTest method assertHistoryAndEnhancedProjection.
private void assertHistoryAndEnhancedProjection(BatteryInfo info) {
mockBatteryStatsHistory();
UsageView view = mock(UsageView.class);
doReturn(mContext).when(view).getContext();
SparseIntArray pointsExpected = new SparseIntArray();
pointsExpected.append(2000, 96);
pointsExpected.append(2500, 95);
pointsExpected.append(3000, 94);
doReturn(pointsExpected).when(mFeatureFactory.powerUsageFeatureProvider).getEnhancedBatteryPredictionCurve(any(Context.class), anyLong());
info.bindHistory(view);
verify(view, times(2)).configureGraph(anyInt(), anyInt());
verify(view, times(1)).addPath(any(SparseIntArray.class));
ArgumentCaptor<SparseIntArray> pointsActual = ArgumentCaptor.forClass(SparseIntArray.class);
verify(view, times(1)).addProjectedPath(pointsActual.capture());
assertThat(pointsActual.getValue()).isEqualTo(pointsExpected);
}
use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by omnirom.
the class ChartDataUsagePreference method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
UsageView chart = (UsageView) holder.findViewById(R.id.data_usage);
if (mNetwork == null)
return;
int top = getTop();
chart.clearPaths();
chart.configureGraph(toInt(mEnd - mStart), top);
calcPoints(chart);
chart.setBottomLabels(new CharSequence[] { Utils.formatDateRange(getContext(), mStart, mStart), Utils.formatDateRange(getContext(), mEnd, mEnd) });
bindNetworkPolicy(chart, mPolicy, top);
}
Aggregations