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

I modified the calculateActiveItem method and the calculateMostVisibleItem method. #109

Open
JakePrim opened this issue Nov 19, 2019 · 0 comments

Comments

@JakePrim
Copy link

I modified the calculateActiveItem method and the calculateMostVisibleItem method.
I think the call to the deactivate method should destroy the previous call to the deactivate method on the next display, which is more logical.

` private void calculateActiveItem(ItemsPositionGetter itemsPositionGetter, ListItemData listItemData) {
/** 1. */
int currentItemVisibilityPercents = listItemData.getVisibilityPercents(mListItems);
if (SHOW_LOGS) Logger.v(TAG, "calculateActiveItem, mScrollDirection " + mScrollDirection);

    /** 2. */
    ListItemData neighbourItemData = new ListItemData();
    switch (mScrollDirection) {
        case UP:
            findPreviousItem(itemsPositionGetter, listItemData, neighbourItemData);
            break;
        case DOWN:
            findNextItem(itemsPositionGetter, listItemData, neighbourItemData);
            break;
    }
    if (SHOW_LOGS)
        Logger.v(TAG, "calculateActiveItem, currentItemVisibilityPercents " + currentItemVisibilityPercents);

    /** 3. */
    if (enoughPercentsForDeactivation(currentItemVisibilityPercents) && neighbourItemData.isAvailable()) {

        // neighbour item become active (current)
        if (mOldItem == null) {
            mOldItem = mCurrentItem;
        } else {
            mCallback.deactivateCurrentItem(mListItems.get(mOldItem.getIndex()), mOldItem.getView(), mOldItem.getIndex());
            mOldItem = mCurrentItem;
        }
        /** 4. */
        setCurrentItem(neighbourItemData);
    } else {
        calculateMostVisibleItem(itemsPositionGetter, itemsPositionGetter.getFirstVisiblePosition(),
                itemsPositionGetter.getLastVisiblePosition());
    }
}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant