package com.rthoni.camotion.ui.fragments; import com.luticate.utils.business.LuPromise; import com.luticate.utils.dbo.LuMultipleDbo; import com.rthoni.camotion.business.CommandsBusiness; import com.rthoni.camotion.dbo.CommandDbo; import com.rthoni.camotion.ui.views.CommandView; /** * * Created by robin on 11/29/15. */ public abstract class AbstractCommandsFragment extends CamotionFragment { @Override protected LuPromise> getLoadPagePromise(int page, int perPage, String query) { return CommandsBusiness.getAll(_currentLocation.getConfig(_fullLoginDbo.getLoginDbo()), page, perPage) .map(new LuPromise.LuConverter>() { @Override public LuMultipleDbo convert(CommandDbo.MultipleCommandDbo data) { return data; } }); } @Override protected CommandView getDboView(final CommandDbo command) { CommandView commandView = new CommandView(getActivity()); commandView.setCamotionDbo(_fullLoginDbo, _currentLocation); commandView.setCommand(command); commandView.setOnClickedListener(new LuPromise.LuConsumer() { @Override public void execute(CommandDbo command) { onCommandClicked(command); } }); return commandView; } protected abstract void onCommandClicked(CommandDbo command); }