Assigned ViewHolder ids to section views based on the section's hash code
This commit is contained in:
@@ -115,6 +115,16 @@ public abstract class SectionCursorAdapter<C extends CursorAdapter.AbstractCurso
|
|||||||
*/
|
*/
|
||||||
protected abstract T getSectionFromCursor(C cursor) throws IllegalStateException;
|
protected abstract T getSectionFromCursor(C cursor) throws IllegalStateException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the id of the item represented by the row the cursor
|
||||||
|
* is currently moved to.
|
||||||
|
* @param section The section item to get the id from
|
||||||
|
* @return The id of the dataset
|
||||||
|
*/
|
||||||
|
public long getIdFromSection(T section) {
|
||||||
|
return section != null ? section.hashCode() : 0L;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return super.getItemCount() + mSectionMap.size();
|
return super.getItemCount() + mSectionMap.size();
|
||||||
@@ -122,21 +132,13 @@ public abstract class SectionCursorAdapter<C extends CursorAdapter.AbstractCurso
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final long getItemId(int listPosition) {
|
public final long getItemId(int listPosition) {
|
||||||
/*
|
|
||||||
int index = mSectionMap.indexOfKey(listPosition);
|
int index = mSectionMap.indexOfKey(listPosition);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
int cursorPosition = getCursorPositionWithoutSections(listPosition);
|
int cursorPosition = getCursorPositionWithoutSections(listPosition);
|
||||||
return super.getItemId(cursorPosition);
|
return super.getItemId(cursorPosition);
|
||||||
} else {
|
} else {
|
||||||
T section = mSectionMap.valueAt(index);
|
T section = mSectionMap.valueAt(index);
|
||||||
return section != null ? section.hashCode() : 0L;
|
return getIdFromSection(section);
|
||||||
} */
|
|
||||||
|
|
||||||
if (isSection(listPosition)) {
|
|
||||||
return RecyclerView.NO_ID;
|
|
||||||
} else {
|
|
||||||
int cursorPosition = getCursorPositionWithoutSections(listPosition);
|
|
||||||
return super.getItemId(cursorPosition);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,10 +112,7 @@ public class FastScrollRecyclerView extends RecyclerView implements RecyclerView
|
|||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
stopScroll();
|
stopScroll();
|
||||||
|
|
||||||
|
|
||||||
int pixelsToScroll = (int) (computeVerticalScrollRange() * fraction);
|
int pixelsToScroll = (int) (computeVerticalScrollRange() * fraction);
|
||||||
System.out.println("ScrollBy Fraction: " + fraction + ", Pixel: " + pixelsToScroll);
|
|
||||||
|
|
||||||
scrollBy(0, pixelsToScroll);
|
scrollBy(0, pixelsToScroll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user