Search in sources :

Example 6 with EXIT

use of com.android.launcher3.util.RaceConditionTracker.EXIT in project Neo-Launcher by NeoApplications.

the class Launcher method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    RaceConditionTracker.onEvent(ON_CREATE_EVT, ENTER);
    if (DEBUG_STRICT_MODE) {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
    }
    TraceHelper.beginSection("Launcher-onCreate");
    super.onCreate(savedInstanceState);
    TraceHelper.partitionSection("Launcher-onCreate", "super call");
    LauncherAppState app = LauncherAppState.getInstance(this);
    OmegaPreferences prefs = Utilities.getOmegaPrefs(this);
    prefs.getDrawerGridSize();
    prefs.getGridSize();
    prefs.getDockGridSize();
    mOldConfig = new Configuration(getResources().getConfiguration());
    mModel = app.setLauncher(this);
    mRotationHelper = new RotationHelper(this);
    InvariantDeviceProfile idp = app.getInvariantDeviceProfile();
    initDeviceProfile(idp);
    idp.addOnChangeListener(this);
    mSharedPrefs = Utilities.getPrefs(this);
    mIconCache = app.getIconCache();
    mAccessibilityDelegate = new LauncherAccessibilityDelegate(this);
    mDragController = new DragController(this);
    mAllAppsController = new AllAppsTransitionController(this);
    mStateManager = new LauncherStateManager(this);
    UiFactory.onCreate(this);
    mAppWidgetManager = AppWidgetManagerCompat.getInstance(this);
    mAppWidgetHost = new LauncherAppWidgetHost(this, appWidgetId -> getWorkspace().removeWidget(appWidgetId));
    mAppWidgetHost.startListening();
    mLauncherView = LayoutInflater.from(this).inflate(R.layout.launcher, null);
    setupViews();
    mPopupDataProvider = new PopupDataProvider(this);
    mAppTransitionManager = LauncherAppTransitionManager.newInstance(this);
    boolean internalStateHandled = InternalStateHandler.handleCreate(this, getIntent());
    if (internalStateHandled) {
        if (savedInstanceState != null) {
            // InternalStateHandler has already set the appropriate state.
            // We dont need to do anything.
            savedInstanceState.remove(RUNTIME_STATE);
        }
    }
    restoreState(savedInstanceState);
    mStateManager.reapplyState();
    // We only load the page synchronously if the user rotates (or triggers a
    // configuration change) while launcher is in the foreground
    int currentScreen = PagedView.INVALID_RESTORE_PAGE;
    if (savedInstanceState != null) {
        currentScreen = savedInstanceState.getInt(RUNTIME_STATE_CURRENT_SCREEN, currentScreen);
    }
    if (!mModel.startLoader(currentScreen)) {
        if (!internalStateHandled) {
            // If we are not binding synchronously, show a fade in animation when
            // the first page bind completes.
            mDragLayer.getAlphaProperty(ALPHA_INDEX_LAUNCHER_LOAD).setValue(0);
        }
    } else {
        // Pages bound synchronously.
        mWorkspace.setCurrentPage(currentScreen);
        setWorkspaceLoading(true);
    }
    // For handling default keys
    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
    setContentView(mLauncherView);
    getRootView().dispatchInsets();
    // Listen for broadcasts
    registerReceiver(mScreenOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
    getSystemUiController().updateUiState(SystemUiController.UI_STATE_BASE_WINDOW, Themes.getAttrBoolean(this, R.attr.isWorkspaceDarkText));
    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.onCreate(savedInstanceState);
    }
    mRotationHelper.initialize();
    TraceHelper.endSection("Launcher-onCreate");
    RaceConditionTracker.onEvent(ON_CREATE_EVT, EXIT);
    mStateManager.addStateListener(new LauncherStateManager.StateListener() {

        @Override
        public void onStateTransitionStart(LauncherState toState) {
        }

        @Override
        public void onStateTransitionComplete(LauncherState finalState) {
            float alpha = 1f - mCurrentAssistantVisibility;
            if (finalState == NORMAL) {
                mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
            } else if (finalState == OVERVIEW || finalState == OVERVIEW_PEEK) {
                mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
                mScrimView.getAlphaProperty(SCRIM_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
            } else {
                mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(1f);
                mScrimView.getAlphaProperty(SCRIM_VIEW_ALPHA_CHANNEL_INDEX).setValue(1f);
            }
        }
    });
}
Also used : Bundle(android.os.Bundle) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) ViewOnDrawExecutor(com.android.launcher3.util.ViewOnDrawExecutor) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) CustomActionsPopup(com.android.launcher3.keyboard.CustomActionsPopup) CONFIG_ORIENTATION(android.content.pm.ActivityInfo.CONFIG_ORIENTATION) OVERVIEW(com.android.launcher3.LauncherState.OVERVIEW) CustomWidgetParser(com.android.launcher3.widget.custom.CustomWidgetParser) Process(android.os.Process) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Handler(android.os.Handler) Display(android.view.Display) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) OmegaLauncher(com.saggitt.omega.OmegaLauncher) RotationMode(com.android.launcher3.graphics.RotationMode) TargetApi(android.annotation.TargetApi) Log(android.util.Log) OVERVIEW_PEEK(com.android.launcher3.LauncherState.OVERVIEW_PEEK) PrintWriter(java.io.PrintWriter) KeyboardShortcutInfo(android.view.KeyboardShortcutInfo) ALPHA_INDEX_LAUNCHER_LOAD(com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOAD) IntentFilter(android.content.IntentFilter) AllAppsStore(com.android.launcher3.allapps.AllAppsStore) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) LauncherAccessibilityDelegate(com.android.launcher3.accessibility.LauncherAccessibilityDelegate) Nullable(androidx.annotation.Nullable) ShortcutUtil(com.android.launcher3.util.ShortcutUtil) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) DiscoveryBounce(com.android.launcher3.allapps.DiscoveryBounce) TextKeyListener(android.text.method.TextKeyListener) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) NORMAL(com.android.launcher3.LauncherState.NORMAL) LauncherLogProto(com.android.launcher3.userevent.nano.LauncherLogProto) TYPE_REBIND_SAFE(com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE) ViewGroupFocusHelper(com.android.launcher3.keyboard.ViewGroupFocusHelper) FileLog(com.android.launcher3.logging.FileLog) UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) InternalStateHandler(com.android.launcher3.states.InternalStateHandler) SystemUiController(com.android.launcher3.util.SystemUiController) AppLaunchTracker(com.android.launcher3.model.AppLaunchTracker) ArrayList(java.util.ArrayList) IntentSender(android.content.IntentSender) REQUEST_NONE(com.android.launcher3.states.RotationHelper.REQUEST_NONE) AppWidgetHostView(android.appwidget.AppWidgetHostView) PendingRequestArgs(com.android.launcher3.util.PendingRequestArgs) Toast(android.widget.Toast) Menu(android.view.Menu) DragObject(com.android.launcher3.DropTarget.DragObject) TYPE_ALL(com.android.launcher3.AbstractFloatingView.TYPE_ALL) PopupDataProvider(com.android.launcher3.popup.PopupDataProvider) IntArray(com.android.launcher3.util.IntArray) Parcelable(android.os.Parcelable) ActivityContext(com.android.launcher3.views.ActivityContext) DragController(com.android.launcher3.dragndrop.DragController) TextUtils(android.text.TextUtils) FeatureFlags(com.android.launcher3.config.FeatureFlags) ItemClickHandler(com.android.launcher3.touch.ItemClickHandler) EXIT(com.android.launcher3.util.RaceConditionTracker.EXIT) AppWidgetManager(android.appwidget.AppWidgetManager) ComponentCallbacks2(android.content.ComponentCallbacks2) ENTER(com.android.launcher3.util.RaceConditionTracker.ENTER) FolderGridOrganizer(com.android.launcher3.folder.FolderGridOrganizer) SharedPreferences(android.content.SharedPreferences) Configuration(android.content.res.Configuration) ComponentKey(com.android.launcher3.util.ComponentKey) AlphaProperty(com.android.launcher3.util.MultiValueAlpha.AlphaProperty) ValueAnimator(android.animation.ValueAnimator) DotInfo(com.android.launcher3.dot.DotInfo) Rect(android.graphics.Rect) Callbacks(com.android.launcher3.model.BgDataModel.Callbacks) PackageManager(android.content.pm.PackageManager) SPRING_LOADED_EXIT_DELAY(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY) LauncherAppsCompatVO(com.android.launcher3.compat.LauncherAppsCompatVO) Animator(android.animation.Animator) IconCache(com.android.launcher3.icons.IconCache) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) WidgetsFullSheet(com.android.launcher3.widget.WidgetsFullSheet) UiFactory(com.android.launcher3.uioverrides.UiFactory) ActivityOptions(android.app.ActivityOptions) KeyboardShortcutGroup(android.view.KeyboardShortcutGroup) RotationHelper(com.android.launcher3.states.RotationHelper) View(android.view.View) Predicate(java.util.function.Predicate) ObjectAnimator(android.animation.ObjectAnimator) Collection(java.util.Collection) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) BroadcastReceiver(android.content.BroadcastReceiver) ViewGroup(android.view.ViewGroup) MultiValueAlpha(com.android.launcher3.util.MultiValueAlpha) SparseArray(android.util.SparseArray) List(java.util.List) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) NotificationListener(com.android.launcher3.notification.NotificationListener) OmegaPreferences(com.saggitt.omega.OmegaPreferences) ActivityNotFoundException(android.content.ActivityNotFoundException) WidgetHostViewLoader(com.android.launcher3.widget.WidgetHostViewLoader) FolderNameProvider(com.android.launcher3.folder.FolderNameProvider) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Themes(com.android.launcher3.util.Themes) ModelWriter(com.android.launcher3.model.ModelWriter) Context(android.content.Context) CONFIG_SCREEN_SIZE(android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE) KeyEvent(android.view.KeyEvent) ActivityResultInfo(com.android.launcher3.util.ActivityResultInfo) WidgetAddFlowHandler(com.android.launcher3.widget.WidgetAddFlowHandler) TYPE_SNACKBAR(com.android.launcher3.AbstractFloatingView.TYPE_SNACKBAR) FolderIcon(com.android.launcher3.folder.FolderIcon) Intent(android.content.Intent) HashMap(java.util.HashMap) UiThreadHelper(com.android.launcher3.util.UiThreadHelper) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) HashSet(java.util.HashSet) LoggerUtils.newTarget(com.android.launcher3.logging.LoggerUtils.newTarget) AnimatorSet(android.animation.AnimatorSet) DragLayer(com.android.launcher3.dragndrop.DragLayer) Build(android.os.Build) StatsLogUtils(com.android.launcher3.logging.StatsLogUtils) Action(com.android.launcher3.userevent.nano.LauncherLogProto.Action) ContainerType(com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType) LayoutInflater(android.view.LayoutInflater) PackageUserKey(com.android.launcher3.util.PackageUserKey) Point(android.graphics.Point) RaceConditionTracker(com.android.launcher3.util.RaceConditionTracker) AppWidgetManagerCompat(com.android.launcher3.compat.AppWidgetManagerCompat) WidgetListRowEntry(com.android.launcher3.widget.WidgetListRowEntry) PropertyListBuilder(com.android.launcher3.anim.PropertyListBuilder) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) StrictMode(android.os.StrictMode) OvershootInterpolator(android.view.animation.OvershootInterpolator) LoggerUtils.newContainerTarget(com.android.launcher3.logging.LoggerUtils.newContainerTarget) FileDescriptor(java.io.FileDescriptor) UserEventDelegate(com.android.launcher3.logging.UserEventDispatcher.UserEventDelegate) ScrimView(com.android.launcher3.views.ScrimView) Thunk(com.android.launcher3.util.Thunk) VisibleForTesting(androidx.annotation.VisibleForTesting) DragView(com.android.launcher3.dragndrop.DragView) TraceHelper(com.android.launcher3.util.TraceHelper) IntentFilter(android.content.IntentFilter) Configuration(android.content.res.Configuration) RotationHelper(com.android.launcher3.states.RotationHelper) PropertyListBuilder(com.android.launcher3.anim.PropertyListBuilder) PopupDataProvider(com.android.launcher3.popup.PopupDataProvider) OmegaPreferences(com.saggitt.omega.OmegaPreferences) Point(android.graphics.Point) StrictMode(android.os.StrictMode) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) DragController(com.android.launcher3.dragndrop.DragController) LauncherAccessibilityDelegate(com.android.launcher3.accessibility.LauncherAccessibilityDelegate)

Example 7 with EXIT

use of com.android.launcher3.util.RaceConditionTracker.EXIT in project Neo-Launcher by NeoApplications.

the class LauncherModel method startLoaderForResults.

public void startLoaderForResults(LoaderResults results) {
    synchronized (mLock) {
        stopLoader();
        mLoaderTask = new LoaderTask(mApp, mBgAllAppsList, sBgDataModel, results);
        // Always post the loader task, instead of running directly (even on same thread) so
        // that we exit any nested synchronized blocks
        MODEL_EXECUTOR.post(mLoaderTask);
    }
}
Also used : LoaderTask(com.android.launcher3.model.LoaderTask)

Example 8 with EXIT

use of com.android.launcher3.util.RaceConditionTracker.EXIT in project Neo-Launcher by NeoApplications.

the class DragController method startDrag.

/**
 * Starts a drag.
 * When the drag is started, the UI automatically goes into spring loaded mode. On a successful
 * drop, it is the responsibility of the {@link DropTarget} to exit out of the spring loaded
 * mode. If the drop was cancelled for some reason, the UI will automatically exit out of this mode.
 *
 * @param b The bitmap to display as the drag image.  It will be re-scaled to the
 *          enlarged size.
 * @param dragLayerX The x position in the DragLayer of the left-top of the bitmap.
 * @param dragLayerY The y position in the DragLayer of the left-top of the bitmap.
 * @param source An object representing where the drag originated
 * @param dragInfo The data associated with the object that is being dragged
 * @param dragRegion Coordinates within the bitmap b for the position of item being dragged.
 *          Makes dragging feel more precise, e.g. you can clip out a transparent border
 */
public DragView startDrag(Bitmap b, int dragLayerX, int dragLayerY, DragSource source, ItemInfo dragInfo, Point dragOffset, Rect dragRegion, float initialDragViewScale, float dragViewScaleOnDrop, DragOptions options) {
    if (PROFILE_DRAWING_DURING_DRAG) {
        android.os.Debug.startMethodTracing("Launcher");
    }
    // Hide soft keyboard, if visible
    UiThreadHelper.hideKeyboardAsync(mLauncher, mWindowToken);
    AbstractFloatingView.closeOpenViews(mLauncher, false, TYPE_DISCOVERY_BOUNCE);
    mOptions = options;
    if (mOptions.systemDndStartPoint != null) {
        mMotionDownX = mOptions.systemDndStartPoint.x;
        mMotionDownY = mOptions.systemDndStartPoint.y;
    }
    final int registrationX = mMotionDownX - dragLayerX;
    final int registrationY = mMotionDownY - dragLayerY;
    final int dragRegionLeft = dragRegion == null ? 0 : dragRegion.left;
    final int dragRegionTop = dragRegion == null ? 0 : dragRegion.top;
    mLastDropTarget = null;
    mDragObject = new DropTarget.DragObject();
    mIsInPreDrag = mOptions.preDragCondition != null && !mOptions.preDragCondition.shouldStartDrag(0);
    final Resources res = mLauncher.getResources();
    final float scaleDps = mIsInPreDrag ? res.getDimensionPixelSize(R.dimen.pre_drag_view_scale) : 0f;
    final DragView dragView = mDragObject.dragView = new DragView(mLauncher, b, registrationX, registrationY, initialDragViewScale, dragViewScaleOnDrop, scaleDps);
    dragView.setItemInfo(dragInfo);
    mDragObject.dragComplete = false;
    if (mOptions.isAccessibleDrag) {
        // For an accessible drag, we assume the view is being dragged from the center.
        mDragObject.xOffset = b.getWidth() / 2;
        mDragObject.yOffset = b.getHeight() / 2;
        mDragObject.accessibleDrag = true;
    } else {
        mDragObject.xOffset = mMotionDownX - (dragLayerX + dragRegionLeft);
        mDragObject.yOffset = mMotionDownY - (dragLayerY + dragRegionTop);
        mDragObject.stateAnnouncer = DragViewStateAnnouncer.createFor(dragView);
        mDragDriver = DragDriver.create(mLauncher, this, mDragObject, mOptions);
    }
    mDragObject.dragSource = source;
    mDragObject.dragInfo = dragInfo;
    mDragObject.originalDragInfo = new ItemInfo();
    mDragObject.originalDragInfo.copyFrom(dragInfo);
    if (dragOffset != null) {
        dragView.setDragVisualizeOffset(new Point(dragOffset));
    }
    if (dragRegion != null) {
        dragView.setDragRegion(new Rect(dragRegion));
    }
    mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    dragView.show(mLastTouch[0], mLastTouch[1]);
    mDistanceSinceScroll = 0;
    if (!mIsInPreDrag) {
        callOnDragStart();
    } else if (mOptions.preDragCondition != null) {
        mOptions.preDragCondition.onPreDragStart(mDragObject);
    }
    handleMoveEvent(mLastTouch[0], mLastTouch[1]);
    mLauncher.getUserEventDispatcher().resetActionDurationMillis();
    return dragView;
}
Also used : Rect(android.graphics.Rect) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) ItemInfo(com.android.launcher3.ItemInfo) DropTarget(com.android.launcher3.DropTarget) Resources(android.content.res.Resources) Point(android.graphics.Point) Point(android.graphics.Point)

