Restore the drag state with the sort mode
This commit is contained in:
parent
f41eb620aa
commit
cbdced2df1
1 changed files with 12 additions and 5 deletions
|
@ -149,9 +149,16 @@ public class MainActivity extends BaseActivity
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreSortMode(EntriesCardAdapter adapter) {
|
private void restoreSortMode() {
|
||||||
if (settings != null)
|
if (settings != null && adapter != null && touchHelperCallback != null) {
|
||||||
adapter.setSortMode(settings.getSortMode());
|
SortMode mode = settings.getSortMode();
|
||||||
|
adapter.setSortMode(mode);
|
||||||
|
|
||||||
|
if (mode == SortMode.LABEL)
|
||||||
|
touchHelperCallback.setDragEnabled(false);
|
||||||
|
else
|
||||||
|
touchHelperCallback.setDragEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveSortMode(SortMode mode) {
|
private void saveSortMode(SortMode mode) {
|
||||||
|
@ -219,12 +226,12 @@ public class MainActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
restoreSortMode(adapter);
|
|
||||||
|
|
||||||
touchHelperCallback = new SimpleItemTouchHelperCallback(adapter);
|
touchHelperCallback = new SimpleItemTouchHelperCallback(adapter);
|
||||||
ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback);
|
ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback);
|
||||||
touchHelper.attachToRecyclerView(recList);
|
touchHelper.attachToRecyclerView(recList);
|
||||||
|
|
||||||
|
restoreSortMode();
|
||||||
|
|
||||||
float durationScale = android.provider.Settings.Global.getFloat(this.getContentResolver(), android.provider.Settings.Global.ANIMATOR_DURATION_SCALE, 0);
|
float durationScale = android.provider.Settings.Global.getFloat(this.getContentResolver(), android.provider.Settings.Global.ANIMATOR_DURATION_SCALE, 0);
|
||||||
final long animatorDuration = (long) (1000 / durationScale);
|
final long animatorDuration = (long) (1000 / durationScale);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue