Commit ee47058f authored by Romain Hunault's avatar Romain Hunault
Browse files

Merge branch 'fix-duplicate-icon' into 'master'

[FIX] Prevent item from being added twice by first checking them

See merge request !52
parents 0306fc15 55349ca6
Pipeline #87634 passed with stage
in 6 minutes and 1 second
......@@ -22,4 +22,12 @@ public class AppAddEvent extends Event{
public UserHandle getUserHandle() {
return userHandle;
}
@Override
public String toString() {
return "AppAddEvent{" +
"packageName='" + packageName + '\'' +
", userHandle=" + userHandle +
'}';
}
}
......@@ -520,10 +520,7 @@ public class LauncherActivity extends AppCompatActivity implements
}
public void onAppAddEvent(AppAddEvent appAddEvent) {
moveTo = -1;
ApplicationItem applicationItem = AppUtils.createAppItem(this, appAddEvent.getPackageName(),
appAddEvent.getUserHandle());
addLauncherItem(applicationItem);
updateOrAddApp(appAddEvent.getPackageName(),appAddEvent.getUserHandle());
//DatabaseManager.getManager(this).saveLayouts(pages, mDock);
if (moveTo != -1) {
mHorizontalPager.setCurrentPage(moveTo);
......@@ -538,7 +535,7 @@ public class LauncherActivity extends AppCompatActivity implements
}
public void onAppChangeEvent(AppChangeEvent appChangeEvent) {
updateApp(appChangeEvent.getPackageName(), appChangeEvent.getUserHandle());
updateOrAddApp(appChangeEvent.getPackageName(), appChangeEvent.getUserHandle());
DatabaseManager.getManager(this).saveLayouts(pages, mDock);
}
......@@ -558,6 +555,7 @@ public class LauncherActivity extends AppCompatActivity implements
return;
}
if (launcherItem != null) {
BlissFrameLayout view = prepareLauncherItem(launcherItem);
int current = 0;
......@@ -860,7 +858,7 @@ public class LauncherActivity extends AppCompatActivity implements
}
}
private void updateApp(String packageName, UserHandle userHandle) {
private void updateOrAddApp(String packageName, UserHandle userHandle) {
handleWobbling(false);
ApplicationItem updatedAppItem = AppUtils.createAppItem(this, packageName, userHandle);
if (updatedAppItem == null) {
......@@ -952,6 +950,7 @@ public class LauncherActivity extends AppCompatActivity implements
existingAppItem);
gridLayout.removeViewAt(j);
addAppToGrid(gridLayout, blissFrameLayout, j);
moveTo = i + 1;
return;
}
}
......@@ -964,6 +963,7 @@ public class LauncherActivity extends AppCompatActivity implements
BlissFrameLayout blissFrameLayout = prepareLauncherItem(updatedAppItem);
gridLayout.removeViewAt(j);
addAppToGrid(gridLayout, blissFrameLayout, j);
moveTo = i + 1;
return;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment