mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-18 03:39:00 +00:00
remove obsolete method, use lambda sytax
This commit is contained in:
parent
2f22ca06d2
commit
f94f0c4032
1 changed files with 7 additions and 26 deletions
|
|
@ -206,32 +206,13 @@ public class TasksFragment extends BaseMainFragment implements OnCheckedChangeLi
|
|||
public Fragment getItem(int position) {
|
||||
TaskRecyclerViewFragment fragment;
|
||||
SortableTasksRecyclerViewAdapter.SortTasksCallback sortCallback =
|
||||
new SortableTasksRecyclerViewAdapter.SortTasksCallback() {
|
||||
@Override
|
||||
public void onMove(Task task, int from, int to) {
|
||||
if (apiHelper != null){
|
||||
apiHelper.apiService.postTaskNewPosition(task.getId(), String.valueOf(toIndex(to)))
|
||||
.compose(apiHelper.configureApiCallObserver())
|
||||
.subscribe(aVoid -> {
|
||||
new HabitRPGUserCallback(activity);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private int toIndex(int to){
|
||||
int toIndex = 0;
|
||||
if (to > 0){
|
||||
boolean shouldBreak = false;
|
||||
for (toIndex = 0; toIndex<user.getTodos().size(); toIndex++){
|
||||
Task otherTask = user.getTodos().get(toIndex);
|
||||
if (!otherTask.getCompleted()){
|
||||
to--;
|
||||
if (shouldBreak) break;
|
||||
if (to == 0) shouldBreak = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return toIndex;
|
||||
(task, from, to) -> {
|
||||
if (apiHelper != null){
|
||||
apiHelper.apiService.postTaskNewPosition(task.getId(), String.valueOf(to))
|
||||
.compose(apiHelper.configureApiCallObserver())
|
||||
.subscribe(aVoid -> {
|
||||
new HabitRPGUserCallback(activity);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue