CPP working

This commit is contained in:
AdrianLxM 2016-11-14 03:22:11 +01:00
parent 85b052efda
commit 74ea6c4011
3 changed files with 42 additions and 13 deletions

View file

@ -1,14 +1,10 @@
package info.nightscout.androidaps.plugins.CircadianPercentageProfile;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.media.Image;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
@ -25,7 +21,6 @@ import android.widget.TextView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Text;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase;
@ -291,6 +286,28 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
}
getDialog().setCancelable(true);
view.findViewById(R.id.ok_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
for (int i = 0; i < 24; i++) {
if (editTexts[i].getText().length()!= 0){
values[i]= SafeParse.stringToDouble(editTexts[i].getText().toString()) ;
}
}
updateProfileInfo();
getPlugin().storeSettings();
dismiss();
}
});
view.findViewById(R.id.cancel_action).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
return view;
}

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.CircadianPercentageProfile;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.StringBuilderPrinter;
import org.json.JSONArray;
import org.json.JSONException;
@ -41,8 +40,8 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
int percentage;
int timeshift;
double[] basebasal = new double[]{1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d, 1d};
double[] baseisf = new double[]{35d, 35d, 35d, 35.1d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d};
double[] baseic = new double[]{4d, 4d, 4d, 4d, 4.1d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d};
double[] baseisf = new double[]{35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d, 35d};
double[] baseic = new double[]{4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d, 4d};
public CircadianPercentageProfilePlugin() {
loadSettings();
@ -203,8 +202,21 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
JSONObject store = new JSONObject();
JSONObject profile = new JSONObject();
StringBuilder stringBuilder = new StringBuilder();
double sum = 0d;
for (int i = 0; i < 24; i++) {
sum += basebasal[i];
}
stringBuilder.append(DecimalFormatter.to2Decimal(sum));
stringBuilder.append("U@");
stringBuilder.append(percentage);
stringBuilder.append("%>");
stringBuilder.append(timeshift);
stringBuilder.append("h");
String profileName = stringBuilder.toString();
try {
json.put("defaultProfile", "CircadianPercentage");
json.put("defaultProfile", profileName);
json.put("store", store);
profile.put("dia", dia);
@ -234,11 +246,11 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
profile.put("target_low", new JSONArray().put(new JSONObject().put("timeAsSeconds", 0).put("value", targetLow)));
profile.put("target_high", new JSONArray().put(new JSONObject().put("timeAsSeconds", 0).put("value", targetHigh)));
profile.put("units", mgdl ? Constants.MGDL : Constants.MMOL);
store.put("CircadianPercentage", profile);
store.put(profileName, profile);
} catch (JSONException e) {
e.printStackTrace();
}
convertedProfile = new NSProfile(json, "CircadianPercentage");
convertedProfile = new NSProfile(json, profileName);
}
@Override

View file

@ -41,7 +41,7 @@
android:layout_gravity="center_horizontal">
<Button
android:id="@+id/fill_preset_button2"
android:id="@+id/cancel_action"
style="?android:attr/buttonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -50,7 +50,7 @@
android:text="CANCEL"
android:textSize="20sp" />
<Button
android:id="@+id/fill_preset_button3"
android:id="@+id/ok_button"
style="?android:attr/buttonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"