be far less aggressive on restoring saved positions
This commit is contained in:
parent
a55f1c795c
commit
161b8855fb
@ -710,7 +710,6 @@ public class LibraryActivity
|
|||||||
.setMessage(delete_message)
|
.setMessage(delete_message)
|
||||||
.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
mPagerAdapter.maintainPosition(); // remember current scrolling position
|
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_DELETE, intent));
|
mHandler.sendMessage(mHandler.obtainMessage(MSG_DELETE, intent));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -443,6 +443,7 @@ public class LibraryPagerAdapter
|
|||||||
out.putSerializable("limiter_songs", mSongAdapter.getLimiter());
|
out.putSerializable("limiter_songs", mSongAdapter.getLimiter());
|
||||||
if (mFilesAdapter != null)
|
if (mFilesAdapter != null)
|
||||||
out.putSerializable("limiter_files", mFilesAdapter.getLimiter());
|
out.putSerializable("limiter_files", mFilesAdapter.getLimiter());
|
||||||
|
|
||||||
maintainPosition();
|
maintainPosition();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -588,7 +589,7 @@ public class LibraryPagerAdapter
|
|||||||
/**
|
/**
|
||||||
* Saves the scrolling position of every visible limiter
|
* Saves the scrolling position of every visible limiter
|
||||||
*/
|
*/
|
||||||
public void maintainPosition() {
|
private void maintainPosition() {
|
||||||
for (int i = MAX_ADAPTER_COUNT; --i != -1; ) {
|
for (int i = MAX_ADAPTER_COUNT; --i != -1; ) {
|
||||||
if (mAdapters[i] != null) {
|
if (mAdapters[i] != null) {
|
||||||
sLruAdapterPos.storePosition(mAdapters[i], mLists[i].getFirstVisiblePosition());
|
sLruAdapterPos.storePosition(mAdapters[i], mLists[i].getFirstVisiblePosition());
|
||||||
@ -646,15 +647,14 @@ public class LibraryPagerAdapter
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSG_COMMIT_QUERY: {
|
case MSG_COMMIT_QUERY: {
|
||||||
int pos = 0;
|
|
||||||
int index = message.arg1;
|
int index = message.arg1;
|
||||||
mAdapters[index].commitQuery(message.obj);
|
mAdapters[index].commitQuery(message.obj);
|
||||||
|
|
||||||
Integer curPos = sLruAdapterPos.getPosition(mAdapters[index]);
|
// Restore scrolling position if present and valid
|
||||||
|
Integer curPos = sLruAdapterPos.popPosition(mAdapters[index]);
|
||||||
if (curPos != null && curPos < mLists[index].getCount())
|
if (curPos != null && curPos < mLists[index].getCount())
|
||||||
pos = (int)curPos;
|
mLists[index].setSelection(curPos);
|
||||||
|
|
||||||
mLists[index].setSelection(pos);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSG_SAVE_SORT: {
|
case MSG_SAVE_SORT: {
|
||||||
@ -861,8 +861,8 @@ public class LibraryPagerAdapter
|
|||||||
public void storePosition(LibraryAdapter adapter, Integer val) {
|
public void storePosition(LibraryAdapter adapter, Integer val) {
|
||||||
this.put(_k(adapter), val);
|
this.put(_k(adapter), val);
|
||||||
}
|
}
|
||||||
public Integer getPosition(LibraryAdapter adapter) {
|
public Integer popPosition(LibraryAdapter adapter) {
|
||||||
return this.get(_k(adapter));
|
return this.remove(_k(adapter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user