Skip to content

Commit

Permalink
fix(android): guard scroll event section data (#12434)
Browse files Browse the repository at this point in the history
Fixes TIMOB-28330
  • Loading branch information
build authored Feb 2, 2021
1 parent 1d1f174 commit a92bea2
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiUIHelper;

import android.app.Activity;
Expand Down Expand Up @@ -260,12 +261,20 @@ public KrollDict generateScrollPayload()
payload.put(TiC.PROPERTY_FIRST_VISIBLE_ITEM_INDEX, firstVisibleItemIndex);

// Obtain first visible section proxy.
final ListSectionProxy firstVisibleSection = (ListSectionProxy) firstVisibleProxy.getParent();
payload.put(TiC.PROPERTY_FIRST_VISIBLE_SECTION, firstVisibleSection);

// Obtain first visible section index.
final int firstVisibleSectionIndex = proxy.getIndexOfSection(firstVisibleSection);
payload.put(TiC.PROPERTY_FIRST_VISIBLE_SECTION_INDEX, firstVisibleSectionIndex);
final TiViewProxy firstVisibleParentProxy = firstVisibleProxy.getParent();
if (firstVisibleParentProxy instanceof ListSectionProxy) {
final ListSectionProxy firstVisibleSection = (ListSectionProxy) firstVisibleParentProxy;
payload.put(TiC.PROPERTY_FIRST_VISIBLE_SECTION, firstVisibleSection);

// Obtain first visible section index.
final int firstVisibleSectionIndex = proxy.getIndexOfSection(firstVisibleSection);
payload.put(TiC.PROPERTY_FIRST_VISIBLE_SECTION_INDEX, firstVisibleSectionIndex);
} else {

// Could not obtain section, mark as undefined.
payload.put(TiC.PROPERTY_FIRST_VISIBLE_SECTION, null);
payload.put(TiC.PROPERTY_FIRST_VISIBLE_SECTION_INDEX, -1);
}
}

// Define visible item count.
Expand Down

0 comments on commit a92bea2

Please sign in to comment.