Fix activity fetching getting stuck when double tapping #333

master
cpfeiffer 2016-06-28 23:07:24 +02:00
parent 76dcb8f828
commit f0da25c49b
3 changed files with 7 additions and 3 deletions

View File

@ -102,8 +102,8 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
swipeLayout.setRefreshing(true);
} else {
boolean wasBusy = swipeLayout.isRefreshing();
swipeLayout.setRefreshing(false);
if (wasBusy) {
swipeLayout.setRefreshing(false);
LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(REFRESH));
}
}

View File

@ -105,8 +105,10 @@ public abstract class AbstractBTLEOperation<T extends AbstractBTLEDeviceSupport>
}
protected void unsetBusy() {
getDevice().unsetBusyTask();
getDevice().sendDeviceUpdateIntent(getContext());
if (getDevice().isBusy()) {
getDevice().unsetBusyTask();
getDevice().sendDeviceUpdateIntent(getContext());
}
}
public boolean isOperationRunning() {

View File

@ -18,6 +18,7 @@ public abstract class AbstractMiBandOperation extends AbstractBTLEOperation<MiBa
@Override
protected void prePerform() throws IOException {
super.prePerform();
getDevice().setBusyTask("fetch activity data"); // mark as busy quickly to avoid interruptions from the outside
TransactionBuilder builder = performInitialized("disabling some notifications");
enableOtherNotifications(builder, false);
builder.queue(getQueue());
@ -27,6 +28,7 @@ public abstract class AbstractMiBandOperation extends AbstractBTLEOperation<MiBa
protected void operationFinished() {
operationStatus = OperationStatus.FINISHED;
if (getDevice() != null && getDevice().isConnected()) {
unsetBusy();
try {
TransactionBuilder builder = performInitialized("reenabling disabled notifications");
enableOtherNotifications(builder, true);