Refresh data only when needed

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-01-24 13:49:10 +01:00
parent b14999fdec
commit dc0064ee13
4 changed files with 8 additions and 5 deletions

View File

@ -385,7 +385,7 @@ public class CallsListController extends BaseController implements SearchView.On
if (!bottomSheetLockEvent.isCancel()) { if (!bottomSheetLockEvent.isCancel()) {
bottomSheet.setCancelable(bottomSheetLockEvent.isCancel()); bottomSheet.setCancelable(bottomSheetLockEvent.isCancel());
} else { } else {
if (bottomSheetLockEvent.getDelay() != 0) { if (bottomSheetLockEvent.getDelay() != 0 && bottomSheetLockEvent.isShouldRefreshData()) {
fetchData(true); fetchData(true);
} else { } else {
bottomSheet.setCancelable(true); bottomSheet.setCancelable(true);

View File

@ -143,7 +143,7 @@ public class CallMenuController extends BaseController implements FlexibleAdapte
if (menuItem != null) { if (menuItem != null) {
int tag = menuItem.getTag(); int tag = menuItem.getTag();
if (tag > 0 && tag < 9) { if (tag > 0 && tag < 9) {
eventBus.post(new BottomSheetLockEvent(false, 0)); eventBus.post(new BottomSheetLockEvent(false, 0, false));
bundle.putInt(BundleKeys.KEY_OPERATION_CODE, tag); bundle.putInt(BundleKeys.KEY_OPERATION_CODE, tag);
if (tag != 6 && tag != 2) { if (tag != 6 && tag != 2) {
getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle))); getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle)));

View File

@ -182,11 +182,12 @@ public class OperationsMenuController extends BaseController {
resultsTextView.setText(R.string.nc_failed_to_perform_operation); resultsTextView.setText(R.string.nc_failed_to_perform_operation);
} }
boolean shouldRefreshData = operationCode != 4 && operationCode != 5;
resultsTextView.setVisibility(View.VISIBLE); resultsTextView.setVisibility(View.VISIBLE);
if (everythingOK) { if (everythingOK) {
eventBus.post(new BottomSheetLockEvent(true, 2500)); eventBus.post(new BottomSheetLockEvent(true, 2500, shouldRefreshData));
} else { } else {
okButton.setOnClickListener(v -> eventBus.post(new BottomSheetLockEvent(true, 0))); okButton.setOnClickListener(v -> eventBus.post(new BottomSheetLockEvent(true, 0, shouldRefreshData)));
okButton.setVisibility(View.VISIBLE); okButton.setVisibility(View.VISIBLE);
} }
} }

View File

@ -26,9 +26,11 @@ import lombok.Data;
public class BottomSheetLockEvent { public class BottomSheetLockEvent {
private final boolean cancel; private final boolean cancel;
private final int delay; private final int delay;
private final boolean shouldRefreshData;
public BottomSheetLockEvent(boolean cancel, int delay) { public BottomSheetLockEvent(boolean cancel, int delay, boolean shouldRefreshData) {
this.cancel = cancel; this.cancel = cancel;
this.delay = delay; this.delay = delay;
this.shouldRefreshData = shouldRefreshData;
} }
} }