Example 9 with EXIT

use of com.android.launcher3.util.RaceConditionTracker.EXIT in project android_packages_apps_Launcher3 by ArrowOS.

the class LauncherModel method startLoader.

private boolean startLoader(Callbacks[] newCallbacks) {
    // Enable queue before starting loader. It will get disabled in Launcher#finishBindingItems
    ItemInstallQueue.INSTANCE.get(mApp.getContext()).pauseModelPush(ItemInstallQueue.FLAG_LOADER_RUNNING);
    synchronized (mLock) {
        // If there is already one running, tell it to stop.
        boolean wasRunning = stopLoader();
        boolean bindDirectly = mModelLoaded && !mIsLoaderTaskRunning;
        boolean bindAllCallbacks = wasRunning || !bindDirectly || newCallbacks.length == 0;
        final Callbacks[] callbacksList = bindAllCallbacks ? getCallbacks() : newCallbacks;
        if (callbacksList.length > 0) {
            // Clear any pending bind-runnables from the synchronized load process.
            for (Callbacks cb : callbacksList) {
                MAIN_EXECUTOR.execute(cb::clearPendingBinds);
            }
            LoaderResults loaderResults = new LoaderResults(mApp, mBgDataModel, mBgAllAppsList, callbacksList);
            if (bindDirectly) {
                // Divide the set of loaded items into those that we are binding synchronously,
                // and everything else that is to be bound normally (asynchronously).
                loaderResults.bindWorkspace(bindAllCallbacks);
                // For now, continue posting the binding of AllApps as there are other
                // issues that arise from that.
                loaderResults.bindAllApps();
                loaderResults.bindDeepShortcuts();
                loaderResults.bindWidgets();
                return true;
            } else {
                stopLoader();
                mLoaderTask = new LoaderTask(mApp, mBgAllAppsList, mBgDataModel, mModelDelegate, loaderResults);
                // Always post the loader task, instead of running directly
                // (even on same thread) so that we exit any nested synchronized blocks
                MODEL_EXECUTOR.post(mLoaderTask);
            }
        }
    }
    return false;
}
Also used : Callbacks(com.android.launcher3.model.BgDataModel.Callbacks) LoaderTask(com.android.launcher3.model.LoaderTask) LoaderResults(com.android.launcher3.model.LoaderResults)

Example 10 with EXIT

use of com.android.launcher3.util.RaceConditionTracker.EXIT in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WidgetsDiffReporter method process.

/**
 * Notifies the difference between {@code currentEntries} & {@code newEntries} by calling the
 * relevant {@link androidx.recyclerview.widget.RecyclerView.RecyclerViewDataObserver} methods.
 */
public void process(ArrayList<WidgetsListBaseEntry> currentEntries, List<WidgetsListBaseEntry> newEntries, WidgetListBaseRowEntryComparator comparator) {
    if (DEBUG) {
        Log.d(TAG, "process oldEntries#=" + currentEntries.size() + " newEntries#=" + newEntries.size());
    }
    // Early exit if either of the list is empty
    if (currentEntries.isEmpty() || newEntries.isEmpty()) {
        // when the bind actually completes.
        if (currentEntries.size() != newEntries.size()) {
            currentEntries.clear();
            currentEntries.addAll(newEntries);
            mListener.notifyDataSetChanged();
        }
        return;
    }
    ArrayList<WidgetsListBaseEntry> orgEntries = (ArrayList<WidgetsListBaseEntry>) currentEntries.clone();
    Iterator<WidgetsListBaseEntry> orgIter = orgEntries.iterator();
    Iterator<WidgetsListBaseEntry> newIter = newEntries.iterator();
    WidgetsListBaseEntry orgRowEntry = orgIter.next();
    WidgetsListBaseEntry newRowEntry = newIter.next();
    do {
        int diff = compareAppNameAndType(orgRowEntry, newRowEntry, comparator);
        if (DEBUG) {
            Log.d(TAG, String.format("diff=%d orgRowEntry (%s) newRowEntry (%s)", diff, orgRowEntry != null ? orgRowEntry.toString() : null, newRowEntry != null ? newRowEntry.toString() : null));
        }
        int index = -1;
        if (diff < 0) {
            index = currentEntries.indexOf(orgRowEntry);
            mListener.notifyItemRemoved(index);
            if (DEBUG) {
                Log.d(TAG, String.format("notifyItemRemoved called (%d)%s", index, orgRowEntry.mTitleSectionName));
            }
            currentEntries.remove(index);
            orgRowEntry = orgIter.hasNext() ? orgIter.next() : null;
        } else if (diff > 0) {
            index = orgRowEntry != null ? currentEntries.indexOf(orgRowEntry) : currentEntries.size();
            currentEntries.add(index, newRowEntry);
            if (DEBUG) {
                Log.d(TAG, String.format("notifyItemInserted called (%d)%s", index, newRowEntry.mTitleSectionName));
            }
            newRowEntry = newIter.hasNext() ? newIter.next() : null;
            mListener.notifyItemInserted(index);
        } else {
            // or did the widget size and desc, span, etc change?
            if (!isSamePackageItemInfo(orgRowEntry.mPkgItem, newRowEntry.mPkgItem) || hasHeaderUpdated(orgRowEntry, newRowEntry) || hasWidgetsListContentChanged(orgRowEntry, newRowEntry)) {
                index = currentEntries.indexOf(orgRowEntry);
                currentEntries.set(index, newRowEntry);
                mListener.notifyItemChanged(index);
                if (DEBUG) {
                    Log.d(TAG, String.format("notifyItemChanged called (%d)%s", index, newRowEntry.mTitleSectionName));
                }
            }
            orgRowEntry = orgIter.hasNext() ? orgIter.next() : null;
            newRowEntry = newIter.hasNext() ? newIter.next() : null;
        }
    } while (orgRowEntry != null || newRowEntry != null);
}
Also used : WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) ArrayList(java.util.ArrayList)

Aggregations

Point (android.graphics.Point)11 Animator (android.animation.Animator)9 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)9 ValueAnimator (android.animation.ValueAnimator)9 ObjectAnimator (android.animation.ObjectAnimator)8 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)8 Paint (android.graphics.Paint)8 SuppressLint (android.annotation.SuppressLint)7 LoaderTask (com.android.launcher3.model.LoaderTask)7 Callbacks (com.android.launcher3.model.BgDataModel.Callbacks)6 GridOccupancy (com.android.launcher3.util.GridOccupancy)6 ArrayList (java.util.ArrayList)6 LoaderResults (com.android.launcher3.model.LoaderResults)5 ItemInfo (com.android.launcher3.model.data.ItemInfo)5 WidgetsListBaseEntry (com.android.launcher3.widget.model.WidgetsListBaseEntry)5 Rect (android.graphics.Rect)3 Resources (android.content.res.Resources)2 DropTarget (com.android.launcher3.DropTarget)2 AnimatorSet (android.animation.AnimatorSet)1 TargetApi (android.annotation.TargetApi)1