use of com.android.launcher3.model.BgDataModel.Callbacks in project android_packages_apps_Launcher3 by crdroidandroid.
the class Workspace method removeAllWorkspaceScreens.
public void removeAllWorkspaceScreens() {
// Disable all layout transitions before removing all pages to ensure that we don't get the
// transition animations competing with us changing the scroll when we add pages
disableLayoutTransitions();
// Recycle the QSB widget
View qsb = findViewById(R.id.search_container_workspace);
if (qsb != null) {
((ViewGroup) qsb.getParent()).removeView(qsb);
}
// Remove the pages and clear the screen models
removeFolderListeners();
removeAllViews();
mScreenOrder.clear();
mWorkspaceScreens.clear();
// Remove any deferred refresh callbacks
mLauncher.mHandler.removeCallbacksAndMessages(DeferredWidgetRefresh.class);
// Ensure that the first page is always present
bindAndInitFirstWorkspaceScreen(qsb);
// Re-enable the layout transitions
enableLayoutTransitions();
}
use of com.android.launcher3.model.BgDataModel.Callbacks in project Neo-Launcher by NeoApplications.
the class AddWorkspaceItemsTaskTest method testAddItem_some_items_added.
@Test
public void testAddItem_some_items_added() throws Exception {
WorkspaceItemInfo info = new WorkspaceItemInfo();
info.intent = new Intent().setComponent(mComponent1);
WorkspaceItemInfo info2 = new WorkspaceItemInfo();
info2.intent = new Intent().setComponent(mComponent2);
// Setup a screen with a hole
setupWorkspaceWithHoles(1, 1, new Rect(2, 2, 3, 3));
executeTaskForTest(newTask(info, info2)).get(0).run();
ArgumentCaptor<ArrayList> notAnimated = ArgumentCaptor.forClass(ArrayList.class);
ArgumentCaptor<ArrayList> animated = ArgumentCaptor.forClass(ArrayList.class);
// only info2 should be added because info was already added to the workspace
// in setupWorkspaceWithHoles()
verify(callbacks).bindAppsAdded(any(IntArray.class), notAnimated.capture(), animated.capture());
assertTrue(notAnimated.getValue().isEmpty());
assertEquals(1, animated.getValue().size());
assertTrue(animated.getValue().contains(info2));
}
use of com.android.launcher3.model.BgDataModel.Callbacks in project Neo-Launcher by NeoApplications.
the class BaseModelUpdateTaskTestCase method setUp.
@Before
public void setUp() throws Exception {
ShadowLog.stream = System.out;
mProvider = Robolectric.setupContentProvider(TestLauncherProvider.class);
ShadowContentResolver.registerProviderInternal(LauncherProvider.AUTHORITY, mProvider);
callbacks = mock(Callbacks.class);
appState = mock(LauncherAppState.class);
model = mock(LauncherModel.class);
modelWriter = mock(ModelWriter.class);
when(appState.getModel()).thenReturn(model);
when(model.getWriter(anyBoolean(), anyBoolean())).thenReturn(modelWriter);
when(model.getCallback()).thenReturn(callbacks);
myUser = Process.myUserHandle();
bgDataModel = new BgDataModel();
targetContext = RuntimeEnvironment.application;
idp = new InvariantDeviceProfile();
iconCache = new MyIconCache(targetContext, idp);
allAppsList = new AllAppsList(iconCache, new AppFilter());
when(appState.getIconCache()).thenReturn(iconCache);
when(appState.getInvariantDeviceProfile()).thenReturn(idp);
when(appState.getContext()).thenReturn(targetContext);
}
use of com.android.launcher3.model.BgDataModel.Callbacks in project Neo-Launcher by NeoApplications.
the class LauncherModel method forceReload.
/**
* Reloads the workspace items from the DB and re-binds the workspace. This should generally
* not be called as DB updates are automatically followed by UI update
*
* @param synchronousBindPage The page to bind first. Can pass -1 to use the current page.
*/
public void forceReload(int synchronousBindPage) {
synchronized (mLock) {
// Stop any existing loaders first, so they don't set mModelLoaded to true later
stopLoader();
mModelLoaded = false;
}
// Start the loader if launcher is already running, otherwise the loader will run,
// the next time launcher starts
Callbacks callbacks = getCallback();
if (callbacks != null) {
if (synchronousBindPage < 0) {
synchronousBindPage = callbacks.getCurrentWorkspaceScreen();
}
startLoader(synchronousBindPage);
}
}
use of com.android.launcher3.model.BgDataModel.Callbacks in project android_packages_apps_Trebuchet by LineageOS.
the class AddWorkspaceItemsTaskTest method testAddItem_some_items_added.
@Test
public void testAddItem_some_items_added() throws Exception {
Callbacks callbacks = mock(Callbacks.class);
mModelHelper.getModel().addCallbacks(callbacks);
WorkspaceItemInfo info = new WorkspaceItemInfo();
info.intent = new Intent().setComponent(mComponent1);
WorkspaceItemInfo info2 = new WorkspaceItemInfo();
info2.intent = new Intent().setComponent(mComponent2);
// Setup a screen with a hole
setupWorkspaceWithHoles(1, 1, new Rect(2, 2, 3, 3));
mModelHelper.executeTaskForTest(newTask(info, info2)).get(0).run();
ArgumentCaptor<ArrayList> notAnimated = ArgumentCaptor.forClass(ArrayList.class);
ArgumentCaptor<ArrayList> animated = ArgumentCaptor.forClass(ArrayList.class);
// only info2 should be added because info was already added to the workspace
// in setupWorkspaceWithHoles()
verify(callbacks).bindAppsAdded(any(IntArray.class), notAnimated.capture(), animated.capture());
assertTrue(notAnimated.getValue().isEmpty());
assertEquals(1, animated.getValue().size());
assertTrue(animated.getValue().contains(info2));
}
Aggregations