mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-21 16:34:23 +01:00
GLS race condition fixed
This commit is contained in:
@@ -24,6 +24,7 @@ package no.nordicsemi.android.nrftoolbox.gls;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -32,30 +33,38 @@ import android.widget.TextView;
|
||||
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
public class ExpandableRecordAdapter extends BaseExpandableListAdapter {
|
||||
public class ExpandableRecordAdapter extends BaseExpandableListAdapter {;
|
||||
private final GlucoseManager mGlucoseManager;
|
||||
private final LayoutInflater mInflater;
|
||||
private final Context mContext;
|
||||
private SparseArray<GlucoseRecord> mRecords;
|
||||
|
||||
public ExpandableRecordAdapter(final Context context, final GlucoseManager manager) {
|
||||
mGlucoseManager = manager;
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mRecords = manager.getRecords().clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyDataSetChanged() {
|
||||
mRecords = mGlucoseManager.getRecords().clone();
|
||||
super.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupCount() {
|
||||
return mGlucoseManager.getRecords().size();
|
||||
return mRecords.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGroup(int groupPosition) {
|
||||
return mGlucoseManager.getRecords().valueAt(groupPosition);
|
||||
public Object getGroup(final int groupPosition) {
|
||||
return mRecords.valueAt(groupPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGroupId(final int groupPosition) {
|
||||
return mGlucoseManager.getRecords().keyAt(groupPosition);
|
||||
return mRecords.keyAt(groupPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -140,11 +140,9 @@ public class GlucoseManager extends BatteryManager<GlucoseManagerCallbacks> {
|
||||
record.sampleLocation = sampleLocation != null ? sampleLocation : 0;
|
||||
record.status = status != null ? status.value : 0;
|
||||
|
||||
// data set modifications must be done in UI thread
|
||||
// insert the new record to storage
|
||||
mRecords.put(record.sequenceNumber, record);
|
||||
mHandler.post(() -> {
|
||||
// insert the new record to storage
|
||||
mRecords.put(record.sequenceNumber, record);
|
||||
|
||||
// if there is no context information following the measurement data,
|
||||
// notify callback about the new record
|
||||
if (!contextInformationFollows)
|
||||
|
||||
Reference in New Issue
Block a user