导航菜单

页面标题

页面副标题

xDrip+ v04633772025.07.16 - NewSensorLocation.java 源代码

正在查看: xDrip+ v04633772025.07.16 应用的 NewSensorLocation.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.eveningoutpost.dexdrip;

import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import com.eveningoutpost.dexdrip.models.Sensor;
import com.eveningoutpost.dexdrip.utils.ActivityWithMenu;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class NewSensorLocation extends ActivityWithMenu {
    public static String menu_name = "New sensor location";
    CheckBox DontAskAgain;
    private Button button;
    private Button buttonCancel;
    List<Location> locations;
    private RadioGroup radioGroup;
    private EditText sensor_location_other;
    final int PRIVATE_ID = 200;
    final int OTHER_ID = 201;

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(2131492928);
        this.button = (Button) findViewById(2131296925);
        this.buttonCancel = (Button) findViewById(2131296926);
        EditText editText = (EditText) findViewById(2131296574);
        this.sensor_location_other = editText;
        editText.setEnabled(false);
        this.DontAskAgain = (CheckBox) findViewById(2131296972);
        this.radioGroup = (RadioGroup) findViewById(2131296796);
        addListenerOnButton();
        LinkedList linkedList = new LinkedList();
        this.locations = linkedList;
        linkedList.add(new Location("I don't wish to share", 200));
        this.locations.add(new Location("Upper arm", 1));
        this.locations.add(new Location("Thigh", 2));
        this.locations.add(new Location("Belly (abdomen)", 3));
        this.locations.add(new Location("Lower back", 4));
        this.locations.add(new Location("Buttocks", 5));
        this.locations.add(new Location("Other", 201));
        for (Location location : this.locations) {
            AddButton(location.location, location.location_id);
        }
        this.radioGroup.check(200);
    }

    private void AddButton(String str, int i) {
        RadioButton radioButton = new RadioButton(this);
        radioButton.setText(str);
        radioButton.setId(i);
        new RadioGroup.LayoutParams(-2, -2);
        this.radioGroup.addView(radioButton);
    }

    @Override
    public String getMenuName() {
        return menu_name;
    }

    public void addListenerOnButton() {
        this.button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int checkedRadioButtonId = NewSensorLocation.this.radioGroup.getCheckedRadioButtonId();
                String str = new String();
                if (checkedRadioButtonId == 201) {
                    str = NewSensorLocation.this.sensor_location_other.getText().toString();
                } else {
                    Iterator<Location> it = NewSensorLocation.this.locations.iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            break;
                        }
                        Location next = it.next();
                        if (checkedRadioButtonId == next.location_id) {
                            str = next.location;
                            break;
                        }
                    }
                }
                Toast.makeText(NewSensorLocation.this.getApplicationContext(), "Sensor locaton is " + str, 1).show();
                Log.d("NEW SENSOR", "Sensor location is " + str);
                Sensor.updateSensorLocation(str);
                PreferenceManager.getDefaultSharedPreferences(NewSensorLocation.this.getApplicationContext());
                NewSensorLocation.this.startActivity(new Intent(NewSensorLocation.this.getApplicationContext(), (Class<?>) Home.class));
                NewSensorLocation.this.finish();
            }
        });
        this.buttonCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PreferenceManager.getDefaultSharedPreferences(NewSensorLocation.this.getApplicationContext());
                NewSensorLocation.this.startActivity(new Intent(NewSensorLocation.this.getApplicationContext(), (Class<?>) Home.class));
                NewSensorLocation.this.finish();
            }
        });
        this.radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == 201) {
                    NewSensorLocation.this.sensor_location_other.setEnabled(true);
                    NewSensorLocation.this.sensor_location_other.requestFocus();
                } else {
                    NewSensorLocation.this.sensor_location_other.setEnabled(false);
                }
            }
        });
    }
}