Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve energy efficiency by applying Cache Energy Pattern #138

Merged
merged 2 commits into from
Jul 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,24 @@
import com.farmerbb.taskbar.util.U;

public final class TaskerConditionReceiver extends BroadcastReceiver {
private Bundle lastbundle = null;

@Override
public void onReceive(Context context, Intent intent) {
if(U.isExternalAccessDisabled(context)) return;

if (lastbundle.equals(intent.getBundleExtra(com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE))) {
// bundle hasn't changed: we can safely return
return;
}
updateValues(intent);

BundleScrubber.scrub(intent);

final Bundle bundle = intent.getBundleExtra(com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE);
BundleScrubber.scrub(bundle);
BundleScrubber.scrub(lastbundle);

if(PluginBundleManager.isBundleValid(bundle)) {
String action = bundle.getString(PluginBundleManager.BUNDLE_EXTRA_STRING_MESSAGE);
if(PluginBundleManager.isBundleValid(lastbundle)) {
String action = lastbundle.getString(PluginBundleManager.BUNDLE_EXTRA_STRING_MESSAGE);

if(action != null) switch(action) {
case "tasker_on":
Expand All @@ -54,4 +61,8 @@ public void onReceive(Context context, Intent intent) {
}
}
}

private void updateValues(Intent intent) {
lastbundle = intent.getBundleExtra(com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE);
}
}