private static final String KEY_INDEXES = "INDEXES";
private static final String KEY_FIRST_POSITIONS= "FIRST_POSITIONS";
private static final String KEY_TOPS = "TOPS";
+ private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL";
private OCFileListFragment.ContainerActivity mContainerActivity;
private Handler mHandler;
private OCFile mTargetFile;
+ // Save the state of the scroll in browsing
private ArrayList<Integer> mIndexes;
private ArrayList<Integer> mFirstPositions;
private ArrayList<Integer> mTops;
+ private int mHeightCell = 0;
/**
* {@inheritDoc}
mIndexes = savedInstanceState.getIntegerArrayList(KEY_INDEXES);
mFirstPositions = savedInstanceState.getIntegerArrayList(KEY_FIRST_POSITIONS);
mTops = savedInstanceState.getIntegerArrayList(KEY_TOPS);
+ mHeightCell = savedInstanceState.getInt(KEY_HEIGHT_CELL);
} else {
mIndexes = new ArrayList<Integer>();
mFirstPositions = new ArrayList<Integer>();
mTops = new ArrayList<Integer>();
+ mHeightCell = 0;
}
outState.putIntegerArrayList(KEY_INDEXES, mIndexes);
outState.putIntegerArrayList(KEY_FIRST_POSITIONS, mFirstPositions);
outState.putIntegerArrayList(KEY_TOPS, mTops);
+ outState.putInt(KEY_HEIGHT_CELL, mHeightCell);
}
/**
mList.setSelectionFromTop(firstPosition, top);
// Move the scroll if the selection is not visible
- View view = mList.getChildAt(0);
- int indexPosition = view.getHeight()*index;
+ int indexPosition = mHeightCell*index;
int height = mList.getHeight();
if (indexPosition > height) {
int top = (view == null) ? 0 : view.getTop() ;
mTops.add(top);
+
+ // Save the height of a cell
+ mHeightCell = (view == null || mHeightCell != 0) ? mHeightCell : view.getHeight();
}
@Override