Skip to content

Commit

Permalink
fix: #4 drop already removed applications from the stack
Browse files Browse the repository at this point in the history
  • Loading branch information
yauhen-l committed Oct 7, 2020
1 parent 0da48e7 commit 4dc5544
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/src/main/java/by/yauhenl/gardine/GardineWidgetService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import androidx.preference.PreferenceManager;

import java.util.ArrayDeque;
import java.util.Iterator;

public class GardineWidgetService extends AccessibilityService {

Expand Down Expand Up @@ -173,6 +174,16 @@ public void actualizeRecentApps() {
boolean removed = recentApps.removeFirstOccurrence(new App(this.currentAppPackage));
Log.d(LoggingUtils.RECENT_APPS_TAG, "Current app " + this.currentAppPackage + " has been removed: " + removed);
}
Iterator<App> iter = recentApps.iterator();
while (iter.hasNext()) {
App a = iter.next();
if (this.getPackageManager().getLaunchIntentForPackage(a.packageName) == null) {
Log.i(LoggingUtils.RECENT_APPS_TAG, "App '" + a.title + "' cannot be resolved. Dropping it.");
this.recentActivities.remove(a);
iter.remove();
}
}

this.gardineView.setApps(recentApps);
}

Expand Down

0 comments on commit 4dc5544

Please sign in to comment.