use of com.android.settings.slices.SliceBackgroundWorker in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryFixSlice method getSlice.
@Override
public Slice getSlice() {
final ListBuilder sliceBuilder = new ListBuilder(mContext, BATTERY_FIX_SLICE_URI, ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED);
if (!isBatteryTipAvailableFromCache(mContext)) {
return buildBatteryGoodSlice(sliceBuilder, true);
}
final SliceBackgroundWorker worker = SliceBackgroundWorker.getInstance(getUri());
final List<BatteryTip> batteryTips = worker != null ? worker.getResults() : null;
if (batteryTips == null) {
// Because we need wait slice background worker return data
return buildBatteryGoodSlice(sliceBuilder, false);
}
for (BatteryTip batteryTip : batteryTips) {
if (batteryTip.getState() == BatteryTip.StateType.INVISIBLE) {
continue;
}
final Drawable drawable = mContext.getDrawable(batteryTip.getIconId());
final int iconTintColorId = batteryTip.getIconTintColorId();
if (iconTintColorId != View.NO_ID) {
drawable.setColorFilter(new PorterDuffColorFilter(mContext.getResources().getColor(iconTintColorId), PorterDuff.Mode.SRC_IN));
}
final IconCompat icon = Utils.createIconWithDrawable(drawable);
final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, batteryTip.getTitle(mContext));
sliceBuilder.addRow(new RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(batteryTip.getTitle(mContext)).setSubtitle(batteryTip.getSummary(mContext)).setPrimaryAction(primaryAction));
break;
}
return sliceBuilder.build();
}
use of com.android.settings.slices.SliceBackgroundWorker in project android_packages_apps_Settings by omnirom.
the class WifiSliceTest method setWorkerResults.
private void setWorkerResults(WifiSliceItem... wifiSliceItems) {
final ArrayList<WifiSliceItem> results = new ArrayList<>();
for (WifiSliceItem wifiSliceItem : wifiSliceItems) {
results.add(wifiSliceItem);
}
final SliceBackgroundWorker worker = SliceBackgroundWorker.getInstance(mWifiSlice.getUri());
doReturn(results).when(worker).getResults();
}
use of com.android.settings.slices.SliceBackgroundWorker in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiSliceTest method setWorkerResults.
private void setWorkerResults(AccessPoint... accessPoints) {
final ArrayList<AccessPoint> results = new ArrayList<>();
for (AccessPoint ap : accessPoints) {
results.add(ap);
}
final SliceBackgroundWorker worker = SliceBackgroundWorker.getInstance(mWifiSlice.getUri());
doReturn(results).when(worker).getResults();
}
use of com.android.settings.slices.SliceBackgroundWorker in project android_packages_apps_Settings by omnirom.
the class BatteryFixSlice method getSlice.
@Override
public Slice getSlice() {
final ListBuilder sliceBuilder = new ListBuilder(mContext, BATTERY_FIX_SLICE_URI, ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED);
if (!isBatteryTipAvailableFromCache(mContext)) {
return buildBatteryGoodSlice(sliceBuilder, true);
}
final SliceBackgroundWorker worker = SliceBackgroundWorker.getInstance(getUri());
final List<BatteryTip> batteryTips = worker != null ? worker.getResults() : null;
if (batteryTips == null) {
// Because we need wait slice background worker return data
return buildBatteryGoodSlice(sliceBuilder, false);
}
for (BatteryTip batteryTip : batteryTips) {
if (batteryTip.getState() == BatteryTip.StateType.INVISIBLE) {
continue;
}
final Drawable drawable = mContext.getDrawable(batteryTip.getIconId());
final int iconTintColorId = batteryTip.getIconTintColorId();
if (iconTintColorId != View.NO_ID) {
drawable.setColorFilter(new PorterDuffColorFilter(mContext.getResources().getColor(iconTintColorId), PorterDuff.Mode.SRC_IN));
}
final IconCompat icon = Utils.createIconWithDrawable(drawable);
final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, batteryTip.getTitle(mContext));
sliceBuilder.addRow(new RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(batteryTip.getTitle(mContext)).setSubtitle(batteryTip.getSummary(mContext)).setPrimaryAction(primaryAction));
break;
}
return sliceBuilder.build();
}
Aggregations