正在查看: xDrip+ v04633772025.07.16 应用的 InsulinProfileEditor.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: xDrip+ v04633772025.07.16 应用的 InsulinProfileEditor.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.eveningoutpost.dexdrip.insulin;
import android.R;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import com.eveningoutpost.dexdrip.BaseAppCompatActivity;
import com.eveningoutpost.dexdrip.models.JoH;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
public class InsulinProfileEditor extends BaseAppCompatActivity {
private Spinner basalSpinner;
private Spinner bolusSpinner;
private Button cancelBtn;
private HashMap<Insulin, CheckBox> checkboxes;
private LinearLayout linearLayout;
private HashMap<String, Insulin> profiles;
private Button saveBtn;
private Button undoBtn;
@Override
protected void onCreate(Bundle bundle) {
int i;
super.onCreate(bundle);
setContentView(2131492920);
this.checkboxes = new HashMap<>();
this.profiles = new HashMap<>();
this.undoBtn = (Button) findViewById(2131296856);
this.saveBtn = (Button) findViewById(2131296852);
this.cancelBtn = (Button) findViewById(2131296850);
this.linearLayout = (LinearLayout) findViewById(2131296857);
this.basalSpinner = (Spinner) findViewById(2131296387);
this.bolusSpinner = (Spinner) findViewById(2131296399);
ArrayList<Insulin> allProfiles = InsulinManager.getAllProfiles();
if (allProfiles == null) {
JoH.static_toast_long("Can't initialize insulin profiles");
finish();
return;
}
Iterator<Insulin> it = allProfiles.iterator();
while (true) {
if (!it.hasNext()) {
break;
}
final Insulin next = it.next();
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(0);
final CheckBox checkBox = new CheckBox(this);
if (InsulinManager.isProfileEnabled(next).booleanValue()) {
checkBox.setChecked(true);
} else {
checkBox.setChecked(false);
}
checkBox.setText(next.getDisplayName());
checkBox.setTextSize(20.0f);
this.checkboxes.put(next, checkBox);
checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (InsulinManager.isProfileEnabled(next).booleanValue()) {
InsulinManager.disableProfile(next);
} else {
InsulinManager.enableProfile(next);
}
if (InsulinManager.isProfileEnabled(next).booleanValue()) {
checkBox.setChecked(true);
} else {
checkBox.setChecked(false);
}
}
});
linearLayout.addView(checkBox);
this.linearLayout.addView(linearLayout);
this.profiles.put(next.getDisplayName(), next);
}
ArrayList arrayList = new ArrayList(this.profiles.keySet());
ArrayAdapter arrayAdapter = new ArrayAdapter(this, R.layout.simple_spinner_item, arrayList);
arrayAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
this.basalSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i2, long j) {
InsulinManager.setBasalProfile((Insulin) InsulinProfileEditor.this.profiles.get(adapterView.getItemAtPosition(i2)));
}
});
this.basalSpinner.setAdapter((SpinnerAdapter) arrayAdapter);
this.bolusSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i2, long j) {
InsulinManager.setBolusProfile((Insulin) InsulinProfileEditor.this.profiles.get(adapterView.getItemAtPosition(i2)));
}
});
this.bolusSpinner.setAdapter((SpinnerAdapter) arrayAdapter);
String displayName = InsulinManager.getBasalProfile().getDisplayName();
String displayName2 = InsulinManager.getBolusProfile().getDisplayName();
for (i = 0; i < arrayList.size(); i++) {
if (((String) arrayList.get(i)).equals(displayName)) {
this.basalSpinner.setSelection(i);
}
if (((String) arrayList.get(i)).equals(displayName2)) {
this.bolusSpinner.setSelection(i);
}
}
}
@Override
public void onPause() {
super.onPause();
}
public void profileCancelButton(View view) {
InsulinManager.LoadDisabledProfilesFromPrefs();
finish();
}
public void profileSaveButton(View view) {
InsulinManager.saveDisabledProfilesToPrefs();
finish();
}
public void profileUndoButton(View view) {
int i;
InsulinManager.LoadDisabledProfilesFromPrefs();
Iterator<Insulin> it = InsulinManager.getAllProfiles().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
Insulin next = it.next();
if (InsulinManager.isProfileEnabled(next).booleanValue()) {
this.checkboxes.get(next).setChecked(true);
} else {
this.checkboxes.get(next).setChecked(false);
}
}
ArrayList arrayList = new ArrayList(this.profiles.keySet());
String displayName = InsulinManager.getBasalProfile().getDisplayName();
String displayName2 = InsulinManager.getBolusProfile().getDisplayName();
for (i = 0; i < arrayList.size(); i++) {
if (((String) arrayList.get(i)).equals(displayName)) {
this.basalSpinner.setSelection(i);
}
if (((String) arrayList.get(i)).equals(displayName2)) {
this.bolusSpinner.setSelection(i);
}
}
}
}