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;
QueryBuilder<ProfileSwitch, Long> queryBuilder = daoProfileSwitch.queryBuilder();
queryBuilder.orderBy("date", ascending);
queryBuilder.limit(20L);
queryBuilder.limit(100L);
PreparedQuery<ProfileSwitch> preparedQuery = queryBuilder.prepare();
profileSwitches = daoProfileSwitch.query(preparedQuery);
return profileSwitches;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return new ArrayList<ProfileSwitch>();
return new ArrayList<>();
}
public boolean createOrUpdate(ProfileSwitch profileSwitch) {

View file

@ -20,11 +20,12 @@ import android.widget.TextView;
import com.squareup.otto.Subscribe;
import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileIntervals;
import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.events.EventProfileSwitchChange;
@ -49,9 +50,9 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
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;
}
@ -65,7 +66,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
public void onBindViewHolder(ProfileSwitchViewHolder holder, int position) {
Profile profile = MainApp.getConfigBuilder().getProfile();
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.ns.setVisibility(NSUpload.isIdValid(profileSwitch._id) ? View.VISIBLE : View.GONE);
@ -168,7 +169,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
llm = new LinearLayoutManager(view.getContext());
recyclerView.setLayoutManager(llm);
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getProfileSwitchesFromHistory());
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getDbHelper().getProfileSwitchData(false));
recyclerView.setAdapter(adapter);
refreshFromNS = (Button) view.findViewById(R.id.profileswitch_refreshfromnightscout);
@ -216,7 +217,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
activity.runOnUiThread(new Runnable() {
@Override
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
android:id="@+id/invalid_sign"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingEnd="10dp"
android:text="@string/invalid"
android:textAlignment="viewEnd"
android:textColor="@android:color/holo_red_light" />
<TextView