show status on Dana fragment too

This commit is contained in:
Milos Kozak 2017-10-13 13:31:32 +02:00
parent 02c57fb9a3
commit 3b90d02e05
2 changed files with 35 additions and 0 deletions

View file

@ -12,6 +12,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.crashlytics.android.Crashlytics; import com.crashlytics.android.Crashlytics;
@ -61,6 +62,9 @@ public class DanaRFragment extends SubscriberFragment {
Button historyButton; Button historyButton;
Button statsButton; Button statsButton;
LinearLayout pumpStatusLayout;
TextView pumpStatusView;
static Runnable connectRunnable = new Runnable() { static Runnable connectRunnable = new Runnable() {
@Override @Override
public void run() { public void run() {
@ -115,6 +119,9 @@ public class DanaRFragment extends SubscriberFragment {
bolusStepView = (TextView) view.findViewById(R.id.danar_bolusstep); bolusStepView = (TextView) view.findViewById(R.id.danar_bolusstep);
serialNumberView = (TextView) view.findViewById(R.id.danar_serialnumber); serialNumberView = (TextView) view.findViewById(R.id.danar_serialnumber);
pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus);
pumpStatusView.setBackgroundColor(MainApp.sResources.getColor(R.color.colorInitializingBorder));
pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout);
viewProfileButton.setOnClickListener(new View.OnClickListener() { viewProfileButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -159,6 +166,7 @@ public class DanaRFragment extends SubscriberFragment {
@Subscribe @Subscribe
public void onStatusEvent(final EventPumpStatusChanged c) { public void onStatusEvent(final EventPumpStatusChanged c) {
Activity activity = getActivity(); Activity activity = getActivity();
final String status = c.textStatus();
if (activity != null) { if (activity != null) {
activity.runOnUiThread( activity.runOnUiThread(
new Runnable() { new Runnable() {
@ -170,6 +178,13 @@ public class DanaRFragment extends SubscriberFragment {
btConnectionView.setText("{fa-bluetooth}"); btConnectionView.setText("{fa-bluetooth}");
else if (c.sStatus == EventPumpStatusChanged.DISCONNECTED) else if (c.sStatus == EventPumpStatusChanged.DISCONNECTED)
btConnectionView.setText("{fa-bluetooth-b}"); btConnectionView.setText("{fa-bluetooth-b}");
if (!status.equals("")) {
pumpStatusView.setText(status);
pumpStatusLayout.setVisibility(View.VISIBLE);
} else {
pumpStatusLayout.setVisibility(View.GONE);
}
} }
} }
); );

View file

@ -20,6 +20,26 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:id="@+id/overview_pumpstatuslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="2dp"
android:visibility="gone">
<TextView
android:id="@+id/overview_pumpstatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center_vertical|center_horizontal"
android:text="@string/initializing"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"