show invalid profiles in treatments tab

This commit is contained in:
Milos Kozak 2018-03-18 23:41:53 +01:00
parent 7f0918d147
commit 0266a79201
3 changed files with 12 additions and 10 deletions

View file

@ -1584,14 +1584,14 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
List<ProfileSwitch> profileSwitches; List<ProfileSwitch> profileSwitches;
QueryBuilder<ProfileSwitch, Long> queryBuilder = daoProfileSwitch.queryBuilder(); QueryBuilder<ProfileSwitch, Long> queryBuilder = daoProfileSwitch.queryBuilder();
queryBuilder.orderBy("date", ascending); queryBuilder.orderBy("date", ascending);
queryBuilder.limit(20L); queryBuilder.limit(100L);
PreparedQuery<ProfileSwitch> preparedQuery = queryBuilder.prepare(); PreparedQuery<ProfileSwitch> preparedQuery = queryBuilder.prepare();
profileSwitches = daoProfileSwitch.query(preparedQuery); profileSwitches = daoProfileSwitch.query(preparedQuery);
return profileSwitches; return profileSwitches;
} catch (SQLException e) { } catch (SQLException e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }
return new ArrayList<ProfileSwitch>(); return new ArrayList<>();
} }
public boolean createOrUpdate(ProfileSwitch profileSwitch) { public boolean createOrUpdate(ProfileSwitch profileSwitch) {

View file

@ -20,11 +20,12 @@ import android.widget.TextView;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import java.util.List;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileIntervals;
import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.events.EventProfileSwitchChange; import info.nightscout.androidaps.events.EventProfileSwitchChange;
@ -49,9 +50,9 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ProfileSwitchViewHolder> { public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ProfileSwitchViewHolder> {
ProfileIntervals<ProfileSwitch> profileSwitchList; List<ProfileSwitch> profileSwitchList;
RecyclerViewAdapter(ProfileIntervals<ProfileSwitch> profileSwitchList) { RecyclerViewAdapter(List<ProfileSwitch> profileSwitchList) {
this.profileSwitchList = profileSwitchList; this.profileSwitchList = profileSwitchList;
} }
@ -65,7 +66,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
public void onBindViewHolder(ProfileSwitchViewHolder holder, int position) { public void onBindViewHolder(ProfileSwitchViewHolder holder, int position) {
Profile profile = MainApp.getConfigBuilder().getProfile(); Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) return; if (profile == null) return;
ProfileSwitch profileSwitch = profileSwitchList.getReversed(position); ProfileSwitch profileSwitch = profileSwitchList.get(position);
holder.ph.setVisibility(profileSwitch.source == Source.PUMP ? View.VISIBLE : View.GONE); holder.ph.setVisibility(profileSwitch.source == Source.PUMP ? View.VISIBLE : View.GONE);
holder.ns.setVisibility(NSUpload.isIdValid(profileSwitch._id) ? View.VISIBLE : View.GONE); holder.ns.setVisibility(NSUpload.isIdValid(profileSwitch._id) ? View.VISIBLE : View.GONE);
@ -148,7 +149,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
break; break;
case R.id.profileswitch_date: case R.id.profileswitch_date:
case R.id.profileswitch_name: case R.id.profileswitch_name:
long time = ((ProfileSwitch)v.getTag()).date; long time = ((ProfileSwitch) v.getTag()).date;
ProfileViewerDialog pvd = ProfileViewerDialog.newInstance(time); ProfileViewerDialog pvd = ProfileViewerDialog.newInstance(time);
FragmentManager manager = getFragmentManager(); FragmentManager manager = getFragmentManager();
pvd.show(manager, "ProfileViewDialog"); pvd.show(manager, "ProfileViewDialog");
@ -168,7 +169,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
llm = new LinearLayoutManager(view.getContext()); llm = new LinearLayoutManager(view.getContext());
recyclerView.setLayoutManager(llm); recyclerView.setLayoutManager(llm);
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getProfileSwitchesFromHistory()); RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getDbHelper().getProfileSwitchData(false));
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
refreshFromNS = (Button) view.findViewById(R.id.profileswitch_refreshfromnightscout); refreshFromNS = (Button) view.findViewById(R.id.profileswitch_refreshfromnightscout);
@ -216,7 +217,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getProfileSwitchesFromHistory()), false); recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getDbHelper().getProfileSwitchData(false)), false);
} }
}); });
} }

View file

@ -64,10 +64,11 @@
<TextView <TextView
android:id="@+id/invalid_sign" android:id="@+id/invalid_sign"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingEnd="10dp" android:paddingEnd="10dp"
android:text="@string/invalid" android:text="@string/invalid"
android:textAlignment="viewEnd"
android:textColor="@android:color/holo_red_light" /> android:textColor="@android:color/holo_red_light" />
<TextView <TextView