Remove Sync button from DanaRHistoryActivity

This commit is contained in:
Milos Kozak 2019-08-13 08:16:46 +02:00
parent 899c801822
commit d8795f4d80
2 changed files with 24 additions and 62 deletions

View file

@ -1,12 +1,6 @@
package info.nightscout.androidaps.plugins.pump.danaR.activities; package info.nightscout.androidaps.plugins.pump.danaR.activities;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -16,6 +10,11 @@ import android.widget.Button;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -47,14 +46,11 @@ import info.nightscout.androidaps.utils.ToastUtils;
public class DanaRHistoryActivity extends NoSplashActivity { public class DanaRHistoryActivity extends NoSplashActivity {
private static Logger log = LoggerFactory.getLogger(L.PUMP); private static Logger log = LoggerFactory.getLogger(L.PUMP);
private Handler mHandler;
static Profile profile = null; static Profile profile = null;
Spinner historyTypeSpinner; Spinner historyTypeSpinner;
TextView statusView; TextView statusView;
Button reloadButton; Button reloadButton;
Button syncButton;
RecyclerView recyclerView; RecyclerView recyclerView;
LinearLayoutManager llm; LinearLayoutManager llm;
@ -70,6 +66,7 @@ public class DanaRHistoryActivity extends NoSplashActivity {
this.name = name; this.name = name;
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return name; return name;
@ -78,9 +75,6 @@ public class DanaRHistoryActivity extends NoSplashActivity {
public DanaRHistoryActivity() { public DanaRHistoryActivity() {
super(); super();
HandlerThread mHandlerThread = new HandlerThread(DanaRHistoryActivity.class.getSimpleName());
mHandlerThread.start();
this.mHandler = new Handler(mHandlerThread.getLooper());
} }
@ -101,11 +95,10 @@ public class DanaRHistoryActivity extends NoSplashActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.danar_historyactivity); setContentView(R.layout.danar_historyactivity);
historyTypeSpinner = (Spinner) findViewById(R.id.danar_historytype); historyTypeSpinner = findViewById(R.id.danar_historytype);
statusView = (TextView) findViewById(R.id.danar_historystatus); statusView = findViewById(R.id.danar_historystatus);
reloadButton = (Button) findViewById(R.id.danar_historyreload); reloadButton = findViewById(R.id.danar_historyreload);
syncButton = (Button) findViewById(R.id.danar_historysync); recyclerView = findViewById(R.id.danar_history_recyclerview);
recyclerView = (RecyclerView) findViewById(R.id.danar_history_recyclerview);
recyclerView.setHasFixedSize(true); recyclerView.setHasFixedSize(true);
llm = new LinearLayoutManager(this); llm = new LinearLayoutManager(this);
@ -145,7 +138,6 @@ public class DanaRHistoryActivity extends NoSplashActivity {
final TypeList selected = (TypeList) historyTypeSpinner.getSelectedItem(); final TypeList selected = (TypeList) historyTypeSpinner.getSelectedItem();
runOnUiThread(() -> { runOnUiThread(() -> {
reloadButton.setVisibility(View.GONE); reloadButton.setVisibility(View.GONE);
syncButton.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE); statusView.setVisibility(View.VISIBLE);
}); });
clearCardView(); clearCardView();
@ -155,37 +147,12 @@ public class DanaRHistoryActivity extends NoSplashActivity {
loadDataFromDB(selected.type); loadDataFromDB(selected.type);
runOnUiThread(() -> { runOnUiThread(() -> {
reloadButton.setVisibility(View.VISIBLE); reloadButton.setVisibility(View.VISIBLE);
syncButton.setVisibility(View.VISIBLE);
statusView.setVisibility(View.GONE); statusView.setVisibility(View.GONE);
}); });
} }
}); });
}); });
syncButton.setOnClickListener(v -> mHandler.post(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
reloadButton.setVisibility(View.GONE);
syncButton.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE);
}
});
DanaRNSHistorySync sync = new DanaRNSHistorySync(historyList);
sync.sync(DanaRNSHistorySync.SYNC_ALL);
runOnUiThread(new Runnable() {
@Override
public void run() {
reloadButton.setVisibility(View.VISIBLE);
syncButton.setVisibility(View.VISIBLE);
statusView.setVisibility(View.GONE);
}
});
}
}));
historyTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { historyTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
@ -214,14 +181,15 @@ public class DanaRHistoryActivity extends NoSplashActivity {
this.historyList = historyList; this.historyList = historyList;
} }
@NonNull
@Override @Override
public HistoryViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { public HistoryViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.danar_history_item, viewGroup, false); View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.danar_history_item, viewGroup, false);
return new HistoryViewHolder(v); return new HistoryViewHolder(v);
} }
@Override @Override
public void onBindViewHolder(HistoryViewHolder holder, int position) { public void onBindViewHolder(@NonNull HistoryViewHolder holder, int position) {
DanaRHistoryRecord record = historyList.get(position); DanaRHistoryRecord record = historyList.get(position);
holder.time.setText(DateUtil.dateAndTimeString(record.recordDate)); holder.time.setText(DateUtil.dateAndTimeString(record.recordDate));
holder.value.setText(DecimalFormatter.to2Decimal(record.recordValue)); holder.value.setText(DecimalFormatter.to2Decimal(record.recordValue));
@ -306,7 +274,7 @@ public class DanaRHistoryActivity extends NoSplashActivity {
} }
@Override @Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) { public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView); super.onAttachedToRecyclerView(recyclerView);
} }
@ -324,16 +292,16 @@ public class DanaRHistoryActivity extends NoSplashActivity {
HistoryViewHolder(View itemView) { HistoryViewHolder(View itemView) {
super(itemView); super(itemView);
cv = (CardView) itemView.findViewById(R.id.danar_history_cardview); cv = itemView.findViewById(R.id.danar_history_cardview);
time = (TextView) itemView.findViewById(R.id.danar_history_time); time = itemView.findViewById(R.id.danar_history_time);
value = (TextView) itemView.findViewById(R.id.danar_history_value); value = itemView.findViewById(R.id.danar_history_value);
bolustype = (TextView) itemView.findViewById(R.id.danar_history_bolustype); bolustype = itemView.findViewById(R.id.danar_history_bolustype);
stringvalue = (TextView) itemView.findViewById(R.id.danar_history_stringvalue); stringvalue = itemView.findViewById(R.id.danar_history_stringvalue);
duration = (TextView) itemView.findViewById(R.id.danar_history_duration); duration = itemView.findViewById(R.id.danar_history_duration);
dailybasal = (TextView) itemView.findViewById(R.id.danar_history_dailybasal); dailybasal = itemView.findViewById(R.id.danar_history_dailybasal);
dailybolus = (TextView) itemView.findViewById(R.id.danar_history_dailybolus); dailybolus = itemView.findViewById(R.id.danar_history_dailybolus);
dailytotal = (TextView) itemView.findViewById(R.id.danar_history_dailytotal); dailytotal = itemView.findViewById(R.id.danar_history_dailytotal);
alarm = (TextView) itemView.findViewById(R.id.danar_history_alarm); alarm = itemView.findViewById(R.id.danar_history_alarm);
} }
} }
} }

View file

@ -71,12 +71,6 @@
android:layout_weight="1" android:layout_weight="1"
android:text="@string/danar_historyreload" /> android:text="@string/danar_historyreload" />
<Button
android:id="@+id/danar_historysync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Sync to NS" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>