Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#277: Change the order and remove tasks assigned to the plan #334

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mrwrob
Copy link
Contributor

@mrwrob mrwrob commented Jul 25, 2018

  • Changing order of the tasks assigned to the plan using drag-and-drop.
  • Removing tasks assignment to the plan, using both button and a swipe.

Resolves #277 #315

Copy link
Contributor

@malsolec malsolec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I was doing some testing I am getting random problems. It is something worth to look at.
First, when I had 2 items on list and they were duplicating each time I swapped it. And current state was saved, I was closing app going back and I was able to remove it item by item.
Then after I removed it, I started adding new items, I was able to add same items twice - what I think should be ok - and then when It happened, swapping worked on the list view, but when I go back to menu and open list again changes were not saved. It is random and strange so I will take a look at this later also.


@Override
public boolean onItemMove(int fromPosition, int toPosition) {
if (fromPosition < toPosition) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same code is in steps list. It would be good to extract it so some common component like. ItemOrderUpdater with method swapOrder(list, from, to)

@Inject
ToastUserNotifier toastUserNotifier;

PlanCreateTaskListRecyclerViewAdapter.TaskItemClickListener taskItemClickListener =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if that code could be extracted to separate class implementing this interface, only create instance here ( dependencies could be pass in constructor) or are there any Android limitations?

for(int i = 0; i < taskListAdapter.getItemCount(); i++){
PlanTaskTemplate planTaskItem = taskListAdapter.getPlanTaskTemplate(i);
if(i != planTaskItem.getOrder()) {
planTemplateRepository.removeTaskFromPlan(planId, planTaskItem.getId());
Copy link
Contributor

@malsolec malsolec Jul 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem could be here, why removing and creating new task, instead of updating the order? Ids will change. And the items in adapter's list have old ids still. I think it should be updating or setting new list to adapter should be added here.

planTemplateRepository.setTaskWithPlan(planId, planTaskItem.getTaskTemplateId(), i);
reordered = true;
}
if(!removedTask && reordered){
Copy link
Contributor

@malsolec malsolec Jul 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this if(line 66) was going to be after for loop to notify user once after all changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants