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();
|
||||
}
|
||||
|
||||
private void restoreSortMode(EntriesCardAdapter adapter) {
|
||||
if (settings != null)
|
||||
adapter.setSortMode(settings.getSortMode());
|
||||
private void restoreSortMode() {
|
||||
if (settings != null && adapter != null && touchHelperCallback != null) {
|
||||
SortMode mode = settings.getSortMode();
|
||||
adapter.setSortMode(mode);
|
||||
|
||||
if (mode == SortMode.LABEL)
|
||||
touchHelperCallback.setDragEnabled(false);
|
||||
else
|
||||
touchHelperCallback.setDragEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveSortMode(SortMode mode) {
|
||||
|
@ -219,12 +226,12 @@ public class MainActivity extends BaseActivity
|
|||
}
|
||||
});
|
||||
|
||||
restoreSortMode(adapter);
|
||||
|
||||
touchHelperCallback = new SimpleItemTouchHelperCallback(adapter);
|
||||
ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback);
|
||||
touchHelper.attachToRecyclerView(recList);
|
||||
|
||||
restoreSortMode();
|
||||
|
||||
float durationScale = android.provider.Settings.Global.getFloat(this.getContentResolver(), android.provider.Settings.Global.ANIMATOR_DURATION_SCALE, 0);
|
||||
final long animatorDuration = (long) (1000 / durationScale);
|
||||
|
||||
|
|
Loading…
Reference in a new issue