BolusProgress code cleanup
This commit is contained in:
parent
32ff72b620
commit
b0eecac00e
3 changed files with 17 additions and 28 deletions
|
@ -290,22 +290,6 @@ public class MainApp extends Application {
|
|||
KeepAliveReceiver.cancelAlarm(this);
|
||||
}
|
||||
|
||||
public static void subscribe(Object subscriber) {
|
||||
try {
|
||||
bus().register(subscriber);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// already registered
|
||||
}
|
||||
}
|
||||
|
||||
public static void unsubscribe(Object subscriber) {
|
||||
try {
|
||||
bus().unregister(subscriber);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// already unregistered
|
||||
}
|
||||
}
|
||||
|
||||
public static Bus bus() {
|
||||
return sBus;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
|||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -13,6 +11,9 @@ import android.widget.Button;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -86,11 +87,15 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
} else {
|
||||
if (getDialog() != null)
|
||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
MainApp.subscribe(this);
|
||||
running = true;
|
||||
if (L.isEnabled(L.UI))
|
||||
log.debug("onResume running");
|
||||
}
|
||||
try {
|
||||
MainApp.bus().register(this);
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.error("Already registered");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,11 +117,15 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
|
||||
@Override
|
||||
public void onPause() {
|
||||
running = false;
|
||||
super.onPause();
|
||||
MainApp.unsubscribe(this);
|
||||
if (L.isEnabled(L.UI))
|
||||
log.debug("onPause");
|
||||
running = false;
|
||||
super.onPause();
|
||||
try {
|
||||
MainApp.bus().unregister(this);
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.error("Already unregistered");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -196,9 +205,6 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
log.error("Unhandled exception", e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (L.isEnabled(L.UI))
|
||||
log.debug("activity == null");
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
|
|
|
@ -15,10 +15,9 @@ public class BolusProgressHelperActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.getIntent().getDoubleExtra("insulin", 0d);
|
||||
BolusProgressDialog bolusProgressDialog = new BolusProgressDialog();
|
||||
bolusProgressDialog.setHelperActivity(this);
|
||||
bolusProgressDialog.setInsulin(this.getIntent().getDoubleExtra("insulin", 0d));
|
||||
bolusProgressDialog.show(this.getSupportFragmentManager(), "BolusProgress");
|
||||
bolusProgressDialog.setInsulin(getIntent().getDoubleExtra("insulin", 0d));
|
||||
bolusProgressDialog.show(getSupportFragmentManager(), "BolusProgress");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue